-
Notifications
You must be signed in to change notification settings - Fork 923
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
Cobra command Kubectl Create does not return error to be handled #1615
Comments
The problem, as you found out, is that inside Cobra's Run() command, we use Ideally, instead of calling Unfortunately, the create command is written in a way that requires a cobra command, even if you want to call But, as a workaround, you might be able to make it work by calling
Alternatively, you could forget about trying to leverage create altogether and just copy the code you need out of the Also, would |
/kind support |
Thank you very much @brianpursley ! that makes sense! Should we open a GH issue for the refactor? |
Cool, I'm glad you were able to work around it. The point raised in your issue is definitely valid though.
There is a somewhat related umbrella issue (#1046), but that is more about separating the options from the flags, which is a slightly different problem than this. It looks like there were a couple of previous attempts to refactor this command as part of that issue, but they were not able to be merged. @ardaguclu do you have thoughts on whether this should be a separate issue or fall under the umbrella? |
I think, we can manage this specific change in this issue. The other one requires more dramatic changes. |
/remove-kind support |
What happened:
I'm writing a function to basically do
kubectl create -k /path
. However, If the manifests there have already been created, I don't want my program to exit, but just ignore it.This is a quick snippet:
createCmd.Execute() just throws an error, but It never gets into
klog.Infof("Creating kustomization failed: %s", err)
Am I doing something wrong?
What you expected to happen:
To return an error so I can handle it.
Anything else we need to know?:
Environment:
Library: k8s.io/kubectl v0.30.2
kubectl version
):cat /etc/os-release
):The text was updated successfully, but these errors were encountered: