0

I am including a library

"github.com/k8snetworkplumbingwg/network-attachment-definition-client/pkg/client/clientset/versioned/typed/k8s.cni.cncf.io/v1"

in kubernetes source code, this is for internal purpose (kubernetes devs will not like it)

while compiling it I am getting an issue:

+++ [0515 07:51:26] Building go targets for linux/amd64:
    test/e2e/e2e.test
# k8s.io/kubernetes/test/e2e/framework
test/e2e/framework/framework.go:239:44: cannot use config (type *"k8s.io/kubernetes/vendor/k8s.io/client-go/rest".Config) as type *"k8s.io/kubernetes/vendor/github.com/k8snetworkplumbingwg/network-attachment-definition-client/vendor/k8s.io/client-go/rest".Config in argument to "k8s.io/kubernetes/vendor/github.com/k8snetworkplumbingwg/network-attachment-definition-client/pkg/client/clientset/versioned/typed/k8s.cni.cncf.io/v1".NewForConfig
test/e2e/framework/framework_multus.go:14:3: cannot use "k8s.io/kubernetes/vendor/k8s.io/apimachinery/pkg/apis/meta/v1".ObjectMeta literal (type "k8s.io/kubernetes/vendor/k8s.io/apimachinery/pkg/apis/meta/v1".ObjectMeta) as type "k8s.io/kubernetes/vendor/github.com/k8snetworkplumbingwg/network-attachment-definition-client/vendor/k8s.io/apimachinery/pkg/apis/meta/v1".ObjectMeta in field value
!!! [0515 07:51:30] Call tree:
!!! [0515 07:51:30]  1: /home/eccd/go/src/k8s.io/kubernetes/hack/lib/golang.sh:853 kube::golang::build_binaries_for_platform(...)
!!! [0515 07:51:30]  2: hack/make-rules/build.sh:27 kube::golang::build_binaries(...)
!!! [0515 07:51:30] Call tree:
!!! [0515 07:51:30]  1: hack/make-rules/build.sh:27 kube::golang::build_binaries(...)
!!! [0515 07:51:30] Call tree:
!!! [0515 07:51:30]  1: hack/make-rules/build.sh:27 kube::golang::build_binaries(...)
make: *** [Makefile:93: all] Error 1

In line 239 it says expected type "k8s.io/kubernetes/vendor/github.com/k8snetworkplumbingwg/network-attachment-definition-client/vendor/k8s.io/client-go/rest".Config but passed of type "k8s.io/kubernetes/vendor/k8s.io/client-go/rest".Config.

But if you see what is after "vendor" both are same i.e. k8s.io/client-go/rest".Config

How to solve this issue, any help or pointers?

nmathew
  • 3
  • 3
  • 1
    The package path is part of the type, if the package path is different then the type is different, i.e. if you have a single package, you create a copy next to it, and then you have a program that imports both and tries to use them interchangeably, that ain't gonna work. That's the scenario you're in, you have two copies of a single package in two different locations. – mkopriva May 15 '20 at 08:38
  • 1
    ... so to fix this you need to make sure that your program and the k8s code both import the same copy of the package, not a different one. You can often remedy the problem by removing nested vendors, i.e. moving the vendored dependencies of a vendored dependency into the root vendor. – mkopriva May 15 '20 at 08:40
  • Thanks @mkopriva, But I have no control in package github.com/k8snetworkplumbingwg/network-attachment-definition-client/pkg/client/clientset/versioned/typed/k8s.cni.cncf.io/v1, how I will do it. Any pointers? – nmathew May 15 '20 at 09:12
  • "The package path is part of the type " why golang choose this design? – nmathew May 15 '20 at 09:15
  • my go compiler version is 1.12.9 – nmathew May 15 '20 at 10:07
  • *"why golang choose this design?"* I don't know, but if you have questions about the decision process you can try the #go-nuts mailing list, it is frequented by many of the go team's members so there's some chance that you'll get an accurate answer. – mkopriva May 15 '20 at 11:21

0 Answers0