Add mass config for managing CLI profiles (SDK v0.3.3) - #252
Merged
Merged
Conversation
# Manage Configuration Profiles
A profile holds the organization, credential, and API URL used to talk to
Massdriver. Profiles live in ~/.config/massdriver/config.yaml (or
$XDG_CONFIG_HOME/massdriver/config.yaml), and these commands read and write
that file for you.
Use separate profiles to work across organizations or against a self-hosted
installation without re-editing the file each time.
## Choosing a profile
A profile is selected in this order, highest precedence first:
1. The --profile flag
2. The MASSDRIVER_PROFILE environment variable
3. The current_profile key in the config file, set by mass config use
4. The profile named default
The first three name a profile explicitly, so a name that isn't in the file
is an error rather than a silent fallback. The default fallback may be
absent — that is how credentials supplied entirely through environment
variables resolve.
## Getting started
mass config add default --org acme --api-key mds_xxx
mass config list
Usage:
mass config [command]
Aliases:
config, profile
Available Commands:
add Add a profile
get Show a profile's settings (defaults to the active profile)
list List configured profiles
path Print the path to the configuration file
remove Remove a profile
set Update settings on an existing profile
use Set the active profile
Flags:
-h, --help help for config
Global Flags:
--profile string Configuration profile to use (overrides MASSDRIVER_PROFILE and the active profile)
Use "mass config [command] --help" for more information about a command. commands for managing config file
Member
Author
|
@claude review |
|
Claude finished @chrisghill's task in 1m 38s —— View job Reviewing PR #252
ReviewThis is a clean, well-scoped implementation. A few observations: Strengths
Minor/nit-level notes (nothing blocking):
I was not able to execute No blocking issues found. This looks ready to merge pending CI. |
coryodaniel
approved these changes
Sep 11, 2026
ChristensenJoe
approved these changes
Sep 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a
mass configcommand group so users can manage~/.config/massdriver/config.yamlthrough the CLI instead of hand-editing it:list,get,add,set,remove,use, andpath. Adds a global--profileflag for per-command profile selection.mass config addverifies credentials against the API before writing, so a mistyped key or organization fails at the point of entry rather than on some later unrelated command. Nothing is written when verification fails;--no-verifyskips the check. API keys are masked in all output unless--show-secretsis passed, and the file is written atomically at0600.Writes go through the parsed
yaml.Nodetree rather than re-marshaling a struct, so comments, key order, and keys the CLI doesn't model all survive an edit. That matters because everyone using this today has a hand-annotated file.Profile selection is entirely the SDK's
This depends on
current_profilesupport added in massdriver-sdk-go v0.3.3, which also exportsFile,Profile,FilePath(),ReadFile(),Version, andDefaultProfileName. The CLI declares no schema, no file location, and no version of its own, and it does not resolve profiles or credentials.internal/configfileis a writer over the SDK's types;mass config usewritescurrent_profileand the SDK reads it. Precedence —--profile, thenMASSDRIVER_PROFILE, thencurrent_profile, thendefault— lives entirely inLoad.Three contract tests hold the two in agreement: the SDK selects what
usewrites, the active-profile marker inlist/getmatchescfg.Profileacross all four precedence levels, and the CLI refuses to edit a file the SDK can't read.Because the SDK now treats
current_profileas an explicit selection that fails withErrProfileNotFoundwhen it names nothing,usevalidates the profile exists before writing it andremoveclears the key when it deletes the active profile. Without those, one typo or one removal would break every subsequent command.--profileand the client refactor--profileis passed to the SDK asmassdriver.WithProfilevia a newnewMassdriverClient(cmd)helper that all 75 call sites now route through. An earlier revision setMASSDRIVER_PROFILEinPersistentPreRunEinstead, which produced a misleading error —mass whoami --profile typoreported the name "was requested by MASSDRIVER_PROFILE" for a variable the user never set. Each layer now attributes itself correctly. This accounts for most of the diff incmd/(15 files, largely one-line changes);runBundleNew,runBundleList, andrunRepositoryListgained acmd *cobra.Commandparameter.Other notes
internal/commands/config(75.1% covered) withinternal/configfileat 83.2%;cmd/config.gois flag reading and delegation, andcmd/remains test-free.CLAUDE.mdrecording thecmd/internal/commandslayering, the SDK-owns-auth boundary, comment and test conventions, and that CI enforces committed generated docs.docs/generated/are the new--profileflag appearing in every command's inherited-options section.Testing
make checkpasses. Verified end to end against a hand-annotated config: comments and unknown keys survive writes, precedence resolves to the right profile at each level, verification failure leaves no file behind, and removing the active profile leaves the SDK resolving cleanly.