-
Notifications
You must be signed in to change notification settings - Fork 3
feat(cmd)!: replace all, sync, and render commands with a single render command
#570
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…e `render` command
WalkthroughThe changes consolidate the CLI's Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant CLI (render)
participant Myks Globe
User->>CLI (render): myks render [flags] [envs] [apps]
CLI (render)->>CLI (render): Parse flags (--sync/--render)
CLI (render)->>Myks Globe: Initialize with args
alt --sync only
CLI (render)->>Myks Globe: Sync()
else --render only
CLI (render)->>Myks Globe: Render()
else default (both)
CLI (render)->>Myks Globe: SyncAndRender()
end
Myks Globe-->>CLI (render): Success/Error
CLI (render)-->>User: Output result or error
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~15–20 minutes Poem
✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
all, sync, and render commands with a single render commandall, sync, and render commands with a single render command
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🔭 Outside diff range comments (1)
cmd/root.go (1)
70-81: Incorrect issues URL in help textHelp text points to example repo. Should link to the actual project issues.
- • Report issues at https://github.com/example/myks/issues + • Report issues at https://github.com/mykso/myks/issues
🧹 Nitpick comments (11)
cmd/util.go (1)
13-17: Good DRY helper for fatal error handling; consider testability.Centralizing fatal logging is solid. Optional: add a variant that returns error (e.g., okOrErr) and have okOrFatal wrap it. This makes core ops callable from tests and libraries without forcing process exit.
cmd/embedded/embdedded.go (1)
1-1: Nit: filename typo.Consider renaming file from embdedded.go to embedded.go for consistency and to avoid confusion.
docs/optimizations.md (2)
5-5: Typo: “impreve” → “improve”.Minor spelling fix to polish docs.
35-36: Clarify default behavior and flags.Since render now handles both sync and render by default, consider adding a short note here about flags to run sync-only or render-only (if available), to guide users migrating from separate commands.
docs/smart-mode.md (1)
25-25: Typo: “Than means” → “That means”.Minor grammar fix.
internal/integration/render_test.go (1)
90-90: Test updates toRenderCmd(false, false)are consistent; consider avoiding hard exits in tests.LGTM for replacing the removed RunAllCmd. Caution: RenderCmd uses fatal exits on errors, which will terminate the test process. Consider exposing an error-returning variant (e.g., RenderCmdE or RunRender) and using it in tests to assert failures without exiting.
Also applies to: 120-120
docs/plugins.md (1)
32-32: Wording nit: prefer “myks’ render logic”“Like the render logic of myks” reads a bit awkward. Suggest tightening the phrasing.
-Like the render logic of myks, a plugin is executed for every +Like myks' render logic, a plugin is executed for everydocs/README.md (2)
156-159: Clarify accepted argument formatsMention that both arguments accept comma-separated lists and the special value ALL (as reflected in the command’s usage template).
-The `render` command accepts two optional arguments: +The `render` command accepts two optional arguments (comma-separated lists or `ALL`): environments and applications to process. When no arguments are provided, myks will use the [Smart Mode](/docs/smart-mode.md) to detect what to process.
226-226: Fix markdownlint MD014: drop prompt or show outputStatic analysis flagged MD014. Either remove the leading “$ ” or include a sample output block.
-$ myks render envs --log-level debug +myks render envs --log-level debugcmd/render.go (2)
39-73: Usage template grammar fixMinor grammar issue in the Smart Mode sentence.
- 0. When no arguments are provided, myks uses the Smart Mode to determine the environments and applications to process. - In Smart Mode, myks relies on git to only processes applications with changes. + 0. When no arguments are provided, myks uses Smart Mode to determine the environments and applications to process. + In Smart Mode, myks relies on git to only process applications with changes.
74-77: Enforce mutual exclusivity via cobraCobra can enforce mutually exclusive flags at parse time, improving UX vs runtime fatal.
renderCmd.Flags().BoolP("sync", "s", false, "only sync external sources") renderCmd.Flags().BoolP("render", "r", false, "only render manifests") + +// Enforce mutual exclusivity between --sync and --render +if err := renderCmd.MarkFlagsMutuallyExclusive("sync", "render"); err != nil { + log.Fatal().Err(err).Msg("Failed to mark flags mutually exclusive") +}
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (12)
cmd/all.go(0 hunks)cmd/embedded/embdedded.go(1 hunks)cmd/render.go(1 hunks)cmd/root.go(2 hunks)cmd/sync.go(0 hunks)cmd/util.go(1 hunks)docs/README.md(3 hunks)docs/optimizations.md(1 hunks)docs/plugins.md(1 hunks)docs/smart-mode.md(1 hunks)internal/integration/render_test.go(2 hunks)main.go(1 hunks)
💤 Files with no reviewable changes (2)
- cmd/sync.go
- cmd/all.go
🧰 Additional context used
🧬 Code Graph Analysis (3)
internal/integration/render_test.go (1)
cmd/render.go (1)
RenderCmd(82-104)
main.go (1)
cmd/root.go (1)
NewMyksCmd(32-47)
cmd/render.go (2)
cmd/smart-mode.go (2)
AnnotationSmartMode(18-18)AnnotationTrue(19-19)internal/myks/globe.go (1)
New(131-178)
🪛 markdownlint-cli2 (0.17.2)
docs/README.md
226-226: Dollar signs used before commands without showing output
(MD014, commands-show-output)
🔇 Additional comments (9)
cmd/embedded/embdedded.go (1)
1-1: Package doc comment LGTM.Accurately documents package purpose and follows Go doc style.
docs/optimizations.md (1)
32-32: Docs aligned with new CLI command.Example updated to myks render … matches the unified command behavior (sync+render by default).
docs/smart-mode.md (1)
32-32: Docs updated to userender— looks good.Example now reflects removed
allcommand.main.go (1)
24-27: LGTM: inline Execute refactorDirectly executing the constructed command is clean and preserves behavior.
docs/README.md (2)
58-59: Command consolidation update looks goodReplacing “myks all” with “myks render” aligns with the new CLI.
147-150: Clear two-stage overviewThe sync + render stage explanation is clear and consistent with the code.
cmd/root.go (1)
32-47: Command registration update is soundRemoving
all/syncand registering onlyrender, plus other commands, matches the new model.cmd/render.go (2)
10-23: Well-structured command: usage, args, annotations, completionGood separation via constructor; Args range, Smart Mode annotation, and completion hook are all appropriate.
100-103: Verify cleanup semantics for sync-only runsCleanup runs whenever envAppMap == nil, even if only --sync is used. If cleanup removes stale rendered artifacts, doing it after sync-only may be surprising.
Do we intend to clean rendered manifests when only syncing? If not, guard cleanup to run only when a render happened.
- // Cleaning up only if all environments and applications were processed - if envAppMap == nil { + // Clean up only if all envs/apps were processed AND a render occurred + if !sync && envAppMap == nil { okOrFatal(g.CleanupRenderedManifests(false), "Unable to cleanup rendered manifests") }
| The `render` command handles both stages and accepts optional flags to control behavior: | ||
| - By default, it runs both sync and render stages sequentially | ||
| - Use `--sync` to only sync external sources | ||
| - Use `--render` to only render manifests | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
Document mutual exclusivity of flags
The code errors if both flags are provided (see cmd/render.go). Make this explicit in the docs.
The `render` command handles both stages and accepts optional flags to control behavior:
- By default, it runs both sync and render stages sequentially
- Use `--sync` to only sync external sources
- Use `--render` to only render manifests
+Note: `--sync` and `--render` are mutually exclusive.🏁 Script executed:
#!/bin/bash
# Verify no stale references to removed commands remain in docs/help text.
rg -n -S -e 'myks all' -e 'myks sync' -e '^\\s+sync\\s' -e '^\\s+all\\s' -- glob:'**/*.{md,go,txt}'Length of output: 163
Let’s re-run the search with correct glob patterns to catch any lingering references:
🏁 Script executed:
#!/bin/bash
# Verify no stale references to removed commands remain in docs/help text.
rg -n -S -e 'myks all' -e 'myks sync' --glob '**/*.md' --glob '**/*.go' --glob '**/*.txt'Length of output: 342
Document mutual-exclusivity & clean up stale “myks sync” reference
- In docs/README.md, add a note that the flags cannot be combined:
The `render` command handles both stages and accepts optional flags to control behavior: - By default, it runs both sync and render stages sequentially - Use `--sync` to only sync external sources - Use `--render` to only render manifests +Note: `--sync` and `--render` are mutually exclusive. - In CHANGELOG.md (around line 584), there’s still a reference to the standalone
myks syncstep; update or remove it to reflect the new flags-based workflow.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| The `render` command handles both stages and accepts optional flags to control behavior: | |
| - By default, it runs both sync and render stages sequentially | |
| - Use `--sync` to only sync external sources | |
| - Use `--render` to only render manifests | |
| The `render` command handles both stages and accepts optional flags to control behavior: | |
| - By default, it runs both sync and render stages sequentially | |
| - Use `--sync` to only sync external sources | |
| - Use `--render` to only render manifests | |
| Note: `--sync` and `--render` are mutually exclusive. |
🤖 Prompt for AI Agents
In docs/README.md around lines 151 to 155, add a clear note stating that the
`--sync` and `--render` flags for the `render` command are mutually exclusive
and cannot be combined. Additionally, in CHANGELOG.md near line 584, locate and
update or remove any references to the old standalone `myks sync` step to
accurately reflect the new workflow that uses these flags instead.
New major version with a number of improvements. feat(cmd)!: replace `all`, `sync`, and `render` commands with a single `render` command (#570) chore: fix typos in documentation and rename embedded.go refactor(cmd): ensure mutuall exclusivity of sync and render flags via Cobra feat: add config-in-root option that sets root-dir to the config file location feat: add kbld support (#626)
Summary by CodeRabbit
New Features
rendercommand now handles both syncing external sources and rendering manifests, with new--syncand--renderflags for more control.Refactor
allandsynccommands; all related functionality is now available via therendercommand.Documentation
rendercommand structure and usage.Tests
rendercommand.