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
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?????
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?????