2

相关代码如下:

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

4

1 回答 1

0

如何处理 Go 包中嵌套的“供应商”目录?

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

这是一个重复的问题。

于 2019-02-15T06:01:42.117 回答