Skip to content

Commit

Permalink
Move SetupServiceOperatorDefaults to openstack pkg
Browse files Browse the repository at this point in the history
Mova SetupServiceOperatorDefaults from main to openstack pkg to allow
calling it both from main and suite_test so both codepath will do the
same defaulting.
  • Loading branch information
gibizer committed Dec 4, 2023
1 parent f62f8ec commit f5b4794
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 65 deletions.
66 changes: 2 additions & 64 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ import (
corev1 "github.com/openstack-k8s-operators/openstack-operator/apis/core/v1beta1"
clientcontrollers "github.com/openstack-k8s-operators/openstack-operator/controllers/client"
corecontrollers "github.com/openstack-k8s-operators/openstack-operator/controllers/core"
"github.com/openstack-k8s-operators/openstack-operator/pkg/openstack"
//+kubebuilder:scaffold:imports
)

Expand Down Expand Up @@ -199,7 +200,7 @@ func main() {
}

// Defaults for service operators
setupServiceOperatorDefaults()
openstack.SetupServiceOperatorDefaults()

// Defaults for OpenStackClient
clientv1.SetupDefaults()
Expand Down Expand Up @@ -242,66 +243,3 @@ func main() {
os.Exit(1)
}
}

// Set up any defaults used by service operator defaulting logic
func setupServiceOperatorDefaults() {
// Acquire environmental defaults and initialize service operators that
// require each respective default

// Cinder
cinderv1.SetupDefaults()

// Glance
glancev1.SetupDefaults()

// Ironic
ironicv1.SetupDefaults()

// Keystone
keystonev1.SetupDefaults()

// Manila
manilav1.SetupDefaults()

// MariaDB
mariadbv1.SetupDefaults()

// Memcached
memcachedv1.SetupDefaults()

// Neutron
neutronv1.SetupDefaults()

// Nova
novav1.SetupDefaults()

// OVN
ovnv1.SetupDefaults()

// Placement
placementv1.SetupDefaults()

// Heat
heatv1.SetupDefaults()

// Redis
redisv1.SetupDefaults()

// DNS
networkv1.SetupDefaults()

// Ceilometer
telemetryv1.SetupDefaultsCeilometer()

// Swift
swiftv1.SetupDefaults()

// Octavia
octaviav1.SetupDefaults()

// Designate
designatev1.SetupDefaults()

// Barbican
barbicanv1.SetupDefaults()
}
82 changes: 82 additions & 0 deletions pkg/openstack/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ import (
"time"

routev1 "github.com/openshift/api/route/v1"
barbicanv1 "github.com/openstack-k8s-operators/barbican-operator/api/v1beta1"
cinderv1 "github.com/openstack-k8s-operators/cinder-operator/api/v1beta1"
designatev1 "github.com/openstack-k8s-operators/designate-operator/api/v1beta1"
glancev1 "github.com/openstack-k8s-operators/glance-operator/api/v1beta1"
heatv1 "github.com/openstack-k8s-operators/heat-operator/api/v1beta1"
memcachedv1 "github.com/openstack-k8s-operators/infra-operator/apis/memcached/v1beta1"
networkv1 "github.com/openstack-k8s-operators/infra-operator/apis/network/v1beta1"
redisv1 "github.com/openstack-k8s-operators/infra-operator/apis/redis/v1beta1"
ironicv1 "github.com/openstack-k8s-operators/ironic-operator/api/v1beta1"
keystonev1 "github.com/openstack-k8s-operators/keystone-operator/api/v1beta1"
"github.com/openstack-k8s-operators/lib-common/modules/certmanager"
"github.com/openstack-k8s-operators/lib-common/modules/common"
"github.com/openstack-k8s-operators/lib-common/modules/common/condition"
Expand All @@ -14,7 +24,16 @@ import (
"github.com/openstack-k8s-operators/lib-common/modules/common/secret"
"github.com/openstack-k8s-operators/lib-common/modules/common/service"
"github.com/openstack-k8s-operators/lib-common/modules/common/util"
manilav1 "github.com/openstack-k8s-operators/manila-operator/api/v1beta1"
mariadbv1 "github.com/openstack-k8s-operators/mariadb-operator/api/v1beta1"
neutronv1 "github.com/openstack-k8s-operators/neutron-operator/api/v1beta1"
novav1 "github.com/openstack-k8s-operators/nova-operator/api/v1beta1"
octaviav1 "github.com/openstack-k8s-operators/octavia-operator/api/v1beta1"
corev1 "github.com/openstack-k8s-operators/openstack-operator/apis/core/v1beta1"
ovnv1 "github.com/openstack-k8s-operators/ovn-operator/api/v1beta1"
placementv1 "github.com/openstack-k8s-operators/placement-operator/api/v1beta1"
swiftv1 "github.com/openstack-k8s-operators/swift-operator/api/v1beta1"
telemetryv1 "github.com/openstack-k8s-operators/telemetry-operator/api/v1beta1"

k8s_corev1 "k8s.io/api/core/v1"
k8s_errors "k8s.io/apimachinery/pkg/api/errors"
Expand Down Expand Up @@ -425,3 +444,66 @@ func (ed *EndpointDetails) CreateRoute(

return ctrl.Result{}, nil
}

// Set up any defaults used by service operator defaulting logic
func SetupServiceOperatorDefaults() {
// Acquire environmental defaults and initialize service operators that
// require each respective default

// Cinder
cinderv1.SetupDefaults()

// Glance
glancev1.SetupDefaults()

// Ironic
ironicv1.SetupDefaults()

// Keystone
keystonev1.SetupDefaults()

// Manila
manilav1.SetupDefaults()

// MariaDB
mariadbv1.SetupDefaults()

// Memcached
memcachedv1.SetupDefaults()

// Neutron
neutronv1.SetupDefaults()

// Nova
novav1.SetupDefaults()

// OVN
ovnv1.SetupDefaults()

// Placement
placementv1.SetupDefaults()

// Heat
heatv1.SetupDefaults()

// Redis
redisv1.SetupDefaults()

// DNS
networkv1.SetupDefaults()

// Ceilometer
telemetryv1.SetupDefaultsCeilometer()

// Swift
swiftv1.SetupDefaults()

// Octavia
octaviav1.SetupDefaults()

// Designate
designatev1.SetupDefaults()

// Barbican
barbicanv1.SetupDefaults()
}
3 changes: 2 additions & 1 deletion tests/functional/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import (
octaviav1 "github.com/openstack-k8s-operators/octavia-operator/api/v1beta1"
openstackclientv1 "github.com/openstack-k8s-operators/openstack-operator/apis/client/v1beta1"
corev1 "github.com/openstack-k8s-operators/openstack-operator/apis/core/v1beta1"
"github.com/openstack-k8s-operators/openstack-operator/pkg/openstack"
ovnv1 "github.com/openstack-k8s-operators/ovn-operator/api/v1beta1"
placementv1 "github.com/openstack-k8s-operators/placement-operator/api/v1beta1"
swiftv1 "github.com/openstack-k8s-operators/swift-operator/api/v1beta1"
Expand Down Expand Up @@ -300,9 +301,9 @@ var _ = BeforeSuite(func() {
err = (&corev1.OpenStackControlPlane{}).SetupWebhookWithManager(k8sManager)
Expect(err).NotTo(HaveOccurred())

openstack.SetupServiceOperatorDefaults()
openstackclientv1.SetupDefaults()
corev1.SetupDefaults()
cinderv1.SetupDefaults()

err = (&client_ctrl.OpenStackClientReconciler{
Client: k8sManager.GetClient(),
Expand Down

0 comments on commit f5b4794

Please sign in to comment.