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

failed to initialize project with "go.kubebuilder.io/v3" #1971

Closed
abhi1693 opened this issue Jan 24, 2021 · 10 comments
Closed

failed to initialize project with "go.kubebuilder.io/v3" #1971

abhi1693 opened this issue Jan 24, 2021 · 10 comments
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.
Milestone

Comments

@abhi1693
Copy link

abhi1693 commented Jan 24, 2021

➜  kubeact-operator git:(feat/v0.0.1) ✗ kubebuilder init                                                                                        git:(feat/v0.0.1|●53✚1…2 
Error: failed to initialize project with "go.kubebuilder.io/v3": only the go.mod and files with the prefix "(.)" are allowed before the init
Usage:
  kubebuilder init [flags]

Examples:
  # Scaffold a project using the apache2 license with "The Kubernetes authors" as owners
  kubebuilder init --project-version=2 --domain example.org --license apache2 --owner "The Kubernetes authors"


Flags:
      --component-config         create a versioned ComponentConfig file, may be 'true' or 'false'
      --domain string            domain for groups (default "my.domain")
      --fetch-deps               ensure dependencies are downloaded (default true)
  -h, --help                     help for init
      --license string           license to use to boilerplate, may be one of 'apache2', 'none' (default "apache2")
      --owner string             owner to add to the copyright
      --plugins strings          Name and optionally version of the plugin to initialize the project with. Available plugins: ("go.kubebuilder.io/v2", "go.kubebuilder.io/v3")
      --project-name string      name of this project
      --project-version string   project version, possible values: ("2", "3-alpha") (default "3-alpha")
      --repo string              name to use for go module (e.g., github.com/user/repo), defaults to the go package of the current working directory.
      --skip-go-version-check    if specified, skip checking the Go version

2021/01/24 07:14:18 failed to initialize project with "go.kubebuilder.io/v3": only the go.mod and files with the prefix "(.)" are allowed before the init
➜  kubeact-operator git:(feat/v0.0.1) ✗ ls                                                                                                                                       git:(feat/v0.0.1|●53✚1…2 
go.mod  go.sum
➜  kubeact-operator git:(feat/v0.0.1) ✗ 
  • go version go1.15.6 linux/amd64
  • Version: main.version{KubeBuilderVersion:"3.0.0-alpha.1", KubernetesVendor:"1.19.2", GitCommit:"1428bba7c162cf2b783c89fd6f07f4efbae97130", BuildDate:"2021-01-08T22:30:36Z", GoOs:"linux", GoArch:"amd64"}

/kind bug

@k8s-ci-robot k8s-ci-robot added the kind/bug Categorizes issue or PR as related to a bug. label Jan 24, 2021
@daenney
Copy link

daenney commented Jan 24, 2021

You have a go.sum in that directory it seems, which would explain the error since it seems to only permit go.mod?

But I get the exact same error without a go.sum present, so this seems broken one way or another.

@daenney
Copy link

daenney commented Jan 24, 2021

The error also triggers in a new git repo without anything present but a .git when the plugin is invoked with --repo.

@camilamacedo86
Copy link
Member

See the error failed to initialize project with "go.kubebuilder.io/v3": only the go.mod and files with the prefix "(.)" are allowed before the init. It means that your directory has files already which are not go.mod or that ones which starts with (.)

@abhi1693
Copy link
Author

@camilamacedo86 So, I cannot initialize a project which is checked out of Github? This does not make sense as I have a template with which I normally start a new project and I cannot use it due to this issue. In my knowledge, kubebuilder does not use any dotfile so why put such a limitation on the initialization?

I have several dotfiles and folders that are part of our automation. And the error states that dotfiles and dot-folders are indeed allowed. So, this is a bug with either the code or the message.

@camilamacedo86
Copy link
Member

Kubebuilder should allow initing the project in a directory with files/directories which starts with (.) and that has go.mod already. However, other directories not because then we cannot ensure that the tool will do the scaffold properly. You can init the project and then, push your changes to the top as all.

Are you facing issues when you have a file/directory whcih has the prefix (.)? If yes, we need to fix that. Could you check my comments in your PR and change the fix to ensure that only these scenarios will be allowed? Also, please let me know if it makes sense for you or not.

Also, please feel free to raise your suggestions regards to it.

@abhi1693
Copy link
Author

@camilamacedo86 I tried again with only .git and go.mod and it still failed with the same issue

@Adirio
Copy link
Contributor

Adirio commented Jan 26, 2021

This bug was already discovered and #1944 is working on fixing it. Sorry for the inconvenience.

@estroz
Copy link
Contributor

estroz commented Jan 26, 2021

IIRC it was decided that initializing a new project with go.mod is not supported because make could fail. Ignore this.

@camilamacedo86 camilamacedo86 added the triage/accepted Indicates an issue or PR is ready to be actively worked on. label Jan 26, 2021
@camilamacedo86 camilamacedo86 added this to the 3.1.0 milestone Jan 26, 2021
@Adirio
Copy link
Contributor

Adirio commented Jan 30, 2021

This should be fixed by #1944, if you find that it is still bugged please reopen this issue.

/close

@k8s-ci-robot
Copy link
Contributor

@Adirio: Closing this issue.

In response to this:

This should be fixed by #1944, if you find that it is still bugged please reopen this issue.

/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

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.

6 participants