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 ?
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.