Skip to content

feat(cli): add environment contexts#3

Draft
tkkhq wants to merge 2 commits into
mainfrom
feat/env-context-switch
Draft

feat(cli): add environment contexts#3
tkkhq wants to merge 2 commits into
mainfrom
feat/env-context-switch

Conversation

@tkkhq

@tkkhq tkkhq commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add named Volcano API contexts with built-in dev, stage, and prod presets
  • add context selection via volcano context, --context, and VOLCANO_CONTEXT
  • make login/session/project selection use the active context and stop selecting device client IDs from URL shape

Tests

  • go test ./...

@tkkhq tkkhq requested a review from a team as a code owner June 8, 2026 20:03
Comment thread internal/config/config.go
case ContextStage:
return ContextConfig{APIBaseURL: stageAPIURL, DeviceClientID: devDeviceClientID}
case ContextProd:
return ContextConfig{APIBaseURL: prodAPIURL, DeviceClientID: prodDeviceClientID}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This hardcodes the prod API URL and OAuth client ID, which makes the ldflag-injected compiledDefaultAPIURL and compiledFirstPartyDeviceClientID effectively unreachable for the default prod context. The release build still injects those values through the Makefile/publish workflow, so a rotated client ID or alternate build target would not be honored after this change. Can the prod preset use the compiled values, and can DeviceClientID() still fall back to compiledFirstPartyDeviceClientID before hardcoded defaults?

Short: "List contexts",
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, _ []string) error {
cfg, err := config.Load()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This command loads config directly, so it never sees the root deps.ContextName pointer populated by the global --context flag. As a result, volcano --context stage context list still marks prod as current. Can the context command accept/apply the same override, or otherwise keep the advertised global context selection consistent here?

)

const authAlphaProjectID = "11111111-1111-4111-8111-111111111111"
const testProdDeviceClientID = "devcli_94e247237984b85cfd58d37e"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI is currently failing gofumpt on this const section. Grouping the three const declarations should satisfy the formatter.

}
name := config.NormalizeContextName(opts.name)
if name == "" {
return fmt.Errorf("context name cannot be empty")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI is currently failing perfsprint here because this static error can be errors.New(...) instead of fmt.Errorf(...).

@tkkhq tkkhq marked this pull request as draft June 9, 2026 14:43
@tkkhq

tkkhq commented Jun 9, 2026

Copy link
Copy Markdown
Contributor Author

This is not yet ready for review. was incorrectly marked ready.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants