Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,27 @@ fast-build: ## go build -o brev
echo ${VERSION}
CGO_ENABLED=0 go build -o brev -ldflags "-X github.com/brevdev/brev-cli/pkg/cmd/version.Version=${VERSION}"

.PHONY: local
local: ## build with env wrapper (use: make local env=dev0|dev1|dev2|stg, or make local for defaults)
$(call print-target)
ifdef env
@echo "Building with env=$(env) wrapper..."
@echo ${VERSION}
CGO_ENABLED=0 go build -o brev -ldflags "-X github.com/brevdev/brev-cli/pkg/cmd/version.Version=${VERSION}"
@echo '#!/bin/sh' > brev
@echo '# Auto-generated wrapper with environment overrides' >> brev
@echo 'export BREV_CONSOLE_URL="https://localhost.nvidia.com:3000"' >> brev
@echo 'export BREV_AUTH_URL="https://api.stg.ngc.nvidia.com"' >> brev
@echo 'export BREV_AUTH_ISSUER_URL="https://stg.login.nvidia.com"' >> brev
@echo 'export BREV_API_URL="https://bd.$(env).brev.nvidia.com"' >> brev
@echo 'export BREV_GRPC_URL="api.$(env).brev.nvidia.com:443"' >> brev
@echo 'exec "$$(cd "$$(dirname "$$0")" && pwd)/brev" "$$@"' >> brev
@chmod +x brev
else
@echo "Building without environment overrides (using config.go defaults)..."
$(MAKE) fast-build
endif

.PHONY: install-dev
install-dev: fast-build ## go install
cp brev $(shell go env GOPATH)/bin/
Expand Down Expand Up @@ -278,3 +299,13 @@ new-cmd:
.PHONY: develop-with-nix
develop-with-nix:
nix develop .

.PHONY: update-devplane-deps
update-devplane-deps: ## update devplane dependencies (use: make update-devplane-deps commit=<hash-or-tag>, defaults to latest)
@COMMIT=$${commit:-latest}; \
echo "Updating devplane dependencies to: $$COMMIT"; \
go get -u github.com/brevdev/dev-plane@$$COMMIT; \
go get buf.build/gen/go/brevdev/devplane/grpc/go@$$COMMIT; \
go get buf.build/gen/go/brevdev/devplane/protocolbuffers/go@$$COMMIT; \
go mod tidy; \
echo "Successfully updated to $$COMMIT"
2 changes: 1 addition & 1 deletion pkg/auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ func StandardLogin(authProvider string, email string, tokens *entity.AuthTokens)
kasAuthenticator := NewKasAuthenticator(
email,
config.GlobalConfig.GetBrevAuthURL(),
"https://login.nvidia.com",
config.GlobalConfig.GetBrevAuthIssuerURL(),
shouldPromptEmail,
config.GlobalConfig.GetConsoleURL(),
)
Expand Down
11 changes: 11 additions & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ type EnvVarName string // should be caps with underscore

const (
brevAPIURL EnvVarName = "BREV_API_URL"
brevGRPCURL EnvVarName = "BREV_GRPC_URL"
brevAuthURL EnvVarName = "BREV_AUTH_URL"
brevAuthIssuerURL EnvVarName = "BREV_AUTH_ISSUER_URL"
brevConsoleURL EnvVarName = "BREV_CONSOLE_URL"
coordURL EnvVarName = "BREV_COORD_URL"
version EnvVarName = "VERSION"
Expand All @@ -30,10 +32,19 @@ func (c ConstantsConfig) GetBrevAPIURl() string {
return getEnvOrDefault(brevAPIURL, "https://brevapi.us-west-2-prod.control-plane.brev.dev")
}

func (c ConstantsConfig) GetBrevGRPCURL() string {
// GRPC does not use https:// prefix
return getEnvOrDefault(brevGRPCURL, "api.brev.dev:443")
}

func (c ConstantsConfig) GetBrevAuthURL() string {
return getEnvOrDefault(brevAuthURL, "https://api.ngc.nvidia.com")
}

func (c ConstantsConfig) GetBrevAuthIssuerURL() string {
return getEnvOrDefault(brevAuthIssuerURL, "https://login.nvidia.com")
}

func (c ConstantsConfig) GetConsoleURL() string {
return getEnvOrDefault(brevConsoleURL, "https://brev.nvidia.com")
}
Expand Down
Loading