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

🐛 fix(completion): Fix completion in deprecated projects #3474

Merged

Commits on Jun 21, 2023

  1. fix(completion): Fix completion in deprecated projects

    Currently, when initializing in a project with deprecated plugins
    the kubebuilder cli will immediately output a deprecation notice to
    stdout before even parsing the command. While this is acceptable and
    even desirable for interactive usage of the cli, it will "randomly"
    (i.e. dependent on $PWD and not on the command) break automated usage of
    the kubebuilder output. This, again is fine if kubebuilder makes no
    guarantees of stable machine readable output, but this does not hold for
    the completion sub commands which are only ever parsed by machines: The
    output of "kubebuilder completion <shell>" must always only output the
    exact script generated by cobra and the cobra internal commands
    __complete and __completeNoDesc must only only return an exact list of
    completion options.
    
    In deprecated projects this will break shell completion if the shell is
    started in the directory and if the completion script is correctly
    initialized, all completion options will be polluted by the massive
    deprecation notice.
    
    This commit instead changes the deprecation notice to output to stderr
    (while maintaining the return code of the actual command). This fixes
    the completion usecase which only reads in stdout, and should not break
    existing integrations, unless there exist scripts which use the length
    of stderr to check for errors rather than the return code of the call.
    
    Signed-off-by: Joel Pepper <pepper@bronze-deer.de>
    BronzeDeer committed Jun 21, 2023
    Configuration menu
    Copy the full SHA
    0f3db00 View commit details
    Browse the repository at this point in the history