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

External plugins discovery fails when XDG_CONFIG_HOME is set #3224

Closed
em-r opened this issue Feb 13, 2023 · 4 comments · Fixed by #3247
Closed

External plugins discovery fails when XDG_CONFIG_HOME is set #3224

em-r opened this issue Feb 13, 2023 · 4 comments · Fixed by #3247
Assignees
Labels
kind/bug Categorizes issue or PR as related to a bug. triage/accepted Indicates an issue or PR is ready to be actively worked on.

Comments

@em-r
Copy link
Contributor

em-r commented Feb 13, 2023

What broke? What's expected?

On Ubuntu, when specifying an external plugin to any subcommand (e.g. init) through the --plugins flag, the subcommand fails if XDG_CONFIG_HOME is set to its default value $HOME/.config, with the following error:

2023/02/11 15:35:25 no plugin could be resolved with key "myexternalplugin/v1"

The subcommands eventually run successfully after unsetting XDG_CONFIG_HOME.

Reproducing this issue

  1. Set XDG_CONFIG_HOME variable in the shell: export XDG_CONFIG_HOME=$HOME/.config
  2. Create a folder for an external plugin: mkdir -p $XDG_CONFIG_HOME/kubebuilder/plugins/myexternalplugin/v1
  3. Copy the plugin binary to the directory created in 2).
  4. Initialize a new project: kubebuilder init --plugins=myexternalplugin/v1
  5. Notice how the execution will exit with an error, and myexternalplugin won't appear in the available plugins table.

KubeBuilder (CLI) Version

3.9.0

PROJECT version

No response

Plugin versions

No response

Other versions

Go version: 1.19.4 linux/amd64
OS version: Ubuntu 22.04.1 LTS

Extra Labels

No response

@em-r em-r added the kind/bug Categorizes issue or PR as related to a bug. label Feb 13, 2023
@em-r
Copy link
Contributor Author

em-r commented Feb 13, 2023

Looking at the code, I believe this issue occurs because Kubebuilder concatenates the outcome of getHomeDir (which maybe $XDG_CONFIG_HOME) to .config (see options.go#L182)

So, when XDG_CONFIG_HOME is set, Kubebuilder will try to find external plugins in the directory $XDG_CONFIG_HOME/.config/kubebuilder.
For example, if XDG_CONFIG_HOME is set to its default value ($HOME/.config), then Kubebuilder will lookup external plugins in $HOME/.config/.config/kubebuilder.

@em-r
Copy link
Contributor Author

em-r commented Feb 13, 2023

I'll be happy to send a PR with a fix if this gets accepted.

@camilamacedo86
Copy link
Member

Hi @em-r,

All issues that you find if you either be able to contribute with the fix that is amazing !!! please feel free to move forward !!!

@em-r
Copy link
Contributor Author

em-r commented Feb 13, 2023

Thank you @camilamacedo86, always happy to help. I'll try to put together fixes for any issue I report.

/assign

@varshaprasad96 varshaprasad96 added the triage/accepted Indicates an issue or PR is ready to be actively worked on. label Feb 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants