File tree Expand file tree Collapse file tree 3 files changed +10
-4
lines changed
Expand file tree Collapse file tree 3 files changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -274,6 +274,8 @@ func IsColumnarPrivateRegistry(u *url.URL) bool {
274274
275275const licenseURI = "https://heimdall.columnar.tech/trial_license"
276276
277+ var ErrNoTrialLicense = errors .New ("no trial license found" )
278+
277279func FetchColumnarLicense (cred * Credential ) error {
278280 licensePath := filepath .Join (filepath .Dir (credPath ), "columnar.lic" )
279281 _ , err := os .Stat (licensePath )
@@ -298,7 +300,7 @@ func FetchColumnarLicense(cred *Credential) error {
298300
299301 _ , ok := tk .Claims .(jwt.MapClaims )["urn:columnar:trial_start" ]
300302 if ! ok {
301- return nil // not a trial account
303+ return ErrNoTrialLicense
302304 }
303305 authToken = "Bearer " + cred .GetAuthToken ()
304306 }
Original file line number Diff line number Diff line change @@ -195,12 +195,11 @@ func (m loginModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
195195 return err
196196 }
197197
198- if msg . RegistryURL . Host == auth . DefaultOauthURI {
198+ if auth . IsColumnarPrivateRegistry (( * url . URL )( & msg . RegistryURL )) {
199199 return auth .FetchColumnarLicense (& msg )
200200 }
201201 return nil
202- }, tea .Println ("Authentication successful!" ),
203- tea .Quit )
202+ }, tea .Println ("Authentication successful!" ), tea .Quit )
204203 }
205204
206205 base , cmd := m .baseModel .Update (msg )
Original file line number Diff line number Diff line change 1515package main
1616
1717import (
18+ "errors"
1819 "fmt"
1920 "os"
2021 "slices"
@@ -23,6 +24,7 @@ import (
2324 tea "github.com/charmbracelet/bubbletea"
2425 "github.com/charmbracelet/lipgloss"
2526 "github.com/columnar-tech/dbc"
27+ "github.com/columnar-tech/dbc/auth"
2628 "github.com/columnar-tech/dbc/cmd/dbc/completions"
2729 "github.com/columnar-tech/dbc/config"
2830 "github.com/mattn/go-isatty"
@@ -118,6 +120,9 @@ func (m baseModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
118120 return m , tea .Quit
119121 }
120122 case error :
123+ if errors .Is (msg , auth .ErrNoTrialLicense ) {
124+ return m , tea .Println (errStyle .Render ("Could not download license, trial not started" ))
125+ }
121126 m .status = 1
122127 return m , tea .Sequence (tea .Println ("Error: " , msg .Error ()), tea .Quit )
123128 }
You can’t perform that action at this time.
0 commit comments