Skip to content

Commit ec40876

Browse files
committed
local cli
1 parent 6edcb12 commit ec40876

7 files changed

Lines changed: 24 additions & 16 deletions

File tree

pkg/auth/auth.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ func defaultAuthFunc(url, code string) {
223223
}
224224
urlType := color.New(color.FgCyan, color.Bold).SprintFunc()
225225
fmt.Println("Browser link: " + urlType(url) + "\n")
226-
fmt.Println("Alternatively, get CLI Command (\"Login via CLI\"): ", urlType(fmt.Sprintf("%s/profile?login=cli", config.ConsoleBaseURL)))
226+
fmt.Println("Alternatively, get CLI Command (\"Login via CLI\"): ", urlType(fmt.Sprintf("%s/profile?login=cli", config.GlobalConfig.GetConsoleBaseURL())))
227227
fmt.Print("\n")
228228
caretType := color.New(color.FgGreen, color.Bold).SprintFunc()
229229
enterType := color.New(color.FgGreen, color.Bold).SprintFunc()
@@ -245,7 +245,7 @@ func defaultAuthFunc(url, code string) {
245245
func skipBrowserAuthFunc(url, _ string) {
246246
urlType := color.New(color.FgCyan, color.Bold).SprintFunc()
247247
fmt.Println("Please copy", urlType(url), "and paste it in your browser.")
248-
fmt.Println("Alternatively, get CLI Command (\"Login via CLI\"): ", urlType(fmt.Sprintf("%s/profile?login=cli", config.ConsoleBaseURL)))
248+
fmt.Println("Alternatively, get CLI Command (\"Login via CLI\"): ", urlType(fmt.Sprintf("%s/profile?login=cli", config.GlobalConfig.GetConsoleBaseURL())))
249249
fmt.Println("Waiting for login to complete in browser... Ctrl+C to use CLI command instead.")
250250
}
251251

@@ -402,10 +402,10 @@ func StandardLogin(authProvider string, email string, tokens *entity.AuthTokens)
402402

403403
kasAuthenticator := NewKasAuthenticator(
404404
email,
405-
"https://api.ngc.nvidia.com",
405+
config.GlobalConfig.GetBrevAuthURL(),
406406
"https://login.nvidia.com",
407407
shouldPromptEmail,
408-
"https://brev.nvidia.com",
408+
config.GlobalConfig.GetConsoleBaseURL(),
409409
)
410410

411411
// Create the auth0 authenticator as an alternative
@@ -446,9 +446,9 @@ func StandardLogin(authProvider string, email string, tokens *entity.AuthTokens)
446446
}
447447
}
448448

449-
if authenticator.GetCredentialProvider() == CredentialProviderKAS {
450-
config.ConsoleBaseURL = "https://brev.nvidia.com"
451-
}
449+
// if authenticator.GetCre[dentialProvider() == CredentialProviderKAS {
450+
// config.ConsoleBaseURL = "https://brev.nvidia.com"
451+
// }]
452452

453453
return authenticator
454454
}

pkg/cmd/hello/steps.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func GetTextBasedONStatus(status string, t *terminal.Terminal) string {
4141
s += "\n\nRun " + t.Yellow("brev hello") + " to resume this walk through when your instance is ready\n"
4242
default:
4343
s += t.Red("Please create a running instance for this walk through. ")
44-
s += "\n\tYou can do that here: " + t.Yellow(fmt.Sprintf("%s/environments/new", config.ConsoleBaseURL))
44+
s += "\n\tYou can do that here: " + t.Yellow(fmt.Sprintf("%s/environments/new", config.GlobalConfig.GetConsoleBaseURL()))
4545
s += "\n\nRun " + t.Yellow("brev hello") + " to resume this walk through when your instance is ready\n"
4646
}
4747
return s
@@ -62,7 +62,7 @@ func GetDevEnvOrStall(t *terminal.Terminal, workspaces []entity.Workspace) *enti
6262

