code-generator is not getting downloaded to vendor folder

5/25/2020

I am trying to create a CRD following the instructions here + using go modules.

My go.mod looks like this:

module github.com/v*****va/kustred

go 1.14

require (
        github.com/golangci/golangci-lint v1.25.0 // indirect
        github.com/google/go-cmp v0.4.0 // indirect
        github.com/json-iterator/go v1.1.9 // indirect
        github.com/kr/pretty v0.2.0 // indirect
        golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2 // indirect
        gopkg.in/yaml.v2 v2.3.0 // indirect
        gotest.tools/gotestsum v0.4.2 // indirect
        k8s.io/apimachinery v0.18.3
        k8s.io/code-generator v0.18.3 // indirect
)

After I ran go mod vendor, I looked at the contents of vendor/k8s.io/, I see that only apimachinery and klog are present, code-generator is missing. I am not sure about relevance of vendor.moudles.txt but there is a line about code-generator commented out.

Am i missing something?

-- Tech Junkie
go
kubernetes

1 Answer

5/25/2020

It's indirect in this module file, so probably not needed (not imported by your code). That's why it's unnecessary to vendor.

It's tracked because it's a dependency of your machinery dependency but actually packages you're using from machinery don't need packages from code-generator.

If you want to vendor it explicitly, you can do a blank import somewhere in your code such that

import _ "k8s.io/code-generator"
-- ferhat elmas
Source: StackOverflow