refactor: fold duplicated command-layer helpers into one copy each - #261
Merged
Merged
Conversation
tas50
enabled auto-merge (squash)
September 24, 2026 05:18
- Eleven fetch<Noun>Names functions, identical but for the service they listed, become one generic listNames(ctx, c.Nodes.List). - The --profile / $CINC_PROFILE / $CHEF_PROFILE lookup was written out five times; config.EnvProfile (exported) and explicitProfile(cmd) are now the only copies. - create.go carried private copies of components.PromptWithDefault and config.ExpandHome; use the shared ones. - openClientJSONEditor was openObjectJSONEditor[cinc.APIClient] spelled out by hand. - Drop the RunList == nil guards before Nodes/Roles.Update: Node.MarshalJSON and Role.MarshalJSON already send []. - Replace cmpString with strings.Compare, the config check's manual StatusCode == 403 test with errors.Is(err, cinc.ErrForbidden), and the bagCreateOrPropagate pass-through with the call it wrapped. Signed-off-by: Tim Smith <tsmith84@proton.me>
tas50
force-pushed
the
refactor/remove-duplicate-helpers
branch
from
September 24, 2026 05:29
5aa0981 to
25ad5a1
Compare
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.
Cleanup from an audit of the command layer. No behavior change. It removes 292 net lines.
listNames: elevenfetch<Noun>Namesfunctions (list, collect keys, sort) differed only in the service they called. They're now one genericlistNames(ctx, c.Nodes.List), built onslices.Sorted(maps.Keys(...)).--profile→$CINC_PROFILE→$CHEF_PROFILEprecedence was written out five times (common.go,create.gotwice,explore.go, and privately incli/config).config.EnvProfileis exported andexplicitProfile(cmd)sits on top of it.create.gohad byte-identical private copies ofcomponents.PromptWithDefaultandconfig.ExpandHome.openClientJSONEditorwasopenObjectJSONEditor[cinc.APIClient]spelled out by hand. The fused doc comment above the editor vars is fixed too.RunList == nilguards beforeNodes.Update/Roles.Update.Node.MarshalJSON/Role.MarshalJSONalready sendrun_listas[].cmpStringbecomesstrings.Compare. The config check's hand-rolledErrorResponse.StatusCode == 403becomeserrors.Is(err, cinc.ErrForbidden). ThebagCreateOrPropagatepass-through is inlined.Test plan
go test ./apps/... ./cli/config/ ./cli/components/go vet,gofmtclean