doudianhuo1129 2019-09-22 14:16
浏览 93
已采纳

如何解析多个对象的引用

I am using the go-client library.
I am searching for mounted secrets inside the workload.
In my example we have two workloads: daemonset and deployments.
Although both of them are different objects, they have similar structure:

type DaemonSet struct {
    metav1.TypeMeta `json:",inline"`
    metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
    Spec DaemonSetSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"`
    Status DaemonSetStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"`
}


type Deployment struct {
    metav1.TypeMeta `json:",inline"`
    metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
    Spec DeploymentSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"`
    Status DeploymentStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"`
}

I am getting errors of:

Unresolved reference

This happens because the compilation doesn't know what object I am referring to: v1beta2.DaemonSetList or v1beta2.DeploymentList.

How can I resolve it for both of them ?

enter image description here

  • 写回答

1条回答

  • dongying3744 2019-09-22 14:26
    关注

    no. This happens because your variable controllerList is not declared in the right scope.

    it must be declared in the common scope shared by both the for loop and the switch statement, the parent scope, IE the if controllerName != ....

    ** Note that to post on SO you must NOT include screenshot of the code, but provide a minimal reproducible example of the code, copy && pasted && linted in your post.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 有没有帮写代码做实验仿真的
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥30 vmware exsi重置后登不上
  • ¥15 易盾点选的cb参数怎么解啊
  • ¥15 MATLAB运行显示错误,如何解决?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题