Skip to content

feat: add interactive 'minder profile edit' command#6355

Open
DharunMR wants to merge 1 commit intomindersec:mainfrom
DharunMR:feat-minder-profile
Open

feat: add interactive 'minder profile edit' command#6355
DharunMR wants to merge 1 commit intomindersec:mainfrom
DharunMR:feat-minder-profile

Conversation

@DharunMR
Copy link
Copy Markdown
Contributor

@DharunMR DharunMR commented Apr 13, 2026

Summary

This PR introduces the minder profile edit command, allowing users to fetch a profile, modify it in their local text editor, and apply changes in a single interactive workflow.

  • Implemented a robust lookup system that checks $VISUAL -> $EDITOR -> system path (searching for nano, vim, nvim, vi, or emacs) using exec.LookPath.

  • The implementation ensures that critical fields such as Id, Context, Type, and Version are preserved from the original fetch. This prevents validation errors if the user accidentally deletes these fields during the editing session.



Before
swappy-20260413_185940

After
swappy-20260413_190001

@DharunMR DharunMR requested a review from a team as a code owner April 13, 2026 13:36
@DharunMR DharunMR force-pushed the feat-minder-profile branch from 58fc5b5 to 65dc745 Compare April 13, 2026 13:43
@coveralls
Copy link
Copy Markdown

coveralls commented Apr 13, 2026

Coverage Status

Coverage is 60.194%DharunMR:feat-minder-profile into mindersec:main. No base build found for mindersec:main.

Copy link
Copy Markdown
Member

@evankanderson evankanderson left a comment

Choose a reason for hiding this comment

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

A few comments; I'd merge this except that I think the handling of $EDITOR is probably wrong (should not be space-split).

Comment thread cmd/cli/app/profile/edit.go
Comment thread cmd/cli/app/profile/edit.go Outdated
Comment thread cmd/cli/app/profile/edit.go Outdated
Comment thread cmd/cli/app/profile/edit.go Outdated
Comment thread cmd/cli/app/profile/edit.go Outdated
Comment on lines +150 to +157
updatedJSON, err := yaml.YAMLToJSON(updatedBytes)
if err != nil {
return cli.MessageAndError("Error parsing updated YAML", err)
}
um := protojson.UnmarshalOptions{DiscardUnknown: true}
if err := um.Unmarshal(updatedJSON, &updatedProfile); err != nil {
return cli.MessageAndError("Error loading updated profile data into protobuf", err)
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You may want to use minderv1.ParseResource to convert YAML to a protobuf.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

my only concern is GetProfile API response drops the type and version fields so i had to manually inject them into the struct before generating the yaml so ParseResource wouldnt fail validation.

@DharunMR DharunMR force-pushed the feat-minder-profile branch from 65dc745 to b655a78 Compare April 21, 2026 12:02
Signed-off-by: DharunMR <maddharun56@gmail.com>
@DharunMR DharunMR force-pushed the feat-minder-profile branch from b655a78 to 4383402 Compare April 21, 2026 12:12
@DharunMR DharunMR requested a review from evankanderson April 24, 2026 15:36
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.

minder profile edit

3 participants