6363
if noneFound {
6464
s := t.Red("Please create a running instance for this walk through. ")
65-
s += "\n\tYou can do that here: " + t.Yellow(fmt.Sprintf("%s/environments/new", config.ConsoleBaseURL))
65+
s += "\n\tYou can do that here: " + t.Yellow(fmt.Sprintf("%s/environments/new", config.GlobalConfig.GetConsoleBaseURL()))
6666
s += "\n\nRun: " + t.Yellow("brev hello") + " to resume this walk through when your instance is ready\n"
6767
TypeItToMe(s)
6868
return nil
@@ -103,7 +103,7 @@ func printBrevOpen(t *terminal.Terminal, firstWorkspace entity.Workspace) {
103103

104104
func printCompletedOnboarding(t *terminal.Terminal) {
105105
s := "\n\nI think I'm done here. Now you know how to open an instance and start coding."
106-
s += "\n\nUse the console " + t.Yellow(fmt.Sprintf("(%s)", config.ConsoleBaseURL)) + " to create a new instance or share it with people"
106+
s += "\n\nUse the console " + t.Yellow(fmt.Sprintf("(%s)", config.GlobalConfig.GetConsoleBaseURL())) + " to create a new instance or share it with people"
107107
s += "\nand use this CLI to code the way you would normally 🤙"
108108
s += "\n\nCheck out the docs at " + t.Yellow("https://brev.dev") + " and let us know if we can help!\n"
109109
s += "\n\nIn case you missed it, my cell is " + t.Yellow("(415) 237-2247") + "\n\t-Nader\n"

pkg/cmd/invite/invite.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ func RunInvite(t *terminal.Terminal, inviteStore InviteStore, orgflag string) er
9898

9999
t.Vprintf("Share this link to add someone to %s. It will expire in 7 days.", t.Green(org.Name))
100100
t.Vprintf("\n\n %s", t.Green("▸"))
101-
t.Vprintf(" %s", t.White("%s/invite?token=%s\n\n", config.ConsoleBaseURL, token))
101+
t.Vprintf(" %s", t.White("%s/invite?token=%s\n\n", config.GlobalConfig.GetConsoleBaseURL(), token))
102102

103103
return nil
104104
}

pkg/cmd/ls/ls.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ func (ls Ls) RunOrgs() error {
236236
return breverrors.WrapAndTrace(err)
237237
}
238238
if len(orgs) == 0 {
239-
ls.terminal.Vprint(ls.terminal.Yellow(fmt.Sprintf("You don't have any orgs. Create one! %s", config.ConsoleBaseURL)))
239+
ls.terminal.Vprint(ls.terminal.Yellow(fmt.Sprintf("You don't have any orgs. Create one! %s", config.GlobalConfig.GetConsoleBaseURL())))
240240
return nil
241241
}
242242

pkg/cmd/org/org.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ func RunOrgs(t *terminal.Terminal, store OrgCmdStore) error {
7575
return breverrors.WrapAndTrace(err)
7676
}
7777
if len(orgs) == 0 {
78-
t.Vprint(t.Yellow(fmt.Sprintf("You don't have any orgs. Create one! %s", config.ConsoleBaseURL)))
78+
t.Vprint(t.Yellow(fmt.Sprintf("You don't have any orgs. Create one! %s", config.GlobalConfig.GetConsoleBaseURL())))
7979
return nil
8080
}
8181

pkg/cmd/profile/profile.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func NewCmdProfile(t *terminal.Terminal, loginProfileStore ProfileStore, noLogin
5555
}
5656

5757
func goToProfileInConsole() {
58-
url := fmt.Sprintf("%s/profile", config.ConsoleBaseURL)
58+
url := fmt.Sprintf("%s/profile", config.GlobalConfig.GetConsoleBaseURL())
5959
caretType := color.New(color.FgGreen, color.Bold).SprintFunc()
6060
enterType := color.New(color.FgGreen, color.Bold).SprintFunc()
6161
urlType := color.New(color.FgWhite, color.Bold).SprintFunc()

pkg/config/config.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ type EnvVarName string // should be caps with underscore
88

99
const (
1010
brevAPIURL EnvVarName = "BREV_API_URL"
11+
brevAuthURL EnvVarName = "BREV_AUTH_URL"
12+
consoleBaseURL EnvVarName = "BREV_CONSOLE_BASE_URL"
1113
coordURL EnvVarName = "BREV_COORD_URL"
1214
version EnvVarName = "VERSION"
1315
clusterID EnvVarName = "DEFAULT_CLUSTER_ID"
@@ -18,8 +20,6 @@ const (
1820
ollamaAPIURL EnvVarName = "OLLAMA_API_URL"
1921
)
2022

21-
var ConsoleBaseURL = "https://brev.nvidia.com"
22-
2323
type ConstantsConfig struct{}
2424

2525
func NewConstants() *ConstantsConfig {
@@ -30,6 +30,14 @@ func (c ConstantsConfig) GetBrevAPIURl() string {
3030
return getEnvOrDefault(brevAPIURL, "https://brevapi.us-west-2-prod.control-plane.brev.dev")
3131
}
3232

33+
func (c ConstantsConfig) GetBrevAuthURL() string {
34+
return getEnvOrDefault(brevAuthURL, "https://api.ngc.nvidia.com")
35+
}
36+
37+
func (c ConstantsConfig) GetConsoleBaseURL() string {
38+
return getEnvOrDefault(consoleBaseURL, "https://brev.nvidia.com")
39+
}
40+
3341
func (c ConstantsConfig) GetOllamaAPIURL() string {
3442
return getEnvOrDefault(ollamaAPIURL, "https://registry.ollama.ai")
3543
}

0 commit comments

Comments
 (0)