diff --git a/PROJECT b/PROJECT index 5b7a660..916341e 100644 --- a/PROJECT +++ b/PROJECT @@ -5,16 +5,16 @@ projectName: conduit-operator repo: github.com/conduitio/conduit-operator resources: - api: - crdVersion: v1 + crdVersion: v1alpha namespaced: true controller: true domain: conduit.io group: operator kind: Conduit - path: github.com/conduitio/conduit-operator/api/v1 + path: github.com/conduitio/conduit-operator/api/v1alpha version: v1 webhooks: defaulting: true validation: true - webhookVersion: v1 + webhookVersion: v1alpha version: "3" diff --git a/api/v1/condition.go b/api/v1alpha/condition.go similarity index 99% rename from api/v1/condition.go rename to api/v1alpha/condition.go index e2a2e2f..a1eb0cc 100644 --- a/api/v1/condition.go +++ b/api/v1alpha/condition.go @@ -1,4 +1,4 @@ -package v1 +package v1alpha import ( "sort" diff --git a/api/v1/condition_test.go b/api/v1alpha/condition_test.go similarity index 99% rename from api/v1/condition_test.go rename to api/v1alpha/condition_test.go index 568e641..8ba4a7d 100644 --- a/api/v1/condition_test.go +++ b/api/v1alpha/condition_test.go @@ -1,4 +1,4 @@ -package v1 +package v1alpha import ( "testing" diff --git a/api/v1/conduit_types.go b/api/v1alpha/conduit_types.go similarity index 99% rename from api/v1/conduit_types.go rename to api/v1alpha/conduit_types.go index 5881d2b..26f7ecf 100644 --- a/api/v1/conduit_types.go +++ b/api/v1alpha/conduit_types.go @@ -1,4 +1,4 @@ -package v1 +package v1alpha import ( "fmt" diff --git a/api/v1/conduit_validator.go b/api/v1alpha/conduit_validator.go similarity index 95% rename from api/v1/conduit_validator.go rename to api/v1alpha/conduit_validator.go index 820102b..6c01fff 100644 --- a/api/v1/conduit_validator.go +++ b/api/v1alpha/conduit_validator.go @@ -1,4 +1,4 @@ -package v1 +package v1alpha import ( "github.com/conduitio/conduit-operator/pkg/conduit" diff --git a/api/v1/conduit_webhook.go b/api/v1alpha/conduit_webhook.go similarity index 99% rename from api/v1/conduit_webhook.go rename to api/v1alpha/conduit_webhook.go index ac2ee16..83e085d 100644 --- a/api/v1/conduit_webhook.go +++ b/api/v1alpha/conduit_webhook.go @@ -1,4 +1,4 @@ -package v1 +package v1alpha import ( "fmt" diff --git a/api/v1/groupversion_info.go b/api/v1alpha/groupversion_info.go similarity index 94% rename from api/v1/groupversion_info.go rename to api/v1alpha/groupversion_info.go index c285c99..767bd04 100644 --- a/api/v1/groupversion_info.go +++ b/api/v1alpha/groupversion_info.go @@ -1,7 +1,7 @@ // Package v1 contains API Schema definitions for the operator v1 API group // +kubebuilder:object:generate=true // +groupName=operator.conduit.io -package v1 +package v1alpha import ( "k8s.io/apimachinery/pkg/runtime/schema" @@ -10,7 +10,7 @@ import ( var ( // GroupVersion is group version used to register these objects - GroupVersion = schema.GroupVersion{Group: "operator.conduit.io", Version: "v1"} + GroupVersion = schema.GroupVersion{Group: "operator.conduit.io", Version: "v1alpha"} // SchemeBuilder is used to add go types to the GroupVersionKind scheme SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} diff --git a/api/v1/zz_generated.deepcopy.go b/api/v1alpha/zz_generated.deepcopy.go similarity index 98% rename from api/v1/zz_generated.deepcopy.go rename to api/v1alpha/zz_generated.deepcopy.go index 82a33d7..20c3516 100644 --- a/api/v1/zz_generated.deepcopy.go +++ b/api/v1alpha/zz_generated.deepcopy.go @@ -2,10 +2,10 @@ // Code generated by controller-gen. DO NOT EDIT. -package v1 +package v1alpha import ( - corev1 "k8s.io/api/core/v1" + "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/runtime" ) @@ -266,7 +266,7 @@ func (in *SettingsVar) DeepCopyInto(out *SettingsVar) { *out = *in if in.SecretRef != nil { in, out := &in.SecretRef, &out.SecretRef - *out = new(corev1.SecretKeySelector) + *out = new(v1.SecretKeySelector) (*in).DeepCopyInto(*out) } if in.ConfigMapRef != nil { diff --git a/charts/conduit-operator/templates/crd.yaml b/charts/conduit-operator/templates/crd.yaml index d475639..9a350ca 100644 --- a/charts/conduit-operator/templates/crd.yaml +++ b/charts/conduit-operator/templates/crd.yaml @@ -25,7 +25,7 @@ spec: singular: conduit scope: Namespaced versions: - - name: v1 + - name: v1alpha schema: openAPIV3Schema: description: Conduit is the Schema for the conduits API diff --git a/cmd/operator/main.go b/cmd/operator/main.go index 728a3e6..bfa448e 100644 --- a/cmd/operator/main.go +++ b/cmd/operator/main.go @@ -18,7 +18,7 @@ import ( metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server" "sigs.k8s.io/controller-runtime/pkg/webhook" - v1 "github.com/conduitio/conduit-operator/api/v1" + v1alpha "github.com/conduitio/conduit-operator/api/v1alpha" "github.com/conduitio/conduit-operator/controllers" //+kubebuilder:scaffold:imports ) @@ -30,7 +30,7 @@ var ( func init() { utilruntime.Must(clientgoscheme.AddToScheme(scheme)) - utilruntime.Must(v1.AddToScheme(scheme)) + utilruntime.Must(v1alpha.AddToScheme(scheme)) //+kubebuilder:scaffold:scheme } @@ -87,7 +87,7 @@ func main() { }).SetupWithManager(mgr); err != nil { fatal(err, "unable to create controller", "controller", "Conduit") } - if err = (&v1.Conduit{}).SetupWebhookWithManager(mgr); err != nil { + if err = (&v1alpha.Conduit{}).SetupWebhookWithManager(mgr); err != nil { fatal(err, "unable to create webhook", "webhook", "Conduit") } //+kubebuilder:scaffold:builder @@ -110,8 +110,8 @@ func fatal(err error, msg string, kv ...any) { os.Exit(1) } -func readMetadata(file string) (*v1.ConduitInstanceMetadata, error) { - c := v1.ConduitInstanceMetadata{ +func readMetadata(file string) (*v1alpha.ConduitInstanceMetadata, error) { + c := v1alpha.ConduitInstanceMetadata{ PodAnnotations: make(map[string]string), Labels: make(map[string]string), } diff --git a/config/crd/bases/operator.conduit.io_conduits.yaml b/config/crd/bases/operator.conduit.io_conduits.yaml index 9a615ea..e5ecc76 100644 --- a/config/crd/bases/operator.conduit.io_conduits.yaml +++ b/config/crd/bases/operator.conduit.io_conduits.yaml @@ -14,7 +14,7 @@ spec: singular: conduit scope: Namespaced versions: - - name: v1 + - name: v1alpha schema: openAPIV3Schema: description: Conduit is the Schema for the conduits API diff --git a/controllers/conduit_config.go b/controllers/conduit_config.go index b91e8c5..bdbc6e9 100644 --- a/controllers/conduit_config.go +++ b/controllers/conduit_config.go @@ -8,7 +8,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" - v1 "github.com/conduitio/conduit-operator/api/v1" + v1alpha "github.com/conduitio/conduit-operator/api/v1alpha" cyaml "github.com/conduitio/conduit/pkg/provisioning/config/yaml/v2" "github.com/conduitio/yaml/v3" corev1 "k8s.io/api/core/v1" @@ -18,7 +18,7 @@ const pipelineConfigVersion = "2.0" // PipelineConfigYAML produces a conduit pipeline configuration in YAML. // Invalid configuration will result in a marshalling error. -func PipelineConfigYAML(ctx context.Context, client client.Client, conduit *v1.Conduit) (string, error) { +func PipelineConfigYAML(ctx context.Context, client client.Client, conduit *v1alpha.Conduit) (string, error) { var ( spec = conduit.Spec pipelineStatus = "stopped" @@ -70,7 +70,7 @@ func PipelineConfigYAML(ctx context.Context, client client.Client, conduit *v1.C // EnvVars returns a slice of EnvVar with all connector settings. // Only secrets are put into environment variables. -func EnvVars(c *v1.Conduit) []corev1.EnvVar { +func EnvVars(c *v1alpha.Conduit) []corev1.EnvVar { var envVars []corev1.EnvVar for _, cc := range c.Spec.Connectors { for _, v := range cc.Settings { @@ -92,7 +92,7 @@ func EnvVars(c *v1.Conduit) []corev1.EnvVar { // settingsWithEnvVars converts settings to a map, every secret key // reference is converted to env var reference. -func settingsWithEnvVars(ctx context.Context, client client.Client, s []v1.SettingsVar) (map[string]string, error) { +func settingsWithEnvVars(ctx context.Context, client client.Client, s []v1alpha.SettingsVar) (map[string]string, error) { settings := make(map[string]string) for _, v := range s { switch { @@ -112,7 +112,7 @@ func settingsWithEnvVars(ctx context.Context, client client.Client, s []v1.Setti return settings, nil } -func configMapValue(ctx context.Context, cl client.Client, ref *v1.GlobalConfigMapRef) (string, error) { +func configMapValue(ctx context.Context, cl client.Client, ref *v1alpha.GlobalConfigMapRef) (string, error) { configMap := &corev1.ConfigMap{} // Fetch the ConfigMap using the client's Get method @@ -146,7 +146,7 @@ func envVarName(s string) string { // connectorConfig returns a conduit connector config which is created // from a connector resource settings. Settings which refer to a secret are // converted to env variables. -func connectorConfig(ctx context.Context, cl client.Client, c *v1.ConduitConnector) (cyaml.Connector, error) { +func connectorConfig(ctx context.Context, cl client.Client, c *v1alpha.ConduitConnector) (cyaml.Connector, error) { var processors []cyaml.Processor for _, p := range c.Processors { procCfg, err := processorConfig(ctx, cl, p) @@ -173,7 +173,7 @@ func connectorConfig(ctx context.Context, cl client.Client, c *v1.ConduitConnect }, nil } -func processorConfig(ctx context.Context, cl client.Client, p *v1.ConduitProcessor) (cyaml.Processor, error) { +func processorConfig(ctx context.Context, cl client.Client, p *v1alpha.ConduitProcessor) (cyaml.Processor, error) { settings, err := settingsWithEnvVars(ctx, cl, p.Settings) if err != nil { return cyaml.Processor{}, fmt.Errorf("failed getting settings for processor %v: %w", p.Name, err) diff --git a/controllers/conduit_config_test.go b/controllers/conduit_config_test.go index 0e7f69e..f4211d5 100644 --- a/controllers/conduit_config_test.go +++ b/controllers/conduit_config_test.go @@ -9,7 +9,7 @@ import ( "github.com/google/go-cmp/cmp" corev1 "k8s.io/api/core/v1" - v1 "github.com/conduitio/conduit-operator/api/v1" + v1alpha "github.com/conduitio/conduit-operator/api/v1alpha" ctrls "github.com/conduitio/conduit-operator/controllers" ) @@ -49,7 +49,7 @@ func Test_EnvVars(t *testing.T) { func Test_PipelineConfigYAML(t *testing.T) { tests := []struct { name string - conduit *v1.Conduit + conduit *v1alpha.Conduit want string }{ { diff --git a/controllers/conduit_containers.go b/controllers/conduit_containers.go index 45c2048..09d4100 100644 --- a/controllers/conduit_containers.go +++ b/controllers/conduit_containers.go @@ -7,7 +7,7 @@ import ( "strings" "sync" - v1 "github.com/conduitio/conduit-operator/api/v1" + v1alpha "github.com/conduitio/conduit-operator/api/v1alpha" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/util/intstr" ) @@ -74,22 +74,22 @@ func (c *commandBuilder) addConnectorBuild(b connectorBuild) { } // ConduitInitContainers returns a slice of kubernetes container definitions -func ConduitInitContainers(cc []*v1.ConduitConnector) []corev1.Container { +func ConduitInitContainers(cc []*v1alpha.ConduitConnector) []corev1.Container { builder := &commandBuilder{} containers := []corev1.Container{ { - Name: v1.ConduitInitContainerName, - Image: v1.ConduitInitImage, + Name: v1alpha.ConduitInitContainerName, + Image: v1alpha.ConduitInitImage, ImagePullPolicy: corev1.PullIfNotPresent, Args: []string{ "sh", "-xe", "-c", - fmt.Sprintf("mkdir -p %s %s", v1.ConduitProcessorsPath, v1.ConduitConnectorsPath), + fmt.Sprintf("mkdir -p %s %s", v1alpha.ConduitProcessorsPath, v1alpha.ConduitConnectorsPath), }, VolumeMounts: []corev1.VolumeMount{ { - Name: v1.ConduitStorageVolumeMount, - MountPath: v1.ConduitVolumePath, + Name: v1alpha.ConduitStorageVolumeMount, + MountPath: v1alpha.ConduitVolumePath, }, }, }, @@ -103,15 +103,15 @@ func ConduitInitContainers(cc []*v1.ConduitConnector) []corev1.Container { name: fmt.Sprintf("%s-%s", filepath.Base(c.Plugin), c.PluginVersion), goPkg: c.PluginPkg, tmpDir: builderTempPath, - targetDir: v1.ConduitConnectorsPath, + targetDir: v1alpha.ConduitConnectorsPath, ldflags: fmt.Sprintf(`-ldflags "-X 'github.com/%s.version=%s'"`, c.Plugin, c.PluginVersion), }) } if !builder.empty() { containers = append(containers, corev1.Container{ - Name: fmt.Sprint(v1.ConduitInitContainerName, "-connectors"), - Image: v1.ConduitInitImage, + Name: fmt.Sprint(v1alpha.ConduitInitContainerName, "-connectors"), + Image: v1alpha.ConduitInitImage, ImagePullPolicy: corev1.PullIfNotPresent, Args: []string{ "sh", "-xe", @@ -119,8 +119,8 @@ func ConduitInitContainers(cc []*v1.ConduitConnector) []corev1.Container { }, VolumeMounts: []corev1.VolumeMount{ { - Name: v1.ConduitStorageVolumeMount, - MountPath: v1.ConduitVolumePath, + Name: v1alpha.ConduitStorageVolumeMount, + MountPath: v1alpha.ConduitVolumePath, }, }, }) @@ -134,19 +134,19 @@ func ConduitInitContainers(cc []*v1.ConduitConnector) []corev1.Container { func ConduitRuntimeContainer(image, version string, envVars []corev1.EnvVar) corev1.Container { args := []string{ "/app/conduit", - "-pipelines.path", v1.ConduitPipelineFile, - "-connectors.path", v1.ConduitConnectorsPath, + "-pipelines.path", v1alpha.ConduitPipelineFile, + "-connectors.path", v1alpha.ConduitConnectorsPath, "-db.type", "badger", - "-db.badger.path", v1.ConduitDBPath, + "-db.badger.path", v1alpha.ConduitDBPath, "-pipelines.exit-on-error", } if withProcessors(version) { - args = append(args, "-processors.path", v1.ConduitProcessorsPath) + args = append(args, "-processors.path", v1alpha.ConduitProcessorsPath) } return corev1.Container{ - Name: v1.ConduitContainerName, + Name: v1alpha.ConduitContainerName, Image: fmt.Sprint(image, ":", version), ImagePullPolicy: corev1.PullAlways, Args: args, @@ -177,12 +177,12 @@ func ConduitRuntimeContainer(image, version string, envVars []corev1.EnvVar) cor }, VolumeMounts: []corev1.VolumeMount{ { - Name: v1.ConduitStorageVolumeMount, - MountPath: v1.ConduitVolumePath, + Name: v1alpha.ConduitStorageVolumeMount, + MountPath: v1alpha.ConduitVolumePath, }, { - Name: v1.ConduitPipelineVolumeMount, - MountPath: v1.ConduitPipelinePath, + Name: v1alpha.ConduitPipelineVolumeMount, + MountPath: v1alpha.ConduitPipelinePath, ReadOnly: true, }, }, diff --git a/controllers/conduit_containers_test.go b/controllers/conduit_containers_test.go index b84b9b5..7f216f7 100644 --- a/controllers/conduit_containers_test.go +++ b/controllers/conduit_containers_test.go @@ -8,7 +8,7 @@ import ( corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/util/intstr" - v1 "github.com/conduitio/conduit-operator/api/v1" + v1alpha "github.com/conduitio/conduit-operator/api/v1alpha" ctrls "github.com/conduitio/conduit-operator/controllers" ) @@ -26,13 +26,13 @@ func Test_ConduitInitContainers(t *testing.T) { tests := []struct { name string - connectors []*v1.ConduitConnector + connectors []*v1alpha.ConduitConnector imageVer string want []corev1.Container }{ { name: "only builtin connectors", - connectors: []*v1.ConduitConnector{ + connectors: []*v1alpha.ConduitConnector{ { Plugin: "builtin:builtin-test", PluginVersion: "latest", @@ -42,7 +42,7 @@ func Test_ConduitInitContainers(t *testing.T) { }, { name: "with latest standalone connector", - connectors: []*v1.ConduitConnector{ + connectors: []*v1alpha.ConduitConnector{ { Plugin: "builtin:builtin-test", PluginVersion: "latest", @@ -74,7 +74,7 @@ func Test_ConduitInitContainers(t *testing.T) { }, { name: "with version standalone connector", - connectors: []*v1.ConduitConnector{ + connectors: []*v1alpha.ConduitConnector{ { Plugin: "builtin:builtin-test", PluginVersion: "latest", @@ -106,7 +106,7 @@ func Test_ConduitInitContainers(t *testing.T) { }, { name: "with multiple standalone connector", - connectors: []*v1.ConduitConnector{ + connectors: []*v1alpha.ConduitConnector{ { Plugin: "builtin:builtin-test", PluginVersion: "latest", @@ -143,7 +143,7 @@ func Test_ConduitInitContainers(t *testing.T) { }, { name: "with duplicate standalone connector", - connectors: []*v1.ConduitConnector{ + connectors: []*v1alpha.ConduitConnector{ { Plugin: "builtin:builtin-test", PluginVersion: "latest", diff --git a/controllers/conduit_controller.go b/controllers/conduit_controller.go index 6e28709..7453c17 100644 --- a/controllers/conduit_controller.go +++ b/controllers/conduit_controller.go @@ -12,7 +12,7 @@ import ( "golang.org/x/exp/maps" - v1 "github.com/conduitio/conduit-operator/api/v1" + v1 "github.com/conduitio/conduit-operator/api/v1alpha" "github.com/go-logr/logr" "github.com/hashicorp/go-multierror" apierrors "k8s.io/apimachinery/pkg/api/errors" diff --git a/controllers/conduit_controller_test.go b/controllers/conduit_controller_test.go index f11a3a3..65de909 100644 --- a/controllers/conduit_controller_test.go +++ b/controllers/conduit_controller_test.go @@ -24,7 +24,7 @@ import ( "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/intstr" - v1 "github.com/conduitio/conduit-operator/api/v1" + v1alpha "github.com/conduitio/conduit-operator/api/v1alpha" "github.com/conduitio/conduit-operator/controllers" "github.com/conduitio/conduit-operator/controllers/mock" ) @@ -42,8 +42,8 @@ func Test_Reconciler(t *testing.T) { tests := []struct { name string - conduit *v1.Conduit - setup func(ctrl *gomock.Controller, c *v1.Conduit) *controllers.ConduitReconciler + conduit *v1alpha.Conduit + setup func(ctrl *gomock.Controller, c *v1alpha.Conduit) *controllers.ConduitReconciler result runtimectrl.Result wantErr error }{ @@ -53,17 +53,17 @@ func Test_Reconciler(t *testing.T) { result: runtimectrl.Result{ RequeueAfter: 10 * time.Second, }, - setup: func(ctrl *gomock.Controller, c *v1.Conduit) *controllers.ConduitReconciler { + setup: func(ctrl *gomock.Controller, c *v1alpha.Conduit) *controllers.ConduitReconciler { client := mock.NewMockClient(ctrl) client.EXPECT(). - Get(ctx, kclient.ObjectKeyFromObject(c), &v1.Conduit{}). - DoAndReturn(func(_ context.Context, _ types.NamespacedName, cc *v1.Conduit, _ ...kclient.CreateOption) error { + Get(ctx, kclient.ObjectKeyFromObject(c), &v1alpha.Conduit{}). + DoAndReturn(func(_ context.Context, _ types.NamespacedName, cc *v1alpha.Conduit, _ ...kclient.CreateOption) error { *cc = *c return nil }) withFinalizers := c.DeepCopy() - ctrlutil.AddFinalizer(withFinalizers, v1.ConduitFinalizer) + ctrlutil.AddFinalizer(withFinalizers, v1alpha.ConduitFinalizer) client.EXPECT().Update(ctx, withFinalizers) return &controllers.ConduitReconciler{ @@ -76,27 +76,27 @@ func Test_Reconciler(t *testing.T) { { name: "remove finalizers when deleted", conduit: sampleConduit(true), - setup: func(ctrl *gomock.Controller, c *v1.Conduit) *controllers.ConduitReconciler { + setup: func(ctrl *gomock.Controller, c *v1alpha.Conduit) *controllers.ConduitReconciler { now := metav1.Now() deletedConduit := c.DeepCopy() deletedConduit.ObjectMeta.DeletionTimestamp = &now - ctrlutil.AddFinalizer(deletedConduit, v1.ConduitFinalizer) + ctrlutil.AddFinalizer(deletedConduit, v1alpha.ConduitFinalizer) client := mock.NewMockClient(ctrl) client.EXPECT(). - Get(ctx, kclient.ObjectKeyFromObject(c), &v1.Conduit{}). - DoAndReturn(func(_ context.Context, _ types.NamespacedName, cc *v1.Conduit, _ ...kclient.CreateOption) error { + Get(ctx, kclient.ObjectKeyFromObject(c), &v1alpha.Conduit{}). + DoAndReturn(func(_ context.Context, _ types.NamespacedName, cc *v1alpha.Conduit, _ ...kclient.CreateOption) error { *cc = *deletedConduit return nil }) withoutFinalizers := deletedConduit.DeepCopy() - ctrlutil.RemoveFinalizer(withoutFinalizers, v1.ConduitFinalizer) + ctrlutil.RemoveFinalizer(withoutFinalizers, v1alpha.ConduitFinalizer) client.EXPECT().Update(ctx, withoutFinalizers) recorder := mock.NewMockEventRecorder(ctrl) recorder.EXPECT(). - Eventf(withoutFinalizers, corev1.EventTypeNormal, v1.DeletedReason, gomock.Any(), gomock.Any(), gomock.Any()) + Eventf(withoutFinalizers, corev1.EventTypeNormal, v1alpha.DeletedReason, gomock.Any(), gomock.Any(), gomock.Any()) return &controllers.ConduitReconciler{ Client: client, @@ -108,10 +108,10 @@ func Test_Reconciler(t *testing.T) { { name: "error when fetching conduit", conduit: sampleConduit(true), - setup: func(ctrl *gomock.Controller, c *v1.Conduit) *controllers.ConduitReconciler { + setup: func(ctrl *gomock.Controller, c *v1alpha.Conduit) *controllers.ConduitReconciler { client := mock.NewMockClient(ctrl) client.EXPECT(). - Get(ctx, kclient.ObjectKeyFromObject(c), &v1.Conduit{}). + Get(ctx, kclient.ObjectKeyFromObject(c), &v1alpha.Conduit{}). Return(internalErr) return &controllers.ConduitReconciler{ @@ -155,22 +155,22 @@ func Test_CreateOrUpdateConfig(t *testing.T) { tests := []struct { name string - conduit *v1.Conduit - setup func(ctrl *gomock.Controller, c *v1.Conduit) *controllers.ConduitReconciler - wantStatus *v1.ConduitStatus + conduit *v1alpha.Conduit + setup func(ctrl *gomock.Controller, c *v1alpha.Conduit) *controllers.ConduitReconciler + wantStatus *v1alpha.ConduitStatus wantErr error }{ { name: "creates config map", conduit: sampleConduit(true), - wantStatus: func() *v1.ConduitStatus { - status := &v1.ConduitStatus{} - status.SetCondition(v1.ConditionConduitConfigReady, corev1.ConditionTrue, "", "") - status.SetCondition(v1.ConditionConduitReady, corev1.ConditionFalse, "", "") + wantStatus: func() *v1alpha.ConduitStatus { + status := &v1alpha.ConduitStatus{} + status.SetCondition(v1alpha.ConditionConduitConfigReady, corev1.ConditionTrue, "", "") + status.SetCondition(v1alpha.ConditionConduitReady, corev1.ConditionFalse, "", "") return status }(), - setup: func(ctrl *gomock.Controller, c *v1.Conduit) *controllers.ConduitReconciler { + setup: func(ctrl *gomock.Controller, c *v1alpha.Conduit) *controllers.ConduitReconciler { nn := c.NamespacedName() cm := &corev1.ConfigMap{ ObjectMeta: metav1.ObjectMeta{ @@ -193,7 +193,7 @@ func Test_CreateOrUpdateConfig(t *testing.T) { Return(nil) recorder := mock.NewMockEventRecorder(ctrl) - recorder.EXPECT().Eventf(c, corev1.EventTypeNormal, v1.CreatedReason, gomock.Any(), nn) + recorder.EXPECT().Eventf(c, corev1.EventTypeNormal, v1alpha.CreatedReason, gomock.Any(), nn) return &controllers.ConduitReconciler{ Client: client, @@ -204,14 +204,14 @@ func Test_CreateOrUpdateConfig(t *testing.T) { { name: "updates config map", conduit: sampleConduit(true), - wantStatus: func() *v1.ConduitStatus { - status := &v1.ConduitStatus{} - status.SetCondition(v1.ConditionConduitConfigReady, corev1.ConditionTrue, "", "") - status.SetCondition(v1.ConditionConduitReady, corev1.ConditionFalse, "", "") + wantStatus: func() *v1alpha.ConduitStatus { + status := &v1alpha.ConduitStatus{} + status.SetCondition(v1alpha.ConditionConduitConfigReady, corev1.ConditionTrue, "", "") + status.SetCondition(v1alpha.ConditionConduitReady, corev1.ConditionFalse, "", "") return status }(), - setup: func(ctrl *gomock.Controller, c *v1.Conduit) *controllers.ConduitReconciler { + setup: func(ctrl *gomock.Controller, c *v1alpha.Conduit) *controllers.ConduitReconciler { nn := c.NamespacedName() cm := &corev1.ConfigMap{ ObjectMeta: metav1.ObjectMeta{ @@ -230,7 +230,7 @@ func Test_CreateOrUpdateConfig(t *testing.T) { client.EXPECT().Update(ctx, mock.NewConfigMapMatcher(cmUpdated)).Return(nil) recorder := mock.NewMockEventRecorder(ctrl) - recorder.EXPECT().Eventf(c, corev1.EventTypeNormal, v1.UpdatedReason, gomock.Any(), nn) + recorder.EXPECT().Eventf(c, corev1.EventTypeNormal, v1alpha.UpdatedReason, gomock.Any(), nn) return &controllers.ConduitReconciler{ Client: client, @@ -241,14 +241,14 @@ func Test_CreateOrUpdateConfig(t *testing.T) { { name: "error while updating config map", conduit: sampleConduit(true), - wantStatus: func() *v1.ConduitStatus { - status := &v1.ConduitStatus{} - status.SetCondition(v1.ConditionConduitConfigReady, corev1.ConditionFalse, "", "") - status.SetCondition(v1.ConditionConduitReady, corev1.ConditionFalse, "", "") + wantStatus: func() *v1alpha.ConduitStatus { + status := &v1alpha.ConduitStatus{} + status.SetCondition(v1alpha.ConditionConduitConfigReady, corev1.ConditionFalse, "", "") + status.SetCondition(v1alpha.ConditionConduitReady, corev1.ConditionFalse, "", "") return status }(), - setup: func(ctrl *gomock.Controller, c *v1.Conduit) *controllers.ConduitReconciler { + setup: func(ctrl *gomock.Controller, c *v1alpha.Conduit) *controllers.ConduitReconciler { err := internalErr nn := c.NamespacedName() cm := &corev1.ConfigMap{ @@ -261,7 +261,7 @@ func Test_CreateOrUpdateConfig(t *testing.T) { client.EXPECT().Get(ctx, nn, cm).Return(err) recorder := mock.NewMockEventRecorder(ctrl) - recorder.EXPECT().Eventf(c, corev1.EventTypeWarning, v1.ErroredReason, gomock.Any(), nn, gomock.Any()) + recorder.EXPECT().Eventf(c, corev1.EventTypeWarning, v1alpha.ErroredReason, gomock.Any(), nn, gomock.Any()) return &controllers.ConduitReconciler{ Client: client, @@ -303,22 +303,22 @@ func Test_CreateOrUpdateVolume(t *testing.T) { tests := []struct { name string - conduit *v1.Conduit - setup func(ctrl *gomock.Controller, c *v1.Conduit) *controllers.ConduitReconciler - wantStatus *v1.ConduitStatus + conduit *v1alpha.Conduit + setup func(ctrl *gomock.Controller, c *v1alpha.Conduit) *controllers.ConduitReconciler + wantStatus *v1alpha.ConduitStatus wantErr error }{ { name: "creates volume", conduit: sampleConduit(true), - wantStatus: func() *v1.ConduitStatus { - status := &v1.ConduitStatus{} - status.SetCondition(v1.ConditionConduitVolumeReady, corev1.ConditionFalse, "", "") - status.SetCondition(v1.ConditionConduitReady, corev1.ConditionFalse, "", "") + wantStatus: func() *v1alpha.ConduitStatus { + status := &v1alpha.ConduitStatus{} + status.SetCondition(v1alpha.ConditionConduitVolumeReady, corev1.ConditionFalse, "", "") + status.SetCondition(v1alpha.ConditionConduitReady, corev1.ConditionFalse, "", "") return status }(), - setup: func(ctrl *gomock.Controller, c *v1.Conduit) *controllers.ConduitReconciler { + setup: func(ctrl *gomock.Controller, c *v1alpha.Conduit) *controllers.ConduitReconciler { nn := c.NamespacedName() pvc := controllers.ConduitVolumeClaim(nn, "1Gi") @@ -328,7 +328,7 @@ func Test_CreateOrUpdateVolume(t *testing.T) { client.EXPECT().Create(ctx, mock.NewPvcMatcher(pvc)).Return(nil) recorder := mock.NewMockEventRecorder(ctrl) - recorder.EXPECT().Eventf(c, corev1.EventTypeNormal, v1.CreatedReason, gomock.Any(), nn) + recorder.EXPECT().Eventf(c, corev1.EventTypeNormal, v1alpha.CreatedReason, gomock.Any(), nn) return &controllers.ConduitReconciler{ Client: client, @@ -339,14 +339,14 @@ func Test_CreateOrUpdateVolume(t *testing.T) { { name: "updates volume", conduit: sampleConduit(true), - wantStatus: func() *v1.ConduitStatus { - status := &v1.ConduitStatus{} - status.SetCondition(v1.ConditionConduitVolumeReady, corev1.ConditionFalse, "", "") - status.SetCondition(v1.ConditionConduitReady, corev1.ConditionFalse, "", "") + wantStatus: func() *v1alpha.ConduitStatus { + status := &v1alpha.ConduitStatus{} + status.SetCondition(v1alpha.ConditionConduitVolumeReady, corev1.ConditionFalse, "", "") + status.SetCondition(v1alpha.ConditionConduitReady, corev1.ConditionFalse, "", "") return status }(), - setup: func(ctrl *gomock.Controller, c *v1.Conduit) *controllers.ConduitReconciler { + setup: func(ctrl *gomock.Controller, c *v1alpha.Conduit) *controllers.ConduitReconciler { nn := c.NamespacedName() pvc := controllers.ConduitVolumeClaim(nn, "1Gi") @@ -356,7 +356,7 @@ func Test_CreateOrUpdateVolume(t *testing.T) { client.EXPECT().Update(ctx, mock.NewPvcMatcher(pvc)).Return(nil) recorder := mock.NewMockEventRecorder(ctrl) - recorder.EXPECT().Eventf(c, corev1.EventTypeNormal, v1.UpdatedReason, gomock.Any(), nn) + recorder.EXPECT().Eventf(c, corev1.EventTypeNormal, v1alpha.UpdatedReason, gomock.Any(), nn) return &controllers.ConduitReconciler{ Client: client, @@ -367,14 +367,14 @@ func Test_CreateOrUpdateVolume(t *testing.T) { { name: "updates volume to bound", conduit: sampleConduit(true), - wantStatus: func() *v1.ConduitStatus { - status := &v1.ConduitStatus{} - status.SetCondition(v1.ConditionConduitVolumeReady, corev1.ConditionTrue, "", "") - status.SetCondition(v1.ConditionConduitReady, corev1.ConditionFalse, "", "") + wantStatus: func() *v1alpha.ConduitStatus { + status := &v1alpha.ConduitStatus{} + status.SetCondition(v1alpha.ConditionConduitVolumeReady, corev1.ConditionTrue, "", "") + status.SetCondition(v1alpha.ConditionConduitReady, corev1.ConditionFalse, "", "") return status }(), - setup: func(ctrl *gomock.Controller, c *v1.Conduit) *controllers.ConduitReconciler { + setup: func(ctrl *gomock.Controller, c *v1alpha.Conduit) *controllers.ConduitReconciler { nn := c.NamespacedName() pvc := controllers.ConduitVolumeClaim(nn, "1Gi") @@ -387,12 +387,12 @@ func Test_CreateOrUpdateVolume(t *testing.T) { *p = *newp return nil }) - c.Status.SetCondition(v1.ConditionConduitVolumeReady, corev1.ConditionFalse, "", "") + c.Status.SetCondition(v1alpha.ConditionConduitVolumeReady, corev1.ConditionFalse, "", "") client.EXPECT().Update(ctx, mock.NewPvcMatcher(pvc)).Return(nil) recorder := mock.NewMockEventRecorder(ctrl) - recorder.EXPECT().Eventf(c, corev1.EventTypeNormal, v1.VolBoundReason, gomock.Any(), nn) - recorder.EXPECT().Eventf(c, corev1.EventTypeNormal, v1.UpdatedReason, gomock.Any(), nn) + recorder.EXPECT().Eventf(c, corev1.EventTypeNormal, v1alpha.VolBoundReason, gomock.Any(), nn) + recorder.EXPECT().Eventf(c, corev1.EventTypeNormal, v1alpha.UpdatedReason, gomock.Any(), nn) return &controllers.ConduitReconciler{ Client: client, @@ -403,14 +403,14 @@ func Test_CreateOrUpdateVolume(t *testing.T) { { name: "error when updating volume", conduit: sampleConduit(true), - wantStatus: func() *v1.ConduitStatus { - status := &v1.ConduitStatus{} - status.SetCondition(v1.ConditionConduitVolumeReady, corev1.ConditionFalse, "", "") - status.SetCondition(v1.ConditionConduitReady, corev1.ConditionFalse, "", "") + wantStatus: func() *v1alpha.ConduitStatus { + status := &v1alpha.ConduitStatus{} + status.SetCondition(v1alpha.ConditionConduitVolumeReady, corev1.ConditionFalse, "", "") + status.SetCondition(v1alpha.ConditionConduitReady, corev1.ConditionFalse, "", "") return status }(), - setup: func(ctrl *gomock.Controller, c *v1.Conduit) *controllers.ConduitReconciler { + setup: func(ctrl *gomock.Controller, c *v1alpha.Conduit) *controllers.ConduitReconciler { nn := c.NamespacedName() pvc := controllers.ConduitVolumeClaim(nn, "1Gi") @@ -418,7 +418,7 @@ func Test_CreateOrUpdateVolume(t *testing.T) { client.EXPECT().Get(ctx, nn, pvc).Return(internalErr) recorder := mock.NewMockEventRecorder(ctrl) - recorder.EXPECT().Eventf(c, corev1.EventTypeWarning, v1.ErroredReason, gomock.Any(), nn, internalErr) + recorder.EXPECT().Eventf(c, corev1.EventTypeWarning, v1alpha.ErroredReason, gomock.Any(), nn, internalErr) return &controllers.ConduitReconciler{ Client: client, @@ -460,22 +460,22 @@ func Test_CreateOrUpdateService(t *testing.T) { tests := []struct { name string - conduit *v1.Conduit - setup func(ctrl *gomock.Controller, c *v1.Conduit) *controllers.ConduitReconciler - wantStatus *v1.ConduitStatus + conduit *v1alpha.Conduit + setup func(ctrl *gomock.Controller, c *v1alpha.Conduit) *controllers.ConduitReconciler + wantStatus *v1alpha.ConduitStatus wantErr error }{ { name: "service is created", conduit: sampleConduit(true), - wantStatus: func() *v1.ConduitStatus { - status := &v1.ConduitStatus{} - status.SetCondition(v1.ConditionConduitServiceReady, corev1.ConditionTrue, "", "") - status.SetCondition(v1.ConditionConduitReady, corev1.ConditionFalse, "", "") + wantStatus: func() *v1alpha.ConduitStatus { + status := &v1alpha.ConduitStatus{} + status.SetCondition(v1alpha.ConditionConduitServiceReady, corev1.ConditionTrue, "", "") + status.SetCondition(v1alpha.ConditionConduitReady, corev1.ConditionFalse, "", "") return status }(), - setup: func(ctrl *gomock.Controller, c *v1.Conduit) *controllers.ConduitReconciler { + setup: func(ctrl *gomock.Controller, c *v1alpha.Conduit) *controllers.ConduitReconciler { nn := c.NamespacedName() svc := &corev1.Service{ ObjectMeta: metav1.ObjectMeta{ @@ -508,7 +508,7 @@ func Test_CreateOrUpdateService(t *testing.T) { client.EXPECT().Create(ctx, mock.NewServiceMatcher(svcCreated)).Return(nil) recorder := mock.NewMockEventRecorder(ctrl) - recorder.EXPECT().Eventf(c, corev1.EventTypeNormal, v1.CreatedReason, gomock.Any(), nn) + recorder.EXPECT().Eventf(c, corev1.EventTypeNormal, v1alpha.CreatedReason, gomock.Any(), nn) return &controllers.ConduitReconciler{ Client: client, @@ -519,14 +519,14 @@ func Test_CreateOrUpdateService(t *testing.T) { { name: "service is updated", conduit: sampleConduit(true), - wantStatus: func() *v1.ConduitStatus { - status := &v1.ConduitStatus{} - status.SetCondition(v1.ConditionConduitServiceReady, corev1.ConditionTrue, "", "") - status.SetCondition(v1.ConditionConduitReady, corev1.ConditionFalse, "", "") + wantStatus: func() *v1alpha.ConduitStatus { + status := &v1alpha.ConduitStatus{} + status.SetCondition(v1alpha.ConditionConduitServiceReady, corev1.ConditionTrue, "", "") + status.SetCondition(v1alpha.ConditionConduitReady, corev1.ConditionFalse, "", "") return status }(), - setup: func(ctrl *gomock.Controller, c *v1.Conduit) *controllers.ConduitReconciler { + setup: func(ctrl *gomock.Controller, c *v1alpha.Conduit) *controllers.ConduitReconciler { nn := c.NamespacedName() svc := &corev1.Service{ ObjectMeta: metav1.ObjectMeta{ @@ -559,7 +559,7 @@ func Test_CreateOrUpdateService(t *testing.T) { client.EXPECT().Update(ctx, mock.NewServiceMatcher(svcCreated)).Return(nil) recorder := mock.NewMockEventRecorder(ctrl) - recorder.EXPECT().Eventf(c, corev1.EventTypeNormal, v1.UpdatedReason, gomock.Any(), nn) + recorder.EXPECT().Eventf(c, corev1.EventTypeNormal, v1alpha.UpdatedReason, gomock.Any(), nn) return &controllers.ConduitReconciler{ Client: client, @@ -570,14 +570,14 @@ func Test_CreateOrUpdateService(t *testing.T) { { name: "error creating or updating service", conduit: sampleConduit(true), - wantStatus: func() *v1.ConduitStatus { - status := &v1.ConduitStatus{} - status.SetCondition(v1.ConditionConduitServiceReady, corev1.ConditionFalse, "", "") - status.SetCondition(v1.ConditionConduitReady, corev1.ConditionFalse, "", "") + wantStatus: func() *v1alpha.ConduitStatus { + status := &v1alpha.ConduitStatus{} + status.SetCondition(v1alpha.ConditionConduitServiceReady, corev1.ConditionFalse, "", "") + status.SetCondition(v1alpha.ConditionConduitReady, corev1.ConditionFalse, "", "") return status }(), - setup: func(ctrl *gomock.Controller, c *v1.Conduit) *controllers.ConduitReconciler { + setup: func(ctrl *gomock.Controller, c *v1alpha.Conduit) *controllers.ConduitReconciler { nn := c.NamespacedName() svc := &corev1.Service{ ObjectMeta: metav1.ObjectMeta{ @@ -590,7 +590,7 @@ func Test_CreateOrUpdateService(t *testing.T) { client.EXPECT().Get(ctx, nn, svc).Return(internalErr) recorder := mock.NewMockEventRecorder(ctrl) - recorder.EXPECT().Eventf(c, corev1.EventTypeWarning, v1.ErroredReason, gomock.Any(), nn, internalErr) + recorder.EXPECT().Eventf(c, corev1.EventTypeWarning, v1alpha.ErroredReason, gomock.Any(), nn, internalErr) return &controllers.ConduitReconciler{ Client: client, @@ -626,22 +626,22 @@ func Test_CreateOrUpdateDeployment(t *testing.T) { tests := []struct { name string - conduit *v1.Conduit - setup func(ctrl *gomock.Controller, c *v1.Conduit) *controllers.ConduitReconciler - wantStatus *v1.ConduitStatus + conduit *v1alpha.Conduit + setup func(ctrl *gomock.Controller, c *v1alpha.Conduit) *controllers.ConduitReconciler + wantStatus *v1alpha.ConduitStatus wantErr error }{ { name: "deployment is created", conduit: sampleConduit(true), - wantStatus: func() *v1.ConduitStatus { - status := &v1.ConduitStatus{} - status.SetCondition(v1.ConditionConduitDeploymentRunning, corev1.ConditionTrue, "", "") - status.SetCondition(v1.ConditionConduitReady, corev1.ConditionFalse, "", "") + wantStatus: func() *v1alpha.ConduitStatus { + status := &v1alpha.ConduitStatus{} + status.SetCondition(v1alpha.ConditionConduitDeploymentRunning, corev1.ConditionTrue, "", "") + status.SetCondition(v1alpha.ConditionConduitReady, corev1.ConditionFalse, "", "") return status }(), - setup: func(ctrl *gomock.Controller, c *v1.Conduit) *controllers.ConduitReconciler { + setup: func(ctrl *gomock.Controller, c *v1alpha.Conduit) *controllers.ConduitReconciler { nn := c.NamespacedName() deployment := &appsv1.Deployment{ ObjectMeta: metav1.ObjectMeta{ @@ -666,10 +666,10 @@ func Test_CreateOrUpdateDeployment(t *testing.T) { client.EXPECT().Create(ctx, mock.NewDeploymentMatcher(createdDeployment)).Return(nil) recorder := mock.NewMockEventRecorder(ctrl) - recorder.EXPECT().Eventf(c, corev1.EventTypeNormal, v1.CreatedReason, gomock.Any(), nn) + recorder.EXPECT().Eventf(c, corev1.EventTypeNormal, v1alpha.CreatedReason, gomock.Any(), nn) return &controllers.ConduitReconciler{ - Metadata: &v1.ConduitInstanceMetadata{}, + Metadata: &v1alpha.ConduitInstanceMetadata{}, Client: client, EventRecorder: recorder, } @@ -678,14 +678,14 @@ func Test_CreateOrUpdateDeployment(t *testing.T) { { name: "deployment is updated", conduit: sampleConduit(true), - wantStatus: func() *v1.ConduitStatus { - status := &v1.ConduitStatus{} - status.SetCondition(v1.ConditionConduitDeploymentRunning, corev1.ConditionTrue, "", "") - status.SetCondition(v1.ConditionConduitReady, corev1.ConditionFalse, "", "") + wantStatus: func() *v1alpha.ConduitStatus { + status := &v1alpha.ConduitStatus{} + status.SetCondition(v1alpha.ConditionConduitDeploymentRunning, corev1.ConditionTrue, "", "") + status.SetCondition(v1alpha.ConditionConduitReady, corev1.ConditionFalse, "", "") return status }(), - setup: func(ctrl *gomock.Controller, c *v1.Conduit) *controllers.ConduitReconciler { + setup: func(ctrl *gomock.Controller, c *v1alpha.Conduit) *controllers.ConduitReconciler { nn := c.NamespacedName() deployment := &appsv1.Deployment{ ObjectMeta: metav1.ObjectMeta{ @@ -707,15 +707,15 @@ func Test_CreateOrUpdateDeployment(t *testing.T) { updatedDeployment.Spec.Template.Annotations = map[string]string{ "operator.conduit.io/config-map-version": resourceVer, } - c.Status.SetCondition(v1.ConditionConduitDeploymentRunning, corev1.ConditionFalse, "", "") + c.Status.SetCondition(v1alpha.ConditionConduitDeploymentRunning, corev1.ConditionFalse, "", "") client.EXPECT().Update(ctx, mock.NewDeploymentMatcher(updatedDeployment)).Return(nil) recorder := mock.NewMockEventRecorder(ctrl) - recorder.EXPECT().Eventf(c, corev1.EventTypeNormal, v1.RunningReason, gomock.Any(), nn) - recorder.EXPECT().Eventf(c, corev1.EventTypeNormal, v1.UpdatedReason, gomock.Any(), nn) + recorder.EXPECT().Eventf(c, corev1.EventTypeNormal, v1alpha.RunningReason, gomock.Any(), nn) + recorder.EXPECT().Eventf(c, corev1.EventTypeNormal, v1alpha.UpdatedReason, gomock.Any(), nn) return &controllers.ConduitReconciler{ - Metadata: &v1.ConduitInstanceMetadata{}, + Metadata: &v1alpha.ConduitInstanceMetadata{}, Client: client, EventRecorder: recorder, } @@ -724,14 +724,14 @@ func Test_CreateOrUpdateDeployment(t *testing.T) { { name: "deployment is updated but not running", conduit: sampleConduit(true), - wantStatus: func() *v1.ConduitStatus { - status := &v1.ConduitStatus{} - status.SetCondition(v1.ConditionConduitDeploymentRunning, corev1.ConditionFalse, "", "") - status.SetCondition(v1.ConditionConduitReady, corev1.ConditionFalse, "", "") + wantStatus: func() *v1alpha.ConduitStatus { + status := &v1alpha.ConduitStatus{} + status.SetCondition(v1alpha.ConditionConduitDeploymentRunning, corev1.ConditionFalse, "", "") + status.SetCondition(v1alpha.ConditionConduitReady, corev1.ConditionFalse, "", "") return status }(), - setup: func(ctrl *gomock.Controller, c *v1.Conduit) *controllers.ConduitReconciler { + setup: func(ctrl *gomock.Controller, c *v1alpha.Conduit) *controllers.ConduitReconciler { nn := c.NamespacedName() deployment := &appsv1.Deployment{ ObjectMeta: metav1.ObjectMeta{ @@ -757,15 +757,15 @@ func Test_CreateOrUpdateDeployment(t *testing.T) { updatedDeployment.Spec.Template.Annotations = map[string]string{ "operator.conduit.io/config-map-version": "resource-version-121", } - c.Status.SetCondition(v1.ConditionConduitDeploymentRunning, corev1.ConditionTrue, "", "") + c.Status.SetCondition(v1alpha.ConditionConduitDeploymentRunning, corev1.ConditionTrue, "", "") client.EXPECT().Update(ctx, mock.NewDeploymentMatcher(updatedDeployment)).Return(nil) recorder := mock.NewMockEventRecorder(ctrl) - recorder.EXPECT().Eventf(c, corev1.EventTypeNormal, v1.PendingReason, gomock.Any(), nn) - recorder.EXPECT().Eventf(c, corev1.EventTypeNormal, v1.UpdatedReason, gomock.Any(), nn) + recorder.EXPECT().Eventf(c, corev1.EventTypeNormal, v1alpha.PendingReason, gomock.Any(), nn) + recorder.EXPECT().Eventf(c, corev1.EventTypeNormal, v1alpha.UpdatedReason, gomock.Any(), nn) return &controllers.ConduitReconciler{ - Metadata: &v1.ConduitInstanceMetadata{}, + Metadata: &v1alpha.ConduitInstanceMetadata{}, Client: client, EventRecorder: recorder, } @@ -774,20 +774,20 @@ func Test_CreateOrUpdateDeployment(t *testing.T) { { name: "error when getting config map", conduit: sampleConduit(true), - wantStatus: func() *v1.ConduitStatus { - return &v1.ConduitStatus{} + wantStatus: func() *v1alpha.ConduitStatus { + return &v1alpha.ConduitStatus{} }(), - setup: func(ctrl *gomock.Controller, c *v1.Conduit) *controllers.ConduitReconciler { + setup: func(ctrl *gomock.Controller, c *v1alpha.Conduit) *controllers.ConduitReconciler { nn := c.NamespacedName() client := mock.NewMockClient(ctrl) client.EXPECT().Get(ctx, nn, &corev1.ConfigMap{}).Return(internalErr) recorder := mock.NewMockEventRecorder(ctrl) - recorder.EXPECT().Eventf(c, corev1.EventTypeWarning, v1.ErroredReason, gomock.Any(), nn, internalErr) + recorder.EXPECT().Eventf(c, corev1.EventTypeWarning, v1alpha.ErroredReason, gomock.Any(), nn, internalErr) return &controllers.ConduitReconciler{ - Metadata: &v1.ConduitInstanceMetadata{}, + Metadata: &v1alpha.ConduitInstanceMetadata{}, Client: client, EventRecorder: recorder, } @@ -797,14 +797,14 @@ func Test_CreateOrUpdateDeployment(t *testing.T) { { name: "error when creating or updating deployment", conduit: sampleConduit(true), - wantStatus: func() *v1.ConduitStatus { - status := &v1.ConduitStatus{} - status.SetCondition(v1.ConditionConduitDeploymentRunning, corev1.ConditionFalse, "", "") - status.SetCondition(v1.ConditionConduitReady, corev1.ConditionFalse, "", "") + wantStatus: func() *v1alpha.ConduitStatus { + status := &v1alpha.ConduitStatus{} + status.SetCondition(v1alpha.ConditionConduitDeploymentRunning, corev1.ConditionFalse, "", "") + status.SetCondition(v1alpha.ConditionConduitReady, corev1.ConditionFalse, "", "") return status }(), - setup: func(ctrl *gomock.Controller, c *v1.Conduit) *controllers.ConduitReconciler { + setup: func(ctrl *gomock.Controller, c *v1alpha.Conduit) *controllers.ConduitReconciler { nn := c.NamespacedName() deployment := &appsv1.Deployment{ ObjectMeta: metav1.ObjectMeta{ @@ -831,10 +831,10 @@ func Test_CreateOrUpdateDeployment(t *testing.T) { client.EXPECT().Create(ctx, mock.NewDeploymentMatcher(createdDeployment)).Return(internalErr) recorder := mock.NewMockEventRecorder(ctrl) - recorder.EXPECT().Eventf(c, corev1.EventTypeWarning, v1.ErroredReason, gomock.Any(), nn, internalErr) + recorder.EXPECT().Eventf(c, corev1.EventTypeWarning, v1alpha.ErroredReason, gomock.Any(), nn, internalErr) return &controllers.ConduitReconciler{ - Metadata: &v1.ConduitInstanceMetadata{}, + Metadata: &v1alpha.ConduitInstanceMetadata{}, Client: client, EventRecorder: recorder, } @@ -874,23 +874,23 @@ func Test_UpdateStatus(t *testing.T) { tests := []struct { name string - conduit *v1.Conduit - setup func(ctrl *gomock.Controller, c *v1.Conduit) *controllers.ConduitReconciler - wantStatus *v1.ConduitStatus + conduit *v1alpha.Conduit + setup func(ctrl *gomock.Controller, c *v1alpha.Conduit) *controllers.ConduitReconciler + wantStatus *v1alpha.ConduitStatus wantErr error }{ { name: "status is updated", conduit: conduitSample.DeepCopy(), - setup: func(ctrl *gomock.Controller, c *v1.Conduit) *controllers.ConduitReconciler { + setup: func(ctrl *gomock.Controller, c *v1alpha.Conduit) *controllers.ConduitReconciler { client := mock.NewMockClient(ctrl) statusWriter := mock.NewMockStatusWriter(ctrl) - c.Status = v1.ConduitStatus{} - c.Status.SetCondition(v1.ConditionConduitServiceReady, corev1.ConditionFalse, "", "") + c.Status = v1alpha.ConduitStatus{} + c.Status.SetCondition(v1alpha.ConditionConduitServiceReady, corev1.ConditionFalse, "", "") client.EXPECT(). - Get(ctx, kclient.ObjectKeyFromObject(c), &v1.Conduit{}). + Get(ctx, kclient.ObjectKeyFromObject(c), &v1alpha.Conduit{}). Return(nil) client.EXPECT().Status().Return(statusWriter) @@ -898,7 +898,7 @@ func Test_UpdateStatus(t *testing.T) { recorder := mock.NewMockEventRecorder(ctrl) recorder.EXPECT(). - Event(c, corev1.EventTypeNormal, v1.UpdatedReason, "Status updated") + Event(c, corev1.EventTypeNormal, v1alpha.UpdatedReason, "Status updated") return &controllers.ConduitReconciler{ Client: client, @@ -909,10 +909,10 @@ func Test_UpdateStatus(t *testing.T) { { name: "status is unchaged", conduit: conduitSample.DeepCopy(), - setup: func(ctrl *gomock.Controller, c *v1.Conduit) *controllers.ConduitReconciler { + setup: func(ctrl *gomock.Controller, c *v1alpha.Conduit) *controllers.ConduitReconciler { client := mock.NewMockClient(ctrl) client.EXPECT(). - Get(ctx, kclient.ObjectKeyFromObject(c), &v1.Conduit{}). + Get(ctx, kclient.ObjectKeyFromObject(c), &v1alpha.Conduit{}). Return(nil) return &controllers.ConduitReconciler{ @@ -924,10 +924,10 @@ func Test_UpdateStatus(t *testing.T) { { name: "error getting latest conduit", conduit: conduitSample.DeepCopy(), - setup: func(ctrl *gomock.Controller, c *v1.Conduit) *controllers.ConduitReconciler { + setup: func(ctrl *gomock.Controller, c *v1alpha.Conduit) *controllers.ConduitReconciler { client := mock.NewMockClient(ctrl) client.EXPECT(). - Get(ctx, kclient.ObjectKeyFromObject(c), &v1.Conduit{}). + Get(ctx, kclient.ObjectKeyFromObject(c), &v1alpha.Conduit{}). Return(internalErr) return &controllers.ConduitReconciler{ @@ -940,22 +940,22 @@ func Test_UpdateStatus(t *testing.T) { { name: "error updating status", conduit: conduitSample.DeepCopy(), - setup: func(ctrl *gomock.Controller, c *v1.Conduit) *controllers.ConduitReconciler { + setup: func(ctrl *gomock.Controller, c *v1alpha.Conduit) *controllers.ConduitReconciler { client := mock.NewMockClient(ctrl) statusWriter := mock.NewMockStatusWriter(ctrl) client.EXPECT(). - Get(ctx, kclient.ObjectKeyFromObject(c), &v1.Conduit{}). - DoAndReturn(func(_ context.Context, _ types.NamespacedName, pc *v1.Conduit, _ ...kclient.CreateOption) error { - pc.Status = v1.ConduitStatus{} - pc.Status.SetCondition(v1.ConditionConduitServiceReady, corev1.ConditionFalse, "", "") + Get(ctx, kclient.ObjectKeyFromObject(c), &v1alpha.Conduit{}). + DoAndReturn(func(_ context.Context, _ types.NamespacedName, pc *v1alpha.Conduit, _ ...kclient.CreateOption) error { + pc.Status = v1alpha.ConduitStatus{} + pc.Status.SetCondition(v1alpha.ConditionConduitServiceReady, corev1.ConditionFalse, "", "") return nil }) client.EXPECT().Status().Return(statusWriter) statusWriter.EXPECT().Update(ctx, c).Return(internalErr) recorder := mock.NewMockEventRecorder(ctrl) - recorder.EXPECT().Eventf(c, corev1.EventTypeWarning, v1.ErroredReason, gomock.Any(), internalErr) + recorder.EXPECT().Eventf(c, corev1.EventTypeWarning, v1alpha.ErroredReason, gomock.Any(), internalErr) return &controllers.ConduitReconciler{ Client: client, @@ -983,8 +983,8 @@ func Test_UpdateStatus(t *testing.T) { func conduitScheme() *runtime.Scheme { scheme := runtime.NewScheme() - _ = v1.AddToScheme(scheme) - v1.SchemeBuilder.Register(&v1.Conduit{}, &v1.ConduitList{}) + _ = v1alpha.AddToScheme(scheme) + v1alpha.SchemeBuilder.Register(&v1alpha.Conduit{}, &v1alpha.ConduitList{}) return scheme } diff --git a/controllers/conduit_test.go b/controllers/conduit_test.go index beabfae..d7e3af9 100644 --- a/controllers/conduit_test.go +++ b/controllers/conduit_test.go @@ -9,11 +9,11 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" - v1 "github.com/conduitio/conduit-operator/api/v1" + v1alpha "github.com/conduitio/conduit-operator/api/v1alpha" ) -func compareStatusConditions(want, got v1.Conditions) string { - return cmp.Diff(want, got, cmpopts.IgnoreFields(v1.Condition{}, []string{ +func compareStatusConditions(want, got v1alpha.Conditions) string { + return cmp.Diff(want, got, cmpopts.IgnoreFields(v1alpha.Condition{}, []string{ "LastTransitionTime", "Message", "Reason", @@ -28,14 +28,14 @@ func mustReadFile(file string) string { return string(v) } -func sampleConduitWithProcessors(running bool) *v1.Conduit { +func sampleConduitWithProcessors(running bool) *v1alpha.Conduit { c := sampleConduit(running) - c.Spec.Processors = []*v1.ConduitProcessor{ + c.Spec.Processors = []*v1alpha.ConduitProcessor{ { Name: "proc1", Type: "yaml", - Settings: []v1.SettingsVar{ + Settings: []v1alpha.SettingsVar{ { Name: "setting101", SecretRef: &corev1.SecretKeySelector{ @@ -58,11 +58,11 @@ func sampleConduitWithProcessors(running bool) *v1.Conduit { } // source - c.Spec.Connectors[0].Processors = []*v1.ConduitProcessor{ + c.Spec.Connectors[0].Processors = []*v1alpha.ConduitProcessor{ { Name: "proc1src", Type: "js", - Settings: []v1.SettingsVar{ + Settings: []v1alpha.SettingsVar{ { Name: "setting0", SecretRef: &corev1.SecretKeySelector{ @@ -81,11 +81,11 @@ func sampleConduitWithProcessors(running bool) *v1.Conduit { } // dest - c.Spec.Connectors[1].Processors = []*v1.ConduitProcessor{ + c.Spec.Connectors[1].Processors = []*v1alpha.ConduitProcessor{ { Name: "proc1dest", Type: "js", - Settings: []v1.SettingsVar{ + Settings: []v1alpha.SettingsVar{ { Name: "setting0", SecretRef: &corev1.SecretKeySelector{ @@ -106,22 +106,22 @@ func sampleConduitWithProcessors(running bool) *v1.Conduit { return c } -func sampleConduit(running bool) *v1.Conduit { - return &v1.Conduit{ +func sampleConduit(running bool) *v1alpha.Conduit { + return &v1alpha.Conduit{ ObjectMeta: metav1.ObjectMeta{ Name: "sample", Namespace: "sample", }, - Spec: v1.ConduitSpec{ + Spec: v1alpha.ConduitSpec{ Running: running, Name: "my-pipeline", Description: "my-description", - Connectors: []*v1.ConduitConnector{ + Connectors: []*v1alpha.ConduitConnector{ { Name: "source-connector", Type: "source", PluginName: "standalone:generator", - Settings: []v1.SettingsVar{ + Settings: []v1alpha.SettingsVar{ { Name: "setting1", Value: "setting1-val", @@ -145,7 +145,7 @@ func sampleConduit(running bool) *v1.Conduit { Name: "destination-connector", Type: "destination", PluginName: "builtin:file", - Settings: []v1.SettingsVar{ + Settings: []v1alpha.SettingsVar{ { Name: "setting2", SecretRef: &corev1.SecretKeySelector{ diff --git a/controllers/conduit_ver.go b/controllers/conduit_ver.go index 81b117a..62425de 100644 --- a/controllers/conduit_ver.go +++ b/controllers/conduit_ver.go @@ -5,12 +5,12 @@ import ( "strings" "github.com/Masterminds/semver/v3" - v1 "github.com/conduitio/conduit-operator/api/v1" + v1alpha "github.com/conduitio/conduit-operator/api/v1alpha" ) func init() { // validate constraint - constraint := fmt.Sprint(">= ", v1.ConduitWithProcessorsVersion) + constraint := fmt.Sprint(">= ", v1alpha.ConduitWithProcessorsVersion) if _, err := semver.NewConstraint(constraint); err != nil { panic(fmt.Errorf("failed to create version constraint: %w", err)) } @@ -24,6 +24,6 @@ func withProcessors(ver string) bool { if err != nil { return false } - c, _ := semver.NewConstraint(fmt.Sprint(">= ", v1.ConduitWithProcessorsVersion)) + c, _ := semver.NewConstraint(fmt.Sprint(">= ", v1alpha.ConduitWithProcessorsVersion)) return c.Check(v) } diff --git a/controllers/conduit_volumes.go b/controllers/conduit_volumes.go index 67bb4bf..b645d12 100644 --- a/controllers/conduit_volumes.go +++ b/controllers/conduit_volumes.go @@ -1,7 +1,7 @@ package controllers import ( - v1 "github.com/conduitio/conduit-operator/api/v1" + v1alpha "github.com/conduitio/conduit-operator/api/v1alpha" "k8s.io/apimachinery/pkg/api/resource" "k8s.io/apimachinery/pkg/types" @@ -32,7 +32,7 @@ func ConduitVolumeClaim(nn types.NamespacedName, size string) *corev1.Persistent // ConduitVolume returns a kubernetes volume definition for the provided claim func ConduitVolume(claimName string) corev1.Volume { return corev1.Volume{ - Name: v1.ConduitStorageVolumeMount, + Name: v1alpha.ConduitStorageVolumeMount, VolumeSource: corev1.VolumeSource{ PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{ ClaimName: claimName, @@ -45,7 +45,7 @@ func ConduitVolume(claimName string) corev1.Volume { func ConduitPipelineVol(refName string) corev1.Volume { defaultMode := int32(0o440) // octal, user/group readable return corev1.Volume{ - Name: v1.ConduitPipelineVolumeMount, + Name: v1alpha.ConduitPipelineVolumeMount, VolumeSource: corev1.VolumeSource{ ConfigMap: &corev1.ConfigMapVolumeSource{ LocalObjectReference: corev1.LocalObjectReference{ diff --git a/controllers/conduit_volumes_test.go b/controllers/conduit_volumes_test.go index 7a9147f..4b4825c 100644 --- a/controllers/conduit_volumes_test.go +++ b/controllers/conduit_volumes_test.go @@ -11,7 +11,7 @@ import ( "k8s.io/apimachinery/pkg/api/resource" "k8s.io/apimachinery/pkg/types" - v1 "github.com/conduitio/conduit-operator/api/v1" + v1alpha "github.com/conduitio/conduit-operator/api/v1alpha" ctrls "github.com/conduitio/conduit-operator/controllers" ) @@ -45,7 +45,7 @@ func Test_ConduitVolumeClaim(t *testing.T) { func Test_ConduitVolume(t *testing.T) { want := corev1.Volume{ - Name: v1.ConduitStorageVolumeMount, + Name: v1alpha.ConduitStorageVolumeMount, VolumeSource: corev1.VolumeSource{ PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{ ClaimName: "my-claim-name", @@ -62,7 +62,7 @@ func Test_ConduitVolume(t *testing.T) { func Test_ConduitPipelineVol(t *testing.T) { mode := int32(0o440) want := corev1.Volume{ - Name: v1.ConduitPipelineVolumeMount, + Name: v1alpha.ConduitPipelineVolumeMount, VolumeSource: corev1.VolumeSource{ ConfigMap: &corev1.ConfigMapVolumeSource{ LocalObjectReference: corev1.LocalObjectReference{ diff --git a/controllers/mock/client_matcher.go b/controllers/mock/client_matcher.go index ff9a94e..9ae3fc8 100644 --- a/controllers/mock/client_matcher.go +++ b/controllers/mock/client_matcher.go @@ -3,7 +3,7 @@ package mock import ( "fmt" - v1 "github.com/conduitio/conduit-operator/api/v1" + v1alpha "github.com/conduitio/conduit-operator/api/v1alpha" "github.com/golang/mock/gomock" "github.com/google/go-cmp/cmp" @@ -85,15 +85,15 @@ func (m *pvcMatcher) Matches(x interface{}) bool { } type conduitMatcher struct { - want, got *v1.Conduit + want, got *v1alpha.Conduit } -func NewConduitMatcher(c *v1.Conduit) gomock.Matcher { +func NewConduitMatcher(c *v1alpha.Conduit) gomock.Matcher { return &conduitMatcher{want: c} } func (m *conduitMatcher) Matches(x interface{}) bool { - other, ok := x.(*v1.Conduit) + other, ok := x.(*v1alpha.Conduit) if !ok { return false }