From 37e3b34064958ed6cecf61fbdf33833be7558103 Mon Sep 17 00:00:00 2001 From: Matt Topol Date: Sat, 24 Jan 2026 16:00:45 -0500 Subject: [PATCH 1/2] feat(staging): add staging config --- auth/credentials.go | 4 +--- auth/oauth.go | 20 +++++++++++++++++--- cmd/dbc/auth.go | 8 ++++---- drivers.go | 2 +- 4 files changed, 23 insertions(+), 11 deletions(-) diff --git a/auth/credentials.go b/auth/credentials.go index 225086c..fc986c5 100644 --- a/auth/credentials.go +++ b/auth/credentials.go @@ -258,11 +258,9 @@ func PurgeCredentials() error { } func IsColumnarPrivateRegistry(u *url.URL) bool { - return u.Host == DefaultOauthURI + return u.Host == defaultOauthURI } -const licenseURI = "https://heimdall.columnar.tech/trial_license" - var ( ErrNoTrialLicense = errors.New("no trial license found") ErrTrialExpired = errors.New("trial license has expired") diff --git a/auth/oauth.go b/auth/oauth.go index ae85073..b18ead0 100644 --- a/auth/oauth.go +++ b/auth/oauth.go @@ -19,14 +19,28 @@ import ( "fmt" "net/http" "net/url" + "os" + "strconv" "strings" ) -const ( - DefaultOauthURI = "dbc-cdn-private.columnar.tech" - DefaultOauthClientID = "eSKuasirO0gUnGuNURPagErV3TSSFhEK" +var ( + defaultOauthURI = "dbc-cdn-private.columnar.tech" + defaultOauthClientID = "eSKuasirO0gUnGuNURPagErV3TSSFhEK" + licenseURI = "https://heimdall.columnar.tech/trial_license" ) +func init() { + if isStaging, _ := strconv.ParseBool(os.Getenv("DBC_USE_STAGING")); isStaging { + defaultOauthURI = "dbc-cdn-private-staging.columnar.tech" + defaultOauthClientID = "XZaxtg7XjYSTLNzgrLbYNrPOZzRiRpvW" + licenseURI = "https://dbc-cf-api-staging.columnar.workers.dev/trial_license" + } +} + +func DefaultOauthURI() string { return defaultOauthURI } +func DefaultOauthClientID() string { return defaultOauthClientID } + type OpenIDConfig struct { Issuer Uri `json:"issuer"` AuthorizationEndpoint Uri `json:"authorization_endpoint"` diff --git a/cmd/dbc/auth.go b/cmd/dbc/auth.go index d802ea7..17a977b 100644 --- a/cmd/dbc/auth.go +++ b/cmd/dbc/auth.go @@ -55,12 +55,12 @@ func (l LoginCmd) GetModelCustom(baseModel baseModel) tea.Model { } if l.RegistryURL == "" { - l.RegistryURL = auth.DefaultOauthURI + l.RegistryURL = auth.DefaultOauthURI() } - if l.RegistryURL == auth.DefaultOauthURI { + if l.RegistryURL == auth.DefaultOauthURI() { if l.ClientID == "" { - l.ClientID = auth.DefaultOauthClientID + l.ClientID = auth.DefaultOauthClientID() } } @@ -237,7 +237,7 @@ type LogoutCmd struct { func (l LogoutCmd) GetModelCustom(baseModel baseModel) tea.Model { if l.RegistryURL == "" { - l.RegistryURL = auth.DefaultOauthURI + l.RegistryURL = auth.DefaultOauthURI() } return logoutModel{ diff --git a/drivers.go b/drivers.go index 28bcf08..eadb8b3 100644 --- a/drivers.go +++ b/drivers.go @@ -63,7 +63,7 @@ func mustParseURL(u string) *url.URL { var ( registries = []Registry{ {BaseURL: mustParseURL("https://dbc-cdn.columnar.tech")}, - {BaseURL: mustParseURL("https://dbc-cdn-private.columnar.tech")}, + {BaseURL: mustParseURL("https://" + auth.DefaultOauthURI())}, } Version = "unknown" mid string From 438fce99b60e1d1ad4436c976bdb43a956559a09 Mon Sep 17 00:00:00 2001 From: Matt Topol Date: Sat, 24 Jan 2026 16:06:44 -0500 Subject: [PATCH 2/2] fix tests with funcs --- cmd/dbc/auth_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cmd/dbc/auth_test.go b/cmd/dbc/auth_test.go index 6f6f683..ef558be 100644 --- a/cmd/dbc/auth_test.go +++ b/cmd/dbc/auth_test.go @@ -37,8 +37,8 @@ func (suite *SubcommandTestSuite) TestLoginCmdDefaults() { loginM, ok := m.(loginModel) suite.Require().True(ok, "expected loginModel") - suite.Equal(auth.DefaultOauthURI, loginM.inputURI) - suite.Equal(auth.DefaultOauthClientID, loginM.oauthClientID) + suite.Equal(auth.DefaultOauthURI(), loginM.inputURI) + suite.Equal(auth.DefaultOauthClientID(), loginM.oauthClientID) suite.Equal("", loginM.apiKey) } @@ -66,7 +66,7 @@ func (suite *SubcommandTestSuite) TestLoginCmdWithClientID() { loginM, ok := m.(loginModel) suite.Require().True(ok, "expected loginModel") - suite.Equal(auth.DefaultOauthURI, loginM.inputURI) + suite.Equal(auth.DefaultOauthURI(), loginM.inputURI) suite.Equal("custom-client-id", loginM.oauthClientID) } @@ -180,7 +180,7 @@ func (suite *SubcommandTestSuite) TestLogoutCmdDefaults() { logoutM, ok := m.(logoutModel) suite.Require().True(ok, "expected logoutModel") - suite.Equal(auth.DefaultOauthURI, logoutM.inputURI) + suite.Equal(auth.DefaultOauthURI(), logoutM.inputURI) } func (suite *SubcommandTestSuite) TestLogoutCmdWithRegistryURL() {