kubernetes-sigs / kustomize

Customization of kubernetes YAML configurations
Apache License 2.0
10.95k stars 2.24k forks source link

kustomize get compile error when using github.com/swaggo #3443

Closed kaiguoo closed 3 years ago

kaiguoo commented 3 years ago

I could use helm.sh/helm/v3 (v3.4.2) in my project without any problem. but if I add github.com/swaggo in my project got following compile error

sigs.k8s.io/kustomize/pkg/transformers/config /home/xxxxx/go/pkg/mod/sigs.k8s.io/kustomize@v2.0.3+incompatible/pkg/transformers/config/factorycrd.go:71:47: cannot use api.Schema.SchemaProps.Properties (type spec.SchemaProperties) as type myProperties in argument to looksLikeAk8sType

this compile error occurred only in combination with helm.sh/helm/v3

uid09552 commented 3 years ago

might be fixed by this

3444

monopole commented 3 years ago

The line

sigs.k8s.io/kustomize/pkg/transformers/config
/home/xxxxx/go/pkg/mod/sigs.k8s.io/kustomize@v2.0.3+incompatible/

suggests that some go.mod file is using a very old abandoned version of kustomize libraries.

Please emulate how the kustomize CLI program refers to the kustomize libraries here: https://github.com/kubernetes-sigs/kustomize/blob/master/kustomize/go.mod#L11

The go.mod line is

require sigs.k8s.io/kustomize/api v0.7.1

Soon that will be v0.7.2, etc. It's released every two weeks.

Please reopen if you have any questions

Vaibhav619 commented 3 years ago

@monopole I am also facing. same issue. Tried the below one but didn't help

sigs.k8s.io/kustomize/api v0.7.2

my go.sum dependency for kustomize is

sigs.k8s.io/kustomize v2.0.3+incompatible 
sigs.k8s.io/kustomize v2.0.3+incompatible/go.mod

Error coming

 cannot use api.Schema.SchemaProps.Properties (type spec.SchemaProperties) as type myProperties in argument to looksLikeAk8sType
erir910 commented 3 years ago

Did you manage to solve this issue @Vaibhav619 ? Why is the norm among Golang people to close unresolved issues?

erir910 commented 3 years ago

@monopole You closed the issue and at the same you don't want to accept the pull request the solves the issue.

Vaibhav619 commented 3 years ago

@erir910 I am not able to solve the issue. Issue is still there for me.

monopole commented 3 years ago

@Vaibhav619 Are you intentionally depending on

sigs.k8s.io/kustomize v2.0.3+incompatible 

That release was made almost two years ago.

It's ok to use old versions, but i'd like to reproduce the error.

Can you point to a go.mod file in github that's using this? I'd like a clearer picture of the use case.

@erir910, @uid09552 #3444 is reopened, but still needs a signed CLA.

erir910 commented 3 years ago

@monopole My problem isn't that I import kustomize directly, my problem is I imported helmv3 packages which import kubectl package which in turn imports kustomize v2.0.3+incompatible. Removing my helmv3 dependent code makes the build succeed

Vaibhav619 commented 3 years ago

@monopole Please find my go.mod file My go.mod file


