滑行或Dep依赖性问题,供应商中的依赖性不平坦

时间:2019-02-15 03:28:23

标签: go glide-golang

相关代码如下:

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如下:

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

当我在项目中运行go build时,某事会出错。



# 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



然后我看到./vendor目录中,似乎glidedep以某种方式错误地组织了依赖路径。由于供应商路径vendor中还有另一个./vendor/k8s.io/kubernetes/vendor,因此依赖性并不平坦。

1 个答案:

答案 0 :(得分:0)

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

典型的嵌套供应商问题。仍然不知道为什么--strip-vendor中默认情况下glide install不正确,这会带来很多不便。

这是重复的问题。