Operator-sdk: CRD generation : map values must be a named type, not *ast.StarExpr

Created on 30 Jan 2020  路  7Comments  路  Source: operator-framework/operator-sdk

Bug Report

What did you do?

Upgraded the operator-sdk to versionv0.15.0, and used operator-sdk generate crds, to generate crd from spec : https://github.com/Orange-OpenSource/casskop/blob/master/pkg/apis/db/v1alpha1/cassandracluster_types.go#L818

What did you expect to see?

Having my crd object generated with the following logs :

$ operator-sdk generate crds
INFO[0000] Running CRD generator.
INFO[0001] CRD generation complete.

What did you see instead? Under which circumstances?

$ operator-sdk generate crds  
INFO[0000] Running CRD generator.
/Users/aguitton/workspace/casskop/casskop/pkg/apis/db/v1alpha1/cassandracluster_types.go:819:33: map values must be a named type, not *ast.StarExpr
FATA[0001] error generating CRDs from APIs in pkg/apis: error generating CRD manifests: error running CRD generator: not all generators ran successfull

Environment

  • operator-sdk version : v0.15.0
  • go-version : 0.13

Possible Solution

The operator sdk have a dependency to sigs.k8s.io/controller-tools v0.2.4, which perform the schema validation during the crd generation, this module is the root cause of the error.

To fix this, there is a PR : https://github.com/kubernetes-sigs/controller-tools/pull/317, which is not merged yet. Once the merge will be done, update the dependency should be enough (until it's done we forked the operator-sdk and the controller-tool).

help wanted kinfeature

All 7 comments

Shows that It should be closed after the pr https://github.com/kubernetes-sigs/controller-tools/issues/287 get merged and SDK be updated/using that gets a new release version of it.

HI @drnic,

Really tks for your collab. What do you think about assigning it to yourself since shows that you already provided the solution as well?

This is a controller-tools issue. We can bump the controller-tools version once this bug is fixed upstream.

@estroz they just released https://github.com/kubernetes-sigs/controller-tools/releases/tag/v0.4.0 which fixes it. Can you bump
It ?

@cscetbon are you looking for this fix for a legacy project or one created with SDK v0.19+?

@estroz for the project in the description 馃槵. It uses operator-sdk 0.18 atm

@cscetbon v0.18 is outside our backport policy unfortunately. We could probably backport this to v0.19.

Instead, you could use controller-gen directly like in the v1.0.0 Makefile:

CRD_OPTIONS ?= "crd:trivialVersions=true"

controller-gen:
ifeq (, $(shell which controller-gen))
    @{ \
    set -e ;\
    CONTROLLER_GEN_TMP_DIR=$$(mktemp -d) ;\
    cd $$CONTROLLER_GEN_TMP_DIR ;\
    go mod init tmp ;\
    go get sigs.k8s.io/controller-tools/cmd/[email protected] ;\
    rm -rf $$CONTROLLER_GEN_TMP_DIR ;\
    }
CONTROLLER_GEN=$(GOBIN)/controller-gen
else
CONTROLLER_GEN=$(shell which controller-gen)
endif

manifests: controller-gen
    $(CONTROLLER_GEN) $(CRD_OPTIONS) paths="./..." output:crd:artifacts:config=deploy/crds

We can upgrade to 0.19 if you backport it. We鈥檙e probably not the only ones to have this issue. And in the meantime use that method (will have to try it)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

smiklosovic picture smiklosovic  路  4Comments

camilamacedo86 picture camilamacedo86  路  4Comments

joelanford picture joelanford  路  3Comments

chowmean picture chowmean  路  5Comments

ffoysal picture ffoysal  路  3Comments