Skip to content
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

remove flags.Parse in cobra #369

Merged
merged 1 commit into from
Sep 18, 2022
Merged

remove flags.Parse in cobra #369

merged 1 commit into from
Sep 18, 2022

Conversation

yxxhero
Copy link
Member

@yxxhero yxxhero commented Sep 18, 2022

Signed-off-by: yxxhero aiopsclub@163.com

remove flags.Parse in cobra

flags. Parse refers to the code of the helm, but I found that some parameter parsing exceptions would occur, so I removed this logic

[root@devops helmfile]# go run main.go template --args "-s templates/deployment.yaml"
environment will be: mplates/deployment.yaml [it's error]
args will be: -s templates/deployment.yaml

fixed: #299

@yxxhero
Copy link
Member Author

yxxhero commented Sep 18, 2022

@mumoshu

Signed-off-by: yxxhero <aiopsclub@163.com>
Copy link
Contributor

@mumoshu mumoshu left a comment

Choose a reason for hiding this comment

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

This LGTM!

But I think this revealead another issue for me. Let me explain- so if you run ./helmfile --log-level=debug template -f path/to/your/helmfile.yaml --args "-s templates/deployment.yaml" you'll see from helmfile debug logs that it isn't passing the specified args to any helm commands ran by helmfile.
--args has never worked reliably, but this seems worse than before. Perhaps we somehow broke it when we migrated to cobra? 🤔

You can merge this, but we'd better investigate since when and how --args isn't working in that case.

Note though, long flags in --args seem to "work". I figure it out by passing an invalid long flag to --args, like helmfile --log-level=debug template -f path/to/helmfile.yaml --args "--aaa. It did fail with Error: unknown flag: --aaa as helm-template does not support the flag. So unlike the -s case, the flag has been passed to helm-template.

Perhaps it's just that short flags like -s path/to/template isn't working when specified within --args?

@yxxhero
Copy link
Member Author

yxxhero commented Sep 18, 2022

@mumoshu ok. I will look at the logic of args in detail.

@yxxhero yxxhero merged commit d4e4d10 into main Sep 18, 2022
@yxxhero yxxhero deleted the remove_flags_parse_in_cobra branch September 18, 2022 05:40
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 20, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Passing --args "--show-only path/to/template.yaml" works but not --args "-s path/to/template.yaml"
2 participants