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

operator-sdk create api: unknown flag: --version #4744

Closed
Dentrax opened this issue Apr 12, 2021 · 5 comments
Closed

operator-sdk create api: unknown flag: --version #4744

Dentrax opened this issue Apr 12, 2021 · 5 comments
Assignees
Labels
triage/support Indicates an issue that is a support question.
Milestone

Comments

@Dentrax
Copy link

Dentrax commented Apr 12, 2021

What is the URL of the document?

https://sdk.operatorframework.io/docs/building-operators/golang/quickstart/#steps

Which section(s) is the issue in?

Create a simple Memcached API:

What needs fixing?

$ operator-sdk create api --version v1alpha1 --kind Hello

Error: unknown flag: --version
Usage:
  operator-sdk create api [flags]

Flags:
  -h, --help   help for api

Global Flags:
      --plugins strings          plugin keys of the plugin to initialize the project with
      --project-version string   project version
      --verbose                  Enable verbose logging

FATA[0000] unknown flag: --version
$ operator-sdk version

operator-sdk version: "v1.5.0", commit: "98f30d59ade2d911a7a8c76f0169a7de0dec37a0", kubernetes version: "v1.19.4", go version: "go1.16.1", GOOS: "darwin", GOARCH: "amd64"
@camilamacedo86
Copy link
Contributor

camilamacedo86 commented Apr 12, 2021

Hi @Dentrax,

The problem might be the go version. go version: "go1.16.1" . That is not supported we need an version => 1.15 and < 1.16.

Also, the instruction is:

operator-sdk create api --group cache --version v1alpha1 --kind Memcached --resource --controller

And you are using:

operator-sdk create api --version v1alpha1 --kind Hello

@Dentrax
Copy link
Author

Dentrax commented Apr 12, 2021

Hi @camilamacedo86

Hmm, I could not see those flag instructions (--group, --version, --kind, --resource and --controller) on --help flag, due to operator-sdk version, I guess. 🤔

$ operator-sdk create api --help

Scaffold a Kubernetes API.

Note: unable to find configuration file, project must be initialized

Usage:
  operator-sdk create api [flags]

Flags:
  -h, --help   help for api

Global Flags:
      --plugins strings          plugin keys of the plugin to initialize the project with
      --project-version string   project version
      --verbose                  Enable verbose logging

@camilamacedo86
Copy link
Contributor

That will be solved with the next kb bump in SDK to address: kubernetes-sigs/kubebuilder#2126

@estroz
Copy link
Member

estroz commented Apr 12, 2021

This may have been fixed in master, but needs investigation.

/assign @jmrodri
/triage support
/remove-kind documentation

@openshift-ci-robot openshift-ci-robot added triage/support Indicates an issue that is a support question. and removed kind/documentation Categorizes issue or PR as related to documentation. labels Apr 12, 2021
@estroz estroz added this to the Backlog milestone Apr 12, 2021
@jmrodri
Copy link
Member

jmrodri commented Apr 13, 2021

this has been fixed in the master branch, should be fix in v1.6.0 when it is released.

Verification v1.5.0

Verified that the problem currently exists in v1.5.0.

$ operator-sdk version
operator-sdk version: "v1.5.0", commit: "98f30d59ade2d911a7a8c76f0169a7de0dec37a0", kubernetes version: "v1.19.4", go version: "go1.15.8", GOOS: "linux", GOARCH: "amd64"

In an empty directory,

$ ls
$ operator-sdk create api --version v1alpha1 --kind Hello
Error: unknown flag: --version
Usage:
  operator-sdk create api [flags]

Flags:
  -h, --help   help for api

Global Flags:
      --plugins strings          plugin keys of the plugin to initialize the project with
      --project-version string   project version
      --verbose                  Enable verbose logging

FATA[0000] unknown flag: --version   

Verification using master

Again in an empty directory, but this time a more detailed help will print out.

$ ls
$ operator-sdk create api --version v1alpha1 --kind Hello               
Error: failed to create API: unable to load configuration file: unable to load the configuration: unable to read "PROJECT" file: open PROJECT: no such file or directory
Usage:                                                                                         
  operator-sdk create api [flags]                                                                                                                                                             
                                               
Examples:
  # Create a frigates API with Group: ship, Version: v1beta1 and Kind: Frigate
  operator-sdk create api --group ship --version v1beta1 --kind Frigate       
                                                                                               
  # Edit the API Scheme
  nano api/v1beta1/frigate_types.go                                                                                                                                                           
                                               
  # Edit the Controller
  nano controllers/frigate/frigate_controller.go

  # Edit the Controller Test
  nano controllers/frigate/frigate_controller_test.go

  # Install CRDs into the Kubernetes cluster using kubectl apply
  make install

  # Regenerate code and run against the Kubernetes cluster configured by ~/.kube/config
  make run


Flags:
      --controller           if set, generate the controller without prompting the user (default true)
      --crd-version string   version of CustomResourceDefinition to scaffold. Options: [v1, v1beta1] (default "v1")
      --force                attempt to create resource even if it already exists
      --group string         resource Group
  -h, --help                 help for api
      --kind string          resource Kind
      --make make generate   if true, run make generate after generating files (default true)
      --namespaced           resource is namespaced (default true)
      --plural string        resource irregular plural form
      --resource             if set, generate the resource without prompting the user (default true)
      --version string       resource Version

Global Flags:
      --plugins strings   plugin keys to be used for this subcommand execution
      --verbose           Enable verbose logging

FATA[0000] failed to create API: unable to load configuration file: unable to load the configuration: unable to read "PROJECT" file: open PROJECT: no such file or directory 

@jmrodri jmrodri closed this as completed Apr 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage/support Indicates an issue that is a support question.
Projects
None yet
Development

No branches or pull requests

5 participants