require (
    bitbucket.org/liamstask/goose v0.0.0-20150115234039-8488cc47d90c // indirect
    cloud.google.com/go v0.55.0 // indirect
    github.com/Bowery/prompt v0.0.0-20190916142128-fa8279994f75 // indirect
    github.com/DATA-DOG/go-sqlmock v1.5.0
    github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible // indirect
    github.com/MichaelTJones/walk v0.0.0-20161122175330-4748e29d5718 // indirect
    github.com/abiosoft/semaphore v0.0.0-20180811165425-cb737ff681bd // indirect
    github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751
    github.com/alecthomas/units v0.0.0-20201120081800-1786d5ef83d4 // indirect
    github.com/aliyun/aliyun-oss-go-sdk v2.0.6+incompatible // indirect
    github.com/andygrunwald/go-jira v1.12.0
    github.com/argoproj/argo v2.5.2+incompatible
    github.com/argoproj/argo-rollouts v0.9.2
    github.com/argoproj/pkg v0.3.0 // indirect
    github.com/baiyubin/aliyun-sts-go-sdk v0.0.0-20180326062324-cfa1a18b161f // indirect
    github.com/bluele/gcache v0.0.0-20190518031135-bc40bd653833 // indirect
    github.com/bradleyfalzon/ghinstallation v1.1.1
    github.com/codegangsta/negroni v1.0.0
    github.com/colinmarc/hdfs v1.1.4-0.20180805212432-9746310a4d31 // indirect
    github.com/dave/dst v0.26.2 // indirect
    github.com/dchest/safefile v0.0.0-20151022103144-855e8d98f185 // indirect
    github.com/dgrijalva/jwt-go v3.2.0+incompatible
    github.com/elastic/go-elasticsearch/v7 v7.0.0
    github.com/fatih/structs v1.1.0 // indirect
    github.com/fsnotify/fsnotify v1.4.9 // indirect
    github.com/fzipp/gocyclo v0.3.1 // indirect
    github.com/gavv/httpexpect/v2 v2.0.3 // indirect
    github.com/ghodss/yaml v1.0.1-0.20190212211648-25d852aebe32
    github.com/gin-gonic/gin v1.6.3
    github.com/go-critic/go-critic v0.5.3 // indirect
    github.com/go-ini/ini v1.51.1 // indirect
    github.com/go-sql-driver/mysql v1.5.0
    github.com/go-toolsmith/pkgload v1.0.1 // indirect
    github.com/gojektech/heimdall v5.0.2+incompatible
    github.com/gojektech/valkyrie v0.0.0-20190210220504-8f62c1e7ba45 // indirect
    github.com/google/go-github/v28 v28.1.1 // indirect
    github.com/google/go-github/v32 v32.1.0
    github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
    github.com/googleapis/gnostic v0.3.1 // indirect
    github.com/gophercloud/gophercloud v0.7.0 // indirect
    github.com/gorilla/websocket v1.4.2 // indirect
    github.com/grpc-ecosystem/go-grpc-middleware v1.1.0 // indirect
    github.com/hashicorp/go-uuid v1.0.2 // indirect
    github.com/howeyc/gopass v0.0.0-20190910152052-7cb4b85ec19c // indirect
    github.com/imdario/mergo v0.3.8
    github.com/imkira/go-interpol v1.1.0 // indirect
    github.com/jcmturner/gofork v1.0.0 // indirect
    github.com/jinzhu/gorm v1.9.16
    github.com/jmoiron/sqlx v1.2.0
    github.com/jpillora/backoff v1.0.0
    github.com/julienschmidt/httprouter v1.3.0
    github.com/justinas/alice v0.0.0-20171023064455-03f45bd4b7da
    github.com/kardianos/govendor v1.0.9 // indirect
    github.com/klauspost/compress v1.9.7 // indirect
    github.com/kylelemons/go-gypsy v0.0.0-20160905020020-08cad365cd28 // indirect
    github.com/lib/pq v1.3.0 // indirect
    github.com/logrusorgru/aurora v2.0.3+incompatible // indirect
    github.com/mattn/go-colorable v0.1.8 // indirect
    github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect
    github.com/mgutz/str v1.2.0 // indirect
    github.com/minio/minio-go v6.0.14+incompatible // indirect
    github.com/mitchellh/go-ps v0.0.0-20190716172923-621e5597135b // indirect
    github.com/onsi/ginkgo v1.12.0
    github.com/onsi/gomega v1.9.0
    github.com/pkg/errors v0.9.1
    github.com/pmezard/go-difflib v1.0.0
    github.com/prometheus/client_golang v1.7.1 // indirect
    github.com/quasilyte/go-ruleguard v0.2.1 // indirect
    github.com/quasilyte/regex/syntax v0.0.0-20200805063351-8f842688393c // indirect
    github.com/r3labs/diff/v2 v2.8.0
    github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a
    github.com/robfig/cron v1.2.0 // indirect
    github.com/robfig/cron/v3 v3.0.1 // indirect
    github.com/rs/xid v1.2.1
    github.com/satori/go.uuid v1.2.0
    github.com/segmentio/golines v0.0.0-20200824192126-7f30d3046793 // indirect
    github.com/sergi/go-diff v1.1.0 // indirect
    github.com/sirupsen/logrus v1.7.0 // indirect
    github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966 // indirect
    github.com/stretchr/testify v1.6.1
    github.com/swaggo/files v0.0.0-20190704085106-630677cd5c14
    github.com/swaggo/gin-swagger v1.3.0
    github.com/swaggo/swag v1.7.0
    github.com/tidwall/gjson v1.3.5 // indirect
    github.com/uber-go/tally v3.3.12+incompatible
    github.com/valyala/fasttemplate v1.2.1 // indirect
    github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
    github.com/xeipuuv/gojsonschema v1.2.0 // indirect
    github.com/ziutek/mymysql v1.5.4 // indirect
    go.uber.org/atomic v1.5.1 // indirect
    go.uber.org/multierr v1.1.0
    go.uber.org/zap v1.10.0
    golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad // indirect
    golang.org/x/mod v0.4.0 // indirect
    golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d
    golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c // indirect
    golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf // indirect
    golang.org/x/tools v0.1.0 // indirect
    gopkg.in/DATA-DOG/go-sqlmock.v1 v1.3.0
    gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect
    gopkg.in/go-playground/validator.v8 v8.18.2
    gopkg.in/go-playground/webhooks.v5 v5.17.0
    gopkg.in/godo.v2 v2.0.9
    gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df
    gopkg.in/jcmturner/goidentity.v2 v2.0.0 // indirect
    gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22 // indirect
    gopkg.in/square/go-jose.v2 v2.2.2
    gopkg.in/src-d/go-git.v4 v4.13.1 // indirect
    gopkg.in/validator.v2 v2.0.0-20200605151824-2b28d334fa05 // indirect
    gopkg.in/yaml.v2 v2.4.0
    gotest.tools v2.2.0+incompatible
    helm.sh/helm/v3 v3.1.3
    k8s.io/api v0.17.8
    k8s.io/apimachinery v0.17.8
    k8s.io/cli-runtime v0.17.8
    k8s.io/client-go v0.17.8
    k8s.io/utils v0.0.0-20191218082557-f07c713de883 // indirect
    rsc.io/letsencrypt v0.0.3 // indirect
    sigs.k8s.io/kustomize/api v0.8.1
    upper.io/db.v3 v3.6.3+incompatible // indirect
)

