Skip to content

feat: resolve the profile by name, current profile or endpoint, and run without a stored one - #111

Merged
grubmeshi merged 1 commit into
mainfrom
profile-resolution
Nov 25, 2026
Merged

grubmeshi merged 1 commit into
mainfrom
profile-resolution

Conversation

@grubmeshi

Copy link
Copy Markdown
Collaborator

What it does

  • A command takes the profile that --profile or MESHSTACK_PROFILE names. An unknown name is an error.
  • Without a name, it takes the current profile when no endpoint is given or the current profile has that endpoint. Otherwise it takes the only stored profile with that endpoint.
  • With no such profile, it runs with the endpoint and the credential from the settings alone. It stores nothing and caches no token. Only meshstack login creates a profile.
  • An endpoint is a scheme and a host. An endpoint with a path is refused.
  • meshstack api <URL> takes the origin of the URL as the endpoint. The URL wins over MESHSTACK_ENDPOINT, and the command logs one warning when MESHSTACK_ENDPOINT names another endpoint. --endpoint with a URL on another host is an error.
  • When profiles exist and none has the endpoint, the login hint adds --profile <new-profile-name>, because login refuses --endpoint X alone in that case.
  • meshstack logout with no stored profile warns "Nothing to log out of" and exits 0. --profile <unknown> is an error.
  • A profile stores an API token with its other credentials. A token that an earlier version cached is gone, so log in with --apitoken again.

Review carefully

  • internal/profile/resolve.go and select.go: the order in which the name, the current profile and the endpoint decide.
  • internal/setting/resolve.go: the new warning when a source of the command, such as the URL of meshstack api, overrides another value in the environment.
  • cmd/auth/logout.go.

Mechanical

The removal of cmd/api/profile.go and the test updates.

Place in the stack

2 of 6. Base: public-client-http. Next: http-do-request.

🤖 Generated with Claude Code

@meshcloud-gh-actions

meshcloud-gh-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Coverage of the acceptance run against the meshStack backend, on 351d6327942d646358cd4d065546e687715be97b.

Scope Coverage
Unit tests 78.1%
Acceptance tests 52.8%
Combined 82.5%
Uncovered functions
client/api_key.go:52: meshApiKeyClient.Create 0.0%
client/api_key.go:56: meshApiKeyClient.Read 0.0%
client/api_key.go:60: meshApiKeyClient.Update 0.0%
client/api_key.go:64: meshApiKeyClient.Delete 0.0%
client/api_key_permissions.go:20: ApiKeyPermissions.AllCodes 0.0%
client/api_key_permissions.go:33: ApiKeyPermissions.WorkspaceCodes 0.0%
client/api_key_permissions.go:263: AllApiKeyPermissions 0.0%
client/api_key_permissions.go:267: WorkspacePermissionCodes 0.0%
client/binding_status.go:18: *MeshGroupBindingStatus.WaitsForApproval 0.0%
client/binding_status.go:22: *MeshUserBindingStatus.WaitsForApproval 0.0%
client/building_block_definition.go:71: MeshBuildingBlockDefinitionApprovalPolicies.NothingRequiresApproval 0.0%
client/building_block_definition.go:82: DisabledSchedule 0.0%
client/building_block_definition.go:89: MeshBuildingBlockDefinitionSchedule.IsDisabled 0.0%
client/building_block_definition.go:93: MeshBuildingBlockDefinitionSpec.HasNeutralPolicies 0.0%
client/building_block_definition.go:97: MeshBuildingBlockDefinitionSpec.WithNeutralPolicies 0.0%
client/building_block_definition.go:166: meshBuildingBlockDefinitionClient.List 0.0%
client/building_block_definition.go:173: meshBuildingBlockDefinitionClient.Read 0.0%
client/building_block_definition.go:177: meshBuildingBlockDefinitionClient.Create 0.0%
client/building_block_definition.go:181: meshBuildingBlockDefinitionClient.Update 0.0%
client/building_block_definition.go:185: meshBuildingBlockDefinitionClient.Delete 0.0%
client/building_block_definition_version.go:103: MeshBuildingBlockType.TagInputTargets 0.0%
client/building_block_definition_version.go:247: meshBuildingBlockDefinitionVersionClient.Create 0.0%
client/building_block_definition_version.go:256: meshBuildingBlockDefinitionVersionClient.Update 0.0%
client/building_block_definition_version_implementation.go:81: MeshBuildingBlockDefinitionImplementation.InferType 0.0%
client/building_block_definition_version_implementation.go:95: MeshBuildingBlockDefinitionImplementation.MarshalJSONTo 0.0%
... and 137 more

covdata func names a method without its receiver, so an entry can belong to an implementation nothing selects rather than to a function the tests never reached. Open the file and line before reading one as a coverage gap.

@grubmeshi
grubmeshi added this pull request to stack #115 November 25, 2026 10:25
@grubmeshi
grubmeshi requested a review from j0g3sc November 25, 2026 10:26
…un without a stored one

A command takes the profile that --profile or MESHSTACK_PROFILE names, and an unknown name is an
error. Without a name it takes the current profile when no endpoint is given or the profile has
that endpoint, else the only stored profile with that endpoint. With no such profile it runs with
the endpoint and the credential from the settings alone: it stores nothing and caches no token.
Only 'meshstack login' creates a profile.

An endpoint is a scheme and a host, and one with a path is refused. 'meshstack api <URL>' takes
the origin of the URL as the endpoint, and warns where MESHSTACK_ENDPOINT names another one.
Where profiles exist and none has the endpoint, the login hint adds --profile, because login
refuses the endpoint alone then. 'meshstack logout' without any stored profile only warns.

A profile stores an API token with its other credentials. A token that an earlier version cached
is gone, so log in with --apitoken again.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

Base automatically changed from public-client-http to main November 25, 2026 15:16
@grubmeshi
grubmeshi merged commit 351d632 into main Nov 25, 2026
15 of 25 checks passed
@grubmeshi
grubmeshi deleted the profile-resolution branch November 25, 2026 15:16
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