Operator-sdk: Problems generating client

Created on 1 Jun 2018  路  5Comments  路  Source: operator-framework/operator-sdk

Hi, I am having problems while generating client code. There are just imports with package and no functions, interfaces or structs in the files in v1alpha1 folder. Also there is only clientset folder and no other folders are in the generated folder.

update-generated.sh

#!/usr/bin/env bash

set -o errexit
set -o nounset
set -o pipefail

DOCKER_REPO_ROOT="/go/src/gitlab.com/galwaydevops/wp-operator"
IMAGE=${IMAGE:-"gcr.io/coreos-k8s-scale-testing/codegen"}

docker run --rm --privileged \
  -v "$PWD":"$DOCKER_REPO_ROOT" \
  -w "$DOCKER_REPO_ROOT" \
  "$IMAGE" \
  "/go/src/k8s.io/code-generator/generate-groups.sh"  \
  "all" \
  "gitlab.com/galwaydevops/wp-operator/pkg/generated" \
  "gitlab.com/galwaydevops/wp-operator/pkg/apis" \
  "galwaydevops:v1alpha1" \
  --go-header-file "./tmp/codegen/boilerplate.go.txt" \
  $@

logs

Generating deepcopy funcs
Generating clientset for galwaydevops:v1alpha1 at gitlab.com/galwaydevops/wp-operator/pkg/generated/clientset
Generating listers for galwaydevops:v1alpha1 at gitlab.com/galwaydevops/wp-operator/pkg/generated/listers
Generating informers for galwaydevops:v1alpha1 at gitlab.com/galwaydevops/wp-operator/pkg/generated/informers

Most helpful comment

the operator-sdk no longer generates a client at all. what is the best practice here if we need to programatically interact with out CRDs from other repos?????

All 5 comments

Did you manage to fix this issue? I'm also having trouble generating the client.

@andrestc there are comments that you have to enter for deepcopy func and there is one for generating clients. Just put this comment on top of the root struct that houses type meta, object meta, spec and status // +genclient, then regererate the files and you should get them in the generated folder. If you do not get that folder, then you will need to replace the docker run in tmp/codegen/update-generated.sh to something like this:

#!/usr/bin/env bash

set -o errexit
set -o nounset
set -o pipefail

DOCKER_REPO_ROOT="/go/src/gitlab.com/galwaydevops/wp-operator"
IMAGE=${IMAGE:-"gcr.io/coreos-k8s-scale-testing/codegen"}

docker run --rm --privileged \
  -v "$PWD":"$DOCKER_REPO_ROOT" \
  -w "$DOCKER_REPO_ROOT" \
  "$IMAGE" \
  "/go/src/k8s.io/code-generator/generate-groups.sh"  \
  "all" \
  "github.com/namespace/name/pkg/generated" \
  "gitlab.com/nemaspace/namer/pkg/apis" \
  "name:v1alpha1" \
  --go-header-file "./tmp/codegen/boilerplate.go.txt" \
  $@

Thanks, @kristiandrucker. I also had to add this function to register.go:

// Resource takes an unqualified resource and returns a Group qualified GroupResource
func Resource(resource string) schema.GroupResource {
    return SchemeGroupVersion.WithResource(resource).GroupResource()
}

@andrestc You welcome. I didn't have to add anything else than what I have written. Glad it works.

the operator-sdk no longer generates a client at all. what is the best practice here if we need to programatically interact with out CRDs from other repos?????

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hasbro17 picture hasbro17  路  3Comments

joelanford picture joelanford  路  3Comments

flickerfly picture flickerfly  路  5Comments

magescher picture magescher  路  3Comments

bobdonat picture bobdonat  路  3Comments