Skip to content

Commit 9276942

Browse files
authored
fix(infra): define Configuration type before its methods (#2695)
Moves the BillingMode, UsesOrgBilling and BillingServiceURL methods below the Configuration struct definition to satisfy gocritic typeDefFirst. The violation is latent on main: normal PR lint hides it via only-new-issues, but the merge queue cannot read the base ref to diff against and reports all issues, which blocks every PR from merging.
1 parent 99b60f8 commit 9276942

1 file changed

Lines changed: 30 additions & 30 deletions

File tree

config/config.go

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -36,36 +36,6 @@ const (
3636
// OSS or self-hosted instance has not configured an explicit billing URL.
3737
const DefaultOverwatchHost = "https://overwatch.getconvoy.cloud"
3838

39-
func (c Configuration) BillingMode(instanceLicenseKey string) BillingMode {
40-
if strings.TrimSpace(c.Billing.APIKey) != "" {
41-
return BillingModeCloud
42-
}
43-
if strings.TrimSpace(instanceLicenseKey) != "" {
44-
return BillingModeLicensedSelfHosted
45-
}
46-
return BillingModeOSS
47-
}
48-
49-
func (c Configuration) UsesOrgBilling() bool {
50-
return c.BillingMode("") == BillingModeCloud
51-
}
52-
53-
// BillingServiceURL returns the billing service base URL to use. OSS and
54-
// self-hosted instances (no billing API key) default to prod Overwatch so the
55-
// plan catalog, guest checkout, and license management work without operator
56-
// config, mirroring the SSO/license service defaults. Cloud (API key set) keeps
57-
// requiring an explicit URL: an empty URL there is a misconfiguration that
58-
// Billing.Validate already fails closed on, so this never invents a cloud host.
59-
func (c Configuration) BillingServiceURL() string {
60-
if url := strings.TrimSpace(c.Billing.URL); url != "" {
61-
return url
62-
}
63-
if strings.TrimSpace(c.Billing.APIKey) == "" {
64-
return DefaultOverwatchHost
65-
}
66-
return ""
67-
}
68-
6939
var cfgSingleton atomic.Value
7040

7141
var DefaultConfiguration = Configuration{
@@ -570,6 +540,36 @@ type Configuration struct {
570540
Billing BillingConfiguration `json:"billing"`
571541
}
572542

543+
func (c Configuration) BillingMode(instanceLicenseKey string) BillingMode {
544+
if strings.TrimSpace(c.Billing.APIKey) != "" {
545+
return BillingModeCloud
546+
}
547+
if strings.TrimSpace(instanceLicenseKey) != "" {
548+
return BillingModeLicensedSelfHosted
549+
}
550+
return BillingModeOSS
551+
}
552+
553+
func (c Configuration) UsesOrgBilling() bool {
554+
return c.BillingMode("") == BillingModeCloud
555+
}
556+
557+
// BillingServiceURL returns the billing service base URL to use. OSS and
558+
// self-hosted instances (no billing API key) default to prod Overwatch so the
559+
// plan catalog, guest checkout, and license management work without operator
560+
// config, mirroring the SSO/license service defaults. Cloud (API key set) keeps
561+
// requiring an explicit URL: an empty URL there is a misconfiguration that
562+
// Billing.Validate already fails closed on, so this never invents a cloud host.
563+
func (c Configuration) BillingServiceURL() string {
564+
if url := strings.TrimSpace(c.Billing.URL); url != "" {
565+
return url
566+
}
567+
if strings.TrimSpace(c.Billing.APIKey) == "" {
568+
return DefaultOverwatchHost
569+
}
570+
return ""
571+
}
572+
573573
type DispatcherConfiguration struct {
574574
InsecureSkipVerify bool `json:"insecure_skip_verify" envconfig:"CONVOY_DISPATCHER_INSECURE_SKIP_VERIFY"`
575575
AllowList []string `json:"allow_list" envconfig:"CONVOY_DISPATCHER_ALLOW_LIST"`

0 commit comments

Comments
 (0)