admin管理员组

文章数量:1315252

My Kubernetes CRD:

type FooSpec struct {
    // +kubebuilder:validation:UniqueItems=true
    MyItems []string `json:"myItems"`

Fails:

Forbidden: uniqueItems cannot be set to true since the runtime complexity becomes quadratic

This is documented: kubernetes.io validation docs


How can I ensure that the slice MyItems contains no duplicates without writing a webhook?

My Kubernetes CRD:

type FooSpec struct {
    // +kubebuilder:validation:UniqueItems=true
    MyItems []string `json:"myItems"`

Fails:

Forbidden: uniqueItems cannot be set to true since the runtime complexity becomes quadratic

This is documented: kubernetes.io validation docs


How can I ensure that the slice MyItems contains no duplicates without writing a webhook?

Share Improve this question edited Jan 30 at 8:51 guettli asked Jan 30 at 8:33 guettliguettli 27.2k105 gold badges413 silver badges758 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 2

This works: listType=set

type FooSpec struct {
    // +listType=set
    MyItems []string `json:"myItems"`

本文标签: goForbidden uniqueItems cannot be set to true since the runtime complexity becomes quadraticStack Overflow