Skip to content

codegen: remove CLI flags and provide error on their usage#1278

Merged
amalavet merged 16 commits intomainfrom
ale/remove-cli-flags
Mar 9, 2026
Merged

codegen: remove CLI flags and provide error on their usage#1278
amalavet merged 16 commits intomainfrom
ale/remove-cli-flags

Conversation

@amalavet
Copy link
Copy Markdown
Contributor

@amalavet amalavet commented Mar 4, 2026

What Changed? Why?

Removes the CLI flags that have been replaced with a config cue block. If someone attempts to use the flags, they will get an error like below:

grafana-app-sdk generate --grouping=kind --gogenpath=pkg/gen1 --tsgenpath=ts/gen1 --gomodgenpath="pkg/generated" --defencoding=json --manifest=customManifest --crdmanifest
Error: CLI flags have been replaced by CUE defined config values:
 --grouping -> kinds.grouping
 --gogenpath -> codegen.goGenPath
 --tsgenpath -> codegen.tsGenPath
 --gomodgenpath -> codegen.goModGenPath
 --defencoding -> definitions.encoding (if set to 'none' -> definitions.genManifest=false, definitions.genCRDs=false)
 --manifest -> manifestSelectors
 --crdmanifest -> definitions.manifestVersion
Follow this migration guide https://github.com/grafana/grafana-app-sdk/blob/main/docs/migrations/v0.52.md to migrate your usage of CLI flags to the new CUE config values

How was it tested?

Unit, integration tests pass, no change to existing generated code.

@amalavet amalavet marked this pull request as ready for review March 5, 2026 00:41
@amalavet amalavet requested a review from a team as a code owner March 5, 2026 00:41
@amalavet amalavet requested review from IfSentient, charandas, konsalex and stephaniehingtgen and removed request for konsalex and stephaniehingtgen March 5, 2026 00:41
Comment on lines -74 to -86
- name: Generate code (backwards compatibility)
run: |
cd codegen-tests
# NOTE: These four are here for backwards compatibility testing using now deprecated cli flags
grafana-app-sdk generate --grouping=kind --gogenpath=pkg/gen1 --tsgenpath=ts/gen1 --gomodgenpath="pkg/generated" --defencoding=json --manifest=customManifest --crdmanifest
grafana-app-sdk generate --grouping=kind --gogenpath=pkg/gen1 --tsgenpath=ts/gen1 --gomodgenpath="pkg/generated" --defencoding=json --manifest=testManifest --crdmanifest
grafana-app-sdk generate --grouping=group --gogenpath=pkg/gen2 --tsgenpath=ts/gen2 --gomodgenpath="pkg/generated" --defencoding=yaml --manifest=customManifest --crdmanifest
grafana-app-sdk generate --grouping=group --gogenpath=pkg/gen2 --tsgenpath=ts/gen2 --gomodgenpath="pkg/generated" --defencoding=yaml --manifest=testManifest --crdmanifest
sed -i 's/codegen\-tests\/pkg\/gen2/codegen\-tests\/pkg\/generated/g' pkg/gen2/manifestdata/*.go
diff pkg/gen1/customkind cmp/go/groupbykind/customkind > diff.txt
sed -i '/^Common subdirectories/d' diff.txt
difflines=$(wc -l diff.txt | awk '{ print $1 }')
echo "GoGroupByKindDiff=${difflines}" >> $GITHUB_ENV
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.

this test was just here as a backwards compatibility sanity check for the CLI flags still working

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.

below is the up to date test which relies on cue configs

Copy link
Copy Markdown
Contributor

@IfSentient IfSentient left a comment

Choose a reason for hiding this comment

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

Approved with a couple of small changes to the docs on the CUE

Comment thread codegen/cuekind/def.cue Outdated
Comment thread codegen/cuekind/def.cue Outdated
@amalavet amalavet enabled auto-merge (squash) March 9, 2026 15:30
@amalavet amalavet merged commit 7c68736 into main Mar 9, 2026
16 checks passed
@amalavet amalavet deleted the ale/remove-cli-flags branch March 9, 2026 15:31
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