codego123
codego123

Reputation: 301

How to access non-primitive type of data from a k8s customer resource using dynamic client + unstructured

I have a K8s custom resource where the Spec looks like the following:

type Spec1 struct {
  field1 string
  field2 int64
  field3 []MyType
}

type MyType struct {
  a string
  b string
}

Now I am using dynamic client to access this k8s resource and using unstructured.Example:

f1 := unstructured.NestedString(obj.Object, "spec", "field1")

How can I access field3[0].a here which is of type MyType?

unstructured documentation has no information about accessing non-primitive data type.

Upvotes: 0

Views: 42

Answers (0)

Related Questions