简体   繁体   中英

Glide or dep dependencies issue, dependencies in vendor are not flat

Related code is as follow:

import (
    core "k8s.io/api/core/v1"
    metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    "k8s.io/kubernetes/pkg/api/legacyscheme"
)
...

func PodExec(clusterId string, namespace string, podName string, containerName string, cmd string) (){

    ...

    req.VersionedParams(&core.PodExecOptions{
        Container: containerName,
        Command:   []string{"bash", "-c", cmd},
        Stdin:     false,
        Stdout:    true,
        Stderr:    true,
        TTY:       false,
    }, legacyscheme.ParameterCodec) //FIXME Here is the concerned code.

}

...

glide.yaml is as follow:

package: xxx-k8s-apiserver
import:
- package: github.com/astaxie/beego
  version: v1.10.1
- package: k8s.io/api
  subpackages:
  - apps/v1
  - core/v1
- package: k8s.io/apimachinery
  subpackages:
  - pkg/api/errors
  - pkg/api/resource
  - pkg/apis/meta/v1
  - pkg/util/intstr
  - pkg/util/yaml
- package: k8s.io/client-go
  version: v10.0.0

When I run go build in my project, sth goes wrong like this.



# xxx-k8s-apiserver/models
models/pod.go:82:3: cannot use legacyscheme.ParameterCodec (type "xxx-k8s-apiserver/vendor/k8s.io/kubernetes/vendor/k8s.io/apimachinery/pkg/runtime".ParameterCodec) as type "xxx-k8s-apiserver/vendor/k8s.io/apimachinery/pkg/runtime".ParameterCodec in argument to req.VersionedParams:
        "xxx-k8s-apiserver/vendor/k8s.io/kubernetes/vendor/k8s.io/apimachinery/pkg/runtime".ParameterCodec does not implement "xxx-k8s-apiserver/vendor/k8s.io/apimachinery/pkg/runtime".ParameterCodec (wrong type for DecodeParameters method)
                have DecodeParameters(url.Values, "xxx-k8s-apiserver/vendor/k8s.io/kubernetes/vendor/k8s.io/apimachinery/pkg/runtime/schema".GroupVersion, "xxx-k8s-apiserver/vendor/k8s.io/kubernetes/vendor/k8s.io/apimachinery/pkg/runtime".Object) error
                want DecodeParameters(url.Values, "xxx-k8s-apiserver/vendor/k8s.io/apimachinery/pkg/runtime/schema".GroupVersion, "xxx-k8s-apiserver/vendor/k8s.io/apimachinery/pkg/runtime".Object) error



Then I see into the ./vendor directory, it seems like glide or dep somehow falsely organized the dependency path. Dependencies are not flat because there is another vendor in the vendor path ./vendor/k8s.io/kubernetes/vendor .

How to handle nested "vendor" directories in Go packages?

Typical nested vendor issue. Still no clues why --strip-vendor is not true by default in glide install , it causes so much inconvenience.

It's a duplicate issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM