Support canonical-domain-file configuration

This commit is contained in:
Max Stanley 2024-02-28 23:14:01 +00:00
parent a6e9510c07
commit ac1b9520a5
12 changed files with 95 additions and 68 deletions

View File

@ -79,6 +79,12 @@ var (
Usage: "specifies the domain from which raw repository content shall be served, not set disable raw content hosting", Usage: "specifies the domain from which raw repository content shall be served, not set disable raw content hosting",
EnvVars: []string{"RAW_DOMAIN"}, EnvVars: []string{"RAW_DOMAIN"},
}, },
&cli.StringFlag{
Name: "canonical-domain-file",
Usage: "specifies the file from which the canonical domain shall be specified in",
EnvVars: []string{"CANONICAL_DOMAIN_FILE"},
Value: ".domains",
},
// ######################### // #########################
// ### Page Server Setup ### // ### Page Server Setup ###

View File

@ -9,15 +9,16 @@ type Config struct {
} }
type ServerConfig struct { type ServerConfig struct {
Host string `default:"[::]"` Host string `default:"[::]"`
Port uint16 `default:"443"` Port uint16 `default:"443"`
HttpPort uint16 `default:"80"` HttpPort uint16 `default:"80"`
HttpServerEnabled bool `default:"true"` HttpServerEnabled bool `default:"true"`
MainDomain string MainDomain string
RawDomain string RawDomain string
PagesBranches []string CanonicalDomainFile string `default:".domains"`
AllowedCorsDomains []string PagesBranches []string
BlacklistedPaths []string AllowedCorsDomains []string
BlacklistedPaths []string
} }
type GiteaConfig struct { type GiteaConfig struct {

View File

@ -75,6 +75,9 @@ func mergeServerConfig(ctx *cli.Context, config *ServerConfig) {
if ctx.IsSet("raw-domain") { if ctx.IsSet("raw-domain") {
config.RawDomain = ctx.String("raw-domain") config.RawDomain = ctx.String("raw-domain")
} }
if ctx.IsSet("canonical-domain-file") {
config.CanonicalDomainFile = ctx.String("canonical-domain-file")
}
if ctx.IsSet("pages-branch") { if ctx.IsSet("pages-branch") {
config.PagesBranches = ctx.StringSlice("pages-branch") config.PagesBranches = ctx.StringSlice("pages-branch")
} }

View File

@ -136,15 +136,16 @@ func TestMergeConfigShouldReplaceAllExistingValuesGivenAllArgsExist(t *testing.T
cfg := &Config{ cfg := &Config{
LogLevel: "original", LogLevel: "original",
Server: ServerConfig{ Server: ServerConfig{
Host: "original", Host: "original",
Port: 8080, Port: 8080,
HttpPort: 80, HttpPort: 80,
HttpServerEnabled: false, HttpServerEnabled: false,
MainDomain: "original", MainDomain: "original",
RawDomain: "original", RawDomain: "original",
PagesBranches: []string{"original"}, CanonicalDomainFile: "original",
AllowedCorsDomains: []string{"original"}, PagesBranches: []string{"original"},
BlacklistedPaths: []string{"original"}, AllowedCorsDomains: []string{"original"},
BlacklistedPaths: []string{"original"},
}, },
Gitea: GiteaConfig{ Gitea: GiteaConfig{
Root: "original", Root: "original",
@ -175,15 +176,16 @@ func TestMergeConfigShouldReplaceAllExistingValuesGivenAllArgsExist(t *testing.T
expectedConfig := &Config{ expectedConfig := &Config{
LogLevel: "changed", LogLevel: "changed",
Server: ServerConfig{ Server: ServerConfig{
Host: "changed", Host: "changed",
Port: 8443, Port: 8443,
HttpPort: 443, HttpPort: 443,
HttpServerEnabled: true, HttpServerEnabled: true,
MainDomain: "changed", MainDomain: "changed",
RawDomain: "changed", RawDomain: "changed",
PagesBranches: []string{"changed"}, CanonicalDomainFile: "changed",
AllowedCorsDomains: []string{"changed"}, PagesBranches: []string{"changed"},
BlacklistedPaths: append([]string{"changed"}, ALWAYS_BLACKLISTED_PATHS...), AllowedCorsDomains: []string{"changed"},
BlacklistedPaths: append([]string{"changed"}, ALWAYS_BLACKLISTED_PATHS...),
}, },
Gitea: GiteaConfig{ Gitea: GiteaConfig{
Root: "changed", Root: "changed",
@ -218,6 +220,7 @@ func TestMergeConfigShouldReplaceAllExistingValuesGivenAllArgsExist(t *testing.T
// Server // Server
"--pages-domain", "changed", "--pages-domain", "changed",
"--raw-domain", "changed", "--raw-domain", "changed",
"--canonical-domain-file", "changed",
"--allowed-cors-domains", "changed", "--allowed-cors-domains", "changed",
"--blacklisted-paths", "changed", "--blacklisted-paths", "changed",
"--pages-branch", "changed", "--pages-branch", "changed",
@ -270,27 +273,29 @@ func TestMergeServerConfigShouldReplaceAllExistingValuesGivenAllArgsExist(t *tes
t, t,
func(ctx *cli.Context) error { func(ctx *cli.Context) error {
cfg := &ServerConfig{ cfg := &ServerConfig{
Host: "original", Host: "original",
Port: 8080, Port: 8080,
HttpPort: 80, HttpPort: 80,
HttpServerEnabled: false, HttpServerEnabled: false,
MainDomain: "original", MainDomain: "original",
RawDomain: "original", RawDomain: "original",
AllowedCorsDomains: []string{"original"}, CanonicalDomainFile: "original",
BlacklistedPaths: []string{"original"}, AllowedCorsDomains: []string{"original"},
BlacklistedPaths: []string{"original"},
} }
mergeServerConfig(ctx, cfg) mergeServerConfig(ctx, cfg)
expectedConfig := &ServerConfig{ expectedConfig := &ServerConfig{
Host: "changed", Host: "changed",
Port: 8443, Port: 8443,
HttpPort: 443, HttpPort: 443,
HttpServerEnabled: true, HttpServerEnabled: true,
MainDomain: "changed", MainDomain: "changed",
RawDomain: "changed", RawDomain: "changed",
AllowedCorsDomains: fixArrayFromCtx(ctx, "allowed-cors-domains", []string{"changed"}), CanonicalDomainFile: "changed",
BlacklistedPaths: fixArrayFromCtx(ctx, "blacklisted-paths", append([]string{"changed"}, ALWAYS_BLACKLISTED_PATHS...)), AllowedCorsDomains: fixArrayFromCtx(ctx, "allowed-cors-domains", []string{"changed"}),
BlacklistedPaths: fixArrayFromCtx(ctx, "blacklisted-paths", append([]string{"changed"}, ALWAYS_BLACKLISTED_PATHS...)),
} }
assert.Equal(t, expectedConfig, cfg) assert.Equal(t, expectedConfig, cfg)
@ -300,6 +305,7 @@ func TestMergeServerConfigShouldReplaceAllExistingValuesGivenAllArgsExist(t *tes
[]string{ []string{
"--pages-domain", "changed", "--pages-domain", "changed",
"--raw-domain", "changed", "--raw-domain", "changed",
"--canonical-domain-file", "changed",
"--allowed-cors-domains", "changed", "--allowed-cors-domains", "changed",
"--blacklisted-paths", "changed", "--blacklisted-paths", "changed",
"--host", "changed", "--host", "changed",
@ -323,6 +329,7 @@ func TestMergeServerConfigShouldReplaceOnlyOneValueExistingValueGivenOnlyOneArgE
{args: []string{"--enable-http-server"}, callback: func(sc *ServerConfig) { sc.HttpServerEnabled = true }}, {args: []string{"--enable-http-server"}, callback: func(sc *ServerConfig) { sc.HttpServerEnabled = true }},
{args: []string{"--pages-domain", "changed"}, callback: func(sc *ServerConfig) { sc.MainDomain = "changed" }}, {args: []string{"--pages-domain", "changed"}, callback: func(sc *ServerConfig) { sc.MainDomain = "changed" }},
{args: []string{"--raw-domain", "changed"}, callback: func(sc *ServerConfig) { sc.RawDomain = "changed" }}, {args: []string{"--raw-domain", "changed"}, callback: func(sc *ServerConfig) { sc.RawDomain = "changed" }},
{args: []string{"--canonical-domain-file", "changed"}, callback: func(sc *ServerConfig) { sc.CanonicalDomainFile = "changed" }},
{args: []string{"--pages-branch", "changed"}, callback: func(sc *ServerConfig) { sc.PagesBranches = []string{"changed"} }}, {args: []string{"--pages-branch", "changed"}, callback: func(sc *ServerConfig) { sc.PagesBranches = []string{"changed"} }},
{args: []string{"--allowed-cors-domains", "changed"}, callback: func(sc *ServerConfig) { sc.AllowedCorsDomains = []string{"changed"} }}, {args: []string{"--allowed-cors-domains", "changed"}, callback: func(sc *ServerConfig) { sc.AllowedCorsDomains = []string{"changed"} }},
{args: []string{"--blacklisted-paths", "changed"}, callback: func(sc *ServerConfig) { sc.BlacklistedPaths = []string{"changed"} }}, {args: []string{"--blacklisted-paths", "changed"}, callback: func(sc *ServerConfig) { sc.BlacklistedPaths = []string{"changed"} }},
@ -333,15 +340,16 @@ func TestMergeServerConfigShouldReplaceOnlyOneValueExistingValueGivenOnlyOneArgE
t, t,
func(ctx *cli.Context) error { func(ctx *cli.Context) error {
cfg := ServerConfig{ cfg := ServerConfig{
Host: "original", Host: "original",
Port: 8080, Port: 8080,
HttpPort: 80, HttpPort: 80,
HttpServerEnabled: false, HttpServerEnabled: false,
MainDomain: "original", MainDomain: "original",
RawDomain: "original", RawDomain: "original",
PagesBranches: []string{"original"}, CanonicalDomainFile: "original",
AllowedCorsDomains: []string{"original"}, PagesBranches: []string{"original"},
BlacklistedPaths: []string{"original"}, AllowedCorsDomains: []string{"original"},
BlacklistedPaths: []string{"original"},
} }
expectedConfig := cfg expectedConfig := cfg

View File

@ -31,6 +31,7 @@ func TLSConfig(mainDomainSuffix string,
giteaClient *gitea.Client, giteaClient *gitea.Client,
acmeClient *AcmeClient, acmeClient *AcmeClient,
firstDefaultBranch string, firstDefaultBranch string,
canonicalDomainConfig string,
keyCache, challengeCache, dnsLookupCache, canonicalDomainCache cache.ICache, keyCache, challengeCache, dnsLookupCache, canonicalDomainCache cache.ICache,
certDB database.CertDB, certDB database.CertDB,
) *tls.Config { ) *tls.Config {
@ -79,7 +80,7 @@ func TLSConfig(mainDomainSuffix string,
TargetRepo: targetRepo, TargetRepo: targetRepo,
TargetBranch: targetBranch, TargetBranch: targetBranch,
} }
_, valid := targetOpt.CheckCanonicalDomain(giteaClient, domain, mainDomainSuffix, canonicalDomainCache) _, valid := targetOpt.CheckCanonicalDomain(giteaClient, domain, mainDomainSuffix, canonicalDomainConfig, canonicalDomainCache)
if !valid { if !valid {
// We shouldn't obtain a certificate when we cannot check if the // We shouldn't obtain a certificate when we cannot check if the
// repository has specified this domain in the `.domains` file. // repository has specified this domain in the `.domains` file.

View File

@ -92,6 +92,7 @@ func Handler(
cfg.MainDomain, cfg.MainDomain,
trimmedHost, trimmedHost,
pathElements, pathElements,
cfg.CanonicalDomainFile,
canonicalDomainCache, redirectsCache) canonicalDomainCache, redirectsCache)
} else if strings.HasSuffix(trimmedHost, cfg.MainDomain) { } else if strings.HasSuffix(trimmedHost, cfg.MainDomain) {
log.Debug().Msg("subdomain request detected") log.Debug().Msg("subdomain request detected")
@ -100,6 +101,7 @@ func Handler(
cfg.PagesBranches, cfg.PagesBranches,
trimmedHost, trimmedHost,
pathElements, pathElements,
cfg.CanonicalDomainFile,
canonicalDomainCache, redirectsCache) canonicalDomainCache, redirectsCache)
} else { } else {
log.Debug().Msg("custom domain request detected") log.Debug().Msg("custom domain request detected")
@ -108,6 +110,7 @@ func Handler(
trimmedHost, trimmedHost,
pathElements, pathElements,
cfg.PagesBranches[0], cfg.PagesBranches[0],
cfg.CanonicalDomainFile,
dnsLookupCache, canonicalDomainCache, redirectsCache) dnsLookupCache, canonicalDomainCache, redirectsCache)
} }
} }

View File

@ -19,6 +19,7 @@ func handleCustomDomain(log zerolog.Logger, ctx *context.Context, giteaClient *g
trimmedHost string, trimmedHost string,
pathElements []string, pathElements []string,
firstDefaultBranch string, firstDefaultBranch string,
canonicalDomainConfig string,
dnsLookupCache, canonicalDomainCache, redirectsCache cache.ICache, dnsLookupCache, canonicalDomainCache, redirectsCache cache.ICache,
) { ) {
// Serve pages from custom domains // Serve pages from custom domains
@ -47,7 +48,7 @@ func handleCustomDomain(log zerolog.Logger, ctx *context.Context, giteaClient *g
TargetBranch: targetBranch, TargetBranch: targetBranch,
TargetPath: path.Join(pathParts...), TargetPath: path.Join(pathParts...),
}, canonicalLink); works { }, canonicalLink); works {
canonicalDomain, valid := targetOpt.CheckCanonicalDomain(giteaClient, trimmedHost, mainDomainSuffix, canonicalDomainCache) canonicalDomain, valid := targetOpt.CheckCanonicalDomain(giteaClient, trimmedHost, mainDomainSuffix, canonicalDomainConfig, canonicalDomainCache)
if !valid { if !valid {
html.ReturnErrorPage(ctx, "domain not specified in <code>.domains</code> file", http.StatusMisdirectedRequest) html.ReturnErrorPage(ctx, "domain not specified in <code>.domains</code> file", http.StatusMisdirectedRequest)
return return
@ -64,7 +65,7 @@ func handleCustomDomain(log zerolog.Logger, ctx *context.Context, giteaClient *g
} }
log.Debug().Msg("tryBranch, now trying upstream 7") log.Debug().Msg("tryBranch, now trying upstream 7")
tryUpstream(ctx, giteaClient, mainDomainSuffix, trimmedHost, targetOpt, canonicalDomainCache, redirectsCache) tryUpstream(ctx, giteaClient, mainDomainSuffix, trimmedHost, targetOpt, canonicalDomainConfig, canonicalDomainCache, redirectsCache)
return return
} }

View File

@ -19,6 +19,7 @@ func handleRaw(log zerolog.Logger, ctx *context.Context, giteaClient *gitea.Clie
mainDomainSuffix string, mainDomainSuffix string,
trimmedHost string, trimmedHost string,
pathElements []string, pathElements []string,
canonicalDomainConfig string,
canonicalDomainCache, redirectsCache cache.ICache, canonicalDomainCache, redirectsCache cache.ICache,
) { ) {
// Serve raw content from RawDomain // Serve raw content from RawDomain
@ -45,7 +46,7 @@ func handleRaw(log zerolog.Logger, ctx *context.Context, giteaClient *gitea.Clie
TargetPath: path.Join(pathElements[3:]...), TargetPath: path.Join(pathElements[3:]...),
}, true); works { }, true); works {
log.Trace().Msg("tryUpstream: serve raw domain with specified branch") log.Trace().Msg("tryUpstream: serve raw domain with specified branch")
tryUpstream(ctx, giteaClient, mainDomainSuffix, trimmedHost, targetOpt, canonicalDomainCache, redirectsCache) tryUpstream(ctx, giteaClient, mainDomainSuffix, trimmedHost, targetOpt, canonicalDomainConfig, canonicalDomainCache, redirectsCache)
return return
} }
log.Debug().Msg("missing branch info") log.Debug().Msg("missing branch info")
@ -62,7 +63,7 @@ func handleRaw(log zerolog.Logger, ctx *context.Context, giteaClient *gitea.Clie
TargetPath: path.Join(pathElements[2:]...), TargetPath: path.Join(pathElements[2:]...),
}, true); works { }, true); works {
log.Trace().Msg("tryUpstream: serve raw domain with default branch") log.Trace().Msg("tryUpstream: serve raw domain with default branch")
tryUpstream(ctx, giteaClient, mainDomainSuffix, trimmedHost, targetOpt, canonicalDomainCache, redirectsCache) tryUpstream(ctx, giteaClient, mainDomainSuffix, trimmedHost, targetOpt, canonicalDomainConfig, canonicalDomainCache, redirectsCache)
} else { } else {
html.ReturnErrorPage(ctx, html.ReturnErrorPage(ctx,
fmt.Sprintf("raw domain could not find repo <code>%s/%s</code> or repo is empty", targetOpt.TargetOwner, targetOpt.TargetRepo), fmt.Sprintf("raw domain could not find repo <code>%s/%s</code> or repo is empty", targetOpt.TargetOwner, targetOpt.TargetRepo),

View File

@ -21,6 +21,7 @@ func handleSubDomain(log zerolog.Logger, ctx *context.Context, giteaClient *gite
defaultPagesBranches []string, defaultPagesBranches []string,
trimmedHost string, trimmedHost string,
pathElements []string, pathElements []string,
canonicalDomainConfig string,
canonicalDomainCache, redirectsCache cache.ICache, canonicalDomainCache, redirectsCache cache.ICache,
) { ) {
// Serve pages from subdomains of MainDomainSuffix // Serve pages from subdomains of MainDomainSuffix
@ -53,7 +54,7 @@ func handleSubDomain(log zerolog.Logger, ctx *context.Context, giteaClient *gite
TargetPath: path.Join(pathElements[2:]...), TargetPath: path.Join(pathElements[2:]...),
}, true); works { }, true); works {
log.Trace().Msg("tryUpstream: serve with specified repo and branch") log.Trace().Msg("tryUpstream: serve with specified repo and branch")
tryUpstream(ctx, giteaClient, mainDomainSuffix, trimmedHost, targetOpt, canonicalDomainCache, redirectsCache) tryUpstream(ctx, giteaClient, mainDomainSuffix, trimmedHost, targetOpt, canonicalDomainConfig, canonicalDomainCache, redirectsCache)
} else { } else {
html.ReturnErrorPage( html.ReturnErrorPage(
ctx, ctx,
@ -85,7 +86,7 @@ func handleSubDomain(log zerolog.Logger, ctx *context.Context, giteaClient *gite
TargetPath: path.Join(pathElements[1:]...), TargetPath: path.Join(pathElements[1:]...),
}, true); works { }, true); works {
log.Trace().Msg("tryUpstream: serve default pages repo with specified branch") log.Trace().Msg("tryUpstream: serve default pages repo with specified branch")
tryUpstream(ctx, giteaClient, mainDomainSuffix, trimmedHost, targetOpt, canonicalDomainCache, redirectsCache) tryUpstream(ctx, giteaClient, mainDomainSuffix, trimmedHost, targetOpt, canonicalDomainConfig, canonicalDomainCache, redirectsCache)
} else { } else {
html.ReturnErrorPage( html.ReturnErrorPage(
ctx, ctx,
@ -110,7 +111,7 @@ func handleSubDomain(log zerolog.Logger, ctx *context.Context, giteaClient *gite
TargetPath: path.Join(pathElements[1:]...), TargetPath: path.Join(pathElements[1:]...),
}, false); works { }, false); works {
log.Debug().Msg("tryBranch, now trying upstream 5") log.Debug().Msg("tryBranch, now trying upstream 5")
tryUpstream(ctx, giteaClient, mainDomainSuffix, trimmedHost, targetOpt, canonicalDomainCache, redirectsCache) tryUpstream(ctx, giteaClient, mainDomainSuffix, trimmedHost, targetOpt, canonicalDomainConfig, canonicalDomainCache, redirectsCache)
return return
} }
} }
@ -126,7 +127,7 @@ func handleSubDomain(log zerolog.Logger, ctx *context.Context, giteaClient *gite
TargetPath: path.Join(pathElements...), TargetPath: path.Join(pathElements...),
}, false); works { }, false); works {
log.Debug().Msg("tryBranch, now trying upstream 6") log.Debug().Msg("tryBranch, now trying upstream 6")
tryUpstream(ctx, giteaClient, mainDomainSuffix, trimmedHost, targetOpt, canonicalDomainCache, redirectsCache) tryUpstream(ctx, giteaClient, mainDomainSuffix, trimmedHost, targetOpt, canonicalDomainConfig, canonicalDomainCache, redirectsCache)
return return
} }
} }
@ -141,7 +142,7 @@ func handleSubDomain(log zerolog.Logger, ctx *context.Context, giteaClient *gite
TargetPath: path.Join(pathElements...), TargetPath: path.Join(pathElements...),
}, false); works { }, false); works {
log.Debug().Msg("tryBranch, now trying upstream 6") log.Debug().Msg("tryBranch, now trying upstream 6")
tryUpstream(ctx, giteaClient, mainDomainSuffix, trimmedHost, targetOpt, canonicalDomainCache, redirectsCache) tryUpstream(ctx, giteaClient, mainDomainSuffix, trimmedHost, targetOpt, canonicalDomainConfig, canonicalDomainCache, redirectsCache)
return return
} }

View File

@ -17,12 +17,13 @@ import (
func tryUpstream(ctx *context.Context, giteaClient *gitea.Client, func tryUpstream(ctx *context.Context, giteaClient *gitea.Client,
mainDomainSuffix, trimmedHost string, mainDomainSuffix, trimmedHost string,
options *upstream.Options, options *upstream.Options,
canonicalDomainConfig string,
canonicalDomainCache cache.ICache, canonicalDomainCache cache.ICache,
redirectsCache cache.ICache, redirectsCache cache.ICache,
) { ) {
// check if a canonical domain exists on a request on MainDomain // check if a canonical domain exists on a request on MainDomain
if strings.HasSuffix(trimmedHost, mainDomainSuffix) && !options.ServeRaw { if strings.HasSuffix(trimmedHost, mainDomainSuffix) && !options.ServeRaw {
canonicalDomain, _ := options.CheckCanonicalDomain(giteaClient, "", mainDomainSuffix, canonicalDomainCache) canonicalDomain, _ := options.CheckCanonicalDomain(giteaClient, "", mainDomainSuffix, canonicalDomainConfig, canonicalDomainCache)
if !strings.HasSuffix(strings.SplitN(canonicalDomain, "/", 2)[0], mainDomainSuffix) { if !strings.HasSuffix(strings.SplitN(canonicalDomain, "/", 2)[0], mainDomainSuffix) {
canonicalPath := ctx.Req.RequestURI canonicalPath := ctx.Req.RequestURI
if options.TargetRepo != defaultPagesRepo { if options.TargetRepo != defaultPagesRepo {

View File

@ -108,6 +108,7 @@ func Serve(ctx *cli.Context) error {
giteaClient, giteaClient,
acmeClient, acmeClient,
cfg.Server.PagesBranches[0], cfg.Server.PagesBranches[0],
cfg.Server.CanonicalDomainFile,
keyCache, challengeCache, dnsLookupCache, canonicalDomainCache, keyCache, challengeCache, dnsLookupCache, canonicalDomainCache,
certDB, certDB,
)) ))

View File

@ -14,12 +14,12 @@ import (
// canonicalDomainCacheTimeout specifies the timeout for the canonical domain cache. // canonicalDomainCacheTimeout specifies the timeout for the canonical domain cache.
var canonicalDomainCacheTimeout = 15 * time.Minute var canonicalDomainCacheTimeout = 15 * time.Minute
const canonicalDomainConfig = ".domains"
// CheckCanonicalDomain returns the canonical domain specified in the repo (using the `.domains` file). // CheckCanonicalDomain returns the canonical domain specified in the repo (using the `.domains` file).
func (o *Options) CheckCanonicalDomain(giteaClient *gitea.Client, actualDomain, mainDomainSuffix string, canonicalDomainCache cache.ICache) (domain string, valid bool) { func (o *Options) CheckCanonicalDomain(giteaClient *gitea.Client, actualDomain, mainDomainSuffix, canonicalDomainConfig string, canonicalDomainCache cache.ICache) (domain string, valid bool) {
canonicalDomainCacheKey := o.TargetOwner + "/" + o.TargetRepo + "/" + o.TargetBranch + "/" + canonicalDomainConfig
// Check if this request is cached. // Check if this request is cached.
if cachedValue, ok := canonicalDomainCache.Get(o.TargetOwner + "/" + o.TargetRepo + "/" + o.TargetBranch); ok { if cachedValue, ok := canonicalDomainCache.Get(canonicalDomainCacheKey); ok {
domains := cachedValue.([]string) domains := cachedValue.([]string)
for _, domain := range domains { for _, domain := range domains {
if domain == actualDomain { if domain == actualDomain {
@ -62,7 +62,7 @@ func (o *Options) CheckCanonicalDomain(giteaClient *gitea.Client, actualDomain,
} }
// Add result to cache. // Add result to cache.
_ = canonicalDomainCache.Set(o.TargetOwner+"/"+o.TargetRepo+"/"+o.TargetBranch, domains, canonicalDomainCacheTimeout) _ = canonicalDomainCache.Set(canonicalDomainCacheKey, domains, canonicalDomainCacheTimeout)
// Return the first domain from the list and return if any of the domains // Return the first domain from the list and return if any of the domains
// matched the requested domain. // matched the requested domain.