mirror of
https://code.forgejo.org/forgejo/runner.git
synced 2025-09-30 19:22:09 +00:00
fix: Correctly override the value of Forgejo-Cache-Host
when ACTIONS_CACHE_URL is overridden. (#1027)
This fixes a bug currently preventing use of an external cache server in the Codeberg runner setup. <!--start release-notes-assistant--> <!--URL:https://code.forgejo.org/forgejo/runner--> - bug fixes - [PR](https://code.forgejo.org/forgejo/runner/pulls/1027): <!--number 1027 --><!--line 0 --><!--description Zml4OiBDb3JyZWN0bHkgb3ZlcnJpZGUgdGhlIHZhbHVlIG9mIGBGb3JnZWpvLUNhY2hlLUhvc3RgIHdoZW4gQUNUSU9OU19DQUNIRV9VUkwgaXMgb3ZlcnJpZGRlbi4=-->fix: Correctly override the value of `Forgejo-Cache-Host` when ACTIONS_CACHE_URL is overridden.<!--description--> <!--end release-notes-assistant--> Co-authored-by: Vivian <me@vivstuff.gay> Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/1027 Reviewed-by: Michael Kriese <michael.kriese@gmx.de> Reviewed-by: Mathieu Fenniak <mfenniak@noreply.code.forgejo.org> Co-authored-by: Kwonunn <kwonunn@noreply.code.forgejo.org> Co-committed-by: Kwonunn <kwonunn@noreply.code.forgejo.org>
This commit is contained in:
parent
8debbe699e
commit
6bdb7ed9c7
2 changed files with 8 additions and 6 deletions
|
@ -37,7 +37,8 @@ type Handler struct {
|
|||
|
||||
outboundIP string
|
||||
|
||||
cacheServerHost string
|
||||
cacheServerHost string
|
||||
cacheProxyHostOverride string
|
||||
|
||||
cacheSecret string
|
||||
|
||||
|
@ -55,7 +56,7 @@ func (h *Handler) CreateRunData(fullName, runNumber, timestamp, writeIsolationKe
|
|||
}
|
||||
}
|
||||
|
||||
func StartHandler(targetHost, outboundIP string, port uint16, cacheSecret string, logger logrus.FieldLogger) (*Handler, error) {
|
||||
func StartHandler(targetHost, outboundIP string, port uint16, cacheProxyHostOverride, cacheSecret string, logger logrus.FieldLogger) (*Handler, error) {
|
||||
h := &Handler{}
|
||||
|
||||
if logger == nil {
|
||||
|
@ -77,6 +78,7 @@ func StartHandler(targetHost, outboundIP string, port uint16, cacheSecret string
|
|||
}
|
||||
|
||||
h.cacheServerHost = targetHost
|
||||
h.cacheProxyHostOverride = cacheProxyHostOverride
|
||||
|
||||
proxy, err := h.newReverseProxy(targetHost)
|
||||
if err != nil {
|
||||
|
@ -153,7 +155,9 @@ func (h *Handler) newReverseProxy(targetHost string) (*httputil.ReverseProxy, er
|
|||
}
|
||||
|
||||
func (h *Handler) ExternalURL() string {
|
||||
// TODO: make the external url configurable if necessary
|
||||
if h.cacheProxyHostOverride != "" {
|
||||
return h.cacheProxyHostOverride
|
||||
}
|
||||
return fmt.Sprintf("http://%s", net.JoinHostPort(h.outboundIP, strconv.Itoa(h.listener.Addr().(*net.TCPAddr).Port)))
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue