operator-sdk: FATA[0020] failed to initialize project: unable to scaffold with "base.go.kubebuilder.io/v3": exit status 2

First tutorial command fails:

operator-sdk init --domain mypopescu.com --repo github.com/al3xandru/memcached-operator.

The other similar issues suggest an incompatible go version. I made sure the above runs with go 1.16:

go version go1.16.14 darwin/amd64

Output

Writing kustomize manifests for you to edit...
Writing scaffold for you to edit...
Get controller runtime:
$ go get sigs.k8s.io/controller-runtime@v0.11.0
go: downloading github.com/evanphx/json-patch v0.5.2
go: downloading k8s.io/client-go v1.5.2
# sigs.k8s.io/json/internal/golang/encoding/json
/Users/alexandp/go/pkg/mod/sigs.k8s.io/json@v0.0.0-20211020170558-c049b76a60c6/internal/golang/encoding/json/encode.go:1249:12: sf.IsExported undefined (type reflect.StructField has no field or method IsExported)
/Users/alexandp/go/pkg/mod/sigs.k8s.io/json@v0.0.0-20211020170558-c049b76a60c6/internal/golang/encoding/json/encode.go:1255:18: sf.IsExported undefined (type reflect.StructField has no field or method IsExported)
Error: failed to initialize project: unable to scaffold with "base.go.kubebuilder.io/v3": exit status 2

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 18 (9 by maintainers)

Most upvoted comments

  1. It would be great if the required version of Go was clearly communicated. Different issues are directing users to use 1.16 not 1.17
  2. With Go 1.17, it is the second step of the tutorial that fails.

@al3xandru you may have to bump the go version to 1.17. kubernetes-sigs/json has StructField.IsExported added which was introduced only in 1.17. Ref: https://pkg.go.dev/reflect#StructField.IsExported