//required to resolve dependency conflicts
replace (
    k8s.io/api => k8s.io/api v0.17.8
    k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.17.8
    k8s.io/apimachinery => k8s.io/apimachinery v0.17.8
    k8s.io/apiserver => k8s.io/apiserver v0.17.8
    k8s.io/cli-runtime => k8s.io/cli-runtime v0.17.8
    k8s.io/client-go => k8s.io/client-go v0.17.8
    k8s.io/cloud-provider => k8s.io/cloud-provider v0.17.8
    k8s.io/cluster-bootstrap => k8s.io/cluster-bootstrap v0.17.8
    k8s.io/code-generator => k8s.io/code-generator v0.17.8
    k8s.io/component-base => k8s.io/component-base v0.17.8
    k8s.io/cri-api => k8s.io/cri-api v0.17.8
    k8s.io/csi-translation-lib => k8s.io/csi-translation-lib v0.17.8
    k8s.io/kube-aggregator => k8s.io/kube-aggregator v0.17.8
    k8s.io/kube-controller-manager => k8s.io/kube-controller-manager v0.17.8
    k8s.io/kube-openapi => k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a // indirect
    k8s.io/kube-proxy => k8s.io/kube-proxy v0.17.8
    k8s.io/kube-scheduler => k8s.io/kube-scheduler v0.17.8
    k8s.io/kubectl => k8s.io/kubectl v0.17.8
    k8s.io/kubelet => k8s.io/kubelet v0.17.8
    k8s.io/legacy-cloud-providers => k8s.io/legacy-cloud-providers v0.17.8
    k8s.io/metrics => k8s.io/metrics v0.17.8
    k8s.io/sample-apiserver => k8s.io/sample-apiserver v0.17.8
)
go 1.13

My error logs when tried to build

# sigs.k8s.io/kustomize/pkg/transformers/config
../../go/pkg/mod/sigs.k8s.io/kustomize@v2.0.3+incompatible/pkg/transformers/config/factorycrd.go:71:47: cannot use api.Schema.SchemaProps.Properties (type spec.SchemaProperties) as type myProperties in argument to looksLikeAk8sType

@monopole After adding this build started failing

github.com/swaggo/files v0.0.0-20190704085106-630677cd5c14
github.com/swaggo/gin-swagger v1.3.0
github.com/swaggo/swag v1.7.0
foxish commented 3 years ago

I found that in my case on a related issue caused by swaggo/swag breaking my build, the issue was with the version of github.com/go-openapi/spec that was being brought in by cli-runtime and swaggo being different.

go mod graph | grep go-openapi/spec
...
github.com/swaggo/swag@v1.7.0 github.com/go-openapi/spec@v0.19.14
k8s.io/cli-runtime@v0.17.3 github.com/go-openapi/spec@v0.19.3

Solved it by pinning the version of that library.

replace github.com/go-openapi/spec => github.com/go-openapi/spec v0.19.3
cache-sk commented 3 years ago

Well, solution proposed by @foxish brought another issue for me..

/home/cache/go/pkg/mod/github.com/swaggo/swag@v1.7.0/operation.go:249:30: schema.SchemaProps.Properties.ToOrderedSchemaItems undefined (type map[string]spec.Schema has no field or method ToOrderedSchemaItems)

So i must "upgrade" generated docs package to full module and use replace github.com/go-openapi/spec => github.com/go-openapi/spec v0.19.3 in main go.mod and v0.20.3 in docs go.mod..

monopole commented 3 years ago

More notes here https://github.com/kubernetes-sigs/kustomize/blob/master/cmd/depprobcheck/README.md

lqywow commented 2 years ago

Well, solution proposed by @foxish brought another issue for me..

/home/cache/go/pkg/mod/github.com/swaggo/swag@v1.7.0/operation.go:249:30: schema.SchemaProps.Properties.ToOrderedSchemaItems undefined (type map[string]spec.Schema has no field or method ToOrderedSchemaItems)

So i must "upgrade" generated docs package to full module and use replace github.com/go-openapi/spec => github.com/go-openapi/spec v0.19.3 in main go.mod and v0.20.3 in docs go.mod..

@cache-sk I met the same problem. How can I "upgrade" generated docs package to full module

smjt-h commented 11 months ago

I am facing the same issue, Any idea @cache-sk , @lqywow how to bypass this?