github.com/caos/orbos@v1.5.14-0.20221103111702-e6cd0cea7ad4/internal/operator/networking/kinds/orb/desired.go (about) 1 package orb 2 3 import ( 4 "fmt" 5 6 "github.com/caos/orbos/mntr" 7 8 "github.com/caos/orbos/pkg/tree" 9 corev1 "k8s.io/api/core/v1" 10 ) 11 12 type DesiredV0 struct { 13 Common *tree.Common `json:",inline" yaml:",inline"` 14 Spec *Spec `json:"spec" yaml:"spec"` 15 Networking *tree.Tree 16 } 17 18 // +kubebuilder:object:generate=true 19 type Spec struct { 20 Verbose bool `json:"verbose" yaml:"verbose"` 21 NodeSelector map[string]string `json:"nodeSelector,omitempty" yaml:"nodeSelector,omitempty"` 22 Tolerations []corev1.Toleration `json:"tolerations,omitempty" yaml:"tolerations,omitempty"` 23 Version string `json:"version,omitempty" yaml:"version,omitempty"` 24 SelfReconciling bool `json:"selfReconciling" yaml:"selfReconciling"` 25 //Use this registry to pull the Networking-operator image from 26 //@default: ghcr.io 27 CustomImageRegistry string `json:"customImageRegistry,omitempty" yaml:"customImageRegistry,omitempty"` 28 } 29 30 func ParseDesiredV0(desiredTree *tree.Tree) (*DesiredV0, error) { 31 desiredKind := &DesiredV0{Common: desiredTree.Common} 32 33 if err := desiredTree.Original.Decode(desiredKind); err != nil { 34 return nil, mntr.ToUserError(fmt.Errorf("parsing desired state failed: %w", err)) 35 } 36 desiredKind.Common.OverwriteVersion("v0") 37 38 return desiredKind, nil 39 }