Skip to content

Commit

Permalink
Merge pull request #239 from dprince/core_api
Browse files Browse the repository at this point in the history
Add *Core structs
  • Loading branch information
openshift-merge-bot[bot] committed Mar 5, 2024
2 parents c8756a9 + 79d50d3 commit 67e8aec
Show file tree
Hide file tree
Showing 8 changed files with 109 additions and 23 deletions.
13 changes: 9 additions & 4 deletions api/v1beta1/ovncontroller_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@ const (

// OVNControllerSpec defines the desired state of OVNController
type OVNControllerSpec struct {
// +kubebuilder:validation:Optional
// +kubebuilder:default={}
ExternalIDS OVSExternalIDs `json:"external-ids"`

// +kubebuilder:validation:Required
// Image used for the ovsdb-server and ovs-vswitchd containers (will be set to environmental default if empty)
OvsContainerImage string `json:"ovsContainerImage"`
Expand All @@ -49,6 +45,15 @@ type OVNControllerSpec struct {
// Image used for the ovn-controller container (will be set to environmental default if empty)
OvnContainerImage string `json:"ovnContainerImage"`

OVNControllerSpecCore `json:",inline"`
}

// OVNControllerSpecCore -
type OVNControllerSpecCore struct {
// +kubebuilder:validation:Optional
// +kubebuilder:default={}
ExternalIDS OVSExternalIDs `json:"external-ids"`

// +kubebuilder:validation:Optional
// +optional
NicMappings map[string]string `json:"nicMappings,omitempty"`
Expand Down
6 changes: 6 additions & 0 deletions api/v1beta1/ovncontroller_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ func (spec *OVNControllerSpec) Default() {
if spec.OvnContainerImage == "" {
spec.OvnContainerImage = ovnDefaults.OvnControllerContainerImageURL
}
spec.OVNControllerSpecCore.Default()
}

// Default - set defaults for this OVNController core spec (this version is called by OpenStackControlplane webhooks)
func (spec *OVNControllerSpecCore) Default() {
// nothing here yet
}

//+kubebuilder:webhook:path=/validate-ovn-openstack-org-v1beta1-ovncontroller,mutating=false,failurePolicy=fail,sideEffects=None,groups=ovn.openstack.org,resources=ovncontrollers,verbs=create;update,versions=v1beta1,name=vovncontroller.kb.io,admissionReviewVersions=v1
Expand Down
7 changes: 6 additions & 1 deletion api/v1beta1/ovndbcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,16 @@ const (

// OVNDBClusterSpec defines the desired state of OVNDBCluster
type OVNDBClusterSpec struct {

// +kubebuilder:validation:Required
// ContainerImage - Container Image URL (will be set to environmental default if empty)
ContainerImage string `json:"containerImage"`

OVNDBClusterSpecCore `json:",inline"`
}

// OVNDBClusterSpecCore -
type OVNDBClusterSpecCore struct {

// +kubebuilder:validation:Required
// +kubebuilder:default="NB"
// +kubebuilder:validation:Pattern="^NB|SB$"
Expand Down
6 changes: 6 additions & 0 deletions api/v1beta1/ovndbcluster_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ func (spec *OVNDBClusterSpec) Default() {
spec.ContainerImage = ovnDbClusterDefaults.SBContainerImageURL
}
}
spec.OVNDBClusterSpecCore.Default()
}

// Default - set defaults for this OVNDBCluster core spec (this version is called by OpenStackControlplane webhooks)
func (spec *OVNDBClusterSpecCore) Default() {
// nothing here yet
}

// TODO(user): change verbs to "verbs=create;update;delete" if you want to enable deletion validation.
Expand Down
6 changes: 6 additions & 0 deletions api/v1beta1/ovnnorthd_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ type OVNNorthdSpec struct {
// ContainerImage - Container Image URL (will be set to environmental default if empty)
ContainerImage string `json:"containerImage"`

OVNNorthdSpecCore `json:",inline"`
}

// OVNNorthdSpecCore -
type OVNNorthdSpecCore struct {

// +kubebuilder:validation:Optional
// +kubebuilder:default=1
// +kubebuilder:validation:Maximum=32
Expand Down
6 changes: 6 additions & 0 deletions api/v1beta1/ovnnorthd_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ func (spec *OVNNorthdSpec) Default() {
if spec.ContainerImage == "" {
spec.ContainerImage = ovnNorthdDefaults.ContainerImageURL
}
spec.OVNNorthdSpecCore.Default()
}

// Default - set defaults for this OVNNorthd core spec (this version is called by OpenStackControlplane webhooks)
func (spec *OVNNorthdSpecCore) Default() {
// nothing here yet
}

// TODO(user): change verbs to "verbs=create;update;delete" if you want to enable deletion validation.
Expand Down
66 changes: 57 additions & 9 deletions api/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 13 additions & 9 deletions tests/functional/base_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,11 @@ const (

func GetDefaultOVNNorthdSpec() ovnv1.OVNNorthdSpec {
return ovnv1.OVNNorthdSpec{
// TODO: Create() doesn't apply kubebuilder defaults, in contrast to
// CreateUnstructured for some reason; need to understand why
LogLevel: "info",
OVNNorthdSpecCore: ovnv1.OVNNorthdSpecCore{
// TODO: Create() doesn't apply kubebuilder defaults, in contrast to
// CreateUnstructured for some reason; need to understand why
LogLevel: "info",
},
}
}

Expand All @@ -63,12 +65,14 @@ func OVNNorthdConditionGetter(name types.NamespacedName) condition.Conditions {

func GetDefaultOVNDBClusterSpec() ovnv1.OVNDBClusterSpec {
return ovnv1.OVNDBClusterSpec{
DBType: v1beta1.NBDBType,
// TODO: Create() doesn't apply kubebuilder defaults, in contrast to
// CreateUnstructured for some reason; need to understand why
LogLevel: "info",
StorageRequest: "1G",
StorageClass: "local-storage",
OVNDBClusterSpecCore: ovnv1.OVNDBClusterSpecCore{
DBType: v1beta1.NBDBType,
// TODO: Create() doesn't apply kubebuilder defaults, in contrast to
// CreateUnstructured for some reason; need to understand why
LogLevel: "info",
StorageRequest: "1G",
StorageClass: "local-storage",
},
}
}

Expand Down

0 comments on commit 67e8aec

Please sign in to comment.