Skip to content

Commit d33317c

Browse files
authored
basic prep for grpc behavior (#272)
1 parent a833765 commit d33317c

File tree

3 files changed

+43
-1
lines changed

3 files changed

+43
-1
lines changed

Makefile

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,27 @@ fast-build: ## go build -o brev
77
echo ${VERSION}
88
CGO_ENABLED=0 go build -o brev -ldflags "-X github.com/brevdev/brev-cli/pkg/cmd/version.Version=${VERSION}"
99

10+
.PHONY: local
11+
local: ## build with env wrapper (use: make local env=dev0|dev1|dev2|stg, or make local for defaults)
12+
$(call print-target)
13+
ifdef env
14+
@echo "Building with env=$(env) wrapper..."
15+
@echo ${VERSION}
16+
CGO_ENABLED=0 go build -o brev -ldflags "-X github.com/brevdev/brev-cli/pkg/cmd/version.Version=${VERSION}"
17+
@echo '#!/bin/sh' > brev
18+
@echo '# Auto-generated wrapper with environment overrides' >> brev
19+
@echo 'export BREV_CONSOLE_URL="https://localhost.nvidia.com:3000"' >> brev
20+
@echo 'export BREV_AUTH_URL="https://api.stg.ngc.nvidia.com"' >> brev
21+
@echo 'export BREV_AUTH_ISSUER_URL="https://stg.login.nvidia.com"' >> brev
22+
@echo 'export BREV_API_URL="https://bd.$(env).brev.nvidia.com"' >> brev
23+
@echo 'export BREV_GRPC_URL="api.$(env).brev.nvidia.com:443"' >> brev
24+
@echo 'exec "$$(cd "$$(dirname "$$0")" && pwd)/brev" "$$@"' >> brev
25+
@chmod +x brev
26+
else
27+
@echo "Building without environment overrides (using config.go defaults)..."
28+
$(MAKE) fast-build
29+
endif
30+
1031
.PHONY: install-dev
1132
install-dev: fast-build ## go install
1233
cp brev $(shell go env GOPATH)/bin/
@@ -278,3 +299,13 @@ new-cmd:
278299
.PHONY: develop-with-nix
279300
develop-with-nix:
280301
nix develop .
302+
303+
.PHONY: update-devplane-deps
304+
update-devplane-deps: ## update devplane dependencies (use: make update-devplane-deps commit=<hash-or-tag>, defaults to latest)
305+
@COMMIT=$${commit:-latest}; \
306+
echo "Updating devplane dependencies to: $$COMMIT"; \
307+
go get -u github.com/brevdev/dev-plane@$$COMMIT; \
308+
go get buf.build/gen/go/brevdev/devplane/grpc/go@$$COMMIT; \
309+
go get buf.build/gen/go/brevdev/devplane/protocolbuffers/go@$$COMMIT; \
310+
go mod tidy; \
311+
echo "Successfully updated to $$COMMIT"

pkg/auth/auth.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ func StandardLogin(authProvider string, email string, tokens *entity.AuthTokens)
403403
kasAuthenticator := NewKasAuthenticator(
404404
email,
405405
config.GlobalConfig.GetBrevAuthURL(),
406-
"https://login.nvidia.com",
406+
config.GlobalConfig.GetBrevAuthIssuerURL(),
407407
shouldPromptEmail,
408408
config.GlobalConfig.GetConsoleURL(),
409409
)

pkg/config/config.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ type EnvVarName string // should be caps with underscore
88

99
const (
1010
brevAPIURL EnvVarName = "BREV_API_URL"
11+
brevGRPCURL EnvVarName = "BREV_GRPC_URL"
1112
brevAuthURL EnvVarName = "BREV_AUTH_URL"
13+
brevAuthIssuerURL EnvVarName = "BREV_AUTH_ISSUER_URL"
1214
brevConsoleURL EnvVarName = "BREV_CONSOLE_URL"
1315
coordURL EnvVarName = "BREV_COORD_URL"
1416
version EnvVarName = "VERSION"
@@ -30,10 +32,19 @@ func (c ConstantsConfig) GetBrevAPIURl() string {
3032
return getEnvOrDefault(brevAPIURL, "https://brevapi.us-west-2-prod.control-plane.brev.dev")
3133
}
3234

35+
func (c ConstantsConfig) GetBrevGRPCURL() string {
36+
// GRPC does not use https:// prefix
37+
return getEnvOrDefault(brevGRPCURL, "api.brev.dev:443")
38+
}
39+
3340
func (c ConstantsConfig) GetBrevAuthURL() string {
3441
return getEnvOrDefault(brevAuthURL, "https://api.ngc.nvidia.com")
3542
}
3643

44+
func (c ConstantsConfig) GetBrevAuthIssuerURL() string {
45+
return getEnvOrDefault(brevAuthIssuerURL, "https://login.nvidia.com")
46+
}
47+
3748
func (c ConstantsConfig) GetConsoleURL() string {
3849
return getEnvOrDefault(brevConsoleURL, "https://brev.nvidia.com")
3950
}

0 commit comments

Comments
 (0)