相关代码如下:
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
目录中,似乎glide
或dep
以某种方式错误地组织了依赖路径。由于供应商路径vendor
中还有另一个./vendor/k8s.io/kubernetes/vendor
,因此依赖性并不平坦。
答案 0 :(得分:0)
How to handle nested "vendor" directories in Go packages?
典型的嵌套供应商问题。仍然不知道为什么--strip-vendor
中默认情况下glide install
不正确,这会带来很多不便。
这是重复的问题。