From eed393b859000866ecc271d117b9971c3693cfda Mon Sep 17 00:00:00 2001 From: odubajDT <93584209+odubajDT@users.noreply.github.com> Date: Tue, 26 Mar 2024 14:59:46 +0100 Subject: [PATCH] feat(lifecycle-operator): move API HUB version to v1 (#3350) Signed-off-by: odubajDT --- .github/actions/spelling/expect.txt | 1 + .../scripts/.helm-tests/default/result.yaml | 44 +-- .../.helm-tests/lifecycle-only/result.yaml | 44 +-- .../lifecycle-with-certs/result.yaml | 44 +-- .../local-global-precedence/result.yaml | 44 +-- .../api-reference/lifecycle/v1/index.md | 118 +++--- .../apis/lifecycle/v1/common/common.go | 8 +- .../apis/lifecycle/v1/keptnapp_conversion.go | 63 +--- .../apis/lifecycle/v1/keptnapp_types.go | 1 + .../{v1beta1 => v1}/keptnapp_webhook.go | 2 +- .../lifecycle/v1/keptnappcontext_types.go | 1 + .../v1/keptnappcreationrequest_types.go | 1 + .../v1/keptnappversion_conversion.go | 259 +------------- .../lifecycle/v1/keptnappversion_types.go | 1 + .../keptnappversion_webhook.go | 2 +- .../lifecycle/v1/keptnevaluation_types.go | 1 + .../v1/keptnevaluationdefinition_types.go | 1 + .../apis/lifecycle/v1/keptntask_types.go | 1 + .../lifecycle/v1/keptntaskdefinition_types.go | 1 + .../keptntaskdefinition_webhook.go | 4 +- .../keptntaskdefinition_webhook_test.go | 2 +- .../apis/lifecycle/v1/keptnworkload_types.go | 1 + .../v1/keptnworkloadversion_types.go | 1 + .../lifecycle/v1/zz_generated.deepcopy.go | 2 +- .../apis/lifecycle/v1alpha1/common/common.go | 6 +- .../lifecycle/v1alpha1/keptnapp_conversion.go | 12 +- .../v1alpha1/keptnapp_conversion_test.go | 60 ++-- .../v1alpha1/keptnappversion_conversion.go | 50 +-- .../keptnappversion_conversion_test.go | 174 ++++----- .../apis/lifecycle/v1alpha2/common/common.go | 6 +- .../lifecycle/v1alpha2/keptnapp_conversion.go | 12 +- .../v1alpha2/keptnapp_conversion_test.go | 54 +-- .../v1alpha2/keptnappversion_conversion.go | 50 +-- .../keptnappversion_conversion_test.go | 176 ++++----- .../v1alpha2/keptnappversion_test.go | 9 +- .../apis/lifecycle/v1alpha3/common/common.go | 4 +- .../lifecycle/v1alpha3/keptnapp_conversion.go | 12 +- .../v1alpha3/keptnapp_conversion_test.go | 62 ++-- .../v1alpha3/keptnappversion_conversion.go | 50 +-- .../keptnappversion_conversion_test.go | 174 ++++----- .../apis/lifecycle/v1beta1/common/common.go | 4 + .../lifecycle/v1beta1/keptnapp_conversion.go | 63 +++- .../keptnapp_conversion_test.go | 58 +-- .../apis/lifecycle/v1beta1/keptnapp_types.go | 1 - .../v1beta1/keptnappcontext_types.go | 1 - .../v1beta1/keptnappcreationrequest_types.go | 1 - .../v1beta1/keptnappversion_conversion.go | 259 +++++++++++++- .../keptnappversion_conversion_test.go | 188 +++++----- .../v1beta1/keptnappversion_types.go | 1 - .../v1beta1/keptnevaluation_types.go | 1 - .../keptnevaluationdefinition_types.go | 1 - .../apis/lifecycle/v1beta1/keptntask_types.go | 1 - .../v1beta1/keptntaskdefinition_types.go | 1 - .../lifecycle/v1beta1/keptnworkload_types.go | 1 - .../v1beta1/keptnworkloadversion_types.go | 1 - .../v1beta1/zz_generated.deepcopy.go | 2 +- .../chart/templates/keptnapp-crd.yaml | 4 +- .../chart/templates/keptnappcontext-crd.yaml | 4 +- .../keptnappcreationrequest-crd.yaml | 4 +- .../chart/templates/keptnappversion-crd.yaml | 4 +- .../chart/templates/keptnevaluation-crd.yaml | 4 +- .../keptnevaluationdefinition-crd.yaml | 4 +- .../chart/templates/keptntask-crd.yaml | 4 +- .../templates/keptntaskdefinition-crd.yaml | 4 +- .../chart/templates/keptnworkload-crd.yaml | 4 +- .../templates/keptnworkloadversion-crd.yaml | 4 +- ...ycle-validating-webhook-configuration.yaml | 4 +- .../lifecycle.keptn.sh_keptnappcontexts.yaml | 4 +- ...cle.keptn.sh_keptnappcreationrequests.yaml | 4 +- .../bases/lifecycle.keptn.sh_keptnapps.yaml | 4 +- .../lifecycle.keptn.sh_keptnappversions.yaml | 4 +- ...e.keptn.sh_keptnevaluationdefinitions.yaml | 4 +- .../lifecycle.keptn.sh_keptnevaluations.yaml | 4 +- ...fecycle.keptn.sh_keptntaskdefinitions.yaml | 4 +- .../bases/lifecycle.keptn.sh_keptntasks.yaml | 4 +- .../lifecycle.keptn.sh_keptnworkloads.yaml | 4 +- ...ecycle.keptn.sh_keptnworkloadversions.yaml | 4 +- .../config/webhook/manifests.yaml | 4 +- .../evaluation/fake/evaluationhandler_mock.go | 10 +- .../controllers/common/evaluation/handler.go | 24 +- .../common/evaluation/handler_test.go | 158 ++++---- .../common/eventsender/eventsender.go | 2 +- .../common/eventsender/eventsender_test.go | 62 ++-- .../common/eventsender/fake/event_mock.go | 2 +- .../controllers/common/helperfunctions.go | 20 +- .../common/helperfunctions_test.go | 78 ++-- .../common/phase/fake/handler_mock.go | 2 +- .../controllers/common/phase/handler.go | 2 +- .../controllers/common/phase/handler_test.go | 64 ++-- .../providers/keptnmetric/keptnmetric.go | 6 +- .../providers/keptnmetric/keptnmetric_test.go | 24 +- .../controllers/common/task/handler.go | 24 +- .../controllers/common/task/handler_test.go | 178 +++++----- .../common/taskdefinition/handler.go | 28 +- .../common/taskdefinition/handler_test.go | 164 ++++----- .../common/telemetry/metrics_test.go | 168 ++++----- .../common/telemetry/otel_utils.go | 20 +- .../common/telemetry/spanhandler_test.go | 14 +- .../controllers/common/testcommon/utils.go | 24 +- .../interfaces/activemetricsobject_test.go | 8 +- .../lifecycle/interfaces/eventobject_test.go | 8 +- .../interfaces/fake/phaseitem_mock.go | 62 ++-- .../lifecycle/interfaces/listitem_test.go | 10 +- .../interfaces/metricsobject_test.go | 8 +- .../lifecycle/interfaces/phaseitem.go | 32 +- .../lifecycle/interfaces/phaseitem_test.go | 32 +- .../lifecycle/interfaces/spanitem_test.go | 10 +- .../lifecycle/keptnapp/controller.go | 20 +- .../lifecycle/keptnapp/controller_test.go | 56 +-- .../keptnappcreationrequest/controller.go | 48 +-- .../controller_test.go | 162 ++++----- .../lifecycle/keptnappversion/controller.go | 18 +- .../keptnappversion/controller_test.go | 102 +++--- .../keptnappversion/reconcile_phase.go | 6 +- .../reconcile_prepostevaluation.go | 6 +- .../reconcile_workloadsstate.go | 20 +- .../reconcile_workloadstate_test.go | 56 +-- .../lifecycle/keptnevaluation/common.go | 4 +- .../lifecycle/keptnevaluation/common_test.go | 76 ++-- .../lifecycle/keptnevaluation/controller.go | 26 +- .../keptnevaluation/controller_test.go | 66 ++-- .../lifecycle/keptntask/container_builder.go | 6 +- .../keptntask/container_builder_test.go | 36 +- .../lifecycle/keptntask/controller.go | 8 +- .../lifecycle/keptntask/job_runner_builder.go | 8 +- .../keptntask/job_runner_builder_test.go | 8 +- .../lifecycle/keptntask/job_utils.go | 12 +- .../lifecycle/keptntask/job_utils_test.go | 40 +-- .../lifecycle/keptntask/runtime_builder.go | 10 +- .../keptntask/runtime_builder_test.go | 80 ++--- .../keptntaskdefinition/controller.go | 6 +- .../keptntaskdefinition/reconcile_function.go | 8 +- .../lifecycle/keptnworkload/controller.go | 28 +- .../keptnworkload/controller_test.go | 66 ++-- .../keptnworkloadversion/controller.go | 54 +-- .../keptnworkloadversion/controller_test.go | 336 +++++++++--------- .../reconcile_deploymentstate.go | 18 +- .../reconcile_prepostdeployment.go | 6 +- .../reconcile_prepostevaluation.go | 6 +- .../lifecycle/schedulinggates/controller.go | 6 +- .../schedulinggates/controller_test.go | 54 +-- lifecycle-operator/converter/convert_app.go | 36 +- .../converter/example_output.yaml | 4 +- lifecycle-operator/main.go | 6 +- .../test/component/app/app_test.go | 12 +- .../component/appversion/appversion_test.go | 34 +- .../test/component/common/common.go | 14 +- .../component/evaluation/evaluation_test.go | 54 +-- .../test/component/load/load_test.go | 12 +- .../test/component/task/task_test.go | 34 +- .../taskdefinition/taskdefinition_test.go | 44 +-- .../test/component/workload/workload_test.go | 16 +- .../workloadversion/workloadversion_test.go | 76 ++-- lifecycle-operator/test/e2e/suite_test.go | 4 +- .../handlers/appcreationrequest_handler.go | 14 +- .../appcreationrequest_handler_test.go | 26 +- .../pod_mutator/handlers/objectmeta.go | 2 +- .../pod_mutator/handlers/objectmeta_test.go | 2 +- .../pod_mutator/handlers/pod_annotation.go | 2 +- .../handlers/pod_annotation_test.go | 2 +- .../webhooks/pod_mutator/handlers/workload.go | 18 +- .../pod_mutator/handlers/workload_test.go | 32 +- .../pod_mutator/pod_mutating_webhook.go | 2 +- .../pod_mutator/pod_mutating_webhook_test.go | 44 +-- .../simple-deployment-allowed/00-install.yaml | 2 +- .../simple-deployment-allowed/01-assert.yaml | 4 +- .../00-install.yaml | 2 +- .../chainsaw-test.yaml | 6 +- .../00-install.yaml | 4 +- .../00-assert.yaml | 0 .../00-install.yaml | 18 +- .../chainsaw-test.yaml | 2 +- .../00-assert.yaml | 18 +- .../00-install.yaml | 0 .../chainsaw-test.yaml | 2 +- .../app-creation-request/00-assert.yaml | 2 +- .../app-creation-request/00-install.yaml | 4 +- .../app-creation-request/01-assert.yaml | 2 +- .../app-creation-request/01-install.yaml | 6 +- .../00-assert.yaml | 2 +- .../00-install.yaml | 4 +- .../app-failing-post-task/00-assert.yaml | 2 +- .../app-failing-post-task/00-install.yaml | 4 +- .../00-assert.yaml | 6 +- .../00-install.yaml | 4 +- .../app-failing-pre-evaluation/00-assert.yaml | 6 +- .../00-install.yaml | 4 +- .../app-failing-pre-task-retry/00-assert.yaml | 4 +- .../00-install.yaml | 4 +- .../00-assert.yaml | 4 +- .../00-install.yaml | 4 +- .../app-failing-pre-task/00-assert.yaml | 2 +- .../app-failing-pre-task/00-install.yaml | 4 +- .../00-assert.yaml | 4 +- .../00-install.yaml | 4 +- .../container-runtime/00-assert.yaml | 4 +- .../container-runtime/00-install.yaml | 2 +- .../imagepullsecret/00-assert.yaml | 4 +- .../imagepullsecret/00-install.yaml | 2 +- .../00-assert.yaml | 2 +- .../podtato-head-application/00-assert.yaml | 16 +- .../podtato-head-application/00-install.yaml | 10 +- .../restartable-app/00-assert.yaml | 2 +- .../restartable-app/00-install.yaml | 6 +- .../restartable-app/01-assert.yaml | 16 +- .../restartable-app/01-install.yaml | 2 +- .../restartable-app/02-assert.yaml | 18 +- .../restartable-app/02-install.yaml | 2 +- .../serviceaccount-in-jobs/00-install.yaml | 4 +- .../00-install.yaml | 2 +- .../simple-daemonset-annotated/01-assert.yaml | 4 +- .../simple-daemonset-annotated/02-assert.yaml | 2 +- .../00-assert.yaml | 4 +- .../00-install.yaml | 4 +- .../00-assert.yaml | 8 +- .../01-assert.yaml | 8 +- .../00-assert.yaml | 4 +- .../00-install.yaml | 2 +- .../00-assert.yaml | 8 +- .../00-assert.yaml | 4 +- .../00-install.yaml | 2 +- .../00-assert.yaml | 2 +- .../00-install.yaml | 4 +- .../00-assert.yaml | 8 +- .../00-install.yaml | 2 +- .../simple-deployment/00-assert.yaml | 8 +- .../simple-deployment/00-install.yaml | 2 +- .../00-assert.yaml | 4 +- .../00-install.yaml | 2 +- .../02-assert.yaml | 2 +- .../integration/simple-task/00-install.yaml | 4 +- .../td_bad_container_deno.yaml | 2 +- .../td_bad_container_python.yaml | 2 +- .../validate-taskdefinition/td_bad_empty.yaml | 2 +- .../td_bad_function_python.yaml | 2 +- .../td_bad_python_deno.yaml | 2 +- .../td_good_container.yaml | 2 +- .../validate-taskdefinition/td_good_deno.yaml | 2 +- .../td_good_function.yaml | 2 +- .../td_good_python.yaml | 2 +- .../00-assert.yaml | 4 +- .../00-install.yaml | 2 +- .../00-assert.yaml | 4 +- .../00-assert.yaml | 4 +- .../non-blocking-deployment/00-assert.yaml | 4 +- .../non-blocking-deployment/00-install.yaml | 4 +- .../non-blocking-deployment/01-assert.yaml | 4 +- .../non-blocking-deployment/01-install.yaml | 4 +- .../00-install.yaml | 2 +- .../01-assert.yaml | 8 +- .../simple-deployment/00-install.yaml | 2 +- .../simple-deployment/01-assert.yaml | 8 +- .../testmetrics/metrics-keda/metric.yaml | 4 +- .../timeout-failure-deployment/00-assert.yaml | 4 +- test/chainsaw/traces/00-assert.yaml | 2 +- 255 files changed, 2903 insertions(+), 2915 deletions(-) rename lifecycle-operator/apis/lifecycle/{v1beta1 => v1}/keptnapp_webhook.go (92%) rename lifecycle-operator/apis/lifecycle/{v1beta1 => v1}/keptnappversion_webhook.go (92%) rename lifecycle-operator/apis/lifecycle/{v1beta1 => v1}/keptntaskdefinition_webhook.go (91%) rename lifecycle-operator/apis/lifecycle/{v1beta1 => v1}/keptntaskdefinition_webhook_test.go (99%) rename lifecycle-operator/apis/lifecycle/{v1 => v1beta1}/keptnapp_conversion_test.go (82%) rename lifecycle-operator/apis/lifecycle/{v1 => v1beta1}/keptnappversion_conversion_test.go (77%) rename test/chainsaw/integration/{api-conversion-v1beta1-to-v1alpha => api-conversion-v1-to-v1alpha}/00-assert.yaml (100%) rename test/chainsaw/integration/{api-conversion-v1beta1-to-v1alpha => api-conversion-v1-to-v1alpha}/00-install.yaml (85%) rename test/chainsaw/integration/{api-conversion-v1alpha-to-v1beta1 => api-conversion-v1-to-v1alpha}/chainsaw-test.yaml (89%) rename test/chainsaw/integration/{api-conversion-v1alpha-to-v1beta1 => api-conversion-v1alpha-to-v1}/00-assert.yaml (85%) rename test/chainsaw/integration/{api-conversion-v1alpha-to-v1beta1 => api-conversion-v1alpha-to-v1}/00-install.yaml (100%) rename test/chainsaw/integration/{api-conversion-v1beta1-to-v1alpha => api-conversion-v1alpha-to-v1}/chainsaw-test.yaml (89%) diff --git a/.github/actions/spelling/expect.txt b/.github/actions/spelling/expect.txt index c194b9ce95..1fe7a2eeb3 100644 --- a/.github/actions/spelling/expect.txt +++ b/.github/actions/spelling/expect.txt @@ -693,3 +693,4 @@ Yash yml YOURNAME yourregistry +apilifecycle diff --git a/.github/scripts/.helm-tests/default/result.yaml b/.github/scripts/.helm-tests/default/result.yaml index 477e4da858..0b6fbd1f54 100644 --- a/.github/scripts/.helm-tests/default/result.yaml +++ b/.github/scripts/.helm-tests/default/result.yaml @@ -233,7 +233,7 @@ spec: type: object type: object served: true - storage: false + storage: true subresources: status: {} - name: v1alpha1 @@ -550,7 +550,7 @@ spec: type: object type: object served: true - storage: true + storage: false subresources: status: {} --- @@ -670,7 +670,7 @@ spec: type: object type: object served: true - storage: false + storage: true subresources: status: {} - name: v1beta1 @@ -763,7 +763,7 @@ spec: type: object type: object served: true - storage: true + storage: false subresources: status: {} --- @@ -830,7 +830,7 @@ spec: type: string type: object served: true - storage: false + storage: true subresources: status: {} - name: v1alpha3 @@ -912,7 +912,7 @@ spec: type: string type: object served: true - storage: true + storage: false subresources: status: {} --- @@ -1342,7 +1342,7 @@ spec: type: object type: object served: true - storage: false + storage: true subresources: status: {} - additionalPrinterColumns: @@ -2575,7 +2575,7 @@ spec: type: object type: object served: true - storage: true + storage: false subresources: status: {} --- @@ -2842,7 +2842,7 @@ spec: type: object type: object served: true - storage: false + storage: true subresources: status: {} - additionalPrinterColumns: @@ -3374,7 +3374,7 @@ spec: type: object type: object served: true - storage: true + storage: false subresources: status: {} --- @@ -3482,7 +3482,7 @@ spec: type: string type: object served: true - storage: false + storage: true subresources: status: {} - name: v1alpha1 @@ -3741,7 +3741,7 @@ spec: type: string type: object served: true - storage: true + storage: false subresources: status: {} --- @@ -3935,7 +3935,7 @@ spec: type: object type: object served: true - storage: false + storage: true subresources: status: {} - additionalPrinterColumns: @@ -4507,7 +4507,7 @@ spec: type: object type: object served: true - storage: true + storage: false subresources: status: {} --- @@ -6090,7 +6090,7 @@ spec: type: object type: object served: true - storage: false + storage: true subresources: status: {} - name: v1alpha1 @@ -9504,7 +9504,7 @@ spec: type: object type: object served: true - storage: true + storage: false subresources: status: {} --- @@ -9646,7 +9646,7 @@ spec: type: object type: object served: true - storage: false + storage: true subresources: status: {} - additionalPrinterColumns: @@ -10044,7 +10044,7 @@ spec: type: object type: object served: true - storage: true + storage: false subresources: status: {} --- @@ -10406,7 +10406,7 @@ spec: type: object type: object served: true - storage: false + storage: true subresources: status: {} - additionalPrinterColumns: @@ -11057,7 +11057,7 @@ spec: type: object type: object served: true - storage: true + storage: false subresources: status: {} --- @@ -15675,14 +15675,14 @@ webhooks: service: name: 'lifecycle-webhook-service' namespace: 'helmtests' - path: /validate-lifecycle-keptn-sh-v1beta1-keptntaskdefinition + path: /validate-lifecycle-keptn-sh-v1-keptntaskdefinition failurePolicy: Fail name: vkeptntaskdefinition.kb.io rules: - apiGroups: - lifecycle.keptn.sh apiVersions: - - v1beta1 + - v1 operations: - CREATE - UPDATE diff --git a/.github/scripts/.helm-tests/lifecycle-only/result.yaml b/.github/scripts/.helm-tests/lifecycle-only/result.yaml index 584d0e3766..e865ee5d09 100644 --- a/.github/scripts/.helm-tests/lifecycle-only/result.yaml +++ b/.github/scripts/.helm-tests/lifecycle-only/result.yaml @@ -179,7 +179,7 @@ spec: type: object type: object served: true - storage: false + storage: true subresources: status: {} - name: v1alpha1 @@ -496,7 +496,7 @@ spec: type: object type: object served: true - storage: true + storage: false subresources: status: {} --- @@ -616,7 +616,7 @@ spec: type: object type: object served: true - storage: false + storage: true subresources: status: {} - name: v1beta1 @@ -709,7 +709,7 @@ spec: type: object type: object served: true - storage: true + storage: false subresources: status: {} --- @@ -776,7 +776,7 @@ spec: type: string type: object served: true - storage: false + storage: true subresources: status: {} - name: v1alpha3 @@ -858,7 +858,7 @@ spec: type: string type: object served: true - storage: true + storage: false subresources: status: {} --- @@ -1288,7 +1288,7 @@ spec: type: object type: object served: true - storage: false + storage: true subresources: status: {} - additionalPrinterColumns: @@ -2521,7 +2521,7 @@ spec: type: object type: object served: true - storage: true + storage: false subresources: status: {} --- @@ -2788,7 +2788,7 @@ spec: type: object type: object served: true - storage: false + storage: true subresources: status: {} - additionalPrinterColumns: @@ -3320,7 +3320,7 @@ spec: type: object type: object served: true - storage: true + storage: false subresources: status: {} --- @@ -3428,7 +3428,7 @@ spec: type: string type: object served: true - storage: false + storage: true subresources: status: {} - name: v1alpha1 @@ -3687,7 +3687,7 @@ spec: type: string type: object served: true - storage: true + storage: false subresources: status: {} --- @@ -3881,7 +3881,7 @@ spec: type: object type: object served: true - storage: false + storage: true subresources: status: {} - additionalPrinterColumns: @@ -4453,7 +4453,7 @@ spec: type: object type: object served: true - storage: true + storage: false subresources: status: {} --- @@ -6036,7 +6036,7 @@ spec: type: object type: object served: true - storage: false + storage: true subresources: status: {} - name: v1alpha1 @@ -9450,7 +9450,7 @@ spec: type: object type: object served: true - storage: true + storage: false subresources: status: {} --- @@ -9592,7 +9592,7 @@ spec: type: object type: object served: true - storage: false + storage: true subresources: status: {} - additionalPrinterColumns: @@ -9990,7 +9990,7 @@ spec: type: object type: object served: true - storage: true + storage: false subresources: status: {} --- @@ -10352,7 +10352,7 @@ spec: type: object type: object served: true - storage: false + storage: true subresources: status: {} - additionalPrinterColumns: @@ -11003,7 +11003,7 @@ spec: type: object type: object served: true - storage: true + storage: false subresources: status: {} --- @@ -12120,14 +12120,14 @@ webhooks: service: name: 'lifecycle-webhook-service' namespace: 'helmtests' - path: /validate-lifecycle-keptn-sh-v1beta1-keptntaskdefinition + path: /validate-lifecycle-keptn-sh-v1-keptntaskdefinition failurePolicy: Fail name: vkeptntaskdefinition.kb.io rules: - apiGroups: - lifecycle.keptn.sh apiVersions: - - v1beta1 + - v1 operations: - CREATE - UPDATE diff --git a/.github/scripts/.helm-tests/lifecycle-with-certs/result.yaml b/.github/scripts/.helm-tests/lifecycle-with-certs/result.yaml index 1e8b426e74..72dbb3af78 100644 --- a/.github/scripts/.helm-tests/lifecycle-with-certs/result.yaml +++ b/.github/scripts/.helm-tests/lifecycle-with-certs/result.yaml @@ -194,7 +194,7 @@ spec: type: object type: object served: true - storage: false + storage: true subresources: status: {} - name: v1alpha1 @@ -511,7 +511,7 @@ spec: type: object type: object served: true - storage: true + storage: false subresources: status: {} --- @@ -631,7 +631,7 @@ spec: type: object type: object served: true - storage: false + storage: true subresources: status: {} - name: v1beta1 @@ -724,7 +724,7 @@ spec: type: object type: object served: true - storage: true + storage: false subresources: status: {} --- @@ -791,7 +791,7 @@ spec: type: string type: object served: true - storage: false + storage: true subresources: status: {} - name: v1alpha3 @@ -873,7 +873,7 @@ spec: type: string type: object served: true - storage: true + storage: false subresources: status: {} --- @@ -1303,7 +1303,7 @@ spec: type: object type: object served: true - storage: false + storage: true subresources: status: {} - additionalPrinterColumns: @@ -2536,7 +2536,7 @@ spec: type: object type: object served: true - storage: true + storage: false subresources: status: {} --- @@ -2803,7 +2803,7 @@ spec: type: object type: object served: true - storage: false + storage: true subresources: status: {} - additionalPrinterColumns: @@ -3335,7 +3335,7 @@ spec: type: object type: object served: true - storage: true + storage: false subresources: status: {} --- @@ -3443,7 +3443,7 @@ spec: type: string type: object served: true - storage: false + storage: true subresources: status: {} - name: v1alpha1 @@ -3702,7 +3702,7 @@ spec: type: string type: object served: true - storage: true + storage: false subresources: status: {} --- @@ -3896,7 +3896,7 @@ spec: type: object type: object served: true - storage: false + storage: true subresources: status: {} - additionalPrinterColumns: @@ -4468,7 +4468,7 @@ spec: type: object type: object served: true - storage: true + storage: false subresources: status: {} --- @@ -6051,7 +6051,7 @@ spec: type: object type: object served: true - storage: false + storage: true subresources: status: {} - name: v1alpha1 @@ -9465,7 +9465,7 @@ spec: type: object type: object served: true - storage: true + storage: false subresources: status: {} --- @@ -9607,7 +9607,7 @@ spec: type: object type: object served: true - storage: false + storage: true subresources: status: {} - additionalPrinterColumns: @@ -10005,7 +10005,7 @@ spec: type: object type: object served: true - storage: true + storage: false subresources: status: {} --- @@ -10367,7 +10367,7 @@ spec: type: object type: object served: true - storage: false + storage: true subresources: status: {} - additionalPrinterColumns: @@ -11018,7 +11018,7 @@ spec: type: object type: object served: true - storage: true + storage: false subresources: status: {} --- @@ -12376,14 +12376,14 @@ webhooks: service: name: 'lifecycle-webhook-service' namespace: 'helmtests' - path: /validate-lifecycle-keptn-sh-v1beta1-keptntaskdefinition + path: /validate-lifecycle-keptn-sh-v1-keptntaskdefinition failurePolicy: Fail name: vkeptntaskdefinition.kb.io rules: - apiGroups: - lifecycle.keptn.sh apiVersions: - - v1beta1 + - v1 operations: - CREATE - UPDATE diff --git a/.github/scripts/.helm-tests/local-global-precedence/result.yaml b/.github/scripts/.helm-tests/local-global-precedence/result.yaml index f3c7a331ee..6bd5caa7cd 100644 --- a/.github/scripts/.helm-tests/local-global-precedence/result.yaml +++ b/.github/scripts/.helm-tests/local-global-precedence/result.yaml @@ -280,7 +280,7 @@ spec: type: object type: object served: true - storage: false + storage: true subresources: status: {} - name: v1alpha1 @@ -597,7 +597,7 @@ spec: type: object type: object served: true - storage: true + storage: false subresources: status: {} --- @@ -722,7 +722,7 @@ spec: type: object type: object served: true - storage: false + storage: true subresources: status: {} - name: v1beta1 @@ -815,7 +815,7 @@ spec: type: object type: object served: true - storage: true + storage: false subresources: status: {} --- @@ -888,7 +888,7 @@ spec: type: string type: object served: true - storage: false + storage: true subresources: status: {} - name: v1alpha3 @@ -970,7 +970,7 @@ spec: type: string type: object served: true - storage: true + storage: false subresources: status: {} --- @@ -1406,7 +1406,7 @@ spec: type: object type: object served: true - storage: false + storage: true subresources: status: {} - additionalPrinterColumns: @@ -2639,7 +2639,7 @@ spec: type: object type: object served: true - storage: true + storage: false subresources: status: {} --- @@ -2918,7 +2918,7 @@ spec: type: object type: object served: true - storage: false + storage: true subresources: status: {} - additionalPrinterColumns: @@ -3450,7 +3450,7 @@ spec: type: object type: object served: true - storage: true + storage: false subresources: status: {} --- @@ -3564,7 +3564,7 @@ spec: type: string type: object served: true - storage: false + storage: true subresources: status: {} - name: v1alpha1 @@ -3823,7 +3823,7 @@ spec: type: string type: object served: true - storage: true + storage: false subresources: status: {} --- @@ -4023,7 +4023,7 @@ spec: type: object type: object served: true - storage: false + storage: true subresources: status: {} - additionalPrinterColumns: @@ -4595,7 +4595,7 @@ spec: type: object type: object served: true - storage: true + storage: false subresources: status: {} --- @@ -6184,7 +6184,7 @@ spec: type: object type: object served: true - storage: false + storage: true subresources: status: {} - name: v1alpha1 @@ -9598,7 +9598,7 @@ spec: type: object type: object served: true - storage: true + storage: false subresources: status: {} --- @@ -9746,7 +9746,7 @@ spec: type: object type: object served: true - storage: false + storage: true subresources: status: {} - additionalPrinterColumns: @@ -10144,7 +10144,7 @@ spec: type: object type: object served: true - storage: true + storage: false subresources: status: {} --- @@ -10512,7 +10512,7 @@ spec: type: object type: object served: true - storage: false + storage: true subresources: status: {} - additionalPrinterColumns: @@ -11163,7 +11163,7 @@ spec: type: object type: object served: true - storage: true + storage: false subresources: status: {} --- @@ -16032,14 +16032,14 @@ webhooks: service: name: 'lifecycle-webhook-service' namespace: 'helmtests' - path: /validate-lifecycle-keptn-sh-v1beta1-keptntaskdefinition + path: /validate-lifecycle-keptn-sh-v1-keptntaskdefinition failurePolicy: Fail name: vkeptntaskdefinition.kb.io rules: - apiGroups: - lifecycle.keptn.sh apiVersions: - - v1beta1 + - v1 operations: - CREATE - UPDATE diff --git a/docs/docs/reference/api-reference/lifecycle/v1/index.md b/docs/docs/reference/api-reference/lifecycle/v1/index.md index 74544713c9..a811581c9b 100644 --- a/docs/docs/reference/api-reference/lifecycle/v1/index.md +++ b/docs/docs/reference/api-reference/lifecycle/v1/index.md @@ -6,7 +6,6 @@ Reference information for lifecycle.keptn.sh/v1 ## Packages - [lifecycle.keptn.sh/v1](#lifecyclekeptnshv1) -- [lifecycle.keptn.sh/v1beta1](#lifecyclekeptnshv1beta1) ## lifecycle.keptn.sh/v1 @@ -37,6 +36,8 @@ Package v1 contains API Schema definitions for the lifecycle v1 API group + + #### AutomountServiceAccountTokenSpec @@ -53,6 +54,20 @@ _Appears in:_ | `type` _boolean_ | || x | | +#### CheckType + +_Underlying type:_ _string_ + + + + + +_Appears in:_ +- [KeptnEvaluationSpec](#keptnevaluationspec) +- [KeptnTaskSpec](#keptntaskspec) + + + #### ConfigMapReference @@ -664,6 +679,8 @@ _Appears in:_ | `endTime` _[Time](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.28/#time-v1-meta)_ | EndTime represents the time at which the KeptnEvaluation finished. || ✓ | | + + #### KeptnMetricReference @@ -681,6 +698,27 @@ _Appears in:_ | `namespace` _string_ | Namespace is the namespace where the referenced KeptnMetric is located. || ✓ | | + + +#### KeptnState + +_Underlying type:_ _string_ + +KeptnState is a string containing current Phase state (Progressing/Succeeded/Failed/Unknown/Pending/Deprecated/Warning) + + + +_Appears in:_ +- [EvaluationStatusItem](#evaluationstatusitem) +- [ItemStatus](#itemstatus) +- [KeptnAppVersionStatus](#keptnappversionstatus) +- [KeptnEvaluationStatus](#keptnevaluationstatus) +- [KeptnTaskStatus](#keptntaskstatus) +- [KeptnWorkloadVersionStatus](#keptnworkloadversionstatus) +- [WorkloadStatus](#workloadstatus) + + + #### KeptnTask @@ -1049,6 +1087,20 @@ _Appears in:_ | `evaluationTarget` _string_ | EvaluationTarget specifies the target value for the references KeptnMetric.
Needs to start with either '<' or '>', followed by the target value (e.g. '<10'). || x | | +#### PhaseTraceID + +_Underlying type:_ _[MapCarrier](https://pkg.go.dev/go.opentelemetry.io/otel/propagation#MapCarrier)_ + + + + + +_Appears in:_ +- [KeptnAppVersionStatus](#keptnappversionstatus) +- [KeptnWorkloadVersionStatus](#keptnworkloadversionstatus) + + + #### ResourceReference @@ -1123,6 +1175,8 @@ _Appears in:_ | `name` _string_ | || x | | + + #### TaskContext @@ -1179,65 +1233,3 @@ _Appears in:_ | `status` _string_ | Status indicates the current status of the KeptnWorkload. |Pending| ✓ | | - -## lifecycle.keptn.sh/v1beta1 - -Package v1beta1 contains API Schema definitions for the lifecycle v1beta1 API group - - - - - -#### CheckType - -_Underlying type:_ _string_ - - - - - -_Appears in:_ -- [KeptnEvaluationSpec](#keptnevaluationspec) -- [KeptnTaskSpec](#keptntaskspec) - - - - - - - -#### KeptnState - -_Underlying type:_ _string_ - -KeptnState is a string containing current Phase state (Progressing/Succeeded/Failed/Unknown/Pending/Deprecated/Warning) - - - -_Appears in:_ -- [EvaluationStatusItem](#evaluationstatusitem) -- [ItemStatus](#itemstatus) -- [KeptnAppVersionStatus](#keptnappversionstatus) -- [KeptnEvaluationStatus](#keptnevaluationstatus) -- [KeptnTaskStatus](#keptntaskstatus) -- [KeptnWorkloadVersionStatus](#keptnworkloadversionstatus) -- [WorkloadStatus](#workloadstatus) - - - -#### PhaseTraceID - -_Underlying type:_ _[MapCarrier](https://pkg.go.dev/go.opentelemetry.io/otel/propagation#MapCarrier)_ - - - - - -_Appears in:_ -- [KeptnAppVersionStatus](#keptnappversionstatus) -- [KeptnWorkloadVersionStatus](#keptnworkloadversionstatus) - - - - - diff --git a/lifecycle-operator/apis/lifecycle/v1/common/common.go b/lifecycle-operator/apis/lifecycle/v1/common/common.go index a8f1080b76..3980bb89b4 100644 --- a/lifecycle-operator/apis/lifecycle/v1/common/common.go +++ b/lifecycle-operator/apis/lifecycle/v1/common/common.go @@ -1,12 +1,11 @@ -// Package v1beta1 contains API Schema definitions for the lifecycle v1beta1 API group +// Package v1 contains API Schema definitions for the lifecycle v1 API group // +groupName=lifecycle.keptn.sh -// +versionName=v1beta1 +// +versionName=v1 package common import ( "crypto/sha256" "encoding/hex" - "errors" "math/rand" "strconv" @@ -42,9 +41,6 @@ const MetadataAnnotation = "keptn.sh/metadata" const MinKeptnNameLen = 80 const MaxK8sObjectLength = 253 -var ErrCannotCastKeptnAppVersion = errors.New("cannot cast KeptnAppVersion to v1beta1") -var ErrCannotCastKeptnApp = errors.New("cannot cast KeptnApp to v1beta1") - type AppType string const ( diff --git a/lifecycle-operator/apis/lifecycle/v1/keptnapp_conversion.go b/lifecycle-operator/apis/lifecycle/v1/keptnapp_conversion.go index aaa58a34ab..d171b15e3d 100644 --- a/lifecycle-operator/apis/lifecycle/v1/keptnapp_conversion.go +++ b/lifecycle-operator/apis/lifecycle/v1/keptnapp_conversion.go @@ -1,63 +1,6 @@ package v1 -import ( - "fmt" - - "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1/common" - "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" - "sigs.k8s.io/controller-runtime/pkg/conversion" -) - -// ConvertTo converts the src v1.KeptnApp to the hub version (v1beta1.KeptnApp) -func (src *KeptnApp) ConvertTo(dstRaw conversion.Hub) error { - dst, ok := dstRaw.(*v1beta1.KeptnApp) - - if !ok { - return fmt.Errorf("type %T %w", dstRaw, common.ErrCannotCastKeptnApp) - } - - // Copy equal stuff to new object - // DO NOT COPY TypeMeta - dst.ObjectMeta = src.ObjectMeta - - dst.Spec.Version = src.Spec.Version - for _, srcWl := range src.Spec.Workloads { - dst.Spec.Workloads = append(dst.Spec.Workloads, v1beta1.KeptnWorkloadRef{ - Name: srcWl.Name, - Version: srcWl.Version, - }) - } - - dst.Status.CurrentVersion = src.Status.CurrentVersion - - dst.Spec.Revision = src.Spec.Revision - - return nil -} - -// ConvertFrom converts from the hub version (v1beta1.KeptnApp) to this version (v1.KeptnApp) -func (dst *KeptnApp) ConvertFrom(srcRaw conversion.Hub) error { - src, ok := srcRaw.(*v1beta1.KeptnApp) - - if !ok { - return fmt.Errorf("type %T %w", srcRaw, common.ErrCannotCastKeptnApp) - } - - // Copy equal stuff to new object - // DO NOT COPY TypeMeta - dst.ObjectMeta = src.ObjectMeta - - dst.Spec.Version = src.Spec.Version - for _, srcWl := range src.Spec.Workloads { - dst.Spec.Workloads = append(dst.Spec.Workloads, KeptnWorkloadRef{ - Name: srcWl.Name, - Version: srcWl.Version, - }) - } - - dst.Status.CurrentVersion = src.Status.CurrentVersion - - dst.Spec.Revision = src.Spec.Revision - - return nil +// Hub is the stub function to make the API conversion pattern with hub and spokes complete +func (*KeptnApp) Hub() { + // Hub() needed to implement interface } diff --git a/lifecycle-operator/apis/lifecycle/v1/keptnapp_types.go b/lifecycle-operator/apis/lifecycle/v1/keptnapp_types.go index 6da457968a..69fc0b0d92 100644 --- a/lifecycle-operator/apis/lifecycle/v1/keptnapp_types.go +++ b/lifecycle-operator/apis/lifecycle/v1/keptnapp_types.go @@ -59,6 +59,7 @@ type KeptnWorkloadRef struct { } // +kubebuilder:object:root=true +// +kubebuilder:storageversion // +kubebuilder:subresource:status // KeptnApp is the Schema for the keptnapps API diff --git a/lifecycle-operator/apis/lifecycle/v1beta1/keptnapp_webhook.go b/lifecycle-operator/apis/lifecycle/v1/keptnapp_webhook.go similarity index 92% rename from lifecycle-operator/apis/lifecycle/v1beta1/keptnapp_webhook.go rename to lifecycle-operator/apis/lifecycle/v1/keptnapp_webhook.go index 5d280f77c8..2ce78979de 100644 --- a/lifecycle-operator/apis/lifecycle/v1beta1/keptnapp_webhook.go +++ b/lifecycle-operator/apis/lifecycle/v1/keptnapp_webhook.go @@ -1,4 +1,4 @@ -package v1beta1 +package v1 import ( ctrl "sigs.k8s.io/controller-runtime" diff --git a/lifecycle-operator/apis/lifecycle/v1/keptnappcontext_types.go b/lifecycle-operator/apis/lifecycle/v1/keptnappcontext_types.go index 6a7a955fcd..5c33ae4678 100644 --- a/lifecycle-operator/apis/lifecycle/v1/keptnappcontext_types.go +++ b/lifecycle-operator/apis/lifecycle/v1/keptnappcontext_types.go @@ -67,6 +67,7 @@ type KeptnAppContextStatus struct { } //+kubebuilder:object:root=true +//+kubebuilder:storageversion //+kubebuilder:subresource:status // KeptnAppContext is the Schema for the keptnappcontexts API diff --git a/lifecycle-operator/apis/lifecycle/v1/keptnappcreationrequest_types.go b/lifecycle-operator/apis/lifecycle/v1/keptnappcreationrequest_types.go index def1d69a1e..d2af9057b3 100644 --- a/lifecycle-operator/apis/lifecycle/v1/keptnappcreationrequest_types.go +++ b/lifecycle-operator/apis/lifecycle/v1/keptnappcreationrequest_types.go @@ -30,6 +30,7 @@ type KeptnAppCreationRequestSpec struct { } // +kubebuilder:object:root=true +// +kubebuilder:storageversion // +kubebuilder:subresource:status // KeptnAppCreationRequest is the Schema for the keptnappcreationrequests API diff --git a/lifecycle-operator/apis/lifecycle/v1/keptnappversion_conversion.go b/lifecycle-operator/apis/lifecycle/v1/keptnappversion_conversion.go index ec60bfcc25..65a8d5999d 100644 --- a/lifecycle-operator/apis/lifecycle/v1/keptnappversion_conversion.go +++ b/lifecycle-operator/apis/lifecycle/v1/keptnappversion_conversion.go @@ -1,259 +1,6 @@ package v1 -import ( - "fmt" - - "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1/common" - "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" - v1beta1common "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" - "go.opentelemetry.io/otel/propagation" - "sigs.k8s.io/controller-runtime/pkg/conversion" -) - -// ConvertTo converts the src v1.KeptnAppVersion to the hub version (v1beta1.KeptnAppVersion) -// -//nolint:gocyclo -func (src *KeptnAppVersion) ConvertTo(dstRaw conversion.Hub) error { - dst, ok := dstRaw.(*v1beta1.KeptnAppVersion) - - if !ok { - return fmt.Errorf("type %T %w", dstRaw, common.ErrCannotCastKeptnAppVersion) - } - - // Copy equal stuff to new object - // DO NOT COPY TypeMeta - dst.ObjectMeta = src.ObjectMeta - - dst.Spec.Version = src.Spec.Version - for _, srcWl := range src.Spec.Workloads { - dst.Spec.Workloads = append(dst.Spec.Workloads, v1beta1.KeptnWorkloadRef{ - Name: srcWl.Name, - Version: srcWl.Version, - }) - } - dst.Spec.PreDeploymentTasks = src.Spec.PreDeploymentTasks - dst.Spec.PostDeploymentTasks = src.Spec.PostDeploymentTasks - dst.Spec.PreDeploymentEvaluations = src.Spec.PreDeploymentEvaluations - dst.Spec.PostDeploymentEvaluations = src.Spec.PostDeploymentEvaluations - dst.Spec.PromotionTasks = src.Spec.PromotionTasks - - dst.Spec.AppName = src.Spec.AppName - dst.Spec.PreviousVersion = src.Spec.PreviousVersion - - dst.Spec.TraceId = make(map[string]string, len(src.Spec.TraceId)) - for k, v := range src.Spec.TraceId { - dst.Spec.TraceId[k] = v - } - - dst.Status.PreDeploymentStatus = v1beta1common.KeptnState(src.Status.PreDeploymentStatus) - dst.Status.PostDeploymentStatus = v1beta1common.KeptnState(src.Status.PostDeploymentStatus) - dst.Status.PreDeploymentEvaluationStatus = v1beta1common.KeptnState(src.Status.PreDeploymentEvaluationStatus) - dst.Status.PostDeploymentEvaluationStatus = v1beta1common.KeptnState(src.Status.PostDeploymentEvaluationStatus) - dst.Status.WorkloadOverallStatus = v1beta1common.KeptnState(src.Status.WorkloadOverallStatus) - dst.Status.PromotionStatus = v1beta1common.KeptnState(src.Status.PromotionStatus) - dst.Status.Status = v1beta1common.KeptnState(src.Status.Status) - - for _, srcWls := range src.Status.WorkloadStatus { - dst.Status.WorkloadStatus = append(dst.Status.WorkloadStatus, v1beta1.WorkloadStatus{ - Workload: v1beta1.KeptnWorkloadRef{ - Name: srcWls.Workload.Name, - Version: srcWls.Workload.Version, - }, - Status: v1beta1common.KeptnState(srcWls.Status), - }) - } - - dst.Status.CurrentPhase = src.Status.CurrentPhase - - // Set sensible defaults for new fields - dst.Spec.Revision = src.Spec.Revision - - // Convert changed fields - for _, item := range src.Status.PreDeploymentTaskStatus { - dst.Status.PreDeploymentTaskStatus = append(dst.Status.PreDeploymentTaskStatus, v1beta1.ItemStatus{ - DefinitionName: item.DefinitionName, - Status: v1beta1common.KeptnState(item.Status), - Name: item.Name, - StartTime: item.StartTime, - EndTime: item.EndTime, - }) - } - - for _, item := range src.Status.PostDeploymentTaskStatus { - dst.Status.PostDeploymentTaskStatus = append(dst.Status.PostDeploymentTaskStatus, v1beta1.ItemStatus{ - DefinitionName: item.DefinitionName, - Status: v1beta1common.KeptnState(item.Status), - Name: item.Name, - StartTime: item.StartTime, - EndTime: item.EndTime, - }) - } - - for _, item := range src.Status.PreDeploymentEvaluationTaskStatus { - dst.Status.PreDeploymentEvaluationTaskStatus = append(dst.Status.PreDeploymentEvaluationTaskStatus, v1beta1.ItemStatus{ - DefinitionName: item.DefinitionName, - Status: v1beta1common.KeptnState(item.Status), - Name: item.Name, - StartTime: item.StartTime, - EndTime: item.EndTime, - }) - } - - for _, item := range src.Status.PostDeploymentEvaluationTaskStatus { - dst.Status.PostDeploymentEvaluationTaskStatus = append(dst.Status.PostDeploymentEvaluationTaskStatus, v1beta1.ItemStatus{ - DefinitionName: item.DefinitionName, - Status: v1beta1common.KeptnState(item.Status), - Name: item.Name, - StartTime: item.StartTime, - EndTime: item.EndTime, - }) - } - - for _, item := range src.Status.PromotionTaskStatus { - dst.Status.PromotionTaskStatus = append(dst.Status.PromotionTaskStatus, v1beta1.ItemStatus{ - DefinitionName: item.DefinitionName, - Status: v1beta1common.KeptnState(item.Status), - Name: item.Name, - StartTime: item.StartTime, - EndTime: item.EndTime, - }) - } - - dst.Status.PhaseTraceIDs = make(v1beta1common.PhaseTraceID, len(src.Status.PhaseTraceIDs)) - for k, v := range src.Status.PhaseTraceIDs { - c := make(propagation.MapCarrier, len(v)) - for k1, v1 := range v { - c[k1] = v1 - } - dst.Status.PhaseTraceIDs[k] = c - } - - dst.Status.StartTime = src.Status.StartTime - dst.Status.EndTime = src.Status.EndTime - - return nil -} - -// ConvertFrom converts from the hub version (v1beta1.KeptnAppVersion) to this version (v1.KeptnAppVersion) -// -//nolint:gocyclo -func (dst *KeptnAppVersion) ConvertFrom(srcRaw conversion.Hub) error { - src, ok := srcRaw.(*v1beta1.KeptnAppVersion) - - if !ok { - return fmt.Errorf("type %T %w", srcRaw, common.ErrCannotCastKeptnAppVersion) - } - - // Copy equal stuff to new object - // DO NOT COPY TypeMeta - dst.ObjectMeta = src.ObjectMeta - - dst.Spec.Version = src.Spec.Version - for _, srcWl := range src.Spec.Workloads { - dst.Spec.Workloads = append(dst.Spec.Workloads, KeptnWorkloadRef{ - Name: srcWl.Name, - Version: srcWl.Version, - }) - } - dst.Spec.PreDeploymentTasks = src.Spec.PreDeploymentTasks - dst.Spec.PostDeploymentTasks = src.Spec.PostDeploymentTasks - dst.Spec.PreDeploymentEvaluations = src.Spec.PreDeploymentEvaluations - dst.Spec.PostDeploymentEvaluations = src.Spec.PostDeploymentEvaluations - dst.Spec.PromotionTasks = src.Spec.PromotionTasks - - dst.Spec.AppName = src.Spec.AppName - dst.Spec.PreviousVersion = src.Spec.PreviousVersion - - // Set sensible defaults for new fields - dst.Spec.Revision = src.Spec.Revision - - dst.Spec.TraceId = make(map[string]string, len(src.Spec.TraceId)) - for k, v := range src.Spec.TraceId { - dst.Spec.TraceId[k] = v - } - - dst.Status.PreDeploymentStatus = common.KeptnState(src.Status.PreDeploymentStatus) - dst.Status.PostDeploymentStatus = common.KeptnState(src.Status.PostDeploymentStatus) - dst.Status.PreDeploymentEvaluationStatus = common.KeptnState(src.Status.PreDeploymentEvaluationStatus) - dst.Status.PostDeploymentEvaluationStatus = common.KeptnState(src.Status.PostDeploymentEvaluationStatus) - dst.Status.WorkloadOverallStatus = common.KeptnState(src.Status.WorkloadOverallStatus) - dst.Status.PromotionStatus = common.KeptnState(src.Status.PromotionStatus) - dst.Status.Status = common.KeptnState(src.Status.Status) - - for _, srcWls := range src.Status.WorkloadStatus { - dst.Status.WorkloadStatus = append(dst.Status.WorkloadStatus, WorkloadStatus{ - Workload: KeptnWorkloadRef{ - Name: srcWls.Workload.Name, - Version: srcWls.Workload.Version, - }, - Status: common.KeptnState(srcWls.Status), - }) - } - - dst.Status.CurrentPhase = src.Status.CurrentPhase - - // Convert changed fields - for _, item := range src.Status.PreDeploymentTaskStatus { - dst.Status.PreDeploymentTaskStatus = append(dst.Status.PreDeploymentTaskStatus, ItemStatus{ - DefinitionName: item.DefinitionName, - Status: common.KeptnState(item.Status), - Name: item.Name, - StartTime: item.StartTime, - EndTime: item.EndTime, - }) - } - - for _, item := range src.Status.PostDeploymentTaskStatus { - dst.Status.PostDeploymentTaskStatus = append(dst.Status.PostDeploymentTaskStatus, ItemStatus{ - DefinitionName: item.DefinitionName, - Status: common.KeptnState(item.Status), - Name: item.Name, - StartTime: item.StartTime, - EndTime: item.EndTime, - }) - } - - for _, item := range src.Status.PreDeploymentEvaluationTaskStatus { - dst.Status.PreDeploymentEvaluationTaskStatus = append(dst.Status.PreDeploymentEvaluationTaskStatus, ItemStatus{ - DefinitionName: item.DefinitionName, - Status: common.KeptnState(item.Status), - Name: item.Name, - StartTime: item.StartTime, - EndTime: item.EndTime, - }) - } - - for _, item := range src.Status.PostDeploymentEvaluationTaskStatus { - dst.Status.PostDeploymentEvaluationTaskStatus = append(dst.Status.PostDeploymentEvaluationTaskStatus, ItemStatus{ - DefinitionName: item.DefinitionName, - Status: common.KeptnState(item.Status), - Name: item.Name, - StartTime: item.StartTime, - EndTime: item.EndTime, - }) - } - - for _, item := range src.Status.PromotionTaskStatus { - dst.Status.PromotionTaskStatus = append(dst.Status.PromotionTaskStatus, ItemStatus{ - DefinitionName: item.DefinitionName, - Status: common.KeptnState(item.Status), - Name: item.Name, - StartTime: item.StartTime, - EndTime: item.EndTime, - }) - } - - dst.Status.PhaseTraceIDs = make(common.PhaseTraceID, len(src.Status.PhaseTraceIDs)) - for k, v := range src.Status.PhaseTraceIDs { - c := make(propagation.MapCarrier, len(v)) - for k1, v1 := range v { - c[k1] = v1 - } - dst.Status.PhaseTraceIDs[k] = c - } - - dst.Status.StartTime = src.Status.StartTime - dst.Status.EndTime = src.Status.EndTime - - return nil +// Hub is the stub function to make the API conversion pattern with hub and spokes complete +func (*KeptnAppVersion) Hub() { + // Hub() needed to implement interface } diff --git a/lifecycle-operator/apis/lifecycle/v1/keptnappversion_types.go b/lifecycle-operator/apis/lifecycle/v1/keptnappversion_types.go index 5c772bdd4b..724d51b945 100644 --- a/lifecycle-operator/apis/lifecycle/v1/keptnappversion_types.go +++ b/lifecycle-operator/apis/lifecycle/v1/keptnappversion_types.go @@ -116,6 +116,7 @@ type WorkloadStatus struct { } // +kubebuilder:object:root=true +// +kubebuilder:storageversion // +kubebuilder:resource:path=keptnappversions,shortName=kav // +kubebuilder:subresource:status // +kubebuilder:printcolumn:name="AppName",type=string,JSONPath=`.spec.appName` diff --git a/lifecycle-operator/apis/lifecycle/v1beta1/keptnappversion_webhook.go b/lifecycle-operator/apis/lifecycle/v1/keptnappversion_webhook.go similarity index 92% rename from lifecycle-operator/apis/lifecycle/v1beta1/keptnappversion_webhook.go rename to lifecycle-operator/apis/lifecycle/v1/keptnappversion_webhook.go index 48387d9612..93fd96cd6d 100644 --- a/lifecycle-operator/apis/lifecycle/v1beta1/keptnappversion_webhook.go +++ b/lifecycle-operator/apis/lifecycle/v1/keptnappversion_webhook.go @@ -1,4 +1,4 @@ -package v1beta1 +package v1 import ( ctrl "sigs.k8s.io/controller-runtime" diff --git a/lifecycle-operator/apis/lifecycle/v1/keptnevaluation_types.go b/lifecycle-operator/apis/lifecycle/v1/keptnevaluation_types.go index b9dac49e96..adaa7d5df7 100644 --- a/lifecycle-operator/apis/lifecycle/v1/keptnevaluation_types.go +++ b/lifecycle-operator/apis/lifecycle/v1/keptnevaluation_types.go @@ -87,6 +87,7 @@ type EvaluationStatusItem struct { } // +kubebuilder:object:root=true +// +kubebuilder:storageversion // +kubebuilder:subresource:status // +kubebuilder:resource:path=keptnevaluations,shortName=ke // +kubebuilder:printcolumn:name="AppName",type=string,JSONPath=`.spec.appName` diff --git a/lifecycle-operator/apis/lifecycle/v1/keptnevaluationdefinition_types.go b/lifecycle-operator/apis/lifecycle/v1/keptnevaluationdefinition_types.go index 1b82fe6745..93bf69492f 100644 --- a/lifecycle-operator/apis/lifecycle/v1/keptnevaluationdefinition_types.go +++ b/lifecycle-operator/apis/lifecycle/v1/keptnevaluationdefinition_types.go @@ -64,6 +64,7 @@ type KeptnMetricReference struct { } // +kubebuilder:object:root=true +// +kubebuilder:storageversion // +kubebuilder:subresource:status // +kubebuilder:resource:path=keptnevaluationdefinitions,shortName=ked diff --git a/lifecycle-operator/apis/lifecycle/v1/keptntask_types.go b/lifecycle-operator/apis/lifecycle/v1/keptntask_types.go index 5677f3535b..18d9363b18 100644 --- a/lifecycle-operator/apis/lifecycle/v1/keptntask_types.go +++ b/lifecycle-operator/apis/lifecycle/v1/keptntask_types.go @@ -128,6 +128,7 @@ type KeptnTaskStatus struct { } // +kubebuilder:object:root=true +// +kubebuilder:storageversion // +kubebuilder:subresource:status // +kubebuilder:printcolumn:name="AppName",type=string,JSONPath=`.spec.app` // +kubebuilder:printcolumn:name="AppVersion",type=string,JSONPath=`.spec.appVersion` diff --git a/lifecycle-operator/apis/lifecycle/v1/keptntaskdefinition_types.go b/lifecycle-operator/apis/lifecycle/v1/keptntaskdefinition_types.go index fe73402ce8..4c1b17ca00 100644 --- a/lifecycle-operator/apis/lifecycle/v1/keptntaskdefinition_types.go +++ b/lifecycle-operator/apis/lifecycle/v1/keptntaskdefinition_types.go @@ -141,6 +141,7 @@ type FunctionStatus struct { } // +kubebuilder:object:root=true +// +kubebuilder:storageversion // +kubebuilder:subresource:status // KeptnTaskDefinition is the Schema for the keptntaskdefinitions API diff --git a/lifecycle-operator/apis/lifecycle/v1beta1/keptntaskdefinition_webhook.go b/lifecycle-operator/apis/lifecycle/v1/keptntaskdefinition_webhook.go similarity index 91% rename from lifecycle-operator/apis/lifecycle/v1beta1/keptntaskdefinition_webhook.go rename to lifecycle-operator/apis/lifecycle/v1/keptntaskdefinition_webhook.go index 5cc502cf12..0ac58b1ed0 100644 --- a/lifecycle-operator/apis/lifecycle/v1beta1/keptntaskdefinition_webhook.go +++ b/lifecycle-operator/apis/lifecycle/v1/keptntaskdefinition_webhook.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v1beta1 +package v1 import ( "github.com/pkg/errors" @@ -37,7 +37,7 @@ func (r *KeptnTaskDefinition) SetupWebhookWithManager(mgr ctrl.Manager) error { Complete() } -//+kubebuilder:webhook:path=/validate-lifecycle-keptn-sh-v1beta1-keptntaskdefinition,mutating=false,failurePolicy=fail,sideEffects=None,groups=lifecycle.keptn.sh,resources=keptntaskdefinitions,verbs=create;update,versions=v1beta1,name=vkeptntaskdefinition.kb.io,admissionReviewVersions=v1 +//+kubebuilder:webhook:path=/validate-lifecycle-keptn-sh-v1-keptntaskdefinition,mutating=false,failurePolicy=fail,sideEffects=None,groups=lifecycle.keptn.sh,resources=keptntaskdefinitions,verbs=create;update,versions=v1,name=vkeptntaskdefinition.kb.io,admissionReviewVersions=v1 var _ webhook.Validator = &KeptnTaskDefinition{} diff --git a/lifecycle-operator/apis/lifecycle/v1beta1/keptntaskdefinition_webhook_test.go b/lifecycle-operator/apis/lifecycle/v1/keptntaskdefinition_webhook_test.go similarity index 99% rename from lifecycle-operator/apis/lifecycle/v1beta1/keptntaskdefinition_webhook_test.go rename to lifecycle-operator/apis/lifecycle/v1/keptntaskdefinition_webhook_test.go index 4cd2a647b4..80f1d5f98e 100644 --- a/lifecycle-operator/apis/lifecycle/v1beta1/keptntaskdefinition_webhook_test.go +++ b/lifecycle-operator/apis/lifecycle/v1/keptntaskdefinition_webhook_test.go @@ -1,4 +1,4 @@ -package v1beta1 +package v1 import ( "testing" diff --git a/lifecycle-operator/apis/lifecycle/v1/keptnworkload_types.go b/lifecycle-operator/apis/lifecycle/v1/keptnworkload_types.go index 91711acff5..b8a5275afd 100644 --- a/lifecycle-operator/apis/lifecycle/v1/keptnworkload_types.go +++ b/lifecycle-operator/apis/lifecycle/v1/keptnworkload_types.go @@ -72,6 +72,7 @@ type KeptnWorkloadStatus struct { // +kubebuilder:object:root=true // +kubebuilder:subresource:status +// +kubebuilder:storageversion // +kubebuilder:printcolumn:name="AppName",type=string,JSONPath=`.spec.app` // +kubebuilder:printcolumn:name="Version",type=string,JSONPath=`.spec.version` diff --git a/lifecycle-operator/apis/lifecycle/v1/keptnworkloadversion_types.go b/lifecycle-operator/apis/lifecycle/v1/keptnworkloadversion_types.go index a25b37e23e..a34671acb2 100644 --- a/lifecycle-operator/apis/lifecycle/v1/keptnworkloadversion_types.go +++ b/lifecycle-operator/apis/lifecycle/v1/keptnworkloadversion_types.go @@ -124,6 +124,7 @@ type KeptnWorkloadVersionStatus struct { // +kubebuilder:object:root=true // +kubebuilder:resource:path=keptnworkloadversions,shortName=kwv +// +kubebuilder:storageversion // +kubebuilder:subresource:status // +kubebuilder:printcolumn:name="AppName",type=string,JSONPath=`.spec.app` // +kubebuilder:printcolumn:name="WorkloadName",type=string,JSONPath=`.spec.workloadName` diff --git a/lifecycle-operator/apis/lifecycle/v1/zz_generated.deepcopy.go b/lifecycle-operator/apis/lifecycle/v1/zz_generated.deepcopy.go index f23484d059..2d2a6aa2f8 100644 --- a/lifecycle-operator/apis/lifecycle/v1/zz_generated.deepcopy.go +++ b/lifecycle-operator/apis/lifecycle/v1/zz_generated.deepcopy.go @@ -24,7 +24,7 @@ import ( "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1/common" "go.opentelemetry.io/otel/propagation" corev1 "k8s.io/api/core/v1" - runtime "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime" ) // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. diff --git a/lifecycle-operator/apis/lifecycle/v1alpha1/common/common.go b/lifecycle-operator/apis/lifecycle/v1alpha1/common/common.go index ba60eee39d..6dc05c4e48 100644 --- a/lifecycle-operator/apis/lifecycle/v1alpha1/common/common.go +++ b/lifecycle-operator/apis/lifecycle/v1alpha1/common/common.go @@ -35,10 +35,8 @@ const MaxWorkloadNameLength = 25 const MaxTaskNameLength = 25 const MaxVersionLength = 12 -var ErrCannotCastKeptnEvaluationProvider = errors.New("cannot cast KeptnEvaluationDefinition to v1beta1") -var ErrCannotCastKeptnAppVersion = errors.New("cannot cast KeptnAppVersion to v1beta1") -var ErrCannotCastKeptnApp = errors.New("cannot cast KeptnApp to v1beta1") -var ErrCannotCastKeptnWorkloadInstance = errors.New("cannot cast KeptnWorkloadInstance to v1beta1") +var ErrCannotCastKeptnAppVersion = errors.New("cannot cast KeptnAppVersion to v1") +var ErrCannotCastKeptnApp = errors.New("cannot cast KeptnApp to v1") // KeptnState is a string containing current Phase state (Progressing/Succeeded/Failed/Unknown/Pending/Cancelled) type KeptnState string diff --git a/lifecycle-operator/apis/lifecycle/v1alpha1/keptnapp_conversion.go b/lifecycle-operator/apis/lifecycle/v1alpha1/keptnapp_conversion.go index b71f9f8470..5fe1ddc256 100644 --- a/lifecycle-operator/apis/lifecycle/v1alpha1/keptnapp_conversion.go +++ b/lifecycle-operator/apis/lifecycle/v1alpha1/keptnapp_conversion.go @@ -3,14 +3,14 @@ package v1alpha1 import ( "fmt" + v1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha1/common" - "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" "sigs.k8s.io/controller-runtime/pkg/conversion" ) -// ConvertTo converts the src v1alpha1.KeptnApp to the hub version (v1beta1.KeptnApp) +// ConvertTo converts the src v1alpha1.KeptnApp to the hub version (v1.KeptnApp) func (src *KeptnApp) ConvertTo(dstRaw conversion.Hub) error { - dst, ok := dstRaw.(*v1beta1.KeptnApp) + dst, ok := dstRaw.(*v1.KeptnApp) if !ok { return fmt.Errorf("type %T %w", dstRaw, common.ErrCannotCastKeptnApp) @@ -22,7 +22,7 @@ func (src *KeptnApp) ConvertTo(dstRaw conversion.Hub) error { dst.Spec.Version = src.Spec.Version for _, srcWl := range src.Spec.Workloads { - dst.Spec.Workloads = append(dst.Spec.Workloads, v1beta1.KeptnWorkloadRef{ + dst.Spec.Workloads = append(dst.Spec.Workloads, v1.KeptnWorkloadRef{ Name: srcWl.Name, Version: srcWl.Version, }) @@ -36,9 +36,9 @@ func (src *KeptnApp) ConvertTo(dstRaw conversion.Hub) error { return nil } -// ConvertFrom converts from the hub version (v1beta1.KeptnApp) to this version (v1alpha1.KeptnApp) +// ConvertFrom converts from the hub version (v1.KeptnApp) to this version (v1alpha1.KeptnApp) func (dst *KeptnApp) ConvertFrom(srcRaw conversion.Hub) error { - src, ok := srcRaw.(*v1beta1.KeptnApp) + src, ok := srcRaw.(*v1.KeptnApp) if !ok { return fmt.Errorf("type %T %w", srcRaw, common.ErrCannotCastKeptnApp) diff --git a/lifecycle-operator/apis/lifecycle/v1alpha1/keptnapp_conversion_test.go b/lifecycle-operator/apis/lifecycle/v1alpha1/keptnapp_conversion_test.go index 5a31de0254..aefc3ee6da 100644 --- a/lifecycle-operator/apis/lifecycle/v1alpha1/keptnapp_conversion_test.go +++ b/lifecycle-operator/apis/lifecycle/v1alpha1/keptnapp_conversion_test.go @@ -3,28 +3,28 @@ package v1alpha1 import ( "testing" + v1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha1/common" - "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" "github.com/stretchr/testify/require" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" v2 "sigs.k8s.io/controller-runtime/pkg/webhook/conversion/testdata/api/v2" ) func TestKeptnApp_ConvertFrom(t *testing.T) { tests := []struct { name string - srcObj *v1beta1.KeptnApp + srcObj *v1.KeptnApp wantErr bool wantObj *KeptnApp }{ { - name: "Test that conversion from v1beta1 to v1alpha1 works", - srcObj: &v1beta1.KeptnApp{ - TypeMeta: v1.TypeMeta{ + name: "Test that conversion from v1 to v1alpha1 works", + srcObj: &v1.KeptnApp{ + TypeMeta: metav1.TypeMeta{ Kind: "KeptnApp", - APIVersion: "lifecycle.keptn.sh/v1beta1", + APIVersion: "lifecycle.keptn.sh/v1", }, - ObjectMeta: v1.ObjectMeta{ + ObjectMeta: metav1.ObjectMeta{ Name: "some-keptn-app-name", Namespace: "", Labels: map[string]string{ @@ -34,10 +34,10 @@ func TestKeptnApp_ConvertFrom(t *testing.T) { "some-annotation": "some-annotation-value", }, }, - Spec: v1beta1.KeptnAppSpec{ + Spec: v1.KeptnAppSpec{ Version: "1.2.3", Revision: 1, - Workloads: []v1beta1.KeptnWorkloadRef{ + Workloads: []v1.KeptnWorkloadRef{ { Name: "workload-1", Version: "1.2.3", @@ -48,13 +48,13 @@ func TestKeptnApp_ConvertFrom(t *testing.T) { }, }, }, - Status: v1beta1.KeptnAppStatus{ + Status: v1.KeptnAppStatus{ CurrentVersion: "1.2.3", }, }, wantErr: false, wantObj: &KeptnApp{ - ObjectMeta: v1.ObjectMeta{ + ObjectMeta: metav1.ObjectMeta{ Name: "some-keptn-app-name", Namespace: "", Labels: map[string]string{ @@ -86,8 +86,8 @@ func TestKeptnApp_ConvertFrom(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { dst := &KeptnApp{ - TypeMeta: v1.TypeMeta{}, - ObjectMeta: v1.ObjectMeta{}, + TypeMeta: metav1.TypeMeta{}, + ObjectMeta: metav1.ObjectMeta{}, Spec: KeptnAppSpec{}, Status: KeptnAppStatus{}, } @@ -106,16 +106,16 @@ func TestKeptnApp_ConvertTo(t *testing.T) { name string src *KeptnApp wantErr bool - wantObj *v1beta1.KeptnApp + wantObj *v1.KeptnApp }{ { - name: "Test that conversion from v1alpha1 to v1beta1 works", + name: "Test that conversion from v1alpha1 to v1 works", src: &KeptnApp{ - TypeMeta: v1.TypeMeta{ + TypeMeta: metav1.TypeMeta{ Kind: "KeptnApp", APIVersion: "lifecycle.keptn.sh/v1alpha1", }, - ObjectMeta: v1.ObjectMeta{ + ObjectMeta: metav1.ObjectMeta{ Name: "some-keptn-app-name", Namespace: "", Labels: map[string]string{ @@ -143,8 +143,8 @@ func TestKeptnApp_ConvertTo(t *testing.T) { }, }, wantErr: false, - wantObj: &v1beta1.KeptnApp{ - ObjectMeta: v1.ObjectMeta{ + wantObj: &v1.KeptnApp{ + ObjectMeta: metav1.ObjectMeta{ Name: "some-keptn-app-name", Namespace: "", Labels: map[string]string{ @@ -154,10 +154,10 @@ func TestKeptnApp_ConvertTo(t *testing.T) { "some-annotation": "some-annotation-value", }, }, - Spec: v1beta1.KeptnAppSpec{ + Spec: v1.KeptnAppSpec{ Version: "1.2.3", Revision: 1, - Workloads: []v1beta1.KeptnWorkloadRef{ + Workloads: []v1.KeptnWorkloadRef{ { Name: "workload-1", Version: "1.2.3", @@ -168,7 +168,7 @@ func TestKeptnApp_ConvertTo(t *testing.T) { }, }, }, - Status: v1beta1.KeptnAppStatus{ + Status: v1.KeptnAppStatus{ CurrentVersion: "1.2.3", }, }, @@ -176,11 +176,11 @@ func TestKeptnApp_ConvertTo(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - dst := v1beta1.KeptnApp{ - TypeMeta: v1.TypeMeta{}, - ObjectMeta: v1.ObjectMeta{}, - Spec: v1beta1.KeptnAppSpec{}, - Status: v1beta1.KeptnAppStatus{}, + dst := v1.KeptnApp{ + TypeMeta: metav1.TypeMeta{}, + ObjectMeta: metav1.ObjectMeta{}, + Spec: v1.KeptnAppSpec{}, + Status: v1.KeptnAppStatus{}, } if err := tt.src.ConvertTo(&dst); (err != nil) != tt.wantErr { t.Errorf("ConvertTo() error = %v, wantErr %v", err, tt.wantErr) @@ -197,8 +197,8 @@ func TestKeptnApp_ConvertFrom_Errorcase(t *testing.T) { testObj := v2.ExternalJob{} dst := &KeptnApp{ - TypeMeta: v1.TypeMeta{}, - ObjectMeta: v1.ObjectMeta{}, + TypeMeta: metav1.TypeMeta{}, + ObjectMeta: metav1.ObjectMeta{}, Spec: KeptnAppSpec{}, Status: KeptnAppStatus{}, } diff --git a/lifecycle-operator/apis/lifecycle/v1alpha1/keptnappversion_conversion.go b/lifecycle-operator/apis/lifecycle/v1alpha1/keptnappversion_conversion.go index 1bfaeb025a..8bbea4d046 100644 --- a/lifecycle-operator/apis/lifecycle/v1alpha1/keptnappversion_conversion.go +++ b/lifecycle-operator/apis/lifecycle/v1alpha1/keptnappversion_conversion.go @@ -3,18 +3,18 @@ package v1alpha1 import ( "fmt" + v1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1" + v1common "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1/common" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha1/common" - "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" - v1beta1common "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" "go.opentelemetry.io/otel/propagation" "sigs.k8s.io/controller-runtime/pkg/conversion" ) -// ConvertTo converts the src v1alpha1.KeptnAppVersion to the hub version (v1beta1.KeptnAppVersion) +// ConvertTo converts the src v1alpha1.KeptnAppVersion to the hub version (v1.KeptnAppVersion) // //nolint:gocyclo func (src *KeptnAppVersion) ConvertTo(dstRaw conversion.Hub) error { - dst, ok := dstRaw.(*v1beta1.KeptnAppVersion) + dst, ok := dstRaw.(*v1.KeptnAppVersion) if !ok { return fmt.Errorf("type %T %w", dstRaw, common.ErrCannotCastKeptnAppVersion) @@ -26,7 +26,7 @@ func (src *KeptnAppVersion) ConvertTo(dstRaw conversion.Hub) error { dst.Spec.Version = src.Spec.Version for _, srcWl := range src.Spec.Workloads { - dst.Spec.Workloads = append(dst.Spec.Workloads, v1beta1.KeptnWorkloadRef{ + dst.Spec.Workloads = append(dst.Spec.Workloads, v1.KeptnWorkloadRef{ Name: srcWl.Name, Version: srcWl.Version, }) @@ -44,20 +44,20 @@ func (src *KeptnAppVersion) ConvertTo(dstRaw conversion.Hub) error { dst.Spec.TraceId[k] = v } - dst.Status.PreDeploymentStatus = v1beta1common.KeptnState(src.Status.PreDeploymentStatus) - dst.Status.PostDeploymentStatus = v1beta1common.KeptnState(src.Status.PostDeploymentStatus) - dst.Status.PreDeploymentEvaluationStatus = v1beta1common.KeptnState(src.Status.PreDeploymentEvaluationStatus) - dst.Status.PostDeploymentEvaluationStatus = v1beta1common.KeptnState(src.Status.PostDeploymentEvaluationStatus) - dst.Status.WorkloadOverallStatus = v1beta1common.KeptnState(src.Status.WorkloadOverallStatus) - dst.Status.Status = v1beta1common.KeptnState(src.Status.Status) + dst.Status.PreDeploymentStatus = v1common.KeptnState(src.Status.PreDeploymentStatus) + dst.Status.PostDeploymentStatus = v1common.KeptnState(src.Status.PostDeploymentStatus) + dst.Status.PreDeploymentEvaluationStatus = v1common.KeptnState(src.Status.PreDeploymentEvaluationStatus) + dst.Status.PostDeploymentEvaluationStatus = v1common.KeptnState(src.Status.PostDeploymentEvaluationStatus) + dst.Status.WorkloadOverallStatus = v1common.KeptnState(src.Status.WorkloadOverallStatus) + dst.Status.Status = v1common.KeptnState(src.Status.Status) for _, srcWls := range src.Status.WorkloadStatus { - dst.Status.WorkloadStatus = append(dst.Status.WorkloadStatus, v1beta1.WorkloadStatus{ - Workload: v1beta1.KeptnWorkloadRef{ + dst.Status.WorkloadStatus = append(dst.Status.WorkloadStatus, v1.WorkloadStatus{ + Workload: v1.KeptnWorkloadRef{ Name: srcWls.Workload.Name, Version: srcWls.Workload.Version, }, - Status: v1beta1common.KeptnState(srcWls.Status), + Status: v1common.KeptnState(srcWls.Status), }) } @@ -68,9 +68,9 @@ func (src *KeptnAppVersion) ConvertTo(dstRaw conversion.Hub) error { // Convert changed fields for _, item := range src.Status.PreDeploymentTaskStatus { - dst.Status.PreDeploymentTaskStatus = append(dst.Status.PreDeploymentTaskStatus, v1beta1.ItemStatus{ + dst.Status.PreDeploymentTaskStatus = append(dst.Status.PreDeploymentTaskStatus, v1.ItemStatus{ DefinitionName: item.TaskDefinitionName, - Status: v1beta1common.KeptnState(item.Status), + Status: v1common.KeptnState(item.Status), Name: item.TaskName, StartTime: item.StartTime, EndTime: item.EndTime, @@ -78,9 +78,9 @@ func (src *KeptnAppVersion) ConvertTo(dstRaw conversion.Hub) error { } for _, item := range src.Status.PostDeploymentTaskStatus { - dst.Status.PostDeploymentTaskStatus = append(dst.Status.PostDeploymentTaskStatus, v1beta1.ItemStatus{ + dst.Status.PostDeploymentTaskStatus = append(dst.Status.PostDeploymentTaskStatus, v1.ItemStatus{ DefinitionName: item.TaskDefinitionName, - Status: v1beta1common.KeptnState(item.Status), + Status: v1common.KeptnState(item.Status), Name: item.TaskName, StartTime: item.StartTime, EndTime: item.EndTime, @@ -88,9 +88,9 @@ func (src *KeptnAppVersion) ConvertTo(dstRaw conversion.Hub) error { } for _, item := range src.Status.PreDeploymentEvaluationTaskStatus { - dst.Status.PreDeploymentEvaluationTaskStatus = append(dst.Status.PreDeploymentEvaluationTaskStatus, v1beta1.ItemStatus{ + dst.Status.PreDeploymentEvaluationTaskStatus = append(dst.Status.PreDeploymentEvaluationTaskStatus, v1.ItemStatus{ DefinitionName: item.EvaluationDefinitionName, - Status: v1beta1common.KeptnState(item.Status), + Status: v1common.KeptnState(item.Status), Name: item.EvaluationName, StartTime: item.StartTime, EndTime: item.EndTime, @@ -98,16 +98,16 @@ func (src *KeptnAppVersion) ConvertTo(dstRaw conversion.Hub) error { } for _, item := range src.Status.PostDeploymentEvaluationTaskStatus { - dst.Status.PostDeploymentEvaluationTaskStatus = append(dst.Status.PostDeploymentEvaluationTaskStatus, v1beta1.ItemStatus{ + dst.Status.PostDeploymentEvaluationTaskStatus = append(dst.Status.PostDeploymentEvaluationTaskStatus, v1.ItemStatus{ DefinitionName: item.EvaluationDefinitionName, - Status: v1beta1common.KeptnState(item.Status), + Status: v1common.KeptnState(item.Status), Name: item.EvaluationName, StartTime: item.StartTime, EndTime: item.EndTime, }) } - dst.Status.PhaseTraceIDs = make(v1beta1common.PhaseTraceID, len(src.Status.PhaseTraceIDs)) + dst.Status.PhaseTraceIDs = make(v1common.PhaseTraceID, len(src.Status.PhaseTraceIDs)) for k, v := range src.Status.PhaseTraceIDs { c := make(propagation.MapCarrier, len(v)) for k1, v1 := range v { @@ -122,11 +122,11 @@ func (src *KeptnAppVersion) ConvertTo(dstRaw conversion.Hub) error { return nil } -// ConvertFrom converts from the hub version (v1beta1.KeptnAppVersion) to this version (v1alpha1.KeptnAppVersion) +// ConvertFrom converts from the hub version (v1.KeptnAppVersion) to this version (v1alpha1.KeptnAppVersion) // //nolint:gocyclo func (dst *KeptnAppVersion) ConvertFrom(srcRaw conversion.Hub) error { - src, ok := srcRaw.(*v1beta1.KeptnAppVersion) + src, ok := srcRaw.(*v1.KeptnAppVersion) if !ok { return fmt.Errorf("type %T %w", srcRaw, common.ErrCannotCastKeptnAppVersion) diff --git a/lifecycle-operator/apis/lifecycle/v1alpha1/keptnappversion_conversion_test.go b/lifecycle-operator/apis/lifecycle/v1alpha1/keptnappversion_conversion_test.go index bcdff0b162..7e05f07f37 100644 --- a/lifecycle-operator/apis/lifecycle/v1alpha1/keptnappversion_conversion_test.go +++ b/lifecycle-operator/apis/lifecycle/v1alpha1/keptnappversion_conversion_test.go @@ -4,30 +4,30 @@ package v1alpha1 import ( "testing" + v1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1" + v1common "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1/common" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha1/common" - "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" - v1beta1common "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" "github.com/stretchr/testify/require" "go.opentelemetry.io/otel/propagation" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" v2 "sigs.k8s.io/controller-runtime/pkg/webhook/conversion/testdata/api/v2" ) func TestKeptnAppVersion_ConvertFrom(t *testing.T) { tests := []struct { name string - srcObj *v1beta1.KeptnAppVersion + srcObj *v1.KeptnAppVersion wantErr bool wantObj *KeptnAppVersion }{ { - name: "Test that conversion from v1beta1 to v1alpha1 works", - srcObj: &v1beta1.KeptnAppVersion{ - TypeMeta: v1.TypeMeta{ + name: "Test that conversion from v1 to v1alpha1 works", + srcObj: &v1.KeptnAppVersion{ + TypeMeta: metav1.TypeMeta{ Kind: "KeptnAppVersion", - APIVersion: "lifecycle.keptn.sh/v1beta1", + APIVersion: "lifecycle.keptn.sh/v1", }, - ObjectMeta: v1.ObjectMeta{ + ObjectMeta: metav1.ObjectMeta{ Name: "some-keptn-app-name", Namespace: "", Labels: map[string]string{ @@ -37,11 +37,11 @@ func TestKeptnAppVersion_ConvertFrom(t *testing.T) { "some-annotation": "some-annotation-value", }, }, - Spec: v1beta1.KeptnAppVersionSpec{ - KeptnAppSpec: v1beta1.KeptnAppSpec{ + Spec: v1.KeptnAppVersionSpec{ + KeptnAppSpec: v1.KeptnAppSpec{ Version: "1.2.3", Revision: 1, - Workloads: []v1beta1.KeptnWorkloadRef{ + Workloads: []v1.KeptnWorkloadRef{ { Name: "workload-1", Version: "1.2.3", @@ -52,8 +52,8 @@ func TestKeptnAppVersion_ConvertFrom(t *testing.T) { }, }, }, - KeptnAppContextSpec: v1beta1.KeptnAppContextSpec{ - DeploymentTaskSpec: v1beta1.DeploymentTaskSpec{ + KeptnAppContextSpec: v1.KeptnAppContextSpec{ + DeploymentTaskSpec: v1.DeploymentTaskSpec{ PreDeploymentTasks: []string{ "some-pre-deployment-task1", }, @@ -75,78 +75,78 @@ func TestKeptnAppVersion_ConvertFrom(t *testing.T) { "key2": "value2", }, }, - Status: v1beta1.KeptnAppVersionStatus{ - PreDeploymentStatus: v1beta1common.StateFailed, - PostDeploymentStatus: v1beta1common.StateFailed, - PreDeploymentEvaluationStatus: v1beta1common.StateFailed, - PostDeploymentEvaluationStatus: v1beta1common.StateFailed, - WorkloadOverallStatus: v1beta1common.StateFailed, - WorkloadStatus: []v1beta1.WorkloadStatus{ - { - Workload: v1beta1.KeptnWorkloadRef{ + Status: v1.KeptnAppVersionStatus{ + PreDeploymentStatus: v1common.StateFailed, + PostDeploymentStatus: v1common.StateFailed, + PreDeploymentEvaluationStatus: v1common.StateFailed, + PostDeploymentEvaluationStatus: v1common.StateFailed, + WorkloadOverallStatus: v1common.StateFailed, + WorkloadStatus: []v1.WorkloadStatus{ + { + Workload: v1.KeptnWorkloadRef{ Name: "name1", Version: "1", }, - Status: v1beta1common.StateFailed, + Status: v1common.StateFailed, }, { - Workload: v1beta1.KeptnWorkloadRef{ + Workload: v1.KeptnWorkloadRef{ Name: "name2", Version: "2", }, - Status: v1beta1common.StateFailed, + Status: v1common.StateFailed, }, }, CurrentPhase: "phase", - PreDeploymentTaskStatus: []v1beta1.ItemStatus{ + PreDeploymentTaskStatus: []v1.ItemStatus{ { DefinitionName: "def1", Name: "name1", - Status: v1beta1common.StateFailed, + Status: v1common.StateFailed, }, { DefinitionName: "def12", Name: "name12", - Status: v1beta1common.StateFailed, + Status: v1common.StateFailed, }, }, - PostDeploymentTaskStatus: []v1beta1.ItemStatus{ + PostDeploymentTaskStatus: []v1.ItemStatus{ { DefinitionName: "def2", Name: "name2", - Status: v1beta1common.StateFailed, + Status: v1common.StateFailed, }, { DefinitionName: "def22", Name: "name22", - Status: v1beta1common.StateFailed, + Status: v1common.StateFailed, }, }, - PreDeploymentEvaluationTaskStatus: []v1beta1.ItemStatus{ + PreDeploymentEvaluationTaskStatus: []v1.ItemStatus{ { DefinitionName: "def3", Name: "name3", - Status: v1beta1common.StateFailed, + Status: v1common.StateFailed, }, { DefinitionName: "def32", Name: "name32", - Status: v1beta1common.StateFailed, + Status: v1common.StateFailed, }, }, - PostDeploymentEvaluationTaskStatus: []v1beta1.ItemStatus{ + PostDeploymentEvaluationTaskStatus: []v1.ItemStatus{ { DefinitionName: "def4", Name: "name4", - Status: v1beta1common.StateFailed, + Status: v1common.StateFailed, }, { DefinitionName: "def42", Name: "name42", - Status: v1beta1common.StateFailed, + Status: v1common.StateFailed, }, }, - PhaseTraceIDs: v1beta1common.PhaseTraceID{ + PhaseTraceIDs: v1common.PhaseTraceID{ "key": propagation.MapCarrier{ "key1": "value1", "key2": "value2", @@ -156,12 +156,12 @@ func TestKeptnAppVersion_ConvertFrom(t *testing.T) { "key222": "value222", }, }, - Status: v1beta1common.StateFailed, + Status: v1common.StateFailed, }, }, wantErr: false, wantObj: &KeptnAppVersion{ - ObjectMeta: v1.ObjectMeta{ + ObjectMeta: metav1.ObjectMeta{ Name: "some-keptn-app-name", Namespace: "", Labels: map[string]string{ @@ -293,8 +293,8 @@ func TestKeptnAppVersion_ConvertFrom(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { dst := &KeptnAppVersion{ - TypeMeta: v1.TypeMeta{}, - ObjectMeta: v1.ObjectMeta{}, + TypeMeta: metav1.TypeMeta{}, + ObjectMeta: metav1.ObjectMeta{}, Spec: KeptnAppVersionSpec{}, Status: KeptnAppVersionStatus{}, } @@ -313,16 +313,16 @@ func TestKeptnAppVersion_ConvertTo(t *testing.T) { name string src *KeptnAppVersion wantErr bool - wantObj *v1beta1.KeptnAppVersion + wantObj *v1.KeptnAppVersion }{ { - name: "Test that conversion from v1alpha1 to v1beta1 works", + name: "Test that conversion from v1alpha1 to v1 works", src: &KeptnAppVersion{ - TypeMeta: v1.TypeMeta{ + TypeMeta: metav1.TypeMeta{ Kind: "KeptnAppVersion", APIVersion: "lifecycle.keptn.sh/v1alpha1", }, - ObjectMeta: v1.ObjectMeta{ + ObjectMeta: metav1.ObjectMeta{ Name: "some-keptn-app-name", Namespace: "", Labels: map[string]string{ @@ -450,8 +450,8 @@ func TestKeptnAppVersion_ConvertTo(t *testing.T) { }, }, wantErr: false, - wantObj: &v1beta1.KeptnAppVersion{ - ObjectMeta: v1.ObjectMeta{ + wantObj: &v1.KeptnAppVersion{ + ObjectMeta: metav1.ObjectMeta{ Name: "some-keptn-app-name", Namespace: "", Labels: map[string]string{ @@ -461,11 +461,11 @@ func TestKeptnAppVersion_ConvertTo(t *testing.T) { "some-annotation": "some-annotation-value", }, }, - Spec: v1beta1.KeptnAppVersionSpec{ - KeptnAppSpec: v1beta1.KeptnAppSpec{ + Spec: v1.KeptnAppVersionSpec{ + KeptnAppSpec: v1.KeptnAppSpec{ Version: "1.2.3", Revision: 1, - Workloads: []v1beta1.KeptnWorkloadRef{ + Workloads: []v1.KeptnWorkloadRef{ { Name: "workload-1", Version: "1.2.3", @@ -476,8 +476,8 @@ func TestKeptnAppVersion_ConvertTo(t *testing.T) { }, }, }, - KeptnAppContextSpec: v1beta1.KeptnAppContextSpec{ - DeploymentTaskSpec: v1beta1.DeploymentTaskSpec{ + KeptnAppContextSpec: v1.KeptnAppContextSpec{ + DeploymentTaskSpec: v1.DeploymentTaskSpec{ PreDeploymentTasks: []string{ "some-pre-deployment-task1", }, @@ -499,78 +499,78 @@ func TestKeptnAppVersion_ConvertTo(t *testing.T) { "key2": "value2", }, }, - Status: v1beta1.KeptnAppVersionStatus{ - PreDeploymentStatus: v1beta1common.StateFailed, - PostDeploymentStatus: v1beta1common.StateFailed, - PreDeploymentEvaluationStatus: v1beta1common.StateFailed, - PostDeploymentEvaluationStatus: v1beta1common.StateFailed, - WorkloadOverallStatus: v1beta1common.StateFailed, - WorkloadStatus: []v1beta1.WorkloadStatus{ - { - Workload: v1beta1.KeptnWorkloadRef{ + Status: v1.KeptnAppVersionStatus{ + PreDeploymentStatus: v1common.StateFailed, + PostDeploymentStatus: v1common.StateFailed, + PreDeploymentEvaluationStatus: v1common.StateFailed, + PostDeploymentEvaluationStatus: v1common.StateFailed, + WorkloadOverallStatus: v1common.StateFailed, + WorkloadStatus: []v1.WorkloadStatus{ + { + Workload: v1.KeptnWorkloadRef{ Name: "name1", Version: "1", }, - Status: v1beta1common.StateFailed, + Status: v1common.StateFailed, }, { - Workload: v1beta1.KeptnWorkloadRef{ + Workload: v1.KeptnWorkloadRef{ Name: "name2", Version: "2", }, - Status: v1beta1common.StateFailed, + Status: v1common.StateFailed, }, }, CurrentPhase: "phase", - PreDeploymentTaskStatus: []v1beta1.ItemStatus{ + PreDeploymentTaskStatus: []v1.ItemStatus{ { DefinitionName: "def1", Name: "name1", - Status: v1beta1common.StateFailed, + Status: v1common.StateFailed, }, { DefinitionName: "def12", Name: "name12", - Status: v1beta1common.StateFailed, + Status: v1common.StateFailed, }, }, - PostDeploymentTaskStatus: []v1beta1.ItemStatus{ + PostDeploymentTaskStatus: []v1.ItemStatus{ { DefinitionName: "def2", Name: "name2", - Status: v1beta1common.StateFailed, + Status: v1common.StateFailed, }, { DefinitionName: "def22", Name: "name22", - Status: v1beta1common.StateFailed, + Status: v1common.StateFailed, }, }, - PreDeploymentEvaluationTaskStatus: []v1beta1.ItemStatus{ + PreDeploymentEvaluationTaskStatus: []v1.ItemStatus{ { DefinitionName: "def3", Name: "name3", - Status: v1beta1common.StateFailed, + Status: v1common.StateFailed, }, { DefinitionName: "def32", Name: "name32", - Status: v1beta1common.StateFailed, + Status: v1common.StateFailed, }, }, - PostDeploymentEvaluationTaskStatus: []v1beta1.ItemStatus{ + PostDeploymentEvaluationTaskStatus: []v1.ItemStatus{ { DefinitionName: "def4", Name: "name4", - Status: v1beta1common.StateFailed, + Status: v1common.StateFailed, }, { DefinitionName: "def42", Name: "name42", - Status: v1beta1common.StateFailed, + Status: v1common.StateFailed, }, }, - PhaseTraceIDs: v1beta1common.PhaseTraceID{ + PhaseTraceIDs: v1common.PhaseTraceID{ "key": propagation.MapCarrier{ "key1": "value1", "key2": "value2", @@ -580,18 +580,18 @@ func TestKeptnAppVersion_ConvertTo(t *testing.T) { "key222": "value222", }, }, - Status: v1beta1common.StateFailed, + Status: v1common.StateFailed, }, }, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - dst := v1beta1.KeptnAppVersion{ - TypeMeta: v1.TypeMeta{}, - ObjectMeta: v1.ObjectMeta{}, - Spec: v1beta1.KeptnAppVersionSpec{}, - Status: v1beta1.KeptnAppVersionStatus{}, + dst := v1.KeptnAppVersion{ + TypeMeta: metav1.TypeMeta{}, + ObjectMeta: metav1.ObjectMeta{}, + Spec: v1.KeptnAppVersionSpec{}, + Status: v1.KeptnAppVersionStatus{}, } if err := tt.src.ConvertTo(&dst); (err != nil) != tt.wantErr { t.Errorf("ConvertTo() error = %v, wantErr %v", err, tt.wantErr) @@ -608,8 +608,8 @@ func TestKeptnAppVersion_ConvertFrom_Errorcase(t *testing.T) { testObj := v2.ExternalJob{} dst := &KeptnAppVersion{ - TypeMeta: v1.TypeMeta{}, - ObjectMeta: v1.ObjectMeta{}, + TypeMeta: metav1.TypeMeta{}, + ObjectMeta: metav1.ObjectMeta{}, Spec: KeptnAppVersionSpec{}, Status: KeptnAppVersionStatus{}, } diff --git a/lifecycle-operator/apis/lifecycle/v1alpha2/common/common.go b/lifecycle-operator/apis/lifecycle/v1alpha2/common/common.go index a7fdf21310..57c49d7889 100644 --- a/lifecycle-operator/apis/lifecycle/v1alpha2/common/common.go +++ b/lifecycle-operator/apis/lifecycle/v1alpha2/common/common.go @@ -34,10 +34,8 @@ const MaxWorkloadNameLength = 25 const MaxTaskNameLength = 25 const MaxVersionLength = 12 -var ErrCannotCastKeptnAppVersion = errors.New("cannot cast KeptnAppVersion to v1beta1") -var ErrCannotCastKeptnApp = errors.New("cannot cast KeptnApp to v1beta1") -var ErrCannotCastKeptnWorkloadInstance = errors.New("cannot cast KeptnWorkloadInstance to v1beta1") -var ErrCannotCastKeptnEvaluationProvider = errors.New("cannot cast KeptnEvaluationDefinition to v1beta1") +var ErrCannotCastKeptnAppVersion = errors.New("cannot cast KeptnAppVersion to v1") +var ErrCannotCastKeptnApp = errors.New("cannot cast KeptnApp to v1") // KeptnState is a string containing current Phase state (Progressing/Succeeded/Failed/Unknown/Pending/Cancelled) type KeptnState string diff --git a/lifecycle-operator/apis/lifecycle/v1alpha2/keptnapp_conversion.go b/lifecycle-operator/apis/lifecycle/v1alpha2/keptnapp_conversion.go index d3a485c51f..10f179656c 100644 --- a/lifecycle-operator/apis/lifecycle/v1alpha2/keptnapp_conversion.go +++ b/lifecycle-operator/apis/lifecycle/v1alpha2/keptnapp_conversion.go @@ -3,14 +3,14 @@ package v1alpha2 import ( "fmt" + v1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha2/common" - "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" "sigs.k8s.io/controller-runtime/pkg/conversion" ) -// ConvertTo converts the src v1alpha2.KeptnApp to the hub version (v1beta1.KeptnApp) +// ConvertTo converts the src v1alpha2.KeptnApp to the hub version (v1.KeptnApp) func (src *KeptnApp) ConvertTo(dstRaw conversion.Hub) error { - dst, ok := dstRaw.(*v1beta1.KeptnApp) + dst, ok := dstRaw.(*v1.KeptnApp) if !ok { return fmt.Errorf("type %T %w", dstRaw, common.ErrCannotCastKeptnApp) @@ -22,7 +22,7 @@ func (src *KeptnApp) ConvertTo(dstRaw conversion.Hub) error { dst.Spec.Version = src.Spec.Version for _, srcWl := range src.Spec.Workloads { - dst.Spec.Workloads = append(dst.Spec.Workloads, v1beta1.KeptnWorkloadRef{ + dst.Spec.Workloads = append(dst.Spec.Workloads, v1.KeptnWorkloadRef{ Name: srcWl.Name, Version: srcWl.Version, }) @@ -35,9 +35,9 @@ func (src *KeptnApp) ConvertTo(dstRaw conversion.Hub) error { return nil } -// ConvertFrom converts from the hub version (v1beta1.KeptnApp) to this version (v1alpha2.KeptnApp) +// ConvertFrom converts from the hub version (v1.KeptnApp) to this version (v1alpha2.KeptnApp) func (dst *KeptnApp) ConvertFrom(srcRaw conversion.Hub) error { - src, ok := srcRaw.(*v1beta1.KeptnApp) + src, ok := srcRaw.(*v1.KeptnApp) if !ok { return fmt.Errorf("type %T %w", srcRaw, common.ErrCannotCastKeptnApp) diff --git a/lifecycle-operator/apis/lifecycle/v1alpha2/keptnapp_conversion_test.go b/lifecycle-operator/apis/lifecycle/v1alpha2/keptnapp_conversion_test.go index 8b6509e7b9..6ece547f92 100644 --- a/lifecycle-operator/apis/lifecycle/v1alpha2/keptnapp_conversion_test.go +++ b/lifecycle-operator/apis/lifecycle/v1alpha2/keptnapp_conversion_test.go @@ -3,28 +3,28 @@ package v1alpha2 import ( "testing" + v1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha2/common" - "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" "github.com/stretchr/testify/require" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" v2 "sigs.k8s.io/controller-runtime/pkg/webhook/conversion/testdata/api/v2" ) func TestKeptnApp_ConvertFrom(t *testing.T) { tests := []struct { name string - srcObj *v1beta1.KeptnApp + srcObj *v1.KeptnApp wantErr bool wantObj *KeptnApp }{ { name: "Test that conversion from v1alpha3 to v1alpha3 works", - srcObj: &v1beta1.KeptnApp{ - TypeMeta: v1.TypeMeta{ + srcObj: &v1.KeptnApp{ + TypeMeta: metav1.TypeMeta{ Kind: "KeptnApp", APIVersion: "lifecycle.keptn.sh/v1alpha3", }, - ObjectMeta: v1.ObjectMeta{ + ObjectMeta: metav1.ObjectMeta{ Name: "some-keptn-app-name", Namespace: "", Labels: map[string]string{ @@ -34,10 +34,10 @@ func TestKeptnApp_ConvertFrom(t *testing.T) { "some-annotation": "some-annotation-value", }, }, - Spec: v1beta1.KeptnAppSpec{ + Spec: v1.KeptnAppSpec{ Version: "1.2.3", Revision: 1, - Workloads: []v1beta1.KeptnWorkloadRef{ + Workloads: []v1.KeptnWorkloadRef{ { Name: "workload-1", Version: "1.2.3", @@ -48,13 +48,13 @@ func TestKeptnApp_ConvertFrom(t *testing.T) { }, }, }, - Status: v1beta1.KeptnAppStatus{ + Status: v1.KeptnAppStatus{ CurrentVersion: "1.2.3", }, }, wantErr: false, wantObj: &KeptnApp{ - ObjectMeta: v1.ObjectMeta{ + ObjectMeta: metav1.ObjectMeta{ Name: "some-keptn-app-name", Namespace: "", Labels: map[string]string{ @@ -87,8 +87,8 @@ func TestKeptnApp_ConvertFrom(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { dst := &KeptnApp{ - TypeMeta: v1.TypeMeta{}, - ObjectMeta: v1.ObjectMeta{}, + TypeMeta: metav1.TypeMeta{}, + ObjectMeta: metav1.ObjectMeta{}, Spec: KeptnAppSpec{}, Status: KeptnAppStatus{}, } @@ -107,16 +107,16 @@ func TestKeptnApp_ConvertTo(t *testing.T) { name string src *KeptnApp wantErr bool - wantObj *v1beta1.KeptnApp + wantObj *v1.KeptnApp }{ { name: "Test that conversion from v1alpha3 to v1alpha3 works", src: &KeptnApp{ - TypeMeta: v1.TypeMeta{ + TypeMeta: metav1.TypeMeta{ Kind: "KeptnApp", APIVersion: "lifecycle.keptn.sh/v1alpha3", }, - ObjectMeta: v1.ObjectMeta{ + ObjectMeta: metav1.ObjectMeta{ Name: "some-keptn-app-name", Namespace: "", Labels: map[string]string{ @@ -145,8 +145,8 @@ func TestKeptnApp_ConvertTo(t *testing.T) { }, }, wantErr: false, - wantObj: &v1beta1.KeptnApp{ - ObjectMeta: v1.ObjectMeta{ + wantObj: &v1.KeptnApp{ + ObjectMeta: metav1.ObjectMeta{ Name: "some-keptn-app-name", Namespace: "", Labels: map[string]string{ @@ -156,10 +156,10 @@ func TestKeptnApp_ConvertTo(t *testing.T) { "some-annotation": "some-annotation-value", }, }, - Spec: v1beta1.KeptnAppSpec{ + Spec: v1.KeptnAppSpec{ Version: "1.2.3", Revision: 1, - Workloads: []v1beta1.KeptnWorkloadRef{ + Workloads: []v1.KeptnWorkloadRef{ { Name: "workload-1", Version: "1.2.3", @@ -170,7 +170,7 @@ func TestKeptnApp_ConvertTo(t *testing.T) { }, }, }, - Status: v1beta1.KeptnAppStatus{ + Status: v1.KeptnAppStatus{ CurrentVersion: "1.2.3", }, }, @@ -178,11 +178,11 @@ func TestKeptnApp_ConvertTo(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - dst := v1beta1.KeptnApp{ - TypeMeta: v1.TypeMeta{}, - ObjectMeta: v1.ObjectMeta{}, - Spec: v1beta1.KeptnAppSpec{}, - Status: v1beta1.KeptnAppStatus{}, + dst := v1.KeptnApp{ + TypeMeta: metav1.TypeMeta{}, + ObjectMeta: metav1.ObjectMeta{}, + Spec: v1.KeptnAppSpec{}, + Status: v1.KeptnAppStatus{}, } if err := tt.src.ConvertTo(&dst); (err != nil) != tt.wantErr { t.Errorf("ConvertTo() error = %v, wantErr %v", err, tt.wantErr) @@ -199,8 +199,8 @@ func TestKeptnApp_ConvertFrom_Errorcase(t *testing.T) { testObj := v2.ExternalJob{} dst := &KeptnApp{ - TypeMeta: v1.TypeMeta{}, - ObjectMeta: v1.ObjectMeta{}, + TypeMeta: metav1.TypeMeta{}, + ObjectMeta: metav1.ObjectMeta{}, Spec: KeptnAppSpec{}, Status: KeptnAppStatus{}, } diff --git a/lifecycle-operator/apis/lifecycle/v1alpha2/keptnappversion_conversion.go b/lifecycle-operator/apis/lifecycle/v1alpha2/keptnappversion_conversion.go index 5a03253a49..f446a95f75 100644 --- a/lifecycle-operator/apis/lifecycle/v1alpha2/keptnappversion_conversion.go +++ b/lifecycle-operator/apis/lifecycle/v1alpha2/keptnappversion_conversion.go @@ -3,18 +3,18 @@ package v1alpha2 import ( "fmt" + v1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1" + v1common "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1/common" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha2/common" - "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" - v1beta1common "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" "go.opentelemetry.io/otel/propagation" "sigs.k8s.io/controller-runtime/pkg/conversion" ) -// ConvertTo converts the src v1alpha2.KeptnAppVersion to the hub version (v1beta1.KeptnAppVersion) +// ConvertTo converts the src v1alpha2.KeptnAppVersion to the hub version (v1.KeptnAppVersion) // //nolint:gocyclo func (src *KeptnAppVersion) ConvertTo(dstRaw conversion.Hub) error { - dst, ok := dstRaw.(*v1beta1.KeptnAppVersion) + dst, ok := dstRaw.(*v1.KeptnAppVersion) if !ok { return fmt.Errorf("type %T %w", dstRaw, common.ErrCannotCastKeptnAppVersion) @@ -26,7 +26,7 @@ func (src *KeptnAppVersion) ConvertTo(dstRaw conversion.Hub) error { dst.Spec.Version = src.Spec.Version for _, srcWl := range src.Spec.Workloads { - dst.Spec.Workloads = append(dst.Spec.Workloads, v1beta1.KeptnWorkloadRef{ + dst.Spec.Workloads = append(dst.Spec.Workloads, v1.KeptnWorkloadRef{ Name: srcWl.Name, Version: srcWl.Version, }) @@ -44,20 +44,20 @@ func (src *KeptnAppVersion) ConvertTo(dstRaw conversion.Hub) error { dst.Spec.TraceId[k] = v } - dst.Status.PreDeploymentStatus = v1beta1common.KeptnState(src.Status.PreDeploymentStatus) - dst.Status.PostDeploymentStatus = v1beta1common.KeptnState(src.Status.PostDeploymentStatus) - dst.Status.PreDeploymentEvaluationStatus = v1beta1common.KeptnState(src.Status.PreDeploymentEvaluationStatus) - dst.Status.PostDeploymentEvaluationStatus = v1beta1common.KeptnState(src.Status.PostDeploymentEvaluationStatus) - dst.Status.WorkloadOverallStatus = v1beta1common.KeptnState(src.Status.WorkloadOverallStatus) - dst.Status.Status = v1beta1common.KeptnState(src.Status.Status) + dst.Status.PreDeploymentStatus = v1common.KeptnState(src.Status.PreDeploymentStatus) + dst.Status.PostDeploymentStatus = v1common.KeptnState(src.Status.PostDeploymentStatus) + dst.Status.PreDeploymentEvaluationStatus = v1common.KeptnState(src.Status.PreDeploymentEvaluationStatus) + dst.Status.PostDeploymentEvaluationStatus = v1common.KeptnState(src.Status.PostDeploymentEvaluationStatus) + dst.Status.WorkloadOverallStatus = v1common.KeptnState(src.Status.WorkloadOverallStatus) + dst.Status.Status = v1common.KeptnState(src.Status.Status) for _, srcWls := range src.Status.WorkloadStatus { - dst.Status.WorkloadStatus = append(dst.Status.WorkloadStatus, v1beta1.WorkloadStatus{ - Workload: v1beta1.KeptnWorkloadRef{ + dst.Status.WorkloadStatus = append(dst.Status.WorkloadStatus, v1.WorkloadStatus{ + Workload: v1.KeptnWorkloadRef{ Name: srcWls.Workload.Name, Version: srcWls.Workload.Version, }, - Status: v1beta1common.KeptnState(srcWls.Status), + Status: v1common.KeptnState(srcWls.Status), }) } @@ -68,9 +68,9 @@ func (src *KeptnAppVersion) ConvertTo(dstRaw conversion.Hub) error { // Convert changed fields for _, item := range src.Status.PreDeploymentTaskStatus { - dst.Status.PreDeploymentTaskStatus = append(dst.Status.PreDeploymentTaskStatus, v1beta1.ItemStatus{ + dst.Status.PreDeploymentTaskStatus = append(dst.Status.PreDeploymentTaskStatus, v1.ItemStatus{ DefinitionName: item.DefinitionName, - Status: v1beta1common.KeptnState(item.Status), + Status: v1common.KeptnState(item.Status), Name: item.Name, StartTime: item.StartTime, EndTime: item.EndTime, @@ -78,9 +78,9 @@ func (src *KeptnAppVersion) ConvertTo(dstRaw conversion.Hub) error { } for _, item := range src.Status.PostDeploymentTaskStatus { - dst.Status.PostDeploymentTaskStatus = append(dst.Status.PostDeploymentTaskStatus, v1beta1.ItemStatus{ + dst.Status.PostDeploymentTaskStatus = append(dst.Status.PostDeploymentTaskStatus, v1.ItemStatus{ DefinitionName: item.DefinitionName, - Status: v1beta1common.KeptnState(item.Status), + Status: v1common.KeptnState(item.Status), Name: item.Name, StartTime: item.StartTime, EndTime: item.EndTime, @@ -88,9 +88,9 @@ func (src *KeptnAppVersion) ConvertTo(dstRaw conversion.Hub) error { } for _, item := range src.Status.PreDeploymentEvaluationTaskStatus { - dst.Status.PreDeploymentEvaluationTaskStatus = append(dst.Status.PreDeploymentEvaluationTaskStatus, v1beta1.ItemStatus{ + dst.Status.PreDeploymentEvaluationTaskStatus = append(dst.Status.PreDeploymentEvaluationTaskStatus, v1.ItemStatus{ DefinitionName: item.DefinitionName, - Status: v1beta1common.KeptnState(item.Status), + Status: v1common.KeptnState(item.Status), Name: item.Name, StartTime: item.StartTime, EndTime: item.EndTime, @@ -98,16 +98,16 @@ func (src *KeptnAppVersion) ConvertTo(dstRaw conversion.Hub) error { } for _, item := range src.Status.PostDeploymentEvaluationTaskStatus { - dst.Status.PostDeploymentEvaluationTaskStatus = append(dst.Status.PostDeploymentEvaluationTaskStatus, v1beta1.ItemStatus{ + dst.Status.PostDeploymentEvaluationTaskStatus = append(dst.Status.PostDeploymentEvaluationTaskStatus, v1.ItemStatus{ DefinitionName: item.DefinitionName, - Status: v1beta1common.KeptnState(item.Status), + Status: v1common.KeptnState(item.Status), Name: item.Name, StartTime: item.StartTime, EndTime: item.EndTime, }) } - dst.Status.PhaseTraceIDs = make(v1beta1common.PhaseTraceID, len(src.Status.PhaseTraceIDs)) + dst.Status.PhaseTraceIDs = make(v1common.PhaseTraceID, len(src.Status.PhaseTraceIDs)) for k, v := range src.Status.PhaseTraceIDs { c := make(propagation.MapCarrier, len(v)) for k1, v1 := range v { @@ -122,11 +122,11 @@ func (src *KeptnAppVersion) ConvertTo(dstRaw conversion.Hub) error { return nil } -// ConvertFrom converts from the hub version (v1beta1.KeptnAppVersion) to this version (v1alpha2.KeptnAppVersion) +// ConvertFrom converts from the hub version (v1.KeptnAppVersion) to this version (v1alpha2.KeptnAppVersion) // //nolint:gocyclo func (dst *KeptnAppVersion) ConvertFrom(srcRaw conversion.Hub) error { - src, ok := srcRaw.(*v1beta1.KeptnAppVersion) + src, ok := srcRaw.(*v1.KeptnAppVersion) if !ok { return fmt.Errorf("type %T %w", srcRaw, common.ErrCannotCastKeptnAppVersion) diff --git a/lifecycle-operator/apis/lifecycle/v1alpha2/keptnappversion_conversion_test.go b/lifecycle-operator/apis/lifecycle/v1alpha2/keptnappversion_conversion_test.go index 93a4ea6282..3dd6d9a330 100644 --- a/lifecycle-operator/apis/lifecycle/v1alpha2/keptnappversion_conversion_test.go +++ b/lifecycle-operator/apis/lifecycle/v1alpha2/keptnappversion_conversion_test.go @@ -4,30 +4,30 @@ package v1alpha2 import ( "testing" + v1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1" + v1common "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1/common" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha2/common" - "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" - v1beta1common "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" "github.com/stretchr/testify/require" "go.opentelemetry.io/otel/propagation" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" v2 "sigs.k8s.io/controller-runtime/pkg/webhook/conversion/testdata/api/v2" ) func TestKeptnAppVersion_ConvertFrom(t *testing.T) { tests := []struct { name string - srcObj *v1beta1.KeptnAppVersion + srcObj *v1.KeptnAppVersion wantErr bool wantObj *KeptnAppVersion }{ { - name: "Test that conversion from v1beta1 to v1beta1 works", - srcObj: &v1beta1.KeptnAppVersion{ - TypeMeta: v1.TypeMeta{ + name: "Test that conversion from v1 to v1alpha2 works", + srcObj: &v1.KeptnAppVersion{ + TypeMeta: metav1.TypeMeta{ Kind: "KeptnAppVersion", - APIVersion: "lifecycle.keptn.sh/v1beta1", + APIVersion: "lifecycle.keptn.sh/v1", }, - ObjectMeta: v1.ObjectMeta{ + ObjectMeta: metav1.ObjectMeta{ Name: "some-keptn-app-name", Namespace: "", Labels: map[string]string{ @@ -37,11 +37,11 @@ func TestKeptnAppVersion_ConvertFrom(t *testing.T) { "some-annotation": "some-annotation-value", }, }, - Spec: v1beta1.KeptnAppVersionSpec{ - KeptnAppSpec: v1beta1.KeptnAppSpec{ + Spec: v1.KeptnAppVersionSpec{ + KeptnAppSpec: v1.KeptnAppSpec{ Version: "1.2.3", Revision: 1, - Workloads: []v1beta1.KeptnWorkloadRef{ + Workloads: []v1.KeptnWorkloadRef{ { Name: "workload-1", Version: "1.2.3", @@ -52,8 +52,8 @@ func TestKeptnAppVersion_ConvertFrom(t *testing.T) { }, }, }, - KeptnAppContextSpec: v1beta1.KeptnAppContextSpec{ - DeploymentTaskSpec: v1beta1.DeploymentTaskSpec{ + KeptnAppContextSpec: v1.KeptnAppContextSpec{ + DeploymentTaskSpec: v1.DeploymentTaskSpec{ PreDeploymentTasks: []string{ "some-pre-deployment-task1", }, @@ -75,78 +75,78 @@ func TestKeptnAppVersion_ConvertFrom(t *testing.T) { "key2": "value2", }, }, - Status: v1beta1.KeptnAppVersionStatus{ - PreDeploymentStatus: v1beta1common.StateFailed, - PostDeploymentStatus: v1beta1common.StateFailed, - PreDeploymentEvaluationStatus: v1beta1common.StateFailed, - PostDeploymentEvaluationStatus: v1beta1common.StateFailed, - WorkloadOverallStatus: v1beta1common.StateFailed, - WorkloadStatus: []v1beta1.WorkloadStatus{ - { - Workload: v1beta1.KeptnWorkloadRef{ + Status: v1.KeptnAppVersionStatus{ + PreDeploymentStatus: v1common.StateFailed, + PostDeploymentStatus: v1common.StateFailed, + PreDeploymentEvaluationStatus: v1common.StateFailed, + PostDeploymentEvaluationStatus: v1common.StateFailed, + WorkloadOverallStatus: v1common.StateFailed, + WorkloadStatus: []v1.WorkloadStatus{ + { + Workload: v1.KeptnWorkloadRef{ Name: "name1", Version: "1", }, - Status: v1beta1common.StateFailed, + Status: v1common.StateFailed, }, { - Workload: v1beta1.KeptnWorkloadRef{ + Workload: v1.KeptnWorkloadRef{ Name: "name2", Version: "2", }, - Status: v1beta1common.StateFailed, + Status: v1common.StateFailed, }, }, CurrentPhase: "phase", - PreDeploymentTaskStatus: []v1beta1.ItemStatus{ + PreDeploymentTaskStatus: []v1.ItemStatus{ { DefinitionName: "def1", Name: "name1", - Status: v1beta1common.StateFailed, + Status: v1common.StateFailed, }, { DefinitionName: "def12", Name: "name12", - Status: v1beta1common.StateFailed, + Status: v1common.StateFailed, }, }, - PostDeploymentTaskStatus: []v1beta1.ItemStatus{ + PostDeploymentTaskStatus: []v1.ItemStatus{ { DefinitionName: "def2", Name: "name2", - Status: v1beta1common.StateFailed, + Status: v1common.StateFailed, }, { DefinitionName: "def22", Name: "name22", - Status: v1beta1common.StateFailed, + Status: v1common.StateFailed, }, }, - PreDeploymentEvaluationTaskStatus: []v1beta1.ItemStatus{ + PreDeploymentEvaluationTaskStatus: []v1.ItemStatus{ { DefinitionName: "def3", Name: "name3", - Status: v1beta1common.StateFailed, + Status: v1common.StateFailed, }, { DefinitionName: "def32", Name: "name32", - Status: v1beta1common.StateFailed, + Status: v1common.StateFailed, }, }, - PostDeploymentEvaluationTaskStatus: []v1beta1.ItemStatus{ + PostDeploymentEvaluationTaskStatus: []v1.ItemStatus{ { DefinitionName: "def4", Name: "name4", - Status: v1beta1common.StateFailed, + Status: v1common.StateFailed, }, { DefinitionName: "def42", Name: "name42", - Status: v1beta1common.StateFailed, + Status: v1common.StateFailed, }, }, - PhaseTraceIDs: v1beta1common.PhaseTraceID{ + PhaseTraceIDs: v1common.PhaseTraceID{ "key": propagation.MapCarrier{ "key1": "value1", "key2": "value2", @@ -156,12 +156,12 @@ func TestKeptnAppVersion_ConvertFrom(t *testing.T) { "key222": "value222", }, }, - Status: v1beta1common.StateFailed, + Status: v1common.StateFailed, }, }, wantErr: false, wantObj: &KeptnAppVersion{ - ObjectMeta: v1.ObjectMeta{ + ObjectMeta: metav1.ObjectMeta{ Name: "some-keptn-app-name", Namespace: "", Labels: map[string]string{ @@ -293,8 +293,8 @@ func TestKeptnAppVersion_ConvertFrom(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { dst := &KeptnAppVersion{ - TypeMeta: v1.TypeMeta{}, - ObjectMeta: v1.ObjectMeta{}, + TypeMeta: metav1.TypeMeta{}, + ObjectMeta: metav1.ObjectMeta{}, Spec: KeptnAppVersionSpec{}, Status: KeptnAppVersionStatus{}, } @@ -313,16 +313,16 @@ func TestKeptnAppVersion_ConvertTo(t *testing.T) { name string src *KeptnAppVersion wantErr bool - wantObj *v1beta1.KeptnAppVersion + wantObj *v1.KeptnAppVersion }{ { - name: "Test that conversion from v1beta1 to v1beta1 works", + name: "Test that conversion from v1alpha2 to v1 works", src: &KeptnAppVersion{ - TypeMeta: v1.TypeMeta{ + TypeMeta: metav1.TypeMeta{ Kind: "KeptnAppVersion", - APIVersion: "lifecycle.keptn.sh/v1beta1", + APIVersion: "lifecycle.keptn.sh/v1alpha2", }, - ObjectMeta: v1.ObjectMeta{ + ObjectMeta: metav1.ObjectMeta{ Name: "some-keptn-app-name", Namespace: "", Labels: map[string]string{ @@ -450,8 +450,8 @@ func TestKeptnAppVersion_ConvertTo(t *testing.T) { }, }, wantErr: false, - wantObj: &v1beta1.KeptnAppVersion{ - ObjectMeta: v1.ObjectMeta{ + wantObj: &v1.KeptnAppVersion{ + ObjectMeta: metav1.ObjectMeta{ Name: "some-keptn-app-name", Namespace: "", Labels: map[string]string{ @@ -461,11 +461,11 @@ func TestKeptnAppVersion_ConvertTo(t *testing.T) { "some-annotation": "some-annotation-value", }, }, - Spec: v1beta1.KeptnAppVersionSpec{ - KeptnAppSpec: v1beta1.KeptnAppSpec{ + Spec: v1.KeptnAppVersionSpec{ + KeptnAppSpec: v1.KeptnAppSpec{ Version: "1.2.3", Revision: 1, - Workloads: []v1beta1.KeptnWorkloadRef{ + Workloads: []v1.KeptnWorkloadRef{ { Name: "workload-1", Version: "1.2.3", @@ -476,8 +476,8 @@ func TestKeptnAppVersion_ConvertTo(t *testing.T) { }, }, }, - KeptnAppContextSpec: v1beta1.KeptnAppContextSpec{ - DeploymentTaskSpec: v1beta1.DeploymentTaskSpec{ + KeptnAppContextSpec: v1.KeptnAppContextSpec{ + DeploymentTaskSpec: v1.DeploymentTaskSpec{ PreDeploymentTasks: []string{ "some-pre-deployment-task1", }, @@ -499,78 +499,78 @@ func TestKeptnAppVersion_ConvertTo(t *testing.T) { "key2": "value2", }, }, - Status: v1beta1.KeptnAppVersionStatus{ - PreDeploymentStatus: v1beta1common.StateFailed, - PostDeploymentStatus: v1beta1common.StateFailed, - PreDeploymentEvaluationStatus: v1beta1common.StateFailed, - PostDeploymentEvaluationStatus: v1beta1common.StateFailed, - WorkloadOverallStatus: v1beta1common.StateFailed, - WorkloadStatus: []v1beta1.WorkloadStatus{ - { - Workload: v1beta1.KeptnWorkloadRef{ + Status: v1.KeptnAppVersionStatus{ + PreDeploymentStatus: v1common.StateFailed, + PostDeploymentStatus: v1common.StateFailed, + PreDeploymentEvaluationStatus: v1common.StateFailed, + PostDeploymentEvaluationStatus: v1common.StateFailed, + WorkloadOverallStatus: v1common.StateFailed, + WorkloadStatus: []v1.WorkloadStatus{ + { + Workload: v1.KeptnWorkloadRef{ Name: "name1", Version: "1", }, - Status: v1beta1common.StateFailed, + Status: v1common.StateFailed, }, { - Workload: v1beta1.KeptnWorkloadRef{ + Workload: v1.KeptnWorkloadRef{ Name: "name2", Version: "2", }, - Status: v1beta1common.StateFailed, + Status: v1common.StateFailed, }, }, CurrentPhase: "phase", - PreDeploymentTaskStatus: []v1beta1.ItemStatus{ + PreDeploymentTaskStatus: []v1.ItemStatus{ { DefinitionName: "def1", Name: "name1", - Status: v1beta1common.StateFailed, + Status: v1common.StateFailed, }, { DefinitionName: "def12", Name: "name12", - Status: v1beta1common.StateFailed, + Status: v1common.StateFailed, }, }, - PostDeploymentTaskStatus: []v1beta1.ItemStatus{ + PostDeploymentTaskStatus: []v1.ItemStatus{ { DefinitionName: "def2", Name: "name2", - Status: v1beta1common.StateFailed, + Status: v1common.StateFailed, }, { DefinitionName: "def22", Name: "name22", - Status: v1beta1common.StateFailed, + Status: v1common.StateFailed, }, }, - PreDeploymentEvaluationTaskStatus: []v1beta1.ItemStatus{ + PreDeploymentEvaluationTaskStatus: []v1.ItemStatus{ { DefinitionName: "def3", Name: "name3", - Status: v1beta1common.StateFailed, + Status: v1common.StateFailed, }, { DefinitionName: "def32", Name: "name32", - Status: v1beta1common.StateFailed, + Status: v1common.StateFailed, }, }, - PostDeploymentEvaluationTaskStatus: []v1beta1.ItemStatus{ + PostDeploymentEvaluationTaskStatus: []v1.ItemStatus{ { DefinitionName: "def4", Name: "name4", - Status: v1beta1common.StateFailed, + Status: v1common.StateFailed, }, { DefinitionName: "def42", Name: "name42", - Status: v1beta1common.StateFailed, + Status: v1common.StateFailed, }, }, - PhaseTraceIDs: v1beta1common.PhaseTraceID{ + PhaseTraceIDs: v1common.PhaseTraceID{ "key": propagation.MapCarrier{ "key1": "value1", "key2": "value2", @@ -580,18 +580,18 @@ func TestKeptnAppVersion_ConvertTo(t *testing.T) { "key222": "value222", }, }, - Status: v1beta1common.StateFailed, + Status: v1common.StateFailed, }, }, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - dst := v1beta1.KeptnAppVersion{ - TypeMeta: v1.TypeMeta{}, - ObjectMeta: v1.ObjectMeta{}, - Spec: v1beta1.KeptnAppVersionSpec{}, - Status: v1beta1.KeptnAppVersionStatus{}, + dst := v1.KeptnAppVersion{ + TypeMeta: metav1.TypeMeta{}, + ObjectMeta: metav1.ObjectMeta{}, + Spec: v1.KeptnAppVersionSpec{}, + Status: v1.KeptnAppVersionStatus{}, } if err := tt.src.ConvertTo(&dst); (err != nil) != tt.wantErr { t.Errorf("ConvertTo() error = %v, wantErr %v", err, tt.wantErr) @@ -608,8 +608,8 @@ func TestKeptnAppVersion_ConvertFrom_Errorcase(t *testing.T) { testObj := v2.ExternalJob{} dst := &KeptnAppVersion{ - TypeMeta: v1.TypeMeta{}, - ObjectMeta: v1.ObjectMeta{}, + TypeMeta: metav1.TypeMeta{}, + ObjectMeta: metav1.ObjectMeta{}, Spec: KeptnAppVersionSpec{}, Status: KeptnAppVersionStatus{}, } diff --git a/lifecycle-operator/apis/lifecycle/v1alpha2/keptnappversion_test.go b/lifecycle-operator/apis/lifecycle/v1alpha2/keptnappversion_test.go index 2595aa52b5..69af203c59 100644 --- a/lifecycle-operator/apis/lifecycle/v1alpha2/keptnappversion_test.go +++ b/lifecycle-operator/apis/lifecycle/v1alpha2/keptnappversion_test.go @@ -8,13 +8,12 @@ import ( "github.com/stretchr/testify/require" "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/propagation" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) func TestKeptnAppVersion(t *testing.T) { app := &KeptnAppVersion{ - ObjectMeta: metav1.ObjectMeta{ + ObjectMeta: v1.ObjectMeta{ Name: "app", Namespace: "namespace", }, @@ -194,7 +193,7 @@ func TestKeptnAppVersion(t *testing.T) { AppName: app.GetParentName(), EvaluationDefinition: "taskdef", Type: common.PostDeploymentCheckType, - RetryInterval: metav1.Duration{ + RetryInterval: v1.Duration{ Duration: 5 * time.Second, }, }, evaluation.Spec) @@ -417,7 +416,7 @@ func TestKeptnAppVersionList(t *testing.T) { list := KeptnAppVersionList{ Items: []KeptnAppVersion{ { - ObjectMeta: metav1.ObjectMeta{ + ObjectMeta: v1.ObjectMeta{ Name: "obj1", }, Status: KeptnAppVersionStatus{ @@ -425,7 +424,7 @@ func TestKeptnAppVersionList(t *testing.T) { }, }, { - ObjectMeta: metav1.ObjectMeta{ + ObjectMeta: v1.ObjectMeta{ Name: "obj2", }, Status: KeptnAppVersionStatus{ diff --git a/lifecycle-operator/apis/lifecycle/v1alpha3/common/common.go b/lifecycle-operator/apis/lifecycle/v1alpha3/common/common.go index dcef442312..b503e8bef4 100644 --- a/lifecycle-operator/apis/lifecycle/v1alpha3/common/common.go +++ b/lifecycle-operator/apis/lifecycle/v1alpha3/common/common.go @@ -43,8 +43,8 @@ const MaxK8sObjectLength = 253 type AppType string -var ErrCannotCastKeptnAppVersion = errors.New("cannot cast KeptnAppVersion to v1beta1") -var ErrCannotCastKeptnApp = errors.New("cannot cast KeptnApp to v1beta1") +var ErrCannotCastKeptnAppVersion = errors.New("cannot cast KeptnAppVersion to v1") +var ErrCannotCastKeptnApp = errors.New("cannot cast KeptnApp to v1") const ( AppTypeSingleService AppType = "single-service" diff --git a/lifecycle-operator/apis/lifecycle/v1alpha3/keptnapp_conversion.go b/lifecycle-operator/apis/lifecycle/v1alpha3/keptnapp_conversion.go index e958c9d4b4..c0793dc3a7 100644 --- a/lifecycle-operator/apis/lifecycle/v1alpha3/keptnapp_conversion.go +++ b/lifecycle-operator/apis/lifecycle/v1alpha3/keptnapp_conversion.go @@ -3,14 +3,14 @@ package v1alpha3 import ( "fmt" + v1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3/common" - "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" "sigs.k8s.io/controller-runtime/pkg/conversion" ) -// ConvertTo converts the src v1alpha3.KeptnApp to the hub version (v1beta1.KeptnApp) +// ConvertTo converts the src v1alpha3.KeptnApp to the hub version (v1.KeptnApp) func (src *KeptnApp) ConvertTo(dstRaw conversion.Hub) error { - dst, ok := dstRaw.(*v1beta1.KeptnApp) + dst, ok := dstRaw.(*v1.KeptnApp) if !ok { return fmt.Errorf("type %T %w", dstRaw, common.ErrCannotCastKeptnApp) @@ -22,7 +22,7 @@ func (src *KeptnApp) ConvertTo(dstRaw conversion.Hub) error { dst.Spec.Version = src.Spec.Version for _, srcWl := range src.Spec.Workloads { - dst.Spec.Workloads = append(dst.Spec.Workloads, v1beta1.KeptnWorkloadRef{ + dst.Spec.Workloads = append(dst.Spec.Workloads, v1.KeptnWorkloadRef{ Name: srcWl.Name, Version: srcWl.Version, }) @@ -35,9 +35,9 @@ func (src *KeptnApp) ConvertTo(dstRaw conversion.Hub) error { return nil } -// ConvertFrom converts from the hub version (v1beta1.KeptnApp) to this version (v1alpha3.KeptnApp) +// ConvertFrom converts from the hub version (v1.KeptnApp) to this version (v1alpha3.KeptnApp) func (dst *KeptnApp) ConvertFrom(srcRaw conversion.Hub) error { - src, ok := srcRaw.(*v1beta1.KeptnApp) + src, ok := srcRaw.(*v1.KeptnApp) if !ok { return fmt.Errorf("type %T %w", srcRaw, common.ErrCannotCastKeptnApp) diff --git a/lifecycle-operator/apis/lifecycle/v1alpha3/keptnapp_conversion_test.go b/lifecycle-operator/apis/lifecycle/v1alpha3/keptnapp_conversion_test.go index d7b1ff6d42..9c815f8994 100644 --- a/lifecycle-operator/apis/lifecycle/v1alpha3/keptnapp_conversion_test.go +++ b/lifecycle-operator/apis/lifecycle/v1alpha3/keptnapp_conversion_test.go @@ -3,28 +3,28 @@ package v1alpha3 import ( "testing" + v1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3/common" - "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" "github.com/stretchr/testify/require" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" v2 "sigs.k8s.io/controller-runtime/pkg/webhook/conversion/testdata/api/v2" ) func TestKeptnApp_ConvertFrom(t *testing.T) { tests := []struct { name string - srcObj *v1beta1.KeptnApp + srcObj *v1.KeptnApp wantErr bool wantObj *KeptnApp }{ { - name: "Test that conversion from v1beta1 to v1alpha3 works", - srcObj: &v1beta1.KeptnApp{ - TypeMeta: v1.TypeMeta{ + name: "Test that conversion from v1 to v1alpha3 works", + srcObj: &v1.KeptnApp{ + TypeMeta: metav1.TypeMeta{ Kind: "KeptnApp", - APIVersion: "lifecycle.keptn.sh/v1beta1", + APIVersion: "lifecycle.keptn.sh/v1", }, - ObjectMeta: v1.ObjectMeta{ + ObjectMeta: metav1.ObjectMeta{ Name: "some-keptn-app-name", Namespace: "", Labels: map[string]string{ @@ -34,10 +34,10 @@ func TestKeptnApp_ConvertFrom(t *testing.T) { "some-annotation": "some-annotation-value", }, }, - Spec: v1beta1.KeptnAppSpec{ + Spec: v1.KeptnAppSpec{ Version: "1.2.3", Revision: 1, - Workloads: []v1beta1.KeptnWorkloadRef{ + Workloads: []v1.KeptnWorkloadRef{ { Name: "workload-1", Version: "1.2.3", @@ -48,13 +48,13 @@ func TestKeptnApp_ConvertFrom(t *testing.T) { }, }, }, - Status: v1beta1.KeptnAppStatus{ + Status: v1.KeptnAppStatus{ CurrentVersion: "1.2.3", }, }, wantErr: false, wantObj: &KeptnApp{ - ObjectMeta: v1.ObjectMeta{ + ObjectMeta: metav1.ObjectMeta{ Name: "some-keptn-app-name", Namespace: "", Labels: map[string]string{ @@ -87,8 +87,8 @@ func TestKeptnApp_ConvertFrom(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { dst := &KeptnApp{ - TypeMeta: v1.TypeMeta{}, - ObjectMeta: v1.ObjectMeta{}, + TypeMeta: metav1.TypeMeta{}, + ObjectMeta: metav1.ObjectMeta{}, Spec: KeptnAppSpec{}, Status: KeptnAppStatus{}, } @@ -107,16 +107,16 @@ func TestKeptnApp_ConvertTo(t *testing.T) { name string src *KeptnApp wantErr bool - wantObj *v1beta1.KeptnApp + wantObj *v1.KeptnApp }{ { - name: "Test that conversion from v1alpha3 to v1beta1 works", + name: "Test that conversion from v1alpha3 to v1 works", src: &KeptnApp{ - TypeMeta: v1.TypeMeta{ + TypeMeta: metav1.TypeMeta{ Kind: "KeptnApp", - APIVersion: "lifecycle.keptn.sh/v1beta1", + APIVersion: "lifecycle.keptn.sh/v1", }, - ObjectMeta: v1.ObjectMeta{ + ObjectMeta: metav1.ObjectMeta{ Name: "some-keptn-app-name", Namespace: "", Labels: map[string]string{ @@ -145,8 +145,8 @@ func TestKeptnApp_ConvertTo(t *testing.T) { }, }, wantErr: false, - wantObj: &v1beta1.KeptnApp{ - ObjectMeta: v1.ObjectMeta{ + wantObj: &v1.KeptnApp{ + ObjectMeta: metav1.ObjectMeta{ Name: "some-keptn-app-name", Namespace: "", Labels: map[string]string{ @@ -156,10 +156,10 @@ func TestKeptnApp_ConvertTo(t *testing.T) { "some-annotation": "some-annotation-value", }, }, - Spec: v1beta1.KeptnAppSpec{ + Spec: v1.KeptnAppSpec{ Version: "1.2.3", Revision: 1, - Workloads: []v1beta1.KeptnWorkloadRef{ + Workloads: []v1.KeptnWorkloadRef{ { Name: "workload-1", Version: "1.2.3", @@ -170,7 +170,7 @@ func TestKeptnApp_ConvertTo(t *testing.T) { }, }, }, - Status: v1beta1.KeptnAppStatus{ + Status: v1.KeptnAppStatus{ CurrentVersion: "1.2.3", }, }, @@ -178,11 +178,11 @@ func TestKeptnApp_ConvertTo(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - dst := v1beta1.KeptnApp{ - TypeMeta: v1.TypeMeta{}, - ObjectMeta: v1.ObjectMeta{}, - Spec: v1beta1.KeptnAppSpec{}, - Status: v1beta1.KeptnAppStatus{}, + dst := v1.KeptnApp{ + TypeMeta: metav1.TypeMeta{}, + ObjectMeta: metav1.ObjectMeta{}, + Spec: v1.KeptnAppSpec{}, + Status: v1.KeptnAppStatus{}, } if err := tt.src.ConvertTo(&dst); (err != nil) != tt.wantErr { t.Errorf("ConvertTo() error = %v, wantErr %v", err, tt.wantErr) @@ -199,8 +199,8 @@ func TestKeptnApp_ConvertFrom_Errorcase(t *testing.T) { testObj := v2.ExternalJob{} dst := &KeptnApp{ - TypeMeta: v1.TypeMeta{}, - ObjectMeta: v1.ObjectMeta{}, + TypeMeta: metav1.TypeMeta{}, + ObjectMeta: metav1.ObjectMeta{}, Spec: KeptnAppSpec{}, Status: KeptnAppStatus{}, } diff --git a/lifecycle-operator/apis/lifecycle/v1alpha3/keptnappversion_conversion.go b/lifecycle-operator/apis/lifecycle/v1alpha3/keptnappversion_conversion.go index b45079e201..632442c9d7 100644 --- a/lifecycle-operator/apis/lifecycle/v1alpha3/keptnappversion_conversion.go +++ b/lifecycle-operator/apis/lifecycle/v1alpha3/keptnappversion_conversion.go @@ -3,18 +3,18 @@ package v1alpha3 import ( "fmt" + v1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1" + v1common "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1/common" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3/common" - "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" - v1beta1common "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" "go.opentelemetry.io/otel/propagation" "sigs.k8s.io/controller-runtime/pkg/conversion" ) -// ConvertTo converts the src v1alpha3.KeptnAppVersion to the hub version (v1beta1.KeptnAppVersion) +// ConvertTo converts the src v1alpha3.KeptnAppVersion to the hub version (v1.KeptnAppVersion) // //nolint:gocyclo func (src *KeptnAppVersion) ConvertTo(dstRaw conversion.Hub) error { - dst, ok := dstRaw.(*v1beta1.KeptnAppVersion) + dst, ok := dstRaw.(*v1.KeptnAppVersion) if !ok { return fmt.Errorf("type %T %w", dstRaw, common.ErrCannotCastKeptnAppVersion) @@ -26,7 +26,7 @@ func (src *KeptnAppVersion) ConvertTo(dstRaw conversion.Hub) error { dst.Spec.Version = src.Spec.Version for _, srcWl := range src.Spec.Workloads { - dst.Spec.Workloads = append(dst.Spec.Workloads, v1beta1.KeptnWorkloadRef{ + dst.Spec.Workloads = append(dst.Spec.Workloads, v1.KeptnWorkloadRef{ Name: srcWl.Name, Version: srcWl.Version, }) @@ -44,20 +44,20 @@ func (src *KeptnAppVersion) ConvertTo(dstRaw conversion.Hub) error { dst.Spec.TraceId[k] = v } - dst.Status.PreDeploymentStatus = v1beta1common.KeptnState(src.Status.PreDeploymentStatus) - dst.Status.PostDeploymentStatus = v1beta1common.KeptnState(src.Status.PostDeploymentStatus) - dst.Status.PreDeploymentEvaluationStatus = v1beta1common.KeptnState(src.Status.PreDeploymentEvaluationStatus) - dst.Status.PostDeploymentEvaluationStatus = v1beta1common.KeptnState(src.Status.PostDeploymentEvaluationStatus) - dst.Status.WorkloadOverallStatus = v1beta1common.KeptnState(src.Status.WorkloadOverallStatus) - dst.Status.Status = v1beta1common.KeptnState(src.Status.Status) + dst.Status.PreDeploymentStatus = v1common.KeptnState(src.Status.PreDeploymentStatus) + dst.Status.PostDeploymentStatus = v1common.KeptnState(src.Status.PostDeploymentStatus) + dst.Status.PreDeploymentEvaluationStatus = v1common.KeptnState(src.Status.PreDeploymentEvaluationStatus) + dst.Status.PostDeploymentEvaluationStatus = v1common.KeptnState(src.Status.PostDeploymentEvaluationStatus) + dst.Status.WorkloadOverallStatus = v1common.KeptnState(src.Status.WorkloadOverallStatus) + dst.Status.Status = v1common.KeptnState(src.Status.Status) for _, srcWls := range src.Status.WorkloadStatus { - dst.Status.WorkloadStatus = append(dst.Status.WorkloadStatus, v1beta1.WorkloadStatus{ - Workload: v1beta1.KeptnWorkloadRef{ + dst.Status.WorkloadStatus = append(dst.Status.WorkloadStatus, v1.WorkloadStatus{ + Workload: v1.KeptnWorkloadRef{ Name: srcWls.Workload.Name, Version: srcWls.Workload.Version, }, - Status: v1beta1common.KeptnState(srcWls.Status), + Status: v1common.KeptnState(srcWls.Status), }) } @@ -68,9 +68,9 @@ func (src *KeptnAppVersion) ConvertTo(dstRaw conversion.Hub) error { // Convert changed fields for _, item := range src.Status.PreDeploymentTaskStatus { - dst.Status.PreDeploymentTaskStatus = append(dst.Status.PreDeploymentTaskStatus, v1beta1.ItemStatus{ + dst.Status.PreDeploymentTaskStatus = append(dst.Status.PreDeploymentTaskStatus, v1.ItemStatus{ DefinitionName: item.DefinitionName, - Status: v1beta1common.KeptnState(item.Status), + Status: v1common.KeptnState(item.Status), Name: item.Name, StartTime: item.StartTime, EndTime: item.EndTime, @@ -78,9 +78,9 @@ func (src *KeptnAppVersion) ConvertTo(dstRaw conversion.Hub) error { } for _, item := range src.Status.PostDeploymentTaskStatus { - dst.Status.PostDeploymentTaskStatus = append(dst.Status.PostDeploymentTaskStatus, v1beta1.ItemStatus{ + dst.Status.PostDeploymentTaskStatus = append(dst.Status.PostDeploymentTaskStatus, v1.ItemStatus{ DefinitionName: item.DefinitionName, - Status: v1beta1common.KeptnState(item.Status), + Status: v1common.KeptnState(item.Status), Name: item.Name, StartTime: item.StartTime, EndTime: item.EndTime, @@ -88,9 +88,9 @@ func (src *KeptnAppVersion) ConvertTo(dstRaw conversion.Hub) error { } for _, item := range src.Status.PreDeploymentEvaluationTaskStatus { - dst.Status.PreDeploymentEvaluationTaskStatus = append(dst.Status.PreDeploymentEvaluationTaskStatus, v1beta1.ItemStatus{ + dst.Status.PreDeploymentEvaluationTaskStatus = append(dst.Status.PreDeploymentEvaluationTaskStatus, v1.ItemStatus{ DefinitionName: item.DefinitionName, - Status: v1beta1common.KeptnState(item.Status), + Status: v1common.KeptnState(item.Status), Name: item.Name, StartTime: item.StartTime, EndTime: item.EndTime, @@ -98,16 +98,16 @@ func (src *KeptnAppVersion) ConvertTo(dstRaw conversion.Hub) error { } for _, item := range src.Status.PostDeploymentEvaluationTaskStatus { - dst.Status.PostDeploymentEvaluationTaskStatus = append(dst.Status.PostDeploymentEvaluationTaskStatus, v1beta1.ItemStatus{ + dst.Status.PostDeploymentEvaluationTaskStatus = append(dst.Status.PostDeploymentEvaluationTaskStatus, v1.ItemStatus{ DefinitionName: item.DefinitionName, - Status: v1beta1common.KeptnState(item.Status), + Status: v1common.KeptnState(item.Status), Name: item.Name, StartTime: item.StartTime, EndTime: item.EndTime, }) } - dst.Status.PhaseTraceIDs = make(v1beta1common.PhaseTraceID, len(src.Status.PhaseTraceIDs)) + dst.Status.PhaseTraceIDs = make(v1common.PhaseTraceID, len(src.Status.PhaseTraceIDs)) for k, v := range src.Status.PhaseTraceIDs { c := make(propagation.MapCarrier, len(v)) for k1, v1 := range v { @@ -122,11 +122,11 @@ func (src *KeptnAppVersion) ConvertTo(dstRaw conversion.Hub) error { return nil } -// ConvertFrom converts from the hub version (v1beta1.KeptnAppVersion) to this version (v1alpha3.KeptnAppVersion) +// ConvertFrom converts from the hub version (v1.KeptnAppVersion) to this version (v1alpha3.KeptnAppVersion) // //nolint:gocyclo func (dst *KeptnAppVersion) ConvertFrom(srcRaw conversion.Hub) error { - src, ok := srcRaw.(*v1beta1.KeptnAppVersion) + src, ok := srcRaw.(*v1.KeptnAppVersion) if !ok { return fmt.Errorf("type %T %w", srcRaw, common.ErrCannotCastKeptnAppVersion) diff --git a/lifecycle-operator/apis/lifecycle/v1alpha3/keptnappversion_conversion_test.go b/lifecycle-operator/apis/lifecycle/v1alpha3/keptnappversion_conversion_test.go index cb897f329b..f5ad67d49a 100644 --- a/lifecycle-operator/apis/lifecycle/v1alpha3/keptnappversion_conversion_test.go +++ b/lifecycle-operator/apis/lifecycle/v1alpha3/keptnappversion_conversion_test.go @@ -4,30 +4,30 @@ package v1alpha3 import ( "testing" + v1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1" + v1common "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1/common" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3/common" - "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" - v1beta1common "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" "github.com/stretchr/testify/require" "go.opentelemetry.io/otel/propagation" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" v2 "sigs.k8s.io/controller-runtime/pkg/webhook/conversion/testdata/api/v2" ) func TestKeptnAppVersion_ConvertFrom(t *testing.T) { tests := []struct { name string - srcObj *v1beta1.KeptnAppVersion + srcObj *v1.KeptnAppVersion wantErr bool wantObj *KeptnAppVersion }{ { - name: "Test that conversion from v1beta1 to v1alpha3 works", - srcObj: &v1beta1.KeptnAppVersion{ - TypeMeta: v1.TypeMeta{ + name: "Test that conversion from v1 to v1alpha3 works", + srcObj: &v1.KeptnAppVersion{ + TypeMeta: metav1.TypeMeta{ Kind: "KeptnAppVersion", - APIVersion: "lifecycle.keptn.sh/v1beta1", + APIVersion: "lifecycle.keptn.sh/v1", }, - ObjectMeta: v1.ObjectMeta{ + ObjectMeta: metav1.ObjectMeta{ Name: "some-keptn-app-name", Namespace: "", Labels: map[string]string{ @@ -37,11 +37,11 @@ func TestKeptnAppVersion_ConvertFrom(t *testing.T) { "some-annotation": "some-annotation-value", }, }, - Spec: v1beta1.KeptnAppVersionSpec{ - KeptnAppSpec: v1beta1.KeptnAppSpec{ + Spec: v1.KeptnAppVersionSpec{ + KeptnAppSpec: v1.KeptnAppSpec{ Version: "1.2.3", Revision: 1, - Workloads: []v1beta1.KeptnWorkloadRef{ + Workloads: []v1.KeptnWorkloadRef{ { Name: "workload-1", Version: "1.2.3", @@ -52,8 +52,8 @@ func TestKeptnAppVersion_ConvertFrom(t *testing.T) { }, }, }, - KeptnAppContextSpec: v1beta1.KeptnAppContextSpec{ - DeploymentTaskSpec: v1beta1.DeploymentTaskSpec{ + KeptnAppContextSpec: v1.KeptnAppContextSpec{ + DeploymentTaskSpec: v1.DeploymentTaskSpec{ PreDeploymentTasks: []string{ "some-pre-deployment-task1", }, @@ -75,78 +75,78 @@ func TestKeptnAppVersion_ConvertFrom(t *testing.T) { "key2": "value2", }, }, - Status: v1beta1.KeptnAppVersionStatus{ - PreDeploymentStatus: v1beta1common.StateFailed, - PostDeploymentStatus: v1beta1common.StateFailed, - PreDeploymentEvaluationStatus: v1beta1common.StateFailed, - PostDeploymentEvaluationStatus: v1beta1common.StateFailed, - WorkloadOverallStatus: v1beta1common.StateFailed, - WorkloadStatus: []v1beta1.WorkloadStatus{ - { - Workload: v1beta1.KeptnWorkloadRef{ + Status: v1.KeptnAppVersionStatus{ + PreDeploymentStatus: v1common.StateFailed, + PostDeploymentStatus: v1common.StateFailed, + PreDeploymentEvaluationStatus: v1common.StateFailed, + PostDeploymentEvaluationStatus: v1common.StateFailed, + WorkloadOverallStatus: v1common.StateFailed, + WorkloadStatus: []v1.WorkloadStatus{ + { + Workload: v1.KeptnWorkloadRef{ Name: "name1", Version: "1", }, - Status: v1beta1common.StateFailed, + Status: v1common.StateFailed, }, { - Workload: v1beta1.KeptnWorkloadRef{ + Workload: v1.KeptnWorkloadRef{ Name: "name2", Version: "2", }, - Status: v1beta1common.StateFailed, + Status: v1common.StateFailed, }, }, CurrentPhase: "phase", - PreDeploymentTaskStatus: []v1beta1.ItemStatus{ + PreDeploymentTaskStatus: []v1.ItemStatus{ { DefinitionName: "def1", Name: "name1", - Status: v1beta1common.StateFailed, + Status: v1common.StateFailed, }, { DefinitionName: "def12", Name: "name12", - Status: v1beta1common.StateFailed, + Status: v1common.StateFailed, }, }, - PostDeploymentTaskStatus: []v1beta1.ItemStatus{ + PostDeploymentTaskStatus: []v1.ItemStatus{ { DefinitionName: "def2", Name: "name2", - Status: v1beta1common.StateFailed, + Status: v1common.StateFailed, }, { DefinitionName: "def22", Name: "name22", - Status: v1beta1common.StateFailed, + Status: v1common.StateFailed, }, }, - PreDeploymentEvaluationTaskStatus: []v1beta1.ItemStatus{ + PreDeploymentEvaluationTaskStatus: []v1.ItemStatus{ { DefinitionName: "def3", Name: "name3", - Status: v1beta1common.StateFailed, + Status: v1common.StateFailed, }, { DefinitionName: "def32", Name: "name32", - Status: v1beta1common.StateFailed, + Status: v1common.StateFailed, }, }, - PostDeploymentEvaluationTaskStatus: []v1beta1.ItemStatus{ + PostDeploymentEvaluationTaskStatus: []v1.ItemStatus{ { DefinitionName: "def4", Name: "name4", - Status: v1beta1common.StateFailed, + Status: v1common.StateFailed, }, { DefinitionName: "def42", Name: "name42", - Status: v1beta1common.StateFailed, + Status: v1common.StateFailed, }, }, - PhaseTraceIDs: v1beta1common.PhaseTraceID{ + PhaseTraceIDs: v1common.PhaseTraceID{ "key": propagation.MapCarrier{ "key1": "value1", "key2": "value2", @@ -156,12 +156,12 @@ func TestKeptnAppVersion_ConvertFrom(t *testing.T) { "key222": "value222", }, }, - Status: v1beta1common.StateFailed, + Status: v1common.StateFailed, }, }, wantErr: false, wantObj: &KeptnAppVersion{ - ObjectMeta: v1.ObjectMeta{ + ObjectMeta: metav1.ObjectMeta{ Name: "some-keptn-app-name", Namespace: "", Labels: map[string]string{ @@ -294,8 +294,8 @@ func TestKeptnAppVersion_ConvertFrom(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { dst := &KeptnAppVersion{ - TypeMeta: v1.TypeMeta{}, - ObjectMeta: v1.ObjectMeta{}, + TypeMeta: metav1.TypeMeta{}, + ObjectMeta: metav1.ObjectMeta{}, Spec: KeptnAppVersionSpec{}, Status: KeptnAppVersionStatus{}, } @@ -314,16 +314,16 @@ func TestKeptnAppVersion_ConvertTo(t *testing.T) { name string src *KeptnAppVersion wantErr bool - wantObj *v1beta1.KeptnAppVersion + wantObj *v1.KeptnAppVersion }{ { - name: "Test that conversion from v1beta1 to v1alpha3 works", + name: "Test that conversion from v1 to v1alpha3 works", src: &KeptnAppVersion{ - TypeMeta: v1.TypeMeta{ + TypeMeta: metav1.TypeMeta{ Kind: "KeptnAppVersion", APIVersion: "lifecycle.keptn.sh/v1alpha3", }, - ObjectMeta: v1.ObjectMeta{ + ObjectMeta: metav1.ObjectMeta{ Name: "some-keptn-app-name", Namespace: "", Labels: map[string]string{ @@ -452,8 +452,8 @@ func TestKeptnAppVersion_ConvertTo(t *testing.T) { }, }, wantErr: false, - wantObj: &v1beta1.KeptnAppVersion{ - ObjectMeta: v1.ObjectMeta{ + wantObj: &v1.KeptnAppVersion{ + ObjectMeta: metav1.ObjectMeta{ Name: "some-keptn-app-name", Namespace: "", Labels: map[string]string{ @@ -463,11 +463,11 @@ func TestKeptnAppVersion_ConvertTo(t *testing.T) { "some-annotation": "some-annotation-value", }, }, - Spec: v1beta1.KeptnAppVersionSpec{ - KeptnAppSpec: v1beta1.KeptnAppSpec{ + Spec: v1.KeptnAppVersionSpec{ + KeptnAppSpec: v1.KeptnAppSpec{ Version: "1.2.3", Revision: 1, - Workloads: []v1beta1.KeptnWorkloadRef{ + Workloads: []v1.KeptnWorkloadRef{ { Name: "workload-1", Version: "1.2.3", @@ -478,8 +478,8 @@ func TestKeptnAppVersion_ConvertTo(t *testing.T) { }, }, }, - KeptnAppContextSpec: v1beta1.KeptnAppContextSpec{ - DeploymentTaskSpec: v1beta1.DeploymentTaskSpec{ + KeptnAppContextSpec: v1.KeptnAppContextSpec{ + DeploymentTaskSpec: v1.DeploymentTaskSpec{ PreDeploymentTasks: []string{ "some-pre-deployment-task1", }, @@ -501,78 +501,78 @@ func TestKeptnAppVersion_ConvertTo(t *testing.T) { "key2": "value2", }, }, - Status: v1beta1.KeptnAppVersionStatus{ - PreDeploymentStatus: v1beta1common.StateFailed, - PostDeploymentStatus: v1beta1common.StateFailed, - PreDeploymentEvaluationStatus: v1beta1common.StateFailed, - PostDeploymentEvaluationStatus: v1beta1common.StateFailed, - WorkloadOverallStatus: v1beta1common.StateFailed, - WorkloadStatus: []v1beta1.WorkloadStatus{ - { - Workload: v1beta1.KeptnWorkloadRef{ + Status: v1.KeptnAppVersionStatus{ + PreDeploymentStatus: v1common.StateFailed, + PostDeploymentStatus: v1common.StateFailed, + PreDeploymentEvaluationStatus: v1common.StateFailed, + PostDeploymentEvaluationStatus: v1common.StateFailed, + WorkloadOverallStatus: v1common.StateFailed, + WorkloadStatus: []v1.WorkloadStatus{ + { + Workload: v1.KeptnWorkloadRef{ Name: "name1", Version: "1", }, - Status: v1beta1common.StateFailed, + Status: v1common.StateFailed, }, { - Workload: v1beta1.KeptnWorkloadRef{ + Workload: v1.KeptnWorkloadRef{ Name: "name2", Version: "2", }, - Status: v1beta1common.StateFailed, + Status: v1common.StateFailed, }, }, CurrentPhase: "phase", - PreDeploymentTaskStatus: []v1beta1.ItemStatus{ + PreDeploymentTaskStatus: []v1.ItemStatus{ { DefinitionName: "def1", Name: "name1", - Status: v1beta1common.StateFailed, + Status: v1common.StateFailed, }, { DefinitionName: "def12", Name: "name12", - Status: v1beta1common.StateFailed, + Status: v1common.StateFailed, }, }, - PostDeploymentTaskStatus: []v1beta1.ItemStatus{ + PostDeploymentTaskStatus: []v1.ItemStatus{ { DefinitionName: "def2", Name: "name2", - Status: v1beta1common.StateFailed, + Status: v1common.StateFailed, }, { DefinitionName: "def22", Name: "name22", - Status: v1beta1common.StateFailed, + Status: v1common.StateFailed, }, }, - PreDeploymentEvaluationTaskStatus: []v1beta1.ItemStatus{ + PreDeploymentEvaluationTaskStatus: []v1.ItemStatus{ { DefinitionName: "def3", Name: "name3", - Status: v1beta1common.StateFailed, + Status: v1common.StateFailed, }, { DefinitionName: "def32", Name: "name32", - Status: v1beta1common.StateFailed, + Status: v1common.StateFailed, }, }, - PostDeploymentEvaluationTaskStatus: []v1beta1.ItemStatus{ + PostDeploymentEvaluationTaskStatus: []v1.ItemStatus{ { DefinitionName: "def4", Name: "name4", - Status: v1beta1common.StateFailed, + Status: v1common.StateFailed, }, { DefinitionName: "def42", Name: "name42", - Status: v1beta1common.StateFailed, + Status: v1common.StateFailed, }, }, - PhaseTraceIDs: v1beta1common.PhaseTraceID{ + PhaseTraceIDs: v1common.PhaseTraceID{ "key": propagation.MapCarrier{ "key1": "value1", "key2": "value2", @@ -582,18 +582,18 @@ func TestKeptnAppVersion_ConvertTo(t *testing.T) { "key222": "value222", }, }, - Status: v1beta1common.StateFailed, + Status: v1common.StateFailed, }, }, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - dst := v1beta1.KeptnAppVersion{ - TypeMeta: v1.TypeMeta{}, - ObjectMeta: v1.ObjectMeta{}, - Spec: v1beta1.KeptnAppVersionSpec{}, - Status: v1beta1.KeptnAppVersionStatus{}, + dst := v1.KeptnAppVersion{ + TypeMeta: metav1.TypeMeta{}, + ObjectMeta: metav1.ObjectMeta{}, + Spec: v1.KeptnAppVersionSpec{}, + Status: v1.KeptnAppVersionStatus{}, } if err := tt.src.ConvertTo(&dst); (err != nil) != tt.wantErr { t.Errorf("ConvertTo() error = %v, wantErr %v", err, tt.wantErr) @@ -610,8 +610,8 @@ func TestKeptnAppVersion_ConvertFrom_Errorcase(t *testing.T) { testObj := v2.ExternalJob{} dst := &KeptnAppVersion{ - TypeMeta: v1.TypeMeta{}, - ObjectMeta: v1.ObjectMeta{}, + TypeMeta: metav1.TypeMeta{}, + ObjectMeta: metav1.ObjectMeta{}, Spec: KeptnAppVersionSpec{}, Status: KeptnAppVersionStatus{}, } diff --git a/lifecycle-operator/apis/lifecycle/v1beta1/common/common.go b/lifecycle-operator/apis/lifecycle/v1beta1/common/common.go index 40bddcdcd5..5c91b6ca12 100644 --- a/lifecycle-operator/apis/lifecycle/v1beta1/common/common.go +++ b/lifecycle-operator/apis/lifecycle/v1beta1/common/common.go @@ -6,6 +6,7 @@ package common import ( "crypto/sha256" "encoding/hex" + "errors" "math/rand" "strconv" @@ -48,6 +49,9 @@ const ( AppTypeMultiService AppType = "multi-service" ) +var ErrCannotCastKeptnAppVersion = errors.New("cannot cast KeptnAppVersion to v1") +var ErrCannotCastKeptnApp = errors.New("cannot cast KeptnApp to v1") + // KeptnState is a string containing current Phase state (Progressing/Succeeded/Failed/Unknown/Pending/Deprecated/Warning) type KeptnState string diff --git a/lifecycle-operator/apis/lifecycle/v1beta1/keptnapp_conversion.go b/lifecycle-operator/apis/lifecycle/v1beta1/keptnapp_conversion.go index 946767780b..71e7b7b73d 100644 --- a/lifecycle-operator/apis/lifecycle/v1beta1/keptnapp_conversion.go +++ b/lifecycle-operator/apis/lifecycle/v1beta1/keptnapp_conversion.go @@ -1,6 +1,63 @@ package v1beta1 -// Hub is the stub function to make the API conversion pattern with hub and spokes complete -func (*KeptnApp) Hub() { - // Hub() needed to implement interface +import ( + "fmt" + + v1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1" + "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" + "sigs.k8s.io/controller-runtime/pkg/conversion" +) + +// ConvertTo converts the src v1beta1.KeptnApp to the hub version (v1.KeptnApp) +func (src *KeptnApp) ConvertTo(dstRaw conversion.Hub) error { + dst, ok := dstRaw.(*v1.KeptnApp) + + if !ok { + return fmt.Errorf("type %T %w", dstRaw, common.ErrCannotCastKeptnApp) + } + + // Copy equal stuff to new object + // DO NOT COPY TypeMeta + dst.ObjectMeta = src.ObjectMeta + + dst.Spec.Version = src.Spec.Version + for _, srcWl := range src.Spec.Workloads { + dst.Spec.Workloads = append(dst.Spec.Workloads, v1.KeptnWorkloadRef{ + Name: srcWl.Name, + Version: srcWl.Version, + }) + } + + dst.Status.CurrentVersion = src.Status.CurrentVersion + + dst.Spec.Revision = src.Spec.Revision + + return nil +} + +// ConvertFrom converts from the hub version (v1.KeptnApp) to this version (v1beta1.KeptnApp) +func (dst *KeptnApp) ConvertFrom(srcRaw conversion.Hub) error { + src, ok := srcRaw.(*v1.KeptnApp) + + if !ok { + return fmt.Errorf("type %T %w", srcRaw, common.ErrCannotCastKeptnApp) + } + + // Copy equal stuff to new object + // DO NOT COPY TypeMeta + dst.ObjectMeta = src.ObjectMeta + + dst.Spec.Version = src.Spec.Version + for _, srcWl := range src.Spec.Workloads { + dst.Spec.Workloads = append(dst.Spec.Workloads, KeptnWorkloadRef{ + Name: srcWl.Name, + Version: srcWl.Version, + }) + } + + dst.Status.CurrentVersion = src.Status.CurrentVersion + + dst.Spec.Revision = src.Spec.Revision + + return nil } diff --git a/lifecycle-operator/apis/lifecycle/v1/keptnapp_conversion_test.go b/lifecycle-operator/apis/lifecycle/v1beta1/keptnapp_conversion_test.go similarity index 82% rename from lifecycle-operator/apis/lifecycle/v1/keptnapp_conversion_test.go rename to lifecycle-operator/apis/lifecycle/v1beta1/keptnapp_conversion_test.go index 7e23561418..c488453b09 100644 --- a/lifecycle-operator/apis/lifecycle/v1/keptnapp_conversion_test.go +++ b/lifecycle-operator/apis/lifecycle/v1beta1/keptnapp_conversion_test.go @@ -1,30 +1,30 @@ -package v1 +package v1beta1 import ( "testing" - "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1/common" - "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" + v1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1" + "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" "github.com/stretchr/testify/require" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" v2 "sigs.k8s.io/controller-runtime/pkg/webhook/conversion/testdata/api/v2" ) func TestKeptnApp_ConvertFrom(t *testing.T) { tests := []struct { name string - srcObj *v1beta1.KeptnApp + srcObj *v1.KeptnApp wantErr bool wantObj *KeptnApp }{ { name: "Test that conversion from v1beta1 to v1 works", - srcObj: &v1beta1.KeptnApp{ - TypeMeta: v1.TypeMeta{ + srcObj: &v1.KeptnApp{ + TypeMeta: metav1.TypeMeta{ Kind: "KeptnApp", APIVersion: "lifecycle.keptn.sh/v1beta1", }, - ObjectMeta: v1.ObjectMeta{ + ObjectMeta: metav1.ObjectMeta{ Name: "some-keptn-app-name", Namespace: "", Labels: map[string]string{ @@ -34,10 +34,10 @@ func TestKeptnApp_ConvertFrom(t *testing.T) { "some-annotation": "some-annotation-value", }, }, - Spec: v1beta1.KeptnAppSpec{ + Spec: v1.KeptnAppSpec{ Version: "1.2.3", Revision: 1, - Workloads: []v1beta1.KeptnWorkloadRef{ + Workloads: []v1.KeptnWorkloadRef{ { Name: "workload-1", Version: "1.2.3", @@ -48,13 +48,13 @@ func TestKeptnApp_ConvertFrom(t *testing.T) { }, }, }, - Status: v1beta1.KeptnAppStatus{ + Status: v1.KeptnAppStatus{ CurrentVersion: "1.2.3", }, }, wantErr: false, wantObj: &KeptnApp{ - ObjectMeta: v1.ObjectMeta{ + ObjectMeta: metav1.ObjectMeta{ Name: "some-keptn-app-name", Namespace: "", Labels: map[string]string{ @@ -87,8 +87,8 @@ func TestKeptnApp_ConvertFrom(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { dst := &KeptnApp{ - TypeMeta: v1.TypeMeta{}, - ObjectMeta: v1.ObjectMeta{}, + TypeMeta: metav1.TypeMeta{}, + ObjectMeta: metav1.ObjectMeta{}, Spec: KeptnAppSpec{}, Status: KeptnAppStatus{}, } @@ -107,16 +107,16 @@ func TestKeptnApp_ConvertTo(t *testing.T) { name string src *KeptnApp wantErr bool - wantObj *v1beta1.KeptnApp + wantObj *v1.KeptnApp }{ { name: "Test that conversion from v1 to v1beta1 works", src: &KeptnApp{ - TypeMeta: v1.TypeMeta{ + TypeMeta: metav1.TypeMeta{ Kind: "KeptnApp", APIVersion: "lifecycle.keptn.sh/v1beta1", }, - ObjectMeta: v1.ObjectMeta{ + ObjectMeta: metav1.ObjectMeta{ Name: "some-keptn-app-name", Namespace: "", Labels: map[string]string{ @@ -145,8 +145,8 @@ func TestKeptnApp_ConvertTo(t *testing.T) { }, }, wantErr: false, - wantObj: &v1beta1.KeptnApp{ - ObjectMeta: v1.ObjectMeta{ + wantObj: &v1.KeptnApp{ + ObjectMeta: metav1.ObjectMeta{ Name: "some-keptn-app-name", Namespace: "", Labels: map[string]string{ @@ -156,10 +156,10 @@ func TestKeptnApp_ConvertTo(t *testing.T) { "some-annotation": "some-annotation-value", }, }, - Spec: v1beta1.KeptnAppSpec{ + Spec: v1.KeptnAppSpec{ Version: "1.2.3", Revision: 1, - Workloads: []v1beta1.KeptnWorkloadRef{ + Workloads: []v1.KeptnWorkloadRef{ { Name: "workload-1", Version: "1.2.3", @@ -170,7 +170,7 @@ func TestKeptnApp_ConvertTo(t *testing.T) { }, }, }, - Status: v1beta1.KeptnAppStatus{ + Status: v1.KeptnAppStatus{ CurrentVersion: "1.2.3", }, }, @@ -178,11 +178,11 @@ func TestKeptnApp_ConvertTo(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - dst := v1beta1.KeptnApp{ - TypeMeta: v1.TypeMeta{}, - ObjectMeta: v1.ObjectMeta{}, - Spec: v1beta1.KeptnAppSpec{}, - Status: v1beta1.KeptnAppStatus{}, + dst := v1.KeptnApp{ + TypeMeta: metav1.TypeMeta{}, + ObjectMeta: metav1.ObjectMeta{}, + Spec: v1.KeptnAppSpec{}, + Status: v1.KeptnAppStatus{}, } if err := tt.src.ConvertTo(&dst); (err != nil) != tt.wantErr { t.Errorf("ConvertTo() error = %v, wantErr %v", err, tt.wantErr) @@ -199,8 +199,8 @@ func TestKeptnApp_ConvertFrom_Errorcase(t *testing.T) { testObj := v2.ExternalJob{} dst := &KeptnApp{ - TypeMeta: v1.TypeMeta{}, - ObjectMeta: v1.ObjectMeta{}, + TypeMeta: metav1.TypeMeta{}, + ObjectMeta: metav1.ObjectMeta{}, Spec: KeptnAppSpec{}, Status: KeptnAppStatus{}, } diff --git a/lifecycle-operator/apis/lifecycle/v1beta1/keptnapp_types.go b/lifecycle-operator/apis/lifecycle/v1beta1/keptnapp_types.go index 177d441d78..a1dc8ab148 100644 --- a/lifecycle-operator/apis/lifecycle/v1beta1/keptnapp_types.go +++ b/lifecycle-operator/apis/lifecycle/v1beta1/keptnapp_types.go @@ -59,7 +59,6 @@ type KeptnWorkloadRef struct { } // +kubebuilder:object:root=true -// +kubebuilder:storageversion // +kubebuilder:subresource:status // KeptnApp is the Schema for the keptnapps API diff --git a/lifecycle-operator/apis/lifecycle/v1beta1/keptnappcontext_types.go b/lifecycle-operator/apis/lifecycle/v1beta1/keptnappcontext_types.go index 76a1eb20dd..199f84698c 100644 --- a/lifecycle-operator/apis/lifecycle/v1beta1/keptnappcontext_types.go +++ b/lifecycle-operator/apis/lifecycle/v1beta1/keptnappcontext_types.go @@ -67,7 +67,6 @@ type KeptnAppContextStatus struct { } //+kubebuilder:object:root=true -//+kubebuilder:storageversion //+kubebuilder:subresource:status // KeptnAppContext is the Schema for the keptnappcontexts API diff --git a/lifecycle-operator/apis/lifecycle/v1beta1/keptnappcreationrequest_types.go b/lifecycle-operator/apis/lifecycle/v1beta1/keptnappcreationrequest_types.go index 9aa4ac385a..76cce4aed1 100644 --- a/lifecycle-operator/apis/lifecycle/v1beta1/keptnappcreationrequest_types.go +++ b/lifecycle-operator/apis/lifecycle/v1beta1/keptnappcreationrequest_types.go @@ -30,7 +30,6 @@ type KeptnAppCreationRequestSpec struct { } // +kubebuilder:object:root=true -// +kubebuilder:storageversion // +kubebuilder:subresource:status // KeptnAppCreationRequest is the Schema for the keptnappcreationrequests API diff --git a/lifecycle-operator/apis/lifecycle/v1beta1/keptnappversion_conversion.go b/lifecycle-operator/apis/lifecycle/v1beta1/keptnappversion_conversion.go index 4380e2bbd8..d35731f7d1 100644 --- a/lifecycle-operator/apis/lifecycle/v1beta1/keptnappversion_conversion.go +++ b/lifecycle-operator/apis/lifecycle/v1beta1/keptnappversion_conversion.go @@ -1,6 +1,259 @@ package v1beta1 -// Hub is the stub function to make the API conversion pattern with hub and spokes complete -func (*KeptnAppVersion) Hub() { - // Hub() needed to implement interface +import ( + "fmt" + + v1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1" + v1common "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1/common" + "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" + "go.opentelemetry.io/otel/propagation" + "sigs.k8s.io/controller-runtime/pkg/conversion" +) + +// ConvertTo converts the src v1.KeptnAppVersion to the hub version (v1.KeptnAppVersion) +// +//nolint:gocyclo +func (src *KeptnAppVersion) ConvertTo(dstRaw conversion.Hub) error { + dst, ok := dstRaw.(*v1.KeptnAppVersion) + + if !ok { + return fmt.Errorf("type %T %w", dstRaw, common.ErrCannotCastKeptnAppVersion) + } + + // Copy equal stuff to new object + // DO NOT COPY TypeMeta + dst.ObjectMeta = src.ObjectMeta + + dst.Spec.Version = src.Spec.Version + for _, srcWl := range src.Spec.Workloads { + dst.Spec.Workloads = append(dst.Spec.Workloads, v1.KeptnWorkloadRef{ + Name: srcWl.Name, + Version: srcWl.Version, + }) + } + dst.Spec.PreDeploymentTasks = src.Spec.PreDeploymentTasks + dst.Spec.PostDeploymentTasks = src.Spec.PostDeploymentTasks + dst.Spec.PreDeploymentEvaluations = src.Spec.PreDeploymentEvaluations + dst.Spec.PostDeploymentEvaluations = src.Spec.PostDeploymentEvaluations + dst.Spec.PromotionTasks = src.Spec.PromotionTasks + + dst.Spec.AppName = src.Spec.AppName + dst.Spec.PreviousVersion = src.Spec.PreviousVersion + + dst.Spec.TraceId = make(map[string]string, len(src.Spec.TraceId)) + for k, v := range src.Spec.TraceId { + dst.Spec.TraceId[k] = v + } + + dst.Status.PreDeploymentStatus = v1common.KeptnState(src.Status.PreDeploymentStatus) + dst.Status.PostDeploymentStatus = v1common.KeptnState(src.Status.PostDeploymentStatus) + dst.Status.PreDeploymentEvaluationStatus = v1common.KeptnState(src.Status.PreDeploymentEvaluationStatus) + dst.Status.PostDeploymentEvaluationStatus = v1common.KeptnState(src.Status.PostDeploymentEvaluationStatus) + dst.Status.WorkloadOverallStatus = v1common.KeptnState(src.Status.WorkloadOverallStatus) + dst.Status.PromotionStatus = v1common.KeptnState(src.Status.PromotionStatus) + dst.Status.Status = v1common.KeptnState(src.Status.Status) + + for _, srcWls := range src.Status.WorkloadStatus { + dst.Status.WorkloadStatus = append(dst.Status.WorkloadStatus, v1.WorkloadStatus{ + Workload: v1.KeptnWorkloadRef{ + Name: srcWls.Workload.Name, + Version: srcWls.Workload.Version, + }, + Status: v1common.KeptnState(srcWls.Status), + }) + } + + dst.Status.CurrentPhase = src.Status.CurrentPhase + + // Set sensible defaults for new fields + dst.Spec.Revision = src.Spec.Revision + + // Convert changed fields + for _, item := range src.Status.PreDeploymentTaskStatus { + dst.Status.PreDeploymentTaskStatus = append(dst.Status.PreDeploymentTaskStatus, v1.ItemStatus{ + DefinitionName: item.DefinitionName, + Status: v1common.KeptnState(item.Status), + Name: item.Name, + StartTime: item.StartTime, + EndTime: item.EndTime, + }) + } + + for _, item := range src.Status.PostDeploymentTaskStatus { + dst.Status.PostDeploymentTaskStatus = append(dst.Status.PostDeploymentTaskStatus, v1.ItemStatus{ + DefinitionName: item.DefinitionName, + Status: v1common.KeptnState(item.Status), + Name: item.Name, + StartTime: item.StartTime, + EndTime: item.EndTime, + }) + } + + for _, item := range src.Status.PreDeploymentEvaluationTaskStatus { + dst.Status.PreDeploymentEvaluationTaskStatus = append(dst.Status.PreDeploymentEvaluationTaskStatus, v1.ItemStatus{ + DefinitionName: item.DefinitionName, + Status: v1common.KeptnState(item.Status), + Name: item.Name, + StartTime: item.StartTime, + EndTime: item.EndTime, + }) + } + + for _, item := range src.Status.PostDeploymentEvaluationTaskStatus { + dst.Status.PostDeploymentEvaluationTaskStatus = append(dst.Status.PostDeploymentEvaluationTaskStatus, v1.ItemStatus{ + DefinitionName: item.DefinitionName, + Status: v1common.KeptnState(item.Status), + Name: item.Name, + StartTime: item.StartTime, + EndTime: item.EndTime, + }) + } + + for _, item := range src.Status.PromotionTaskStatus { + dst.Status.PromotionTaskStatus = append(dst.Status.PromotionTaskStatus, v1.ItemStatus{ + DefinitionName: item.DefinitionName, + Status: v1common.KeptnState(item.Status), + Name: item.Name, + StartTime: item.StartTime, + EndTime: item.EndTime, + }) + } + + dst.Status.PhaseTraceIDs = make(v1common.PhaseTraceID, len(src.Status.PhaseTraceIDs)) + for k, v := range src.Status.PhaseTraceIDs { + c := make(propagation.MapCarrier, len(v)) + for k1, v1 := range v { + c[k1] = v1 + } + dst.Status.PhaseTraceIDs[k] = c + } + + dst.Status.StartTime = src.Status.StartTime + dst.Status.EndTime = src.Status.EndTime + + return nil +} + +// ConvertFrom converts from the hub version (v1.KeptnAppVersion) to this version (v1.KeptnAppVersion) +// +//nolint:gocyclo +func (dst *KeptnAppVersion) ConvertFrom(srcRaw conversion.Hub) error { + src, ok := srcRaw.(*v1.KeptnAppVersion) + + if !ok { + return fmt.Errorf("type %T %w", srcRaw, common.ErrCannotCastKeptnAppVersion) + } + + // Copy equal stuff to new object + // DO NOT COPY TypeMeta + dst.ObjectMeta = src.ObjectMeta + + dst.Spec.Version = src.Spec.Version + for _, srcWl := range src.Spec.Workloads { + dst.Spec.Workloads = append(dst.Spec.Workloads, KeptnWorkloadRef{ + Name: srcWl.Name, + Version: srcWl.Version, + }) + } + dst.Spec.PreDeploymentTasks = src.Spec.PreDeploymentTasks + dst.Spec.PostDeploymentTasks = src.Spec.PostDeploymentTasks + dst.Spec.PreDeploymentEvaluations = src.Spec.PreDeploymentEvaluations + dst.Spec.PostDeploymentEvaluations = src.Spec.PostDeploymentEvaluations + dst.Spec.PromotionTasks = src.Spec.PromotionTasks + + dst.Spec.AppName = src.Spec.AppName + dst.Spec.PreviousVersion = src.Spec.PreviousVersion + + // Set sensible defaults for new fields + dst.Spec.Revision = src.Spec.Revision + + dst.Spec.TraceId = make(map[string]string, len(src.Spec.TraceId)) + for k, v := range src.Spec.TraceId { + dst.Spec.TraceId[k] = v + } + + dst.Status.PreDeploymentStatus = common.KeptnState(src.Status.PreDeploymentStatus) + dst.Status.PostDeploymentStatus = common.KeptnState(src.Status.PostDeploymentStatus) + dst.Status.PreDeploymentEvaluationStatus = common.KeptnState(src.Status.PreDeploymentEvaluationStatus) + dst.Status.PostDeploymentEvaluationStatus = common.KeptnState(src.Status.PostDeploymentEvaluationStatus) + dst.Status.WorkloadOverallStatus = common.KeptnState(src.Status.WorkloadOverallStatus) + dst.Status.PromotionStatus = common.KeptnState(src.Status.PromotionStatus) + dst.Status.Status = common.KeptnState(src.Status.Status) + + for _, srcWls := range src.Status.WorkloadStatus { + dst.Status.WorkloadStatus = append(dst.Status.WorkloadStatus, WorkloadStatus{ + Workload: KeptnWorkloadRef{ + Name: srcWls.Workload.Name, + Version: srcWls.Workload.Version, + }, + Status: common.KeptnState(srcWls.Status), + }) + } + + dst.Status.CurrentPhase = src.Status.CurrentPhase + + // Convert changed fields + for _, item := range src.Status.PreDeploymentTaskStatus { + dst.Status.PreDeploymentTaskStatus = append(dst.Status.PreDeploymentTaskStatus, ItemStatus{ + DefinitionName: item.DefinitionName, + Status: common.KeptnState(item.Status), + Name: item.Name, + StartTime: item.StartTime, + EndTime: item.EndTime, + }) + } + + for _, item := range src.Status.PostDeploymentTaskStatus { + dst.Status.PostDeploymentTaskStatus = append(dst.Status.PostDeploymentTaskStatus, ItemStatus{ + DefinitionName: item.DefinitionName, + Status: common.KeptnState(item.Status), + Name: item.Name, + StartTime: item.StartTime, + EndTime: item.EndTime, + }) + } + + for _, item := range src.Status.PreDeploymentEvaluationTaskStatus { + dst.Status.PreDeploymentEvaluationTaskStatus = append(dst.Status.PreDeploymentEvaluationTaskStatus, ItemStatus{ + DefinitionName: item.DefinitionName, + Status: common.KeptnState(item.Status), + Name: item.Name, + StartTime: item.StartTime, + EndTime: item.EndTime, + }) + } + + for _, item := range src.Status.PostDeploymentEvaluationTaskStatus { + dst.Status.PostDeploymentEvaluationTaskStatus = append(dst.Status.PostDeploymentEvaluationTaskStatus, ItemStatus{ + DefinitionName: item.DefinitionName, + Status: common.KeptnState(item.Status), + Name: item.Name, + StartTime: item.StartTime, + EndTime: item.EndTime, + }) + } + + for _, item := range src.Status.PromotionTaskStatus { + dst.Status.PromotionTaskStatus = append(dst.Status.PromotionTaskStatus, ItemStatus{ + DefinitionName: item.DefinitionName, + Status: common.KeptnState(item.Status), + Name: item.Name, + StartTime: item.StartTime, + EndTime: item.EndTime, + }) + } + + dst.Status.PhaseTraceIDs = make(common.PhaseTraceID, len(src.Status.PhaseTraceIDs)) + for k, v := range src.Status.PhaseTraceIDs { + c := make(propagation.MapCarrier, len(v)) + for k1, v1 := range v { + c[k1] = v1 + } + dst.Status.PhaseTraceIDs[k] = c + } + + dst.Status.StartTime = src.Status.StartTime + dst.Status.EndTime = src.Status.EndTime + + return nil } diff --git a/lifecycle-operator/apis/lifecycle/v1/keptnappversion_conversion_test.go b/lifecycle-operator/apis/lifecycle/v1beta1/keptnappversion_conversion_test.go similarity index 77% rename from lifecycle-operator/apis/lifecycle/v1/keptnappversion_conversion_test.go rename to lifecycle-operator/apis/lifecycle/v1beta1/keptnappversion_conversion_test.go index fafe8b1180..a9d79035e1 100644 --- a/lifecycle-operator/apis/lifecycle/v1/keptnappversion_conversion_test.go +++ b/lifecycle-operator/apis/lifecycle/v1beta1/keptnappversion_conversion_test.go @@ -1,33 +1,33 @@ //nolint:dupl -package v1 +package v1beta1 import ( "testing" - "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1/common" - "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" - v1beta1common "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" + v1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1" + v1common "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1/common" + "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" "github.com/stretchr/testify/require" "go.opentelemetry.io/otel/propagation" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" v2 "sigs.k8s.io/controller-runtime/pkg/webhook/conversion/testdata/api/v2" ) func TestKeptnAppVersion_ConvertFrom(t *testing.T) { tests := []struct { name string - srcObj *v1beta1.KeptnAppVersion + srcObj *v1.KeptnAppVersion wantErr bool wantObj *KeptnAppVersion }{ { name: "Test that conversion from v1beta1 to v1 works", - srcObj: &v1beta1.KeptnAppVersion{ - TypeMeta: v1.TypeMeta{ + srcObj: &v1.KeptnAppVersion{ + TypeMeta: metav1.TypeMeta{ Kind: "KeptnAppVersion", APIVersion: "lifecycle.keptn.sh/v1beta1", }, - ObjectMeta: v1.ObjectMeta{ + ObjectMeta: metav1.ObjectMeta{ Name: "some-keptn-app-name", Namespace: "", Labels: map[string]string{ @@ -37,11 +37,11 @@ func TestKeptnAppVersion_ConvertFrom(t *testing.T) { "some-annotation": "some-annotation-value", }, }, - Spec: v1beta1.KeptnAppVersionSpec{ - KeptnAppSpec: v1beta1.KeptnAppSpec{ + Spec: v1.KeptnAppVersionSpec{ + KeptnAppSpec: v1.KeptnAppSpec{ Version: "1.2.3", Revision: 1, - Workloads: []v1beta1.KeptnWorkloadRef{ + Workloads: []v1.KeptnWorkloadRef{ { Name: "workload-1", Version: "1.2.3", @@ -52,8 +52,8 @@ func TestKeptnAppVersion_ConvertFrom(t *testing.T) { }, }, }, - KeptnAppContextSpec: v1beta1.KeptnAppContextSpec{ - DeploymentTaskSpec: v1beta1.DeploymentTaskSpec{ + KeptnAppContextSpec: v1.KeptnAppContextSpec{ + DeploymentTaskSpec: v1.DeploymentTaskSpec{ PreDeploymentTasks: []string{ "some-pre-deployment-task1", }, @@ -78,91 +78,91 @@ func TestKeptnAppVersion_ConvertFrom(t *testing.T) { "key2": "value2", }, }, - Status: v1beta1.KeptnAppVersionStatus{ - PreDeploymentStatus: v1beta1common.StateFailed, - PostDeploymentStatus: v1beta1common.StateFailed, - PreDeploymentEvaluationStatus: v1beta1common.StateFailed, - PostDeploymentEvaluationStatus: v1beta1common.StateFailed, - WorkloadOverallStatus: v1beta1common.StateFailed, - PromotionStatus: v1beta1common.StateFailed, - WorkloadStatus: []v1beta1.WorkloadStatus{ - { - Workload: v1beta1.KeptnWorkloadRef{ + Status: v1.KeptnAppVersionStatus{ + PreDeploymentStatus: v1common.StateFailed, + PostDeploymentStatus: v1common.StateFailed, + PreDeploymentEvaluationStatus: v1common.StateFailed, + PostDeploymentEvaluationStatus: v1common.StateFailed, + WorkloadOverallStatus: v1common.StateFailed, + PromotionStatus: v1common.StateFailed, + WorkloadStatus: []v1.WorkloadStatus{ + { + Workload: v1.KeptnWorkloadRef{ Name: "name1", Version: "1", }, - Status: v1beta1common.StateFailed, + Status: v1common.StateFailed, }, { - Workload: v1beta1.KeptnWorkloadRef{ + Workload: v1.KeptnWorkloadRef{ Name: "name2", Version: "2", }, - Status: v1beta1common.StateFailed, + Status: v1common.StateFailed, }, }, CurrentPhase: "phase", - PreDeploymentTaskStatus: []v1beta1.ItemStatus{ + PreDeploymentTaskStatus: []v1.ItemStatus{ { DefinitionName: "def1", Name: "name1", - Status: v1beta1common.StateFailed, + Status: v1common.StateFailed, }, { DefinitionName: "def12", Name: "name12", - Status: v1beta1common.StateFailed, + Status: v1common.StateFailed, }, }, - PostDeploymentTaskStatus: []v1beta1.ItemStatus{ + PostDeploymentTaskStatus: []v1.ItemStatus{ { DefinitionName: "def2", Name: "name2", - Status: v1beta1common.StateFailed, + Status: v1common.StateFailed, }, { DefinitionName: "def22", Name: "name22", - Status: v1beta1common.StateFailed, + Status: v1common.StateFailed, }, }, - PreDeploymentEvaluationTaskStatus: []v1beta1.ItemStatus{ + PreDeploymentEvaluationTaskStatus: []v1.ItemStatus{ { DefinitionName: "def3", Name: "name3", - Status: v1beta1common.StateFailed, + Status: v1common.StateFailed, }, { DefinitionName: "def32", Name: "name32", - Status: v1beta1common.StateFailed, + Status: v1common.StateFailed, }, }, - PostDeploymentEvaluationTaskStatus: []v1beta1.ItemStatus{ + PostDeploymentEvaluationTaskStatus: []v1.ItemStatus{ { DefinitionName: "def4", Name: "name4", - Status: v1beta1common.StateFailed, + Status: v1common.StateFailed, }, { DefinitionName: "def42", Name: "name42", - Status: v1beta1common.StateFailed, + Status: v1common.StateFailed, }, }, - PromotionTaskStatus: []v1beta1.ItemStatus{ + PromotionTaskStatus: []v1.ItemStatus{ { DefinitionName: "def5", Name: "name5", - Status: v1beta1common.StateFailed, + Status: v1common.StateFailed, }, { DefinitionName: "def52", Name: "name52", - Status: v1beta1common.StateSucceeded, + Status: v1common.StateSucceeded, }, }, - PhaseTraceIDs: v1beta1common.PhaseTraceID{ + PhaseTraceIDs: v1common.PhaseTraceID{ "key": propagation.MapCarrier{ "key1": "value1", "key2": "value2", @@ -172,12 +172,12 @@ func TestKeptnAppVersion_ConvertFrom(t *testing.T) { "key222": "value222", }, }, - Status: v1beta1common.StateFailed, + Status: v1common.StateFailed, }, }, wantErr: false, wantObj: &KeptnAppVersion{ - ObjectMeta: v1.ObjectMeta{ + ObjectMeta: metav1.ObjectMeta{ Name: "some-keptn-app-name", Namespace: "", Labels: map[string]string{ @@ -330,8 +330,8 @@ func TestKeptnAppVersion_ConvertFrom(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { dst := &KeptnAppVersion{ - TypeMeta: v1.TypeMeta{}, - ObjectMeta: v1.ObjectMeta{}, + TypeMeta: metav1.TypeMeta{}, + ObjectMeta: metav1.ObjectMeta{}, Spec: KeptnAppVersionSpec{}, Status: KeptnAppVersionStatus{}, } @@ -350,16 +350,16 @@ func TestKeptnAppVersion_ConvertTo(t *testing.T) { name string src *KeptnAppVersion wantErr bool - wantObj *v1beta1.KeptnAppVersion + wantObj *v1.KeptnAppVersion }{ { name: "Test that conversion from v1beta1 to v1 works", src: &KeptnAppVersion{ - TypeMeta: v1.TypeMeta{ + TypeMeta: metav1.TypeMeta{ Kind: "KeptnAppVersion", APIVersion: "lifecycle.keptn.sh/v1", }, - ObjectMeta: v1.ObjectMeta{ + ObjectMeta: metav1.ObjectMeta{ Name: "some-keptn-app-name", Namespace: "", Labels: map[string]string{ @@ -508,8 +508,8 @@ func TestKeptnAppVersion_ConvertTo(t *testing.T) { }, }, wantErr: false, - wantObj: &v1beta1.KeptnAppVersion{ - ObjectMeta: v1.ObjectMeta{ + wantObj: &v1.KeptnAppVersion{ + ObjectMeta: metav1.ObjectMeta{ Name: "some-keptn-app-name", Namespace: "", Labels: map[string]string{ @@ -519,11 +519,11 @@ func TestKeptnAppVersion_ConvertTo(t *testing.T) { "some-annotation": "some-annotation-value", }, }, - Spec: v1beta1.KeptnAppVersionSpec{ - KeptnAppSpec: v1beta1.KeptnAppSpec{ + Spec: v1.KeptnAppVersionSpec{ + KeptnAppSpec: v1.KeptnAppSpec{ Version: "1.2.3", Revision: 1, - Workloads: []v1beta1.KeptnWorkloadRef{ + Workloads: []v1.KeptnWorkloadRef{ { Name: "workload-1", Version: "1.2.3", @@ -534,8 +534,8 @@ func TestKeptnAppVersion_ConvertTo(t *testing.T) { }, }, }, - KeptnAppContextSpec: v1beta1.KeptnAppContextSpec{ - DeploymentTaskSpec: v1beta1.DeploymentTaskSpec{ + KeptnAppContextSpec: v1.KeptnAppContextSpec{ + DeploymentTaskSpec: v1.DeploymentTaskSpec{ PreDeploymentTasks: []string{ "some-pre-deployment-task1", }, @@ -560,91 +560,91 @@ func TestKeptnAppVersion_ConvertTo(t *testing.T) { "key2": "value2", }, }, - Status: v1beta1.KeptnAppVersionStatus{ - PreDeploymentStatus: v1beta1common.StateFailed, - PostDeploymentStatus: v1beta1common.StateFailed, - PreDeploymentEvaluationStatus: v1beta1common.StateFailed, - PostDeploymentEvaluationStatus: v1beta1common.StateFailed, - WorkloadOverallStatus: v1beta1common.StateFailed, - PromotionStatus: v1beta1common.StateFailed, - WorkloadStatus: []v1beta1.WorkloadStatus{ - { - Workload: v1beta1.KeptnWorkloadRef{ + Status: v1.KeptnAppVersionStatus{ + PreDeploymentStatus: v1common.StateFailed, + PostDeploymentStatus: v1common.StateFailed, + PreDeploymentEvaluationStatus: v1common.StateFailed, + PostDeploymentEvaluationStatus: v1common.StateFailed, + WorkloadOverallStatus: v1common.StateFailed, + PromotionStatus: v1common.StateFailed, + WorkloadStatus: []v1.WorkloadStatus{ + { + Workload: v1.KeptnWorkloadRef{ Name: "name1", Version: "1", }, - Status: v1beta1common.StateFailed, + Status: v1common.StateFailed, }, { - Workload: v1beta1.KeptnWorkloadRef{ + Workload: v1.KeptnWorkloadRef{ Name: "name2", Version: "2", }, - Status: v1beta1common.StateFailed, + Status: v1common.StateFailed, }, }, CurrentPhase: "phase", - PreDeploymentTaskStatus: []v1beta1.ItemStatus{ + PreDeploymentTaskStatus: []v1.ItemStatus{ { DefinitionName: "def1", Name: "name1", - Status: v1beta1common.StateFailed, + Status: v1common.StateFailed, }, { DefinitionName: "def12", Name: "name12", - Status: v1beta1common.StateFailed, + Status: v1common.StateFailed, }, }, - PostDeploymentTaskStatus: []v1beta1.ItemStatus{ + PostDeploymentTaskStatus: []v1.ItemStatus{ { DefinitionName: "def2", Name: "name2", - Status: v1beta1common.StateFailed, + Status: v1common.StateFailed, }, { DefinitionName: "def22", Name: "name22", - Status: v1beta1common.StateFailed, + Status: v1common.StateFailed, }, }, - PreDeploymentEvaluationTaskStatus: []v1beta1.ItemStatus{ + PreDeploymentEvaluationTaskStatus: []v1.ItemStatus{ { DefinitionName: "def3", Name: "name3", - Status: v1beta1common.StateFailed, + Status: v1common.StateFailed, }, { DefinitionName: "def32", Name: "name32", - Status: v1beta1common.StateFailed, + Status: v1common.StateFailed, }, }, - PostDeploymentEvaluationTaskStatus: []v1beta1.ItemStatus{ + PostDeploymentEvaluationTaskStatus: []v1.ItemStatus{ { DefinitionName: "def4", Name: "name4", - Status: v1beta1common.StateFailed, + Status: v1common.StateFailed, }, { DefinitionName: "def42", Name: "name42", - Status: v1beta1common.StateFailed, + Status: v1common.StateFailed, }, }, - PromotionTaskStatus: []v1beta1.ItemStatus{ + PromotionTaskStatus: []v1.ItemStatus{ { DefinitionName: "def5", Name: "name5", - Status: v1beta1common.StateFailed, + Status: v1common.StateFailed, }, { DefinitionName: "def52", Name: "name52", - Status: v1beta1common.StateSucceeded, + Status: v1common.StateSucceeded, }, }, - PhaseTraceIDs: v1beta1common.PhaseTraceID{ + PhaseTraceIDs: v1common.PhaseTraceID{ "key": propagation.MapCarrier{ "key1": "value1", "key2": "value2", @@ -654,18 +654,18 @@ func TestKeptnAppVersion_ConvertTo(t *testing.T) { "key222": "value222", }, }, - Status: v1beta1common.StateFailed, + Status: v1common.StateFailed, }, }, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - dst := v1beta1.KeptnAppVersion{ - TypeMeta: v1.TypeMeta{}, - ObjectMeta: v1.ObjectMeta{}, - Spec: v1beta1.KeptnAppVersionSpec{}, - Status: v1beta1.KeptnAppVersionStatus{}, + dst := v1.KeptnAppVersion{ + TypeMeta: metav1.TypeMeta{}, + ObjectMeta: metav1.ObjectMeta{}, + Spec: v1.KeptnAppVersionSpec{}, + Status: v1.KeptnAppVersionStatus{}, } if err := tt.src.ConvertTo(&dst); (err != nil) != tt.wantErr { t.Errorf("ConvertTo() error = %v, wantErr %v", err, tt.wantErr) @@ -682,8 +682,8 @@ func TestKeptnAppVersion_ConvertFrom_Errorcase(t *testing.T) { testObj := v2.ExternalJob{} dst := &KeptnAppVersion{ - TypeMeta: v1.TypeMeta{}, - ObjectMeta: v1.ObjectMeta{}, + TypeMeta: metav1.TypeMeta{}, + ObjectMeta: metav1.ObjectMeta{}, Spec: KeptnAppVersionSpec{}, Status: KeptnAppVersionStatus{}, } diff --git a/lifecycle-operator/apis/lifecycle/v1beta1/keptnappversion_types.go b/lifecycle-operator/apis/lifecycle/v1beta1/keptnappversion_types.go index 8163c48be4..312faf0a9a 100644 --- a/lifecycle-operator/apis/lifecycle/v1beta1/keptnappversion_types.go +++ b/lifecycle-operator/apis/lifecycle/v1beta1/keptnappversion_types.go @@ -117,7 +117,6 @@ type WorkloadStatus struct { // +kubebuilder:object:root=true // +kubebuilder:resource:path=keptnappversions,shortName=kav -// +kubebuilder:storageversion // +kubebuilder:subresource:status // +kubebuilder:printcolumn:name="AppName",type=string,JSONPath=`.spec.appName` // +kubebuilder:printcolumn:name="Version",type=string,JSONPath=`.spec.version` diff --git a/lifecycle-operator/apis/lifecycle/v1beta1/keptnevaluation_types.go b/lifecycle-operator/apis/lifecycle/v1beta1/keptnevaluation_types.go index c239171697..8caa70d146 100644 --- a/lifecycle-operator/apis/lifecycle/v1beta1/keptnevaluation_types.go +++ b/lifecycle-operator/apis/lifecycle/v1beta1/keptnevaluation_types.go @@ -87,7 +87,6 @@ type EvaluationStatusItem struct { } // +kubebuilder:object:root=true -// +kubebuilder:storageversion // +kubebuilder:subresource:status // +kubebuilder:resource:path=keptnevaluations,shortName=ke // +kubebuilder:printcolumn:name="AppName",type=string,JSONPath=`.spec.appName` diff --git a/lifecycle-operator/apis/lifecycle/v1beta1/keptnevaluationdefinition_types.go b/lifecycle-operator/apis/lifecycle/v1beta1/keptnevaluationdefinition_types.go index 29a2d46b14..822b03ffa6 100644 --- a/lifecycle-operator/apis/lifecycle/v1beta1/keptnevaluationdefinition_types.go +++ b/lifecycle-operator/apis/lifecycle/v1beta1/keptnevaluationdefinition_types.go @@ -64,7 +64,6 @@ type KeptnMetricReference struct { } // +kubebuilder:object:root=true -// +kubebuilder:storageversion // +kubebuilder:subresource:status // +kubebuilder:resource:path=keptnevaluationdefinitions,shortName=ked diff --git a/lifecycle-operator/apis/lifecycle/v1beta1/keptntask_types.go b/lifecycle-operator/apis/lifecycle/v1beta1/keptntask_types.go index 4b8c3c161c..85c6a2ae77 100644 --- a/lifecycle-operator/apis/lifecycle/v1beta1/keptntask_types.go +++ b/lifecycle-operator/apis/lifecycle/v1beta1/keptntask_types.go @@ -128,7 +128,6 @@ type KeptnTaskStatus struct { } // +kubebuilder:object:root=true -// +kubebuilder:storageversion // +kubebuilder:subresource:status // +kubebuilder:printcolumn:name="AppName",type=string,JSONPath=`.spec.app` // +kubebuilder:printcolumn:name="AppVersion",type=string,JSONPath=`.spec.appVersion` diff --git a/lifecycle-operator/apis/lifecycle/v1beta1/keptntaskdefinition_types.go b/lifecycle-operator/apis/lifecycle/v1beta1/keptntaskdefinition_types.go index d6e71969ee..c81c518d53 100644 --- a/lifecycle-operator/apis/lifecycle/v1beta1/keptntaskdefinition_types.go +++ b/lifecycle-operator/apis/lifecycle/v1beta1/keptntaskdefinition_types.go @@ -145,7 +145,6 @@ type FunctionStatus struct { } // +kubebuilder:object:root=true -// +kubebuilder:storageversion // +kubebuilder:subresource:status // KeptnTaskDefinition is the Schema for the keptntaskdefinitions API diff --git a/lifecycle-operator/apis/lifecycle/v1beta1/keptnworkload_types.go b/lifecycle-operator/apis/lifecycle/v1beta1/keptnworkload_types.go index 560b4fd800..4036c974b5 100644 --- a/lifecycle-operator/apis/lifecycle/v1beta1/keptnworkload_types.go +++ b/lifecycle-operator/apis/lifecycle/v1beta1/keptnworkload_types.go @@ -71,7 +71,6 @@ type KeptnWorkloadStatus struct { } // +kubebuilder:object:root=true -// +kubebuilder:storageversion // +kubebuilder:subresource:status // +kubebuilder:printcolumn:name="AppName",type=string,JSONPath=`.spec.app` // +kubebuilder:printcolumn:name="Version",type=string,JSONPath=`.spec.version` diff --git a/lifecycle-operator/apis/lifecycle/v1beta1/keptnworkloadversion_types.go b/lifecycle-operator/apis/lifecycle/v1beta1/keptnworkloadversion_types.go index 834ca8766d..39711f8f0e 100644 --- a/lifecycle-operator/apis/lifecycle/v1beta1/keptnworkloadversion_types.go +++ b/lifecycle-operator/apis/lifecycle/v1beta1/keptnworkloadversion_types.go @@ -123,7 +123,6 @@ type KeptnWorkloadVersionStatus struct { } // +kubebuilder:object:root=true -// +kubebuilder:storageversion // +kubebuilder:resource:path=keptnworkloadversions,shortName=kwv // +kubebuilder:subresource:status // +kubebuilder:printcolumn:name="AppName",type=string,JSONPath=`.spec.app` diff --git a/lifecycle-operator/apis/lifecycle/v1beta1/zz_generated.deepcopy.go b/lifecycle-operator/apis/lifecycle/v1beta1/zz_generated.deepcopy.go index 7dbed733c6..415195959f 100644 --- a/lifecycle-operator/apis/lifecycle/v1beta1/zz_generated.deepcopy.go +++ b/lifecycle-operator/apis/lifecycle/v1beta1/zz_generated.deepcopy.go @@ -24,7 +24,7 @@ import ( "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" "go.opentelemetry.io/otel/propagation" "k8s.io/api/core/v1" - "k8s.io/apimachinery/pkg/runtime" + runtime "k8s.io/apimachinery/pkg/runtime" ) // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. diff --git a/lifecycle-operator/chart/templates/keptnapp-crd.yaml b/lifecycle-operator/chart/templates/keptnapp-crd.yaml index 70f48347bc..d86bc604c6 100644 --- a/lifecycle-operator/chart/templates/keptnapp-crd.yaml +++ b/lifecycle-operator/chart/templates/keptnapp-crd.yaml @@ -100,7 +100,7 @@ spec: type: object type: object served: true - storage: false + storage: true subresources: status: {} - name: v1alpha1 @@ -417,6 +417,6 @@ spec: type: object type: object served: true - storage: true + storage: false subresources: status: {} diff --git a/lifecycle-operator/chart/templates/keptnappcontext-crd.yaml b/lifecycle-operator/chart/templates/keptnappcontext-crd.yaml index 2227ad114e..7601a8490d 100644 --- a/lifecycle-operator/chart/templates/keptnappcontext-crd.yaml +++ b/lifecycle-operator/chart/templates/keptnappcontext-crd.yaml @@ -110,7 +110,7 @@ spec: type: object type: object served: true - storage: false + storage: true subresources: status: {} - name: v1beta1 @@ -203,6 +203,6 @@ spec: type: object type: object served: true - storage: true + storage: false subresources: status: {} diff --git a/lifecycle-operator/chart/templates/keptnappcreationrequest-crd.yaml b/lifecycle-operator/chart/templates/keptnappcreationrequest-crd.yaml index 0fd3d0039f..dea7602e7e 100644 --- a/lifecycle-operator/chart/templates/keptnappcreationrequest-crd.yaml +++ b/lifecycle-operator/chart/templates/keptnappcreationrequest-crd.yaml @@ -60,7 +60,7 @@ spec: type: string type: object served: true - storage: false + storage: true subresources: status: {} - name: v1alpha3 @@ -142,6 +142,6 @@ spec: type: string type: object served: true - storage: true + storage: false subresources: status: {} diff --git a/lifecycle-operator/chart/templates/keptnappversion-crd.yaml b/lifecycle-operator/chart/templates/keptnappversion-crd.yaml index 70bebad8f6..6c09bf38ad 100644 --- a/lifecycle-operator/chart/templates/keptnappversion-crd.yaml +++ b/lifecycle-operator/chart/templates/keptnappversion-crd.yaml @@ -423,7 +423,7 @@ spec: type: object type: object served: true - storage: false + storage: true subresources: status: {} - additionalPrinterColumns: @@ -1656,6 +1656,6 @@ spec: type: object type: object served: true - storage: true + storage: false subresources: status: {} diff --git a/lifecycle-operator/chart/templates/keptnevaluation-crd.yaml b/lifecycle-operator/chart/templates/keptnevaluation-crd.yaml index 1ece6efdfc..c6f94382d8 100644 --- a/lifecycle-operator/chart/templates/keptnevaluation-crd.yaml +++ b/lifecycle-operator/chart/templates/keptnevaluation-crd.yaml @@ -172,7 +172,7 @@ spec: type: object type: object served: true - storage: false + storage: true subresources: status: {} - additionalPrinterColumns: @@ -704,6 +704,6 @@ spec: type: object type: object served: true - storage: true + storage: false subresources: status: {} diff --git a/lifecycle-operator/chart/templates/keptnevaluationdefinition-crd.yaml b/lifecycle-operator/chart/templates/keptnevaluationdefinition-crd.yaml index 5f5af44e9b..d91e028b80 100644 --- a/lifecycle-operator/chart/templates/keptnevaluationdefinition-crd.yaml +++ b/lifecycle-operator/chart/templates/keptnevaluationdefinition-crd.yaml @@ -101,7 +101,7 @@ spec: type: string type: object served: true - storage: false + storage: true subresources: status: {} - name: v1alpha1 @@ -360,6 +360,6 @@ spec: type: string type: object served: true - storage: true + storage: false subresources: status: {} diff --git a/lifecycle-operator/chart/templates/keptntask-crd.yaml b/lifecycle-operator/chart/templates/keptntask-crd.yaml index 0cb22601cc..fa39cae8fe 100644 --- a/lifecycle-operator/chart/templates/keptntask-crd.yaml +++ b/lifecycle-operator/chart/templates/keptntask-crd.yaml @@ -188,7 +188,7 @@ spec: type: object type: object served: true - storage: false + storage: true subresources: status: {} - additionalPrinterColumns: @@ -760,6 +760,6 @@ spec: type: object type: object served: true - storage: true + storage: false subresources: status: {} diff --git a/lifecycle-operator/chart/templates/keptntaskdefinition-crd.yaml b/lifecycle-operator/chart/templates/keptntaskdefinition-crd.yaml index 19dd5f661d..3d8b928468 100644 --- a/lifecycle-operator/chart/templates/keptntaskdefinition-crd.yaml +++ b/lifecycle-operator/chart/templates/keptntaskdefinition-crd.yaml @@ -1576,7 +1576,7 @@ spec: type: object type: object served: true - storage: false + storage: true subresources: status: {} - name: v1alpha1 @@ -4990,6 +4990,6 @@ spec: type: object type: object served: true - storage: true + storage: false subresources: status: {} diff --git a/lifecycle-operator/chart/templates/keptnworkload-crd.yaml b/lifecycle-operator/chart/templates/keptnworkload-crd.yaml index f54dca75b6..ac7f9b9018 100644 --- a/lifecycle-operator/chart/templates/keptnworkload-crd.yaml +++ b/lifecycle-operator/chart/templates/keptnworkload-crd.yaml @@ -135,7 +135,7 @@ spec: type: object type: object served: true - storage: false + storage: true subresources: status: {} - additionalPrinterColumns: @@ -533,6 +533,6 @@ spec: type: object type: object served: true - storage: true + storage: false subresources: status: {} diff --git a/lifecycle-operator/chart/templates/keptnworkloadversion-crd.yaml b/lifecycle-operator/chart/templates/keptnworkloadversion-crd.yaml index 24aa782114..92d6219103 100644 --- a/lifecycle-operator/chart/templates/keptnworkloadversion-crd.yaml +++ b/lifecycle-operator/chart/templates/keptnworkloadversion-crd.yaml @@ -355,7 +355,7 @@ spec: type: object type: object served: true - storage: false + storage: true subresources: status: {} - additionalPrinterColumns: @@ -1006,6 +1006,6 @@ spec: type: object type: object served: true - storage: true + storage: false subresources: status: {} diff --git a/lifecycle-operator/chart/templates/lifecycle-validating-webhook-configuration.yaml b/lifecycle-operator/chart/templates/lifecycle-validating-webhook-configuration.yaml index c608b7138e..ea5d3971ff 100644 --- a/lifecycle-operator/chart/templates/lifecycle-validating-webhook-configuration.yaml +++ b/lifecycle-operator/chart/templates/lifecycle-validating-webhook-configuration.yaml @@ -23,14 +23,14 @@ webhooks: service: name: 'lifecycle-webhook-service' namespace: '{{ .Release.Namespace }}' - path: /validate-lifecycle-keptn-sh-v1beta1-keptntaskdefinition + path: /validate-lifecycle-keptn-sh-v1-keptntaskdefinition failurePolicy: Fail name: vkeptntaskdefinition.kb.io rules: - apiGroups: - lifecycle.keptn.sh apiVersions: - - v1beta1 + - v1 operations: - CREATE - UPDATE diff --git a/lifecycle-operator/config/crd/bases/lifecycle.keptn.sh_keptnappcontexts.yaml b/lifecycle-operator/config/crd/bases/lifecycle.keptn.sh_keptnappcontexts.yaml index 81a12e36ed..c725cec384 100644 --- a/lifecycle-operator/config/crd/bases/lifecycle.keptn.sh_keptnappcontexts.yaml +++ b/lifecycle-operator/config/crd/bases/lifecycle.keptn.sh_keptnappcontexts.yaml @@ -104,7 +104,7 @@ spec: type: object type: object served: true - storage: false + storage: true subresources: status: {} - name: v1beta1 @@ -197,6 +197,6 @@ spec: type: object type: object served: true - storage: true + storage: false subresources: status: {} diff --git a/lifecycle-operator/config/crd/bases/lifecycle.keptn.sh_keptnappcreationrequests.yaml b/lifecycle-operator/config/crd/bases/lifecycle.keptn.sh_keptnappcreationrequests.yaml index 9fff35fdf3..31d34f7258 100644 --- a/lifecycle-operator/config/crd/bases/lifecycle.keptn.sh_keptnappcreationrequests.yaml +++ b/lifecycle-operator/config/crd/bases/lifecycle.keptn.sh_keptnappcreationrequests.yaml @@ -52,7 +52,7 @@ spec: type: string type: object served: true - storage: false + storage: true subresources: status: {} - name: v1alpha3 @@ -134,6 +134,6 @@ spec: type: string type: object served: true - storage: true + storage: false subresources: status: {} diff --git a/lifecycle-operator/config/crd/bases/lifecycle.keptn.sh_keptnapps.yaml b/lifecycle-operator/config/crd/bases/lifecycle.keptn.sh_keptnapps.yaml index fb9ea825a1..31c13c50d9 100644 --- a/lifecycle-operator/config/crd/bases/lifecycle.keptn.sh_keptnapps.yaml +++ b/lifecycle-operator/config/crd/bases/lifecycle.keptn.sh_keptnapps.yaml @@ -82,7 +82,7 @@ spec: type: object type: object served: true - storage: false + storage: true subresources: status: {} - name: v1alpha1 @@ -399,6 +399,6 @@ spec: type: object type: object served: true - storage: true + storage: false subresources: status: {} diff --git a/lifecycle-operator/config/crd/bases/lifecycle.keptn.sh_keptnappversions.yaml b/lifecycle-operator/config/crd/bases/lifecycle.keptn.sh_keptnappversions.yaml index 6695a6c757..7071f3ec8f 100644 --- a/lifecycle-operator/config/crd/bases/lifecycle.keptn.sh_keptnappversions.yaml +++ b/lifecycle-operator/config/crd/bases/lifecycle.keptn.sh_keptnappversions.yaml @@ -405,7 +405,7 @@ spec: type: object type: object served: true - storage: false + storage: true subresources: status: {} - additionalPrinterColumns: @@ -1638,6 +1638,6 @@ spec: type: object type: object served: true - storage: true + storage: false subresources: status: {} diff --git a/lifecycle-operator/config/crd/bases/lifecycle.keptn.sh_keptnevaluationdefinitions.yaml b/lifecycle-operator/config/crd/bases/lifecycle.keptn.sh_keptnevaluationdefinitions.yaml index 575772b046..91297a922e 100644 --- a/lifecycle-operator/config/crd/bases/lifecycle.keptn.sh_keptnevaluationdefinitions.yaml +++ b/lifecycle-operator/config/crd/bases/lifecycle.keptn.sh_keptnevaluationdefinitions.yaml @@ -93,7 +93,7 @@ spec: type: string type: object served: true - storage: false + storage: true subresources: status: {} - name: v1alpha1 @@ -352,6 +352,6 @@ spec: type: string type: object served: true - storage: true + storage: false subresources: status: {} diff --git a/lifecycle-operator/config/crd/bases/lifecycle.keptn.sh_keptnevaluations.yaml b/lifecycle-operator/config/crd/bases/lifecycle.keptn.sh_keptnevaluations.yaml index d4d0d80041..72f132d728 100644 --- a/lifecycle-operator/config/crd/bases/lifecycle.keptn.sh_keptnevaluations.yaml +++ b/lifecycle-operator/config/crd/bases/lifecycle.keptn.sh_keptnevaluations.yaml @@ -164,7 +164,7 @@ spec: type: object type: object served: true - storage: false + storage: true subresources: status: {} - additionalPrinterColumns: @@ -696,6 +696,6 @@ spec: type: object type: object served: true - storage: true + storage: false subresources: status: {} diff --git a/lifecycle-operator/config/crd/bases/lifecycle.keptn.sh_keptntaskdefinitions.yaml b/lifecycle-operator/config/crd/bases/lifecycle.keptn.sh_keptntaskdefinitions.yaml index 67df090481..fb9507fc64 100644 --- a/lifecycle-operator/config/crd/bases/lifecycle.keptn.sh_keptntaskdefinitions.yaml +++ b/lifecycle-operator/config/crd/bases/lifecycle.keptn.sh_keptntaskdefinitions.yaml @@ -1568,7 +1568,7 @@ spec: type: object type: object served: true - storage: false + storage: true subresources: status: {} - name: v1alpha1 @@ -4982,6 +4982,6 @@ spec: type: object type: object served: true - storage: true + storage: false subresources: status: {} diff --git a/lifecycle-operator/config/crd/bases/lifecycle.keptn.sh_keptntasks.yaml b/lifecycle-operator/config/crd/bases/lifecycle.keptn.sh_keptntasks.yaml index 8faea85021..d9f1f38c10 100644 --- a/lifecycle-operator/config/crd/bases/lifecycle.keptn.sh_keptntasks.yaml +++ b/lifecycle-operator/config/crd/bases/lifecycle.keptn.sh_keptntasks.yaml @@ -179,7 +179,7 @@ spec: type: object type: object served: true - storage: false + storage: true subresources: status: {} - additionalPrinterColumns: @@ -751,6 +751,6 @@ spec: type: object type: object served: true - storage: true + storage: false subresources: status: {} diff --git a/lifecycle-operator/config/crd/bases/lifecycle.keptn.sh_keptnworkloads.yaml b/lifecycle-operator/config/crd/bases/lifecycle.keptn.sh_keptnworkloads.yaml index 27cc04551c..ff5bba8452 100644 --- a/lifecycle-operator/config/crd/bases/lifecycle.keptn.sh_keptnworkloads.yaml +++ b/lifecycle-operator/config/crd/bases/lifecycle.keptn.sh_keptnworkloads.yaml @@ -127,7 +127,7 @@ spec: type: object type: object served: true - storage: false + storage: true subresources: status: {} - additionalPrinterColumns: @@ -525,6 +525,6 @@ spec: type: object type: object served: true - storage: true + storage: false subresources: status: {} diff --git a/lifecycle-operator/config/crd/bases/lifecycle.keptn.sh_keptnworkloadversions.yaml b/lifecycle-operator/config/crd/bases/lifecycle.keptn.sh_keptnworkloadversions.yaml index 3fd26db9cb..9f3741328a 100644 --- a/lifecycle-operator/config/crd/bases/lifecycle.keptn.sh_keptnworkloadversions.yaml +++ b/lifecycle-operator/config/crd/bases/lifecycle.keptn.sh_keptnworkloadversions.yaml @@ -347,7 +347,7 @@ spec: type: object type: object served: true - storage: false + storage: true subresources: status: {} - additionalPrinterColumns: @@ -998,6 +998,6 @@ spec: type: object type: object served: true - storage: true + storage: false subresources: status: {} diff --git a/lifecycle-operator/config/webhook/manifests.yaml b/lifecycle-operator/config/webhook/manifests.yaml index 03e319b23a..88039702d9 100644 --- a/lifecycle-operator/config/webhook/manifests.yaml +++ b/lifecycle-operator/config/webhook/manifests.yaml @@ -42,14 +42,14 @@ webhooks: service: name: lifecycle-webhook-service namespace: system - path: /validate-lifecycle-keptn-sh-v1beta1-keptntaskdefinition + path: /validate-lifecycle-keptn-sh-v1-keptntaskdefinition failurePolicy: Fail name: vkeptntaskdefinition.kb.io rules: - apiGroups: - lifecycle.keptn.sh apiVersions: - - v1beta1 + - v1 operations: - CREATE - UPDATE diff --git a/lifecycle-operator/controllers/common/evaluation/fake/evaluationhandler_mock.go b/lifecycle-operator/controllers/common/evaluation/fake/evaluationhandler_mock.go index 8626fcf202..3da0553bb5 100644 --- a/lifecycle-operator/controllers/common/evaluation/fake/evaluationhandler_mock.go +++ b/lifecycle-operator/controllers/common/evaluation/fake/evaluationhandler_mock.go @@ -5,8 +5,8 @@ package fake import ( "context" - klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" + apilifecycle "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1/common" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/evaluation" "sigs.k8s.io/controller-runtime/pkg/client" "sync" @@ -18,7 +18,7 @@ import ( // // // make and configure a mocked evaluation.IEvaluationHandler // mockedIEvaluationHandler := &MockEvaluationHandler{ -// ReconcileEvaluationsFunc: func(ctx context.Context, phaseCtx context.Context, reconcileObject client.Object, evaluationCreateAttributes evaluation.CreateEvaluationAttributes) ([]klcv1beta1.ItemStatus, apicommon.StatusSummary, error) { +// ReconcileEvaluationsFunc: func(ctx context.Context, phaseCtx context.Context, reconcileObject client.Object, evaluationCreateAttributes evaluation.CreateEvaluationAttributes) ([]apilifecycle.ItemStatus, apicommon.StatusSummary, error) { // panic("mock out the ReconcileEvaluations method") // }, // } @@ -29,7 +29,7 @@ import ( // } type MockEvaluationHandler struct { // ReconcileEvaluationsFunc mocks the ReconcileEvaluations method. - ReconcileEvaluationsFunc func(ctx context.Context, phaseCtx context.Context, reconcileObject client.Object, evaluationCreateAttributes evaluation.CreateEvaluationAttributes) ([]klcv1beta1.ItemStatus, apicommon.StatusSummary, error) + ReconcileEvaluationsFunc func(ctx context.Context, phaseCtx context.Context, reconcileObject client.Object, evaluationCreateAttributes evaluation.CreateEvaluationAttributes) ([]apilifecycle.ItemStatus, apicommon.StatusSummary, error) // calls tracks calls to the methods. calls struct { @@ -49,7 +49,7 @@ type MockEvaluationHandler struct { } // ReconcileEvaluations calls ReconcileEvaluationsFunc. -func (mock *MockEvaluationHandler) ReconcileEvaluations(ctx context.Context, phaseCtx context.Context, reconcileObject client.Object, evaluationCreateAttributes evaluation.CreateEvaluationAttributes) ([]klcv1beta1.ItemStatus, apicommon.StatusSummary, error) { +func (mock *MockEvaluationHandler) ReconcileEvaluations(ctx context.Context, phaseCtx context.Context, reconcileObject client.Object, evaluationCreateAttributes evaluation.CreateEvaluationAttributes) ([]apilifecycle.ItemStatus, apicommon.StatusSummary, error) { if mock.ReconcileEvaluationsFunc == nil { panic("MockEvaluationHandler.ReconcileEvaluationsFunc: method is nil but IEvaluationHandler.ReconcileEvaluations was just called") } diff --git a/lifecycle-operator/controllers/common/evaluation/handler.go b/lifecycle-operator/controllers/common/evaluation/handler.go index 05562a8445..d15c5c094f 100644 --- a/lifecycle-operator/controllers/common/evaluation/handler.go +++ b/lifecycle-operator/controllers/common/evaluation/handler.go @@ -6,8 +6,8 @@ import ( "time" "github.com/go-logr/logr" - klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" + apilifecycle "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1/common" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/eventsender" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/telemetry" @@ -24,7 +24,7 @@ import ( //go:generate moq -pkg fake -skip-ensure -out ./fake/evaluationhandler_mock.go . IEvaluationHandler:MockEvaluationHandler type IEvaluationHandler interface { - ReconcileEvaluations(ctx context.Context, phaseCtx context.Context, reconcileObject client.Object, evaluationCreateAttributes CreateEvaluationAttributes) ([]klcv1beta1.ItemStatus, apicommon.StatusSummary, error) + ReconcileEvaluations(ctx context.Context, phaseCtx context.Context, reconcileObject client.Object, evaluationCreateAttributes CreateEvaluationAttributes) ([]apilifecycle.ItemStatus, apicommon.StatusSummary, error) } type Handler struct { @@ -38,7 +38,7 @@ type Handler struct { type CreateEvaluationAttributes struct { SpanName string - Definition klcv1beta1.KeptnEvaluationDefinition + Definition apilifecycle.KeptnEvaluationDefinition CheckType apicommon.CheckType } @@ -55,7 +55,7 @@ func NewHandler(client client.Client, eventSender eventsender.IEvent, log logr.L } //nolint:gocognit,gocyclo -func (r Handler) ReconcileEvaluations(ctx context.Context, phaseCtx context.Context, reconcileObject client.Object, evaluationCreateAttributes CreateEvaluationAttributes) ([]klcv1beta1.ItemStatus, apicommon.StatusSummary, error) { +func (r Handler) ReconcileEvaluations(ctx context.Context, phaseCtx context.Context, reconcileObject client.Object, evaluationCreateAttributes CreateEvaluationAttributes) ([]apilifecycle.ItemStatus, apicommon.StatusSummary, error) { piWrapper, err := interfaces.NewPhaseItemWrapperFromClientObject(reconcileObject) if err != nil { return nil, apicommon.StatusSummary{}, err @@ -66,12 +66,12 @@ func (r Handler) ReconcileEvaluations(ctx context.Context, phaseCtx context.Cont var summary apicommon.StatusSummary summary.Total = len(evaluations) // Check current state of the PrePostEvaluationTasks - var newStatus []klcv1beta1.ItemStatus + var newStatus []apilifecycle.ItemStatus for _, evaluationName := range evaluations { oldstatus := common.GetOldStatus(evaluationName, statuses) evaluationStatus := common.GetItemStatus(evaluationName, statuses) - evaluation := &klcv1beta1.KeptnEvaluation{} + evaluation := &apilifecycle.KeptnEvaluation{} evaluationExists := false if oldstatus != evaluationStatus.Status { @@ -167,7 +167,7 @@ func (r Handler) CreateKeptnEvaluation(ctx context.Context, reconcileObject clie return newEvaluation.Name, nil } -func (r Handler) emitEvaluationFailureEvents(evaluation *klcv1beta1.KeptnEvaluation, spanTrace trace.Span, piWrapper *interfaces.PhaseItemWrapper) { +func (r Handler) emitEvaluationFailureEvents(evaluation *apilifecycle.KeptnEvaluation, spanTrace trace.Span, piWrapper *interfaces.PhaseItemWrapper) { k8sEventMessage := "evaluation failed" for k, v := range evaluation.Status.EvaluationStatus { if v.Status == apicommon.StateFailed { @@ -179,9 +179,9 @@ func (r Handler) emitEvaluationFailureEvents(evaluation *klcv1beta1.KeptnEvaluat r.EventSender.Emit(apicommon.PhaseReconcileEvaluation, "Warning", evaluation, apicommon.PhaseStateFailed, k8sEventMessage, piWrapper.GetVersion()) } -func (r Handler) setupEvaluations(evaluationCreateAttributes CreateEvaluationAttributes, piWrapper *interfaces.PhaseItemWrapper) ([]string, []klcv1beta1.ItemStatus) { +func (r Handler) setupEvaluations(evaluationCreateAttributes CreateEvaluationAttributes, piWrapper *interfaces.PhaseItemWrapper) ([]string, []apilifecycle.ItemStatus) { var evaluations []string - var statuses []klcv1beta1.ItemStatus + var statuses []apilifecycle.ItemStatus switch evaluationCreateAttributes.CheckType { case apicommon.PreDeploymentEvaluationCheckType: @@ -194,7 +194,7 @@ func (r Handler) setupEvaluations(evaluationCreateAttributes CreateEvaluationAtt return evaluations, statuses } -func (r Handler) handleEvaluationNotExists(ctx context.Context, phaseCtx context.Context, evaluationCreateAttributes CreateEvaluationAttributes, evaluationName string, piWrapper *interfaces.PhaseItemWrapper, reconcileObject client.Object, evaluation *klcv1beta1.KeptnEvaluation, evaluationStatus *klcv1beta1.ItemStatus) error { +func (r Handler) handleEvaluationNotExists(ctx context.Context, phaseCtx context.Context, evaluationCreateAttributes CreateEvaluationAttributes, evaluationName string, piWrapper *interfaces.PhaseItemWrapper, reconcileObject client.Object, evaluation *apilifecycle.KeptnEvaluation, evaluationStatus *apilifecycle.ItemStatus) error { definition, err := common.GetEvaluationDefinition(r.Client, r.Log, ctx, evaluationName, piWrapper.GetNamespace()) if err != nil { return controllererrors.ErrCannotGetKeptnEvaluationDefinition @@ -214,7 +214,7 @@ func (r Handler) handleEvaluationNotExists(ctx context.Context, phaseCtx context return nil } -func (r Handler) handleEvaluationExists(phaseCtx context.Context, piWrapper *interfaces.PhaseItemWrapper, evaluation *klcv1beta1.KeptnEvaluation, evaluationStatus *klcv1beta1.ItemStatus) { +func (r Handler) handleEvaluationExists(phaseCtx context.Context, piWrapper *interfaces.PhaseItemWrapper, evaluation *apilifecycle.KeptnEvaluation, evaluationStatus *apilifecycle.ItemStatus) { _, spanEvaluationTrace, err := r.SpanHandler.GetSpan(phaseCtx, r.Tracer, evaluation, "") if err != nil { r.Log.Error(err, "could not get span") diff --git a/lifecycle-operator/controllers/common/evaluation/handler_test.go b/lifecycle-operator/controllers/common/evaluation/handler_test.go index 19c341df07..039ae59ab2 100644 --- a/lifecycle-operator/controllers/common/evaluation/handler_test.go +++ b/lifecycle-operator/controllers/common/evaluation/handler_test.go @@ -6,8 +6,8 @@ import ( "strings" "testing" - "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" + apilifecycle "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1/common" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/config" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/eventsender" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/telemetry" @@ -31,10 +31,10 @@ func TestEvaluationHandler(t *testing.T) { name string object client.Object createAttr CreateEvaluationAttributes - wantStatus []v1beta1.ItemStatus + wantStatus []apilifecycle.ItemStatus wantSummary apicommon.StatusSummary - evalObj v1beta1.KeptnEvaluation - evalDef *v1beta1.KeptnEvaluationDefinition + evalObj apilifecycle.KeptnEvaluation + evalDef *apilifecycle.KeptnEvaluationDefinition wantErr error getSpanCalls int unbindSpanCalls int @@ -42,8 +42,8 @@ func TestEvaluationHandler(t *testing.T) { }{ { name: "cannot unwrap object", - object: &v1beta1.KeptnEvaluation{}, - evalObj: v1beta1.KeptnEvaluation{}, + object: &apilifecycle.KeptnEvaluation{}, + evalObj: apilifecycle.KeptnEvaluation{}, createAttr: CreateEvaluationAttributes{}, wantStatus: nil, wantSummary: apicommon.StatusSummary{}, @@ -53,18 +53,18 @@ func TestEvaluationHandler(t *testing.T) { }, { name: "no evaluations", - object: &v1beta1.KeptnAppVersion{}, - evalObj: v1beta1.KeptnEvaluation{}, + object: &apilifecycle.KeptnAppVersion{}, + evalObj: apilifecycle.KeptnEvaluation{}, createAttr: CreateEvaluationAttributes{ SpanName: "", - Definition: v1beta1.KeptnEvaluationDefinition{ + Definition: apilifecycle.KeptnEvaluationDefinition{ ObjectMeta: v1.ObjectMeta{ Name: "", }, }, CheckType: apicommon.PreDeploymentEvaluationCheckType, }, - wantStatus: []v1beta1.ItemStatus(nil), + wantStatus: []apilifecycle.ItemStatus(nil), wantSummary: apicommon.StatusSummary{}, wantErr: nil, getSpanCalls: 0, @@ -72,22 +72,22 @@ func TestEvaluationHandler(t *testing.T) { }, { name: "evaluation not started - could not find evaluationDefinition", - object: &v1beta1.KeptnAppVersion{ + object: &apilifecycle.KeptnAppVersion{ ObjectMeta: v1.ObjectMeta{ Namespace: "namespace", }, - Spec: v1beta1.KeptnAppVersionSpec{ - KeptnAppContextSpec: v1beta1.KeptnAppContextSpec{ - DeploymentTaskSpec: v1beta1.DeploymentTaskSpec{ + Spec: apilifecycle.KeptnAppVersionSpec{ + KeptnAppContextSpec: apilifecycle.KeptnAppContextSpec{ + DeploymentTaskSpec: apilifecycle.DeploymentTaskSpec{ PreDeploymentEvaluations: []string{"eval-def"}, }, }, }, }, - evalObj: v1beta1.KeptnEvaluation{}, + evalObj: apilifecycle.KeptnEvaluation{}, createAttr: CreateEvaluationAttributes{ SpanName: "", - Definition: v1beta1.KeptnEvaluationDefinition{ + Definition: apilifecycle.KeptnEvaluationDefinition{ ObjectMeta: v1.ObjectMeta{ Name: "eval-def", }, @@ -102,35 +102,35 @@ func TestEvaluationHandler(t *testing.T) { }, { name: "evaluations not started - could not find evaluationDefinition of one evaluation", - object: &v1beta1.KeptnAppVersion{ + object: &apilifecycle.KeptnAppVersion{ ObjectMeta: v1.ObjectMeta{ Namespace: "namespace", }, - Spec: v1beta1.KeptnAppVersionSpec{ - KeptnAppContextSpec: v1beta1.KeptnAppContextSpec{ - DeploymentTaskSpec: v1beta1.DeploymentTaskSpec{ + Spec: apilifecycle.KeptnAppVersionSpec{ + KeptnAppContextSpec: apilifecycle.KeptnAppContextSpec{ + DeploymentTaskSpec: apilifecycle.DeploymentTaskSpec{ PreDeploymentEvaluations: []string{"eval-def", "other-eval-def"}, }, }, }, }, - evalDef: &v1beta1.KeptnEvaluationDefinition{ + evalDef: &apilifecycle.KeptnEvaluationDefinition{ ObjectMeta: v1.ObjectMeta{ Namespace: testcommon.KeptnNamespace, Name: "eval-def", }, }, - evalObj: v1beta1.KeptnEvaluation{}, + evalObj: apilifecycle.KeptnEvaluation{}, createAttr: CreateEvaluationAttributes{ SpanName: "", - Definition: v1beta1.KeptnEvaluationDefinition{ + Definition: apilifecycle.KeptnEvaluationDefinition{ ObjectMeta: v1.ObjectMeta{ Name: "eval-def", }, }, CheckType: apicommon.PreDeploymentEvaluationCheckType, }, - wantStatus: []v1beta1.ItemStatus{ + wantStatus: []apilifecycle.ItemStatus{ { DefinitionName: "eval-def", Status: apicommon.StatePending, @@ -144,35 +144,35 @@ func TestEvaluationHandler(t *testing.T) { }, { name: "evaluation not started - evaluationDefinition in default Keptn namespace", - object: &v1beta1.KeptnAppVersion{ + object: &apilifecycle.KeptnAppVersion{ ObjectMeta: v1.ObjectMeta{ Namespace: "namespace", }, - Spec: v1beta1.KeptnAppVersionSpec{ - KeptnAppContextSpec: v1beta1.KeptnAppContextSpec{ - DeploymentTaskSpec: v1beta1.DeploymentTaskSpec{ + Spec: apilifecycle.KeptnAppVersionSpec{ + KeptnAppContextSpec: apilifecycle.KeptnAppContextSpec{ + DeploymentTaskSpec: apilifecycle.DeploymentTaskSpec{ PreDeploymentEvaluations: []string{"eval-def"}, }, }, }, }, - evalDef: &v1beta1.KeptnEvaluationDefinition{ + evalDef: &apilifecycle.KeptnEvaluationDefinition{ ObjectMeta: v1.ObjectMeta{ Namespace: testcommon.KeptnNamespace, Name: "eval-def", }, }, - evalObj: v1beta1.KeptnEvaluation{}, + evalObj: apilifecycle.KeptnEvaluation{}, createAttr: CreateEvaluationAttributes{ SpanName: "", - Definition: v1beta1.KeptnEvaluationDefinition{ + Definition: apilifecycle.KeptnEvaluationDefinition{ ObjectMeta: v1.ObjectMeta{ Name: "eval-def", }, }, CheckType: apicommon.PreDeploymentEvaluationCheckType, }, - wantStatus: []v1beta1.ItemStatus{ + wantStatus: []apilifecycle.ItemStatus{ { DefinitionName: "eval-def", Status: apicommon.StatePending, @@ -186,35 +186,35 @@ func TestEvaluationHandler(t *testing.T) { }, { name: "evaluation not started", - object: &v1beta1.KeptnAppVersion{ + object: &apilifecycle.KeptnAppVersion{ ObjectMeta: v1.ObjectMeta{ Namespace: "namespace", }, - Spec: v1beta1.KeptnAppVersionSpec{ - KeptnAppContextSpec: v1beta1.KeptnAppContextSpec{ - DeploymentTaskSpec: v1beta1.DeploymentTaskSpec{ + Spec: apilifecycle.KeptnAppVersionSpec{ + KeptnAppContextSpec: apilifecycle.KeptnAppContextSpec{ + DeploymentTaskSpec: apilifecycle.DeploymentTaskSpec{ PreDeploymentEvaluations: []string{"eval-def"}, }, }, }, }, - evalDef: &v1beta1.KeptnEvaluationDefinition{ + evalDef: &apilifecycle.KeptnEvaluationDefinition{ ObjectMeta: v1.ObjectMeta{ Namespace: "namespace", Name: "eval-def", }, }, - evalObj: v1beta1.KeptnEvaluation{}, + evalObj: apilifecycle.KeptnEvaluation{}, createAttr: CreateEvaluationAttributes{ SpanName: "", - Definition: v1beta1.KeptnEvaluationDefinition{ + Definition: apilifecycle.KeptnEvaluationDefinition{ ObjectMeta: v1.ObjectMeta{ Name: "eval-def", }, }, CheckType: apicommon.PreDeploymentEvaluationCheckType, }, - wantStatus: []v1beta1.ItemStatus{ + wantStatus: []apilifecycle.ItemStatus{ { DefinitionName: "eval-def", Status: apicommon.StatePending, @@ -228,17 +228,17 @@ func TestEvaluationHandler(t *testing.T) { }, { name: "already done evaluation", - object: &v1beta1.KeptnAppVersion{ - Spec: v1beta1.KeptnAppVersionSpec{ - KeptnAppContextSpec: v1beta1.KeptnAppContextSpec{ - DeploymentTaskSpec: v1beta1.DeploymentTaskSpec{ + object: &apilifecycle.KeptnAppVersion{ + Spec: apilifecycle.KeptnAppVersionSpec{ + KeptnAppContextSpec: apilifecycle.KeptnAppContextSpec{ + DeploymentTaskSpec: apilifecycle.DeploymentTaskSpec{ PreDeploymentEvaluations: []string{"eval-def"}, }, }, }, - Status: v1beta1.KeptnAppVersionStatus{ + Status: apilifecycle.KeptnAppVersionStatus{ PreDeploymentEvaluationStatus: apicommon.StateSucceeded, - PreDeploymentEvaluationTaskStatus: []v1beta1.ItemStatus{ + PreDeploymentEvaluationTaskStatus: []apilifecycle.ItemStatus{ { DefinitionName: "eval-def", Status: apicommon.StateSucceeded, @@ -247,17 +247,17 @@ func TestEvaluationHandler(t *testing.T) { }, }, }, - evalObj: v1beta1.KeptnEvaluation{}, + evalObj: apilifecycle.KeptnEvaluation{}, createAttr: CreateEvaluationAttributes{ SpanName: "", - Definition: v1beta1.KeptnEvaluationDefinition{ + Definition: apilifecycle.KeptnEvaluationDefinition{ ObjectMeta: v1.ObjectMeta{ Name: "eval-def", }, }, CheckType: apicommon.PreDeploymentEvaluationCheckType, }, - wantStatus: []v1beta1.ItemStatus{ + wantStatus: []apilifecycle.ItemStatus{ { DefinitionName: "eval-def", Status: apicommon.StateSucceeded, @@ -271,20 +271,20 @@ func TestEvaluationHandler(t *testing.T) { }, { name: "failed evaluation", - object: &v1beta1.KeptnAppVersion{ + object: &apilifecycle.KeptnAppVersion{ ObjectMeta: v1.ObjectMeta{ Namespace: "namespace", }, - Spec: v1beta1.KeptnAppVersionSpec{ - KeptnAppContextSpec: v1beta1.KeptnAppContextSpec{ - DeploymentTaskSpec: v1beta1.DeploymentTaskSpec{ + Spec: apilifecycle.KeptnAppVersionSpec{ + KeptnAppContextSpec: apilifecycle.KeptnAppContextSpec{ + DeploymentTaskSpec: apilifecycle.DeploymentTaskSpec{ PreDeploymentEvaluations: []string{"eval-def"}, }, }, }, - Status: v1beta1.KeptnAppVersionStatus{ + Status: apilifecycle.KeptnAppVersionStatus{ PreDeploymentEvaluationStatus: apicommon.StateSucceeded, - PreDeploymentEvaluationTaskStatus: []v1beta1.ItemStatus{ + PreDeploymentEvaluationTaskStatus: []apilifecycle.ItemStatus{ { DefinitionName: "eval-def", Status: apicommon.StateProgressing, @@ -293,14 +293,14 @@ func TestEvaluationHandler(t *testing.T) { }, }, }, - evalObj: v1beta1.KeptnEvaluation{ + evalObj: apilifecycle.KeptnEvaluation{ ObjectMeta: v1.ObjectMeta{ Namespace: "namespace", Name: "pre-eval-eval-def-", }, - Status: v1beta1.KeptnEvaluationStatus{ + Status: apilifecycle.KeptnEvaluationStatus{ OverallStatus: apicommon.StateFailed, - EvaluationStatus: map[string]v1beta1.EvaluationStatusItem{ + EvaluationStatus: map[string]apilifecycle.EvaluationStatusItem{ "my-target": { Value: "1", Status: apicommon.StateFailed, @@ -311,14 +311,14 @@ func TestEvaluationHandler(t *testing.T) { }, createAttr: CreateEvaluationAttributes{ SpanName: "", - Definition: v1beta1.KeptnEvaluationDefinition{ + Definition: apilifecycle.KeptnEvaluationDefinition{ ObjectMeta: v1.ObjectMeta{ Name: "eval-def", }, }, CheckType: apicommon.PreDeploymentEvaluationCheckType, }, - wantStatus: []v1beta1.ItemStatus{ + wantStatus: []apilifecycle.ItemStatus{ { DefinitionName: "eval-def", Status: apicommon.StateFailed, @@ -335,20 +335,20 @@ func TestEvaluationHandler(t *testing.T) { }, { name: "succeeded evaluation", - object: &v1beta1.KeptnAppVersion{ + object: &apilifecycle.KeptnAppVersion{ ObjectMeta: v1.ObjectMeta{ Namespace: "namespace", }, - Spec: v1beta1.KeptnAppVersionSpec{ - KeptnAppContextSpec: v1beta1.KeptnAppContextSpec{ - DeploymentTaskSpec: v1beta1.DeploymentTaskSpec{ + Spec: apilifecycle.KeptnAppVersionSpec{ + KeptnAppContextSpec: apilifecycle.KeptnAppContextSpec{ + DeploymentTaskSpec: apilifecycle.DeploymentTaskSpec{ PreDeploymentEvaluations: []string{"eval-def"}, }, }, }, - Status: v1beta1.KeptnAppVersionStatus{ + Status: apilifecycle.KeptnAppVersionStatus{ PreDeploymentEvaluationStatus: apicommon.StateSucceeded, - PreDeploymentEvaluationTaskStatus: []v1beta1.ItemStatus{ + PreDeploymentEvaluationTaskStatus: []apilifecycle.ItemStatus{ { DefinitionName: "eval-def", Status: apicommon.StateProgressing, @@ -357,25 +357,25 @@ func TestEvaluationHandler(t *testing.T) { }, }, }, - evalObj: v1beta1.KeptnEvaluation{ + evalObj: apilifecycle.KeptnEvaluation{ ObjectMeta: v1.ObjectMeta{ Namespace: "namespace", Name: "pre-eval-eval-def-", }, - Status: v1beta1.KeptnEvaluationStatus{ + Status: apilifecycle.KeptnEvaluationStatus{ OverallStatus: apicommon.StateSucceeded, }, }, createAttr: CreateEvaluationAttributes{ SpanName: "", - Definition: v1beta1.KeptnEvaluationDefinition{ + Definition: apilifecycle.KeptnEvaluationDefinition{ ObjectMeta: v1.ObjectMeta{ Name: "eval-def", }, }, CheckType: apicommon.PreDeploymentEvaluationCheckType, }, - wantStatus: []v1beta1.ItemStatus{ + wantStatus: []apilifecycle.ItemStatus{ { DefinitionName: "eval-def", Status: apicommon.StateSucceeded, @@ -393,7 +393,7 @@ func TestEvaluationHandler(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - err := v1beta1.AddToScheme(scheme.Scheme) + err := apilifecycle.AddToScheme(scheme.Scheme) require.Nil(t, err) spanHandlerMock := telemetryfake.ISpanHandlerMock{ GetSpanFunc: func(ctx context.Context, tracer telemetry.ITracer, reconcileObject client.Object, phase string, links ...trace.Link) (context.Context, trace.Span, error) { @@ -453,20 +453,20 @@ func TestEvaluationHandler_createEvaluation(t *testing.T) { }{ { name: "cannot unwrap object", - object: &v1beta1.KeptnEvaluation{}, + object: &apilifecycle.KeptnEvaluation{}, createAttr: CreateEvaluationAttributes{}, wantName: "", wantErr: controllererrors.ErrCannotWrapToPhaseItem, }, { name: "created evaluation", - object: &v1beta1.KeptnAppVersion{ + object: &apilifecycle.KeptnAppVersion{ ObjectMeta: v1.ObjectMeta{ Namespace: "namespace", }, - Spec: v1beta1.KeptnAppVersionSpec{ - KeptnAppContextSpec: v1beta1.KeptnAppContextSpec{ - DeploymentTaskSpec: v1beta1.DeploymentTaskSpec{ + Spec: apilifecycle.KeptnAppVersionSpec{ + KeptnAppContextSpec: apilifecycle.KeptnAppContextSpec{ + DeploymentTaskSpec: apilifecycle.DeploymentTaskSpec{ PreDeploymentEvaluations: []string{"eval-def"}, }, }, @@ -474,7 +474,7 @@ func TestEvaluationHandler_createEvaluation(t *testing.T) { }, createAttr: CreateEvaluationAttributes{ SpanName: "", - Definition: v1beta1.KeptnEvaluationDefinition{ + Definition: apilifecycle.KeptnEvaluationDefinition{ ObjectMeta: v1.ObjectMeta{ Name: "eval-def", }, @@ -488,7 +488,7 @@ func TestEvaluationHandler_createEvaluation(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - err := v1beta1.AddToScheme(scheme.Scheme) + err := apilifecycle.AddToScheme(scheme.Scheme) require.Nil(t, err) handler := NewHandler( diff --git a/lifecycle-operator/controllers/common/eventsender/eventsender.go b/lifecycle-operator/controllers/common/eventsender/eventsender.go index 9c34c7818f..ddabfc24af 100644 --- a/lifecycle-operator/controllers/common/eventsender/eventsender.go +++ b/lifecycle-operator/controllers/common/eventsender/eventsender.go @@ -7,7 +7,7 @@ import ( ce "github.com/cloudevents/sdk-go/v2" "github.com/go-logr/logr" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1/common" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/config" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/lifecycle/interfaces" "golang.org/x/exp/maps" diff --git a/lifecycle-operator/controllers/common/eventsender/eventsender_test.go b/lifecycle-operator/controllers/common/eventsender/eventsender_test.go index f8e1249335..16b709db75 100644 --- a/lifecycle-operator/controllers/common/eventsender/eventsender_test.go +++ b/lifecycle-operator/controllers/common/eventsender/eventsender_test.go @@ -10,8 +10,8 @@ import ( "time" ce "github.com/cloudevents/sdk-go/v2" - "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" - "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" + apilifecycle "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1/common" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/config" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/eventsender/fake" "github.com/stretchr/testify/require" @@ -26,7 +26,7 @@ func TestEventSender_SendK8sEvent(t *testing.T) { fakeRecorder := record.NewFakeRecorder(100) eventSender := NewK8sSender(fakeRecorder) - eventSender.Emit(common.PhaseAppDeployment, "pre-event", &v1beta1.KeptnAppVersion{ + eventSender.Emit(apicommon.PhaseAppDeployment, "pre-event", &apilifecycle.KeptnAppVersion{ ObjectMeta: v1.ObjectMeta{ Name: "app", Namespace: "ns", @@ -35,7 +35,7 @@ func TestEventSender_SendK8sEvent(t *testing.T) { event := <-fakeRecorder.Events - require.Contains(t, event, fmt.Sprintf("%s: reason-long / Namespace: ns, Name: app, Version: ver1", common.PhaseAppDeployment.LongName)) + require.Contains(t, event, fmt.Sprintf("%s: reason-long / Namespace: ns, Name: app, Version: ver1", apicommon.PhaseAppDeployment.LongName)) } func TestEventSender_SendCloudEvent(t *testing.T) { @@ -46,7 +46,7 @@ func TestEventSender_SendCloudEvent(t *testing.T) { eventType := "my-type" version := "v0.0.1-dev" msg := "my message" - phase := common.PhaseAppDeployment + phase := apicommon.PhaseAppDeployment waitToReceive := make(chan bool, 1) // when // we have a CloudEvent endpoint @@ -77,7 +77,7 @@ func TestEventSender_SendCloudEvent(t *testing.T) { log.Fatalf("failed to create client, %v", err) } ceSender := newCloudEventSender(ctrl.Log.WithName("testytest"), c) - ceSender.Emit(phase, eventType, &v1beta1.KeptnAppVersion{ + ceSender.Emit(phase, eventType, &apilifecycle.KeptnAppVersion{ ObjectMeta: v1.ObjectMeta{ Name: name, Namespace: ns, @@ -125,7 +125,7 @@ func TestEventSender_CloudEventNoFailure(t *testing.T) { log.Fatalf("failed to create client, %v", err) } ceSender := newCloudEventSender(ctrl.Log.WithName("testytest"), c) - ceSender.Emit(common.PhaseAppCompleted, "type", &v1beta1.KeptnAppVersion{ + ceSender.Emit(apicommon.PhaseAppCompleted, "type", &apilifecycle.KeptnAppVersion{ ObjectMeta: v1.ObjectMeta{ Name: "app", Namespace: "ns", @@ -173,12 +173,12 @@ func TestEventSender_Multiplexer_emit(t *testing.T) { recE2 := make(chan struct{}) em1 := &fake.MockEvent{} - em1.EmitFunc = func(phase common.KeptnPhaseType, eventType string, reconcileObject client.Object, status string, message string, version string) { + em1.EmitFunc = func(phase apicommon.KeptnPhaseType, eventType string, reconcileObject client.Object, status string, message string, version string) { recE1 <- struct{}{} } em2 := &fake.MockEvent{} - em2.EmitFunc = func(phase common.KeptnPhaseType, eventType string, reconcileObject client.Object, status string, message string, version string) { + em2.EmitFunc = func(phase apicommon.KeptnPhaseType, eventType string, reconcileObject client.Object, status string, message string, version string) { recE2 <- struct{}{} } emitter := EventMultiplexer{} @@ -187,7 +187,7 @@ func TestEventSender_Multiplexer_emit(t *testing.T) { // then // fire a new event msg := "my special message" - emitter.Emit(common.PhaseAppDeployment, "", nil, "", msg, "") + emitter.Emit(apicommon.PhaseAppDeployment, "", nil, "", msg, "") // assert we got one event // wait for the emitMocks to receive the events @@ -229,7 +229,7 @@ func Test_setEventMessage(t *testing.T) { }, } - appVersion := &v1beta1.KeptnAppVersion{ + appVersion := &apilifecycle.KeptnAppVersion{ ObjectMeta: v1.ObjectMeta{ Name: "app", Namespace: "namespace", @@ -237,7 +237,7 @@ func Test_setEventMessage(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - require.Equal(t, setEventMessage(common.PhaseAppDeployment, appVersion, "longReason", tt.version), tt.want) + require.Equal(t, setEventMessage(apicommon.PhaseAppDeployment, appVersion, "longReason", tt.version), tt.want) }) } } @@ -255,12 +255,12 @@ func Test_setAnnotations(t *testing.T) { }, { name: "empty object", - object: &v1beta1.KeptnEvaluationDefinition{}, + object: &apilifecycle.KeptnEvaluationDefinition{}, want: nil, }, { name: "unknown object", - object: &v1beta1.KeptnEvaluationDefinition{ + object: &apilifecycle.KeptnEvaluationDefinition{ ObjectMeta: v1.ObjectMeta{ Name: "def", Namespace: "namespace", @@ -275,7 +275,7 @@ func Test_setAnnotations(t *testing.T) { }, { name: "object with traceparent", - object: &v1beta1.KeptnEvaluationDefinition{ + object: &apilifecycle.KeptnEvaluationDefinition{ ObjectMeta: v1.ObjectMeta{ Name: "def", Namespace: "namespace", @@ -293,13 +293,13 @@ func Test_setAnnotations(t *testing.T) { }, { name: "KeptnApp", - object: &v1beta1.KeptnApp{ + object: &apilifecycle.KeptnApp{ ObjectMeta: v1.ObjectMeta{ Name: "app", Namespace: "namespace", Generation: 1, }, - Spec: v1beta1.KeptnAppSpec{ + Spec: apilifecycle.KeptnAppSpec{ Version: "1.0.0", }, }, @@ -315,14 +315,14 @@ func Test_setAnnotations(t *testing.T) { }, { name: "KeptnAppVersion", - object: &v1beta1.KeptnAppVersion{ + object: &apilifecycle.KeptnAppVersion{ ObjectMeta: v1.ObjectMeta{ Name: "appVersion", Namespace: "namespace", }, - Spec: v1beta1.KeptnAppVersionSpec{ + Spec: apilifecycle.KeptnAppVersionSpec{ AppName: "app", - KeptnAppSpec: v1beta1.KeptnAppSpec{ + KeptnAppSpec: apilifecycle.KeptnAppSpec{ Version: "1.0.0", }, }, @@ -339,12 +339,12 @@ func Test_setAnnotations(t *testing.T) { }, { name: "KeptnWorkload", - object: &v1beta1.KeptnWorkload{ + object: &apilifecycle.KeptnWorkload{ ObjectMeta: v1.ObjectMeta{ Name: "workload", Namespace: "namespace", }, - Spec: v1beta1.KeptnWorkloadSpec{ + Spec: apilifecycle.KeptnWorkloadSpec{ AppName: "app", Version: "1.0.0", }, @@ -361,13 +361,13 @@ func Test_setAnnotations(t *testing.T) { }, { name: "KeptnWorkloadVersion", - object: &v1beta1.KeptnWorkloadVersion{ + object: &apilifecycle.KeptnWorkloadVersion{ ObjectMeta: v1.ObjectMeta{ Name: "workloadVersion", Namespace: "namespace", }, - Spec: v1beta1.KeptnWorkloadVersionSpec{ - KeptnWorkloadSpec: v1beta1.KeptnWorkloadSpec{ + Spec: apilifecycle.KeptnWorkloadVersionSpec{ + KeptnWorkloadSpec: apilifecycle.KeptnWorkloadSpec{ AppName: "app", Version: "1.0.0", }, @@ -387,14 +387,14 @@ func Test_setAnnotations(t *testing.T) { }, { name: "KeptnTask", - object: &v1beta1.KeptnTask{ + object: &apilifecycle.KeptnTask{ ObjectMeta: v1.ObjectMeta{ Name: "task", Namespace: "namespace", }, - Spec: v1beta1.KeptnTaskSpec{ + Spec: apilifecycle.KeptnTaskSpec{ TaskDefinition: "def", - Context: v1beta1.TaskContext{ + Context: apilifecycle.TaskContext{ WorkloadName: "workload", AppName: "app", AppVersion: "1.0.0", @@ -417,12 +417,12 @@ func Test_setAnnotations(t *testing.T) { }, { name: "KeptnEvaluation", - object: &v1beta1.KeptnEvaluation{ + object: &apilifecycle.KeptnEvaluation{ ObjectMeta: v1.ObjectMeta{ Name: "eval", Namespace: "namespace", }, - Spec: v1beta1.KeptnEvaluationSpec{ + Spec: apilifecycle.KeptnEvaluationSpec{ AppName: "app", AppVersion: "1.0.0", Workload: "workload", @@ -447,7 +447,7 @@ func Test_setAnnotations(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - require.Equal(t, setAnnotations(tt.object, common.PhaseAppDeployment), tt.want) + require.Equal(t, setAnnotations(tt.object, apicommon.PhaseAppDeployment), tt.want) }) } } diff --git a/lifecycle-operator/controllers/common/eventsender/fake/event_mock.go b/lifecycle-operator/controllers/common/eventsender/fake/event_mock.go index 4019616842..5d096d6f9e 100644 --- a/lifecycle-operator/controllers/common/eventsender/fake/event_mock.go +++ b/lifecycle-operator/controllers/common/eventsender/fake/event_mock.go @@ -4,7 +4,7 @@ package fake import ( - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1/common" "sigs.k8s.io/controller-runtime/pkg/client" "sync" ) diff --git a/lifecycle-operator/controllers/common/helperfunctions.go b/lifecycle-operator/controllers/common/helperfunctions.go index b6569a393a..fb6b2b870f 100644 --- a/lifecycle-operator/controllers/common/helperfunctions.go +++ b/lifecycle-operator/controllers/common/helperfunctions.go @@ -5,8 +5,8 @@ import ( "fmt" "github.com/go-logr/logr" - klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" + apilifecycle "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1/common" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/config" "golang.org/x/exp/maps" k8serrors "k8s.io/apimachinery/pkg/api/errors" @@ -16,13 +16,13 @@ import ( ) // GetItemStatus retrieves the state of the task/evaluation, if it does not exists, it creates a default one -func GetItemStatus(name string, instanceStatus []klcv1beta1.ItemStatus) klcv1beta1.ItemStatus { +func GetItemStatus(name string, instanceStatus []apilifecycle.ItemStatus) apilifecycle.ItemStatus { for _, status := range instanceStatus { if status.DefinitionName == name { return status } } - return klcv1beta1.ItemStatus{ + return apilifecycle.ItemStatus{ DefinitionName: name, Status: apicommon.StatePending, Name: "", @@ -30,7 +30,7 @@ func GetItemStatus(name string, instanceStatus []klcv1beta1.ItemStatus) klcv1bet } // GetOldStatus retrieves the state of the task/evaluation -func GetOldStatus(name string, statuses []klcv1beta1.ItemStatus) apicommon.KeptnState { +func GetOldStatus(name string, statuses []apilifecycle.ItemStatus) apicommon.KeptnState { var oldstatus apicommon.KeptnState for _, ts := range statuses { if ts.DefinitionName == name { @@ -50,16 +50,16 @@ func MergeMaps[M1 ~map[K]V, K comparable, V any](map1 M1, map2 M1) M1 { return merged } -func GetTaskDefinition(k8sclient client.Client, log logr.Logger, ctx context.Context, definitionName string, namespace string) (*klcv1beta1.KeptnTaskDefinition, error) { - definition := &klcv1beta1.KeptnTaskDefinition{} +func GetTaskDefinition(k8sclient client.Client, log logr.Logger, ctx context.Context, definitionName string, namespace string) (*apilifecycle.KeptnTaskDefinition, error) { + definition := &apilifecycle.KeptnTaskDefinition{} if err := getObject(k8sclient, log, ctx, definitionName, namespace, definition); err != nil { return nil, err } return definition, nil } -func GetEvaluationDefinition(k8sclient client.Client, log logr.Logger, ctx context.Context, definitionName string, namespace string) (*klcv1beta1.KeptnEvaluationDefinition, error) { - definition := &klcv1beta1.KeptnEvaluationDefinition{} +func GetEvaluationDefinition(k8sclient client.Client, log logr.Logger, ctx context.Context, definitionName string, namespace string) (*apilifecycle.KeptnEvaluationDefinition, error) { + definition := &apilifecycle.KeptnEvaluationDefinition{} if err := getObject(k8sclient, log, ctx, definitionName, namespace, definition); err != nil { return nil, err } @@ -92,7 +92,7 @@ func GetRequestInfo(req ctrl.Request) map[string]string { func KeptnWorkloadVersionResourceRefUIDIndexFunc(rawObj client.Object) []string { // Extract the ResourceReference UID name from the KeptnWorkloadVersion Spec, if one is provided - workloadVersion, ok := rawObj.(*klcv1beta1.KeptnWorkloadVersion) + workloadVersion, ok := rawObj.(*apilifecycle.KeptnWorkloadVersion) if !ok { return nil } diff --git a/lifecycle-operator/controllers/common/helperfunctions_test.go b/lifecycle-operator/controllers/common/helperfunctions_test.go index c4a423ae64..debfb62cb7 100644 --- a/lifecycle-operator/controllers/common/helperfunctions_test.go +++ b/lifecycle-operator/controllers/common/helperfunctions_test.go @@ -5,8 +5,8 @@ import ( "reflect" "testing" - klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" + apilifecycle "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1/common" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/config" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/testcommon" "github.com/stretchr/testify/require" @@ -22,19 +22,19 @@ import ( func Test_GetItemStatus(t *testing.T) { tests := []struct { name string - inStatus []klcv1beta1.ItemStatus - want klcv1beta1.ItemStatus + inStatus []apilifecycle.ItemStatus + want apilifecycle.ItemStatus }{ { name: "non-existing", - inStatus: []klcv1beta1.ItemStatus{ + inStatus: []apilifecycle.ItemStatus{ { DefinitionName: "def-name", Name: "name", Status: apicommon.StatePending, }, }, - want: klcv1beta1.ItemStatus{ + want: apilifecycle.ItemStatus{ DefinitionName: "non-existing", Status: apicommon.StatePending, Name: "", @@ -42,14 +42,14 @@ func Test_GetItemStatus(t *testing.T) { }, { name: "def-name", - inStatus: []klcv1beta1.ItemStatus{ + inStatus: []apilifecycle.ItemStatus{ { DefinitionName: "def-name", Name: "name", Status: apicommon.StateProgressing, }, }, - want: klcv1beta1.ItemStatus{ + want: apilifecycle.ItemStatus{ DefinitionName: "def-name", Name: "name", Status: apicommon.StateProgressing, @@ -57,8 +57,8 @@ func Test_GetItemStatus(t *testing.T) { }, { name: "empty", - inStatus: []klcv1beta1.ItemStatus{}, - want: klcv1beta1.ItemStatus{ + inStatus: []apilifecycle.ItemStatus{}, + want: apilifecycle.ItemStatus{ DefinitionName: "empty", Status: apicommon.StatePending, Name: "", @@ -75,22 +75,22 @@ func Test_GetItemStatus(t *testing.T) { func Test_GetOldStatus(t *testing.T) { tests := []struct { - statuses []klcv1beta1.ItemStatus + statuses []apilifecycle.ItemStatus definitionName string want apicommon.KeptnState }{ { - statuses: []klcv1beta1.ItemStatus{}, + statuses: []apilifecycle.ItemStatus{}, definitionName: "", want: "", }, { - statuses: []klcv1beta1.ItemStatus{}, + statuses: []apilifecycle.ItemStatus{}, definitionName: "defName", want: "", }, { - statuses: []klcv1beta1.ItemStatus{ + statuses: []apilifecycle.ItemStatus{ { DefinitionName: "defName", Status: apicommon.StateFailed, @@ -101,7 +101,7 @@ func Test_GetOldStatus(t *testing.T) { want: "", }, { - statuses: []klcv1beta1.ItemStatus{ + statuses: []apilifecycle.ItemStatus{ { DefinitionName: "defName", Status: apicommon.StateFailed, @@ -124,15 +124,15 @@ func Test_GetOldStatus(t *testing.T) { func Test_GetTaskDefinition(t *testing.T) { tests := []struct { name string - taskDef *klcv1beta1.KeptnTaskDefinition + taskDef *apilifecycle.KeptnTaskDefinition taskDefName string taskDefNamespace string - out *klcv1beta1.KeptnTaskDefinition + out *apilifecycle.KeptnTaskDefinition wantError bool }{ { name: "taskDef not found", - taskDef: &klcv1beta1.KeptnTaskDefinition{ + taskDef: &apilifecycle.KeptnTaskDefinition{ ObjectMeta: metav1.ObjectMeta{ Name: "taskDef", Namespace: "some-other-namespace", @@ -145,7 +145,7 @@ func Test_GetTaskDefinition(t *testing.T) { }, { name: "taskDef found", - taskDef: &klcv1beta1.KeptnTaskDefinition{ + taskDef: &apilifecycle.KeptnTaskDefinition{ ObjectMeta: metav1.ObjectMeta{ Name: "taskDef", Namespace: "some-namespace", @@ -153,7 +153,7 @@ func Test_GetTaskDefinition(t *testing.T) { }, taskDefName: "taskDef", taskDefNamespace: "some-namespace", - out: &klcv1beta1.KeptnTaskDefinition{ + out: &apilifecycle.KeptnTaskDefinition{ ObjectMeta: metav1.ObjectMeta{ Name: "taskDef", Namespace: "some-namespace", @@ -163,7 +163,7 @@ func Test_GetTaskDefinition(t *testing.T) { }, { name: "taskDef found in default Keptn namespace", - taskDef: &klcv1beta1.KeptnTaskDefinition{ + taskDef: &apilifecycle.KeptnTaskDefinition{ ObjectMeta: metav1.ObjectMeta{ Name: "taskDef", Namespace: testcommon.KeptnNamespace, @@ -171,7 +171,7 @@ func Test_GetTaskDefinition(t *testing.T) { }, taskDefName: "taskDef", taskDefNamespace: "some-namespace", - out: &klcv1beta1.KeptnTaskDefinition{ + out: &apilifecycle.KeptnTaskDefinition{ ObjectMeta: metav1.ObjectMeta{ Name: "taskDef", Namespace: testcommon.KeptnNamespace, @@ -181,7 +181,7 @@ func Test_GetTaskDefinition(t *testing.T) { }, } - err := klcv1beta1.AddToScheme(scheme.Scheme) + err := apilifecycle.AddToScheme(scheme.Scheme) require.Nil(t, err) config.Instance().SetDefaultNamespace(testcommon.KeptnNamespace) @@ -208,15 +208,15 @@ func Test_GetTaskDefinition(t *testing.T) { func Test_GetEvaluationDefinition(t *testing.T) { tests := []struct { name string - evalDef *klcv1beta1.KeptnEvaluationDefinition + evalDef *apilifecycle.KeptnEvaluationDefinition evalDefName string evalDefNamespace string - out *klcv1beta1.KeptnEvaluationDefinition + out *apilifecycle.KeptnEvaluationDefinition wantError bool }{ { name: "evalDef not found", - evalDef: &klcv1beta1.KeptnEvaluationDefinition{ + evalDef: &apilifecycle.KeptnEvaluationDefinition{ ObjectMeta: metav1.ObjectMeta{ Name: "evalDef", Namespace: "some-other-namespace", @@ -229,7 +229,7 @@ func Test_GetEvaluationDefinition(t *testing.T) { }, { name: "evalDef found", - evalDef: &klcv1beta1.KeptnEvaluationDefinition{ + evalDef: &apilifecycle.KeptnEvaluationDefinition{ ObjectMeta: metav1.ObjectMeta{ Name: "evalDef", Namespace: "some-namespace", @@ -237,7 +237,7 @@ func Test_GetEvaluationDefinition(t *testing.T) { }, evalDefName: "evalDef", evalDefNamespace: "some-namespace", - out: &klcv1beta1.KeptnEvaluationDefinition{ + out: &apilifecycle.KeptnEvaluationDefinition{ ObjectMeta: metav1.ObjectMeta{ Name: "evalDef", Namespace: "some-namespace", @@ -247,7 +247,7 @@ func Test_GetEvaluationDefinition(t *testing.T) { }, { name: "evalDef found in default Keptn namespace", - evalDef: &klcv1beta1.KeptnEvaluationDefinition{ + evalDef: &apilifecycle.KeptnEvaluationDefinition{ ObjectMeta: metav1.ObjectMeta{ Name: "evalDef", Namespace: testcommon.KeptnNamespace, @@ -255,7 +255,7 @@ func Test_GetEvaluationDefinition(t *testing.T) { }, evalDefName: "evalDef", evalDefNamespace: "some-namespace", - out: &klcv1beta1.KeptnEvaluationDefinition{ + out: &apilifecycle.KeptnEvaluationDefinition{ ObjectMeta: metav1.ObjectMeta{ Name: "evalDef", Namespace: testcommon.KeptnNamespace, @@ -265,7 +265,7 @@ func Test_GetEvaluationDefinition(t *testing.T) { }, } - err := klcv1beta1.AddToScheme(scheme.Scheme) + err := apilifecycle.AddToScheme(scheme.Scheme) require.Nil(t, err) config.Instance().SetDefaultNamespace(testcommon.KeptnNamespace) @@ -397,10 +397,10 @@ func Test_resourceRefUIDIndexFunc(t *testing.T) { { name: "get uid of resource reference", args: args{ - rawObj: &klcv1beta1.KeptnWorkloadVersion{ - Spec: klcv1beta1.KeptnWorkloadVersionSpec{ - KeptnWorkloadSpec: klcv1beta1.KeptnWorkloadSpec{ - ResourceReference: klcv1beta1.ResourceReference{ + rawObj: &apilifecycle.KeptnWorkloadVersion{ + Spec: apilifecycle.KeptnWorkloadVersionSpec{ + KeptnWorkloadSpec: apilifecycle.KeptnWorkloadSpec{ + ResourceReference: apilifecycle.ResourceReference{ UID: "my-uid", }, }, @@ -412,10 +412,10 @@ func Test_resourceRefUIDIndexFunc(t *testing.T) { { name: "empty uid", args: args{ - rawObj: &klcv1beta1.KeptnWorkloadVersion{ - Spec: klcv1beta1.KeptnWorkloadVersionSpec{ - KeptnWorkloadSpec: klcv1beta1.KeptnWorkloadSpec{ - ResourceReference: klcv1beta1.ResourceReference{ + rawObj: &apilifecycle.KeptnWorkloadVersion{ + Spec: apilifecycle.KeptnWorkloadVersionSpec{ + KeptnWorkloadSpec: apilifecycle.KeptnWorkloadSpec{ + ResourceReference: apilifecycle.ResourceReference{ UID: "", }, }, diff --git a/lifecycle-operator/controllers/common/phase/fake/handler_mock.go b/lifecycle-operator/controllers/common/phase/fake/handler_mock.go index 428dd3baf7..2801a87d3c 100644 --- a/lifecycle-operator/controllers/common/phase/fake/handler_mock.go +++ b/lifecycle-operator/controllers/common/phase/fake/handler_mock.go @@ -5,7 +5,7 @@ package fake import ( "context" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1/common" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/phase" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/telemetry" "sigs.k8s.io/controller-runtime/pkg/client" diff --git a/lifecycle-operator/controllers/common/phase/handler.go b/lifecycle-operator/controllers/common/phase/handler.go index fb144d8050..2463e0fd93 100644 --- a/lifecycle-operator/controllers/common/phase/handler.go +++ b/lifecycle-operator/controllers/common/phase/handler.go @@ -5,7 +5,7 @@ import ( "time" "github.com/go-logr/logr" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1/common" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/eventsender" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/telemetry" controllererrors "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/errors" diff --git a/lifecycle-operator/controllers/common/phase/handler_test.go b/lifecycle-operator/controllers/common/phase/handler_test.go index 4ae55ccb4c..32bc668c85 100644 --- a/lifecycle-operator/controllers/common/phase/handler_test.go +++ b/lifecycle-operator/controllers/common/phase/handler_test.go @@ -6,8 +6,8 @@ import ( "testing" "time" - "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" + apilifecycle "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1/common" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/eventsender" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/telemetry" "github.com/stretchr/testify/require" @@ -24,10 +24,10 @@ func TestHandler(t *testing.T) { tests := []struct { name string handler Handler - object *v1beta1.KeptnAppVersion + object *apilifecycle.KeptnAppVersion phase apicommon.KeptnPhaseType reconcilePhase func(phaseCtx context.Context) (apicommon.KeptnState, error) - wantObject *v1beta1.KeptnAppVersion + wantObject *apilifecycle.KeptnAppVersion want PhaseResult wantErr error endTimeSet bool @@ -37,15 +37,15 @@ func TestHandler(t *testing.T) { handler: Handler{ SpanHandler: &telemetry.Handler{}, }, - object: &v1beta1.KeptnAppVersion{ - Status: v1beta1.KeptnAppVersionStatus{ + object: &apilifecycle.KeptnAppVersion{ + Status: apilifecycle.KeptnAppVersionStatus{ Status: apicommon.StateDeprecated, }, }, want: PhaseResult{Continue: false, Result: ctrl.Result{}}, wantErr: nil, - wantObject: &v1beta1.KeptnAppVersion{ - Status: v1beta1.KeptnAppVersionStatus{ + wantObject: &apilifecycle.KeptnAppVersion{ + Status: apilifecycle.KeptnAppVersionStatus{ Status: apicommon.StateDeprecated, }, }, @@ -58,8 +58,8 @@ func TestHandler(t *testing.T) { EventSender: eventsender.NewK8sSender(record.NewFakeRecorder(100)), Client: fake.NewClientBuilder().WithScheme(scheme.Scheme).Build(), }, - object: &v1beta1.KeptnAppVersion{ - Status: v1beta1.KeptnAppVersionStatus{ + object: &apilifecycle.KeptnAppVersion{ + Status: apilifecycle.KeptnAppVersionStatus{ Status: apicommon.StatePending, CurrentPhase: apicommon.PhaseAppDeployment.LongName, }, @@ -70,8 +70,8 @@ func TestHandler(t *testing.T) { }, want: PhaseResult{Continue: false, Result: requeueResult}, wantErr: fmt.Errorf("some err"), - wantObject: &v1beta1.KeptnAppVersion{ - Status: v1beta1.KeptnAppVersionStatus{ + wantObject: &apilifecycle.KeptnAppVersion{ + Status: apilifecycle.KeptnAppVersionStatus{ Status: apicommon.StatePending, CurrentPhase: apicommon.PhaseAppDeployment.ShortName, }, @@ -85,8 +85,8 @@ func TestHandler(t *testing.T) { EventSender: eventsender.NewK8sSender(record.NewFakeRecorder(100)), Client: fake.NewClientBuilder().WithScheme(scheme.Scheme).Build(), }, - object: &v1beta1.KeptnAppVersion{ - Status: v1beta1.KeptnAppVersionStatus{ + object: &apilifecycle.KeptnAppVersion{ + Status: apilifecycle.KeptnAppVersionStatus{ Status: apicommon.StatePending, CurrentPhase: apicommon.PhaseAppDeployment.LongName, }, @@ -97,8 +97,8 @@ func TestHandler(t *testing.T) { }, want: PhaseResult{Continue: false, Result: requeueResult}, wantErr: nil, - wantObject: &v1beta1.KeptnAppVersion{ - Status: v1beta1.KeptnAppVersionStatus{ + wantObject: &apilifecycle.KeptnAppVersion{ + Status: apilifecycle.KeptnAppVersionStatus{ Status: apicommon.StateProgressing, CurrentPhase: apicommon.PhaseAppDeployment.ShortName, }, @@ -112,8 +112,8 @@ func TestHandler(t *testing.T) { EventSender: eventsender.NewK8sSender(record.NewFakeRecorder(100)), Client: fake.NewClientBuilder().WithScheme(scheme.Scheme).Build(), }, - object: &v1beta1.KeptnAppVersion{ - Status: v1beta1.KeptnAppVersionStatus{ + object: &apilifecycle.KeptnAppVersion{ + Status: apilifecycle.KeptnAppVersionStatus{ Status: apicommon.StatePending, CurrentPhase: apicommon.PhaseAppDeployment.LongName, }, @@ -124,8 +124,8 @@ func TestHandler(t *testing.T) { }, want: PhaseResult{Continue: false, Result: requeueResult}, wantErr: nil, - wantObject: &v1beta1.KeptnAppVersion{ - Status: v1beta1.KeptnAppVersionStatus{ + wantObject: &apilifecycle.KeptnAppVersion{ + Status: apilifecycle.KeptnAppVersionStatus{ Status: apicommon.StateProgressing, CurrentPhase: apicommon.PhaseAppDeployment.ShortName, }, @@ -139,8 +139,8 @@ func TestHandler(t *testing.T) { EventSender: eventsender.NewK8sSender(record.NewFakeRecorder(100)), Client: fake.NewClientBuilder().WithScheme(scheme.Scheme).Build(), }, - object: &v1beta1.KeptnAppVersion{ - Status: v1beta1.KeptnAppVersionStatus{ + object: &apilifecycle.KeptnAppVersion{ + Status: apilifecycle.KeptnAppVersionStatus{ Status: apicommon.StatePending, CurrentPhase: apicommon.PhaseAppDeployment.LongName, }, @@ -151,8 +151,8 @@ func TestHandler(t *testing.T) { }, want: PhaseResult{Continue: true, Result: requeueResult}, wantErr: nil, - wantObject: &v1beta1.KeptnAppVersion{ - Status: v1beta1.KeptnAppVersionStatus{ + wantObject: &apilifecycle.KeptnAppVersion{ + Status: apilifecycle.KeptnAppVersionStatus{ Status: apicommon.StatePending, CurrentPhase: apicommon.PhaseAppDeployment.ShortName, }, @@ -166,8 +166,8 @@ func TestHandler(t *testing.T) { EventSender: eventsender.NewK8sSender(record.NewFakeRecorder(100)), Client: fake.NewClientBuilder().WithScheme(scheme.Scheme).Build(), }, - object: &v1beta1.KeptnAppVersion{ - Status: v1beta1.KeptnAppVersionStatus{ + object: &apilifecycle.KeptnAppVersion{ + Status: apilifecycle.KeptnAppVersionStatus{ Status: apicommon.StateProgressing, CurrentPhase: apicommon.PhaseAppPreEvaluation.LongName, }, @@ -178,8 +178,8 @@ func TestHandler(t *testing.T) { }, want: PhaseResult{Continue: false, Result: ctrl.Result{}}, wantErr: nil, - wantObject: &v1beta1.KeptnAppVersion{ - Status: v1beta1.KeptnAppVersionStatus{ + wantObject: &apilifecycle.KeptnAppVersion{ + Status: apilifecycle.KeptnAppVersionStatus{ Status: apicommon.StateFailed, CurrentPhase: apicommon.PhaseAppPreEvaluation.ShortName, EndTime: v1.Time{Time: time.Now().UTC()}, @@ -194,8 +194,8 @@ func TestHandler(t *testing.T) { EventSender: eventsender.NewK8sSender(record.NewFakeRecorder(100)), Client: fake.NewClientBuilder().WithScheme(scheme.Scheme).Build(), }, - object: &v1beta1.KeptnAppVersion{ - Status: v1beta1.KeptnAppVersionStatus{ + object: &apilifecycle.KeptnAppVersion{ + Status: apilifecycle.KeptnAppVersionStatus{ Status: apicommon.StateProgressing, CurrentPhase: apicommon.PhaseAppPreEvaluation.LongName, }, @@ -206,8 +206,8 @@ func TestHandler(t *testing.T) { }, want: PhaseResult{Continue: false, Result: requeueResult}, wantErr: nil, - wantObject: &v1beta1.KeptnAppVersion{ - Status: v1beta1.KeptnAppVersionStatus{ + wantObject: &apilifecycle.KeptnAppVersion{ + Status: apilifecycle.KeptnAppVersionStatus{ Status: apicommon.StateProgressing, CurrentPhase: apicommon.PhaseAppPreEvaluation.ShortName, }, diff --git a/lifecycle-operator/controllers/common/providers/keptnmetric/keptnmetric.go b/lifecycle-operator/controllers/common/providers/keptnmetric/keptnmetric.go index eb60cccdcd..870faa8258 100644 --- a/lifecycle-operator/controllers/common/providers/keptnmetric/keptnmetric.go +++ b/lifecycle-operator/controllers/common/providers/keptnmetric/keptnmetric.go @@ -5,7 +5,7 @@ import ( "fmt" "github.com/go-logr/logr" - klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" + apilifecycle "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/config" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/types" @@ -18,7 +18,7 @@ type KeptnMetricProvider struct { } // FetchData fetches the SLI values from KeptnMetric resource -func (p *KeptnMetricProvider) FetchData(ctx context.Context, objective klcv1beta1.Objective, namespace string) (string, []byte, error) { +func (p *KeptnMetricProvider) FetchData(ctx context.Context, objective apilifecycle.Objective, namespace string) (string, []byte, error) { metric, err := p.GetKeptnMetric(ctx, objective, namespace) if err != nil { return "", nil, err @@ -41,7 +41,7 @@ func (p *KeptnMetricProvider) FetchData(ctx context.Context, objective klcv1beta return value, []byte(rawValue), nil } -func (p *KeptnMetricProvider) GetKeptnMetric(ctx context.Context, objective klcv1beta1.Objective, namespace string) (*unstructured.Unstructured, error) { +func (p *KeptnMetricProvider) GetKeptnMetric(ctx context.Context, objective apilifecycle.Objective, namespace string) (*unstructured.Unstructured, error) { metric := &unstructured.Unstructured{ Object: map[string]interface{}{ "kind": "KeptnMetric", diff --git a/lifecycle-operator/controllers/common/providers/keptnmetric/keptnmetric_test.go b/lifecycle-operator/controllers/common/providers/keptnmetric/keptnmetric_test.go index 7a4b6b1121..16407f639a 100644 --- a/lifecycle-operator/controllers/common/providers/keptnmetric/keptnmetric_test.go +++ b/lifecycle-operator/controllers/common/providers/keptnmetric/keptnmetric_test.go @@ -4,7 +4,7 @@ import ( "context" "testing" - klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" + apilifecycle "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/config" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/testcommon" metricsapi "github.com/keptn/lifecycle-toolkit/lifecycle-operator/test/api/metrics/v1" @@ -88,8 +88,8 @@ func Test_keptnmetric(t *testing.T) { K8sClient: client, } - obj := klcv1beta1.Objective{ - KeptnMetricRef: klcv1beta1.KeptnMetricReference{ + obj := apilifecycle.Objective{ + KeptnMetricRef: apilifecycle.KeptnMetricReference{ Name: "metric", Namespace: "default", }, @@ -110,7 +110,7 @@ func Test_keptnmetric(t *testing.T) { func Test_Getkeptnmetric(t *testing.T) { tests := []struct { name string - objective klcv1beta1.Objective + objective apilifecycle.Objective metric *metricsapi.KeptnMetric namespace string out *metricsapi.KeptnMetric @@ -118,8 +118,8 @@ func Test_Getkeptnmetric(t *testing.T) { }{ { name: "objective with namespace and existing keptnmetric", - objective: klcv1beta1.Objective{ - KeptnMetricRef: klcv1beta1.KeptnMetricReference{ + objective: apilifecycle.Objective{ + KeptnMetricRef: apilifecycle.KeptnMetricReference{ Name: "metric", Namespace: "my-namespace", }, @@ -141,8 +141,8 @@ func Test_Getkeptnmetric(t *testing.T) { }, { name: "objective with namespace and non-existing keptnmetric", - objective: klcv1beta1.Objective{ - KeptnMetricRef: klcv1beta1.KeptnMetricReference{ + objective: apilifecycle.Objective{ + KeptnMetricRef: apilifecycle.KeptnMetricReference{ Name: "metric", Namespace: "my-namespace", }, @@ -159,8 +159,8 @@ func Test_Getkeptnmetric(t *testing.T) { }, { name: "objective without namespace and existing keptnmetric", - objective: klcv1beta1.Objective{ - KeptnMetricRef: klcv1beta1.KeptnMetricReference{ + objective: apilifecycle.Objective{ + KeptnMetricRef: apilifecycle.KeptnMetricReference{ Name: "metric", }, }, @@ -181,8 +181,8 @@ func Test_Getkeptnmetric(t *testing.T) { }, { name: "objective without namespace and existing keptnmetric in default Keptn namespace", - objective: klcv1beta1.Objective{ - KeptnMetricRef: klcv1beta1.KeptnMetricReference{ + objective: apilifecycle.Objective{ + KeptnMetricRef: apilifecycle.KeptnMetricReference{ Name: "metric", }, }, diff --git a/lifecycle-operator/controllers/common/task/handler.go b/lifecycle-operator/controllers/common/task/handler.go index e700eb86e7..b089832384 100644 --- a/lifecycle-operator/controllers/common/task/handler.go +++ b/lifecycle-operator/controllers/common/task/handler.go @@ -6,8 +6,8 @@ import ( "time" "github.com/go-logr/logr" - klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" + apilifecycle "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1/common" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common" keptncontext "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/context" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/eventsender" @@ -37,12 +37,12 @@ type Handler struct { type CreateTaskAttributes struct { SpanName string - Definition klcv1beta1.KeptnTaskDefinition + Definition apilifecycle.KeptnTaskDefinition CheckType apicommon.CheckType } //nolint:gocognit,gocyclo -func (r Handler) ReconcileTasks(ctx context.Context, phaseCtx context.Context, reconcileObject client.Object, taskCreateAttributes CreateTaskAttributes) ([]klcv1beta1.ItemStatus, apicommon.StatusSummary, error) { +func (r Handler) ReconcileTasks(ctx context.Context, phaseCtx context.Context, reconcileObject client.Object, taskCreateAttributes CreateTaskAttributes) ([]apilifecycle.ItemStatus, apicommon.StatusSummary, error) { piWrapper, err := interfaces.NewPhaseItemWrapperFromClientObject(reconcileObject) if err != nil { return nil, apicommon.StatusSummary{}, err @@ -55,12 +55,12 @@ func (r Handler) ReconcileTasks(ctx context.Context, phaseCtx context.Context, r var summary apicommon.StatusSummary summary.Total = len(tasks) // Check current state of the PrePostDeploymentTasks - var newStatus []klcv1beta1.ItemStatus + var newStatus []apilifecycle.ItemStatus for _, taskDefinitionName := range tasks { oldstatus := common.GetOldStatus(taskDefinitionName, statuses) taskStatus := common.GetItemStatus(taskDefinitionName, statuses) - task := &klcv1beta1.KeptnTask{} + task := &apilifecycle.KeptnTask{} taskExists := false if oldstatus != taskStatus.Status { @@ -152,7 +152,7 @@ func (r Handler) CreateKeptnTask(ctx, phaseCtx context.Context, namespace string return newTask.Name, nil } -func injectKeptnContext(phaseCtx context.Context, newTask *klcv1beta1.KeptnTask) { +func injectKeptnContext(phaseCtx context.Context, newTask *apilifecycle.KeptnTask) { if metadata, ok := keptncontext.GetAppMetadataFromContext(phaseCtx); ok { traceContextCarrier := &propagation.MapCarrier{} otel.GetTextMapPropagator().Inject(phaseCtx, traceContextCarrier) @@ -164,13 +164,13 @@ func injectKeptnContext(phaseCtx context.Context, newTask *klcv1beta1.KeptnTask) } } -func (r Handler) setTaskFailureEvents(task *klcv1beta1.KeptnTask, spanTrace trace.Span) { +func (r Handler) setTaskFailureEvents(task *apilifecycle.KeptnTask, spanTrace trace.Span) { spanTrace.AddEvent(fmt.Sprintf("task '%s' failed with reason: '%s'", task.Name, task.Status.Message), trace.WithTimestamp(time.Now().UTC())) } -func (r Handler) setupTasks(taskCreateAttributes CreateTaskAttributes, piWrapper *interfaces.PhaseItemWrapper) ([]string, []klcv1beta1.ItemStatus) { +func (r Handler) setupTasks(taskCreateAttributes CreateTaskAttributes, piWrapper *interfaces.PhaseItemWrapper) ([]string, []apilifecycle.ItemStatus) { var tasks []string - var statuses []klcv1beta1.ItemStatus + var statuses []apilifecycle.ItemStatus switch taskCreateAttributes.CheckType { case apicommon.PreDeploymentCheckType: @@ -186,7 +186,7 @@ func (r Handler) setupTasks(taskCreateAttributes CreateTaskAttributes, piWrapper return tasks, statuses } -func (r Handler) handleTaskNotExists(ctx context.Context, phaseCtx context.Context, taskCreateAttributes CreateTaskAttributes, taskName string, piWrapper *interfaces.PhaseItemWrapper, reconcileObject client.Object, task *klcv1beta1.KeptnTask, taskStatus *klcv1beta1.ItemStatus) error { +func (r Handler) handleTaskNotExists(ctx context.Context, phaseCtx context.Context, taskCreateAttributes CreateTaskAttributes, taskName string, piWrapper *interfaces.PhaseItemWrapper, reconcileObject client.Object, task *apilifecycle.KeptnTask, taskStatus *apilifecycle.ItemStatus) error { definition, err := common.GetTaskDefinition(r.Client, r.Log, ctx, taskName, piWrapper.GetNamespace()) if err != nil { return controllererrors.ErrCannotGetKeptnTaskDefinition @@ -206,7 +206,7 @@ func (r Handler) handleTaskNotExists(ctx context.Context, phaseCtx context.Conte return nil } -func (r Handler) handleTaskExists(phaseCtx context.Context, task *klcv1beta1.KeptnTask, taskStatus *klcv1beta1.ItemStatus) { +func (r Handler) handleTaskExists(phaseCtx context.Context, task *apilifecycle.KeptnTask, taskStatus *apilifecycle.ItemStatus) { _, spanTaskTrace, err := r.SpanHandler.GetSpan(phaseCtx, r.Tracer, task, "") if err != nil { r.Log.Error(err, "could not get span") diff --git a/lifecycle-operator/controllers/common/task/handler_test.go b/lifecycle-operator/controllers/common/task/handler_test.go index f22114b624..c33864b58e 100644 --- a/lifecycle-operator/controllers/common/task/handler_test.go +++ b/lifecycle-operator/controllers/common/task/handler_test.go @@ -6,8 +6,8 @@ import ( "strings" "testing" - "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" + apilifecycle "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1/common" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/config" keptncontext "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/context" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/eventsender" @@ -35,18 +35,18 @@ func TestTaskHandler(t *testing.T) { name string object client.Object createAttr CreateTaskAttributes - wantStatus []v1beta1.ItemStatus + wantStatus []apilifecycle.ItemStatus wantSummary apicommon.StatusSummary - taskObj v1beta1.KeptnTask - taskDef *v1beta1.KeptnTaskDefinition + taskObj apilifecycle.KeptnTask + taskDef *apilifecycle.KeptnTaskDefinition wantErr error getSpanCalls int unbindSpanCalls int }{ { name: "cannot unwrap object", - object: &v1beta1.KeptnTask{}, - taskObj: v1beta1.KeptnTask{}, + object: &apilifecycle.KeptnTask{}, + taskObj: apilifecycle.KeptnTask{}, createAttr: CreateTaskAttributes{}, wantStatus: nil, wantSummary: apicommon.StatusSummary{}, @@ -56,14 +56,14 @@ func TestTaskHandler(t *testing.T) { }, { name: "no tasks", - object: &v1beta1.KeptnAppVersion{}, - taskObj: v1beta1.KeptnTask{}, + object: &apilifecycle.KeptnAppVersion{}, + taskObj: apilifecycle.KeptnTask{}, createAttr: CreateTaskAttributes{ SpanName: "", - Definition: v1beta1.KeptnTaskDefinition{}, + Definition: apilifecycle.KeptnTaskDefinition{}, CheckType: apicommon.PreDeploymentCheckType, }, - wantStatus: []v1beta1.ItemStatus(nil), + wantStatus: []apilifecycle.ItemStatus(nil), wantSummary: apicommon.StatusSummary{}, wantErr: nil, getSpanCalls: 0, @@ -71,22 +71,22 @@ func TestTaskHandler(t *testing.T) { }, { name: "task not started - could not find taskDefinition", - object: &v1beta1.KeptnAppVersion{ + object: &apilifecycle.KeptnAppVersion{ ObjectMeta: v1.ObjectMeta{ Namespace: "namespace", }, - Spec: v1beta1.KeptnAppVersionSpec{ - KeptnAppContextSpec: v1beta1.KeptnAppContextSpec{ - DeploymentTaskSpec: v1beta1.DeploymentTaskSpec{ + Spec: apilifecycle.KeptnAppVersionSpec{ + KeptnAppContextSpec: apilifecycle.KeptnAppContextSpec{ + DeploymentTaskSpec: apilifecycle.DeploymentTaskSpec{ PreDeploymentTasks: []string{"task-def"}, }, }, }, }, - taskObj: v1beta1.KeptnTask{}, + taskObj: apilifecycle.KeptnTask{}, createAttr: CreateTaskAttributes{ SpanName: "", - Definition: v1beta1.KeptnTaskDefinition{ + Definition: apilifecycle.KeptnTaskDefinition{ ObjectMeta: v1.ObjectMeta{ Name: "task-def", }, @@ -101,35 +101,35 @@ func TestTaskHandler(t *testing.T) { }, { name: "tasks not started - could not find taskDefinition of one task", - object: &v1beta1.KeptnAppVersion{ + object: &apilifecycle.KeptnAppVersion{ ObjectMeta: v1.ObjectMeta{ Namespace: "namespace", }, - Spec: v1beta1.KeptnAppVersionSpec{ - KeptnAppContextSpec: v1beta1.KeptnAppContextSpec{ - DeploymentTaskSpec: v1beta1.DeploymentTaskSpec{ + Spec: apilifecycle.KeptnAppVersionSpec{ + KeptnAppContextSpec: apilifecycle.KeptnAppContextSpec{ + DeploymentTaskSpec: apilifecycle.DeploymentTaskSpec{ PreDeploymentTasks: []string{"task-def", "other-task-def"}, }, }, }, }, - taskDef: &v1beta1.KeptnTaskDefinition{ + taskDef: &apilifecycle.KeptnTaskDefinition{ ObjectMeta: v1.ObjectMeta{ Namespace: testcommon.KeptnNamespace, Name: "task-def", }, }, - taskObj: v1beta1.KeptnTask{}, + taskObj: apilifecycle.KeptnTask{}, createAttr: CreateTaskAttributes{ SpanName: "", - Definition: v1beta1.KeptnTaskDefinition{ + Definition: apilifecycle.KeptnTaskDefinition{ ObjectMeta: v1.ObjectMeta{ Name: "task-def", }, }, CheckType: apicommon.PreDeploymentCheckType, }, - wantStatus: []v1beta1.ItemStatus{ + wantStatus: []apilifecycle.ItemStatus{ { DefinitionName: "task-def", Status: apicommon.StatePending, @@ -143,35 +143,35 @@ func TestTaskHandler(t *testing.T) { }, { name: "task not started - taskDefinition in default Keptn namespace", - object: &v1beta1.KeptnAppVersion{ + object: &apilifecycle.KeptnAppVersion{ ObjectMeta: v1.ObjectMeta{ Namespace: "namespace", }, - Spec: v1beta1.KeptnAppVersionSpec{ - KeptnAppContextSpec: v1beta1.KeptnAppContextSpec{ - DeploymentTaskSpec: v1beta1.DeploymentTaskSpec{ + Spec: apilifecycle.KeptnAppVersionSpec{ + KeptnAppContextSpec: apilifecycle.KeptnAppContextSpec{ + DeploymentTaskSpec: apilifecycle.DeploymentTaskSpec{ PreDeploymentTasks: []string{"task-def"}, }, }, }, }, - taskDef: &v1beta1.KeptnTaskDefinition{ + taskDef: &apilifecycle.KeptnTaskDefinition{ ObjectMeta: v1.ObjectMeta{ Namespace: testcommon.KeptnNamespace, Name: "task-def", }, }, - taskObj: v1beta1.KeptnTask{}, + taskObj: apilifecycle.KeptnTask{}, createAttr: CreateTaskAttributes{ SpanName: "", - Definition: v1beta1.KeptnTaskDefinition{ + Definition: apilifecycle.KeptnTaskDefinition{ ObjectMeta: v1.ObjectMeta{ Name: "task-def", }, }, CheckType: apicommon.PreDeploymentCheckType, }, - wantStatus: []v1beta1.ItemStatus{ + wantStatus: []apilifecycle.ItemStatus{ { DefinitionName: "task-def", Status: apicommon.StatePending, @@ -185,35 +185,35 @@ func TestTaskHandler(t *testing.T) { }, { name: "task not started", - object: &v1beta1.KeptnAppVersion{ + object: &apilifecycle.KeptnAppVersion{ ObjectMeta: v1.ObjectMeta{ Namespace: "namespace", }, - Spec: v1beta1.KeptnAppVersionSpec{ - KeptnAppContextSpec: v1beta1.KeptnAppContextSpec{ - DeploymentTaskSpec: v1beta1.DeploymentTaskSpec{ + Spec: apilifecycle.KeptnAppVersionSpec{ + KeptnAppContextSpec: apilifecycle.KeptnAppContextSpec{ + DeploymentTaskSpec: apilifecycle.DeploymentTaskSpec{ PreDeploymentTasks: []string{"task-def"}, }, }, }, }, - taskDef: &v1beta1.KeptnTaskDefinition{ + taskDef: &apilifecycle.KeptnTaskDefinition{ ObjectMeta: v1.ObjectMeta{ Namespace: "namespace", Name: "task-def", }, }, - taskObj: v1beta1.KeptnTask{}, + taskObj: apilifecycle.KeptnTask{}, createAttr: CreateTaskAttributes{ SpanName: "", - Definition: v1beta1.KeptnTaskDefinition{ + Definition: apilifecycle.KeptnTaskDefinition{ ObjectMeta: v1.ObjectMeta{ Name: "task-def", }, }, CheckType: apicommon.PreDeploymentCheckType, }, - wantStatus: []v1beta1.ItemStatus{ + wantStatus: []apilifecycle.ItemStatus{ { DefinitionName: "task-def", Status: apicommon.StatePending, @@ -227,17 +227,17 @@ func TestTaskHandler(t *testing.T) { }, { name: "already done task", - object: &v1beta1.KeptnAppVersion{ - Spec: v1beta1.KeptnAppVersionSpec{ - KeptnAppContextSpec: v1beta1.KeptnAppContextSpec{ - DeploymentTaskSpec: v1beta1.DeploymentTaskSpec{ + object: &apilifecycle.KeptnAppVersion{ + Spec: apilifecycle.KeptnAppVersionSpec{ + KeptnAppContextSpec: apilifecycle.KeptnAppContextSpec{ + DeploymentTaskSpec: apilifecycle.DeploymentTaskSpec{ PreDeploymentTasks: []string{"task-def"}, }, }, }, - Status: v1beta1.KeptnAppVersionStatus{ + Status: apilifecycle.KeptnAppVersionStatus{ PreDeploymentStatus: apicommon.StateSucceeded, - PreDeploymentTaskStatus: []v1beta1.ItemStatus{ + PreDeploymentTaskStatus: []apilifecycle.ItemStatus{ { DefinitionName: "task-def", Status: apicommon.StateSucceeded, @@ -246,17 +246,17 @@ func TestTaskHandler(t *testing.T) { }, }, }, - taskObj: v1beta1.KeptnTask{}, + taskObj: apilifecycle.KeptnTask{}, createAttr: CreateTaskAttributes{ SpanName: "", - Definition: v1beta1.KeptnTaskDefinition{ + Definition: apilifecycle.KeptnTaskDefinition{ ObjectMeta: v1.ObjectMeta{ Name: "task-def", }, }, CheckType: apicommon.PreDeploymentCheckType, }, - wantStatus: []v1beta1.ItemStatus{ + wantStatus: []apilifecycle.ItemStatus{ { DefinitionName: "task-def", Status: apicommon.StateSucceeded, @@ -270,20 +270,20 @@ func TestTaskHandler(t *testing.T) { }, { name: "failed task", - object: &v1beta1.KeptnAppVersion{ + object: &apilifecycle.KeptnAppVersion{ ObjectMeta: v1.ObjectMeta{ Namespace: "namespace", }, - Spec: v1beta1.KeptnAppVersionSpec{ - KeptnAppContextSpec: v1beta1.KeptnAppContextSpec{ - DeploymentTaskSpec: v1beta1.DeploymentTaskSpec{ + Spec: apilifecycle.KeptnAppVersionSpec{ + KeptnAppContextSpec: apilifecycle.KeptnAppContextSpec{ + DeploymentTaskSpec: apilifecycle.DeploymentTaskSpec{ PreDeploymentTasks: []string{"task-def"}, }, }, }, - Status: v1beta1.KeptnAppVersionStatus{ + Status: apilifecycle.KeptnAppVersionStatus{ PreDeploymentStatus: apicommon.StateSucceeded, - PreDeploymentTaskStatus: []v1beta1.ItemStatus{ + PreDeploymentTaskStatus: []apilifecycle.ItemStatus{ { DefinitionName: "task-def", Status: apicommon.StateProgressing, @@ -292,25 +292,25 @@ func TestTaskHandler(t *testing.T) { }, }, }, - taskObj: v1beta1.KeptnTask{ + taskObj: apilifecycle.KeptnTask{ ObjectMeta: v1.ObjectMeta{ Namespace: "namespace", Name: "pre-task-def-", }, - Status: v1beta1.KeptnTaskStatus{ + Status: apilifecycle.KeptnTaskStatus{ Status: apicommon.StateFailed, }, }, createAttr: CreateTaskAttributes{ SpanName: "", - Definition: v1beta1.KeptnTaskDefinition{ + Definition: apilifecycle.KeptnTaskDefinition{ ObjectMeta: v1.ObjectMeta{ Name: "task-def", }, }, CheckType: apicommon.PreDeploymentCheckType, }, - wantStatus: []v1beta1.ItemStatus{ + wantStatus: []apilifecycle.ItemStatus{ { DefinitionName: "task-def", Status: apicommon.StateFailed, @@ -324,20 +324,20 @@ func TestTaskHandler(t *testing.T) { }, { name: "succeeded task", - object: &v1beta1.KeptnAppVersion{ + object: &apilifecycle.KeptnAppVersion{ ObjectMeta: v1.ObjectMeta{ Namespace: "namespace", }, - Spec: v1beta1.KeptnAppVersionSpec{ - KeptnAppContextSpec: v1beta1.KeptnAppContextSpec{ - DeploymentTaskSpec: v1beta1.DeploymentTaskSpec{ + Spec: apilifecycle.KeptnAppVersionSpec{ + KeptnAppContextSpec: apilifecycle.KeptnAppContextSpec{ + DeploymentTaskSpec: apilifecycle.DeploymentTaskSpec{ PreDeploymentTasks: []string{"task-def"}, }, }, }, - Status: v1beta1.KeptnAppVersionStatus{ + Status: apilifecycle.KeptnAppVersionStatus{ PreDeploymentStatus: apicommon.StateSucceeded, - PreDeploymentTaskStatus: []v1beta1.ItemStatus{ + PreDeploymentTaskStatus: []apilifecycle.ItemStatus{ { DefinitionName: "task-def", Status: apicommon.StateProgressing, @@ -346,25 +346,25 @@ func TestTaskHandler(t *testing.T) { }, }, }, - taskObj: v1beta1.KeptnTask{ + taskObj: apilifecycle.KeptnTask{ ObjectMeta: v1.ObjectMeta{ Namespace: "namespace", Name: "pre-task-def-", }, - Status: v1beta1.KeptnTaskStatus{ + Status: apilifecycle.KeptnTaskStatus{ Status: apicommon.StateSucceeded, }, }, createAttr: CreateTaskAttributes{ SpanName: "", - Definition: v1beta1.KeptnTaskDefinition{ + Definition: apilifecycle.KeptnTaskDefinition{ ObjectMeta: v1.ObjectMeta{ Name: "task-def", }, }, CheckType: apicommon.PreDeploymentCheckType, }, - wantStatus: []v1beta1.ItemStatus{ + wantStatus: []apilifecycle.ItemStatus{ { DefinitionName: "task-def", Status: apicommon.StateSucceeded, @@ -378,20 +378,20 @@ func TestTaskHandler(t *testing.T) { }, { name: "succeeded promotion task", - object: &v1beta1.KeptnAppVersion{ + object: &apilifecycle.KeptnAppVersion{ ObjectMeta: v1.ObjectMeta{ Namespace: "namespace", }, - Spec: v1beta1.KeptnAppVersionSpec{ - KeptnAppContextSpec: v1beta1.KeptnAppContextSpec{ - DeploymentTaskSpec: v1beta1.DeploymentTaskSpec{ + Spec: apilifecycle.KeptnAppVersionSpec{ + KeptnAppContextSpec: apilifecycle.KeptnAppContextSpec{ + DeploymentTaskSpec: apilifecycle.DeploymentTaskSpec{ PromotionTasks: []string{"task-def"}, }, }, }, - Status: v1beta1.KeptnAppVersionStatus{ + Status: apilifecycle.KeptnAppVersionStatus{ PromotionStatus: apicommon.StateSucceeded, - PromotionTaskStatus: []v1beta1.ItemStatus{ + PromotionTaskStatus: []apilifecycle.ItemStatus{ { DefinitionName: "task-def", Status: apicommon.StateProgressing, @@ -400,25 +400,25 @@ func TestTaskHandler(t *testing.T) { }, }, }, - taskObj: v1beta1.KeptnTask{ + taskObj: apilifecycle.KeptnTask{ ObjectMeta: v1.ObjectMeta{ Namespace: "namespace", Name: "prom-task-def-", }, - Status: v1beta1.KeptnTaskStatus{ + Status: apilifecycle.KeptnTaskStatus{ Status: apicommon.StateSucceeded, }, }, createAttr: CreateTaskAttributes{ SpanName: "", - Definition: v1beta1.KeptnTaskDefinition{ + Definition: apilifecycle.KeptnTaskDefinition{ ObjectMeta: v1.ObjectMeta{ Name: "task-def", }, }, CheckType: apicommon.PromotionCheckType, }, - wantStatus: []v1beta1.ItemStatus{ + wantStatus: []apilifecycle.ItemStatus{ { DefinitionName: "task-def", Status: apicommon.StateSucceeded, @@ -435,7 +435,7 @@ func TestTaskHandler(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - err := v1beta1.AddToScheme(scheme.Scheme) + err := apilifecycle.AddToScheme(scheme.Scheme) require.Nil(t, err) spanHandlerMock := telemetryfake.ISpanHandlerMock{ GetSpanFunc: func(ctx context.Context, tracer telemetry.ITracer, reconcileObject client.Object, phase string, links ...trace.Link) (context.Context, trace.Span, error) { @@ -485,20 +485,20 @@ func TestTaskHandler_createTask(t *testing.T) { }{ { name: "cannot unwrap object", - object: &v1beta1.KeptnEvaluation{}, + object: &apilifecycle.KeptnEvaluation{}, createAttr: CreateTaskAttributes{}, wantName: "", wantErr: controllererrors.ErrCannotWrapToPhaseItem, }, { name: "created task", - object: &v1beta1.KeptnAppVersion{ + object: &apilifecycle.KeptnAppVersion{ ObjectMeta: v1.ObjectMeta{ Namespace: "namespace", }, - Spec: v1beta1.KeptnAppVersionSpec{ - KeptnAppContextSpec: v1beta1.KeptnAppContextSpec{ - DeploymentTaskSpec: v1beta1.DeploymentTaskSpec{ + Spec: apilifecycle.KeptnAppVersionSpec{ + KeptnAppContextSpec: apilifecycle.KeptnAppContextSpec{ + DeploymentTaskSpec: apilifecycle.DeploymentTaskSpec{ PreDeploymentTasks: []string{"task-def"}, }, }, @@ -507,7 +507,7 @@ func TestTaskHandler_createTask(t *testing.T) { createAttr: CreateTaskAttributes{ SpanName: "", CheckType: apicommon.PreDeploymentCheckType, - Definition: v1beta1.KeptnTaskDefinition{ + Definition: apilifecycle.KeptnTaskDefinition{ ObjectMeta: v1.ObjectMeta{ Name: "task-def", }, @@ -520,7 +520,7 @@ func TestTaskHandler_createTask(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - err := v1beta1.AddToScheme(scheme.Scheme) + err := apilifecycle.AddToScheme(scheme.Scheme) require.Nil(t, err) handler := Handler{ @@ -555,7 +555,7 @@ func Test_injectKeptnContext(t *testing.T) { ctx, span := tracer.Start(ctx, "my-span") defer span.End() - task := &v1beta1.KeptnTask{} + task := &apilifecycle.KeptnTask{} injectKeptnContext(ctx, task) require.Equal( diff --git a/lifecycle-operator/controllers/common/taskdefinition/handler.go b/lifecycle-operator/controllers/common/taskdefinition/handler.go index 0af34c69bd..cc0106d0bf 100644 --- a/lifecycle-operator/controllers/common/taskdefinition/handler.go +++ b/lifecycle-operator/controllers/common/taskdefinition/handler.go @@ -4,8 +4,8 @@ import ( "os" "reflect" - klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" + apilifecycle "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1/common" ) const ( @@ -17,7 +17,7 @@ const ( PythonScriptKey = "python" ) -func GetRuntimeSpec(def *klcv1beta1.KeptnTaskDefinition) *klcv1beta1.RuntimeSpec { +func GetRuntimeSpec(def *apilifecycle.KeptnTaskDefinition) *apilifecycle.RuntimeSpec { if !IsRuntimeEmpty(def.Spec.Deno) { return def.Spec.Deno } @@ -28,23 +28,23 @@ func GetRuntimeSpec(def *klcv1beta1.KeptnTaskDefinition) *klcv1beta1.RuntimeSpec return nil } -func IsRuntimeEmpty(spec *klcv1beta1.RuntimeSpec) bool { - return spec == nil || reflect.DeepEqual(spec, &klcv1beta1.RuntimeSpec{}) +func IsRuntimeEmpty(spec *apilifecycle.RuntimeSpec) bool { + return spec == nil || reflect.DeepEqual(spec, &apilifecycle.RuntimeSpec{}) } -func IsContainerEmpty(spec *klcv1beta1.ContainerSpec) bool { - return spec == nil || reflect.DeepEqual(spec, &klcv1beta1.ContainerSpec{}) +func IsContainerEmpty(spec *apilifecycle.ContainerSpec) bool { + return spec == nil || reflect.DeepEqual(spec, &apilifecycle.ContainerSpec{}) } -func IsVolumeMountPresent(spec *klcv1beta1.ContainerSpec) bool { +func IsVolumeMountPresent(spec *apilifecycle.ContainerSpec) bool { return spec != nil && spec.Container != nil && spec.VolumeMounts != nil && len(spec.VolumeMounts) > 0 } -func IsInline(spec *klcv1beta1.RuntimeSpec) bool { - return spec != nil && !reflect.DeepEqual(spec.Inline, klcv1beta1.Inline{}) +func IsInline(spec *apilifecycle.RuntimeSpec) bool { + return spec != nil && !reflect.DeepEqual(spec.Inline, apilifecycle.Inline{}) } -func GetRuntimeImage(def *klcv1beta1.KeptnTaskDefinition) string { +func GetRuntimeImage(def *apilifecycle.KeptnTaskDefinition) string { image := os.Getenv(FunctionRuntimeImageKey) if !IsRuntimeEmpty(def.Spec.Python) && IsRuntimeEmpty(def.Spec.Deno) { image = os.Getenv(PythonRuntimeImageKey) @@ -52,14 +52,14 @@ func GetRuntimeImage(def *klcv1beta1.KeptnTaskDefinition) string { return image } -func GetCmName(functionName string, spec *klcv1beta1.RuntimeSpec) string { +func GetCmName(functionName string, spec *apilifecycle.RuntimeSpec) string { if IsInline(spec) { return "keptnfn-" + apicommon.TruncateString(functionName, 245) } return spec.ConfigMapReference.Name } -func GetRuntimeMountPath(def *klcv1beta1.KeptnTaskDefinition) string { +func GetRuntimeMountPath(def *apilifecycle.KeptnTaskDefinition) string { path := FunctionScriptMountPath if !IsRuntimeEmpty(def.Spec.Python) && IsRuntimeEmpty(def.Spec.Deno) { path = PythonScriptMountPath @@ -68,7 +68,7 @@ func GetRuntimeMountPath(def *klcv1beta1.KeptnTaskDefinition) string { } // check if either the functions or container spec is set -func SpecExists(definition *klcv1beta1.KeptnTaskDefinition) bool { +func SpecExists(definition *apilifecycle.KeptnTaskDefinition) bool { if definition == nil { return false } diff --git a/lifecycle-operator/controllers/common/taskdefinition/handler_test.go b/lifecycle-operator/controllers/common/taskdefinition/handler_test.go index 7ba87e8c24..05870eef82 100644 --- a/lifecycle-operator/controllers/common/taskdefinition/handler_test.go +++ b/lifecycle-operator/controllers/common/taskdefinition/handler_test.go @@ -4,7 +4,7 @@ import ( "reflect" "testing" - klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" + apilifecycle "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1" "github.com/stretchr/testify/require" corev1 "k8s.io/api/core/v1" ) @@ -15,15 +15,15 @@ func TestGetRuntimeImage(t *testing.T) { t.Setenv(PythonRuntimeImageKey, PythonScriptKey) tests := []struct { name string - def *klcv1beta1.KeptnTaskDefinition + def *apilifecycle.KeptnTaskDefinition want string }{ { name: PythonScriptKey, - def: &klcv1beta1.KeptnTaskDefinition{ - Spec: klcv1beta1.KeptnTaskDefinitionSpec{ - Python: &klcv1beta1.RuntimeSpec{ - HttpReference: klcv1beta1.HttpReference{ + def: &apilifecycle.KeptnTaskDefinition{ + Spec: apilifecycle.KeptnTaskDefinitionSpec{ + Python: &apilifecycle.RuntimeSpec{ + HttpReference: apilifecycle.HttpReference{ Url: "testy.com", }, }, @@ -32,10 +32,10 @@ func TestGetRuntimeImage(t *testing.T) { want: PythonScriptKey, }, { name: FunctionScriptKey, - def: &klcv1beta1.KeptnTaskDefinition{ - Spec: klcv1beta1.KeptnTaskDefinitionSpec{ - Deno: &klcv1beta1.RuntimeSpec{ - HttpReference: klcv1beta1.HttpReference{ + def: &apilifecycle.KeptnTaskDefinition{ + Spec: apilifecycle.KeptnTaskDefinitionSpec{ + Deno: &apilifecycle.RuntimeSpec{ + HttpReference: apilifecycle.HttpReference{ Url: "testy.com", }, }, @@ -45,15 +45,15 @@ func TestGetRuntimeImage(t *testing.T) { }, { name: "deno and python defined, deno wins", - def: &klcv1beta1.KeptnTaskDefinition{ - Spec: klcv1beta1.KeptnTaskDefinitionSpec{ - Deno: &klcv1beta1.RuntimeSpec{ - HttpReference: klcv1beta1.HttpReference{ + def: &apilifecycle.KeptnTaskDefinition{ + Spec: apilifecycle.KeptnTaskDefinitionSpec{ + Deno: &apilifecycle.RuntimeSpec{ + HttpReference: apilifecycle.HttpReference{ Url: "testy.com", }, }, - Python: &klcv1beta1.RuntimeSpec{ - HttpReference: klcv1beta1.HttpReference{ + Python: &apilifecycle.RuntimeSpec{ + HttpReference: apilifecycle.HttpReference{ Url: "testy.com", }, }, @@ -74,70 +74,70 @@ func TestGetRuntimeImage(t *testing.T) { func TestGetRuntimeSpec(t *testing.T) { tests := []struct { name string - def *klcv1beta1.KeptnTaskDefinition - want *klcv1beta1.RuntimeSpec + def *apilifecycle.KeptnTaskDefinition + want *apilifecycle.RuntimeSpec }{ { name: PythonScriptKey, - def: &klcv1beta1.KeptnTaskDefinition{ - Spec: klcv1beta1.KeptnTaskDefinitionSpec{ - Python: &klcv1beta1.RuntimeSpec{ - HttpReference: klcv1beta1.HttpReference{ + def: &apilifecycle.KeptnTaskDefinition{ + Spec: apilifecycle.KeptnTaskDefinitionSpec{ + Python: &apilifecycle.RuntimeSpec{ + HttpReference: apilifecycle.HttpReference{ Url: "testy.com", }, }, }, }, - want: &klcv1beta1.RuntimeSpec{ - HttpReference: klcv1beta1.HttpReference{ + want: &apilifecycle.RuntimeSpec{ + HttpReference: apilifecycle.HttpReference{ Url: "testy.com", }, }, }, { name: FunctionScriptKey, - def: &klcv1beta1.KeptnTaskDefinition{ - Spec: klcv1beta1.KeptnTaskDefinitionSpec{ - Deno: &klcv1beta1.RuntimeSpec{ - HttpReference: klcv1beta1.HttpReference{ + def: &apilifecycle.KeptnTaskDefinition{ + Spec: apilifecycle.KeptnTaskDefinitionSpec{ + Deno: &apilifecycle.RuntimeSpec{ + HttpReference: apilifecycle.HttpReference{ Url: "testy.com", }, }, }, }, - want: &klcv1beta1.RuntimeSpec{ - HttpReference: klcv1beta1.HttpReference{ + want: &apilifecycle.RuntimeSpec{ + HttpReference: apilifecycle.HttpReference{ Url: "testy.com", }, }, }, { name: "deno & python exist", - def: &klcv1beta1.KeptnTaskDefinition{ - Spec: klcv1beta1.KeptnTaskDefinitionSpec{ - Deno: &klcv1beta1.RuntimeSpec{ - HttpReference: klcv1beta1.HttpReference{ + def: &apilifecycle.KeptnTaskDefinition{ + Spec: apilifecycle.KeptnTaskDefinitionSpec{ + Deno: &apilifecycle.RuntimeSpec{ + HttpReference: apilifecycle.HttpReference{ Url: "testy.com", }, }, - Python: &klcv1beta1.RuntimeSpec{ - HttpReference: klcv1beta1.HttpReference{ + Python: &apilifecycle.RuntimeSpec{ + HttpReference: apilifecycle.HttpReference{ Url: "nottesty.com", }, }, }, }, - want: &klcv1beta1.RuntimeSpec{ - HttpReference: klcv1beta1.HttpReference{ + want: &apilifecycle.RuntimeSpec{ + HttpReference: apilifecycle.HttpReference{ Url: "testy.com", }, }, }, { name: "only container spec exists ", - def: &klcv1beta1.KeptnTaskDefinition{ - Spec: klcv1beta1.KeptnTaskDefinitionSpec{ - Container: &klcv1beta1.ContainerSpec{ + def: &apilifecycle.KeptnTaskDefinition{ + Spec: apilifecycle.KeptnTaskDefinitionSpec{ + Container: &apilifecycle.ContainerSpec{ Container: &corev1.Container{ Name: "myc", }, @@ -160,14 +160,14 @@ func TestGetRuntimeMountPath(t *testing.T) { tests := []struct { name string - def *klcv1beta1.KeptnTaskDefinition + def *apilifecycle.KeptnTaskDefinition want string }{ { name: "deno", - def: &klcv1beta1.KeptnTaskDefinition{ - Spec: klcv1beta1.KeptnTaskDefinitionSpec{ - Deno: &klcv1beta1.RuntimeSpec{ + def: &apilifecycle.KeptnTaskDefinition{ + Spec: apilifecycle.KeptnTaskDefinitionSpec{ + Deno: &apilifecycle.RuntimeSpec{ CmdParameters: "hi", }, }, @@ -176,9 +176,9 @@ func TestGetRuntimeMountPath(t *testing.T) { }, { name: PythonScriptKey, - def: &klcv1beta1.KeptnTaskDefinition{ - Spec: klcv1beta1.KeptnTaskDefinitionSpec{ - Python: &klcv1beta1.RuntimeSpec{ + def: &apilifecycle.KeptnTaskDefinition{ + Spec: apilifecycle.KeptnTaskDefinitionSpec{ + Python: &apilifecycle.RuntimeSpec{ CmdParameters: "hi", }, }, @@ -187,15 +187,15 @@ func TestGetRuntimeMountPath(t *testing.T) { }, { name: "deno and python defined, deno wins", - def: &klcv1beta1.KeptnTaskDefinition{ - Spec: klcv1beta1.KeptnTaskDefinitionSpec{ - Deno: &klcv1beta1.RuntimeSpec{ - HttpReference: klcv1beta1.HttpReference{ + def: &apilifecycle.KeptnTaskDefinition{ + Spec: apilifecycle.KeptnTaskDefinitionSpec{ + Deno: &apilifecycle.RuntimeSpec{ + HttpReference: apilifecycle.HttpReference{ Url: "testy.com", }, }, - Python: &klcv1beta1.RuntimeSpec{ - HttpReference: klcv1beta1.HttpReference{ + Python: &apilifecycle.RuntimeSpec{ + HttpReference: apilifecycle.HttpReference{ Url: "testy.com", }, }, @@ -216,7 +216,7 @@ func TestGetRuntimeMountPath(t *testing.T) { func TestIsRuntimeEmpty(t *testing.T) { tests := []struct { name string - spec *klcv1beta1.RuntimeSpec + spec *apilifecycle.RuntimeSpec want bool }{ { @@ -226,8 +226,8 @@ func TestIsRuntimeEmpty(t *testing.T) { }, { name: "not empty", - spec: &klcv1beta1.RuntimeSpec{ - HttpReference: klcv1beta1.HttpReference{Url: "hello.com"}, + spec: &apilifecycle.RuntimeSpec{ + HttpReference: apilifecycle.HttpReference{Url: "hello.com"}, }, want: false, }, @@ -244,7 +244,7 @@ func TestIsRuntimeEmpty(t *testing.T) { func TestIsContianerEmpty(t *testing.T) { tests := []struct { name string - spec *klcv1beta1.ContainerSpec + spec *apilifecycle.ContainerSpec want bool }{ { @@ -254,7 +254,7 @@ func TestIsContianerEmpty(t *testing.T) { }, { name: "not empty", - spec: &klcv1beta1.ContainerSpec{ + spec: &apilifecycle.ContainerSpec{ Container: &corev1.Container{ Name: "name", }, @@ -275,20 +275,20 @@ func TestIsInline(t *testing.T) { var tests = []struct { name string - spec *klcv1beta1.RuntimeSpec + spec *apilifecycle.RuntimeSpec want bool }{ { name: "empty inline", - spec: &klcv1beta1.RuntimeSpec{ - Inline: klcv1beta1.Inline{}, + spec: &apilifecycle.RuntimeSpec{ + Inline: apilifecycle.Inline{}, }, want: false, }, { name: "code in inline", - spec: &klcv1beta1.RuntimeSpec{ - Inline: klcv1beta1.Inline{ + spec: &apilifecycle.RuntimeSpec{ + Inline: apilifecycle.Inline{ Code: "testcode", }, }, @@ -313,12 +313,12 @@ func TestIsVolumeMountPresent(t *testing.T) { var tests = []struct { name string - spec *klcv1beta1.ContainerSpec + spec *apilifecycle.ContainerSpec want bool }{ { name: "with mount", - spec: &klcv1beta1.ContainerSpec{ + spec: &apilifecycle.ContainerSpec{ Container: &corev1.Container{ VolumeMounts: []corev1.VolumeMount{ { @@ -336,14 +336,14 @@ func TestIsVolumeMountPresent(t *testing.T) { }, { name: "no container", - spec: &klcv1beta1.ContainerSpec{ + spec: &apilifecycle.ContainerSpec{ Container: nil, }, want: false, }, { name: "no mount", - spec: &klcv1beta1.ContainerSpec{ + spec: &apilifecycle.ContainerSpec{ Container: &corev1.Container{}, }, want: false, @@ -362,14 +362,14 @@ func TestSpecExists(t *testing.T) { tests := []struct { name string - definition *klcv1beta1.KeptnTaskDefinition + definition *apilifecycle.KeptnTaskDefinition want bool }{ { name: "container spec", - definition: &klcv1beta1.KeptnTaskDefinition{ - Spec: klcv1beta1.KeptnTaskDefinitionSpec{ - Container: &klcv1beta1.ContainerSpec{ + definition: &apilifecycle.KeptnTaskDefinition{ + Spec: apilifecycle.KeptnTaskDefinitionSpec{ + Container: &apilifecycle.ContainerSpec{ Container: &corev1.Container{ Name: "mytestcontainer", }, @@ -380,9 +380,9 @@ func TestSpecExists(t *testing.T) { }, { name: "runtime spec", - definition: &klcv1beta1.KeptnTaskDefinition{ - Spec: klcv1beta1.KeptnTaskDefinitionSpec{ - Python: &klcv1beta1.RuntimeSpec{ + definition: &apilifecycle.KeptnTaskDefinition{ + Spec: apilifecycle.KeptnTaskDefinitionSpec{ + Python: &apilifecycle.RuntimeSpec{ CmdParameters: "ciaoPy", }, }, @@ -409,14 +409,14 @@ func TestGetCmName(t *testing.T) { tests := []struct { name string functionName string - spec *klcv1beta1.RuntimeSpec + spec *apilifecycle.RuntimeSpec want string }{ { name: "inline func", functionName: "funcName", - spec: &klcv1beta1.RuntimeSpec{ - Inline: klcv1beta1.Inline{ + spec: &apilifecycle.RuntimeSpec{ + Inline: apilifecycle.Inline{ Code: "code", }, }, @@ -425,8 +425,8 @@ func TestGetCmName(t *testing.T) { { name: "inline func long name", functionName: "funcNamelooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong", - spec: &klcv1beta1.RuntimeSpec{ - Inline: klcv1beta1.Inline{ + spec: &apilifecycle.RuntimeSpec{ + Inline: apilifecycle.Inline{ Code: "code", }, }, @@ -435,8 +435,8 @@ func TestGetCmName(t *testing.T) { { name: "non inline func", functionName: "funcName", - spec: &klcv1beta1.RuntimeSpec{ - ConfigMapReference: klcv1beta1.ConfigMapReference{ + spec: &apilifecycle.RuntimeSpec{ + ConfigMapReference: apilifecycle.ConfigMapReference{ Name: "configMapName", }, }, diff --git a/lifecycle-operator/controllers/common/telemetry/metrics_test.go b/lifecycle-operator/controllers/common/telemetry/metrics_test.go index 838f2c7eeb..101f7b5094 100644 --- a/lifecycle-operator/controllers/common/telemetry/metrics_test.go +++ b/lifecycle-operator/controllers/common/telemetry/metrics_test.go @@ -5,7 +5,7 @@ import ( "testing" "time" - lifecyclev1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" + apilifecycle "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1" controllererrors "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/errors" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/lifecycle/interfaces" "github.com/stretchr/testify/require" @@ -29,18 +29,18 @@ func TestMetrics_ObserveDeploymentDuration(t *testing.T) { }{ { name: "failed to create wrapper", - list: &lifecyclev1beta1.KeptnAppList{}, - clientObjects: &lifecyclev1beta1.KeptnAppList{}, + list: &apilifecycle.KeptnAppList{}, + clientObjects: &apilifecycle.KeptnAppList{}, err: controllererrors.ErrCannotWrapToListItem, gauge: nil, }, { name: "no endtime set", - list: &lifecyclev1beta1.KeptnAppVersionList{}, - clientObjects: &lifecyclev1beta1.KeptnAppVersionList{ - Items: []lifecyclev1beta1.KeptnAppVersion{ + list: &apilifecycle.KeptnAppVersionList{}, + clientObjects: &apilifecycle.KeptnAppVersionList{ + Items: []apilifecycle.KeptnAppVersion{ { - Status: lifecyclev1beta1.KeptnAppVersionStatus{}, + Status: apilifecycle.KeptnAppVersionStatus{}, }, }, }, @@ -49,18 +49,18 @@ func TestMetrics_ObserveDeploymentDuration(t *testing.T) { }, { name: "endtime set", - list: &lifecyclev1beta1.KeptnAppVersionList{}, - clientObjects: &lifecyclev1beta1.KeptnAppVersionList{ - Items: []lifecyclev1beta1.KeptnAppVersion{ + list: &apilifecycle.KeptnAppVersionList{}, + clientObjects: &apilifecycle.KeptnAppVersionList{ + Items: []apilifecycle.KeptnAppVersion{ { - Spec: lifecyclev1beta1.KeptnAppVersionSpec{ - KeptnAppSpec: lifecyclev1beta1.KeptnAppSpec{ + Spec: apilifecycle.KeptnAppVersionSpec{ + KeptnAppSpec: apilifecycle.KeptnAppSpec{ Version: "version", }, AppName: "appName", PreviousVersion: "previousVersion", }, - Status: lifecyclev1beta1.KeptnAppVersionStatus{ + Status: apilifecycle.KeptnAppVersionStatus{ EndTime: metav1.Time{Time: metav1.Now().Time.Add(5 * time.Second)}, StartTime: metav1.Time{Time: metav1.Now().Time}, }, @@ -74,7 +74,7 @@ func TestMetrics_ObserveDeploymentDuration(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - err := lifecyclev1beta1.AddToScheme(scheme.Scheme) + err := apilifecycle.AddToScheme(scheme.Scheme) require.Nil(t, err) client := fake.NewClientBuilder().WithLists(tt.clientObjects).Build() err = ObserveDeploymentDuration(context.TODO(), client, tt.list, gauge, noop.Observer{}) @@ -93,27 +93,27 @@ func TestMetrics_ObserveActiveInstances(t *testing.T) { }{ { name: "failed to create wrapper", - list: &lifecyclev1beta1.KeptnAppList{}, - clientObjects: &lifecyclev1beta1.KeptnAppList{}, + list: &apilifecycle.KeptnAppList{}, + clientObjects: &apilifecycle.KeptnAppList{}, err: controllererrors.ErrCannotWrapToListItem, }, { name: "no endtime set - active instances", - list: &lifecyclev1beta1.KeptnAppVersionList{}, - clientObjects: &lifecyclev1beta1.KeptnAppVersionList{ - Items: []lifecyclev1beta1.KeptnAppVersion{ + list: &apilifecycle.KeptnAppVersionList{}, + clientObjects: &apilifecycle.KeptnAppVersionList{ + Items: []apilifecycle.KeptnAppVersion{ { ObjectMeta: metav1.ObjectMeta{ Namespace: "namespace", }, - Spec: lifecyclev1beta1.KeptnAppVersionSpec{ - KeptnAppSpec: lifecyclev1beta1.KeptnAppSpec{ + Spec: apilifecycle.KeptnAppVersionSpec{ + KeptnAppSpec: apilifecycle.KeptnAppSpec{ Version: "version", }, AppName: "appName", PreviousVersion: "previousVersion", }, - Status: lifecyclev1beta1.KeptnAppVersionStatus{}, + Status: apilifecycle.KeptnAppVersionStatus{}, }, }, }, @@ -121,21 +121,21 @@ func TestMetrics_ObserveActiveInstances(t *testing.T) { }, { name: "endtime set - no active instances", - list: &lifecyclev1beta1.KeptnAppVersionList{}, - clientObjects: &lifecyclev1beta1.KeptnAppVersionList{ - Items: []lifecyclev1beta1.KeptnAppVersion{ + list: &apilifecycle.KeptnAppVersionList{}, + clientObjects: &apilifecycle.KeptnAppVersionList{ + Items: []apilifecycle.KeptnAppVersion{ { ObjectMeta: metav1.ObjectMeta{ Namespace: "namespace", }, - Spec: lifecyclev1beta1.KeptnAppVersionSpec{ - KeptnAppSpec: lifecyclev1beta1.KeptnAppSpec{ + Spec: apilifecycle.KeptnAppVersionSpec{ + KeptnAppSpec: apilifecycle.KeptnAppSpec{ Version: "version", }, AppName: "appName", PreviousVersion: "previousVersion", }, - Status: lifecyclev1beta1.KeptnAppVersionStatus{ + Status: apilifecycle.KeptnAppVersionStatus{ EndTime: metav1.Time{Time: metav1.Now().Time.Add(5 * time.Second)}, StartTime: metav1.Time{Time: metav1.Now().Time}, }, @@ -148,7 +148,7 @@ func TestMetrics_ObserveActiveInstances(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - err := lifecyclev1beta1.AddToScheme(scheme.Scheme) + err := apilifecycle.AddToScheme(scheme.Scheme) require.Nil(t, err) client := fake.NewClientBuilder().WithLists(tt.clientObjects).Build() gauge := noop.Int64ObservableGauge{} @@ -171,21 +171,21 @@ func TestMetrics_ObserveDeploymentInterval(t *testing.T) { }{ { name: "failed to create wrapper", - list: &lifecyclev1beta1.KeptnAppList{}, - clientObjects: &lifecyclev1beta1.KeptnAppList{}, + list: &apilifecycle.KeptnAppList{}, + clientObjects: &apilifecycle.KeptnAppList{}, err: controllererrors.ErrCannotWrapToListItem, }, { name: "no previous version", - list: &lifecyclev1beta1.KeptnAppVersionList{}, - clientObjects: &lifecyclev1beta1.KeptnAppVersionList{ - Items: []lifecyclev1beta1.KeptnAppVersion{ + list: &apilifecycle.KeptnAppVersionList{}, + clientObjects: &apilifecycle.KeptnAppVersionList{ + Items: []apilifecycle.KeptnAppVersion{ { ObjectMeta: metav1.ObjectMeta{ Namespace: "namespace", }, - Spec: lifecyclev1beta1.KeptnAppVersionSpec{ - KeptnAppSpec: lifecyclev1beta1.KeptnAppSpec{ + Spec: apilifecycle.KeptnAppVersionSpec{ + KeptnAppSpec: apilifecycle.KeptnAppSpec{ Version: "version", }, AppName: "appName", @@ -198,15 +198,15 @@ func TestMetrics_ObserveDeploymentInterval(t *testing.T) { }, { name: "previous version - no previous object", - list: &lifecyclev1beta1.KeptnAppVersionList{}, - clientObjects: &lifecyclev1beta1.KeptnAppVersionList{ - Items: []lifecyclev1beta1.KeptnAppVersion{ + list: &apilifecycle.KeptnAppVersionList{}, + clientObjects: &apilifecycle.KeptnAppVersionList{ + Items: []apilifecycle.KeptnAppVersion{ { ObjectMeta: metav1.ObjectMeta{ Namespace: "namespace", }, - Spec: lifecyclev1beta1.KeptnAppVersionSpec{ - KeptnAppSpec: lifecyclev1beta1.KeptnAppSpec{ + Spec: apilifecycle.KeptnAppVersionSpec{ + KeptnAppSpec: apilifecycle.KeptnAppSpec{ Version: "version", }, AppName: "appName", @@ -219,17 +219,17 @@ func TestMetrics_ObserveDeploymentInterval(t *testing.T) { }, { name: "previous version - object found but no endtime", - list: &lifecyclev1beta1.KeptnAppVersionList{}, - previous: &lifecyclev1beta1.KeptnAppVersion{}, - clientObjects: &lifecyclev1beta1.KeptnAppVersionList{ - Items: []lifecyclev1beta1.KeptnAppVersion{ + list: &apilifecycle.KeptnAppVersionList{}, + previous: &apilifecycle.KeptnAppVersion{}, + clientObjects: &apilifecycle.KeptnAppVersionList{ + Items: []apilifecycle.KeptnAppVersion{ { ObjectMeta: metav1.ObjectMeta{ Name: "appName-version", Namespace: "namespace", }, - Spec: lifecyclev1beta1.KeptnAppVersionSpec{ - KeptnAppSpec: lifecyclev1beta1.KeptnAppSpec{ + Spec: apilifecycle.KeptnAppVersionSpec{ + KeptnAppSpec: apilifecycle.KeptnAppSpec{ Version: "version", }, AppName: "appName", @@ -241,8 +241,8 @@ func TestMetrics_ObserveDeploymentInterval(t *testing.T) { Name: "appName-previousVersion", Namespace: "namespace", }, - Spec: lifecyclev1beta1.KeptnAppVersionSpec{ - KeptnAppSpec: lifecyclev1beta1.KeptnAppSpec{ + Spec: apilifecycle.KeptnAppVersionSpec{ + KeptnAppSpec: apilifecycle.KeptnAppSpec{ Version: "previousVersion", }, AppName: "appName", @@ -255,23 +255,23 @@ func TestMetrics_ObserveDeploymentInterval(t *testing.T) { }, { name: "previous version - object found with endtime", - list: &lifecyclev1beta1.KeptnAppVersionList{}, - previous: &lifecyclev1beta1.KeptnAppVersion{}, - clientObjects: &lifecyclev1beta1.KeptnAppVersionList{ - Items: []lifecyclev1beta1.KeptnAppVersion{ + list: &apilifecycle.KeptnAppVersionList{}, + previous: &apilifecycle.KeptnAppVersion{}, + clientObjects: &apilifecycle.KeptnAppVersionList{ + Items: []apilifecycle.KeptnAppVersion{ { ObjectMeta: metav1.ObjectMeta{ Name: "appName-version", Namespace: "namespace", }, - Spec: lifecyclev1beta1.KeptnAppVersionSpec{ - KeptnAppSpec: lifecyclev1beta1.KeptnAppSpec{ + Spec: apilifecycle.KeptnAppVersionSpec{ + KeptnAppSpec: apilifecycle.KeptnAppSpec{ Version: "version", }, AppName: "appName", PreviousVersion: "previousVersion", }, - Status: lifecyclev1beta1.KeptnAppVersionStatus{ + Status: apilifecycle.KeptnAppVersionStatus{ EndTime: metav1.Time{Time: metav1.Now().Time.Add(5 * time.Second)}, StartTime: metav1.Time{Time: metav1.Now().Time}, }, @@ -281,14 +281,14 @@ func TestMetrics_ObserveDeploymentInterval(t *testing.T) { Name: "appName-previousVersion", Namespace: "namespace", }, - Spec: lifecyclev1beta1.KeptnAppVersionSpec{ - KeptnAppSpec: lifecyclev1beta1.KeptnAppSpec{ + Spec: apilifecycle.KeptnAppVersionSpec{ + KeptnAppSpec: apilifecycle.KeptnAppSpec{ Version: "previousVersion", }, AppName: "appName", PreviousVersion: "", }, - Status: lifecyclev1beta1.KeptnAppVersionStatus{ + Status: apilifecycle.KeptnAppVersionStatus{ EndTime: metav1.Time{Time: metav1.Now().Time.Add(5 * time.Second)}, StartTime: metav1.Time{Time: metav1.Now().Time}, }, @@ -299,24 +299,24 @@ func TestMetrics_ObserveDeploymentInterval(t *testing.T) { }, { name: "previous version - object found with endtime and revision", - list: &lifecyclev1beta1.KeptnAppVersionList{}, - previous: &lifecyclev1beta1.KeptnAppVersion{}, - clientObjects: &lifecyclev1beta1.KeptnAppVersionList{ - Items: []lifecyclev1beta1.KeptnAppVersion{ + list: &apilifecycle.KeptnAppVersionList{}, + previous: &apilifecycle.KeptnAppVersion{}, + clientObjects: &apilifecycle.KeptnAppVersionList{ + Items: []apilifecycle.KeptnAppVersion{ { ObjectMeta: metav1.ObjectMeta{ Name: "appName-version-1", Namespace: "namespace", Generation: 1, }, - Spec: lifecyclev1beta1.KeptnAppVersionSpec{ - KeptnAppSpec: lifecyclev1beta1.KeptnAppSpec{ + Spec: apilifecycle.KeptnAppVersionSpec{ + KeptnAppSpec: apilifecycle.KeptnAppSpec{ Version: "version", }, AppName: "appName", PreviousVersion: "previousVersion", }, - Status: lifecyclev1beta1.KeptnAppVersionStatus{ + Status: apilifecycle.KeptnAppVersionStatus{ EndTime: metav1.Time{Time: metav1.Now().Time.Add(5 * time.Second)}, StartTime: metav1.Time{Time: metav1.Now().Time}, }, @@ -327,14 +327,14 @@ func TestMetrics_ObserveDeploymentInterval(t *testing.T) { Namespace: "namespace", Generation: 2, }, - Spec: lifecyclev1beta1.KeptnAppVersionSpec{ - KeptnAppSpec: lifecyclev1beta1.KeptnAppSpec{ + Spec: apilifecycle.KeptnAppVersionSpec{ + KeptnAppSpec: apilifecycle.KeptnAppSpec{ Version: "previousVersion", }, AppName: "appName", PreviousVersion: "", }, - Status: lifecyclev1beta1.KeptnAppVersionStatus{ + Status: apilifecycle.KeptnAppVersionStatus{ EndTime: metav1.Time{Time: metav1.Now().Time.Add(5 * time.Second)}, StartTime: metav1.Time{Time: metav1.Now().Time}, }, @@ -345,14 +345,14 @@ func TestMetrics_ObserveDeploymentInterval(t *testing.T) { Namespace: "namespace", Generation: 1, }, - Spec: lifecyclev1beta1.KeptnAppVersionSpec{ - KeptnAppSpec: lifecyclev1beta1.KeptnAppSpec{ + Spec: apilifecycle.KeptnAppVersionSpec{ + KeptnAppSpec: apilifecycle.KeptnAppSpec{ Version: "previousVersion", }, AppName: "appName", PreviousVersion: "", }, - Status: lifecyclev1beta1.KeptnAppVersionStatus{ + Status: apilifecycle.KeptnAppVersionStatus{ EndTime: metav1.Time{Time: metav1.Now().Time.Add(5 * time.Second)}, StartTime: metav1.Time{Time: metav1.Now().Time}, }, @@ -367,7 +367,7 @@ func TestMetrics_ObserveDeploymentInterval(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - err := lifecyclev1beta1.AddToScheme(scheme.Scheme) + err := apilifecycle.AddToScheme(scheme.Scheme) require.Nil(t, err) fakeClient := fake.NewClientBuilder().WithLists(tt.clientObjects).Build() err = ObserveDeploymentInterval(context.TODO(), fakeClient, tt.list, gauge, noop.Observer{}) @@ -379,20 +379,20 @@ func TestMetrics_ObserveDeploymentInterval(t *testing.T) { func TestGetPredecessor(t *testing.T) { now := time.Now() - appVersions := &lifecyclev1beta1.KeptnAppVersionList{ - Items: []lifecyclev1beta1.KeptnAppVersion{ + appVersions := &apilifecycle.KeptnAppVersionList{ + Items: []apilifecycle.KeptnAppVersion{ { ObjectMeta: metav1.ObjectMeta{ Name: "my-app-1.0.0-1", Generation: 1, }, - Spec: lifecyclev1beta1.KeptnAppVersionSpec{ - KeptnAppSpec: lifecyclev1beta1.KeptnAppSpec{ + Spec: apilifecycle.KeptnAppVersionSpec{ + KeptnAppSpec: apilifecycle.KeptnAppSpec{ Version: "1.0.0", }, AppName: "my-app", }, - Status: lifecyclev1beta1.KeptnAppVersionStatus{ + Status: apilifecycle.KeptnAppVersionStatus{ StartTime: metav1.NewTime(now), EndTime: metav1.NewTime(now.Add(10 * time.Second)), }, @@ -402,13 +402,13 @@ func TestGetPredecessor(t *testing.T) { Name: "my-app-1.0.0-2", Generation: 2, }, - Spec: lifecyclev1beta1.KeptnAppVersionSpec{ - KeptnAppSpec: lifecyclev1beta1.KeptnAppSpec{ + Spec: apilifecycle.KeptnAppVersionSpec{ + KeptnAppSpec: apilifecycle.KeptnAppSpec{ Version: "1.0.0", }, AppName: "my-app", }, - Status: lifecyclev1beta1.KeptnAppVersionStatus{ + Status: apilifecycle.KeptnAppVersionStatus{ StartTime: metav1.NewTime(now.Add(1 * time.Second)), EndTime: metav1.NewTime(now.Add(10 * time.Second)), }, @@ -418,14 +418,14 @@ func TestGetPredecessor(t *testing.T) { Name: "my-app-1.1.0-1", Generation: 1, }, - Spec: lifecyclev1beta1.KeptnAppVersionSpec{ - KeptnAppSpec: lifecyclev1beta1.KeptnAppSpec{ + Spec: apilifecycle.KeptnAppVersionSpec{ + KeptnAppSpec: apilifecycle.KeptnAppSpec{ Version: "1.1.0", }, AppName: "my-app", PreviousVersion: "1.0.0", }, - Status: lifecyclev1beta1.KeptnAppVersionStatus{ + Status: apilifecycle.KeptnAppVersionStatus{ StartTime: metav1.NewTime(now), EndTime: metav1.NewTime(now.Add(10 * time.Second)), }, diff --git a/lifecycle-operator/controllers/common/telemetry/otel_utils.go b/lifecycle-operator/controllers/common/telemetry/otel_utils.go index 93df60aed2..3afce5f45c 100644 --- a/lifecycle-operator/controllers/common/telemetry/otel_utils.go +++ b/lifecycle-operator/controllers/common/telemetry/otel_utils.go @@ -7,8 +7,8 @@ import ( "sync" "time" - lifecyclev1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" - "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" + apilifecycle "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1" + "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1/common" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/lifecycle/interfaces" "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc" @@ -217,12 +217,12 @@ func SetUpKeptnMeters(meter interfaces.IMeter, mgr client.Client) { func observeDuration(ctx context.Context, mgr client.Client, appDeploymentDurationGauge metric.Float64ObservableGauge, workloadDeploymentDurationGauge metric.Float64ObservableGauge, observer metric.Observer) { - err := ObserveDeploymentDuration(ctx, mgr, &lifecyclev1beta1.KeptnAppVersionList{}, appDeploymentDurationGauge, observer) + err := ObserveDeploymentDuration(ctx, mgr, &apilifecycle.KeptnAppVersionList{}, appDeploymentDurationGauge, observer) if err != nil { logger.Error(err, "unable to gather app deployment durations") } - err = ObserveDeploymentDuration(ctx, mgr, &lifecyclev1beta1.KeptnWorkloadVersionList{}, workloadDeploymentDurationGauge, observer) + err = ObserveDeploymentDuration(ctx, mgr, &apilifecycle.KeptnWorkloadVersionList{}, workloadDeploymentDurationGauge, observer) if err != nil { logger.Error(err, "unable to gather workload deployment durations") } @@ -230,12 +230,12 @@ func observeDuration(ctx context.Context, mgr client.Client, appDeploymentDurati } func observeDeploymentInterval(ctx context.Context, mgr client.Client, appDeploymentIntervalGauge metric.Float64ObservableGauge, workloadDeploymentIntervalGauge metric.Float64ObservableGauge, observer metric.Observer) { - err := ObserveDeploymentInterval(ctx, mgr, &lifecyclev1beta1.KeptnAppVersionList{}, appDeploymentIntervalGauge, observer) + err := ObserveDeploymentInterval(ctx, mgr, &apilifecycle.KeptnAppVersionList{}, appDeploymentIntervalGauge, observer) if err != nil { logger.Error(err, "unable to gather app deployment intervals") } - err = ObserveDeploymentInterval(ctx, mgr, &lifecyclev1beta1.KeptnWorkloadVersionList{}, workloadDeploymentIntervalGauge, observer) + err = ObserveDeploymentInterval(ctx, mgr, &apilifecycle.KeptnWorkloadVersionList{}, workloadDeploymentIntervalGauge, observer) if err != nil { logger.Error(err, "unable to gather workload deployment intervals") } @@ -243,19 +243,19 @@ func observeDeploymentInterval(ctx context.Context, mgr client.Client, appDeploy func observeActiveInstances(ctx context.Context, mgr client.Client, deploymentActiveGauge metric.Int64ObservableGauge, appActiveGauge metric.Int64ObservableGauge, taskActiveGauge metric.Int64ObservableGauge, evaluationActiveGauge metric.Int64ObservableGauge, observer metric.Observer) { - err := ObserveActiveInstances(ctx, mgr, &lifecyclev1beta1.KeptnWorkloadVersionList{}, deploymentActiveGauge, observer) + err := ObserveActiveInstances(ctx, mgr, &apilifecycle.KeptnWorkloadVersionList{}, deploymentActiveGauge, observer) if err != nil { logger.Error(err, "unable to gather active deployments") } - err = ObserveActiveInstances(ctx, mgr, &lifecyclev1beta1.KeptnAppVersionList{}, appActiveGauge, observer) + err = ObserveActiveInstances(ctx, mgr, &apilifecycle.KeptnAppVersionList{}, appActiveGauge, observer) if err != nil { logger.Error(err, "unable to gather active apps") } - err = ObserveActiveInstances(ctx, mgr, &lifecyclev1beta1.KeptnTaskList{}, taskActiveGauge, observer) + err = ObserveActiveInstances(ctx, mgr, &apilifecycle.KeptnTaskList{}, taskActiveGauge, observer) if err != nil { logger.Error(err, "unable to gather active tasks") } - err = ObserveActiveInstances(ctx, mgr, &lifecyclev1beta1.KeptnEvaluationList{}, evaluationActiveGauge, observer) + err = ObserveActiveInstances(ctx, mgr, &apilifecycle.KeptnEvaluationList{}, evaluationActiveGauge, observer) if err != nil { logger.Error(err, "unable to gather active evaluations") } diff --git a/lifecycle-operator/controllers/common/telemetry/spanhandler_test.go b/lifecycle-operator/controllers/common/telemetry/spanhandler_test.go index bf466fbbaa..e9ccdf3381 100644 --- a/lifecycle-operator/controllers/common/telemetry/spanhandler_test.go +++ b/lifecycle-operator/controllers/common/telemetry/spanhandler_test.go @@ -4,8 +4,8 @@ import ( "context" "testing" - "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" + apilifecycle "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1/common" keptncontext "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/context" "github.com/stretchr/testify/require" "go.opentelemetry.io/otel" @@ -14,7 +14,7 @@ import ( ) func TestSpanHandler_GetAndUnbindSpan_WorkloadVersion(t *testing.T) { - wi := &v1beta1.KeptnWorkloadVersion{} + wi := &apilifecycle.KeptnWorkloadVersion{} wi.Spec.TraceId = make(map[string]string, 1) wi.Spec.TraceId["test"] = "test" wi.Spec.AppName = "test" @@ -24,7 +24,7 @@ func TestSpanHandler_GetAndUnbindSpan_WorkloadVersion(t *testing.T) { } func TestSpanHandler_GetAndUnbindSpan_AppVersion(t *testing.T) { - av := &v1beta1.KeptnAppVersion{} + av := &apilifecycle.KeptnAppVersion{} av.Spec.TraceId = make(map[string]string, 1) av.Spec.TraceId["test"] = "test" av.Spec.AppName = "test" @@ -51,7 +51,7 @@ func doAssert(t *testing.T, obj client.Object) { } func TestSpanHandler_GetSpan(t *testing.T) { - wi := &v1beta1.KeptnWorkloadVersion{} + wi := &apilifecycle.KeptnWorkloadVersion{} wi.Spec.TraceId = make(map[string]string, 1) wi.Spec.TraceId["traceparent"] = "test-parent" wi.Spec.AppName = "test" @@ -74,7 +74,7 @@ func TestSpanHandler_GetSpan(t *testing.T) { require.Equal(t, ctx, ctx2) require.Equal(t, span, span2) - wi2 := &v1beta1.KeptnWorkloadVersion{} + wi2 := &apilifecycle.KeptnWorkloadVersion{} wi2.Spec.TraceId = make(map[string]string, 1) wi2.Spec.TraceId["traceparent"] = "test-parent2" wi2.Spec.AppName = "test2" @@ -107,7 +107,7 @@ func TestSpanHandler_GetSpan(t *testing.T) { } func TestSpanHandler_GetSpanWithAttributes(t *testing.T) { - wi := &v1beta1.KeptnWorkloadVersion{} + wi := &apilifecycle.KeptnWorkloadVersion{} wi.Spec.TraceId = make(map[string]string, 1) wi.Spec.TraceId["traceparent"] = "test-parent" wi.Spec.AppName = "test" diff --git a/lifecycle-operator/controllers/common/testcommon/utils.go b/lifecycle-operator/controllers/common/testcommon/utils.go index 03cb694eeb..e6dd00a14f 100644 --- a/lifecycle-operator/controllers/common/testcommon/utils.go +++ b/lifecycle-operator/controllers/common/testcommon/utils.go @@ -3,8 +3,8 @@ package testcommon import ( "fmt" - klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" + apilifecycle "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1/common" optionsv1alpha1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/options/v1alpha1" "go.opentelemetry.io/otel/metric" sdkmetric "go.opentelemetry.io/otel/sdk/metric" @@ -30,41 +30,41 @@ func SetupSchemes() { utilruntime.Must(clientgoscheme.AddToScheme(scheme.Scheme)) utilruntime.Must(corev1.AddToScheme(scheme.Scheme)) utilruntime.Must(apiv1.AddToScheme(scheme.Scheme)) - utilruntime.Must(klcv1beta1.AddToScheme(scheme.Scheme)) + utilruntime.Must(apilifecycle.AddToScheme(scheme.Scheme)) utilruntime.Must(optionsv1alpha1.AddToScheme(scheme.Scheme)) } -func GetApp(name string) *klcv1beta1.KeptnApp { - app := &klcv1beta1.KeptnApp{ +func GetApp(name string) *apilifecycle.KeptnApp { + app := &apilifecycle.KeptnApp{ TypeMeta: metav1.TypeMeta{}, ObjectMeta: metav1.ObjectMeta{ Name: name, Namespace: "default", Generation: 1, }, - Spec: klcv1beta1.KeptnAppSpec{ + Spec: apilifecycle.KeptnAppSpec{ Version: "1.0.0", }, - Status: klcv1beta1.KeptnAppStatus{}, + Status: apilifecycle.KeptnAppStatus{}, } return app } -func ReturnAppVersion(namespace string, appName string, version string, workloads []klcv1beta1.KeptnWorkloadRef, status klcv1beta1.KeptnAppVersionStatus) *klcv1beta1.KeptnAppVersion { +func ReturnAppVersion(namespace string, appName string, version string, workloads []apilifecycle.KeptnWorkloadRef, status apilifecycle.KeptnAppVersionStatus) *apilifecycle.KeptnAppVersion { appVersionName := fmt.Sprintf("%s-%s", appName, version) - app := &klcv1beta1.KeptnAppVersion{ + app := &apilifecycle.KeptnAppVersion{ TypeMeta: metav1.TypeMeta{}, ObjectMeta: metav1.ObjectMeta{ Name: appVersionName, Namespace: namespace, Generation: 1, }, - Spec: klcv1beta1.KeptnAppVersionSpec{ - KeptnAppSpec: klcv1beta1.KeptnAppSpec{ + Spec: apilifecycle.KeptnAppVersionSpec{ + KeptnAppSpec: apilifecycle.KeptnAppSpec{ Version: version, Workloads: workloads, }, - KeptnAppContextSpec: klcv1beta1.KeptnAppContextSpec{ + KeptnAppContextSpec: apilifecycle.KeptnAppContextSpec{ Metadata: map[string]string{ "testy": "test", }, diff --git a/lifecycle-operator/controllers/lifecycle/interfaces/activemetricsobject_test.go b/lifecycle-operator/controllers/lifecycle/interfaces/activemetricsobject_test.go index 62a68cc7df..ed61a21a49 100644 --- a/lifecycle-operator/controllers/lifecycle/interfaces/activemetricsobject_test.go +++ b/lifecycle-operator/controllers/lifecycle/interfaces/activemetricsobject_test.go @@ -3,16 +3,16 @@ package interfaces import ( "testing" - "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" + apilifecycle "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1/common" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/lifecycle/interfaces/fake" "github.com/stretchr/testify/require" "go.opentelemetry.io/otel/attribute" ) func TestActiveMetricsObjectWrapper(t *testing.T) { - appVersion := v1beta1.KeptnAppVersion{ - Status: v1beta1.KeptnAppVersionStatus{ + appVersion := apilifecycle.KeptnAppVersion{ + Status: apilifecycle.KeptnAppVersionStatus{ Status: apicommon.StateFailed, CurrentPhase: "test", }, diff --git a/lifecycle-operator/controllers/lifecycle/interfaces/eventobject_test.go b/lifecycle-operator/controllers/lifecycle/interfaces/eventobject_test.go index 2d82820bc6..9643e349a4 100644 --- a/lifecycle-operator/controllers/lifecycle/interfaces/eventobject_test.go +++ b/lifecycle-operator/controllers/lifecycle/interfaces/eventobject_test.go @@ -3,15 +3,15 @@ package interfaces import ( "testing" - "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" + apilifecycle "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1/common" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/lifecycle/interfaces/fake" "github.com/stretchr/testify/require" ) func TestEventObjectWrapper(t *testing.T) { - appVersion := v1beta1.KeptnAppVersion{ - Status: v1beta1.KeptnAppVersionStatus{ + appVersion := apilifecycle.KeptnAppVersion{ + Status: apilifecycle.KeptnAppVersionStatus{ Status: apicommon.StateFailed, CurrentPhase: "test", }, diff --git a/lifecycle-operator/controllers/lifecycle/interfaces/fake/phaseitem_mock.go b/lifecycle-operator/controllers/lifecycle/interfaces/fake/phaseitem_mock.go index eaef9bc740..0c8c6990fc 100644 --- a/lifecycle-operator/controllers/lifecycle/interfaces/fake/phaseitem_mock.go +++ b/lifecycle-operator/controllers/lifecycle/interfaces/fake/phaseitem_mock.go @@ -4,8 +4,8 @@ package fake import ( - klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" + apilifecycle "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1/common" "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/trace" "sync" @@ -24,10 +24,10 @@ import ( // DeprecateRemainingPhasesFunc: func(phase apicommon.KeptnPhaseType) { // panic("mock out the DeprecateRemainingPhases method") // }, -// GenerateEvaluationFunc: func(evaluationDefinition klcv1beta1.KeptnEvaluationDefinition, checkType apicommon.CheckType) klcv1beta1.KeptnEvaluation { +// GenerateEvaluationFunc: func(evaluationDefinition apilifecycle.KeptnEvaluationDefinition, checkType apicommon.CheckType) apilifecycle.KeptnEvaluation { // panic("mock out the GenerateEvaluation method") // }, -// GenerateTaskFunc: func(taskDefinition klcv1beta1.KeptnTaskDefinition, checkType apicommon.CheckType) klcv1beta1.KeptnTask { +// GenerateTaskFunc: func(taskDefinition apilifecycle.KeptnTaskDefinition, checkType apicommon.CheckType) apilifecycle.KeptnTask { // panic("mock out the GenerateTask method") // }, // GetAppNameFunc: func() string { @@ -45,25 +45,25 @@ import ( // GetParentNameFunc: func() string { // panic("mock out the GetParentName method") // }, -// GetPostDeploymentEvaluationTaskStatusFunc: func() []klcv1beta1.ItemStatus { +// GetPostDeploymentEvaluationTaskStatusFunc: func() []apilifecycle.ItemStatus { // panic("mock out the GetPostDeploymentEvaluationTaskStatus method") // }, // GetPostDeploymentEvaluationsFunc: func() []string { // panic("mock out the GetPostDeploymentEvaluations method") // }, -// GetPostDeploymentTaskStatusFunc: func() []klcv1beta1.ItemStatus { +// GetPostDeploymentTaskStatusFunc: func() []apilifecycle.ItemStatus { // panic("mock out the GetPostDeploymentTaskStatus method") // }, // GetPostDeploymentTasksFunc: func() []string { // panic("mock out the GetPostDeploymentTasks method") // }, -// GetPreDeploymentEvaluationTaskStatusFunc: func() []klcv1beta1.ItemStatus { +// GetPreDeploymentEvaluationTaskStatusFunc: func() []apilifecycle.ItemStatus { // panic("mock out the GetPreDeploymentEvaluationTaskStatus method") // }, // GetPreDeploymentEvaluationsFunc: func() []string { // panic("mock out the GetPreDeploymentEvaluations method") // }, -// GetPreDeploymentTaskStatusFunc: func() []klcv1beta1.ItemStatus { +// GetPreDeploymentTaskStatusFunc: func() []apilifecycle.ItemStatus { // panic("mock out the GetPreDeploymentTaskStatus method") // }, // GetPreDeploymentTasksFunc: func() []string { @@ -72,7 +72,7 @@ import ( // GetPreviousVersionFunc: func() string { // panic("mock out the GetPreviousVersion method") // }, -// GetPromotionTaskStatusFunc: func() []klcv1beta1.ItemStatus { +// GetPromotionTaskStatusFunc: func() []apilifecycle.ItemStatus { // panic("mock out the GetPromotionTaskStatus method") // }, // GetPromotionTasksFunc: func() []string { @@ -116,10 +116,10 @@ type PhaseItemMock struct { DeprecateRemainingPhasesFunc func(phase apicommon.KeptnPhaseType) // GenerateEvaluationFunc mocks the GenerateEvaluation method. - GenerateEvaluationFunc func(evaluationDefinition klcv1beta1.KeptnEvaluationDefinition, checkType apicommon.CheckType) klcv1beta1.KeptnEvaluation + GenerateEvaluationFunc func(evaluationDefinition apilifecycle.KeptnEvaluationDefinition, checkType apicommon.CheckType) apilifecycle.KeptnEvaluation // GenerateTaskFunc mocks the GenerateTask method. - GenerateTaskFunc func(taskDefinition klcv1beta1.KeptnTaskDefinition, checkType apicommon.CheckType) klcv1beta1.KeptnTask + GenerateTaskFunc func(taskDefinition apilifecycle.KeptnTaskDefinition, checkType apicommon.CheckType) apilifecycle.KeptnTask // GetAppNameFunc mocks the GetAppName method. GetAppNameFunc func() string @@ -137,25 +137,25 @@ type PhaseItemMock struct { GetParentNameFunc func() string // GetPostDeploymentEvaluationTaskStatusFunc mocks the GetPostDeploymentEvaluationTaskStatus method. - GetPostDeploymentEvaluationTaskStatusFunc func() []klcv1beta1.ItemStatus + GetPostDeploymentEvaluationTaskStatusFunc func() []apilifecycle.ItemStatus // GetPostDeploymentEvaluationsFunc mocks the GetPostDeploymentEvaluations method. GetPostDeploymentEvaluationsFunc func() []string // GetPostDeploymentTaskStatusFunc mocks the GetPostDeploymentTaskStatus method. - GetPostDeploymentTaskStatusFunc func() []klcv1beta1.ItemStatus + GetPostDeploymentTaskStatusFunc func() []apilifecycle.ItemStatus // GetPostDeploymentTasksFunc mocks the GetPostDeploymentTasks method. GetPostDeploymentTasksFunc func() []string // GetPreDeploymentEvaluationTaskStatusFunc mocks the GetPreDeploymentEvaluationTaskStatus method. - GetPreDeploymentEvaluationTaskStatusFunc func() []klcv1beta1.ItemStatus + GetPreDeploymentEvaluationTaskStatusFunc func() []apilifecycle.ItemStatus // GetPreDeploymentEvaluationsFunc mocks the GetPreDeploymentEvaluations method. GetPreDeploymentEvaluationsFunc func() []string // GetPreDeploymentTaskStatusFunc mocks the GetPreDeploymentTaskStatus method. - GetPreDeploymentTaskStatusFunc func() []klcv1beta1.ItemStatus + GetPreDeploymentTaskStatusFunc func() []apilifecycle.ItemStatus // GetPreDeploymentTasksFunc mocks the GetPreDeploymentTasks method. GetPreDeploymentTasksFunc func() []string @@ -164,7 +164,7 @@ type PhaseItemMock struct { GetPreviousVersionFunc func() string // GetPromotionTaskStatusFunc mocks the GetPromotionTaskStatus method. - GetPromotionTaskStatusFunc func() []klcv1beta1.ItemStatus + GetPromotionTaskStatusFunc func() []apilifecycle.ItemStatus // GetPromotionTasksFunc mocks the GetPromotionTasks method. GetPromotionTasksFunc func() []string @@ -206,14 +206,14 @@ type PhaseItemMock struct { // GenerateEvaluation holds details about calls to the GenerateEvaluation method. GenerateEvaluation []struct { // EvaluationDefinition is the evaluationDefinition argument value. - EvaluationDefinition klcv1beta1.KeptnEvaluationDefinition + EvaluationDefinition apilifecycle.KeptnEvaluationDefinition // CheckType is the checkType argument value. CheckType apicommon.CheckType } // GenerateTask holds details about calls to the GenerateTask method. GenerateTask []struct { // TaskDefinition is the taskDefinition argument value. - TaskDefinition klcv1beta1.KeptnTaskDefinition + TaskDefinition apilifecycle.KeptnTaskDefinition // CheckType is the checkType argument value. CheckType apicommon.CheckType } @@ -386,12 +386,12 @@ func (mock *PhaseItemMock) DeprecateRemainingPhasesCalls() []struct { } // GenerateEvaluation calls GenerateEvaluationFunc. -func (mock *PhaseItemMock) GenerateEvaluation(evaluationDefinition klcv1beta1.KeptnEvaluationDefinition, checkType apicommon.CheckType) klcv1beta1.KeptnEvaluation { +func (mock *PhaseItemMock) GenerateEvaluation(evaluationDefinition apilifecycle.KeptnEvaluationDefinition, checkType apicommon.CheckType) apilifecycle.KeptnEvaluation { if mock.GenerateEvaluationFunc == nil { panic("PhaseItemMock.GenerateEvaluationFunc: method is nil but PhaseItem.GenerateEvaluation was just called") } callInfo := struct { - EvaluationDefinition klcv1beta1.KeptnEvaluationDefinition + EvaluationDefinition apilifecycle.KeptnEvaluationDefinition CheckType apicommon.CheckType }{ EvaluationDefinition: evaluationDefinition, @@ -408,11 +408,11 @@ func (mock *PhaseItemMock) GenerateEvaluation(evaluationDefinition klcv1beta1.Ke // // len(mockedPhaseItem.GenerateEvaluationCalls()) func (mock *PhaseItemMock) GenerateEvaluationCalls() []struct { - EvaluationDefinition klcv1beta1.KeptnEvaluationDefinition + EvaluationDefinition apilifecycle.KeptnEvaluationDefinition CheckType apicommon.CheckType } { var calls []struct { - EvaluationDefinition klcv1beta1.KeptnEvaluationDefinition + EvaluationDefinition apilifecycle.KeptnEvaluationDefinition CheckType apicommon.CheckType } mock.lockGenerateEvaluation.RLock() @@ -422,12 +422,12 @@ func (mock *PhaseItemMock) GenerateEvaluationCalls() []struct { } // GenerateTask calls GenerateTaskFunc. -func (mock *PhaseItemMock) GenerateTask(taskDefinition klcv1beta1.KeptnTaskDefinition, checkType apicommon.CheckType) klcv1beta1.KeptnTask { +func (mock *PhaseItemMock) GenerateTask(taskDefinition apilifecycle.KeptnTaskDefinition, checkType apicommon.CheckType) apilifecycle.KeptnTask { if mock.GenerateTaskFunc == nil { panic("PhaseItemMock.GenerateTaskFunc: method is nil but PhaseItem.GenerateTask was just called") } callInfo := struct { - TaskDefinition klcv1beta1.KeptnTaskDefinition + TaskDefinition apilifecycle.KeptnTaskDefinition CheckType apicommon.CheckType }{ TaskDefinition: taskDefinition, @@ -444,11 +444,11 @@ func (mock *PhaseItemMock) GenerateTask(taskDefinition klcv1beta1.KeptnTaskDefin // // len(mockedPhaseItem.GenerateTaskCalls()) func (mock *PhaseItemMock) GenerateTaskCalls() []struct { - TaskDefinition klcv1beta1.KeptnTaskDefinition + TaskDefinition apilifecycle.KeptnTaskDefinition CheckType apicommon.CheckType } { var calls []struct { - TaskDefinition klcv1beta1.KeptnTaskDefinition + TaskDefinition apilifecycle.KeptnTaskDefinition CheckType apicommon.CheckType } mock.lockGenerateTask.RLock() @@ -593,7 +593,7 @@ func (mock *PhaseItemMock) GetParentNameCalls() []struct { } // GetPostDeploymentEvaluationTaskStatus calls GetPostDeploymentEvaluationTaskStatusFunc. -func (mock *PhaseItemMock) GetPostDeploymentEvaluationTaskStatus() []klcv1beta1.ItemStatus { +func (mock *PhaseItemMock) GetPostDeploymentEvaluationTaskStatus() []apilifecycle.ItemStatus { if mock.GetPostDeploymentEvaluationTaskStatusFunc == nil { panic("PhaseItemMock.GetPostDeploymentEvaluationTaskStatusFunc: method is nil but PhaseItem.GetPostDeploymentEvaluationTaskStatus was just called") } @@ -647,7 +647,7 @@ func (mock *PhaseItemMock) GetPostDeploymentEvaluationsCalls() []struct { } // GetPostDeploymentTaskStatus calls GetPostDeploymentTaskStatusFunc. -func (mock *PhaseItemMock) GetPostDeploymentTaskStatus() []klcv1beta1.ItemStatus { +func (mock *PhaseItemMock) GetPostDeploymentTaskStatus() []apilifecycle.ItemStatus { if mock.GetPostDeploymentTaskStatusFunc == nil { panic("PhaseItemMock.GetPostDeploymentTaskStatusFunc: method is nil but PhaseItem.GetPostDeploymentTaskStatus was just called") } @@ -701,7 +701,7 @@ func (mock *PhaseItemMock) GetPostDeploymentTasksCalls() []struct { } // GetPreDeploymentEvaluationTaskStatus calls GetPreDeploymentEvaluationTaskStatusFunc. -func (mock *PhaseItemMock) GetPreDeploymentEvaluationTaskStatus() []klcv1beta1.ItemStatus { +func (mock *PhaseItemMock) GetPreDeploymentEvaluationTaskStatus() []apilifecycle.ItemStatus { if mock.GetPreDeploymentEvaluationTaskStatusFunc == nil { panic("PhaseItemMock.GetPreDeploymentEvaluationTaskStatusFunc: method is nil but PhaseItem.GetPreDeploymentEvaluationTaskStatus was just called") } @@ -755,7 +755,7 @@ func (mock *PhaseItemMock) GetPreDeploymentEvaluationsCalls() []struct { } // GetPreDeploymentTaskStatus calls GetPreDeploymentTaskStatusFunc. -func (mock *PhaseItemMock) GetPreDeploymentTaskStatus() []klcv1beta1.ItemStatus { +func (mock *PhaseItemMock) GetPreDeploymentTaskStatus() []apilifecycle.ItemStatus { if mock.GetPreDeploymentTaskStatusFunc == nil { panic("PhaseItemMock.GetPreDeploymentTaskStatusFunc: method is nil but PhaseItem.GetPreDeploymentTaskStatus was just called") } @@ -836,7 +836,7 @@ func (mock *PhaseItemMock) GetPreviousVersionCalls() []struct { } // GetPromotionTaskStatus calls GetPromotionTaskStatusFunc. -func (mock *PhaseItemMock) GetPromotionTaskStatus() []klcv1beta1.ItemStatus { +func (mock *PhaseItemMock) GetPromotionTaskStatus() []apilifecycle.ItemStatus { if mock.GetPromotionTaskStatusFunc == nil { panic("PhaseItemMock.GetPromotionTaskStatusFunc: method is nil but PhaseItem.GetPromotionTaskStatus was just called") } diff --git a/lifecycle-operator/controllers/lifecycle/interfaces/listitem_test.go b/lifecycle-operator/controllers/lifecycle/interfaces/listitem_test.go index a4d9a63245..299defb9b3 100644 --- a/lifecycle-operator/controllers/lifecycle/interfaces/listitem_test.go +++ b/lifecycle-operator/controllers/lifecycle/interfaces/listitem_test.go @@ -3,18 +3,18 @@ package interfaces import ( "testing" - "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" + apilifecycle "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1/common" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/lifecycle/interfaces/fake" "github.com/stretchr/testify/require" "sigs.k8s.io/controller-runtime/pkg/client" ) func TestListItemWrapper(t *testing.T) { - appVersionList := v1beta1.KeptnAppVersionList{ - Items: []v1beta1.KeptnAppVersion{ + appVersionList := apilifecycle.KeptnAppVersionList{ + Items: []apilifecycle.KeptnAppVersion{ { - Status: v1beta1.KeptnAppVersionStatus{ + Status: apilifecycle.KeptnAppVersionStatus{ Status: apicommon.StateFailed, CurrentPhase: "test", }, diff --git a/lifecycle-operator/controllers/lifecycle/interfaces/metricsobject_test.go b/lifecycle-operator/controllers/lifecycle/interfaces/metricsobject_test.go index 7cf1f8c13a..6a1bf64279 100644 --- a/lifecycle-operator/controllers/lifecycle/interfaces/metricsobject_test.go +++ b/lifecycle-operator/controllers/lifecycle/interfaces/metricsobject_test.go @@ -4,16 +4,16 @@ import ( "testing" "time" - "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" + apilifecycle "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1/common" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/lifecycle/interfaces/fake" "github.com/stretchr/testify/require" "go.opentelemetry.io/otel/attribute" ) func TestMetricsObjectWrapper(t *testing.T) { - appVersion := v1beta1.KeptnAppVersion{ - Status: v1beta1.KeptnAppVersionStatus{ + appVersion := apilifecycle.KeptnAppVersion{ + Status: apilifecycle.KeptnAppVersionStatus{ Status: apicommon.StateFailed, CurrentPhase: "test", }, diff --git a/lifecycle-operator/controllers/lifecycle/interfaces/phaseitem.go b/lifecycle-operator/controllers/lifecycle/interfaces/phaseitem.go index 49028c83ff..76c64b9854 100644 --- a/lifecycle-operator/controllers/lifecycle/interfaces/phaseitem.go +++ b/lifecycle-operator/controllers/lifecycle/interfaces/phaseitem.go @@ -3,8 +3,8 @@ package interfaces import ( "time" - klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" + apilifecycle "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1/common" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/errors" "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/trace" @@ -31,15 +31,15 @@ type PhaseItem interface { GetPreDeploymentTasks() []string GetPostDeploymentTasks() []string GetPromotionTasks() []string - GetPreDeploymentTaskStatus() []klcv1beta1.ItemStatus - GetPostDeploymentTaskStatus() []klcv1beta1.ItemStatus - GetPromotionTaskStatus() []klcv1beta1.ItemStatus + GetPreDeploymentTaskStatus() []apilifecycle.ItemStatus + GetPostDeploymentTaskStatus() []apilifecycle.ItemStatus + GetPromotionTaskStatus() []apilifecycle.ItemStatus GetPreDeploymentEvaluations() []string GetPostDeploymentEvaluations() []string - GetPreDeploymentEvaluationTaskStatus() []klcv1beta1.ItemStatus - GetPostDeploymentEvaluationTaskStatus() []klcv1beta1.ItemStatus - GenerateTask(taskDefinition klcv1beta1.KeptnTaskDefinition, checkType apicommon.CheckType) klcv1beta1.KeptnTask - GenerateEvaluation(evaluationDefinition klcv1beta1.KeptnEvaluationDefinition, checkType apicommon.CheckType) klcv1beta1.KeptnEvaluation + GetPreDeploymentEvaluationTaskStatus() []apilifecycle.ItemStatus + GetPostDeploymentEvaluationTaskStatus() []apilifecycle.ItemStatus + GenerateTask(taskDefinition apilifecycle.KeptnTaskDefinition, checkType apicommon.CheckType) apilifecycle.KeptnTask + GenerateEvaluation(evaluationDefinition apilifecycle.KeptnEvaluationDefinition, checkType apicommon.CheckType) apilifecycle.KeptnEvaluation GetSpanAttributes() []attribute.KeyValue SetSpanAttributes(span trace.Span) DeprecateRemainingPhases(phase apicommon.KeptnPhaseType) @@ -117,11 +117,11 @@ func (pw PhaseItemWrapper) GetPostDeploymentTasks() []string { return pw.Obj.GetPostDeploymentTasks() } -func (pw PhaseItemWrapper) GetPreDeploymentTaskStatus() []klcv1beta1.ItemStatus { +func (pw PhaseItemWrapper) GetPreDeploymentTaskStatus() []apilifecycle.ItemStatus { return pw.Obj.GetPreDeploymentTaskStatus() } -func (pw PhaseItemWrapper) GetPostDeploymentTaskStatus() []klcv1beta1.ItemStatus { +func (pw PhaseItemWrapper) GetPostDeploymentTaskStatus() []apilifecycle.ItemStatus { return pw.Obj.GetPostDeploymentTaskStatus() } @@ -133,19 +133,19 @@ func (pw PhaseItemWrapper) GetPostDeploymentEvaluations() []string { return pw.Obj.GetPostDeploymentEvaluations() } -func (pw PhaseItemWrapper) GetPreDeploymentEvaluationTaskStatus() []klcv1beta1.ItemStatus { +func (pw PhaseItemWrapper) GetPreDeploymentEvaluationTaskStatus() []apilifecycle.ItemStatus { return pw.Obj.GetPreDeploymentEvaluationTaskStatus() } -func (pw PhaseItemWrapper) GetPostDeploymentEvaluationTaskStatus() []klcv1beta1.ItemStatus { +func (pw PhaseItemWrapper) GetPostDeploymentEvaluationTaskStatus() []apilifecycle.ItemStatus { return pw.Obj.GetPostDeploymentEvaluationTaskStatus() } -func (pw PhaseItemWrapper) GenerateTask(taskDefinition klcv1beta1.KeptnTaskDefinition, checkType apicommon.CheckType) klcv1beta1.KeptnTask { +func (pw PhaseItemWrapper) GenerateTask(taskDefinition apilifecycle.KeptnTaskDefinition, checkType apicommon.CheckType) apilifecycle.KeptnTask { return pw.Obj.GenerateTask(taskDefinition, checkType) } -func (pw PhaseItemWrapper) GenerateEvaluation(evaluationDefinition klcv1beta1.KeptnEvaluationDefinition, checkType apicommon.CheckType) klcv1beta1.KeptnEvaluation { +func (pw PhaseItemWrapper) GenerateEvaluation(evaluationDefinition apilifecycle.KeptnEvaluationDefinition, checkType apicommon.CheckType) apilifecycle.KeptnEvaluation { return pw.Obj.GenerateEvaluation(evaluationDefinition, checkType) } @@ -165,6 +165,6 @@ func (pw PhaseItemWrapper) GetPromotionTasks() []string { return pw.Obj.GetPromotionTasks() } -func (pw PhaseItemWrapper) GetPromotionTaskStatus() []klcv1beta1.ItemStatus { +func (pw PhaseItemWrapper) GetPromotionTaskStatus() []apilifecycle.ItemStatus { return pw.Obj.GetPromotionTaskStatus() } diff --git a/lifecycle-operator/controllers/lifecycle/interfaces/phaseitem_test.go b/lifecycle-operator/controllers/lifecycle/interfaces/phaseitem_test.go index b51e5e7a46..17769095a5 100644 --- a/lifecycle-operator/controllers/lifecycle/interfaces/phaseitem_test.go +++ b/lifecycle-operator/controllers/lifecycle/interfaces/phaseitem_test.go @@ -4,8 +4,8 @@ import ( "testing" "time" - "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" + apilifecycle "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1/common" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/lifecycle/interfaces/fake" "github.com/stretchr/testify/require" "go.opentelemetry.io/otel/attribute" @@ -13,8 +13,8 @@ import ( ) func TestPhaseItemWrapper_GetState(t *testing.T) { - appVersion := &v1beta1.KeptnAppVersion{ - Status: v1beta1.KeptnAppVersionStatus{ + appVersion := &apilifecycle.KeptnAppVersion{ + Status: apilifecycle.KeptnAppVersionStatus{ Status: apicommon.StateFailed, CurrentPhase: "test", }, @@ -77,10 +77,10 @@ func TestPhaseItem(t *testing.T) { GetPostDeploymentTasksFunc: func() []string { return nil }, - GetPreDeploymentTaskStatusFunc: func() []v1beta1.ItemStatus { + GetPreDeploymentTaskStatusFunc: func() []apilifecycle.ItemStatus { return nil }, - GetPostDeploymentTaskStatusFunc: func() []v1beta1.ItemStatus { + GetPostDeploymentTaskStatusFunc: func() []apilifecycle.ItemStatus { return nil }, GetPreDeploymentEvaluationsFunc: func() []string { @@ -89,23 +89,23 @@ func TestPhaseItem(t *testing.T) { GetPostDeploymentEvaluationsFunc: func() []string { return nil }, - GetPreDeploymentEvaluationTaskStatusFunc: func() []v1beta1.ItemStatus { + GetPreDeploymentEvaluationTaskStatusFunc: func() []apilifecycle.ItemStatus { return nil }, - GetPostDeploymentEvaluationTaskStatusFunc: func() []v1beta1.ItemStatus { + GetPostDeploymentEvaluationTaskStatusFunc: func() []apilifecycle.ItemStatus { return nil }, GetPromotionTasksFunc: func() []string { return []string{} }, - GetPromotionTaskStatusFunc: func() []v1beta1.ItemStatus { - return []v1beta1.ItemStatus{} + GetPromotionTaskStatusFunc: func() []apilifecycle.ItemStatus { + return []apilifecycle.ItemStatus{} }, - GenerateTaskFunc: func(taskDefinition v1beta1.KeptnTaskDefinition, checkType apicommon.CheckType) v1beta1.KeptnTask { - return v1beta1.KeptnTask{} + GenerateTaskFunc: func(taskDefinition apilifecycle.KeptnTaskDefinition, checkType apicommon.CheckType) apilifecycle.KeptnTask { + return apilifecycle.KeptnTask{} }, - GenerateEvaluationFunc: func(evaluationDefinition v1beta1.KeptnEvaluationDefinition, checkType apicommon.CheckType) v1beta1.KeptnEvaluation { - return v1beta1.KeptnEvaluation{} + GenerateEvaluationFunc: func(evaluationDefinition apilifecycle.KeptnEvaluationDefinition, checkType apicommon.CheckType) apilifecycle.KeptnEvaluation { + return apilifecycle.KeptnEvaluation{} }, SetSpanAttributesFunc: func(span trace.Span) { }, @@ -181,10 +181,10 @@ func TestPhaseItem(t *testing.T) { _ = wrapper.GetPostDeploymentEvaluationTaskStatus() require.Len(t, phaseItemMock.GetPostDeploymentEvaluationTaskStatusCalls(), 1) - _ = wrapper.GenerateTask(v1beta1.KeptnTaskDefinition{}, apicommon.PostDeploymentCheckType) + _ = wrapper.GenerateTask(apilifecycle.KeptnTaskDefinition{}, apicommon.PostDeploymentCheckType) require.Len(t, phaseItemMock.GenerateTaskCalls(), 1) - _ = wrapper.GenerateEvaluation(v1beta1.KeptnEvaluationDefinition{}, apicommon.PostDeploymentCheckType) + _ = wrapper.GenerateEvaluation(apilifecycle.KeptnEvaluationDefinition{}, apicommon.PostDeploymentCheckType) require.Len(t, phaseItemMock.GenerateEvaluationCalls(), 1) wrapper.SetSpanAttributes(nil) diff --git a/lifecycle-operator/controllers/lifecycle/interfaces/spanitem_test.go b/lifecycle-operator/controllers/lifecycle/interfaces/spanitem_test.go index a44ef9c4d9..350c3e4fb8 100644 --- a/lifecycle-operator/controllers/lifecycle/interfaces/spanitem_test.go +++ b/lifecycle-operator/controllers/lifecycle/interfaces/spanitem_test.go @@ -3,8 +3,8 @@ package interfaces import ( "testing" - "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" + apilifecycle "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1/common" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/lifecycle/interfaces/fake" "github.com/stretchr/testify/require" "go.opentelemetry.io/otel/propagation" @@ -13,16 +13,16 @@ import ( ) func TestSpanItemWrapper(t *testing.T) { - evaluation := &v1beta1.KeptnEvaluation{ + evaluation := &apilifecycle.KeptnEvaluation{ ObjectMeta: v1.ObjectMeta{ Name: "evaluation", }, - Spec: v1beta1.KeptnEvaluationSpec{ + Spec: apilifecycle.KeptnEvaluationSpec{ AppName: "app", AppVersion: "appversion", Type: apicommon.PostDeploymentCheckType, }, - Status: v1beta1.KeptnEvaluationStatus{ + Status: apilifecycle.KeptnEvaluationStatus{ OverallStatus: apicommon.StateFailed, }, } diff --git a/lifecycle-operator/controllers/lifecycle/keptnapp/controller.go b/lifecycle-operator/controllers/lifecycle/keptnapp/controller.go index cdb49d18e3..36ed873b75 100644 --- a/lifecycle-operator/controllers/lifecycle/keptnapp/controller.go +++ b/lifecycle-operator/controllers/lifecycle/keptnapp/controller.go @@ -21,8 +21,8 @@ import ( "fmt" "github.com/go-logr/logr" - klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" - "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" + apilifecycle "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1" + "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1/common" operatorcommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/common" controllercommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/eventsender" @@ -69,7 +69,7 @@ func (r *KeptnAppReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c requestInfo := controllercommon.GetRequestInfo(req) r.Log.Info("Searching for App", "requestInfo", requestInfo) - app := &klcv1beta1.KeptnApp{} + app := &apilifecycle.KeptnApp{} err := r.Get(ctx, req.NamespacedName, app) if errors.IsNotFound(err) { return reconcile.Result{}, nil @@ -83,13 +83,13 @@ func (r *KeptnAppReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c r.Log.Info("Reconciling Keptn App", "app", app.Name) - appVersion := &klcv1beta1.KeptnAppVersion{} + appVersion := &apilifecycle.KeptnAppVersion{} // Try to find the AppVersion err = r.Get(ctx, types.NamespacedName{Namespace: app.Namespace, Name: app.GetAppVersionName()}, appVersion) // If the app instance does not exist, create it if errors.IsNotFound(err) { - appContext := &klcv1beta1.KeptnAppContext{} + appContext := &apilifecycle.KeptnAppContext{} err := r.Get(ctx, types.NamespacedName{ Namespace: app.Namespace, Name: app.Name, @@ -130,11 +130,11 @@ func (r *KeptnAppReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c // SetupWithManager sets up the controller with the Manager. func (r *KeptnAppReconciler) SetupWithManager(mgr ctrl.Manager) error { return ctrl.NewControllerManagedBy(mgr). - For(&klcv1beta1.KeptnApp{}, builder.WithPredicates(predicate.GenerationChangedPredicate{})). + For(&apilifecycle.KeptnApp{}, builder.WithPredicates(predicate.GenerationChangedPredicate{})). Complete(r) } -func (r *KeptnAppReconciler) createAppVersion(ctx context.Context, app *klcv1beta1.KeptnApp, appContext *klcv1beta1.KeptnAppContext) (*klcv1beta1.KeptnAppVersion, error) { +func (r *KeptnAppReconciler) createAppVersion(ctx context.Context, app *apilifecycle.KeptnApp, appContext *apilifecycle.KeptnAppContext) (*apilifecycle.KeptnAppVersion, error) { previousVersion := "" if app.Spec.Version != app.Status.CurrentVersion { @@ -153,7 +153,7 @@ func (r *KeptnAppReconciler) createAppVersion(ctx context.Context, app *klcv1bet return &appVersion, err } -func (r *KeptnAppReconciler) handleGenerationBump(ctx context.Context, app *klcv1beta1.KeptnApp) error { +func (r *KeptnAppReconciler) handleGenerationBump(ctx context.Context, app *apilifecycle.KeptnApp) error { if app.Generation != 1 { if err := r.deprecateAppVersions(ctx, app); err != nil { r.Log.Error(err, "could not deprecate appVersions for appVersion %s", app.GetAppVersionName()) @@ -164,11 +164,11 @@ func (r *KeptnAppReconciler) handleGenerationBump(ctx context.Context, app *klcv return nil } -func (r *KeptnAppReconciler) deprecateAppVersions(ctx context.Context, app *klcv1beta1.KeptnApp) error { +func (r *KeptnAppReconciler) deprecateAppVersions(ctx context.Context, app *apilifecycle.KeptnApp) error { var lastResultErr error lastResultErr = nil for i := app.Generation - 1; i > 0; i-- { - deprecatedAppVersion := &klcv1beta1.KeptnAppVersion{} + deprecatedAppVersion := &apilifecycle.KeptnAppVersion{} appVersionName := operatorcommon.CreateResourceName(common.MaxK8sObjectLength, common.MinKeptnNameLen, app.Name, app.Spec.Version, common.Hash(i)) if err := r.Get(ctx, types.NamespacedName{Namespace: app.Namespace, Name: appVersionName}, deprecatedAppVersion); err != nil { if !errors.IsNotFound(err) { diff --git a/lifecycle-operator/controllers/lifecycle/keptnapp/controller_test.go b/lifecycle-operator/controllers/lifecycle/keptnapp/controller_test.go index 8d5fe86838..0755c6bd15 100644 --- a/lifecycle-operator/controllers/lifecycle/keptnapp/controller_test.go +++ b/lifecycle-operator/controllers/lifecycle/keptnapp/controller_test.go @@ -7,8 +7,8 @@ import ( "reflect" "testing" - lfcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" + apilifecycle "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1/common" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/eventsender" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/testcommon" "github.com/magiconair/properties/assert" @@ -27,27 +27,27 @@ import ( // Example Unit test on help function func TestKeptnAppReconciler_createAppVersionSuccess(t *testing.T) { - app := &lfcv1beta1.KeptnApp{ + app := &apilifecycle.KeptnApp{ TypeMeta: metav1.TypeMeta{}, ObjectMeta: metav1.ObjectMeta{ Name: "my-app", Namespace: "default", Generation: 1, }, - Spec: lfcv1beta1.KeptnAppSpec{ + Spec: apilifecycle.KeptnAppSpec{ Version: "1.0.0", }, - Status: lfcv1beta1.KeptnAppStatus{}, + Status: apilifecycle.KeptnAppStatus{}, } - appContext := &lfcv1beta1.KeptnAppContext{ + appContext := &apilifecycle.KeptnAppContext{ TypeMeta: metav1.TypeMeta{}, ObjectMeta: metav1.ObjectMeta{ Name: "my-app-context", Namespace: "default", Generation: 1, }, - Spec: lfcv1beta1.KeptnAppContextSpec{ - DeploymentTaskSpec: lfcv1beta1.DeploymentTaskSpec{ + Spec: apilifecycle.KeptnAppContextSpec{ + DeploymentTaskSpec: apilifecycle.DeploymentTaskSpec{ PreDeploymentTasks: []string{ "some-pre-deployment-task1", }, @@ -68,7 +68,7 @@ func TestKeptnAppReconciler_createAppVersionSuccess(t *testing.T) { "spanlink1", }, }, - Status: lfcv1beta1.KeptnAppContextStatus{}, + Status: apilifecycle.KeptnAppContextStatus{}, } r, _ := setupReconciler() @@ -79,7 +79,7 @@ func TestKeptnAppReconciler_createAppVersionSuccess(t *testing.T) { t.Log("Verifying created app") require.Equal(t, appVersion.Namespace, app.Namespace) require.Equal(t, appVersion.Name, fmt.Sprintf("%s-%s-%s", app.Name, app.Spec.Version, apicommon.Hash(app.Generation))) - require.Equal(t, lfcv1beta1.KeptnAppVersionSpec{ + require.Equal(t, apilifecycle.KeptnAppVersionSpec{ KeptnAppContextSpec: appContext.Spec, KeptnAppSpec: app.Spec, AppName: app.Name, @@ -95,27 +95,27 @@ func TestKeptnAppReconciler_createAppVersionSuccess(t *testing.T) { func TestKeptnAppReconciler_createAppVersionError(t *testing.T) { - app := &lfcv1beta1.KeptnApp{ + app := &apilifecycle.KeptnApp{ TypeMeta: metav1.TypeMeta{}, ObjectMeta: metav1.ObjectMeta{ Name: "my-app", Namespace: "default", Generation: 1, }, - Spec: lfcv1beta1.KeptnAppSpec{ + Spec: apilifecycle.KeptnAppSpec{ Version: "1.0.0", }, - Status: lfcv1beta1.KeptnAppStatus{}, + Status: apilifecycle.KeptnAppStatus{}, } - appContext := &lfcv1beta1.KeptnAppContext{ + appContext := &apilifecycle.KeptnAppContext{ TypeMeta: metav1.TypeMeta{}, ObjectMeta: metav1.ObjectMeta{ Name: "my-app-context", Namespace: "default", Generation: 1, }, - Spec: lfcv1beta1.KeptnAppContextSpec{ - DeploymentTaskSpec: lfcv1beta1.DeploymentTaskSpec{ + Spec: apilifecycle.KeptnAppContextSpec{ + DeploymentTaskSpec: apilifecycle.DeploymentTaskSpec{ PreDeploymentTasks: []string{ "some-pre-deployment-task1", }, @@ -136,7 +136,7 @@ func TestKeptnAppReconciler_createAppVersionError(t *testing.T) { "spanlink1", }, }, - Status: lfcv1beta1.KeptnAppContextStatus{}, + Status: apilifecycle.KeptnAppContextStatus{}, } r, _ := setupReconciler(app, appContext) @@ -163,23 +163,23 @@ func TestKeptnAppReconciler_createAppVersionWithLongName(t *testing.T) { //nolint:gci trimmedName := `loremipsumissimplydummytextoftheprintingandtypesettingindustryloremipsumissimplydummytextoftheprintingandtypesettingindustryloremipsumissimplydummytextoftheprintingandtypesettingindustryloremipsumissimplydummytextoftheprintingandtypeset-version-5feceb66` - app := &lfcv1beta1.KeptnApp{ + app := &apilifecycle.KeptnApp{ ObjectMeta: metav1.ObjectMeta{ Name: longName, }, - Spec: lfcv1beta1.KeptnAppSpec{ + Spec: apilifecycle.KeptnAppSpec{ Version: "version", }, } - appContext := &lfcv1beta1.KeptnAppContext{ + appContext := &apilifecycle.KeptnAppContext{ TypeMeta: metav1.TypeMeta{}, ObjectMeta: metav1.ObjectMeta{ Name: "my-app-context", Namespace: "default", Generation: 1, }, - Spec: lfcv1beta1.KeptnAppContextSpec{ - DeploymentTaskSpec: lfcv1beta1.DeploymentTaskSpec{ + Spec: apilifecycle.KeptnAppContextSpec{ + DeploymentTaskSpec: apilifecycle.DeploymentTaskSpec{ PreDeploymentTasks: []string{ "some-pre-deployment-task1", }, @@ -194,7 +194,7 @@ func TestKeptnAppReconciler_createAppVersionWithLongName(t *testing.T) { }, }, }, - Status: lfcv1beta1.KeptnAppContextStatus{}, + Status: apilifecycle.KeptnAppContextStatus{}, } r, _ := setupReconciler() @@ -250,7 +250,7 @@ func TestKeptnAppReconciler_reconcile(t *testing.T) { app := testcommon.GetApp("myapp") appfin := testcommon.GetApp("myfinishedapp") - appver := testcommon.ReturnAppVersion("default", "myfinishedapp", "1.0.0-6b86b273", nil, lfcv1beta1.KeptnAppVersionStatus{Status: apicommon.StateSucceeded}) + appver := testcommon.ReturnAppVersion("default", "myfinishedapp", "1.0.0-6b86b273", nil, apilifecycle.KeptnAppVersionStatus{Status: apicommon.StateSucceeded}) r, _ := setupReconciler(app, appfin, appver) for _, tt := range tests { @@ -262,7 +262,7 @@ func TestKeptnAppReconciler_reconcile(t *testing.T) { return } if tt.appVersionName != "" { - keptnappversion := &lfcv1beta1.KeptnAppVersion{} + keptnappversion := &apilifecycle.KeptnAppVersion{} err = r.Client.Get(context.TODO(), types.NamespacedName{Namespace: "default", Name: "myapp-1.0.0-6b86b273"}, keptnappversion) require.Nil(t, err) } @@ -276,7 +276,7 @@ func TestKeptnAppReconciler_deprecateAppVersions(t *testing.T) { app := testcommon.GetApp("myapp") app.Spec.Revision = uint(2) app.Generation = int64(2) - appVersion := &lfcv1beta1.KeptnAppVersion{ + appVersion := &apilifecycle.KeptnAppVersion{ ObjectMeta: metav1.ObjectMeta{ Name: "myapp-1.0.0-6b86b273", Namespace: "default", @@ -293,7 +293,7 @@ func TestKeptnAppReconciler_deprecateAppVersions(t *testing.T) { require.Nil(t, err) - keptnappversion := &lfcv1beta1.KeptnAppVersion{} + keptnappversion := &apilifecycle.KeptnAppVersion{} err = r.Client.Get(context.TODO(), types.NamespacedName{Namespace: "default", Name: "myapp-1.0.0-d4735e3a"}, keptnappversion) require.Nil(t, err) @@ -307,7 +307,7 @@ func TestKeptnAppReconciler_deprecateAppVersionsError(t *testing.T) { app := testcommon.GetApp("myapp") app.Spec.Revision = uint(2) app.Generation = int64(2) - appVersion := &lfcv1beta1.KeptnAppVersion{ + appVersion := &apilifecycle.KeptnAppVersion{ ObjectMeta: metav1.ObjectMeta{ Name: "myapp-1.0.0-6b86b273", Namespace: "default", diff --git a/lifecycle-operator/controllers/lifecycle/keptnappcreationrequest/controller.go b/lifecycle-operator/controllers/lifecycle/keptnappcreationrequest/controller.go index da499e6c76..1ec60754df 100644 --- a/lifecycle-operator/controllers/lifecycle/keptnappcreationrequest/controller.go +++ b/lifecycle-operator/controllers/lifecycle/keptnappcreationrequest/controller.go @@ -26,8 +26,8 @@ import ( "github.com/benbjohnson/clock" "github.com/go-logr/logr" - lifecycle "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" - "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" + apilifecycle "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1/common" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/config" "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -74,7 +74,7 @@ func NewReconciler(client client.Client, scheme *runtime.Scheme, log logr.Logger // //nolint:gocyclo func (r *KeptnAppCreationRequestReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { - creationRequest := &lifecycle.KeptnAppCreationRequest{} + creationRequest := &apilifecycle.KeptnAppCreationRequest{} if err := r.Get(ctx, req.NamespacedName, creationRequest); err != nil { if errors.IsNotFound(err) { @@ -86,7 +86,7 @@ func (r *KeptnAppCreationRequestReconciler) Reconcile(ctx context.Context, req c // check if we already have an app that has not been created by this controller appFound := false - keptnApp := &lifecycle.KeptnApp{} + keptnApp := &apilifecycle.KeptnApp{} name := req.NamespacedName name.Name = creationRequest.Spec.AppName if err := r.Get(ctx, name, keptnApp); err != nil { @@ -135,8 +135,8 @@ func (r *KeptnAppCreationRequestReconciler) Reconcile(ctx context.Context, req c return ctrl.Result{}, nil } -func (r *KeptnAppCreationRequestReconciler) getWorkloads(ctx context.Context, creationRequest *lifecycle.KeptnAppCreationRequest) ([]lifecycle.KeptnWorkload, error) { - workloads := &lifecycle.KeptnWorkloadList{} +func (r *KeptnAppCreationRequestReconciler) getWorkloads(ctx context.Context, creationRequest *apilifecycle.KeptnAppCreationRequest) ([]apilifecycle.KeptnWorkload, error) { + workloads := &apilifecycle.KeptnWorkloadList{} if err := r.Client.List(ctx, workloads, client.InNamespace(creationRequest.Namespace), client.MatchingFields{ "spec.app": creationRequest.Spec.AppName, }); err != nil { @@ -148,7 +148,7 @@ func (r *KeptnAppCreationRequestReconciler) getWorkloads(ctx context.Context, cr return workloads.Items, nil } -func (r *KeptnAppCreationRequestReconciler) getCreationRequestExpirationDuration(cr *lifecycle.KeptnAppCreationRequest) time.Duration { +func (r *KeptnAppCreationRequestReconciler) getCreationRequestExpirationDuration(cr *apilifecycle.KeptnAppCreationRequest) time.Duration { creationRequestTimeout := r.config.GetCreationRequestTimeout() deadline := cr.CreationTimestamp.Add(creationRequestTimeout) @@ -161,7 +161,7 @@ func (r *KeptnAppCreationRequestReconciler) getCreationRequestExpirationDuration return 0 } -func (r *KeptnAppCreationRequestReconciler) shouldCreateApp(creationRequest *lifecycle.KeptnAppCreationRequest) bool { +func (r *KeptnAppCreationRequestReconciler) shouldCreateApp(creationRequest *apilifecycle.KeptnAppCreationRequest) bool { discoveryDeadline := r.config.GetCreationRequestTimeout() return creationRequest.IsSingleService() || r.clock.Now().After(creationRequest.CreationTimestamp.Add(discoveryDeadline)) } @@ -169,11 +169,11 @@ func (r *KeptnAppCreationRequestReconciler) shouldCreateApp(creationRequest *lif // SetupWithManager sets up the controller with the Manager. func (r *KeptnAppCreationRequestReconciler) SetupWithManager(mgr ctrl.Manager) error { return ctrl.NewControllerManagedBy(mgr). - For(&lifecycle.KeptnAppCreationRequest{}). + For(&apilifecycle.KeptnAppCreationRequest{}). Complete(r) } -func (r *KeptnAppCreationRequestReconciler) updateKeptnApp(ctx context.Context, keptnApp *lifecycle.KeptnApp, workloads []lifecycle.KeptnWorkload) error { +func (r *KeptnAppCreationRequestReconciler) updateKeptnApp(ctx context.Context, keptnApp *apilifecycle.KeptnApp, workloads []apilifecycle.KeptnWorkload) error { addOrUpdatedWorkload := r.addOrUpdateWorkloads(workloads, keptnApp) removedWorkload := r.cleanupWorkloads(workloads, keptnApp) @@ -187,7 +187,7 @@ func (r *KeptnAppCreationRequestReconciler) updateKeptnApp(ctx context.Context, return r.Update(ctx, keptnApp) } -func (r *KeptnAppCreationRequestReconciler) addOrUpdateWorkloads(workloads []lifecycle.KeptnWorkload, keptnApp *lifecycle.KeptnApp) bool { +func (r *KeptnAppCreationRequestReconciler) addOrUpdateWorkloads(workloads []apilifecycle.KeptnWorkload, keptnApp *apilifecycle.KeptnApp) bool { updated := false for _, workload := range workloads { foundWorkload := false @@ -206,7 +206,7 @@ func (r *KeptnAppCreationRequestReconciler) addOrUpdateWorkloads(workloads []lif } if !foundWorkload { - keptnApp.Spec.Workloads = append(keptnApp.Spec.Workloads, lifecycle.KeptnWorkloadRef{ + keptnApp.Spec.Workloads = append(keptnApp.Spec.Workloads, apilifecycle.KeptnWorkloadRef{ Name: workloadName, Version: workload.Spec.Version, }) @@ -216,9 +216,9 @@ func (r *KeptnAppCreationRequestReconciler) addOrUpdateWorkloads(workloads []lif return updated } -func (r *KeptnAppCreationRequestReconciler) cleanupWorkloads(workloads []lifecycle.KeptnWorkload, keptnApp *lifecycle.KeptnApp) bool { +func (r *KeptnAppCreationRequestReconciler) cleanupWorkloads(workloads []apilifecycle.KeptnWorkload, keptnApp *apilifecycle.KeptnApp) bool { updated := false - updatedWorkloads := []lifecycle.KeptnWorkloadRef{} + updatedWorkloads := []apilifecycle.KeptnWorkloadRef{} for index, appWorkload := range keptnApp.Spec.Workloads { foundWorkload := false for _, workload := range workloads { @@ -236,25 +236,25 @@ func (r *KeptnAppCreationRequestReconciler) cleanupWorkloads(workloads []lifecyc return updated } -func (r *KeptnAppCreationRequestReconciler) createKeptnApp(ctx context.Context, creationRequest *lifecycle.KeptnAppCreationRequest, workloads []lifecycle.KeptnWorkload) error { - keptnApp := &lifecycle.KeptnApp{ +func (r *KeptnAppCreationRequestReconciler) createKeptnApp(ctx context.Context, creationRequest *apilifecycle.KeptnAppCreationRequest, workloads []apilifecycle.KeptnWorkload) error { + keptnApp := &apilifecycle.KeptnApp{ ObjectMeta: metav1.ObjectMeta{ Name: creationRequest.Spec.AppName, Namespace: creationRequest.Namespace, Labels: map[string]string{ - common.K8sRecommendedManagedByAnnotations: managedByKeptn, + apicommon.K8sRecommendedManagedByAnnotations: managedByKeptn, }, // pass through the annotations since those contain the trace context Annotations: creationRequest.Annotations, }, - Spec: lifecycle.KeptnAppSpec{ + Spec: apilifecycle.KeptnAppSpec{ Version: computeVersionFromWorkloads(workloads), - Workloads: []lifecycle.KeptnWorkloadRef{}, + Workloads: []apilifecycle.KeptnWorkloadRef{}, }, } for _, workload := range workloads { - keptnApp.Spec.Workloads = append(keptnApp.Spec.Workloads, lifecycle.KeptnWorkloadRef{ + keptnApp.Spec.Workloads = append(keptnApp.Spec.Workloads, apilifecycle.KeptnWorkloadRef{ Name: strings.TrimPrefix(workload.Name, fmt.Sprintf("%s-", creationRequest.Spec.AppName)), Version: workload.Spec.Version, }) @@ -263,7 +263,7 @@ func (r *KeptnAppCreationRequestReconciler) createKeptnApp(ctx context.Context, return r.Create(ctx, keptnApp) } -func computeVersionFromWorkloads(workloads []lifecycle.KeptnWorkload) string { +func computeVersionFromWorkloads(workloads []apilifecycle.KeptnWorkload) string { // for single workload applications, the workload version is the application version if len(workloads) == 1 { return workloads[0].Spec.Version @@ -281,10 +281,10 @@ func computeVersionFromWorkloads(workloads []lifecycle.KeptnWorkload) string { hash.Write([]byte(versionString)) hashValue := fmt.Sprintf("%x", hash.Sum(nil)) - return common.TruncateString(hashValue, 10) + return apicommon.TruncateString(hashValue, 10) } -func appIsManagedByKeptn(keptnApp *lifecycle.KeptnApp) bool { - annotation := common.K8sRecommendedManagedByAnnotations +func appIsManagedByKeptn(keptnApp *apilifecycle.KeptnApp) bool { + annotation := apicommon.K8sRecommendedManagedByAnnotations return keptnApp.Labels[annotation] == managedByKeptn } diff --git a/lifecycle-operator/controllers/lifecycle/keptnappcreationrequest/controller_test.go b/lifecycle-operator/controllers/lifecycle/keptnappcreationrequest/controller_test.go index b5fefbc0e7..223874a9d3 100644 --- a/lifecycle-operator/controllers/lifecycle/keptnappcreationrequest/controller_test.go +++ b/lifecycle-operator/controllers/lifecycle/keptnappcreationrequest/controller_test.go @@ -8,7 +8,7 @@ import ( "github.com/benbjohnson/clock" "github.com/go-logr/logr" - klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" + apilifecycle "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/config/fake" "github.com/stretchr/testify/require" "k8s.io/apimachinery/pkg/api/errors" @@ -27,13 +27,13 @@ func TestKeptnAppCreationRequestReconciler_CreateAppAfterTimeout_SingleWorkload( const namespace = "my-namespace" const appName = "my-app" - kacr := &klcv1beta1.KeptnAppCreationRequest{ + kacr := &apilifecycle.KeptnAppCreationRequest{ ObjectMeta: metav1.ObjectMeta{ Name: "my-kacr", Namespace: namespace, CreationTimestamp: metav1.Time{Time: theClock.Now()}, }, - Spec: klcv1beta1.KeptnAppCreationRequestSpec{ + Spec: apilifecycle.KeptnAppCreationRequestSpec{ AppName: appName, }, } @@ -41,12 +41,12 @@ func TestKeptnAppCreationRequestReconciler_CreateAppAfterTimeout_SingleWorkload( err := fakeClient.Create(context.TODO(), kacr) require.Nil(t, err) - workload1 := &klcv1beta1.KeptnWorkload{ + workload1 := &apilifecycle.KeptnWorkload{ ObjectMeta: metav1.ObjectMeta{ Name: "w1", Namespace: namespace, }, - Spec: klcv1beta1.KeptnWorkloadSpec{ + Spec: apilifecycle.KeptnWorkloadSpec{ AppName: appName, Version: "1.0+rc0", }, @@ -77,7 +77,7 @@ func TestKeptnAppCreationRequestReconciler_CreateAppAfterTimeout_SingleWorkload( require.False(t, res.Requeue) require.Zero(t, res.RequeueAfter) - kApp := &klcv1beta1.KeptnApp{} + kApp := &apilifecycle.KeptnApp{} err = fakeClient.Get(context.TODO(), types.NamespacedName{Name: kacr.Spec.AppName, Namespace: kacr.Namespace}, kApp) @@ -88,13 +88,13 @@ func TestKeptnAppCreationRequestReconciler_CreateAppAfterTimeout_SingleWorkload( // the App version is the same of the single workload require.Equal(t, workload1.Spec.Version, kApp.Spec.Version) require.Len(t, kApp.Spec.Workloads, 1) - require.Contains(t, kApp.Spec.Workloads, klcv1beta1.KeptnWorkloadRef{ + require.Contains(t, kApp.Spec.Workloads, apilifecycle.KeptnWorkloadRef{ Name: workload1.Name, Version: workload1.Spec.Version, }) // verify that the creationRequest has been deleted - cr := &klcv1beta1.KeptnAppCreationRequest{} + cr := &apilifecycle.KeptnAppCreationRequest{} err = fakeClient.Get(context.TODO(), types.NamespacedName{Name: kacr.Name, Namespace: kacr.Namespace}, cr) @@ -106,13 +106,13 @@ func TestKeptnAppCreationRequestReconciler_CreateAppAfterTimeout(t *testing.T) { const namespace = "my-namespace" const appName = "my-app" - kacr := &klcv1beta1.KeptnAppCreationRequest{ + kacr := &apilifecycle.KeptnAppCreationRequest{ ObjectMeta: metav1.ObjectMeta{ Name: "my-kacr", Namespace: namespace, CreationTimestamp: metav1.Time{Time: theClock.Now()}, }, - Spec: klcv1beta1.KeptnAppCreationRequestSpec{ + Spec: apilifecycle.KeptnAppCreationRequestSpec{ AppName: appName, }, } @@ -120,23 +120,23 @@ func TestKeptnAppCreationRequestReconciler_CreateAppAfterTimeout(t *testing.T) { err := fakeClient.Create(context.TODO(), kacr) require.Nil(t, err) - workload1 := &klcv1beta1.KeptnWorkload{ + workload1 := &apilifecycle.KeptnWorkload{ ObjectMeta: metav1.ObjectMeta{ Name: "w1", Namespace: namespace, }, - Spec: klcv1beta1.KeptnWorkloadSpec{ + Spec: apilifecycle.KeptnWorkloadSpec{ AppName: appName, Version: "1.0", }, } - workload2 := &klcv1beta1.KeptnWorkload{ + workload2 := &apilifecycle.KeptnWorkload{ ObjectMeta: metav1.ObjectMeta{ Name: "w2", Namespace: namespace, }, - Spec: klcv1beta1.KeptnWorkloadSpec{ + Spec: apilifecycle.KeptnWorkloadSpec{ AppName: appName, Version: "2.0", }, @@ -169,7 +169,7 @@ func TestKeptnAppCreationRequestReconciler_CreateAppAfterTimeout(t *testing.T) { require.False(t, res.Requeue) require.Zero(t, res.RequeueAfter) - kApp := &klcv1beta1.KeptnApp{} + kApp := &apilifecycle.KeptnApp{} err = fakeClient.Get(context.TODO(), types.NamespacedName{Name: kacr.Spec.AppName, Namespace: kacr.Namespace}, kApp) @@ -178,17 +178,17 @@ func TestKeptnAppCreationRequestReconciler_CreateAppAfterTimeout(t *testing.T) { require.NotEmpty(t, kApp.Spec.Version) require.Len(t, kApp.Spec.Workloads, 2) - require.Contains(t, kApp.Spec.Workloads, klcv1beta1.KeptnWorkloadRef{ + require.Contains(t, kApp.Spec.Workloads, apilifecycle.KeptnWorkloadRef{ Name: workload1.Name, Version: workload1.Spec.Version, }) - require.Contains(t, kApp.Spec.Workloads, klcv1beta1.KeptnWorkloadRef{ + require.Contains(t, kApp.Spec.Workloads, apilifecycle.KeptnWorkloadRef{ Name: workload2.Name, Version: workload2.Spec.Version, }) // verify that the creationRequest has been deleted - cr := &klcv1beta1.KeptnAppCreationRequest{} + cr := &apilifecycle.KeptnAppCreationRequest{} err = fakeClient.Get(context.TODO(), types.NamespacedName{Name: kacr.Name, Namespace: kacr.Namespace}, cr) @@ -199,13 +199,13 @@ func TestKeptnAppCreationRequestReconciler_UpdateWorkloadsWithNewWorkload(t *tes r, fakeClient, theClock := setupReconcilerAndClient(t) const namespace = "my-namespace" const appName = "my-app" - kacr := &klcv1beta1.KeptnAppCreationRequest{ + kacr := &apilifecycle.KeptnAppCreationRequest{ ObjectMeta: metav1.ObjectMeta{ Name: "my-kacr", Namespace: namespace, CreationTimestamp: metav1.Time{Time: theClock.Now()}, }, - Spec: klcv1beta1.KeptnAppCreationRequestSpec{ + Spec: apilifecycle.KeptnAppCreationRequestSpec{ AppName: appName, }, } @@ -213,12 +213,12 @@ func TestKeptnAppCreationRequestReconciler_UpdateWorkloadsWithNewWorkload(t *tes err := fakeClient.Create(context.TODO(), kacr) require.Nil(t, err) - workload1 := &klcv1beta1.KeptnWorkload{ + workload1 := &apilifecycle.KeptnWorkload{ ObjectMeta: metav1.ObjectMeta{ Name: "w1", Namespace: namespace, }, - Spec: klcv1beta1.KeptnWorkloadSpec{ + Spec: apilifecycle.KeptnWorkloadSpec{ AppName: appName, Version: "1.0", }, @@ -244,7 +244,7 @@ func TestKeptnAppCreationRequestReconciler_UpdateWorkloadsWithNewWorkload(t *tes require.False(t, res.Requeue) require.Zero(t, res.RequeueAfter) - kApp := &klcv1beta1.KeptnApp{} + kApp := &apilifecycle.KeptnApp{} err = fakeClient.Get(context.TODO(), types.NamespacedName{Name: kacr.Spec.AppName, Namespace: kacr.Namespace}, kApp) @@ -253,7 +253,7 @@ func TestKeptnAppCreationRequestReconciler_UpdateWorkloadsWithNewWorkload(t *tes require.NotEmpty(t, kApp.Spec.Version) require.Len(t, kApp.Spec.Workloads, 1) - require.Contains(t, kApp.Spec.Workloads, klcv1beta1.KeptnWorkloadRef{ + require.Contains(t, kApp.Spec.Workloads, apilifecycle.KeptnWorkloadRef{ Name: workload1.Name, Version: workload1.Spec.Version, }) @@ -261,7 +261,7 @@ func TestKeptnAppCreationRequestReconciler_UpdateWorkloadsWithNewWorkload(t *tes firstVersion := kApp.Spec.Version // verify that the creationRequest has been deleted - cr := &klcv1beta1.KeptnAppCreationRequest{} + cr := &apilifecycle.KeptnAppCreationRequest{} err = fakeClient.Get(context.TODO(), types.NamespacedName{Name: kacr.Name, Namespace: kacr.Namespace}, cr) @@ -269,12 +269,12 @@ func TestKeptnAppCreationRequestReconciler_UpdateWorkloadsWithNewWorkload(t *tes // create a new workload - workload2 := &klcv1beta1.KeptnWorkload{ + workload2 := &apilifecycle.KeptnWorkload{ ObjectMeta: metav1.ObjectMeta{ Name: "w2", Namespace: namespace, }, - Spec: klcv1beta1.KeptnWorkloadSpec{ + Spec: apilifecycle.KeptnWorkloadSpec{ AppName: appName, Version: "2.0", }, @@ -284,13 +284,13 @@ func TestKeptnAppCreationRequestReconciler_UpdateWorkloadsWithNewWorkload(t *tes require.Nil(t, err) // create a new instance of a CreationRequest - newKACR := &klcv1beta1.KeptnAppCreationRequest{ + newKACR := &apilifecycle.KeptnAppCreationRequest{ ObjectMeta: metav1.ObjectMeta{ Name: "my-kacr", Namespace: namespace, CreationTimestamp: metav1.Time{Time: theClock.Now()}, }, - Spec: klcv1beta1.KeptnAppCreationRequestSpec{ + Spec: apilifecycle.KeptnAppCreationRequestSpec{ AppName: appName, }, } @@ -307,7 +307,7 @@ func TestKeptnAppCreationRequestReconciler_UpdateWorkloadsWithNewWorkload(t *tes require.False(t, res.Requeue) require.Zero(t, res.RequeueAfter) - kApp = &klcv1beta1.KeptnApp{} + kApp = &apilifecycle.KeptnApp{} err = fakeClient.Get(context.TODO(), types.NamespacedName{Name: kacr.Spec.AppName, Namespace: kacr.Namespace}, kApp) @@ -316,13 +316,13 @@ func TestKeptnAppCreationRequestReconciler_UpdateWorkloadsWithNewWorkload(t *tes require.NotEmpty(t, kApp.Spec.Version) require.NotEqual(t, firstVersion, kApp.Spec.Version) - require.Contains(t, kApp.Spec.Workloads, klcv1beta1.KeptnWorkloadRef{ + require.Contains(t, kApp.Spec.Workloads, apilifecycle.KeptnWorkloadRef{ Name: workload1.Name, Version: workload1.Spec.Version, }) // now we should see the new workload as well require.Len(t, kApp.Spec.Workloads, 2) - require.Contains(t, kApp.Spec.Workloads, klcv1beta1.KeptnWorkloadRef{ + require.Contains(t, kApp.Spec.Workloads, apilifecycle.KeptnWorkloadRef{ Name: workload2.Name, Version: workload2.Spec.Version, }) @@ -332,13 +332,13 @@ func TestKeptnAppCreationRequestReconciler_UpdateWorkloadsWithNewVersion(t *test r, fakeClient, theClock := setupReconcilerAndClient(t) const namespace = "my-namespace" const appName = "my-app" - kacr := &klcv1beta1.KeptnAppCreationRequest{ + kacr := &apilifecycle.KeptnAppCreationRequest{ ObjectMeta: metav1.ObjectMeta{ Name: "my-kacr", Namespace: namespace, CreationTimestamp: metav1.Time{Time: theClock.Now()}, }, - Spec: klcv1beta1.KeptnAppCreationRequestSpec{ + Spec: apilifecycle.KeptnAppCreationRequestSpec{ AppName: appName, }, } @@ -346,12 +346,12 @@ func TestKeptnAppCreationRequestReconciler_UpdateWorkloadsWithNewVersion(t *test err := fakeClient.Create(context.TODO(), kacr) require.Nil(t, err) - workload1 := &klcv1beta1.KeptnWorkload{ + workload1 := &apilifecycle.KeptnWorkload{ ObjectMeta: metav1.ObjectMeta{ Name: "w1", Namespace: namespace, }, - Spec: klcv1beta1.KeptnWorkloadSpec{ + Spec: apilifecycle.KeptnWorkloadSpec{ AppName: appName, Version: "1.0", }, @@ -377,7 +377,7 @@ func TestKeptnAppCreationRequestReconciler_UpdateWorkloadsWithNewVersion(t *test require.False(t, res.Requeue) require.Zero(t, res.RequeueAfter) - kApp := &klcv1beta1.KeptnApp{} + kApp := &apilifecycle.KeptnApp{} err = fakeClient.Get(context.TODO(), types.NamespacedName{Name: kacr.Spec.AppName, Namespace: kacr.Namespace}, kApp) @@ -386,7 +386,7 @@ func TestKeptnAppCreationRequestReconciler_UpdateWorkloadsWithNewVersion(t *test require.NotEmpty(t, kApp.Spec.Version) require.Len(t, kApp.Spec.Workloads, 1) - require.Contains(t, kApp.Spec.Workloads, klcv1beta1.KeptnWorkloadRef{ + require.Contains(t, kApp.Spec.Workloads, apilifecycle.KeptnWorkloadRef{ Name: workload1.Name, Version: workload1.Spec.Version, }) @@ -394,7 +394,7 @@ func TestKeptnAppCreationRequestReconciler_UpdateWorkloadsWithNewVersion(t *test firstVersion := kApp.Spec.Version // verify that the creationRequest has been deleted - cr := &klcv1beta1.KeptnAppCreationRequest{} + cr := &apilifecycle.KeptnAppCreationRequest{} err = fakeClient.Get(context.TODO(), types.NamespacedName{Name: kacr.Name, Namespace: kacr.Namespace}, cr) @@ -407,13 +407,13 @@ func TestKeptnAppCreationRequestReconciler_UpdateWorkloadsWithNewVersion(t *test require.Nil(t, err) // create a new instance of a CreationRequest - newKACR := &klcv1beta1.KeptnAppCreationRequest{ + newKACR := &apilifecycle.KeptnAppCreationRequest{ ObjectMeta: metav1.ObjectMeta{ Name: "my-kacr", Namespace: namespace, CreationTimestamp: metav1.Time{Time: theClock.Now()}, }, - Spec: klcv1beta1.KeptnAppCreationRequestSpec{ + Spec: apilifecycle.KeptnAppCreationRequestSpec{ AppName: appName, }, } @@ -429,7 +429,7 @@ func TestKeptnAppCreationRequestReconciler_UpdateWorkloadsWithNewVersion(t *test require.False(t, res.Requeue) require.Zero(t, res.RequeueAfter) - kApp = &klcv1beta1.KeptnApp{} + kApp = &apilifecycle.KeptnApp{} err = fakeClient.Get(context.TODO(), types.NamespacedName{Name: kacr.Spec.AppName, Namespace: kacr.Namespace}, kApp) @@ -440,7 +440,7 @@ func TestKeptnAppCreationRequestReconciler_UpdateWorkloadsWithNewVersion(t *test // the version number of the app should have been changed require.NotEqual(t, firstVersion, kApp.Spec.Version) require.Len(t, kApp.Spec.Workloads, 1) - require.Contains(t, kApp.Spec.Workloads, klcv1beta1.KeptnWorkloadRef{ + require.Contains(t, kApp.Spec.Workloads, apilifecycle.KeptnWorkloadRef{ Name: workload1.Name, Version: workload1.Spec.Version, }) @@ -450,13 +450,13 @@ func TestKeptnAppCreationRequestReconciler_RemoveWorkload(t *testing.T) { r, fakeClient, theClock := setupReconcilerAndClient(t) const namespace = "my-namespace" const appName = "my-app" - kacr := &klcv1beta1.KeptnAppCreationRequest{ + kacr := &apilifecycle.KeptnAppCreationRequest{ ObjectMeta: metav1.ObjectMeta{ Name: "my-kacr", Namespace: namespace, CreationTimestamp: metav1.Time{Time: theClock.Now()}, }, - Spec: klcv1beta1.KeptnAppCreationRequestSpec{ + Spec: apilifecycle.KeptnAppCreationRequestSpec{ AppName: appName, }, } @@ -464,12 +464,12 @@ func TestKeptnAppCreationRequestReconciler_RemoveWorkload(t *testing.T) { err := fakeClient.Create(context.TODO(), kacr) require.Nil(t, err) - workload1 := &klcv1beta1.KeptnWorkload{ + workload1 := &apilifecycle.KeptnWorkload{ ObjectMeta: metav1.ObjectMeta{ Name: "w1", Namespace: namespace, }, - Spec: klcv1beta1.KeptnWorkloadSpec{ + Spec: apilifecycle.KeptnWorkloadSpec{ AppName: appName, Version: "1.0", }, @@ -478,12 +478,12 @@ func TestKeptnAppCreationRequestReconciler_RemoveWorkload(t *testing.T) { err = fakeClient.Create(context.TODO(), workload1) require.Nil(t, err) - workload2 := &klcv1beta1.KeptnWorkload{ + workload2 := &apilifecycle.KeptnWorkload{ ObjectMeta: metav1.ObjectMeta{ Name: "w2", Namespace: namespace, }, - Spec: klcv1beta1.KeptnWorkloadSpec{ + Spec: apilifecycle.KeptnWorkloadSpec{ AppName: appName, Version: "1.0", }, @@ -507,7 +507,7 @@ func TestKeptnAppCreationRequestReconciler_RemoveWorkload(t *testing.T) { require.False(t, res.Requeue) require.Zero(t, res.RequeueAfter) - kApp := &klcv1beta1.KeptnApp{} + kApp := &apilifecycle.KeptnApp{} err = fakeClient.Get(context.TODO(), types.NamespacedName{Name: kacr.Spec.AppName, Namespace: kacr.Namespace}, kApp) @@ -516,11 +516,11 @@ func TestKeptnAppCreationRequestReconciler_RemoveWorkload(t *testing.T) { require.NotEmpty(t, kApp.Spec.Version) require.Len(t, kApp.Spec.Workloads, 2) - require.Contains(t, kApp.Spec.Workloads, klcv1beta1.KeptnWorkloadRef{ + require.Contains(t, kApp.Spec.Workloads, apilifecycle.KeptnWorkloadRef{ Name: workload1.Name, Version: workload1.Spec.Version, }) - require.Contains(t, kApp.Spec.Workloads, klcv1beta1.KeptnWorkloadRef{ + require.Contains(t, kApp.Spec.Workloads, apilifecycle.KeptnWorkloadRef{ Name: workload2.Name, Version: workload2.Spec.Version, }) @@ -528,7 +528,7 @@ func TestKeptnAppCreationRequestReconciler_RemoveWorkload(t *testing.T) { firstVersion := kApp.Spec.Version // verify that the creationRequest has been deleted - cr := &klcv1beta1.KeptnAppCreationRequest{} + cr := &apilifecycle.KeptnAppCreationRequest{} err = fakeClient.Get(context.TODO(), types.NamespacedName{Name: kacr.Name, Namespace: kacr.Namespace}, cr) @@ -539,13 +539,13 @@ func TestKeptnAppCreationRequestReconciler_RemoveWorkload(t *testing.T) { require.Nil(t, err) // create a new instance of a CreationRequest - newKACR := &klcv1beta1.KeptnAppCreationRequest{ + newKACR := &apilifecycle.KeptnAppCreationRequest{ ObjectMeta: metav1.ObjectMeta{ Name: "my-kacr", Namespace: namespace, CreationTimestamp: metav1.Time{Time: theClock.Now()}, }, - Spec: klcv1beta1.KeptnAppCreationRequestSpec{ + Spec: apilifecycle.KeptnAppCreationRequestSpec{ AppName: appName, }, } @@ -562,7 +562,7 @@ func TestKeptnAppCreationRequestReconciler_RemoveWorkload(t *testing.T) { require.False(t, res.Requeue) require.Zero(t, res.RequeueAfter) - kApp = &klcv1beta1.KeptnApp{} + kApp = &apilifecycle.KeptnApp{} err = fakeClient.Get(context.TODO(), types.NamespacedName{Name: kacr.Spec.AppName, Namespace: kacr.Namespace}, kApp) @@ -573,7 +573,7 @@ func TestKeptnAppCreationRequestReconciler_RemoveWorkload(t *testing.T) { require.NotEqual(t, firstVersion, kApp.Spec.Version) // now we should see only one workload require.Len(t, kApp.Spec.Workloads, 1) - require.Contains(t, kApp.Spec.Workloads, klcv1beta1.KeptnWorkloadRef{ + require.Contains(t, kApp.Spec.Workloads, apilifecycle.KeptnWorkloadRef{ Name: workload2.Name, Version: workload2.Spec.Version, }) @@ -583,13 +583,13 @@ func TestKeptnAppCreationRequestReconciler_DoNotOverwriteUserDefinedApp(t *testi r, fakeClient, theClock := setupReconcilerAndClient(t) const namespace = "my-namespace" const appName = "my-app" - kacr := &klcv1beta1.KeptnAppCreationRequest{ + kacr := &apilifecycle.KeptnAppCreationRequest{ ObjectMeta: metav1.ObjectMeta{ Name: "my-kacr", Namespace: namespace, CreationTimestamp: metav1.Time{Time: theClock.Now()}, }, - Spec: klcv1beta1.KeptnAppCreationRequestSpec{ + Spec: apilifecycle.KeptnAppCreationRequestSpec{ AppName: appName, }, } @@ -597,12 +597,12 @@ func TestKeptnAppCreationRequestReconciler_DoNotOverwriteUserDefinedApp(t *testi err := fakeClient.Create(context.TODO(), kacr) require.Nil(t, err) - existingApp := &klcv1beta1.KeptnApp{ + existingApp := &apilifecycle.KeptnApp{ ObjectMeta: metav1.ObjectMeta{ Name: appName, Namespace: namespace, }, - Spec: klcv1beta1.KeptnAppSpec{ + Spec: apilifecycle.KeptnAppSpec{ Version: "1.0", }, } @@ -628,7 +628,7 @@ func TestKeptnAppCreationRequestReconciler_DoNotOverwriteUserDefinedApp(t *testi require.False(t, res.Requeue) require.Zero(t, res.RequeueAfter) - kApp := &klcv1beta1.KeptnApp{} + kApp := &apilifecycle.KeptnApp{} err = fakeClient.Get(context.Background(), types.NamespacedName{Name: kacr.Spec.AppName, Namespace: kacr.Namespace}, kApp) @@ -638,7 +638,7 @@ func TestKeptnAppCreationRequestReconciler_DoNotOverwriteUserDefinedApp(t *testi require.Equal(t, existingApp.Spec.Version, kApp.Spec.Version) // verify that the creationRequest has been deleted - cr := &klcv1beta1.KeptnAppCreationRequest{} + cr := &apilifecycle.KeptnAppCreationRequest{} err = fakeClient.Get(context.TODO(), types.NamespacedName{Name: kacr.Name, Namespace: kacr.Namespace}, cr) @@ -648,15 +648,15 @@ func TestKeptnAppCreationRequestReconciler_DoNotOverwriteUserDefinedApp(t *testi func setupReconcilerAndClient(t *testing.T) (*KeptnAppCreationRequestReconciler, client.Client, *clock.Mock) { scheme := runtime.NewScheme() - err := klcv1beta1.AddToScheme(scheme) + err := apilifecycle.AddToScheme(scheme) require.Nil(t, err) workloadAppIndexer := func(obj client.Object) []string { - workload, _ := obj.(*klcv1beta1.KeptnWorkload) + workload, _ := obj.(*apilifecycle.KeptnWorkload) return []string{workload.Spec.AppName} } - fakeClient := k8sfake.NewClientBuilder().WithScheme(scheme).WithObjects().WithIndex(&klcv1beta1.KeptnWorkload{}, "spec.app", workloadAppIndexer).Build() + fakeClient := k8sfake.NewClientBuilder().WithScheme(scheme).WithObjects().WithIndex(&apilifecycle.KeptnWorkload{}, "spec.app", workloadAppIndexer).Build() theClock := clock.NewMock() r := &KeptnAppCreationRequestReconciler{ @@ -690,23 +690,23 @@ func TestKeptnAppCreationRequestReconciler_getWorkloads(t *testing.T) { appName := "my-app" - workload1 := &klcv1beta1.KeptnWorkload{ + workload1 := &apilifecycle.KeptnWorkload{ ObjectMeta: metav1.ObjectMeta{ Name: "workloadA", Namespace: namespace, }, - Spec: klcv1beta1.KeptnWorkloadSpec{ + Spec: apilifecycle.KeptnWorkloadSpec{ AppName: appName, Version: "1.0", }, } - workload2 := &klcv1beta1.KeptnWorkload{ + workload2 := &apilifecycle.KeptnWorkload{ ObjectMeta: metav1.ObjectMeta{ Name: "workloadB", Namespace: namespace, }, - Spec: klcv1beta1.KeptnWorkloadSpec{ + Spec: apilifecycle.KeptnWorkloadSpec{ AppName: appName, Version: "1.0", }, @@ -714,41 +714,41 @@ func TestKeptnAppCreationRequestReconciler_getWorkloads(t *testing.T) { type args struct { ctx context.Context - creationRequest *klcv1beta1.KeptnAppCreationRequest + creationRequest *apilifecycle.KeptnAppCreationRequest } tests := []struct { name string args args - workloadsInCluster []klcv1beta1.KeptnWorkload - want []klcv1beta1.KeptnWorkload + workloadsInCluster []apilifecycle.KeptnWorkload + want []apilifecycle.KeptnWorkload wantErr bool }{ { name: "get workloads in alphabetical order - already sorted", args: args{ ctx: context.Background(), - creationRequest: &klcv1beta1.KeptnAppCreationRequest{ - Spec: klcv1beta1.KeptnAppCreationRequestSpec{ + creationRequest: &apilifecycle.KeptnAppCreationRequest{ + Spec: apilifecycle.KeptnAppCreationRequestSpec{ AppName: appName, }, }, }, - workloadsInCluster: []klcv1beta1.KeptnWorkload{*workload1, *workload2}, - want: []klcv1beta1.KeptnWorkload{*workload1, *workload2}, + workloadsInCluster: []apilifecycle.KeptnWorkload{*workload1, *workload2}, + want: []apilifecycle.KeptnWorkload{*workload1, *workload2}, wantErr: false, }, { name: "get workloads in alphabetical order - not sorted", args: args{ ctx: context.Background(), - creationRequest: &klcv1beta1.KeptnAppCreationRequest{ - Spec: klcv1beta1.KeptnAppCreationRequestSpec{ + creationRequest: &apilifecycle.KeptnAppCreationRequest{ + Spec: apilifecycle.KeptnAppCreationRequestSpec{ AppName: appName, }, }, }, - workloadsInCluster: []klcv1beta1.KeptnWorkload{*workload2, *workload1}, - want: []klcv1beta1.KeptnWorkload{*workload1, *workload2}, + workloadsInCluster: []apilifecycle.KeptnWorkload{*workload2, *workload1}, + want: []apilifecycle.KeptnWorkload{*workload1, *workload2}, wantErr: false, }, } diff --git a/lifecycle-operator/controllers/lifecycle/keptnappversion/controller.go b/lifecycle-operator/controllers/lifecycle/keptnappversion/controller.go index 60c12ca6ca..533006137a 100644 --- a/lifecycle-operator/controllers/lifecycle/keptnappversion/controller.go +++ b/lifecycle-operator/controllers/lifecycle/keptnappversion/controller.go @@ -22,8 +22,8 @@ import ( "time" "github.com/go-logr/logr" - klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" + apilifecycle "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1/common" controllercommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/config" appcontext "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/context" @@ -84,7 +84,7 @@ func (r *KeptnAppVersionReconciler) Reconcile(ctx context.Context, req ctrl.Requ requestInfo := controllercommon.GetRequestInfo(req) r.Log.Info("Searching for Keptn App Version", "requestInfo", requestInfo) - appVersion := &klcv1beta1.KeptnAppVersion{} + appVersion := &apilifecycle.KeptnAppVersion{} err := r.Get(ctx, req.NamespacedName, appVersion) if errors.IsNotFound(err) { return reconcile.Result{}, nil @@ -110,7 +110,7 @@ func (r *KeptnAppVersionReconciler) Reconcile(ctx context.Context, req ctrl.Requ r.Log.Error(err, "could not get span") } - defer func(appVersion *klcv1beta1.KeptnAppVersion, spanAppTrace trace.Span) { + defer func(appVersion *apilifecycle.KeptnAppVersion, spanAppTrace trace.Span) { r.closeFailedAppVersionSpan(appVersion, spanAppTrace) }(appVersion, spanAppTrace) @@ -188,7 +188,7 @@ func (r *KeptnAppVersionReconciler) Reconcile(ctx context.Context, req ctrl.Requ return r.finishKeptnAppVersionReconcile(ctx, appVersion, spanAppTrace) } -func (r *KeptnAppVersionReconciler) closeFailedAppVersionSpan(appVersion *klcv1beta1.KeptnAppVersion, spanAppTrace trace.Span) { +func (r *KeptnAppVersionReconciler) closeFailedAppVersionSpan(appVersion *apilifecycle.KeptnAppVersion, spanAppTrace trace.Span) { // make sure we close and unbind the span of a failed AppVersion if appVersion.Status.Status != apicommon.StateFailed { return @@ -202,7 +202,7 @@ func (r *KeptnAppVersionReconciler) closeFailedAppVersionSpan(appVersion *klcv1b r.EventSender.Emit(apicommon.PhaseAppCompleted, "Warning", appVersion, apicommon.PhaseStateFailed, "has failed", appVersion.GetVersion()) } -func (r *KeptnAppVersionReconciler) finishKeptnAppVersionReconcile(ctx context.Context, appVersion *klcv1beta1.KeptnAppVersion, spanAppTrace trace.Span) (ctrl.Result, error) { +func (r *KeptnAppVersionReconciler) finishKeptnAppVersionReconcile(ctx context.Context, appVersion *apilifecycle.KeptnAppVersion, spanAppTrace trace.Span) (ctrl.Result, error) { if !appVersion.IsEndTimeSet() { appVersion.Status.CurrentPhase = apicommon.PhaseCompleted.ShortName @@ -238,7 +238,7 @@ func (r *KeptnAppVersionReconciler) finishKeptnAppVersionReconcile(ctx context.C return ctrl.Result{}, nil } -func (r *KeptnAppVersionReconciler) setupSpansContexts(ctx context.Context, appVersion *klcv1beta1.KeptnAppVersion) (context.Context, func()) { +func (r *KeptnAppVersionReconciler) setupSpansContexts(ctx context.Context, appVersion *apilifecycle.KeptnAppVersion) (context.Context, func()) { appVersion.SetStartTime() appTraceContextCarrier := propagation.MapCarrier(appVersion.Spec.TraceId) @@ -258,7 +258,7 @@ func (r *KeptnAppVersionReconciler) setupSpansContexts(ctx context.Context, appV // SetupWithManager sets up the controller with the Manager. func (r *KeptnAppVersionReconciler) SetupWithManager(mgr ctrl.Manager) error { return ctrl.NewControllerManagedBy(mgr). - For(&klcv1beta1.KeptnAppVersion{}, builder.WithPredicates(predicate.GenerationChangedPredicate{})). + For(&apilifecycle.KeptnAppVersion{}, builder.WithPredicates(predicate.GenerationChangedPredicate{})). Complete(r) } @@ -266,7 +266,7 @@ func (r *KeptnAppVersionReconciler) getTracer() telemetry.ITracer { return r.TracerFactory.GetTracer(traceComponentName) } -func (r *KeptnAppVersionReconciler) getLinkedSpans(appVersion *klcv1beta1.KeptnAppVersion) []trace.Link { +func (r *KeptnAppVersionReconciler) getLinkedSpans(appVersion *apilifecycle.KeptnAppVersion) []trace.Link { result := make([]trace.Link, len(appVersion.Spec.SpanLinks)) for i, linkedSpan := range appVersion.Spec.SpanLinks { diff --git a/lifecycle-operator/controllers/lifecycle/keptnappversion/controller_test.go b/lifecycle-operator/controllers/lifecycle/keptnappversion/controller_test.go index ae0c3ef2d3..3004bb3758 100644 --- a/lifecycle-operator/controllers/lifecycle/keptnappversion/controller_test.go +++ b/lifecycle-operator/controllers/lifecycle/keptnappversion/controller_test.go @@ -9,8 +9,8 @@ import ( "testing" "github.com/go-logr/logr" - lfcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" + apilifecycle "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1/common" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/config" keptncontext "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/context" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/evaluation" @@ -45,7 +45,7 @@ const CONTEXTID contextID = "start" // this test checks if the chain of reconcile events is correct func TestKeptnAppVersionReconciler_reconcile(t *testing.T) { - pendingStatus := lfcv1beta1.KeptnAppVersionStatus{ + pendingStatus := apilifecycle.KeptnAppVersionStatus{ CurrentPhase: "", Status: apicommon.StatePending, PreDeploymentStatus: apicommon.StatePending, @@ -119,11 +119,11 @@ func TestKeptnAppVersionReconciler_reconcile(t *testing.T) { func TestKeptnAppVersionReconciler_ReconcileFailed(t *testing.T) { - status := lfcv1beta1.KeptnAppVersionStatus{ + status := apilifecycle.KeptnAppVersionStatus{ CurrentPhase: apicommon.PhaseAppPreDeployment.ShortName, Status: apicommon.StateProgressing, PreDeploymentStatus: apicommon.StateProgressing, - PreDeploymentTaskStatus: []lfcv1beta1.ItemStatus{ + PreDeploymentTaskStatus: []apilifecycle.ItemStatus{ { Name: "pre-task", DefinitionName: "task", @@ -137,19 +137,19 @@ func TestKeptnAppVersionReconciler_ReconcileFailed(t *testing.T) { } appVersionName := fmt.Sprintf("%s-%s", "myapp", "1.0.0") - app := &lfcv1beta1.KeptnAppVersion{ + app := &apilifecycle.KeptnAppVersion{ TypeMeta: metav1.TypeMeta{}, ObjectMeta: metav1.ObjectMeta{ Name: appVersionName, Namespace: "default", Generation: 1, }, - Spec: lfcv1beta1.KeptnAppVersionSpec{ - KeptnAppSpec: lfcv1beta1.KeptnAppSpec{ + Spec: apilifecycle.KeptnAppVersionSpec{ + KeptnAppSpec: apilifecycle.KeptnAppSpec{ Version: "1.0.0", }, - KeptnAppContextSpec: lfcv1beta1.KeptnAppContextSpec{ - DeploymentTaskSpec: lfcv1beta1.DeploymentTaskSpec{ + KeptnAppContextSpec: apilifecycle.KeptnAppContextSpec{ + DeploymentTaskSpec: apilifecycle.DeploymentTaskSpec{ PreDeploymentTasks: []string{ "task", }, @@ -227,7 +227,7 @@ func TestKeptnAppVersionReconciler_ReconcileReachCompletion(t *testing.T) { func TestKeptnAppVersionReconciler_ReconcileFailedAppVersion(t *testing.T) { - app := testcommon.ReturnAppVersion("default", "myfinishedapp", "1.0.0", nil, lfcv1beta1.KeptnAppVersionStatus{}) + app := testcommon.ReturnAppVersion("default", "myfinishedapp", "1.0.0", nil, apilifecycle.KeptnAppVersionStatus{}) app.Spec.PreDeploymentTasks = []string{"my-task"} r, eventChannel, _ := setupReconciler(app) @@ -277,36 +277,36 @@ func TestKeptnAppVersionReconciler_ReconcileFailedAppVersion(t *testing.T) { func TestKeptnAppVersionReconciler_ReconcilePromotionPhase(t *testing.T) { - appVersionStatus := lfcv1beta1.KeptnAppVersionStatus{ + appVersionStatus := apilifecycle.KeptnAppVersionStatus{ CurrentPhase: apicommon.PhaseCompleted.ShortName, PreDeploymentStatus: apicommon.StateSucceeded, PostDeploymentStatus: apicommon.StateSucceeded, PreDeploymentEvaluationStatus: apicommon.StateSucceeded, PostDeploymentEvaluationStatus: apicommon.StateSucceeded, PromotionStatus: apicommon.StatePending, - PreDeploymentTaskStatus: []lfcv1beta1.ItemStatus{{Status: apicommon.StateSucceeded}}, - PostDeploymentTaskStatus: []lfcv1beta1.ItemStatus{{Status: apicommon.StateSucceeded}}, - PreDeploymentEvaluationTaskStatus: []lfcv1beta1.ItemStatus{{Status: apicommon.StateSucceeded}}, - PostDeploymentEvaluationTaskStatus: []lfcv1beta1.ItemStatus{{Status: apicommon.StateSucceeded}}, + PreDeploymentTaskStatus: []apilifecycle.ItemStatus{{Status: apicommon.StateSucceeded}}, + PostDeploymentTaskStatus: []apilifecycle.ItemStatus{{Status: apicommon.StateSucceeded}}, + PreDeploymentEvaluationTaskStatus: []apilifecycle.ItemStatus{{Status: apicommon.StateSucceeded}}, + PostDeploymentEvaluationTaskStatus: []apilifecycle.ItemStatus{{Status: apicommon.StateSucceeded}}, WorkloadOverallStatus: apicommon.StateSucceeded, - WorkloadStatus: []lfcv1beta1.WorkloadStatus{{Status: apicommon.StateSucceeded}}, + WorkloadStatus: []apilifecycle.WorkloadStatus{{Status: apicommon.StateSucceeded}}, Status: apicommon.StateSucceeded, } appVersionName := fmt.Sprintf("%s-%s", "myapp", "1.0.0") - appVersion := &lfcv1beta1.KeptnAppVersion{ + appVersion := &apilifecycle.KeptnAppVersion{ TypeMeta: metav1.TypeMeta{}, ObjectMeta: metav1.ObjectMeta{ Name: appVersionName, Namespace: "default", Generation: 1, }, - Spec: lfcv1beta1.KeptnAppVersionSpec{ - KeptnAppSpec: lfcv1beta1.KeptnAppSpec{ + Spec: apilifecycle.KeptnAppVersionSpec{ + KeptnAppSpec: apilifecycle.KeptnAppSpec{ Version: "1.0.0", }, - KeptnAppContextSpec: lfcv1beta1.KeptnAppContextSpec{ - DeploymentTaskSpec: lfcv1beta1.DeploymentTaskSpec{ + KeptnAppContextSpec: apilifecycle.KeptnAppContextSpec{ + DeploymentTaskSpec: apilifecycle.DeploymentTaskSpec{ PromotionTasks: []string{"my-promotion-task"}, }, }, @@ -356,36 +356,36 @@ func TestKeptnAppVersionReconciler_ReconcilePromotionPhase(t *testing.T) { func TestKeptnAppVersionReconciler_ReconcilePromotionPhaseFails(t *testing.T) { - appVersionStatus := lfcv1beta1.KeptnAppVersionStatus{ + appVersionStatus := apilifecycle.KeptnAppVersionStatus{ CurrentPhase: apicommon.PhaseCompleted.ShortName, PreDeploymentStatus: apicommon.StateSucceeded, PostDeploymentStatus: apicommon.StateSucceeded, PreDeploymentEvaluationStatus: apicommon.StateSucceeded, PostDeploymentEvaluationStatus: apicommon.StateSucceeded, PromotionStatus: apicommon.StatePending, - PreDeploymentTaskStatus: []lfcv1beta1.ItemStatus{{Status: apicommon.StateSucceeded}}, - PostDeploymentTaskStatus: []lfcv1beta1.ItemStatus{{Status: apicommon.StateSucceeded}}, - PreDeploymentEvaluationTaskStatus: []lfcv1beta1.ItemStatus{{Status: apicommon.StateSucceeded}}, - PostDeploymentEvaluationTaskStatus: []lfcv1beta1.ItemStatus{{Status: apicommon.StateSucceeded}}, + PreDeploymentTaskStatus: []apilifecycle.ItemStatus{{Status: apicommon.StateSucceeded}}, + PostDeploymentTaskStatus: []apilifecycle.ItemStatus{{Status: apicommon.StateSucceeded}}, + PreDeploymentEvaluationTaskStatus: []apilifecycle.ItemStatus{{Status: apicommon.StateSucceeded}}, + PostDeploymentEvaluationTaskStatus: []apilifecycle.ItemStatus{{Status: apicommon.StateSucceeded}}, WorkloadOverallStatus: apicommon.StateSucceeded, - WorkloadStatus: []lfcv1beta1.WorkloadStatus{{Status: apicommon.StateSucceeded}}, + WorkloadStatus: []apilifecycle.WorkloadStatus{{Status: apicommon.StateSucceeded}}, Status: apicommon.StateSucceeded, } appVersionName := fmt.Sprintf("%s-%s", "myapp", "1.0.0") - appVersion := &lfcv1beta1.KeptnAppVersion{ + appVersion := &apilifecycle.KeptnAppVersion{ TypeMeta: metav1.TypeMeta{}, ObjectMeta: metav1.ObjectMeta{ Name: appVersionName, Namespace: "default", Generation: 1, }, - Spec: lfcv1beta1.KeptnAppVersionSpec{ - KeptnAppSpec: lfcv1beta1.KeptnAppSpec{ + Spec: apilifecycle.KeptnAppVersionSpec{ + KeptnAppSpec: apilifecycle.KeptnAppSpec{ Version: "1.0.0", }, - KeptnAppContextSpec: lfcv1beta1.KeptnAppContextSpec{ - DeploymentTaskSpec: lfcv1beta1.DeploymentTaskSpec{ + KeptnAppContextSpec: apilifecycle.KeptnAppContextSpec{ + DeploymentTaskSpec: apilifecycle.DeploymentTaskSpec{ PromotionTasks: []string{"my-promotion-task"}, }, }, @@ -420,20 +420,20 @@ func TestKeptnAppVersionReconciler_ReconcilePromotionPhaseFails(t *testing.T) { require.Equal(t, apicommon.PhasePromotion, mockPhaseHandler.HandlePhaseCalls()[0].PhaseMoqParam) } -func createFinishedAppVersionStatus() lfcv1beta1.KeptnAppVersionStatus { - return lfcv1beta1.KeptnAppVersionStatus{ +func createFinishedAppVersionStatus() apilifecycle.KeptnAppVersionStatus { + return apilifecycle.KeptnAppVersionStatus{ CurrentPhase: apicommon.PhaseCompleted.ShortName, PreDeploymentStatus: apicommon.StateSucceeded, PostDeploymentStatus: apicommon.StateSucceeded, PreDeploymentEvaluationStatus: apicommon.StateSucceeded, PostDeploymentEvaluationStatus: apicommon.StateSucceeded, PromotionStatus: apicommon.StateSucceeded, - PreDeploymentTaskStatus: []lfcv1beta1.ItemStatus{{Status: apicommon.StateSucceeded}}, - PostDeploymentTaskStatus: []lfcv1beta1.ItemStatus{{Status: apicommon.StateSucceeded}}, - PreDeploymentEvaluationTaskStatus: []lfcv1beta1.ItemStatus{{Status: apicommon.StateSucceeded}}, - PostDeploymentEvaluationTaskStatus: []lfcv1beta1.ItemStatus{{Status: apicommon.StateSucceeded}}, + PreDeploymentTaskStatus: []apilifecycle.ItemStatus{{Status: apicommon.StateSucceeded}}, + PostDeploymentTaskStatus: []apilifecycle.ItemStatus{{Status: apicommon.StateSucceeded}}, + PreDeploymentEvaluationTaskStatus: []apilifecycle.ItemStatus{{Status: apicommon.StateSucceeded}}, + PostDeploymentEvaluationTaskStatus: []apilifecycle.ItemStatus{{Status: apicommon.StateSucceeded}}, WorkloadOverallStatus: apicommon.StateSucceeded, - WorkloadStatus: []lfcv1beta1.WorkloadStatus{{Status: apicommon.StateSucceeded}}, + WorkloadStatus: []apilifecycle.WorkloadStatus{{Status: apicommon.StateSucceeded}}, Status: apicommon.StateSucceeded, } } @@ -490,12 +490,12 @@ func setupReconciler(objs ...client.Object) (*KeptnAppVersionReconciler, chan st } workloadVersionIndexer := func(obj client.Object) []string { - workloadVersion, _ := obj.(*lfcv1beta1.KeptnWorkloadVersion) + workloadVersion, _ := obj.(*apilifecycle.KeptnWorkloadVersion) return []string{workloadVersion.Spec.AppName} } testcommon.SetupSchemes() - fakeClient := fake.NewClientBuilder().WithObjects(objs...).WithStatusSubresource(objs...).WithScheme(scheme.Scheme).WithObjects().WithIndex(&lfcv1beta1.KeptnWorkloadVersion{}, "spec.app", workloadVersionIndexer).Build() + fakeClient := fake.NewClientBuilder().WithObjects(objs...).WithStatusSubresource(objs...).WithScheme(scheme.Scheme).WithObjects().WithIndex(&apilifecycle.KeptnWorkloadVersion{}, "spec.app", workloadVersionIndexer).Build() recorder := record.NewFakeRecorder(100) r := &KeptnAppVersionReconciler{ @@ -508,8 +508,8 @@ func setupReconciler(objs ...client.Object) (*KeptnAppVersionReconciler, chan st Meters: testcommon.InitAppMeters(), Config: config.Instance(), EvaluationHandler: &evalfake.MockEvaluationHandler{ - ReconcileEvaluationsFunc: func(ctx context.Context, phaseCtx context.Context, reconcileObject client.Object, evaluationCreateAttributes evaluation.CreateEvaluationAttributes) ([]lfcv1beta1.ItemStatus, apicommon.StatusSummary, error) { - return []lfcv1beta1.ItemStatus{}, apicommon.StatusSummary{}, nil + ReconcileEvaluationsFunc: func(ctx context.Context, phaseCtx context.Context, reconcileObject client.Object, evaluationCreateAttributes evaluation.CreateEvaluationAttributes) ([]apilifecycle.ItemStatus, apicommon.StatusSummary, error) { + return []apilifecycle.ItemStatus{}, apicommon.StatusSummary{}, nil }, }, } @@ -521,7 +521,7 @@ func TestKeptnApVersionReconciler_setupSpansContexts(t *testing.T) { r := setupReconcilerWithMeters() type args struct { ctx context.Context - appVersion *lfcv1beta1.KeptnAppVersion + appVersion *apilifecycle.KeptnAppVersion } tests := []struct { name string @@ -532,8 +532,8 @@ func TestKeptnApVersionReconciler_setupSpansContexts(t *testing.T) { name: "Current trace ctx should be != than app trace context", args: args{ ctx: context.WithValue(context.TODO(), CONTEXTID, 1), - appVersion: &lfcv1beta1.KeptnAppVersion{ - Spec: lfcv1beta1.KeptnAppVersionSpec{TraceId: map[string]string{ + appVersion: &apilifecycle.KeptnAppVersion{ + Spec: apilifecycle.KeptnAppVersionSpec{TraceId: map[string]string{ "traceparent": "00-52527d549a7b33653017ce960be09dfc-a38a5a8d179a88b5-01", }}, }, @@ -557,7 +557,7 @@ func TestKeptnAppVersionReconciler_getLinkedSpans(t *testing.T) { Log logr.Logger } type args struct { - version *lfcv1beta1.KeptnAppVersion + version *apilifecycle.KeptnAppVersion } tests := []struct { name string @@ -571,9 +571,9 @@ func TestKeptnAppVersionReconciler_getLinkedSpans(t *testing.T) { Log: ctrl.Log.WithName("test-appVersionController"), }, args: args{ - version: &lfcv1beta1.KeptnAppVersion{ - Spec: lfcv1beta1.KeptnAppVersionSpec{ - KeptnAppContextSpec: lfcv1beta1.KeptnAppContextSpec{ + version: &apilifecycle.KeptnAppVersion{ + Spec: apilifecycle.KeptnAppVersionSpec{ + KeptnAppContextSpec: apilifecycle.KeptnAppContextSpec{ SpanLinks: []string{"00-c088f5c586bab8649159ccc39a9862f7-f862289833f1fba3-01"}, }, }, diff --git a/lifecycle-operator/controllers/lifecycle/keptnappversion/reconcile_phase.go b/lifecycle-operator/controllers/lifecycle/keptnappversion/reconcile_phase.go index 31aa75ca81..fa53d48378 100644 --- a/lifecycle-operator/controllers/lifecycle/keptnappversion/reconcile_phase.go +++ b/lifecycle-operator/controllers/lifecycle/keptnappversion/reconcile_phase.go @@ -5,12 +5,12 @@ import ( "context" "fmt" - klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" + apilifecycle "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1/common" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/task" ) -func (r *KeptnAppVersionReconciler) reconcilePhase(ctx context.Context, phaseCtx context.Context, appVersion *klcv1beta1.KeptnAppVersion, checkType apicommon.CheckType) (apicommon.KeptnState, error) { +func (r *KeptnAppVersionReconciler) reconcilePhase(ctx context.Context, phaseCtx context.Context, appVersion *apilifecycle.KeptnAppVersion, checkType apicommon.CheckType) (apicommon.KeptnState, error) { taskHandler := task.Handler{ Client: r.Client, EventSender: r.EventSender, diff --git a/lifecycle-operator/controllers/lifecycle/keptnappversion/reconcile_prepostevaluation.go b/lifecycle-operator/controllers/lifecycle/keptnappversion/reconcile_prepostevaluation.go index 2e6953c2e1..e1c651ee2a 100644 --- a/lifecycle-operator/controllers/lifecycle/keptnappversion/reconcile_prepostevaluation.go +++ b/lifecycle-operator/controllers/lifecycle/keptnappversion/reconcile_prepostevaluation.go @@ -5,12 +5,12 @@ import ( "context" "fmt" - klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" + apilifecycle "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1/common" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/evaluation" ) -func (r *KeptnAppVersionReconciler) reconcilePrePostEvaluation(ctx context.Context, phaseCtx context.Context, appVersion *klcv1beta1.KeptnAppVersion, checkType apicommon.CheckType) (apicommon.KeptnState, error) { +func (r *KeptnAppVersionReconciler) reconcilePrePostEvaluation(ctx context.Context, phaseCtx context.Context, appVersion *apilifecycle.KeptnAppVersion, checkType apicommon.CheckType) (apicommon.KeptnState, error) { evaluationCreateAttributes := evaluation.CreateEvaluationAttributes{ SpanName: fmt.Sprintf(apicommon.CreateAppEvalSpanName, checkType), CheckType: checkType, diff --git a/lifecycle-operator/controllers/lifecycle/keptnappversion/reconcile_workloadsstate.go b/lifecycle-operator/controllers/lifecycle/keptnappversion/reconcile_workloadsstate.go index 6ab02a8c4a..dd93e9a56c 100644 --- a/lifecycle-operator/controllers/lifecycle/keptnappversion/reconcile_workloadsstate.go +++ b/lifecycle-operator/controllers/lifecycle/keptnappversion/reconcile_workloadsstate.go @@ -4,13 +4,13 @@ import ( "context" "fmt" - klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" + apilifecycle "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1/common" operatorcommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/common" "sigs.k8s.io/controller-runtime/pkg/client" ) -func (r *KeptnAppVersionReconciler) reconcileWorkloads(ctx context.Context, appVersion *klcv1beta1.KeptnAppVersion) (apicommon.KeptnState, error) { +func (r *KeptnAppVersionReconciler) reconcileWorkloads(ctx context.Context, appVersion *apilifecycle.KeptnAppVersion) (apicommon.KeptnState, error) { r.Log.Info("Reconciling Workloads") var summary apicommon.StatusSummary summary.Total = len(appVersion.Spec.Workloads) @@ -23,7 +23,7 @@ func (r *KeptnAppVersionReconciler) reconcileWorkloads(ctx context.Context, appV return apicommon.StateUnknown, r.handleUnaccessibleWorkloadVersionList(ctx, appVersion) } - newStatus := make([]klcv1beta1.WorkloadStatus, 0, len(appVersion.Spec.Workloads)) + newStatus := make([]apilifecycle.WorkloadStatus, 0, len(appVersion.Spec.Workloads)) for _, w := range appVersion.Spec.Workloads { r.Log.Info("Reconciling workload " + w.Name) workloadStatus := apicommon.StatePending @@ -44,7 +44,7 @@ func (r *KeptnAppVersionReconciler) reconcileWorkloads(ctx context.Context, appV r.EventSender.Emit(phase, "Warning", appVersion, apicommon.PhaseStateNotFound, fmt.Sprintf("could not find KeptnWorkloadVersion for KeptnWorkload: %s ", w.Name), appVersion.GetVersion()) } - newStatus = append(newStatus, klcv1beta1.WorkloadStatus{ + newStatus = append(newStatus, apilifecycle.WorkloadStatus{ Workload: w, Status: workloadStatus, }) @@ -63,18 +63,18 @@ func (r *KeptnAppVersionReconciler) reconcileWorkloads(ctx context.Context, appV return overallState, err } -func (r *KeptnAppVersionReconciler) getWorkloadVersionList(ctx context.Context, namespace string, appName string) (*klcv1beta1.KeptnWorkloadVersionList, error) { - workloadVersionList := &klcv1beta1.KeptnWorkloadVersionList{} +func (r *KeptnAppVersionReconciler) getWorkloadVersionList(ctx context.Context, namespace string, appName string) (*apilifecycle.KeptnWorkloadVersionList, error) { + workloadVersionList := &apilifecycle.KeptnWorkloadVersionList{} err := r.Client.List(ctx, workloadVersionList, client.InNamespace(namespace), client.MatchingFields{ "spec.app": appName, }) return workloadVersionList, err } -func (r *KeptnAppVersionReconciler) handleUnaccessibleWorkloadVersionList(ctx context.Context, appVersion *klcv1beta1.KeptnAppVersion) error { - newStatus := make([]klcv1beta1.WorkloadStatus, 0, len(appVersion.Spec.Workloads)) +func (r *KeptnAppVersionReconciler) handleUnaccessibleWorkloadVersionList(ctx context.Context, appVersion *apilifecycle.KeptnAppVersion) error { + newStatus := make([]apilifecycle.WorkloadStatus, 0, len(appVersion.Spec.Workloads)) for _, w := range appVersion.Spec.Workloads { - newStatus = append(newStatus, klcv1beta1.WorkloadStatus{ + newStatus = append(newStatus, apilifecycle.WorkloadStatus{ Workload: w, Status: apicommon.StateUnknown, }) diff --git a/lifecycle-operator/controllers/lifecycle/keptnappversion/reconcile_workloadstate_test.go b/lifecycle-operator/controllers/lifecycle/keptnappversion/reconcile_workloadstate_test.go index 62ac8419b8..0c97290a4b 100644 --- a/lifecycle-operator/controllers/lifecycle/keptnappversion/reconcile_workloadstate_test.go +++ b/lifecycle-operator/controllers/lifecycle/keptnappversion/reconcile_workloadstate_test.go @@ -4,8 +4,8 @@ import ( "context" "testing" - lfcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" + apilifecycle "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1/common" "github.com/stretchr/testify/require" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" @@ -13,12 +13,12 @@ import ( //nolint:dogsled func TestKeptnAppVersionReconciler_reconcileWorkloads_noWorkloads(t *testing.T) { - appVersion := &lfcv1beta1.KeptnAppVersion{ + appVersion := &apilifecycle.KeptnAppVersion{ ObjectMeta: v1.ObjectMeta{ Name: "appversion", Namespace: "default", }, - Spec: lfcv1beta1.KeptnAppVersionSpec{ + Spec: apilifecycle.KeptnAppVersionSpec{ AppName: "app", }, } @@ -36,14 +36,14 @@ func TestKeptnAppVersionReconciler_reconcileWorkloads_noWorkloads(t *testing.T) //nolint:dogsled func TestKeptnAppVersionReconciler_reconcileWorkloads(t *testing.T) { - appVersion := &lfcv1beta1.KeptnAppVersion{ + appVersion := &apilifecycle.KeptnAppVersion{ ObjectMeta: v1.ObjectMeta{ Name: "appversion", Namespace: "default", }, - Spec: lfcv1beta1.KeptnAppVersionSpec{ - KeptnAppSpec: lfcv1beta1.KeptnAppSpec{ - Workloads: []lfcv1beta1.KeptnWorkloadRef{ + Spec: apilifecycle.KeptnAppVersionSpec{ + KeptnAppSpec: apilifecycle.KeptnAppSpec{ + Workloads: []apilifecycle.KeptnWorkloadRef{ { Name: "workload", Version: "ver1", @@ -65,9 +65,9 @@ func TestKeptnAppVersionReconciler_reconcileWorkloads(t *testing.T) { require.Nil(t, err) require.Equal(t, apicommon.StatePending, appVersion.Status.WorkloadOverallStatus) require.Len(t, appVersion.Status.WorkloadStatus, 1) - require.Equal(t, []lfcv1beta1.WorkloadStatus{ + require.Equal(t, []apilifecycle.WorkloadStatus{ { - Workload: lfcv1beta1.KeptnWorkloadRef{ + Workload: apilifecycle.KeptnWorkloadRef{ Name: "workload", Version: "ver1", }, @@ -77,13 +77,13 @@ func TestKeptnAppVersionReconciler_reconcileWorkloads(t *testing.T) { // Creating WorkloadInstace that is not part of the App -> should stay Pending - wi1 := &lfcv1beta1.KeptnWorkloadVersion{ + wi1 := &apilifecycle.KeptnWorkloadVersion{ ObjectMeta: v1.ObjectMeta{ Name: "workload", Namespace: "default", }, - Spec: lfcv1beta1.KeptnWorkloadVersionSpec{ - KeptnWorkloadSpec: lfcv1beta1.KeptnWorkloadSpec{ + Spec: apilifecycle.KeptnWorkloadVersionSpec{ + KeptnWorkloadSpec: apilifecycle.KeptnWorkloadSpec{ AppName: "app2", }, }, @@ -100,9 +100,9 @@ func TestKeptnAppVersionReconciler_reconcileWorkloads(t *testing.T) { require.Nil(t, err) require.Equal(t, apicommon.StatePending, appVersion.Status.WorkloadOverallStatus) require.Len(t, appVersion.Status.WorkloadStatus, 1) - require.Equal(t, []lfcv1beta1.WorkloadStatus{ + require.Equal(t, []apilifecycle.WorkloadStatus{ { - Workload: lfcv1beta1.KeptnWorkloadRef{ + Workload: apilifecycle.KeptnWorkloadRef{ Name: "workload", Version: "ver1", }, @@ -112,13 +112,13 @@ func TestKeptnAppVersionReconciler_reconcileWorkloads(t *testing.T) { // Creating WorkloadVersion of App with progressing state -> appVersion should be Progressing - wi2 := &lfcv1beta1.KeptnWorkloadVersion{ + wi2 := &apilifecycle.KeptnWorkloadVersion{ ObjectMeta: v1.ObjectMeta{ Name: "app-workload-ver1", Namespace: "default", }, - Spec: lfcv1beta1.KeptnWorkloadVersionSpec{ - KeptnWorkloadSpec: lfcv1beta1.KeptnWorkloadSpec{ + Spec: apilifecycle.KeptnWorkloadVersionSpec{ + KeptnWorkloadSpec: apilifecycle.KeptnWorkloadSpec{ AppName: "app", }, }, @@ -142,9 +142,9 @@ func TestKeptnAppVersionReconciler_reconcileWorkloads(t *testing.T) { require.Nil(t, err) require.Equal(t, apicommon.StateProgressing, appVersion.Status.WorkloadOverallStatus) require.Len(t, appVersion.Status.WorkloadStatus, 1) - require.Equal(t, []lfcv1beta1.WorkloadStatus{ + require.Equal(t, []apilifecycle.WorkloadStatus{ { - Workload: lfcv1beta1.KeptnWorkloadRef{ + Workload: apilifecycle.KeptnWorkloadRef{ Name: "workload", Version: "ver1", }, @@ -169,9 +169,9 @@ func TestKeptnAppVersionReconciler_reconcileWorkloads(t *testing.T) { require.Nil(t, err) require.Equal(t, apicommon.StateSucceeded, appVersion.Status.WorkloadOverallStatus) require.Len(t, appVersion.Status.WorkloadStatus, 1) - require.Equal(t, []lfcv1beta1.WorkloadStatus{ + require.Equal(t, []apilifecycle.WorkloadStatus{ { - Workload: lfcv1beta1.KeptnWorkloadRef{ + Workload: apilifecycle.KeptnWorkloadRef{ Name: "workload", Version: "ver1", }, @@ -182,14 +182,14 @@ func TestKeptnAppVersionReconciler_reconcileWorkloads(t *testing.T) { //nolint:dogsled func TestKeptnAppVersionReconciler_handleUnaccessibleWorkloadVersionList(t *testing.T) { - appVersion := &lfcv1beta1.KeptnAppVersion{ + appVersion := &apilifecycle.KeptnAppVersion{ ObjectMeta: v1.ObjectMeta{ Name: "appversion", Namespace: "default", }, - Spec: lfcv1beta1.KeptnAppVersionSpec{ - KeptnAppSpec: lfcv1beta1.KeptnAppSpec{ - Workloads: []lfcv1beta1.KeptnWorkloadRef{ + Spec: apilifecycle.KeptnAppVersionSpec{ + KeptnAppSpec: apilifecycle.KeptnAppSpec{ + Workloads: []apilifecycle.KeptnWorkloadRef{ { Name: "workload", Version: "ver1", @@ -208,9 +208,9 @@ func TestKeptnAppVersionReconciler_handleUnaccessibleWorkloadVersionList(t *test require.Nil(t, err) require.Equal(t, apicommon.StateUnknown, appVersion.Status.WorkloadOverallStatus) require.Len(t, appVersion.Status.WorkloadStatus, 1) - require.Equal(t, []lfcv1beta1.WorkloadStatus{ + require.Equal(t, []apilifecycle.WorkloadStatus{ { - Workload: lfcv1beta1.KeptnWorkloadRef{ + Workload: apilifecycle.KeptnWorkloadRef{ Name: "workload", Version: "ver1", }, diff --git a/lifecycle-operator/controllers/lifecycle/keptnevaluation/common.go b/lifecycle-operator/controllers/lifecycle/keptnevaluation/common.go index a02cc84e96..b1fe664bc2 100644 --- a/lifecycle-operator/controllers/lifecycle/keptnevaluation/common.go +++ b/lifecycle-operator/controllers/lifecycle/keptnevaluation/common.go @@ -5,10 +5,10 @@ import ( "math" "strconv" - klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" + apilifecycle "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1" ) -func checkValue(objective klcv1beta1.Objective, item *klcv1beta1.EvaluationStatusItem) (bool, error) { +func checkValue(objective apilifecycle.Objective, item *apilifecycle.EvaluationStatusItem) (bool, error) { if len(item.Value) == 0 || len(objective.EvaluationTarget) == 0 { return false, fmt.Errorf("no values") diff --git a/lifecycle-operator/controllers/lifecycle/keptnevaluation/common_test.go b/lifecycle-operator/controllers/lifecycle/keptnevaluation/common_test.go index 4f62c3c4d0..a8db182f18 100644 --- a/lifecycle-operator/controllers/lifecycle/keptnevaluation/common_test.go +++ b/lifecycle-operator/controllers/lifecycle/keptnevaluation/common_test.go @@ -3,35 +3,35 @@ package keptnevaluation import ( "testing" - klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" + apilifecycle "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1" "github.com/stretchr/testify/require" ) func TestCheckValue(t *testing.T) { tests := []struct { name string - obj klcv1beta1.Objective - item *klcv1beta1.EvaluationStatusItem + obj apilifecycle.Objective + item *apilifecycle.EvaluationStatusItem result bool err bool }{ { name: "empty values", - obj: klcv1beta1.Objective{}, - item: &klcv1beta1.EvaluationStatusItem{}, + obj: apilifecycle.Objective{}, + item: &apilifecycle.EvaluationStatusItem{}, result: false, err: true, }, { name: "garbage values", - obj: klcv1beta1.Objective{ - KeptnMetricRef: klcv1beta1.KeptnMetricReference{ + obj: apilifecycle.Objective{ + KeptnMetricRef: apilifecycle.KeptnMetricReference{ Name: "testytest", Namespace: "default", }, EvaluationTarget: "testytest", }, - item: &klcv1beta1.EvaluationStatusItem{ + item: &apilifecycle.EvaluationStatusItem{ Value: "testytest", Status: "testytest", Message: "testytest", @@ -41,14 +41,14 @@ func TestCheckValue(t *testing.T) { }, { name: "Item nan", - obj: klcv1beta1.Objective{ - KeptnMetricRef: klcv1beta1.KeptnMetricReference{ + obj: apilifecycle.Objective{ + KeptnMetricRef: apilifecycle.KeptnMetricReference{ Name: "testytest", Namespace: "default", }, EvaluationTarget: "10", }, - item: &klcv1beta1.EvaluationStatusItem{ + item: &apilifecycle.EvaluationStatusItem{ Value: "nan", Status: "all good", Message: "all good", @@ -58,14 +58,14 @@ func TestCheckValue(t *testing.T) { }, { name: "garbage comparison", - obj: klcv1beta1.Objective{ - KeptnMetricRef: klcv1beta1.KeptnMetricReference{ + obj: apilifecycle.Objective{ + KeptnMetricRef: apilifecycle.KeptnMetricReference{ Name: "testytest", Namespace: "default", }, EvaluationTarget: "testytest", }, - item: &klcv1beta1.EvaluationStatusItem{ + item: &apilifecycle.EvaluationStatusItem{ Value: "10", Status: "all good", Message: "all good", @@ -75,14 +75,14 @@ func TestCheckValue(t *testing.T) { }, { name: "objective nan", - obj: klcv1beta1.Objective{ - KeptnMetricRef: klcv1beta1.KeptnMetricReference{ + obj: apilifecycle.Objective{ + KeptnMetricRef: apilifecycle.KeptnMetricReference{ Name: "testytest", Namespace: "default", }, EvaluationTarget: "nan", }, - item: &klcv1beta1.EvaluationStatusItem{ + item: &apilifecycle.EvaluationStatusItem{ Value: "10", Status: "all good", Message: "all good", @@ -92,14 +92,14 @@ func TestCheckValue(t *testing.T) { }, { name: "10>10", - obj: klcv1beta1.Objective{ - KeptnMetricRef: klcv1beta1.KeptnMetricReference{ + obj: apilifecycle.Objective{ + KeptnMetricRef: apilifecycle.KeptnMetricReference{ Name: "testytest", Namespace: "default", }, EvaluationTarget: ">10", }, - item: &klcv1beta1.EvaluationStatusItem{ + item: &apilifecycle.EvaluationStatusItem{ Value: "10", Status: "all good", Message: "all good", @@ -109,14 +109,14 @@ func TestCheckValue(t *testing.T) { }, { name: "9>10", - obj: klcv1beta1.Objective{ - KeptnMetricRef: klcv1beta1.KeptnMetricReference{ + obj: apilifecycle.Objective{ + KeptnMetricRef: apilifecycle.KeptnMetricReference{ Name: "testytest", Namespace: "default", }, EvaluationTarget: ">10", }, - item: &klcv1beta1.EvaluationStatusItem{ + item: &apilifecycle.EvaluationStatusItem{ Value: "9", Status: "all good", Message: "all good", @@ -126,14 +126,14 @@ func TestCheckValue(t *testing.T) { }, { name: "11>10", - obj: klcv1beta1.Objective{ - KeptnMetricRef: klcv1beta1.KeptnMetricReference{ + obj: apilifecycle.Objective{ + KeptnMetricRef: apilifecycle.KeptnMetricReference{ Name: "testytest", Namespace: "default", }, EvaluationTarget: ">10", }, - item: &klcv1beta1.EvaluationStatusItem{ + item: &apilifecycle.EvaluationStatusItem{ Value: "11", Status: "all good", Message: "all good", @@ -143,14 +143,14 @@ func TestCheckValue(t *testing.T) { }, { name: "10<10", - obj: klcv1beta1.Objective{ - KeptnMetricRef: klcv1beta1.KeptnMetricReference{ + obj: apilifecycle.Objective{ + KeptnMetricRef: apilifecycle.KeptnMetricReference{ Name: "testytest", Namespace: "default", }, EvaluationTarget: "<10", }, - item: &klcv1beta1.EvaluationStatusItem{ + item: &apilifecycle.EvaluationStatusItem{ Value: "10", Status: "all good", Message: "all good", @@ -160,14 +160,14 @@ func TestCheckValue(t *testing.T) { }, { name: "9<10", - obj: klcv1beta1.Objective{ - KeptnMetricRef: klcv1beta1.KeptnMetricReference{ + obj: apilifecycle.Objective{ + KeptnMetricRef: apilifecycle.KeptnMetricReference{ Name: "testytest", Namespace: "default", }, EvaluationTarget: "<10", }, - item: &klcv1beta1.EvaluationStatusItem{ + item: &apilifecycle.EvaluationStatusItem{ Value: "9", Status: "all good", Message: "all good", @@ -177,14 +177,14 @@ func TestCheckValue(t *testing.T) { }, { name: "11<10", - obj: klcv1beta1.Objective{ - KeptnMetricRef: klcv1beta1.KeptnMetricReference{ + obj: apilifecycle.Objective{ + KeptnMetricRef: apilifecycle.KeptnMetricReference{ Name: "testytest", Namespace: "default", }, EvaluationTarget: "<10", }, - item: &klcv1beta1.EvaluationStatusItem{ + item: &apilifecycle.EvaluationStatusItem{ Value: "11", Status: "all good", Message: "all good", @@ -194,14 +194,14 @@ func TestCheckValue(t *testing.T) { }, { name: "invalid op", - obj: klcv1beta1.Objective{ - KeptnMetricRef: klcv1beta1.KeptnMetricReference{ + obj: apilifecycle.Objective{ + KeptnMetricRef: apilifecycle.KeptnMetricReference{ Name: "testytest", Namespace: "default", }, EvaluationTarget: "-10", }, - item: &klcv1beta1.EvaluationStatusItem{ + item: &apilifecycle.EvaluationStatusItem{ Value: "11", Status: "all good", Message: "all good", diff --git a/lifecycle-operator/controllers/lifecycle/keptnevaluation/controller.go b/lifecycle-operator/controllers/lifecycle/keptnevaluation/controller.go index e3940f8c90..2db013a5ea 100644 --- a/lifecycle-operator/controllers/lifecycle/keptnevaluation/controller.go +++ b/lifecycle-operator/controllers/lifecycle/keptnevaluation/controller.go @@ -22,8 +22,8 @@ import ( "time" "github.com/go-logr/logr" - klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" + apilifecycle "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1/common" controllercommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/eventsender" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/providers/keptnmetric" @@ -63,7 +63,7 @@ type KeptnEvaluationReconciler struct { func (r *KeptnEvaluationReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { requestInfo := controllercommon.GetRequestInfo(req) r.Log.Info("Reconciling KeptnEvaluation", "requestInfo", requestInfo) - evaluation := &klcv1beta1.KeptnEvaluation{} + evaluation := &apilifecycle.KeptnEvaluation{} if err := r.Client.Get(ctx, req.NamespacedName, evaluation); err != nil { if errors.IsNotFound(err) { @@ -112,7 +112,7 @@ func (r *KeptnEvaluationReconciler) Reconcile(ctx context.Context, req ctrl.Requ } -func (r *KeptnEvaluationReconciler) handleEvaluationIncomplete(ctx context.Context, evaluation *klcv1beta1.KeptnEvaluation) error { +func (r *KeptnEvaluationReconciler) handleEvaluationIncomplete(ctx context.Context, evaluation *apilifecycle.KeptnEvaluation) error { // Evaluation is uncompleted, update status anyway this avoids updating twice in case of completion err := r.Client.Status().Update(ctx, evaluation) if err != nil { @@ -124,7 +124,7 @@ func (r *KeptnEvaluationReconciler) handleEvaluationIncomplete(ctx context.Conte } -func (r *KeptnEvaluationReconciler) handleEvaluationExceededRetries(ctx context.Context, evaluation *klcv1beta1.KeptnEvaluation) { +func (r *KeptnEvaluationReconciler) handleEvaluationExceededRetries(ctx context.Context, evaluation *apilifecycle.KeptnEvaluation) { r.EventSender.Emit(apicommon.PhaseReconcileEvaluation, "Warning", evaluation, apicommon.PhaseStateReconcileTimeout, "retryCount exceeded", "") evaluation.Status.OverallStatus = apicommon.StateFailed err := r.updateFinishedEvaluationMetrics(ctx, evaluation) @@ -133,12 +133,12 @@ func (r *KeptnEvaluationReconciler) handleEvaluationExceededRetries(ctx context. } } -func (r *KeptnEvaluationReconciler) performEvaluation(ctx context.Context, evaluation *klcv1beta1.KeptnEvaluation, evaluationDefinition *klcv1beta1.KeptnEvaluationDefinition) *klcv1beta1.KeptnEvaluation { +func (r *KeptnEvaluationReconciler) performEvaluation(ctx context.Context, evaluation *apilifecycle.KeptnEvaluation, evaluationDefinition *apilifecycle.KeptnEvaluationDefinition) *apilifecycle.KeptnEvaluation { statusSummary := apicommon.StatusSummary{Total: len(evaluationDefinition.Spec.Objectives)} - newStatus := make(map[string]klcv1beta1.EvaluationStatusItem) + newStatus := make(map[string]apilifecycle.EvaluationStatusItem) if evaluation.Status.EvaluationStatus == nil { - evaluation.Status.EvaluationStatus = make(map[string]klcv1beta1.EvaluationStatusItem) + evaluation.Status.EvaluationStatus = make(map[string]apilifecycle.EvaluationStatusItem) } provider := &keptnmetric.KeptnMetricProvider{ @@ -161,7 +161,7 @@ func (r *KeptnEvaluationReconciler) performEvaluation(ctx context.Context, evalu return evaluation } -func (r *KeptnEvaluationReconciler) evaluateObjective(ctx context.Context, evaluation *klcv1beta1.KeptnEvaluation, statusSummary apicommon.StatusSummary, newStatus map[string]klcv1beta1.EvaluationStatusItem, objective klcv1beta1.Objective, provider *keptnmetric.KeptnMetricProvider) (map[string]klcv1beta1.EvaluationStatusItem, apicommon.StatusSummary) { +func (r *KeptnEvaluationReconciler) evaluateObjective(ctx context.Context, evaluation *apilifecycle.KeptnEvaluation, statusSummary apicommon.StatusSummary, newStatus map[string]apilifecycle.EvaluationStatusItem, objective apilifecycle.Objective, provider *keptnmetric.KeptnMetricProvider) (map[string]apilifecycle.EvaluationStatusItem, apicommon.StatusSummary) { if _, ok := evaluation.Status.EvaluationStatus[objective.KeptnMetricRef.Name]; !ok { evaluation.AddEvaluationStatus(objective) } @@ -171,7 +171,7 @@ func (r *KeptnEvaluationReconciler) evaluateObjective(ctx context.Context, evalu return newStatus, statusSummary } // resolving the SLI value - statusItem := &klcv1beta1.EvaluationStatusItem{ + statusItem := &apilifecycle.EvaluationStatusItem{ Status: apicommon.StateFailed, } @@ -200,13 +200,13 @@ func (r *KeptnEvaluationReconciler) evaluateObjective(ctx context.Context, evalu return updateStatusSummary(statusSummary, statusItem, newStatus, objective) } -func updateStatusSummary(statusSummary apicommon.StatusSummary, statusItem *klcv1beta1.EvaluationStatusItem, newStatus map[string]klcv1beta1.EvaluationStatusItem, objective klcv1beta1.Objective) (map[string]klcv1beta1.EvaluationStatusItem, apicommon.StatusSummary) { +func updateStatusSummary(statusSummary apicommon.StatusSummary, statusItem *apilifecycle.EvaluationStatusItem, newStatus map[string]apilifecycle.EvaluationStatusItem, objective apilifecycle.Objective) (map[string]apilifecycle.EvaluationStatusItem, apicommon.StatusSummary) { statusSummary = apicommon.UpdateStatusSummary(statusItem.Status, statusSummary) newStatus[objective.KeptnMetricRef.Name] = *statusItem return newStatus, statusSummary } -func (r *KeptnEvaluationReconciler) updateFinishedEvaluationMetrics(ctx context.Context, evaluation *klcv1beta1.KeptnEvaluation) error { +func (r *KeptnEvaluationReconciler) updateFinishedEvaluationMetrics(ctx context.Context, evaluation *apilifecycle.KeptnEvaluation) error { evaluation.SetEndTime() err := r.Client.Status().Update(ctx, evaluation) @@ -231,6 +231,6 @@ func (r *KeptnEvaluationReconciler) updateFinishedEvaluationMetrics(ctx context. // SetupWithManager sets up the controller with the Manager. func (r *KeptnEvaluationReconciler) SetupWithManager(mgr ctrl.Manager) error { return ctrl.NewControllerManagedBy(mgr). - For(&klcv1beta1.KeptnEvaluation{}, builder.WithPredicates(predicate.GenerationChangedPredicate{})). + For(&apilifecycle.KeptnEvaluation{}, builder.WithPredicates(predicate.GenerationChangedPredicate{})). Complete(r) } diff --git a/lifecycle-operator/controllers/lifecycle/keptnevaluation/controller_test.go b/lifecycle-operator/controllers/lifecycle/keptnevaluation/controller_test.go index ba0b74ba15..bfc3dfff2f 100644 --- a/lifecycle-operator/controllers/lifecycle/keptnevaluation/controller_test.go +++ b/lifecycle-operator/controllers/lifecycle/keptnevaluation/controller_test.go @@ -6,8 +6,8 @@ import ( "testing" "github.com/go-logr/logr" - klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" - "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" + apilifecycle "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1/common" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/config" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/eventsender" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/telemetry" @@ -37,35 +37,35 @@ func TestKeptnEvaluationReconciler_Reconcile_FailEvaluation(t *testing.T) { }, } - evaluationDefinition := &klcv1beta1.KeptnEvaluationDefinition{ + evaluationDefinition := &apilifecycle.KeptnEvaluationDefinition{ ObjectMeta: metav1.ObjectMeta{ Name: "my-definition", Namespace: namespace, }, - Spec: klcv1beta1.KeptnEvaluationDefinitionSpec{ - Objectives: []klcv1beta1.Objective{ + Spec: apilifecycle.KeptnEvaluationDefinitionSpec{ + Objectives: []apilifecycle.Objective{ { - KeptnMetricRef: klcv1beta1.KeptnMetricReference{ + KeptnMetricRef: apilifecycle.KeptnMetricReference{ Name: metric.Name, Namespace: namespace, }, EvaluationTarget: "<5", }, }, - FailureConditions: klcv1beta1.FailureConditions{ + FailureConditions: apilifecycle.FailureConditions{ Retries: 1, }, }, } - evaluation := &klcv1beta1.KeptnEvaluation{ + evaluation := &apilifecycle.KeptnEvaluation{ ObjectMeta: metav1.ObjectMeta{ Name: "my-evaluation", Namespace: namespace, }, - Spec: klcv1beta1.KeptnEvaluationSpec{ + Spec: apilifecycle.KeptnEvaluationSpec{ EvaluationDefinition: evaluationDefinition.Name, - FailureConditions: klcv1beta1.FailureConditions{ + FailureConditions: apilifecycle.FailureConditions{ Retries: 1, }, }, @@ -85,7 +85,7 @@ func TestKeptnEvaluationReconciler_Reconcile_FailEvaluation(t *testing.T) { require.Nil(t, err) require.True(t, reconcile.Requeue) - updatedEvaluation := &klcv1beta1.KeptnEvaluation{} + updatedEvaluation := &apilifecycle.KeptnEvaluation{} err = fakeClient.Get(context.TODO(), types.NamespacedName{ Namespace: namespace, Name: evaluation.Name, @@ -93,7 +93,7 @@ func TestKeptnEvaluationReconciler_Reconcile_FailEvaluation(t *testing.T) { require.Nil(t, err) - require.Equal(t, common.StateFailed, updatedEvaluation.Status.EvaluationStatus[metric.Name].Status) + require.Equal(t, apicommon.StateFailed, updatedEvaluation.Status.EvaluationStatus[metric.Name].Status) require.Equal(t, "value '10' did not meet objective '<5'", updatedEvaluation.Status.EvaluationStatus[metric.Name].Message) } @@ -111,35 +111,35 @@ func TestKeptnEvaluationReconciler_Reconcile_SucceedEvaluation(t *testing.T) { }, } - evaluationDefinition := &klcv1beta1.KeptnEvaluationDefinition{ + evaluationDefinition := &apilifecycle.KeptnEvaluationDefinition{ ObjectMeta: metav1.ObjectMeta{ Name: "my-definition", Namespace: namespace, }, - Spec: klcv1beta1.KeptnEvaluationDefinitionSpec{ - Objectives: []klcv1beta1.Objective{ + Spec: apilifecycle.KeptnEvaluationDefinitionSpec{ + Objectives: []apilifecycle.Objective{ { - KeptnMetricRef: klcv1beta1.KeptnMetricReference{ + KeptnMetricRef: apilifecycle.KeptnMetricReference{ Name: metric.Name, Namespace: namespace, }, EvaluationTarget: "<11", }, }, - FailureConditions: klcv1beta1.FailureConditions{ + FailureConditions: apilifecycle.FailureConditions{ Retries: 1, }, }, } - evaluation := &klcv1beta1.KeptnEvaluation{ + evaluation := &apilifecycle.KeptnEvaluation{ ObjectMeta: metav1.ObjectMeta{ Name: "my-evaluation", Namespace: namespace, }, - Spec: klcv1beta1.KeptnEvaluationSpec{ + Spec: apilifecycle.KeptnEvaluationSpec{ EvaluationDefinition: evaluationDefinition.Name, - FailureConditions: klcv1beta1.FailureConditions{ + FailureConditions: apilifecycle.FailureConditions{ Retries: 1, }, }, @@ -159,7 +159,7 @@ func TestKeptnEvaluationReconciler_Reconcile_SucceedEvaluation(t *testing.T) { require.Nil(t, err) require.False(t, reconcile.Requeue) - updatedEvaluation := &klcv1beta1.KeptnEvaluation{} + updatedEvaluation := &apilifecycle.KeptnEvaluation{} err = fakeClient.Get(context.TODO(), types.NamespacedName{ Namespace: namespace, Name: evaluation.Name, @@ -167,7 +167,7 @@ func TestKeptnEvaluationReconciler_Reconcile_SucceedEvaluation(t *testing.T) { require.Nil(t, err) - require.Equal(t, common.StateSucceeded, updatedEvaluation.Status.EvaluationStatus[metric.Name].Status) + require.Equal(t, apicommon.StateSucceeded, updatedEvaluation.Status.EvaluationStatus[metric.Name].Status) require.Equal(t, "value '10' met objective '<11'", updatedEvaluation.Status.EvaluationStatus[metric.Name].Message) } @@ -185,35 +185,35 @@ func TestKeptnEvaluationReconciler_Reconcile_SucceedEvaluation_withDefinitionInD }, } - evaluationDefinition := &klcv1beta1.KeptnEvaluationDefinition{ + evaluationDefinition := &apilifecycle.KeptnEvaluationDefinition{ ObjectMeta: metav1.ObjectMeta{ Name: "my-definition", Namespace: "keptn", }, - Spec: klcv1beta1.KeptnEvaluationDefinitionSpec{ - Objectives: []klcv1beta1.Objective{ + Spec: apilifecycle.KeptnEvaluationDefinitionSpec{ + Objectives: []apilifecycle.Objective{ { - KeptnMetricRef: klcv1beta1.KeptnMetricReference{ + KeptnMetricRef: apilifecycle.KeptnMetricReference{ Name: metric.Name, Namespace: namespace, }, EvaluationTarget: "<11", }, }, - FailureConditions: klcv1beta1.FailureConditions{ + FailureConditions: apilifecycle.FailureConditions{ Retries: 1, }, }, } - evaluation := &klcv1beta1.KeptnEvaluation{ + evaluation := &apilifecycle.KeptnEvaluation{ ObjectMeta: metav1.ObjectMeta{ Name: "my-evaluation", Namespace: namespace, }, - Spec: klcv1beta1.KeptnEvaluationSpec{ + Spec: apilifecycle.KeptnEvaluationSpec{ EvaluationDefinition: evaluationDefinition.Name, - FailureConditions: klcv1beta1.FailureConditions{ + FailureConditions: apilifecycle.FailureConditions{ Retries: 1, }, }, @@ -233,7 +233,7 @@ func TestKeptnEvaluationReconciler_Reconcile_SucceedEvaluation_withDefinitionInD require.Nil(t, err) require.False(t, reconcile.Requeue) - updatedEvaluation := &klcv1beta1.KeptnEvaluation{} + updatedEvaluation := &apilifecycle.KeptnEvaluation{} err = fakeClient.Get(context.TODO(), types.NamespacedName{ Namespace: namespace, Name: evaluation.Name, @@ -241,14 +241,14 @@ func TestKeptnEvaluationReconciler_Reconcile_SucceedEvaluation_withDefinitionInD require.Nil(t, err) - require.Equal(t, common.StateSucceeded, updatedEvaluation.Status.EvaluationStatus[metric.Name].Status) + require.Equal(t, apicommon.StateSucceeded, updatedEvaluation.Status.EvaluationStatus[metric.Name].Status) require.Equal(t, "value '10' met objective '<11'", updatedEvaluation.Status.EvaluationStatus[metric.Name].Message) } func setupReconcilerAndClient(t *testing.T, objects ...client.Object) (*KeptnEvaluationReconciler, client.Client) { scheme := runtime.NewScheme() - err := klcv1beta1.AddToScheme(scheme) + err := apilifecycle.AddToScheme(scheme) require.Nil(t, err) err = metricsapi.AddToScheme(scheme) diff --git a/lifecycle-operator/controllers/lifecycle/keptntask/container_builder.go b/lifecycle-operator/controllers/lifecycle/keptntask/container_builder.go index fc0be35da8..87c688b3cd 100644 --- a/lifecycle-operator/controllers/lifecycle/keptntask/container_builder.go +++ b/lifecycle-operator/controllers/lifecycle/keptntask/container_builder.go @@ -3,7 +3,7 @@ package keptntask import ( "encoding/json" - klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" + apilifecycle "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/taskdefinition" "github.com/pkg/errors" "golang.org/x/net/context" @@ -13,8 +13,8 @@ import ( // ContainerBuilder implements container builder interface for python type ContainerBuilder struct { - containerSpec klcv1beta1.ContainerSpec - taskSpec klcv1beta1.KeptnTaskSpec + containerSpec apilifecycle.ContainerSpec + taskSpec apilifecycle.KeptnTaskSpec } func NewContainerBuilder(options BuilderOptions) *ContainerBuilder { diff --git a/lifecycle-operator/controllers/lifecycle/keptntask/container_builder_test.go b/lifecycle-operator/controllers/lifecycle/keptntask/container_builder_test.go index 9c0336ba35..2d2d5a3f32 100644 --- a/lifecycle-operator/controllers/lifecycle/keptntask/container_builder_test.go +++ b/lifecycle-operator/controllers/lifecycle/keptntask/container_builder_test.go @@ -4,7 +4,7 @@ import ( "context" "testing" - "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" + apilifecycle "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1" "github.com/stretchr/testify/require" v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" @@ -20,7 +20,7 @@ func TestContainerBuilder_CreateContainerWithVolumes(t *testing.T) { { name: "defined, no task spec", builder: ContainerBuilder{ - containerSpec: v1beta1.ContainerSpec{ + containerSpec: apilifecycle.ContainerSpec{ Container: &v1.Container{ Image: "image", }, @@ -39,13 +39,13 @@ func TestContainerBuilder_CreateContainerWithVolumes(t *testing.T) { { name: "defined, adding context", builder: ContainerBuilder{ - containerSpec: v1beta1.ContainerSpec{ + containerSpec: apilifecycle.ContainerSpec{ Container: &v1.Container{ Image: "image", }, }, - taskSpec: v1beta1.KeptnTaskSpec{ - Context: v1beta1.TaskContext{ + taskSpec: apilifecycle.KeptnTaskSpec{ + Context: apilifecycle.TaskContext{ WorkloadName: "my-workload", }, }, @@ -63,7 +63,7 @@ func TestContainerBuilder_CreateContainerWithVolumes(t *testing.T) { { name: "defined, replacing context", builder: ContainerBuilder{ - containerSpec: v1beta1.ContainerSpec{ + containerSpec: apilifecycle.ContainerSpec{ Container: &v1.Container{ Image: "image", Env: []v1.EnvVar{ @@ -74,8 +74,8 @@ func TestContainerBuilder_CreateContainerWithVolumes(t *testing.T) { }, }, }, - taskSpec: v1beta1.KeptnTaskSpec{ - Context: v1beta1.TaskContext{ + taskSpec: apilifecycle.KeptnTaskSpec{ + Context: apilifecycle.TaskContext{ WorkloadName: "my-workload", }, }, @@ -93,7 +93,7 @@ func TestContainerBuilder_CreateContainerWithVolumes(t *testing.T) { { name: "nil", builder: ContainerBuilder{ - containerSpec: v1beta1.ContainerSpec{ + containerSpec: apilifecycle.ContainerSpec{ Container: nil, }, }, @@ -123,7 +123,7 @@ func TestContainerBuilder_CreateVolume(t *testing.T) { { name: "defined without volume", builder: ContainerBuilder{ - containerSpec: v1beta1.ContainerSpec{ + containerSpec: apilifecycle.ContainerSpec{ Container: &v1.Container{ Image: "image", }, @@ -134,7 +134,7 @@ func TestContainerBuilder_CreateVolume(t *testing.T) { { name: "defined with volume", builder: ContainerBuilder{ - containerSpec: v1beta1.ContainerSpec{ + containerSpec: apilifecycle.ContainerSpec{ Container: &v1.Container{ Image: "image", VolumeMounts: []v1.VolumeMount{ @@ -159,7 +159,7 @@ func TestContainerBuilder_CreateVolume(t *testing.T) { { name: "defined with volume and limits", builder: ContainerBuilder{ - containerSpec: v1beta1.ContainerSpec{ + containerSpec: apilifecycle.ContainerSpec{ Container: &v1.Container{ Image: "image", Resources: v1.ResourceRequirements{ @@ -198,12 +198,12 @@ func TestContainerBuilder_CreateVolume(t *testing.T) { func Test_GenerateVolumes(t *testing.T) { tests := []struct { name string - spec *v1beta1.ContainerSpec + spec *apilifecycle.ContainerSpec want *v1.Volume }{ { name: "defined", - spec: &v1beta1.ContainerSpec{ + spec: &apilifecycle.ContainerSpec{ Container: &v1.Container{ Image: "image", VolumeMounts: []v1.VolumeMount{ @@ -226,7 +226,7 @@ func Test_GenerateVolumes(t *testing.T) { }, { name: "empty", - spec: &v1beta1.ContainerSpec{}, + spec: &apilifecycle.ContainerSpec{}, want: nil, }, } @@ -243,12 +243,12 @@ func Test_GenerateVolumes(t *testing.T) { func Test_GetVolumeSource(t *testing.T) { tests := []struct { name string - spec *v1beta1.ContainerSpec + spec *apilifecycle.ContainerSpec want *v1.EmptyDirVolumeSource }{ { name: "not set limits", - spec: &v1beta1.ContainerSpec{ + spec: &apilifecycle.ContainerSpec{ Container: &v1.Container{ Image: "image", Resources: v1.ResourceRequirements{ @@ -263,7 +263,7 @@ func Test_GetVolumeSource(t *testing.T) { }, { name: "set limits", - spec: &v1beta1.ContainerSpec{ + spec: &apilifecycle.ContainerSpec{ Container: &v1.Container{ Image: "image", Resources: v1.ResourceRequirements{ diff --git a/lifecycle-operator/controllers/lifecycle/keptntask/controller.go b/lifecycle-operator/controllers/lifecycle/keptntask/controller.go index 7b34d16151..cbb7e4be06 100644 --- a/lifecycle-operator/controllers/lifecycle/keptntask/controller.go +++ b/lifecycle-operator/controllers/lifecycle/keptntask/controller.go @@ -21,8 +21,8 @@ import ( "time" "github.com/go-logr/logr" - klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" + apilifecycle "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1/common" controllercommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/eventsender" "go.opentelemetry.io/otel/metric" @@ -53,7 +53,7 @@ type KeptnTaskReconciler struct { func (r *KeptnTaskReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { requestInfo := controllercommon.GetRequestInfo(req) r.Log.Info("Reconciling KeptnTask", "requestInfo", requestInfo) - task := &klcv1beta1.KeptnTask{} + task := &apilifecycle.KeptnTask{} if err := r.Client.Get(ctx, req.NamespacedName, task); err != nil { if errors.IsNotFound(err) { @@ -118,6 +118,6 @@ func (r *KeptnTaskReconciler) Reconcile(ctx context.Context, req ctrl.Request) ( func (r *KeptnTaskReconciler) SetupWithManager(mgr ctrl.Manager) error { return ctrl.NewControllerManagedBy(mgr). // predicate disabling the auto reconciliation after updating the object status - For(&klcv1beta1.KeptnTask{}, builder.WithPredicates(predicate.GenerationChangedPredicate{})). + For(&apilifecycle.KeptnTask{}, builder.WithPredicates(predicate.GenerationChangedPredicate{})). Complete(r) } diff --git a/lifecycle-operator/controllers/lifecycle/keptntask/job_runner_builder.go b/lifecycle-operator/controllers/lifecycle/keptntask/job_runner_builder.go index ec30d8c5e8..e7842cfda4 100644 --- a/lifecycle-operator/controllers/lifecycle/keptntask/job_runner_builder.go +++ b/lifecycle-operator/controllers/lifecycle/keptntask/job_runner_builder.go @@ -2,7 +2,7 @@ package keptntask import ( "github.com/go-logr/logr" - klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" + apilifecycle "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/eventsender" "golang.org/x/net/context" corev1 "k8s.io/api/core/v1" @@ -23,9 +23,9 @@ type BuilderOptions struct { eventSender eventsender.IEvent req ctrl.Request Log logr.Logger - task *klcv1beta1.KeptnTask - containerSpec *klcv1beta1.ContainerSpec - funcSpec *klcv1beta1.RuntimeSpec + task *apilifecycle.KeptnTask + containerSpec *apilifecycle.ContainerSpec + funcSpec *apilifecycle.RuntimeSpec Image string MountPath string ConfigMap string diff --git a/lifecycle-operator/controllers/lifecycle/keptntask/job_runner_builder_test.go b/lifecycle-operator/controllers/lifecycle/keptntask/job_runner_builder_test.go index 1fc9eed257..894a1117fe 100644 --- a/lifecycle-operator/controllers/lifecycle/keptntask/job_runner_builder_test.go +++ b/lifecycle-operator/controllers/lifecycle/keptntask/job_runner_builder_test.go @@ -3,21 +3,21 @@ package keptntask import ( "testing" - "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" + apilifecycle "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1" "github.com/stretchr/testify/require" v1 "k8s.io/api/core/v1" ) func Test_getJobRunnerBuilder(t *testing.T) { runtimeBuilderOptions := BuilderOptions{ - funcSpec: &v1beta1.RuntimeSpec{ - Inline: v1beta1.Inline{ + funcSpec: &apilifecycle.RuntimeSpec{ + Inline: apilifecycle.Inline{ Code: "some code", }, }, } containerBuilderOptions := BuilderOptions{ - containerSpec: &v1beta1.ContainerSpec{ + containerSpec: &apilifecycle.ContainerSpec{ Container: &v1.Container{ Image: "image", }, diff --git a/lifecycle-operator/controllers/lifecycle/keptntask/job_utils.go b/lifecycle-operator/controllers/lifecycle/keptntask/job_utils.go index 87cb55d1e3..827595afa2 100644 --- a/lifecycle-operator/controllers/lifecycle/keptntask/job_utils.go +++ b/lifecycle-operator/controllers/lifecycle/keptntask/job_utils.go @@ -4,8 +4,8 @@ import ( "context" "fmt" - klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" + apilifecycle "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1/common" controllercommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common" taskdefinition "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/taskdefinition" controllererrors "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/errors" @@ -18,7 +18,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" ) -func (r *KeptnTaskReconciler) createJob(ctx context.Context, req ctrl.Request, task *klcv1beta1.KeptnTask) error { +func (r *KeptnTaskReconciler) createJob(ctx context.Context, req ctrl.Request, task *apilifecycle.KeptnTask) error { jobName := "" definition, err := controllercommon.GetTaskDefinition(r.Client, r.Log, ctx, task.Spec.TaskDefinition, req.Namespace) if err != nil { @@ -54,7 +54,7 @@ func (r *KeptnTaskReconciler) createJob(ctx context.Context, req ctrl.Request, t return nil } -func (r *KeptnTaskReconciler) createFunctionJob(ctx context.Context, req ctrl.Request, task *klcv1beta1.KeptnTask, definition *klcv1beta1.KeptnTaskDefinition) (string, error) { +func (r *KeptnTaskReconciler) createFunctionJob(ctx context.Context, req ctrl.Request, task *apilifecycle.KeptnTask, definition *apilifecycle.KeptnTaskDefinition) (string, error) { job, err := r.generateJob(ctx, task, definition, req) if err != nil { @@ -70,7 +70,7 @@ func (r *KeptnTaskReconciler) createFunctionJob(ctx context.Context, req ctrl.Re return job.Name, nil } -func (r *KeptnTaskReconciler) updateTaskStatus(job *batchv1.Job, task *klcv1beta1.KeptnTask) { +func (r *KeptnTaskReconciler) updateTaskStatus(job *batchv1.Job, task *apilifecycle.KeptnTask) { if len(job.Status.Conditions) > 0 { if job.Status.Conditions[0].Type == batchv1.JobComplete { task.Status.Status = apicommon.StateSucceeded @@ -91,7 +91,7 @@ func (r *KeptnTaskReconciler) getJob(ctx context.Context, jobName string, namesp return job, nil } -func (r *KeptnTaskReconciler) generateJob(ctx context.Context, task *klcv1beta1.KeptnTask, definition *klcv1beta1.KeptnTaskDefinition, request ctrl.Request) (*batchv1.Job, error) { +func (r *KeptnTaskReconciler) generateJob(ctx context.Context, task *apilifecycle.KeptnTask, definition *apilifecycle.KeptnTaskDefinition, request ctrl.Request) (*batchv1.Job, error) { job := &batchv1.Job{ ObjectMeta: metav1.ObjectMeta{ Name: apicommon.GenerateJobName(task.Name), diff --git a/lifecycle-operator/controllers/lifecycle/keptntask/job_utils_test.go b/lifecycle-operator/controllers/lifecycle/keptntask/job_utils_test.go index fafb0b17b4..b19b2af03b 100644 --- a/lifecycle-operator/controllers/lifecycle/keptntask/job_utils_test.go +++ b/lifecycle-operator/controllers/lifecycle/keptntask/job_utils_test.go @@ -4,8 +4,8 @@ import ( "context" "testing" - klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" + apilifecycle "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1/common" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/config" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/eventsender" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/testcommon" @@ -168,7 +168,7 @@ func TestKeptnTaskReconciler_updateTaskStatus(t *testing.T) { fakeClient := fake.NewClientBuilder().WithObjects(job).Build() - err := klcv1beta1.AddToScheme(fakeClient.Scheme()) + err := apilifecycle.AddToScheme(fakeClient.Scheme()) require.Nil(t, err) r := &KeptnTaskReconciler{ @@ -278,8 +278,8 @@ func makeJob(name, namespace string, status batchv1.JobStatus) *batchv1.Job { } } -func makeTask(name, namespace string, taskDefinitionName string) *klcv1beta1.KeptnTask { - return &klcv1beta1.KeptnTask{ +func makeTask(name, namespace string, taskDefinitionName string) *apilifecycle.KeptnTask { + return &apilifecycle.KeptnTask{ ObjectMeta: metav1.ObjectMeta{ Name: name, Namespace: namespace, @@ -290,8 +290,8 @@ func makeTask(name, namespace string, taskDefinitionName string) *klcv1beta1.Kep "annotation1": "annotation2", }, }, - Spec: klcv1beta1.KeptnTaskSpec{ - Context: klcv1beta1.TaskContext{ + Spec: apilifecycle.KeptnTaskSpec{ + Context: apilifecycle.TaskContext{ WorkloadName: "my-workload", AppName: "my-app", AppVersion: "0.1.0", @@ -304,8 +304,8 @@ func makeTask(name, namespace string, taskDefinitionName string) *klcv1beta1.Kep } } -func makeTaskDefinitionWithConfigmapRef(name, namespace, configMapName string) *klcv1beta1.KeptnTaskDefinition { - return &klcv1beta1.KeptnTaskDefinition{ +func makeTaskDefinitionWithConfigmapRef(name, namespace, configMapName string) *apilifecycle.KeptnTaskDefinition { + return &apilifecycle.KeptnTaskDefinition{ ObjectMeta: metav1.ObjectMeta{ Name: name, Namespace: namespace, @@ -316,13 +316,13 @@ func makeTaskDefinitionWithConfigmapRef(name, namespace, configMapName string) * "annotation1": "annotation2", }, }, - Spec: klcv1beta1.KeptnTaskDefinitionSpec{ - Deno: &klcv1beta1.RuntimeSpec{ - ConfigMapReference: klcv1beta1.ConfigMapReference{ + Spec: apilifecycle.KeptnTaskDefinitionSpec{ + Deno: &apilifecycle.RuntimeSpec{ + ConfigMapReference: apilifecycle.ConfigMapReference{ Name: configMapName, }, - Parameters: klcv1beta1.TaskParameters{Inline: map[string]string{"foo": "bar"}}, - SecureParameters: klcv1beta1.SecureParameters{Secret: "my-secret"}, + Parameters: apilifecycle.TaskParameters{Inline: map[string]string{"foo": "bar"}}, + SecureParameters: apilifecycle.SecureParameters{Secret: "my-secret"}, }, }, } @@ -340,8 +340,8 @@ func makeConfigMap(name, namespace string) *v1.ConfigMap { } } -func makeTaskDefinitionWithServiceAccount(name, namespace, serviceAccountName string, token *bool, ttlSeconds *int32, imagePullSecrets []v1.LocalObjectReference) *klcv1beta1.KeptnTaskDefinition { - return &klcv1beta1.KeptnTaskDefinition{ +func makeTaskDefinitionWithServiceAccount(name, namespace, serviceAccountName string, token *bool, ttlSeconds *int32, imagePullSecrets []v1.LocalObjectReference) *apilifecycle.KeptnTaskDefinition { + return &apilifecycle.KeptnTaskDefinition{ ObjectMeta: metav1.ObjectMeta{ Name: name, Namespace: namespace, @@ -352,15 +352,15 @@ func makeTaskDefinitionWithServiceAccount(name, namespace, serviceAccountName st "annotation1": "annotation2", }, }, - Spec: klcv1beta1.KeptnTaskDefinitionSpec{ - Container: &klcv1beta1.ContainerSpec{ + Spec: apilifecycle.KeptnTaskDefinitionSpec{ + Container: &apilifecycle.ContainerSpec{ Container: &v1.Container{}, }, ImagePullSecrets: imagePullSecrets, - ServiceAccount: &klcv1beta1.ServiceAccountSpec{ + ServiceAccount: &apilifecycle.ServiceAccountSpec{ Name: serviceAccountName, }, - AutomountServiceAccountToken: &klcv1beta1.AutomountServiceAccountTokenSpec{ + AutomountServiceAccountToken: &apilifecycle.AutomountServiceAccountTokenSpec{ Type: token, }, TTLSecondsAfterFinished: ttlSeconds, diff --git a/lifecycle-operator/controllers/lifecycle/keptntask/runtime_builder.go b/lifecycle-operator/controllers/lifecycle/keptntask/runtime_builder.go index a8048376a9..71494540f4 100644 --- a/lifecycle-operator/controllers/lifecycle/keptntask/runtime_builder.go +++ b/lifecycle-operator/controllers/lifecycle/keptntask/runtime_builder.go @@ -5,8 +5,8 @@ import ( "fmt" "dario.cat/mergo" - klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" + apilifecycle "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1/common" controllercommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/taskdefinition" controllererrors "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/errors" @@ -33,7 +33,7 @@ type RuntimeExecutionParams struct { SecureParameters string CmdParameters string URL string - Context klcv1beta1.TaskContext + Context apilifecycle.TaskContext Image string MountPath string } @@ -169,12 +169,12 @@ func (fb *RuntimeBuilder) getParams(ctx context.Context) (*RuntimeExecutionParam return ¶ms, nil } -func (fb *RuntimeBuilder) parseRuntimeTaskDefinition(spec *klcv1beta1.RuntimeSpec, name string, namespace string, configMap string) (RuntimeExecutionParams, bool, error) { +func (fb *RuntimeBuilder) parseRuntimeTaskDefinition(spec *apilifecycle.RuntimeSpec, name string, namespace string, configMap string) (RuntimeExecutionParams, bool, error) { params := RuntimeExecutionParams{} // Firstly check if this task definition has a parent object hasParent := false - if spec.FunctionReference != (klcv1beta1.FunctionReference{}) { + if spec.FunctionReference != (apilifecycle.FunctionReference{}) { hasParent = true } params.ConfigMap = configMap diff --git a/lifecycle-operator/controllers/lifecycle/keptntask/runtime_builder_test.go b/lifecycle-operator/controllers/lifecycle/keptntask/runtime_builder_test.go index 768652dc87..c5122feddb 100644 --- a/lifecycle-operator/controllers/lifecycle/keptntask/runtime_builder_test.go +++ b/lifecycle-operator/controllers/lifecycle/keptntask/runtime_builder_test.go @@ -4,8 +4,8 @@ import ( "testing" "github.com/go-logr/logr/testr" - klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" + apilifecycle "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1/common" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/eventsender" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/taskdefinition" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/testcommon" @@ -19,30 +19,30 @@ import ( func TestJSBuilder_handleParent(t *testing.T) { - def := &klcv1beta1.KeptnTaskDefinition{ + def := &apilifecycle.KeptnTaskDefinition{ ObjectMeta: metav1.ObjectMeta{ Name: "mytaskdef", Namespace: "default", }, - Spec: klcv1beta1.KeptnTaskDefinitionSpec{ - Deno: &klcv1beta1.RuntimeSpec{ - FunctionReference: klcv1beta1.FunctionReference{ + Spec: apilifecycle.KeptnTaskDefinitionSpec{ + Deno: &apilifecycle.RuntimeSpec{ + FunctionReference: apilifecycle.FunctionReference{ Name: "mytaskdef", }}}, } - paramDef := &klcv1beta1.KeptnTaskDefinition{ + paramDef := &apilifecycle.KeptnTaskDefinition{ ObjectMeta: metav1.ObjectMeta{ Name: "mytd", Namespace: "default", }, - Spec: klcv1beta1.KeptnTaskDefinitionSpec{ - Deno: &klcv1beta1.RuntimeSpec{ - FunctionReference: klcv1beta1.FunctionReference{ + Spec: apilifecycle.KeptnTaskDefinitionSpec{ + Deno: &apilifecycle.RuntimeSpec{ + FunctionReference: apilifecycle.FunctionReference{ Name: "mytd"}, - Parameters: klcv1beta1.TaskParameters{ + Parameters: apilifecycle.TaskParameters{ Inline: map[string]string{Data: "mydata"}, }, - SecureParameters: klcv1beta1.SecureParameters{ + SecureParameters: apilifecycle.SecureParameters{ Secret: "mysecret", }, }, @@ -123,74 +123,74 @@ func TestJSBuilder_getParams(t *testing.T) { t.Setenv(taskdefinition.FunctionRuntimeImageKey, taskdefinition.FunctionScriptKey) t.Setenv(taskdefinition.PythonRuntimeImageKey, taskdefinition.PythonScriptKey) - def := &klcv1beta1.KeptnTaskDefinition{ + def := &apilifecycle.KeptnTaskDefinition{ ObjectMeta: metav1.ObjectMeta{ Name: "mytaskdef", Namespace: "default", }, - Spec: klcv1beta1.KeptnTaskDefinitionSpec{ - Deno: &klcv1beta1.RuntimeSpec{ - Parameters: klcv1beta1.TaskParameters{ + Spec: apilifecycle.KeptnTaskDefinitionSpec{ + Deno: &apilifecycle.RuntimeSpec{ + Parameters: apilifecycle.TaskParameters{ Inline: map[string]string{"DATA2": "parent_data"}, }, - SecureParameters: klcv1beta1.SecureParameters{ + SecureParameters: apilifecycle.SecureParameters{ Secret: "parent_secret", }, }, }, - Status: klcv1beta1.KeptnTaskDefinitionStatus{ - Function: klcv1beta1.FunctionStatus{ + Status: apilifecycle.KeptnTaskDefinitionStatus{ + Function: apilifecycle.FunctionStatus{ ConfigMap: "mymap", }, }, } - paramDef := &klcv1beta1.KeptnTaskDefinition{ + paramDef := &apilifecycle.KeptnTaskDefinition{ ObjectMeta: metav1.ObjectMeta{ Name: "mytd", Namespace: "default", }, - Spec: klcv1beta1.KeptnTaskDefinitionSpec{ - Deno: &klcv1beta1.RuntimeSpec{ - FunctionReference: klcv1beta1.FunctionReference{ + Spec: apilifecycle.KeptnTaskDefinitionSpec{ + Deno: &apilifecycle.RuntimeSpec{ + FunctionReference: apilifecycle.FunctionReference{ Name: def.Name}, - Parameters: klcv1beta1.TaskParameters{ + Parameters: apilifecycle.TaskParameters{ Inline: map[string]string{"DATA1": "child_data"}, }, - SecureParameters: klcv1beta1.SecureParameters{ + SecureParameters: apilifecycle.SecureParameters{ Secret: "child_pw", }, }, }, - Status: klcv1beta1.KeptnTaskDefinitionStatus{ - Function: klcv1beta1.FunctionStatus{ + Status: apilifecycle.KeptnTaskDefinitionStatus{ + Function: apilifecycle.FunctionStatus{ ConfigMap: "mychildmap", }, }, } - parentPy := &klcv1beta1.KeptnTaskDefinition{ + parentPy := &apilifecycle.KeptnTaskDefinition{ ObjectMeta: metav1.ObjectMeta{ Name: "parentPy", Namespace: "default", }, - Spec: klcv1beta1.KeptnTaskDefinitionSpec{ - Python: &klcv1beta1.RuntimeSpec{ - HttpReference: klcv1beta1.HttpReference{Url: "donothing"}, + Spec: apilifecycle.KeptnTaskDefinitionSpec{ + Python: &apilifecycle.RuntimeSpec{ + HttpReference: apilifecycle.HttpReference{Url: "donothing"}, }}, } - defJS := &klcv1beta1.KeptnTaskDefinition{ + defJS := &apilifecycle.KeptnTaskDefinition{ ObjectMeta: metav1.ObjectMeta{ Name: "myJS", Namespace: "default", }, - Spec: klcv1beta1.KeptnTaskDefinitionSpec{ - Deno: &klcv1beta1.RuntimeSpec{ - FunctionReference: klcv1beta1.FunctionReference{ + Spec: apilifecycle.KeptnTaskDefinitionSpec{ + Deno: &apilifecycle.RuntimeSpec{ + FunctionReference: apilifecycle.FunctionReference{ Name: parentPy.Name}, }, }, - Status: klcv1beta1.KeptnTaskDefinitionStatus{ - Function: klcv1beta1.FunctionStatus{ + Status: apilifecycle.KeptnTaskDefinitionStatus{ + Function: apilifecycle.FunctionStatus{ ConfigMap: "myJSChildmap", }, }, @@ -223,7 +223,7 @@ func TestJSBuilder_getParams(t *testing.T) { Parameters: def.Spec.Deno.Parameters.Inline, SecureParameters: def.Spec.Deno.SecureParameters.Secret, URL: def.Spec.Deno.HttpReference.Url, - Context: klcv1beta1.TaskContext{ + Context: apilifecycle.TaskContext{ WorkloadName: "my-workload", AppName: "my-app", AppVersion: "0.1.0", @@ -256,7 +256,7 @@ func TestJSBuilder_getParams(t *testing.T) { }, SecureParameters: paramDef.Spec.Deno.SecureParameters.Secret, // uses child URL: def.Spec.Deno.HttpReference.Url, // uses parent - Context: klcv1beta1.TaskContext{ + Context: apilifecycle.TaskContext{ WorkloadName: "my-workload", AppName: "my-app", AppVersion: "0.1.0", @@ -284,7 +284,7 @@ func TestJSBuilder_getParams(t *testing.T) { params: &RuntimeExecutionParams{ ConfigMap: parentPy.Status.Function.ConfigMap, URL: parentPy.Spec.Python.HttpReference.Url, // we support a single URL so the original should be taken not the parent one - Context: klcv1beta1.TaskContext{ + Context: apilifecycle.TaskContext{ WorkloadName: "my-workload", AppName: "my-app", AppVersion: "0.1.0", diff --git a/lifecycle-operator/controllers/lifecycle/keptntaskdefinition/controller.go b/lifecycle-operator/controllers/lifecycle/keptntaskdefinition/controller.go index 5482548c23..bf5209d9b9 100644 --- a/lifecycle-operator/controllers/lifecycle/keptntaskdefinition/controller.go +++ b/lifecycle-operator/controllers/lifecycle/keptntaskdefinition/controller.go @@ -21,7 +21,7 @@ import ( "time" "github.com/go-logr/logr" - klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" + apilifecycle "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1" controllercommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/eventsender" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/taskdefinition" @@ -49,7 +49,7 @@ func (r *KeptnTaskDefinitionReconciler) Reconcile(ctx context.Context, req ctrl. requestInfo := controllercommon.GetRequestInfo(req) r.Log.Info("Reconciling KeptnTaskDefinition", "requestInfo", requestInfo) - definition := &klcv1beta1.KeptnTaskDefinition{} + definition := &apilifecycle.KeptnTaskDefinition{} if err := r.Client.Get(ctx, req.NamespacedName, definition); err != nil { if errors.IsNotFound(err) { @@ -99,7 +99,7 @@ func (r *KeptnTaskDefinitionReconciler) Reconcile(ctx context.Context, req ctrl. // SetupWithManager sets up the controller with the Manager. func (r *KeptnTaskDefinitionReconciler) SetupWithManager(mgr ctrl.Manager) error { return ctrl.NewControllerManagedBy(mgr). - For(&klcv1beta1.KeptnTaskDefinition{}). + For(&apilifecycle.KeptnTaskDefinition{}). Owns(&corev1.ConfigMap{}). Complete(r) } diff --git a/lifecycle-operator/controllers/lifecycle/keptntaskdefinition/reconcile_function.go b/lifecycle-operator/controllers/lifecycle/keptntaskdefinition/reconcile_function.go index fa87aa8b5c..3f2ec7c7b4 100644 --- a/lifecycle-operator/controllers/lifecycle/keptntaskdefinition/reconcile_function.go +++ b/lifecycle-operator/controllers/lifecycle/keptntaskdefinition/reconcile_function.go @@ -4,15 +4,15 @@ import ( "context" "reflect" - klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" + apilifecycle "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1/common" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" ) -func (r *KeptnTaskDefinitionReconciler) generateConfigMap(spec *klcv1beta1.RuntimeSpec, name string, namespace string) *corev1.ConfigMap { +func (r *KeptnTaskDefinitionReconciler) generateConfigMap(spec *apilifecycle.RuntimeSpec, name string, namespace string) *corev1.ConfigMap { functionCm := &corev1.ConfigMap{ ObjectMeta: metav1.ObjectMeta{ @@ -56,7 +56,7 @@ func (r *KeptnTaskDefinitionReconciler) getConfigMap(ctx context.Context, cmName return cm, nil } -func (r *KeptnTaskDefinitionReconciler) updateTaskDefinitionStatus(functionCm *corev1.ConfigMap, definition *klcv1beta1.KeptnTaskDefinition) { +func (r *KeptnTaskDefinitionReconciler) updateTaskDefinitionStatus(functionCm *corev1.ConfigMap, definition *apilifecycle.KeptnTaskDefinition) { // config map referenced but does not exist we can use the status to signify that if functionCm != nil && definition.Status.Function.ConfigMap != functionCm.Name { // configmap referenced exists but old definition.Status.Function.ConfigMap = functionCm.Name diff --git a/lifecycle-operator/controllers/lifecycle/keptnworkload/controller.go b/lifecycle-operator/controllers/lifecycle/keptnworkload/controller.go index 6f167300c8..881304e148 100644 --- a/lifecycle-operator/controllers/lifecycle/keptnworkload/controller.go +++ b/lifecycle-operator/controllers/lifecycle/keptnworkload/controller.go @@ -23,8 +23,8 @@ import ( "time" "github.com/go-logr/logr" - klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" - "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" + apilifecycle "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1/common" operatorcommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/common" controllercommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/eventsender" @@ -73,7 +73,7 @@ func (r *KeptnWorkloadReconciler) Reconcile(ctx context.Context, req ctrl.Reques requestInfo := controllercommon.GetRequestInfo(req) r.Log.Info("Searching for workload", "requestInfo", requestInfo) - workload := &klcv1beta1.KeptnWorkload{} + workload := &apilifecycle.KeptnWorkload{} err := r.Get(ctx, req.NamespacedName, workload) if errors.IsNotFound(err) { return reconcile.Result{}, nil @@ -87,8 +87,8 @@ func (r *KeptnWorkloadReconciler) Reconcile(ctx context.Context, req ctrl.Reques r.Log.Info("Reconciling Keptn Workload", "workload", workload.Name, "requestInfo", requestInfo) - workloadVersion := &klcv1beta1.KeptnWorkloadVersion{} - workloadVersionName := operatorcommon.CreateResourceName(common.MaxK8sObjectLength, common.MinKeptnNameLen, workload.Name, workload.Spec.Version) + workloadVersion := &apilifecycle.KeptnWorkloadVersion{} + workloadVersionName := operatorcommon.CreateResourceName(apicommon.MaxK8sObjectLength, apicommon.MinKeptnNameLen, workload.Name, workload.Spec.Version) // Try to find the workload instance err = r.Get(ctx, types.NamespacedName{Namespace: workload.Namespace, Name: workloadVersionName}, workloadVersion) @@ -105,7 +105,7 @@ func (r *KeptnWorkloadReconciler) Reconcile(ctx context.Context, req ctrl.Reques err = r.Client.Create(ctx, workloadVersion) if err != nil { r.Log.Error(err, "could not create WorkloadVersion", "requestInfo", requestInfo) - r.EventSender.Emit(common.PhaseCreateWorkloadVersion, "Warning", workloadVersion, common.PhaseStateFailed, "could not create KeptnWorkloadVersion ", workloadVersion.Spec.Version) + r.EventSender.Emit(apicommon.PhaseCreateWorkloadVersion, "Warning", workloadVersion, apicommon.PhaseStateFailed, "could not create KeptnWorkloadVersion ", workloadVersion.Spec.Version) return ctrl.Result{RequeueAfter: 10 * time.Second}, err } workload.Status.CurrentVersion = workload.Spec.Version @@ -129,18 +129,18 @@ func (r *KeptnWorkloadReconciler) Reconcile(ctx context.Context, req ctrl.Reques // SetupWithManager sets up the controller with the Manager. func (r *KeptnWorkloadReconciler) SetupWithManager(mgr ctrl.Manager) error { - if err := mgr.GetFieldIndexer().IndexField(context.Background(), &klcv1beta1.KeptnWorkload{}, "spec.app", func(rawObj client.Object) []string { - workload := rawObj.(*klcv1beta1.KeptnWorkload) + if err := mgr.GetFieldIndexer().IndexField(context.Background(), &apilifecycle.KeptnWorkload{}, "spec.app", func(rawObj client.Object) []string { + workload := rawObj.(*apilifecycle.KeptnWorkload) return []string{workload.Spec.AppName} }); err != nil { return err } return ctrl.NewControllerManagedBy(mgr). - For(&klcv1beta1.KeptnWorkload{}, builder.WithPredicates(predicate.GenerationChangedPredicate{})). + For(&apilifecycle.KeptnWorkload{}, builder.WithPredicates(predicate.GenerationChangedPredicate{})). Complete(r) } -func (r *KeptnWorkloadReconciler) createWorkloadVersion(ctx context.Context, workload *klcv1beta1.KeptnWorkload) (*klcv1beta1.KeptnWorkloadVersion, error) { +func (r *KeptnWorkloadReconciler) createWorkloadVersion(ctx context.Context, workload *apilifecycle.KeptnWorkload) (*apilifecycle.KeptnWorkloadVersion, error) { // create TraceContext // follow up with a Keptn propagator that JSON-encoded the OTel map into our own key traceContextCarrier := propagation.MapCarrier{} @@ -161,14 +161,14 @@ func (r *KeptnWorkloadReconciler) createWorkloadVersion(ctx context.Context, wor return &workloadVersion, err } -func generateWorkloadVersion(previousVersion string, traceContextCarrier map[string]string, w *klcv1beta1.KeptnWorkload) klcv1beta1.KeptnWorkloadVersion { - return klcv1beta1.KeptnWorkloadVersion{ +func generateWorkloadVersion(previousVersion string, traceContextCarrier map[string]string, w *apilifecycle.KeptnWorkload) apilifecycle.KeptnWorkloadVersion { + return apilifecycle.KeptnWorkloadVersion{ ObjectMeta: metav1.ObjectMeta{ Annotations: traceContextCarrier, - Name: operatorcommon.CreateResourceName(common.MaxK8sObjectLength, common.MinKeptnNameLen, w.Name, w.Spec.Version), + Name: operatorcommon.CreateResourceName(apicommon.MaxK8sObjectLength, apicommon.MinKeptnNameLen, w.Name, w.Spec.Version), Namespace: w.Namespace, }, - Spec: klcv1beta1.KeptnWorkloadVersionSpec{ + Spec: apilifecycle.KeptnWorkloadVersionSpec{ KeptnWorkloadSpec: w.Spec, WorkloadName: w.Name, PreviousVersion: previousVersion, diff --git a/lifecycle-operator/controllers/lifecycle/keptnworkload/controller_test.go b/lifecycle-operator/controllers/lifecycle/keptnworkload/controller_test.go index 84dd2faa02..84f9ced50e 100644 --- a/lifecycle-operator/controllers/lifecycle/keptnworkload/controller_test.go +++ b/lifecycle-operator/controllers/lifecycle/keptnworkload/controller_test.go @@ -6,7 +6,7 @@ import ( "testing" "time" - klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" + apilifecycle "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/eventsender" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/testcommon" "github.com/stretchr/testify/require" @@ -23,15 +23,15 @@ import ( func TestKeptnWorkloadReconciler_CannotLookupWorkloadVersion(t *testing.T) { - workload := &klcv1beta1.KeptnWorkload{ + workload := &apilifecycle.KeptnWorkload{ ObjectMeta: metav1.ObjectMeta{ Name: "my-workload", Namespace: "my-namespace", }, - Spec: klcv1beta1.KeptnWorkloadSpec{ + Spec: apilifecycle.KeptnWorkloadSpec{ AppName: "my-app", Version: "v1", - ResourceReference: klcv1beta1.ResourceReference{ + ResourceReference: apilifecycle.ResourceReference{ UID: "id1", Kind: "ReplicaSet", Name: "my-replica-set", @@ -64,15 +64,15 @@ func TestKeptnWorkloadReconciler_CannotLookupWorkloadVersion(t *testing.T) { func TestKeptnWorkloadReconciler_CreateWorkloadVersion(t *testing.T) { - workload := &klcv1beta1.KeptnWorkload{ + workload := &apilifecycle.KeptnWorkload{ ObjectMeta: metav1.ObjectMeta{ Name: "my-workload", Namespace: "my-namespace", }, - Spec: klcv1beta1.KeptnWorkloadSpec{ + Spec: apilifecycle.KeptnWorkloadSpec{ AppName: "my-app", Version: "v1", - ResourceReference: klcv1beta1.ResourceReference{ + ResourceReference: apilifecycle.ResourceReference{ UID: "id1", Kind: "ReplicaSet", Name: "my-replica-set", @@ -80,12 +80,12 @@ func TestKeptnWorkloadReconciler_CreateWorkloadVersion(t *testing.T) { }, } - expectedWorkloadVersion := &klcv1beta1.KeptnWorkloadVersion{ + expectedWorkloadVersion := &apilifecycle.KeptnWorkloadVersion{ ObjectMeta: metav1.ObjectMeta{ Name: "my-workload-v1", Namespace: "my-namespace", }, - Spec: klcv1beta1.KeptnWorkloadVersionSpec{ + Spec: apilifecycle.KeptnWorkloadVersionSpec{ KeptnWorkloadSpec: workload.Spec, WorkloadName: "my-workload", }, @@ -102,7 +102,7 @@ func TestKeptnWorkloadReconciler_CreateWorkloadVersion(t *testing.T) { require.Nil(t, err) require.False(t, res.Requeue) - createdWorkloadVersion := &klcv1beta1.KeptnWorkloadVersion{} + createdWorkloadVersion := &apilifecycle.KeptnWorkloadVersion{} err = r.Client.Get(context.TODO(), types.NamespacedName{ Namespace: expectedWorkloadVersion.Namespace, @@ -116,15 +116,15 @@ func TestKeptnWorkloadReconciler_CreateWorkloadVersion(t *testing.T) { func TestKeptnWorkloadReconciler_CreateWorkloadVersionErrorWhenCreating(t *testing.T) { - workload := &klcv1beta1.KeptnWorkload{ + workload := &apilifecycle.KeptnWorkload{ ObjectMeta: metav1.ObjectMeta{ Name: "my-workload", Namespace: "my-namespace", }, - Spec: klcv1beta1.KeptnWorkloadSpec{ + Spec: apilifecycle.KeptnWorkloadSpec{ AppName: "my-app", Version: "v1", - ResourceReference: klcv1beta1.ResourceReference{ + ResourceReference: apilifecycle.ResourceReference{ UID: "id1", Kind: "ReplicaSet", Name: "my-replica-set", @@ -155,15 +155,15 @@ func TestKeptnWorkloadReconciler_CreateWorkloadVersionErrorWhenCreating(t *testi func TestKeptnWorkloadReconciler_UpdateExistingWorkloadVersion(t *testing.T) { - workload := &klcv1beta1.KeptnWorkload{ + workload := &apilifecycle.KeptnWorkload{ ObjectMeta: metav1.ObjectMeta{ Name: "my-workload", Namespace: "my-namespace", }, - Spec: klcv1beta1.KeptnWorkloadSpec{ + Spec: apilifecycle.KeptnWorkloadSpec{ AppName: "my-app", Version: "v1", - ResourceReference: klcv1beta1.ResourceReference{ + ResourceReference: apilifecycle.ResourceReference{ UID: "id1", Kind: "ReplicaSet", Name: "my-replica-set", @@ -171,16 +171,16 @@ func TestKeptnWorkloadReconciler_UpdateExistingWorkloadVersion(t *testing.T) { }, } - workloadVersion := &klcv1beta1.KeptnWorkloadVersion{ + workloadVersion := &apilifecycle.KeptnWorkloadVersion{ ObjectMeta: metav1.ObjectMeta{ Name: "my-workload-v1", Namespace: "my-namespace", }, - Spec: klcv1beta1.KeptnWorkloadVersionSpec{ - KeptnWorkloadSpec: klcv1beta1.KeptnWorkloadSpec{ + Spec: apilifecycle.KeptnWorkloadVersionSpec{ + KeptnWorkloadSpec: apilifecycle.KeptnWorkloadSpec{ AppName: "my-app", Version: "v1", - ResourceReference: klcv1beta1.ResourceReference{ + ResourceReference: apilifecycle.ResourceReference{ UID: "id2", Kind: "ReplicaSet", Name: "another-replica-set", @@ -200,7 +200,7 @@ func TestKeptnWorkloadReconciler_UpdateExistingWorkloadVersion(t *testing.T) { require.Nil(t, err) require.False(t, res.Requeue) - updatedWorkloadVersion := &klcv1beta1.KeptnWorkloadVersion{} + updatedWorkloadVersion := &apilifecycle.KeptnWorkloadVersion{} err = r.Client.Get(context.TODO(), types.NamespacedName{ Namespace: workloadVersion.Namespace, @@ -214,15 +214,15 @@ func TestKeptnWorkloadReconciler_UpdateExistingWorkloadVersion(t *testing.T) { func TestKeptnWorkloadReconciler_UpdateExistingWorkloadVersionUpdateFails(t *testing.T) { - workload := &klcv1beta1.KeptnWorkload{ + workload := &apilifecycle.KeptnWorkload{ ObjectMeta: metav1.ObjectMeta{ Name: "my-workload", Namespace: "my-namespace", }, - Spec: klcv1beta1.KeptnWorkloadSpec{ + Spec: apilifecycle.KeptnWorkloadSpec{ AppName: "my-app", Version: "v1", - ResourceReference: klcv1beta1.ResourceReference{ + ResourceReference: apilifecycle.ResourceReference{ UID: "id1", Kind: "ReplicaSet", Name: "my-replica-set", @@ -230,16 +230,16 @@ func TestKeptnWorkloadReconciler_UpdateExistingWorkloadVersionUpdateFails(t *tes }, } - workloadVersion := &klcv1beta1.KeptnWorkloadVersion{ + workloadVersion := &apilifecycle.KeptnWorkloadVersion{ ObjectMeta: metav1.ObjectMeta{ Name: "my-workload-v1", Namespace: "my-namespace", }, - Spec: klcv1beta1.KeptnWorkloadVersionSpec{ - KeptnWorkloadSpec: klcv1beta1.KeptnWorkloadSpec{ + Spec: apilifecycle.KeptnWorkloadVersionSpec{ + KeptnWorkloadSpec: apilifecycle.KeptnWorkloadSpec{ AppName: "my-app", Version: "v1", - ResourceReference: klcv1beta1.ResourceReference{ + ResourceReference: apilifecycle.ResourceReference{ UID: "id2", Kind: "ReplicaSet", Name: "another-replica-set", @@ -268,12 +268,12 @@ func TestKeptnWorkloadReconciler_UpdateExistingWorkloadVersionUpdateFails(t *tes } func TestKeptnWorkload(t *testing.T) { - workload := &klcv1beta1.KeptnWorkload{ + workload := &apilifecycle.KeptnWorkload{ ObjectMeta: metav1.ObjectMeta{ Name: "workload", Namespace: "namespace", }, - Spec: klcv1beta1.KeptnWorkloadSpec{ + Spec: apilifecycle.KeptnWorkloadSpec{ Version: "version", AppName: "app", Metadata: map[string]string{ @@ -283,14 +283,14 @@ func TestKeptnWorkload(t *testing.T) { } workloadVersion := generateWorkloadVersion("prev", map[string]string{}, workload) - require.Equal(t, klcv1beta1.KeptnWorkloadVersion{ + require.Equal(t, apilifecycle.KeptnWorkloadVersion{ ObjectMeta: metav1.ObjectMeta{ Annotations: map[string]string{}, Name: "workload-version", Namespace: "namespace", }, - Spec: klcv1beta1.KeptnWorkloadVersionSpec{ - KeptnWorkloadSpec: klcv1beta1.KeptnWorkloadSpec{ + Spec: apilifecycle.KeptnWorkloadVersionSpec{ + KeptnWorkloadSpec: apilifecycle.KeptnWorkloadSpec{ Version: "version", AppName: "app", Metadata: map[string]string{ diff --git a/lifecycle-operator/controllers/lifecycle/keptnworkloadversion/controller.go b/lifecycle-operator/controllers/lifecycle/keptnworkloadversion/controller.go index aabb8074f7..bdce05c281 100644 --- a/lifecycle-operator/controllers/lifecycle/keptnworkloadversion/controller.go +++ b/lifecycle-operator/controllers/lifecycle/keptnworkloadversion/controller.go @@ -23,8 +23,8 @@ import ( "time" "github.com/go-logr/logr" - klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" + apilifecycle "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1/common" controllercommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/config" keptncontext "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/context" @@ -89,7 +89,7 @@ func (r *KeptnWorkloadVersionReconciler) Reconcile(ctx context.Context, req ctrl r.Log.Info("Searching for KeptnWorkloadVersion", "requestInfo", requestInfo) // retrieve workload version - workloadVersion := &klcv1beta1.KeptnWorkloadVersion{} + workloadVersion := &apilifecycle.KeptnWorkloadVersion{} err := r.Get(ctx, req.NamespacedName, workloadVersion) if errors.IsNotFound(err) { return reconcile.Result{}, nil @@ -121,7 +121,7 @@ func (r *KeptnWorkloadVersionReconciler) Reconcile(ctx context.Context, req ctrl r.Log.Error(err, "could not get span") } - defer func(workloadVersion *klcv1beta1.KeptnWorkloadVersion, spanWorkloadTrace trace.Span) { + defer func(workloadVersion *apilifecycle.KeptnWorkloadVersion, spanWorkloadTrace trace.Span) { r.closeFailedWorkloadVersionSpan(workloadVersion, spanWorkloadTrace) }(workloadVersion, spanWorkloadTrace) @@ -158,7 +158,7 @@ func (r *KeptnWorkloadVersionReconciler) Reconcile(ctx context.Context, req ctrl return r.finishKeptnWorkloadVersionReconcile(ctx, workloadVersion, spanWorkloadTrace) } -func (r *KeptnWorkloadVersionReconciler) doPreDeploymentTaskPhase(ctx context.Context, workloadVersion *klcv1beta1.KeptnWorkloadVersion, ctxWorkloadTrace context.Context) (phase.PhaseResult, error) { +func (r *KeptnWorkloadVersionReconciler) doPreDeploymentTaskPhase(ctx context.Context, workloadVersion *apilifecycle.KeptnWorkloadVersion, ctxWorkloadTrace context.Context) (phase.PhaseResult, error) { if !workloadVersion.IsPreDeploymentSucceeded(r.Config.GetBlockDeployment()) { reconcilePre := func(phaseCtx context.Context) (apicommon.KeptnState, error) { return r.reconcilePrePostDeployment(ctx, phaseCtx, workloadVersion, apicommon.PreDeploymentCheckType) @@ -176,7 +176,7 @@ func (r *KeptnWorkloadVersionReconciler) doPreDeploymentTaskPhase(ctx context.Co }, nil } -func (r *KeptnWorkloadVersionReconciler) doPreDeploymentEvaluationPhase(ctx context.Context, workloadVersion *klcv1beta1.KeptnWorkloadVersion, ctxWorkloadTrace context.Context) (phase.PhaseResult, error) { +func (r *KeptnWorkloadVersionReconciler) doPreDeploymentEvaluationPhase(ctx context.Context, workloadVersion *apilifecycle.KeptnWorkloadVersion, ctxWorkloadTrace context.Context) (phase.PhaseResult, error) { if !workloadVersion.IsPreDeploymentEvaluationSucceeded(r.Config.GetBlockDeployment()) { reconcilePreEval := func(phaseCtx context.Context) (apicommon.KeptnState, error) { return r.reconcilePrePostEvaluation(ctx, phaseCtx, workloadVersion, apicommon.PreDeploymentEvaluationCheckType) @@ -194,7 +194,7 @@ func (r *KeptnWorkloadVersionReconciler) doPreDeploymentEvaluationPhase(ctx cont }, nil } -func (r *KeptnWorkloadVersionReconciler) doDeploymentPhase(ctx context.Context, workloadVersion *klcv1beta1.KeptnWorkloadVersion, ctxWorkloadTrace context.Context) (phase.PhaseResult, error) { +func (r *KeptnWorkloadVersionReconciler) doDeploymentPhase(ctx context.Context, workloadVersion *apilifecycle.KeptnWorkloadVersion, ctxWorkloadTrace context.Context) (phase.PhaseResult, error) { if !workloadVersion.IsDeploymentSucceeded() { reconcileWorkloadVersion := func(phaseCtx context.Context) (apicommon.KeptnState, error) { return r.reconcileDeployment(ctx, workloadVersion) @@ -212,7 +212,7 @@ func (r *KeptnWorkloadVersionReconciler) doDeploymentPhase(ctx context.Context, }, nil } -func (r *KeptnWorkloadVersionReconciler) doPostDeploymentTaskPhase(ctx context.Context, workloadVersion *klcv1beta1.KeptnWorkloadVersion, ctxWorkloadTrace context.Context) (phase.PhaseResult, error) { +func (r *KeptnWorkloadVersionReconciler) doPostDeploymentTaskPhase(ctx context.Context, workloadVersion *apilifecycle.KeptnWorkloadVersion, ctxWorkloadTrace context.Context) (phase.PhaseResult, error) { if !workloadVersion.IsPostDeploymentSucceeded(r.Config.GetBlockDeployment()) { reconcilePost := func(phaseCtx context.Context) (apicommon.KeptnState, error) { return r.reconcilePrePostDeployment(ctx, phaseCtx, workloadVersion, apicommon.PostDeploymentCheckType) @@ -230,7 +230,7 @@ func (r *KeptnWorkloadVersionReconciler) doPostDeploymentTaskPhase(ctx context.C }, nil } -func (r *KeptnWorkloadVersionReconciler) doPostDeploymentEvaluationPhase(ctx context.Context, workloadVersion *klcv1beta1.KeptnWorkloadVersion, ctxWorkloadTrace context.Context) (phase.PhaseResult, error) { +func (r *KeptnWorkloadVersionReconciler) doPostDeploymentEvaluationPhase(ctx context.Context, workloadVersion *apilifecycle.KeptnWorkloadVersion, ctxWorkloadTrace context.Context) (phase.PhaseResult, error) { if !workloadVersion.IsPostDeploymentEvaluationSucceeded(r.Config.GetBlockDeployment()) { reconcilePostEval := func(phaseCtx context.Context) (apicommon.KeptnState, error) { return r.reconcilePrePostEvaluation(ctx, phaseCtx, workloadVersion, apicommon.PostDeploymentEvaluationCheckType) @@ -248,7 +248,7 @@ func (r *KeptnWorkloadVersionReconciler) doPostDeploymentEvaluationPhase(ctx con }, nil } -func (r *KeptnWorkloadVersionReconciler) closeFailedWorkloadVersionSpan(workloadVersion *klcv1beta1.KeptnWorkloadVersion, spanWorkloadTrace trace.Span) { +func (r *KeptnWorkloadVersionReconciler) closeFailedWorkloadVersionSpan(workloadVersion *apilifecycle.KeptnWorkloadVersion, spanWorkloadTrace trace.Span) { // make sure we close and unbind the span of a failed AppVersion if workloadVersion.Status.Status != apicommon.StateFailed { return @@ -262,7 +262,7 @@ func (r *KeptnWorkloadVersionReconciler) closeFailedWorkloadVersionSpan(workload r.EventSender.Emit(apicommon.PhaseWorkloadCompleted, "Warning", workloadVersion, apicommon.PhaseStateFailed, "has failed", workloadVersion.GetVersion()) } -func (r *KeptnWorkloadVersionReconciler) finishKeptnWorkloadVersionReconcile(ctx context.Context, workloadVersion *klcv1beta1.KeptnWorkloadVersion, spanWorkloadTrace trace.Span) (ctrl.Result, error) { +func (r *KeptnWorkloadVersionReconciler) finishKeptnWorkloadVersionReconcile(ctx context.Context, workloadVersion *apilifecycle.KeptnWorkloadVersion, spanWorkloadTrace trace.Span) (ctrl.Result, error) { if !workloadVersion.IsEndTimeSet() { workloadVersion.Status.CurrentPhase = apicommon.PhaseCompleted.ShortName workloadVersion.Status.Status = apicommon.StateSucceeded @@ -294,34 +294,34 @@ func (r *KeptnWorkloadVersionReconciler) finishKeptnWorkloadVersionReconcile(ctx // SetupWithManager sets up the controller with the Manager. func (r *KeptnWorkloadVersionReconciler) SetupWithManager(mgr ctrl.Manager) error { - if err := mgr.GetFieldIndexer().IndexField(context.Background(), &klcv1beta1.KeptnWorkloadVersion{}, "spec.app", func(rawObj client.Object) []string { - workloadVersion := rawObj.(*klcv1beta1.KeptnWorkloadVersion) + if err := mgr.GetFieldIndexer().IndexField(context.Background(), &apilifecycle.KeptnWorkloadVersion{}, "spec.app", func(rawObj client.Object) []string { + workloadVersion := rawObj.(*apilifecycle.KeptnWorkloadVersion) return []string{workloadVersion.Spec.AppName} }); err != nil { return err } - if err := mgr.GetFieldIndexer().IndexField(context.Background(), &klcv1beta1.KeptnWorkloadVersion{}, resourceReferenceUIDField, func(rawObj client.Object) []string { + if err := mgr.GetFieldIndexer().IndexField(context.Background(), &apilifecycle.KeptnWorkloadVersion{}, resourceReferenceUIDField, func(rawObj client.Object) []string { return controllercommon.KeptnWorkloadVersionResourceRefUIDIndexFunc(rawObj) }); err != nil { return err } controllerBuilder := ctrl.NewControllerManagedBy(mgr). // predicate disabling the auto reconciliation after updating the object status - For(&klcv1beta1.KeptnWorkloadVersion{}, builder.WithPredicates(predicate.GenerationChangedPredicate{})) + For(&apilifecycle.KeptnWorkloadVersion{}, builder.WithPredicates(predicate.GenerationChangedPredicate{})) return controllerBuilder.Complete(r) } -func (r *KeptnWorkloadVersionReconciler) sendUnfinishedPreEvaluationEvents(appPreEvalStatus apicommon.KeptnState, phase apicommon.KeptnPhaseType, workloadVersion *klcv1beta1.KeptnWorkloadVersion) { +func (r *KeptnWorkloadVersionReconciler) sendUnfinishedPreEvaluationEvents(appPreEvalStatus apicommon.KeptnState, phase apicommon.KeptnPhaseType, workloadVersion *apilifecycle.KeptnWorkloadVersion) { if appPreEvalStatus.IsFailed() { r.EventSender.Emit(phase, "Warning", workloadVersion, apicommon.PhaseStateFailed, "has failed since app has failed", workloadVersion.GetVersion()) } } -func (r *KeptnWorkloadVersionReconciler) getCompletionFunc(ctx context.Context, workloadVersion *klcv1beta1.KeptnWorkloadVersion) func(workloadVersion *klcv1beta1.KeptnWorkloadVersion) { +func (r *KeptnWorkloadVersionReconciler) getCompletionFunc(ctx context.Context, workloadVersion *apilifecycle.KeptnWorkloadVersion) func(workloadVersion *apilifecycle.KeptnWorkloadVersion) { workloadVersion.SetStartTime() - endFunc := func(workloadVersion *klcv1beta1.KeptnWorkloadVersion) { + endFunc := func(workloadVersion *apilifecycle.KeptnWorkloadVersion) { if workloadVersion.IsEndTimeSet() { r.Log.Info("Increasing deployment count") attrs := workloadVersion.GetMetricsAttributes() @@ -332,7 +332,7 @@ func (r *KeptnWorkloadVersionReconciler) getCompletionFunc(ctx context.Context, return endFunc } -func (r *KeptnWorkloadVersionReconciler) checkPreEvaluationStatusOfApp(ctx context.Context, workloadVersion *klcv1beta1.KeptnWorkloadVersion) (bool, error) { +func (r *KeptnWorkloadVersionReconciler) checkPreEvaluationStatusOfApp(ctx context.Context, workloadVersion *apilifecycle.KeptnWorkloadVersion) (bool, error) { // Wait for pre-evaluation checks of App // Only check if we have not begun with the first phase of the workload version, to avoid retrieving the KeptnAppVersion // in each reconciliation loop @@ -378,12 +378,12 @@ func (r *KeptnWorkloadVersionReconciler) checkPreEvaluationStatusOfApp(ctx conte return false, nil } -func (r *KeptnWorkloadVersionReconciler) getAppVersionForWorkloadVersion(ctx context.Context, wli *klcv1beta1.KeptnWorkloadVersion) (bool, klcv1beta1.KeptnAppVersion, error) { - apps := &klcv1beta1.KeptnAppVersionList{} +func (r *KeptnWorkloadVersionReconciler) getAppVersionForWorkloadVersion(ctx context.Context, wli *apilifecycle.KeptnWorkloadVersion) (bool, apilifecycle.KeptnAppVersion, error) { + apps := &apilifecycle.KeptnAppVersionList{} // TODO add label selector for looking up by name? if err := r.Client.List(ctx, apps, client.InNamespace(wli.Namespace)); err != nil { - return false, klcv1beta1.KeptnAppVersion{}, err + return false, apilifecycle.KeptnAppVersion{}, err } // due to effectivity reasons deprecated KeptnAppVersions are removed from the list, as there is @@ -398,7 +398,7 @@ func (r *KeptnWorkloadVersionReconciler) getAppVersionForWorkloadVersion(ctx con // If the latest version is empty or the workload is not found, return false and empty result if latestVersion.Spec.Version == "" || !workloadFound { - return false, klcv1beta1.KeptnAppVersion{}, nil + return false, apilifecycle.KeptnAppVersion{}, nil } return true, latestVersion, nil } @@ -407,8 +407,8 @@ func (r *KeptnWorkloadVersionReconciler) getTracer() telemetry.ITracer { return r.TracerFactory.GetTracer(traceComponentName) } -func getLatestAppVersion(apps *klcv1beta1.KeptnAppVersionList, wli *klcv1beta1.KeptnWorkloadVersion) (bool, klcv1beta1.KeptnAppVersion, error) { - latestVersion := klcv1beta1.KeptnAppVersion{} +func getLatestAppVersion(apps *apilifecycle.KeptnAppVersionList, wli *apilifecycle.KeptnWorkloadVersion) (bool, apilifecycle.KeptnAppVersion, error) { + latestVersion := apilifecycle.KeptnAppVersion{} workloadFound := false for _, app := range apps.Items { @@ -427,10 +427,10 @@ func getLatestAppVersion(apps *klcv1beta1.KeptnAppVersionList, wli *klcv1beta1.K return workloadFound, latestVersion, nil } -func isNewer(app klcv1beta1.KeptnAppVersion, latestVersion klcv1beta1.KeptnAppVersion) bool { +func isNewer(app apilifecycle.KeptnAppVersion, latestVersion apilifecycle.KeptnAppVersion) bool { return app.ObjectMeta.CreationTimestamp.Time.After(latestVersion.ObjectMeta.CreationTimestamp.Time) || latestVersion.CreationTimestamp.Time.IsZero() } -func workloadMatchesApp(appWorkload klcv1beta1.KeptnWorkloadRef, wli *klcv1beta1.KeptnWorkloadVersion, app klcv1beta1.KeptnAppVersion) bool { +func workloadMatchesApp(appWorkload apilifecycle.KeptnWorkloadRef, wli *apilifecycle.KeptnWorkloadVersion, app apilifecycle.KeptnAppVersion) bool { return appWorkload.Version == wli.Spec.Version && app.GetWorkloadNameOfApp(appWorkload.Name) == wli.Spec.WorkloadName } diff --git a/lifecycle-operator/controllers/lifecycle/keptnworkloadversion/controller_test.go b/lifecycle-operator/controllers/lifecycle/keptnworkloadversion/controller_test.go index 9aa76f10e1..78108a54ea 100644 --- a/lifecycle-operator/controllers/lifecycle/keptnworkloadversion/controller_test.go +++ b/lifecycle-operator/controllers/lifecycle/keptnworkloadversion/controller_test.go @@ -8,8 +8,8 @@ import ( "testing" "time" - klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" + apilifecycle "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1/common" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/config" keptncontext "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/context" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/evaluation" @@ -322,59 +322,59 @@ func Test_getAppVersionForWorkloadVersion(t *testing.T) { now := time.Now() tests := []struct { name string - wli *klcv1beta1.KeptnWorkloadVersion - list *klcv1beta1.KeptnAppVersionList + wli *apilifecycle.KeptnWorkloadVersion + list *apilifecycle.KeptnAppVersionList wantFound bool - wantAppVersion klcv1beta1.KeptnAppVersion + wantAppVersion apilifecycle.KeptnAppVersion wantErr bool }{ { name: "no appVersions", - wli: &klcv1beta1.KeptnWorkloadVersion{ + wli: &apilifecycle.KeptnWorkloadVersion{ ObjectMeta: metav1.ObjectMeta{ Name: "my-workloadVersion", Namespace: "default", }, - Spec: klcv1beta1.KeptnWorkloadVersionSpec{ - KeptnWorkloadSpec: klcv1beta1.KeptnWorkloadSpec{ + Spec: apilifecycle.KeptnWorkloadVersionSpec{ + KeptnWorkloadSpec: apilifecycle.KeptnWorkloadSpec{ AppName: "my-app", Version: "1.0", }, WorkloadName: "my-app-my-workload", }, }, - list: &klcv1beta1.KeptnAppVersionList{}, + list: &apilifecycle.KeptnAppVersionList{}, wantFound: false, - wantAppVersion: klcv1beta1.KeptnAppVersion{}, + wantAppVersion: apilifecycle.KeptnAppVersion{}, wantErr: false, }, { name: "appVersion found", - wli: &klcv1beta1.KeptnWorkloadVersion{ + wli: &apilifecycle.KeptnWorkloadVersion{ ObjectMeta: metav1.ObjectMeta{ Name: "my-workloadVersion", Namespace: "default", }, - Spec: klcv1beta1.KeptnWorkloadVersionSpec{ - KeptnWorkloadSpec: klcv1beta1.KeptnWorkloadSpec{ + Spec: apilifecycle.KeptnWorkloadVersionSpec{ + KeptnWorkloadSpec: apilifecycle.KeptnWorkloadSpec{ AppName: "my-app", Version: "1.0", }, WorkloadName: "my-app-my-workload", }, }, - list: &klcv1beta1.KeptnAppVersionList{ - Items: []klcv1beta1.KeptnAppVersion{ + list: &apilifecycle.KeptnAppVersionList{ + Items: []apilifecycle.KeptnAppVersion{ { ObjectMeta: metav1.ObjectMeta{ Name: "my-app", Namespace: "default", CreationTimestamp: metav1.Time{Time: now}, }, - Spec: klcv1beta1.KeptnAppVersionSpec{ - KeptnAppSpec: klcv1beta1.KeptnAppSpec{ + Spec: apilifecycle.KeptnAppVersionSpec{ + KeptnAppSpec: apilifecycle.KeptnAppSpec{ Version: "1.0", - Workloads: []klcv1beta1.KeptnWorkloadRef{ + Workloads: []apilifecycle.KeptnWorkloadRef{ { Name: "my-workload", Version: "1.0", @@ -390,10 +390,10 @@ func Test_getAppVersionForWorkloadVersion(t *testing.T) { Namespace: "default", CreationTimestamp: metav1.Time{Time: now.Add(5 * time.Second)}, }, - Spec: klcv1beta1.KeptnAppVersionSpec{ - KeptnAppSpec: klcv1beta1.KeptnAppSpec{ + Spec: apilifecycle.KeptnAppVersionSpec{ + KeptnAppSpec: apilifecycle.KeptnAppSpec{ Version: "2.0", - Workloads: []klcv1beta1.KeptnWorkloadRef{ + Workloads: []apilifecycle.KeptnWorkloadRef{ { Name: "my-workload", Version: "1.0", @@ -406,16 +406,16 @@ func Test_getAppVersionForWorkloadVersion(t *testing.T) { }, }, wantFound: true, - wantAppVersion: klcv1beta1.KeptnAppVersion{ + wantAppVersion: apilifecycle.KeptnAppVersion{ ObjectMeta: metav1.ObjectMeta{ Name: "my-app2", Namespace: "default", ResourceVersion: "999", }, - Spec: klcv1beta1.KeptnAppVersionSpec{ - KeptnAppSpec: klcv1beta1.KeptnAppSpec{ + Spec: apilifecycle.KeptnAppVersionSpec{ + KeptnAppSpec: apilifecycle.KeptnAppSpec{ Version: "2.0", - Workloads: []klcv1beta1.KeptnWorkloadRef{ + Workloads: []apilifecycle.KeptnWorkloadRef{ { Name: "my-workload", Version: "1.0", @@ -429,30 +429,30 @@ func Test_getAppVersionForWorkloadVersion(t *testing.T) { }, { name: "appVersion deprecated", - wli: &klcv1beta1.KeptnWorkloadVersion{ + wli: &apilifecycle.KeptnWorkloadVersion{ ObjectMeta: metav1.ObjectMeta{ Name: "my-workloadVersion", Namespace: "default", }, - Spec: klcv1beta1.KeptnWorkloadVersionSpec{ - KeptnWorkloadSpec: klcv1beta1.KeptnWorkloadSpec{ + Spec: apilifecycle.KeptnWorkloadVersionSpec{ + KeptnWorkloadSpec: apilifecycle.KeptnWorkloadSpec{ AppName: "my-app", Version: "1.0", }, WorkloadName: "my-app-my-workload", }, }, - list: &klcv1beta1.KeptnAppVersionList{ - Items: []klcv1beta1.KeptnAppVersion{ + list: &apilifecycle.KeptnAppVersionList{ + Items: []apilifecycle.KeptnAppVersion{ { ObjectMeta: metav1.ObjectMeta{ Name: "my-app", Namespace: "default", }, - Spec: klcv1beta1.KeptnAppVersionSpec{ - KeptnAppSpec: klcv1beta1.KeptnAppSpec{ + Spec: apilifecycle.KeptnAppVersionSpec{ + KeptnAppSpec: apilifecycle.KeptnAppSpec{ Version: "1.0", - Workloads: []klcv1beta1.KeptnWorkloadRef{ + Workloads: []apilifecycle.KeptnWorkloadRef{ { Name: "my-workload", Version: "1.0", @@ -461,7 +461,7 @@ func Test_getAppVersionForWorkloadVersion(t *testing.T) { }, AppName: "my-app", }, - Status: klcv1beta1.KeptnAppVersionStatus{ + Status: apilifecycle.KeptnAppVersionStatus{ Status: apicommon.StateDeprecated, }, }, @@ -470,10 +470,10 @@ func Test_getAppVersionForWorkloadVersion(t *testing.T) { Name: "my-app2", Namespace: "default", }, - Spec: klcv1beta1.KeptnAppVersionSpec{ - KeptnAppSpec: klcv1beta1.KeptnAppSpec{ + Spec: apilifecycle.KeptnAppVersionSpec{ + KeptnAppSpec: apilifecycle.KeptnAppSpec{ Version: "2.0", - Workloads: []klcv1beta1.KeptnWorkloadRef{ + Workloads: []apilifecycle.KeptnWorkloadRef{ { Name: "my-workload", Version: "1.0", @@ -482,42 +482,42 @@ func Test_getAppVersionForWorkloadVersion(t *testing.T) { }, AppName: "my-app", }, - Status: klcv1beta1.KeptnAppVersionStatus{ + Status: apilifecycle.KeptnAppVersionStatus{ Status: apicommon.StateDeprecated, }, }, }, }, wantFound: false, - wantAppVersion: klcv1beta1.KeptnAppVersion{}, + wantAppVersion: apilifecycle.KeptnAppVersion{}, wantErr: false, }, { name: "no workload for appversion", - wli: &klcv1beta1.KeptnWorkloadVersion{ + wli: &apilifecycle.KeptnWorkloadVersion{ ObjectMeta: metav1.ObjectMeta{ Name: "my-workloadVersion3", Namespace: "default", }, - Spec: klcv1beta1.KeptnWorkloadVersionSpec{ - KeptnWorkloadSpec: klcv1beta1.KeptnWorkloadSpec{ + Spec: apilifecycle.KeptnWorkloadVersionSpec{ + KeptnWorkloadSpec: apilifecycle.KeptnWorkloadSpec{ AppName: "my-app333", Version: "1.0.0", }, WorkloadName: "my-app-my-workload", }, }, - list: &klcv1beta1.KeptnAppVersionList{ - Items: []klcv1beta1.KeptnAppVersion{ + list: &apilifecycle.KeptnAppVersionList{ + Items: []apilifecycle.KeptnAppVersion{ { ObjectMeta: metav1.ObjectMeta{ Name: "my-app", Namespace: "default", }, - Spec: klcv1beta1.KeptnAppVersionSpec{ - KeptnAppSpec: klcv1beta1.KeptnAppSpec{ + Spec: apilifecycle.KeptnAppVersionSpec{ + KeptnAppSpec: apilifecycle.KeptnAppSpec{ Version: "1.0", - Workloads: []klcv1beta1.KeptnWorkloadRef{ + Workloads: []apilifecycle.KeptnWorkloadRef{ { Name: "my-workload", Version: "1.0", @@ -532,10 +532,10 @@ func Test_getAppVersionForWorkloadVersion(t *testing.T) { Name: "my-app2", Namespace: "default", }, - Spec: klcv1beta1.KeptnAppVersionSpec{ - KeptnAppSpec: klcv1beta1.KeptnAppSpec{ + Spec: apilifecycle.KeptnAppVersionSpec{ + KeptnAppSpec: apilifecycle.KeptnAppSpec{ Version: "2.0", - Workloads: []klcv1beta1.KeptnWorkloadRef{ + Workloads: []apilifecycle.KeptnWorkloadRef{ { Name: "my-workload", Version: "1.0", @@ -548,14 +548,14 @@ func Test_getAppVersionForWorkloadVersion(t *testing.T) { }, }, wantFound: false, - wantAppVersion: klcv1beta1.KeptnAppVersion{}, + wantAppVersion: apilifecycle.KeptnAppVersion{}, wantErr: false, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - err := klcv1beta1.AddToScheme(scheme.Scheme) + err := apilifecycle.AddToScheme(scheme.Scheme) require.Nil(t, err) r := &KeptnWorkloadVersionReconciler{ Client: k8sfake.NewClientBuilder().WithLists(tt.list).Build(), @@ -577,31 +577,31 @@ func Test_getLatestAppVersion(t *testing.T) { now := time.Now() type args struct { - apps *klcv1beta1.KeptnAppVersionList - wli *klcv1beta1.KeptnWorkloadVersion + apps *apilifecycle.KeptnAppVersionList + wli *apilifecycle.KeptnWorkloadVersion } tests := []struct { name string args args wantFound bool - wantAppVersion klcv1beta1.KeptnAppVersion + wantAppVersion apilifecycle.KeptnAppVersion wantErr bool }{ { name: "app version found", args: args{ - apps: &klcv1beta1.KeptnAppVersionList{ - Items: []klcv1beta1.KeptnAppVersion{ + apps: &apilifecycle.KeptnAppVersionList{ + Items: []apilifecycle.KeptnAppVersion{ { ObjectMeta: metav1.ObjectMeta{ Name: "my-app", Namespace: "default", CreationTimestamp: metav1.Time{Time: now}, }, - Spec: klcv1beta1.KeptnAppVersionSpec{ - KeptnAppSpec: klcv1beta1.KeptnAppSpec{ + Spec: apilifecycle.KeptnAppVersionSpec{ + KeptnAppSpec: apilifecycle.KeptnAppSpec{ Version: "1.0", - Workloads: []klcv1beta1.KeptnWorkloadRef{ + Workloads: []apilifecycle.KeptnWorkloadRef{ { Name: "my-workload", Version: "1.0", @@ -617,10 +617,10 @@ func Test_getLatestAppVersion(t *testing.T) { Namespace: "default", CreationTimestamp: metav1.Time{Time: now.Add(5 * time.Second)}, }, - Spec: klcv1beta1.KeptnAppVersionSpec{ - KeptnAppSpec: klcv1beta1.KeptnAppSpec{ + Spec: apilifecycle.KeptnAppVersionSpec{ + KeptnAppSpec: apilifecycle.KeptnAppSpec{ Version: "2.0", - Workloads: []klcv1beta1.KeptnWorkloadRef{ + Workloads: []apilifecycle.KeptnWorkloadRef{ { Name: "my-workload", Version: "1.0", @@ -632,13 +632,13 @@ func Test_getLatestAppVersion(t *testing.T) { }, }, }, - wli: &klcv1beta1.KeptnWorkloadVersion{ + wli: &apilifecycle.KeptnWorkloadVersion{ ObjectMeta: metav1.ObjectMeta{ Name: "my-workloadVersion", Namespace: "default", }, - Spec: klcv1beta1.KeptnWorkloadVersionSpec{ - KeptnWorkloadSpec: klcv1beta1.KeptnWorkloadSpec{ + Spec: apilifecycle.KeptnWorkloadVersionSpec{ + KeptnWorkloadSpec: apilifecycle.KeptnWorkloadSpec{ AppName: "my-app", Version: "1.0", }, @@ -647,16 +647,16 @@ func Test_getLatestAppVersion(t *testing.T) { }, }, wantFound: true, - wantAppVersion: klcv1beta1.KeptnAppVersion{ + wantAppVersion: apilifecycle.KeptnAppVersion{ ObjectMeta: metav1.ObjectMeta{ Name: "my-app", Namespace: "default", CreationTimestamp: metav1.Time{Time: now.Add(5 * time.Second)}, }, - Spec: klcv1beta1.KeptnAppVersionSpec{ - KeptnAppSpec: klcv1beta1.KeptnAppSpec{ + Spec: apilifecycle.KeptnAppVersionSpec{ + KeptnAppSpec: apilifecycle.KeptnAppSpec{ Version: "2.0", - Workloads: []klcv1beta1.KeptnWorkloadRef{ + Workloads: []apilifecycle.KeptnWorkloadRef{ { Name: "my-workload", Version: "1.0", @@ -671,17 +671,17 @@ func Test_getLatestAppVersion(t *testing.T) { { name: "app version not found", args: args{ - apps: &klcv1beta1.KeptnAppVersionList{ - Items: []klcv1beta1.KeptnAppVersion{ + apps: &apilifecycle.KeptnAppVersionList{ + Items: []apilifecycle.KeptnAppVersion{ { ObjectMeta: metav1.ObjectMeta{ Name: "my-app", Namespace: "default", }, - Spec: klcv1beta1.KeptnAppVersionSpec{ - KeptnAppSpec: klcv1beta1.KeptnAppSpec{ + Spec: apilifecycle.KeptnAppVersionSpec{ + KeptnAppSpec: apilifecycle.KeptnAppSpec{ Version: "1.0", - Workloads: []klcv1beta1.KeptnWorkloadRef{ + Workloads: []apilifecycle.KeptnWorkloadRef{ { Name: "my-other-workload", Version: "1.0", @@ -693,13 +693,13 @@ func Test_getLatestAppVersion(t *testing.T) { }, }, }, - wli: &klcv1beta1.KeptnWorkloadVersion{ + wli: &apilifecycle.KeptnWorkloadVersion{ ObjectMeta: metav1.ObjectMeta{ Name: "my-workloadVersion", Namespace: "default", }, - Spec: klcv1beta1.KeptnWorkloadVersionSpec{ - KeptnWorkloadSpec: klcv1beta1.KeptnWorkloadSpec{ + Spec: apilifecycle.KeptnWorkloadVersionSpec{ + KeptnWorkloadSpec: apilifecycle.KeptnWorkloadSpec{ AppName: "my-app", Version: "1.0", }, @@ -708,22 +708,22 @@ func Test_getLatestAppVersion(t *testing.T) { }, }, wantFound: false, - wantAppVersion: klcv1beta1.KeptnAppVersion{}, + wantAppVersion: apilifecycle.KeptnAppVersion{}, wantErr: false, }, { name: "app version list empty", args: args{ - apps: &klcv1beta1.KeptnAppVersionList{ - Items: []klcv1beta1.KeptnAppVersion{}, + apps: &apilifecycle.KeptnAppVersionList{ + Items: []apilifecycle.KeptnAppVersion{}, }, - wli: &klcv1beta1.KeptnWorkloadVersion{ + wli: &apilifecycle.KeptnWorkloadVersion{ ObjectMeta: metav1.ObjectMeta{ Name: "my-workloadVersion", Namespace: "default", }, - Spec: klcv1beta1.KeptnWorkloadVersionSpec{ - KeptnWorkloadSpec: klcv1beta1.KeptnWorkloadSpec{ + Spec: apilifecycle.KeptnWorkloadVersionSpec{ + KeptnWorkloadSpec: apilifecycle.KeptnWorkloadSpec{ AppName: "my-app", Version: "1.0", }, @@ -732,7 +732,7 @@ func Test_getLatestAppVersion(t *testing.T) { }, }, wantFound: false, - wantAppVersion: klcv1beta1.KeptnAppVersion{}, + wantAppVersion: apilifecycle.KeptnAppVersion{}, wantErr: false, }, } @@ -759,14 +759,14 @@ func TestKeptnWorkloadVersionReconciler_ReconcileReachCompletion(t *testing.T) { testNamespace := "some-ns" - wi := &klcv1beta1.KeptnWorkloadVersion{ + wi := &apilifecycle.KeptnWorkloadVersion{ TypeMeta: metav1.TypeMeta{}, ObjectMeta: metav1.ObjectMeta{ Name: "some-wi", Namespace: testNamespace, }, - Spec: klcv1beta1.KeptnWorkloadVersionSpec{ - KeptnWorkloadSpec: klcv1beta1.KeptnWorkloadSpec{ + Spec: apilifecycle.KeptnWorkloadVersionSpec{ + KeptnWorkloadSpec: apilifecycle.KeptnWorkloadSpec{ AppName: "some-app", Version: "1.0.0", Metadata: map[string]string{ @@ -777,7 +777,7 @@ func TestKeptnWorkloadVersionReconciler_ReconcileReachCompletion(t *testing.T) { PreviousVersion: "", TraceId: nil, }, - Status: klcv1beta1.KeptnWorkloadVersionStatus{ + Status: apilifecycle.KeptnWorkloadVersionStatus{ DeploymentStatus: apicommon.StateSucceeded, PreDeploymentStatus: apicommon.StateSucceeded, PostDeploymentStatus: apicommon.StateSucceeded, @@ -797,13 +797,13 @@ func TestKeptnWorkloadVersionReconciler_ReconcileReachCompletion(t *testing.T) { testNamespace, "some-app", "1.0.0", - []klcv1beta1.KeptnWorkloadRef{ + []apilifecycle.KeptnWorkloadRef{ { Name: "some-workload", Version: "1.0.0", }, }, - klcv1beta1.KeptnAppVersionStatus{ + apilifecycle.KeptnAppVersionStatus{ PreDeploymentEvaluationStatus: apicommon.StateSucceeded, }, ) @@ -853,14 +853,14 @@ func TestKeptnWorkloadVersionReconciler_ReconcileFailed(t *testing.T) { testNamespace := "some-ns" - wi := &klcv1beta1.KeptnWorkloadVersion{ + wi := &apilifecycle.KeptnWorkloadVersion{ TypeMeta: metav1.TypeMeta{}, ObjectMeta: metav1.ObjectMeta{ Name: "some-wi", Namespace: testNamespace, }, - Spec: klcv1beta1.KeptnWorkloadVersionSpec{ - KeptnWorkloadSpec: klcv1beta1.KeptnWorkloadSpec{ + Spec: apilifecycle.KeptnWorkloadVersionSpec{ + KeptnWorkloadSpec: apilifecycle.KeptnWorkloadSpec{ AppName: "some-app", Version: "1.0.0", PreDeploymentTasks: []string{ @@ -871,7 +871,7 @@ func TestKeptnWorkloadVersionReconciler_ReconcileFailed(t *testing.T) { PreviousVersion: "", TraceId: nil, }, - Status: klcv1beta1.KeptnWorkloadVersionStatus{ + Status: apilifecycle.KeptnWorkloadVersionStatus{ DeploymentStatus: apicommon.StatePending, PreDeploymentStatus: apicommon.StateProgressing, PostDeploymentStatus: apicommon.StatePending, @@ -879,7 +879,7 @@ func TestKeptnWorkloadVersionReconciler_ReconcileFailed(t *testing.T) { PostDeploymentEvaluationStatus: apicommon.StatePending, CurrentPhase: apicommon.PhaseWorkloadPreDeployment.ShortName, Status: apicommon.StateProgressing, - PreDeploymentTaskStatus: []klcv1beta1.ItemStatus{ + PreDeploymentTaskStatus: []apilifecycle.ItemStatus{ { Name: "pre-task", DefinitionName: "task", @@ -894,13 +894,13 @@ func TestKeptnWorkloadVersionReconciler_ReconcileFailed(t *testing.T) { testNamespace, "some-app", "1.0.0", - []klcv1beta1.KeptnWorkloadRef{ + []apilifecycle.KeptnWorkloadRef{ { Name: "some-workload", Version: "1.0.0", }, }, - klcv1beta1.KeptnAppVersionStatus{ + apilifecycle.KeptnAppVersionStatus{ PreDeploymentEvaluationStatus: apicommon.StateSucceeded, }, ) @@ -977,14 +977,14 @@ func TestKeptnWorkloadVersionReconciler_ReconcilePreDeploymentEvaluationUnexpect testNamespace := "some-ns" - wi := &klcv1beta1.KeptnWorkloadVersion{ + wi := &apilifecycle.KeptnWorkloadVersion{ TypeMeta: metav1.TypeMeta{}, ObjectMeta: metav1.ObjectMeta{ Name: "some-wi", Namespace: testNamespace, }, - Spec: klcv1beta1.KeptnWorkloadVersionSpec{ - KeptnWorkloadSpec: klcv1beta1.KeptnWorkloadSpec{ + Spec: apilifecycle.KeptnWorkloadVersionSpec{ + KeptnWorkloadSpec: apilifecycle.KeptnWorkloadSpec{ AppName: "some-app", Version: "1.0.0", PreDeploymentEvaluations: []string{"my-pre-evaluation"}, @@ -993,7 +993,7 @@ func TestKeptnWorkloadVersionReconciler_ReconcilePreDeploymentEvaluationUnexpect PreviousVersion: "", TraceId: nil, }, - Status: klcv1beta1.KeptnWorkloadVersionStatus{ + Status: apilifecycle.KeptnWorkloadVersionStatus{ CurrentPhase: apicommon.PhaseWorkloadPreDeployment.ShortName, StartTime: metav1.Time{}, EndTime: metav1.Time{}, @@ -1004,13 +1004,13 @@ func TestKeptnWorkloadVersionReconciler_ReconcilePreDeploymentEvaluationUnexpect testNamespace, "some-app", "1.0.0", - []klcv1beta1.KeptnWorkloadRef{ + []apilifecycle.KeptnWorkloadRef{ { Name: "some-workload", Version: "1.0.0", }, }, - klcv1beta1.KeptnAppVersionStatus{ + apilifecycle.KeptnAppVersionStatus{ PreDeploymentEvaluationStatus: apicommon.StateSucceeded, }, ) @@ -1019,7 +1019,7 @@ func TestKeptnWorkloadVersionReconciler_ReconcilePreDeploymentEvaluationUnexpect mockEvaluationHandler := r.EvaluationHandler.(*evaluationfake.MockEvaluationHandler) - mockEvaluationHandler.ReconcileEvaluationsFunc = func(ctx context.Context, phaseCtx context.Context, reconcileObject client.Object, evaluationCreateAttributes evaluation.CreateEvaluationAttributes) ([]klcv1beta1.ItemStatus, apicommon.StatusSummary, error) { + mockEvaluationHandler.ReconcileEvaluationsFunc = func(ctx context.Context, phaseCtx context.Context, reconcileObject client.Object, evaluationCreateAttributes evaluation.CreateEvaluationAttributes) ([]apilifecycle.ItemStatus, apicommon.StatusSummary, error) { return nil, apicommon.StatusSummary{}, errors.New("unexpected error") } @@ -1084,23 +1084,23 @@ func setupReconciler(objs ...client.Object) (*KeptnWorkloadVersionReconciler, ch TracerFactory: tf, Config: config.Instance(), EvaluationHandler: &evaluationfake.MockEvaluationHandler{ - ReconcileEvaluationsFunc: func(ctx context.Context, phaseCtx context.Context, reconcileObject client.Object, evaluationCreateAttributes evaluation.CreateEvaluationAttributes) ([]klcv1beta1.ItemStatus, apicommon.StatusSummary, error) { - return []klcv1beta1.ItemStatus{}, apicommon.StatusSummary{}, nil + ReconcileEvaluationsFunc: func(ctx context.Context, phaseCtx context.Context, reconcileObject client.Object, evaluationCreateAttributes evaluation.CreateEvaluationAttributes) ([]apilifecycle.ItemStatus, apicommon.StatusSummary, error) { + return []apilifecycle.ItemStatus{}, apicommon.StatusSummary{}, nil }, }, } return r, recorder.Events, tr } -func makeWorkloadVersionWithRef(objectMeta metav1.ObjectMeta, refKind string) *klcv1beta1.KeptnWorkloadVersion { - workloadVersion := &klcv1beta1.KeptnWorkloadVersion{ +func makeWorkloadVersionWithRef(objectMeta metav1.ObjectMeta, refKind string) *apilifecycle.KeptnWorkloadVersion { + workloadVersion := &apilifecycle.KeptnWorkloadVersion{ ObjectMeta: metav1.ObjectMeta{ Name: "my-wli", Namespace: "default", }, - Spec: klcv1beta1.KeptnWorkloadVersionSpec{ - KeptnWorkloadSpec: klcv1beta1.KeptnWorkloadSpec{ - ResourceReference: klcv1beta1.ResourceReference{ + Spec: apilifecycle.KeptnWorkloadVersionSpec{ + KeptnWorkloadSpec: apilifecycle.KeptnWorkloadSpec{ + ResourceReference: apilifecycle.ResourceReference{ UID: objectMeta.UID, Name: objectMeta.Name, Kind: refKind, @@ -1114,9 +1114,9 @@ func makeWorkloadVersionWithRef(objectMeta metav1.ObjectMeta, refKind string) *k func TestKeptnWorkloadVersionReconciler_checkPreEvaluationStatusOfAppCannotRetrieveApp(t *testing.T) { r, _, _ := setupReconciler() - wv := &klcv1beta1.KeptnWorkloadVersion{ - Spec: klcv1beta1.KeptnWorkloadVersionSpec{ - KeptnWorkloadSpec: klcv1beta1.KeptnWorkloadSpec{}, + wv := &apilifecycle.KeptnWorkloadVersion{ + Spec: apilifecycle.KeptnWorkloadVersionSpec{ + KeptnWorkloadSpec: apilifecycle.KeptnWorkloadSpec{}, }, } @@ -1137,9 +1137,9 @@ func TestKeptnWorkloadVersionReconciler_checkPreEvaluationStatusOfAppCannotRetri func TestKeptnWorkloadVersionReconciler_checkPreEvaluationStatusOfAppAppNotFound(t *testing.T) { r, _, _ := setupReconciler() - wv := &klcv1beta1.KeptnWorkloadVersion{ - Spec: klcv1beta1.KeptnWorkloadVersionSpec{ - KeptnWorkloadSpec: klcv1beta1.KeptnWorkloadSpec{ + wv := &apilifecycle.KeptnWorkloadVersion{ + Spec: apilifecycle.KeptnWorkloadVersionSpec{ + KeptnWorkloadSpec: apilifecycle.KeptnWorkloadSpec{ AppName: "my-unknown-app", }, }, @@ -1152,13 +1152,13 @@ func TestKeptnWorkloadVersionReconciler_checkPreEvaluationStatusOfAppAppNotFound } func TestKeptnWorkloadVersionReconciler_checkPreEvaluationStatusOfAppAppPreTasksNotFinished(t *testing.T) { - appVersion := &klcv1beta1.KeptnAppVersion{ + appVersion := &apilifecycle.KeptnAppVersion{ ObjectMeta: metav1.ObjectMeta{}, - Spec: klcv1beta1.KeptnAppVersionSpec{ + Spec: apilifecycle.KeptnAppVersionSpec{ AppName: "my-app", - KeptnAppSpec: klcv1beta1.KeptnAppSpec{ + KeptnAppSpec: apilifecycle.KeptnAppSpec{ Version: "1.0", - Workloads: []klcv1beta1.KeptnWorkloadRef{ + Workloads: []apilifecycle.KeptnWorkloadRef{ { Name: "my-workload", Version: "1.0", @@ -1170,12 +1170,12 @@ func TestKeptnWorkloadVersionReconciler_checkPreEvaluationStatusOfAppAppPreTasks r, _, _ := setupReconciler(appVersion) - wv := &klcv1beta1.KeptnWorkloadVersion{ + wv := &apilifecycle.KeptnWorkloadVersion{ ObjectMeta: metav1.ObjectMeta{ Name: "my-app-my-workload-1.0", }, - Spec: klcv1beta1.KeptnWorkloadVersionSpec{ - KeptnWorkloadSpec: klcv1beta1.KeptnWorkloadSpec{ + Spec: apilifecycle.KeptnWorkloadVersionSpec{ + KeptnWorkloadSpec: apilifecycle.KeptnWorkloadSpec{ AppName: "my-app", Version: "1.0", }, @@ -1190,15 +1190,15 @@ func TestKeptnWorkloadVersionReconciler_checkPreEvaluationStatusOfAppAppPreTasks } func TestKeptnWorkloadVersionReconciler_checkPreEvaluationStatusOfAppUpdateTraceID(t *testing.T) { - appVersion := &klcv1beta1.KeptnAppVersion{ + appVersion := &apilifecycle.KeptnAppVersion{ ObjectMeta: metav1.ObjectMeta{ Name: "my-app-version", }, - Spec: klcv1beta1.KeptnAppVersionSpec{ + Spec: apilifecycle.KeptnAppVersionSpec{ AppName: "my-app", - KeptnAppSpec: klcv1beta1.KeptnAppSpec{ + KeptnAppSpec: apilifecycle.KeptnAppSpec{ Version: "1.0", - Workloads: []klcv1beta1.KeptnWorkloadRef{ + Workloads: []apilifecycle.KeptnWorkloadRef{ { Name: "my-workload", Version: "1.0", @@ -1206,7 +1206,7 @@ func TestKeptnWorkloadVersionReconciler_checkPreEvaluationStatusOfAppUpdateTrace }, }, }, - Status: klcv1beta1.KeptnAppVersionStatus{ + Status: apilifecycle.KeptnAppVersionStatus{ PreDeploymentEvaluationStatus: apicommon.StateSucceeded, PhaseTraceIDs: map[string]propagation.MapCarrier{ apicommon.PhaseAppDeployment.ShortName: map[string]string{"traceparent": "parent-id"}, @@ -1214,12 +1214,12 @@ func TestKeptnWorkloadVersionReconciler_checkPreEvaluationStatusOfAppUpdateTrace }, } - wv := &klcv1beta1.KeptnWorkloadVersion{ + wv := &apilifecycle.KeptnWorkloadVersion{ ObjectMeta: metav1.ObjectMeta{ Name: "my-app-my-workload-1.0", }, - Spec: klcv1beta1.KeptnWorkloadVersionSpec{ - KeptnWorkloadSpec: klcv1beta1.KeptnWorkloadSpec{ + Spec: apilifecycle.KeptnWorkloadVersionSpec{ + KeptnWorkloadSpec: apilifecycle.KeptnWorkloadSpec{ AppName: "my-app", Version: "1.0", }, @@ -1229,7 +1229,7 @@ func TestKeptnWorkloadVersionReconciler_checkPreEvaluationStatusOfAppUpdateTrace r, _, _ := setupReconciler(appVersion, wv) - appVersion.Status = klcv1beta1.KeptnAppVersionStatus{ + appVersion.Status = apilifecycle.KeptnAppVersionStatus{ PreDeploymentEvaluationStatus: apicommon.StateSucceeded, PhaseTraceIDs: map[string]propagation.MapCarrier{ apicommon.PhaseAppDeployment.ShortName: map[string]string{"traceparent": "parent-id"}, @@ -1253,16 +1253,16 @@ func TestKeptnWorkloadVersionReconciler_checkPreEvaluationStatusOfAppUpdateTrace } func TestKeptnWorkloadVersionReconciler_checkPreEvaluationStatusOfAppUpdateTraceIDWithAppVersionSpecTraceID(t *testing.T) { - appVersion := &klcv1beta1.KeptnAppVersion{ + appVersion := &apilifecycle.KeptnAppVersion{ ObjectMeta: metav1.ObjectMeta{ Name: "my-app-version", }, - Spec: klcv1beta1.KeptnAppVersionSpec{ + Spec: apilifecycle.KeptnAppVersionSpec{ AppName: "my-app", TraceId: map[string]string{"traceparent": "parent-id"}, - KeptnAppSpec: klcv1beta1.KeptnAppSpec{ + KeptnAppSpec: apilifecycle.KeptnAppSpec{ Version: "1.0", - Workloads: []klcv1beta1.KeptnWorkloadRef{ + Workloads: []apilifecycle.KeptnWorkloadRef{ { Name: "my-workload", Version: "1.0", @@ -1272,12 +1272,12 @@ func TestKeptnWorkloadVersionReconciler_checkPreEvaluationStatusOfAppUpdateTrace }, } - wv := &klcv1beta1.KeptnWorkloadVersion{ + wv := &apilifecycle.KeptnWorkloadVersion{ ObjectMeta: metav1.ObjectMeta{ Name: "my-app-my-workload-1.0", }, - Spec: klcv1beta1.KeptnWorkloadVersionSpec{ - KeptnWorkloadSpec: klcv1beta1.KeptnWorkloadSpec{ + Spec: apilifecycle.KeptnWorkloadVersionSpec{ + KeptnWorkloadSpec: apilifecycle.KeptnWorkloadSpec{ AppName: "my-app", Version: "1.0", }, @@ -1287,7 +1287,7 @@ func TestKeptnWorkloadVersionReconciler_checkPreEvaluationStatusOfAppUpdateTrace r, _, _ := setupReconciler(appVersion, wv) - appVersion.Status = klcv1beta1.KeptnAppVersionStatus{ + appVersion.Status = apilifecycle.KeptnAppVersionStatus{ PreDeploymentEvaluationStatus: apicommon.StateSucceeded, } @@ -1308,16 +1308,16 @@ func TestKeptnWorkloadVersionReconciler_checkPreEvaluationStatusOfAppUpdateTrace } func TestKeptnWorkloadVersionReconciler_checkPreEvaluationStatusOfAppErrorWhenUpdatingWorkloadVersion(t *testing.T) { - appVersion := &klcv1beta1.KeptnAppVersion{ + appVersion := &apilifecycle.KeptnAppVersion{ ObjectMeta: metav1.ObjectMeta{ Name: "my-app-version", }, - Spec: klcv1beta1.KeptnAppVersionSpec{ + Spec: apilifecycle.KeptnAppVersionSpec{ AppName: "my-app", TraceId: map[string]string{"traceparent": "parent-id"}, - KeptnAppSpec: klcv1beta1.KeptnAppSpec{ + KeptnAppSpec: apilifecycle.KeptnAppSpec{ Version: "1.0", - Workloads: []klcv1beta1.KeptnWorkloadRef{ + Workloads: []apilifecycle.KeptnWorkloadRef{ { Name: "my-workload", Version: "1.0", @@ -1327,12 +1327,12 @@ func TestKeptnWorkloadVersionReconciler_checkPreEvaluationStatusOfAppErrorWhenUp }, } - wv := &klcv1beta1.KeptnWorkloadVersion{ + wv := &apilifecycle.KeptnWorkloadVersion{ ObjectMeta: metav1.ObjectMeta{ Name: "my-app-my-workload-1.0", }, - Spec: klcv1beta1.KeptnWorkloadVersionSpec{ - KeptnWorkloadSpec: klcv1beta1.KeptnWorkloadSpec{ + Spec: apilifecycle.KeptnWorkloadVersionSpec{ + KeptnWorkloadSpec: apilifecycle.KeptnWorkloadSpec{ AppName: "my-app", Version: "1.0", }, @@ -1351,7 +1351,7 @@ func TestKeptnWorkloadVersionReconciler_checkPreEvaluationStatusOfAppErrorWhenUp r.Client = fakeClient - appVersion.Status = klcv1beta1.KeptnAppVersionStatus{ + appVersion.Status = apilifecycle.KeptnAppVersionStatus{ PreDeploymentEvaluationStatus: apicommon.StateSucceeded, } @@ -1366,23 +1366,23 @@ func TestKeptnWorkloadVersionReconciler_checkPreEvaluationStatusOfAppErrorWhenUp } func TestKeptnWorkloadVersionReconciler_checkPreEvaluationStatusOfAppUpdateMetadata(t *testing.T) { - appVersion := &klcv1beta1.KeptnAppVersion{ + appVersion := &apilifecycle.KeptnAppVersion{ ObjectMeta: metav1.ObjectMeta{ Name: "my-app-version", }, - Spec: klcv1beta1.KeptnAppVersionSpec{ + Spec: apilifecycle.KeptnAppVersionSpec{ AppName: "my-app", TraceId: map[string]string{"traceparent": "parent-id"}, - KeptnAppSpec: klcv1beta1.KeptnAppSpec{ + KeptnAppSpec: apilifecycle.KeptnAppSpec{ Version: "1.0", - Workloads: []klcv1beta1.KeptnWorkloadRef{ + Workloads: []apilifecycle.KeptnWorkloadRef{ { Name: "my-workload", Version: "1.0", }, }, }, - KeptnAppContextSpec: klcv1beta1.KeptnAppContextSpec{ + KeptnAppContextSpec: apilifecycle.KeptnAppContextSpec{ Metadata: map[string]string{ "test": "testy", }, @@ -1390,12 +1390,12 @@ func TestKeptnWorkloadVersionReconciler_checkPreEvaluationStatusOfAppUpdateMetad }, } - wv := &klcv1beta1.KeptnWorkloadVersion{ + wv := &apilifecycle.KeptnWorkloadVersion{ ObjectMeta: metav1.ObjectMeta{ Name: "my-app-my-workload-1.0", }, - Spec: klcv1beta1.KeptnWorkloadVersionSpec{ - KeptnWorkloadSpec: klcv1beta1.KeptnWorkloadSpec{ + Spec: apilifecycle.KeptnWorkloadVersionSpec{ + KeptnWorkloadSpec: apilifecycle.KeptnWorkloadSpec{ AppName: "my-app", Version: "1.0", }, @@ -1406,7 +1406,7 @@ func TestKeptnWorkloadVersionReconciler_checkPreEvaluationStatusOfAppUpdateMetad r, _, _ := setupReconciler(appVersion, wv) - appVersion.Status = klcv1beta1.KeptnAppVersionStatus{ + appVersion.Status = apilifecycle.KeptnAppVersionStatus{ PreDeploymentEvaluationStatus: apicommon.StateSucceeded, } @@ -1427,23 +1427,23 @@ func TestKeptnWorkloadVersionReconciler_checkPreEvaluationStatusOfAppUpdateMetad } func TestKeptnWorkloadVersionReconciler_checkPreEvaluationStatusOfAppErrorWhenUpdatingWorkloadVersionStatus(t *testing.T) { - appVersion := &klcv1beta1.KeptnAppVersion{ + appVersion := &apilifecycle.KeptnAppVersion{ ObjectMeta: metav1.ObjectMeta{ Name: "my-app-version", }, - Spec: klcv1beta1.KeptnAppVersionSpec{ + Spec: apilifecycle.KeptnAppVersionSpec{ AppName: "my-app", TraceId: map[string]string{"traceparent": "parent-id"}, - KeptnAppSpec: klcv1beta1.KeptnAppSpec{ + KeptnAppSpec: apilifecycle.KeptnAppSpec{ Version: "1.0", - Workloads: []klcv1beta1.KeptnWorkloadRef{ + Workloads: []apilifecycle.KeptnWorkloadRef{ { Name: "my-workload", Version: "1.0", }, }, }, - KeptnAppContextSpec: klcv1beta1.KeptnAppContextSpec{ + KeptnAppContextSpec: apilifecycle.KeptnAppContextSpec{ Metadata: map[string]string{ "test": "testy", }, @@ -1451,13 +1451,13 @@ func TestKeptnWorkloadVersionReconciler_checkPreEvaluationStatusOfAppErrorWhenUp }, } - wv := &klcv1beta1.KeptnWorkloadVersion{ + wv := &apilifecycle.KeptnWorkloadVersion{ ObjectMeta: metav1.ObjectMeta{ Name: "my-app-my-workload-1.0", }, - Spec: klcv1beta1.KeptnWorkloadVersionSpec{ + Spec: apilifecycle.KeptnWorkloadVersionSpec{ TraceId: map[string]string{"traceparent": "parent-id"}, - KeptnWorkloadSpec: klcv1beta1.KeptnWorkloadSpec{ + KeptnWorkloadSpec: apilifecycle.KeptnWorkloadSpec{ AppName: "my-app", Version: "1.0", }, @@ -1476,7 +1476,7 @@ func TestKeptnWorkloadVersionReconciler_checkPreEvaluationStatusOfAppErrorWhenUp r.Client = fakeClient - appVersion.Status = klcv1beta1.KeptnAppVersionStatus{ + appVersion.Status = apilifecycle.KeptnAppVersionStatus{ PreDeploymentEvaluationStatus: apicommon.StateSucceeded, } diff --git a/lifecycle-operator/controllers/lifecycle/keptnworkloadversion/reconcile_deploymentstate.go b/lifecycle-operator/controllers/lifecycle/keptnworkloadversion/reconcile_deploymentstate.go index 3067bdfab3..6497f633b7 100644 --- a/lifecycle-operator/controllers/lifecycle/keptnworkloadversion/reconcile_deploymentstate.go +++ b/lifecycle-operator/controllers/lifecycle/keptnworkloadversion/reconcile_deploymentstate.go @@ -5,14 +5,14 @@ import ( "time" argov1alpha1 "github.com/argoproj/argo-rollouts/pkg/apis/rollouts/v1alpha1" - klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" + apilifecycle "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1/common" controllererrors "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/errors" appsv1 "k8s.io/api/apps/v1" "k8s.io/apimachinery/pkg/types" ) -func (r *KeptnWorkloadVersionReconciler) reconcileDeployment(ctx context.Context, workloadVersion *klcv1beta1.KeptnWorkloadVersion) (apicommon.KeptnState, error) { +func (r *KeptnWorkloadVersionReconciler) reconcileDeployment(ctx context.Context, workloadVersion *apilifecycle.KeptnWorkloadVersion) (apicommon.KeptnState, error) { var isRunning bool var err error @@ -57,7 +57,7 @@ func (r *KeptnWorkloadVersionReconciler) reconcileDeployment(ctx context.Context return workloadVersion.Status.DeploymentStatus, nil } -func (r *KeptnWorkloadVersionReconciler) isDeploymentTimedOut(workloadVersion *klcv1beta1.KeptnWorkloadVersion) bool { +func (r *KeptnWorkloadVersionReconciler) isDeploymentTimedOut(workloadVersion *apilifecycle.KeptnWorkloadVersion) bool { if !workloadVersion.IsDeploymentStartTimeSet() { return false } @@ -67,7 +67,7 @@ func (r *KeptnWorkloadVersionReconciler) isDeploymentTimedOut(workloadVersion *k return currentTime.After(deploymentDeadline) } -func (r *KeptnWorkloadVersionReconciler) isReplicaSetRunning(ctx context.Context, resource klcv1beta1.ResourceReference, namespace string) (bool, error) { +func (r *KeptnWorkloadVersionReconciler) isReplicaSetRunning(ctx context.Context, resource apilifecycle.ResourceReference, namespace string) (bool, error) { rep := appsv1.ReplicaSet{} err := r.Client.Get(ctx, types.NamespacedName{Name: resource.Name, Namespace: namespace}, &rep) if err != nil { @@ -76,14 +76,14 @@ func (r *KeptnWorkloadVersionReconciler) isReplicaSetRunning(ctx context.Context for _, ownerRef := range rep.OwnerReferences { if ownerRef.Kind == "Rollout" { - return r.isRolloutRunning(ctx, klcv1beta1.ResourceReference{Name: ownerRef.Name, UID: ownerRef.UID}, namespace) + return r.isRolloutRunning(ctx, apilifecycle.ResourceReference{Name: ownerRef.Name, UID: ownerRef.UID}, namespace) } } return *rep.Spec.Replicas == rep.Status.AvailableReplicas, nil } -func (r *KeptnWorkloadVersionReconciler) isDaemonSetRunning(ctx context.Context, resource klcv1beta1.ResourceReference, namespace string) (bool, error) { +func (r *KeptnWorkloadVersionReconciler) isDaemonSetRunning(ctx context.Context, resource apilifecycle.ResourceReference, namespace string) (bool, error) { daemonSet := &appsv1.DaemonSet{} err := r.Client.Get(ctx, types.NamespacedName{Name: resource.Name, Namespace: namespace}, daemonSet) if err != nil { @@ -92,7 +92,7 @@ func (r *KeptnWorkloadVersionReconciler) isDaemonSetRunning(ctx context.Context, return daemonSet.Status.DesiredNumberScheduled == daemonSet.Status.NumberReady, nil } -func (r *KeptnWorkloadVersionReconciler) isStatefulSetRunning(ctx context.Context, resource klcv1beta1.ResourceReference, namespace string) (bool, error) { +func (r *KeptnWorkloadVersionReconciler) isStatefulSetRunning(ctx context.Context, resource apilifecycle.ResourceReference, namespace string) (bool, error) { sts := appsv1.StatefulSet{} err := r.Client.Get(ctx, types.NamespacedName{Name: resource.Name, Namespace: namespace}, &sts) if err != nil { @@ -101,7 +101,7 @@ func (r *KeptnWorkloadVersionReconciler) isStatefulSetRunning(ctx context.Contex return *sts.Spec.Replicas == sts.Status.AvailableReplicas, nil } -func (r *KeptnWorkloadVersionReconciler) isRolloutRunning(ctx context.Context, resource klcv1beta1.ResourceReference, namespace string) (bool, error) { +func (r *KeptnWorkloadVersionReconciler) isRolloutRunning(ctx context.Context, resource apilifecycle.ResourceReference, namespace string) (bool, error) { rollout := argov1alpha1.Rollout{} err := r.Client.Get(ctx, types.NamespacedName{Name: resource.Name, Namespace: namespace}, &rollout) if err != nil { diff --git a/lifecycle-operator/controllers/lifecycle/keptnworkloadversion/reconcile_prepostdeployment.go b/lifecycle-operator/controllers/lifecycle/keptnworkloadversion/reconcile_prepostdeployment.go index 64c4bf6ee0..cd479dc073 100644 --- a/lifecycle-operator/controllers/lifecycle/keptnworkloadversion/reconcile_prepostdeployment.go +++ b/lifecycle-operator/controllers/lifecycle/keptnworkloadversion/reconcile_prepostdeployment.go @@ -5,12 +5,12 @@ import ( "context" "fmt" - klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" + apilifecycle "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1/common" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/task" ) -func (r *KeptnWorkloadVersionReconciler) reconcilePrePostDeployment(ctx context.Context, phaseCtx context.Context, workloadVersion *klcv1beta1.KeptnWorkloadVersion, checkType apicommon.CheckType) (apicommon.KeptnState, error) { +func (r *KeptnWorkloadVersionReconciler) reconcilePrePostDeployment(ctx context.Context, phaseCtx context.Context, workloadVersion *apilifecycle.KeptnWorkloadVersion, checkType apicommon.CheckType) (apicommon.KeptnState, error) { taskHandler := task.Handler{ Client: r.Client, EventSender: r.EventSender, diff --git a/lifecycle-operator/controllers/lifecycle/keptnworkloadversion/reconcile_prepostevaluation.go b/lifecycle-operator/controllers/lifecycle/keptnworkloadversion/reconcile_prepostevaluation.go index bf3e818dc9..c9c8098430 100644 --- a/lifecycle-operator/controllers/lifecycle/keptnworkloadversion/reconcile_prepostevaluation.go +++ b/lifecycle-operator/controllers/lifecycle/keptnworkloadversion/reconcile_prepostevaluation.go @@ -5,12 +5,12 @@ import ( "context" "fmt" - klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" + apilifecycle "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1/common" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/evaluation" ) -func (r *KeptnWorkloadVersionReconciler) reconcilePrePostEvaluation(ctx context.Context, phaseCtx context.Context, workloadVersion *klcv1beta1.KeptnWorkloadVersion, checkType apicommon.CheckType) (apicommon.KeptnState, error) { +func (r *KeptnWorkloadVersionReconciler) reconcilePrePostEvaluation(ctx context.Context, phaseCtx context.Context, workloadVersion *apilifecycle.KeptnWorkloadVersion, checkType apicommon.CheckType) (apicommon.KeptnState, error) { evaluationCreateAttributes := evaluation.CreateEvaluationAttributes{ SpanName: fmt.Sprintf(apicommon.CreateWorkloadEvalSpanName, checkType), CheckType: checkType, diff --git a/lifecycle-operator/controllers/lifecycle/schedulinggates/controller.go b/lifecycle-operator/controllers/lifecycle/schedulinggates/controller.go index 2f741243cd..f66be28972 100644 --- a/lifecycle-operator/controllers/lifecycle/schedulinggates/controller.go +++ b/lifecycle-operator/controllers/lifecycle/schedulinggates/controller.go @@ -6,8 +6,8 @@ import ( "time" "github.com/go-logr/logr" - klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" + apilifecycle "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1/common" controllercommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common" v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/errors" @@ -55,7 +55,7 @@ func (r *SchedulingGatesReconciler) Reconcile(ctx context.Context, req ctrl.Requ Namespace: pod.GetNamespace(), } - attachedWorkloadVersions := &klcv1beta1.KeptnWorkloadVersionList{} + attachedWorkloadVersions := &apilifecycle.KeptnWorkloadVersionList{} if err := r.List(ctx, attachedWorkloadVersions, listOps); err != nil { r.Log.Error(err, "Could not list WorkloadVersions related to pod", "pod", pod.GetName(), "namespace", pod.GetNamespace()) diff --git a/lifecycle-operator/controllers/lifecycle/schedulinggates/controller_test.go b/lifecycle-operator/controllers/lifecycle/schedulinggates/controller_test.go index b59a893651..d9e06120b1 100644 --- a/lifecycle-operator/controllers/lifecycle/schedulinggates/controller_test.go +++ b/lifecycle-operator/controllers/lifecycle/schedulinggates/controller_test.go @@ -6,8 +6,8 @@ import ( "testing" "time" - klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" + apilifecycle "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1/common" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common" "github.com/stretchr/testify/require" v1 "k8s.io/api/core/v1" @@ -138,35 +138,35 @@ func TestSchedulingGatesReconciler_Reconcile(t *testing.T) { { name: "related WorkloadVersion is completed", objects: []client.Object{ - &klcv1beta1.KeptnWorkloadVersion{ + &apilifecycle.KeptnWorkloadVersion{ ObjectMeta: metav1.ObjectMeta{ Name: "my-wlv", Namespace: "my-namespace", }, - Spec: klcv1beta1.KeptnWorkloadVersionSpec{ - KeptnWorkloadSpec: klcv1beta1.KeptnWorkloadSpec{ - ResourceReference: klcv1beta1.ResourceReference{ + Spec: apilifecycle.KeptnWorkloadVersionSpec{ + KeptnWorkloadSpec: apilifecycle.KeptnWorkloadSpec{ + ResourceReference: apilifecycle.ResourceReference{ UID: podMeta.OwnerReferences[0].UID, }, }, }, - Status: klcv1beta1.KeptnWorkloadVersionStatus{DeploymentStatus: apicommon.StateSucceeded}, + Status: apilifecycle.KeptnWorkloadVersionStatus{DeploymentStatus: apicommon.StateSucceeded}, }, - &klcv1beta1.KeptnWorkloadVersion{ + &apilifecycle.KeptnWorkloadVersion{ ObjectMeta: metav1.ObjectMeta{ Name: "my-other-wlv", Namespace: "my-namespace", }, - Spec: klcv1beta1.KeptnWorkloadVersionSpec{}, + Spec: apilifecycle.KeptnWorkloadVersionSpec{}, }, - &klcv1beta1.KeptnWorkloadVersion{ + &apilifecycle.KeptnWorkloadVersion{ ObjectMeta: metav1.ObjectMeta{ Name: "my-wlv", Namespace: "my-other-namespace", }, - Spec: klcv1beta1.KeptnWorkloadVersionSpec{ - KeptnWorkloadSpec: klcv1beta1.KeptnWorkloadSpec{ - ResourceReference: klcv1beta1.ResourceReference{ + Spec: apilifecycle.KeptnWorkloadVersionSpec{ + KeptnWorkloadSpec: apilifecycle.KeptnWorkloadSpec{ + ResourceReference: apilifecycle.ResourceReference{ UID: podMeta.OwnerReferences[0].UID, }, }, @@ -194,19 +194,19 @@ func TestSchedulingGatesReconciler_Reconcile(t *testing.T) { { name: "related WorkloadVersion is completed - error during update", objects: []client.Object{ - &klcv1beta1.KeptnWorkloadVersion{ + &apilifecycle.KeptnWorkloadVersion{ ObjectMeta: metav1.ObjectMeta{ Name: "my-wlv", Namespace: "my-namespace", }, - Spec: klcv1beta1.KeptnWorkloadVersionSpec{ - KeptnWorkloadSpec: klcv1beta1.KeptnWorkloadSpec{ - ResourceReference: klcv1beta1.ResourceReference{ + Spec: apilifecycle.KeptnWorkloadVersionSpec{ + KeptnWorkloadSpec: apilifecycle.KeptnWorkloadSpec{ + ResourceReference: apilifecycle.ResourceReference{ UID: podMeta.OwnerReferences[0].UID, }, }, }, - Status: klcv1beta1.KeptnWorkloadVersionStatus{DeploymentStatus: apicommon.StateSucceeded}, + Status: apilifecycle.KeptnWorkloadVersionStatus{DeploymentStatus: apicommon.StateSucceeded}, }, &v1.Pod{ ObjectMeta: podMeta, @@ -231,19 +231,19 @@ func TestSchedulingGatesReconciler_Reconcile(t *testing.T) { { name: "related WorkloadVersion is not completed", objects: []client.Object{ - &klcv1beta1.KeptnWorkloadVersion{ + &apilifecycle.KeptnWorkloadVersion{ ObjectMeta: metav1.ObjectMeta{ Name: "my-wlv", Namespace: "my-namespace", }, - Spec: klcv1beta1.KeptnWorkloadVersionSpec{ - KeptnWorkloadSpec: klcv1beta1.KeptnWorkloadSpec{ - ResourceReference: klcv1beta1.ResourceReference{ + Spec: apilifecycle.KeptnWorkloadVersionSpec{ + KeptnWorkloadSpec: apilifecycle.KeptnWorkloadSpec{ + ResourceReference: apilifecycle.ResourceReference{ UID: podMeta.OwnerReferences[0].UID, }, }, }, - Status: klcv1beta1.KeptnWorkloadVersionStatus{DeploymentStatus: apicommon.StatePending}, + Status: apilifecycle.KeptnWorkloadVersionStatus{DeploymentStatus: apicommon.StatePending}, }, &v1.Pod{ ObjectMeta: podMeta, @@ -267,7 +267,7 @@ func TestSchedulingGatesReconciler_Reconcile(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - err := klcv1beta1.AddToScheme(scheme.Scheme) + err := apilifecycle.AddToScheme(scheme.Scheme) require.Nil(t, err) opts := zap.Options{ Development: true, @@ -277,8 +277,8 @@ func TestSchedulingGatesReconciler_Reconcile(t *testing.T) { NewClientBuilder(). WithScheme(scheme.Scheme). WithObjects(tt.objects...). - WithStatusSubresource(&klcv1beta1.KeptnWorkloadVersion{}). - WithIndex(&klcv1beta1.KeptnWorkloadVersion{}, ".spec.resourceReference.uid", func(object client.Object) []string { + WithStatusSubresource(&apilifecycle.KeptnWorkloadVersion{}). + WithIndex(&apilifecycle.KeptnWorkloadVersion{}, ".spec.resourceReference.uid", func(object client.Object) []string { return common.KeptnWorkloadVersionResourceRefUIDIndexFunc(object) }). WithInterceptorFuncs( @@ -298,7 +298,7 @@ func TestSchedulingGatesReconciler_Reconcile(t *testing.T) { Build() for _, obj := range tt.objects { - kwv, ok := obj.(*klcv1beta1.KeptnWorkloadVersion) + kwv, ok := obj.(*apilifecycle.KeptnWorkloadVersion) if ok && kwv.Status.DeploymentStatus != "" { err := mockClient.Status().Update(context.TODO(), kwv) require.Nil(t, err) diff --git a/lifecycle-operator/converter/convert_app.go b/lifecycle-operator/converter/convert_app.go index 1f0f609670..9e23e1deb6 100644 --- a/lifecycle-operator/converter/convert_app.go +++ b/lifecycle-operator/converter/convert_app.go @@ -5,8 +5,8 @@ import ( "log" "os" + apilifecycle "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1" klcv1alpha3 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3" - klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "sigs.k8s.io/yaml" ) @@ -36,12 +36,12 @@ func transformKeptnApp(inputFile, outputFile string) error { return fmt.Errorf("error reading input file: %w", err) } - keptnAppV1beta1, keptnAppContext, err := parseAndTransform(inputContent) + keptnAppV1, keptnAppContext, err := parseAndTransform(inputContent) if err != nil { return err } - outputContent := combineYAML(keptnAppV1beta1, keptnAppContext) + outputContent := combineYAML(keptnAppV1, keptnAppContext) if err := os.WriteFile(outputFile, []byte(outputContent), 0644); err != nil { return fmt.Errorf("error writing to output file: %w", err) } @@ -54,19 +54,19 @@ func parseAndTransform(inputContent []byte) ([]byte, []byte, error) { return nil, nil, fmt.Errorf("error unmarshalling KeptnApp: %w", err) } - var keptnAppV1beta1 klcv1beta1.KeptnApp - if err := yaml.Unmarshal(inputContent, &keptnAppV1beta1); err != nil { - return nil, nil, fmt.Errorf("error unmarshalling KeptnAppV1beta1: %w", err) + var keptnAppV1 apilifecycle.KeptnApp + if err := yaml.Unmarshal(inputContent, &keptnAppV1); err != nil { + return nil, nil, fmt.Errorf("error unmarshalling KeptnAppV1: %w", err) } - addKeptnAnnotation(&keptnAppV1beta1.ObjectMeta) - keptnAppV1beta1.TypeMeta.APIVersion = "lifecycle.keptn.sh/v1beta1" + addKeptnAnnotation(&keptnAppV1.ObjectMeta) + keptnAppV1.TypeMeta.APIVersion = "lifecycle.keptn.sh/v1" keptnAppContext := transformKeptnAppContext(keptnApp) - keptnAppV1beta1YAML, err := yaml.Marshal(keptnAppV1beta1) + keptnAppV1YAML, err := yaml.Marshal(keptnAppV1) if err != nil { - return nil, nil, fmt.Errorf("error marshalling KeptnAppV1beta1 to YAML: %w", err) + return nil, nil, fmt.Errorf("error marshalling KeptnAppV1 to YAML: %w", err) } keptnAppContextYAML, err := yaml.Marshal(keptnAppContext) @@ -74,22 +74,22 @@ func parseAndTransform(inputContent []byte) ([]byte, []byte, error) { return nil, nil, fmt.Errorf("error marshalling KeptnAppContext to YAML: %w", err) } - return keptnAppV1beta1YAML, keptnAppContextYAML, nil + return keptnAppV1YAML, keptnAppContextYAML, nil } -func transformKeptnAppContext(keptnApp klcv1alpha3.KeptnApp) klcv1beta1.KeptnAppContext { - return klcv1beta1.KeptnAppContext{ +func transformKeptnAppContext(keptnApp klcv1alpha3.KeptnApp) apilifecycle.KeptnAppContext { + return apilifecycle.KeptnAppContext{ TypeMeta: metav1.TypeMeta{ Kind: "KeptnAppContext", - APIVersion: "lifecycle.keptn.sh/v1beta1", + APIVersion: "lifecycle.keptn.sh/v1", }, ObjectMeta: metav1.ObjectMeta{ Name: keptnApp.Name, Namespace: keptnApp.Namespace, }, - Spec: klcv1beta1.KeptnAppContextSpec{ - DeploymentTaskSpec: klcv1beta1.DeploymentTaskSpec{ + Spec: apilifecycle.KeptnAppContextSpec{ + DeploymentTaskSpec: apilifecycle.DeploymentTaskSpec{ PreDeploymentTasks: keptnApp.Spec.PreDeploymentTasks, PreDeploymentEvaluations: keptnApp.Spec.PreDeploymentEvaluations, PostDeploymentTasks: keptnApp.Spec.PostDeploymentTasks, @@ -99,8 +99,8 @@ func transformKeptnAppContext(keptnApp klcv1alpha3.KeptnApp) klcv1beta1.KeptnApp } } -func combineYAML(keptnAppV1beta1YAML, keptnAppContextYAML []byte) string { - return fmt.Sprintf("%s\n---\n%s", string(keptnAppV1beta1YAML), string(keptnAppContextYAML)) +func combineYAML(keptnAppV1YAML, keptnAppContextYAML []byte) string { + return fmt.Sprintf("%s\n---\n%s", string(keptnAppV1YAML), string(keptnAppContextYAML)) } func addKeptnAnnotation(resource *metav1.ObjectMeta) { diff --git a/lifecycle-operator/converter/example_output.yaml b/lifecycle-operator/converter/example_output.yaml index 41607eae60..0f85adb191 100644 --- a/lifecycle-operator/converter/example_output.yaml +++ b/lifecycle-operator/converter/example_output.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnApp metadata: annotations: @@ -14,7 +14,7 @@ spec: status: {} --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnAppContext metadata: creationTimestamp: null diff --git a/lifecycle-operator/main.go b/lifecycle-operator/main.go index 4e68b0936b..f14c872d5f 100644 --- a/lifecycle-operator/main.go +++ b/lifecycle-operator/main.go @@ -368,15 +368,15 @@ func main() { } } - if err = (&lifecyclev1beta1.KeptnApp{}).SetupWebhookWithManager(mgr); err != nil { + if err = (&lifecyclev1.KeptnApp{}).SetupWebhookWithManager(mgr); err != nil { setupLog.Error(err, "unable to create webhook", "webhook", "KeptnApp") os.Exit(1) } - if err = (&lifecyclev1beta1.KeptnAppVersion{}).SetupWebhookWithManager(mgr); err != nil { + if err = (&lifecyclev1.KeptnAppVersion{}).SetupWebhookWithManager(mgr); err != nil { setupLog.Error(err, "unable to create webhook", "webhook", "KeptnAppVersion") os.Exit(1) } - if err = (&lifecyclev1beta1.KeptnTaskDefinition{}).SetupWebhookWithManager(mgr); err != nil { + if err = (&lifecyclev1.KeptnTaskDefinition{}).SetupWebhookWithManager(mgr); err != nil { setupLog.Error(err, "unable to create webhook", "webhook", "KeptnTaskDefinition") os.Exit(1) } diff --git a/lifecycle-operator/test/component/app/app_test.go b/lifecycle-operator/test/component/app/app_test.go index 15efa014cd..434a3de999 100644 --- a/lifecycle-operator/test/component/app/app_test.go +++ b/lifecycle-operator/test/component/app/app_test.go @@ -3,7 +3,7 @@ package app_test import ( "fmt" - klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" + apilifecycle "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/test/component/common" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" @@ -25,7 +25,7 @@ var _ = Describe("App", Ordered, func() { }) Describe("Creation of AppVersion from a new App", func() { var ( - instance *klcv1beta1.KeptnApp + instance *apilifecycle.KeptnApp ) BeforeEach(func() { @@ -49,16 +49,16 @@ var _ = Describe("App", Ordered, func() { }) }) -func createInstanceInCluster(name string, namespace string, version string) *klcv1beta1.KeptnApp { - instance := &klcv1beta1.KeptnApp{ +func createInstanceInCluster(name string, namespace string, version string) *apilifecycle.KeptnApp { + instance := &apilifecycle.KeptnApp{ ObjectMeta: metav1.ObjectMeta{ Name: name, Namespace: namespace, Generation: 1, }, - Spec: klcv1beta1.KeptnAppSpec{ + Spec: apilifecycle.KeptnAppSpec{ Version: version, - Workloads: []klcv1beta1.KeptnWorkloadRef{ + Workloads: []apilifecycle.KeptnWorkloadRef{ { Name: "app-wname", Version: "2.0", diff --git a/lifecycle-operator/test/component/appversion/appversion_test.go b/lifecycle-operator/test/component/appversion/appversion_test.go index 03040d2146..4ecb127a22 100644 --- a/lifecycle-operator/test/component/appversion/appversion_test.go +++ b/lifecycle-operator/test/component/appversion/appversion_test.go @@ -5,8 +5,8 @@ import ( "strings" "time" - klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" + apilifecycle "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1/common" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/test/component/common" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" @@ -32,7 +32,7 @@ var _ = Describe("Appversion", Ordered, func() { }) Describe("Creation of AppVersion", func() { var ( - av *klcv1beta1.KeptnAppVersion + av *apilifecycle.KeptnAppVersion ) Context("reconcile a new AppVersions CRD", func() { @@ -40,17 +40,17 @@ var _ = Describe("Appversion", Ordered, func() { }) It("should be deprecated when pre-eval checks failed", func() { - evaluation := &klcv1beta1.KeptnEvaluation{ + evaluation := &apilifecycle.KeptnEvaluation{ ObjectMeta: metav1.ObjectMeta{ Name: "pre-eval-eval-def-appversion", Namespace: namespace, }, - Spec: klcv1beta1.KeptnEvaluationSpec{ + Spec: apilifecycle.KeptnEvaluationSpec{ EvaluationDefinition: "eval-def-appversion", AppName: appName, AppVersion: version, Type: apicommon.PreDeploymentEvaluationCheckType, - FailureConditions: klcv1beta1.FailureConditions{ + FailureConditions: apilifecycle.FailureConditions{ Retries: 10, }, }, @@ -70,10 +70,10 @@ var _ = Describe("Appversion", Ordered, func() { }, evaluation) Expect(err).To(BeNil()) - evaluation.Status = klcv1beta1.KeptnEvaluationStatus{ + evaluation.Status = apilifecycle.KeptnEvaluationStatus{ OverallStatus: apicommon.StateFailed, RetryCount: 10, - EvaluationStatus: map[string]klcv1beta1.EvaluationStatusItem{ + EvaluationStatus: map[string]apilifecycle.EvaluationStatusItem{ "something": { Status: apicommon.StateFailed, Value: "10", @@ -86,18 +86,18 @@ var _ = Describe("Appversion", Ordered, func() { err = k8sClient.Status().Update(ctx, evaluation) Expect(err).To(BeNil()) - av = &klcv1beta1.KeptnAppVersion{ + av = &apilifecycle.KeptnAppVersion{ ObjectMeta: metav1.ObjectMeta{ Name: appName + "-" + version, Namespace: namespace, }, - Spec: klcv1beta1.KeptnAppVersionSpec{ + Spec: apilifecycle.KeptnAppVersionSpec{ AppName: appName, - KeptnAppSpec: klcv1beta1.KeptnAppSpec{ + KeptnAppSpec: apilifecycle.KeptnAppSpec{ Version: version, }, - KeptnAppContextSpec: klcv1beta1.KeptnAppContextSpec{ - DeploymentTaskSpec: klcv1beta1.DeploymentTaskSpec{ + KeptnAppContextSpec: apilifecycle.KeptnAppContextSpec{ + DeploymentTaskSpec: apilifecycle.DeploymentTaskSpec{ PreDeploymentEvaluations: []string{"eval-def-appversion"}, }, }, @@ -109,12 +109,12 @@ var _ = Describe("Appversion", Ordered, func() { time.Sleep(5 * time.Second) - av2 := &klcv1beta1.KeptnAppVersion{} + av2 := &apilifecycle.KeptnAppVersion{} err = k8sClient.Get(ctx, types.NamespacedName{Namespace: av.Namespace, Name: av.Name}, av2) Expect(err).To(BeNil()) Expect(av2).To(Not(BeNil())) - av2.Status = klcv1beta1.KeptnAppVersionStatus{ + av2.Status = apilifecycle.KeptnAppVersionStatus{ PreDeploymentStatus: apicommon.StateSucceeded, PreDeploymentEvaluationStatus: apicommon.StateProgressing, WorkloadOverallStatus: apicommon.StatePending, @@ -122,7 +122,7 @@ var _ = Describe("Appversion", Ordered, func() { PostDeploymentEvaluationStatus: apicommon.StatePending, CurrentPhase: apicommon.PhaseWorkloadPreEvaluation.ShortName, Status: apicommon.StateProgressing, - PreDeploymentEvaluationTaskStatus: []klcv1beta1.ItemStatus{ + PreDeploymentEvaluationTaskStatus: []apilifecycle.ItemStatus{ { Name: "pre-eval-eval-def-appversion", Status: apicommon.StateProgressing, @@ -141,7 +141,7 @@ var _ = Describe("Appversion", Ordered, func() { } //nolint:dupl Eventually(func(g Gomega) { - av := &klcv1beta1.KeptnAppVersion{} + av := &apilifecycle.KeptnAppVersion{} err := k8sClient.Get(ctx, avNameObj, av) g.Expect(err).To(BeNil()) g.Expect(av).To(Not(BeNil())) diff --git a/lifecycle-operator/test/component/common/common.go b/lifecycle-operator/test/component/common/common.go index 96e17e4d30..e4ddf75cca 100644 --- a/lifecycle-operator/test/component/common/common.go +++ b/lifecycle-operator/test/component/common/common.go @@ -8,8 +8,8 @@ import ( "strings" "time" - klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" + apilifecycle "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1/common" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/telemetry" metricsapi "github.com/keptn/lifecycle-toolkit/lifecycle-operator/test/api/metrics/v1" . "github.com/onsi/ginkgo/v2" @@ -99,13 +99,13 @@ func MakeKeptnDefaultNamespace(k8sClient client.Client, name string) *v1.Namespa return ns } -func DeleteAppInCluster(ctx context.Context, k8sClient client.Client, instance *klcv1beta1.KeptnApp) { +func DeleteAppInCluster(ctx context.Context, k8sClient client.Client, instance *apilifecycle.KeptnApp) { By("Cleaning Up KeptnApp CRD ") err := k8sClient.Delete(ctx, instance) LogErrorIfPresent(err) } -func AssertResourceUpdated(ctx context.Context, k8sClient client.Client, instance *klcv1beta1.KeptnApp) *klcv1beta1.KeptnAppVersion { +func AssertResourceUpdated(ctx context.Context, k8sClient client.Client, instance *apilifecycle.KeptnApp) *apilifecycle.KeptnAppVersion { appVersion := GetAppVersion(ctx, k8sClient, instance) @@ -117,13 +117,13 @@ func AssertResourceUpdated(ctx context.Context, k8sClient client.Client, instanc return appVersion } -func GetAppVersion(ctx context.Context, k8sClient client.Client, instance *klcv1beta1.KeptnApp) *klcv1beta1.KeptnAppVersion { +func GetAppVersion(ctx context.Context, k8sClient client.Client, instance *apilifecycle.KeptnApp) *apilifecycle.KeptnAppVersion { appvName := types.NamespacedName{ Namespace: instance.Namespace, Name: instance.GetAppVersionName(), } - appVersion := &klcv1beta1.KeptnAppVersion{} + appVersion := &apilifecycle.KeptnAppVersion{} By("Retrieving Created app version") Eventually(func() error { return k8sClient.Get(ctx, appvName, appVersion) @@ -169,7 +169,7 @@ func InitSuite() (context.Context, ctrl.Manager, *otelsdk.TracerProvider, *sdkte Expect(cfg).NotTo(BeNil()) // +kubebuilder:scaffold:scheme - err = klcv1beta1.AddToScheme(scheme.Scheme) + err = apilifecycle.AddToScheme(scheme.Scheme) Expect(err).NotTo(HaveOccurred()) err = metricsapi.AddToScheme(scheme.Scheme) Expect(err).NotTo(HaveOccurred()) diff --git a/lifecycle-operator/test/component/evaluation/evaluation_test.go b/lifecycle-operator/test/component/evaluation/evaluation_test.go index 73eecdb2a6..c0979d5913 100644 --- a/lifecycle-operator/test/component/evaluation/evaluation_test.go +++ b/lifecycle-operator/test/component/evaluation/evaluation_test.go @@ -5,8 +5,8 @@ import ( "fmt" "time" - klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" + apilifecycle "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1/common" metricsapi "github.com/keptn/lifecycle-toolkit/lifecycle-operator/test/api/metrics/v1" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/test/component/common" . "github.com/onsi/ginkgo/v2" @@ -35,8 +35,8 @@ var _ = Describe("Evaluation", Ordered, func() { Describe("Testing reconcile Evaluation scenario when using KeptnMetric instead of provider directly", func() { var ( - evaluationDefinition *klcv1beta1.KeptnEvaluationDefinition - evaluation *klcv1beta1.KeptnEvaluation + evaluationDefinition *apilifecycle.KeptnEvaluationDefinition + evaluation *apilifecycle.KeptnEvaluation ) Context("With an existing EvaluationDefinition pointing to KeptnMetric", func() { It("KeptnEvaluationController Should succeed, as it finds valid values in KeptnMetric", func() { @@ -66,15 +66,15 @@ var _ = Describe("Evaluation", Ordered, func() { err = k8sClient.Status().Update(context.TODO(), metric2) Expect(err).To(BeNil()) - evaluationdef := &klcv1beta1.KeptnEvaluationDefinition{} + evaluationdef := &apilifecycle.KeptnEvaluationDefinition{} Eventually(func(g Gomega) { err := k8sClient.Get(context.TODO(), types.NamespacedName{ Namespace: namespaceName, Name: evaluationDefinitionName, }, evaluationdef) g.Expect(err).To(BeNil()) - g.Expect(evaluationdef.Spec.Objectives[0]).To(Equal(klcv1beta1.Objective{ - KeptnMetricRef: klcv1beta1.KeptnMetricReference{ + g.Expect(evaluationdef.Spec.Objectives[0]).To(Equal(apilifecycle.Objective{ + KeptnMetricRef: apilifecycle.KeptnMetricReference{ Name: metricName, Namespace: namespaceName, }, @@ -88,7 +88,7 @@ var _ = Describe("Evaluation", Ordered, func() { By("Check that the evaluation passed") - evaluation2 := &klcv1beta1.KeptnEvaluation{} + evaluation2 := &apilifecycle.KeptnEvaluation{} Eventually(func(g Gomega) { err := k8sClient.Get(context.TODO(), types.NamespacedName{ Namespace: namespaceName, @@ -96,7 +96,7 @@ var _ = Describe("Evaluation", Ordered, func() { }, evaluation2) g.Expect(err).To(BeNil()) g.Expect(evaluation2.Status.OverallStatus).To(Equal(apicommon.StateSucceeded)) - g.Expect(evaluation2.Status.EvaluationStatus).To(Equal(map[string]klcv1beta1.EvaluationStatusItem{ + g.Expect(evaluation2.Status.EvaluationStatus).To(Equal(map[string]apilifecycle.EvaluationStatusItem{ metricName: { Value: "5", Status: apicommon.StateSucceeded, @@ -135,15 +135,15 @@ var _ = Describe("Evaluation", Ordered, func() { err = k8sClient.Status().Update(context.TODO(), metric2) Expect(err).To(BeNil()) - evaluationdef := &klcv1beta1.KeptnEvaluationDefinition{} + evaluationdef := &apilifecycle.KeptnEvaluationDefinition{} Eventually(func(g Gomega) { err := k8sClient.Get(context.TODO(), types.NamespacedName{ Namespace: KeptnNamespace, Name: evaluationDefinitionName, }, evaluationdef) g.Expect(err).To(BeNil()) - g.Expect(evaluationdef.Spec.Objectives[0]).To(Equal(klcv1beta1.Objective{ - KeptnMetricRef: klcv1beta1.KeptnMetricReference{ + g.Expect(evaluationdef.Spec.Objectives[0]).To(Equal(apilifecycle.Objective{ + KeptnMetricRef: apilifecycle.KeptnMetricReference{ Name: metricName, Namespace: KeptnNamespace, }, @@ -157,7 +157,7 @@ var _ = Describe("Evaluation", Ordered, func() { By("Check that the evaluation passed") - evaluation2 := &klcv1beta1.KeptnEvaluation{} + evaluation2 := &apilifecycle.KeptnEvaluation{} Eventually(func(g Gomega) { err := k8sClient.Get(context.TODO(), types.NamespacedName{ Namespace: namespaceName, @@ -165,7 +165,7 @@ var _ = Describe("Evaluation", Ordered, func() { }, evaluation2) g.Expect(err).To(BeNil()) g.Expect(evaluation2.Status.OverallStatus).To(Equal(apicommon.StateSucceeded)) - g.Expect(evaluation2.Status.EvaluationStatus).To(Equal(map[string]klcv1beta1.EvaluationStatusItem{ + g.Expect(evaluation2.Status.EvaluationStatus).To(Equal(map[string]apilifecycle.EvaluationStatusItem{ metricName: { Value: "5", Status: apicommon.StateSucceeded, @@ -195,7 +195,7 @@ var _ = Describe("Evaluation", Ordered, func() { By("Check that the evaluation failed") - evaluation2 := &klcv1beta1.KeptnEvaluation{} + evaluation2 := &apilifecycle.KeptnEvaluation{} Eventually(func(g Gomega) { err := k8sClient.Get(context.TODO(), types.NamespacedName{ Namespace: namespaceName, @@ -203,7 +203,7 @@ var _ = Describe("Evaluation", Ordered, func() { }, evaluation2) g.Expect(err).To(BeNil()) g.Expect(evaluation2.Status.OverallStatus).To(Equal(apicommon.StateFailed)) - g.Expect(evaluation2.Status.EvaluationStatus).To(Equal(map[string]klcv1beta1.EvaluationStatusItem{ + g.Expect(evaluation2.Status.EvaluationStatus).To(Equal(map[string]apilifecycle.EvaluationStatusItem{ metricName: { Value: "", Status: apicommon.StateFailed, @@ -226,7 +226,7 @@ var _ = Describe("Evaluation", Ordered, func() { By("Check that the evaluation failed") - evaluation2 := &klcv1beta1.KeptnEvaluation{} + evaluation2 := &apilifecycle.KeptnEvaluation{} Eventually(func(g Gomega) { err := k8sClient.Get(context.TODO(), types.NamespacedName{ Namespace: namespaceName, @@ -234,7 +234,7 @@ var _ = Describe("Evaluation", Ordered, func() { }, evaluation2) g.Expect(err).To(BeNil()) g.Expect(evaluation2.Status.OverallStatus).To(Equal(apicommon.StateFailed)) - g.Expect(evaluation2.Status.EvaluationStatus).To(Equal(map[string]klcv1beta1.EvaluationStatusItem{ + g.Expect(evaluation2.Status.EvaluationStatus).To(Equal(map[string]apilifecycle.EvaluationStatusItem{ metricName: { Value: "", Status: apicommon.StateFailed, @@ -257,23 +257,23 @@ var _ = Describe("Evaluation", Ordered, func() { }) }) -func makeEvaluationDefinition(name string, namespaceName string, objectiveName string) *klcv1beta1.KeptnEvaluationDefinition { - evalDef := &klcv1beta1.KeptnEvaluationDefinition{ +func makeEvaluationDefinition(name string, namespaceName string, objectiveName string) *apilifecycle.KeptnEvaluationDefinition { + evalDef := &apilifecycle.KeptnEvaluationDefinition{ ObjectMeta: metav1.ObjectMeta{ Name: name, Namespace: namespaceName, }, - Spec: klcv1beta1.KeptnEvaluationDefinitionSpec{ - Objectives: []klcv1beta1.Objective{ + Spec: apilifecycle.KeptnEvaluationDefinitionSpec{ + Objectives: []apilifecycle.Objective{ { - KeptnMetricRef: klcv1beta1.KeptnMetricReference{ + KeptnMetricRef: apilifecycle.KeptnMetricReference{ Name: objectiveName, Namespace: namespaceName, }, EvaluationTarget: "<10", }, }, - FailureConditions: klcv1beta1.FailureConditions{ + FailureConditions: apilifecycle.FailureConditions{ Retries: 3, }, }, @@ -306,13 +306,13 @@ func makeKeptnMetric(name string, namespaceName string) *metricsapi.KeptnMetric return metric } -func makeEvaluation(name string, namespaceName string, evaluationDefinition string) *klcv1beta1.KeptnEvaluation { - eval := &klcv1beta1.KeptnEvaluation{ +func makeEvaluation(name string, namespaceName string, evaluationDefinition string) *apilifecycle.KeptnEvaluation { + eval := &apilifecycle.KeptnEvaluation{ ObjectMeta: metav1.ObjectMeta{ Name: name, Namespace: namespaceName, }, - Spec: klcv1beta1.KeptnEvaluationSpec{ + Spec: apilifecycle.KeptnEvaluationSpec{ AppVersion: "1", AppName: "app", EvaluationDefinition: evaluationDefinition, diff --git a/lifecycle-operator/test/component/load/load_test.go b/lifecycle-operator/test/component/load/load_test.go index 6bffce8b50..7ca09e7f73 100644 --- a/lifecycle-operator/test/component/load/load_test.go +++ b/lifecycle-operator/test/component/load/load_test.go @@ -7,7 +7,7 @@ import ( "path" "time" - klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" + apilifecycle "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/test/component/common" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" @@ -23,21 +23,21 @@ const LOAD = 100 var _ = Describe("Load", Ordered, func() { var ( - apps []*klcv1beta1.KeptnApp // Shelf is declared here - appVersions []*klcv1beta1.KeptnAppVersion + apps []*apilifecycle.KeptnApp // Shelf is declared here + appVersions []*apilifecycle.KeptnAppVersion metrics Metric ) BeforeEach(func() { for i := 0; i < LOAD; i++ { - instance := &klcv1beta1.KeptnApp{ + instance := &apilifecycle.KeptnApp{ ObjectMeta: metav1.ObjectMeta{ Name: fmt.Sprintf("app-%d", i), Namespace: "default", }, - Spec: klcv1beta1.KeptnAppSpec{ + Spec: apilifecycle.KeptnAppSpec{ Version: "1.2.3", - Workloads: []klcv1beta1.KeptnWorkloadRef{ + Workloads: []apilifecycle.KeptnWorkloadRef{ { Name: "app-wname", Version: "2.0", diff --git a/lifecycle-operator/test/component/task/task_test.go b/lifecycle-operator/test/component/task/task_test.go index 047deed3f4..232899e3f9 100644 --- a/lifecycle-operator/test/component/task/task_test.go +++ b/lifecycle-operator/test/component/task/task_test.go @@ -3,8 +3,8 @@ package task_test import ( "context" - klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" + apilifecycle "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1/common" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/test/component/common" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" @@ -30,8 +30,8 @@ var _ = Describe("Task", Ordered, func() { Describe("Creation of a Task", func() { var ( - taskDefinition *klcv1beta1.KeptnTaskDefinition - task *klcv1beta1.KeptnTask + taskDefinition *apilifecycle.KeptnTaskDefinition + task *apilifecycle.KeptnTask ) Context("with an existing TaskDefinition", func() { It("should end up in a failed state if the created job fails", func() { @@ -243,8 +243,8 @@ var _ = Describe("Task", Ordered, func() { }) }) -func makeTask(name string, namespace, taskDefinitionName string) *klcv1beta1.KeptnTask { - task := &klcv1beta1.KeptnTask{ +func makeTask(name string, namespace, taskDefinitionName string) *apilifecycle.KeptnTask { + task := &apilifecycle.KeptnTask{ ObjectMeta: metav1.ObjectMeta{ Name: name, Namespace: namespace, @@ -255,8 +255,8 @@ func makeTask(name string, namespace, taskDefinitionName string) *klcv1beta1.Kep "annotation1": "annotation2", }, }, - Spec: klcv1beta1.KeptnTaskSpec{ - Context: klcv1beta1.TaskContext{ + Spec: apilifecycle.KeptnTaskSpec{ + Context: apilifecycle.TaskContext{ WorkloadName: "my-workload", AppName: "my-app", AppVersion: "0.1.0", @@ -271,7 +271,7 @@ func makeTask(name string, namespace, taskDefinitionName string) *klcv1beta1.Kep return task } -func makeTaskDefinition(taskDefinitionName, namespace string) *klcv1beta1.KeptnTaskDefinition { +func makeTaskDefinition(taskDefinitionName, namespace string) *apilifecycle.KeptnTaskDefinition { cmName := "my-cm" cm := &v1.ConfigMap{ ObjectMeta: metav1.ObjectMeta{ @@ -286,14 +286,14 @@ func makeTaskDefinition(taskDefinitionName, namespace string) *klcv1beta1.KeptnT err := k8sClient.Create(context.TODO(), cm) Expect(err).To(BeNil()) - taskDefinition := &klcv1beta1.KeptnTaskDefinition{ + taskDefinition := &apilifecycle.KeptnTaskDefinition{ ObjectMeta: metav1.ObjectMeta{ Name: taskDefinitionName, Namespace: namespace, }, - Spec: klcv1beta1.KeptnTaskDefinitionSpec{ - Deno: &klcv1beta1.RuntimeSpec{ - ConfigMapReference: klcv1beta1.ConfigMapReference{ + Spec: apilifecycle.KeptnTaskDefinitionSpec{ + Deno: &apilifecycle.RuntimeSpec{ + ConfigMapReference: apilifecycle.ConfigMapReference{ Name: cmName, }, }, @@ -318,15 +318,15 @@ func makeTaskDefinition(taskDefinitionName, namespace string) *klcv1beta1.KeptnT return taskDefinition } -func makeContainerTaskDefinition(taskDefinitionName, namespace string) *klcv1beta1.KeptnTaskDefinition { +func makeContainerTaskDefinition(taskDefinitionName, namespace string) *apilifecycle.KeptnTaskDefinition { - taskDefinition := &klcv1beta1.KeptnTaskDefinition{ + taskDefinition := &apilifecycle.KeptnTaskDefinition{ ObjectMeta: metav1.ObjectMeta{ Name: taskDefinitionName, Namespace: namespace, }, - Spec: klcv1beta1.KeptnTaskDefinitionSpec{ - Container: &klcv1beta1.ContainerSpec{ + Spec: apilifecycle.KeptnTaskDefinitionSpec{ + Container: &apilifecycle.ContainerSpec{ Container: &v1.Container{ Name: "test", Image: "busybox:1.36.0", diff --git a/lifecycle-operator/test/component/taskdefinition/taskdefinition_test.go b/lifecycle-operator/test/component/taskdefinition/taskdefinition_test.go index cb6bfe8c18..f03727211d 100644 --- a/lifecycle-operator/test/component/taskdefinition/taskdefinition_test.go +++ b/lifecycle-operator/test/component/taskdefinition/taskdefinition_test.go @@ -3,7 +3,7 @@ package taskdefinition_test import ( "context" - klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" + apilifecycle "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/test/component/common" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" @@ -27,7 +27,7 @@ var _ = Describe("Taskdefinition", Ordered, func() { Describe("Creation of a TaskDefinition", func() { var ( - taskDefinition *klcv1beta1.KeptnTaskDefinition + taskDefinition *apilifecycle.KeptnTaskDefinition configmap *v1.ConfigMap ) Context("Reconcile TaskDefinition", func() { @@ -36,14 +36,14 @@ var _ = Describe("Taskdefinition", Ordered, func() { It("create ConfigMap from inline deno", func() { By("Create TaskDefinition") - taskDefinition = &klcv1beta1.KeptnTaskDefinition{ + taskDefinition = &apilifecycle.KeptnTaskDefinition{ ObjectMeta: metav1.ObjectMeta{ Name: taskDefinitionName, Namespace: namespace, }, - Spec: klcv1beta1.KeptnTaskDefinitionSpec{ - Deno: &klcv1beta1.RuntimeSpec{ - Inline: klcv1beta1.Inline{ + Spec: apilifecycle.KeptnTaskDefinitionSpec{ + Deno: &apilifecycle.RuntimeSpec{ + Inline: apilifecycle.Inline{ Code: "console.log(Hello);", }, }, @@ -68,7 +68,7 @@ var _ = Describe("Taskdefinition", Ordered, func() { By("Check if TaskDefinition was updated") - taskDefinition2 := &klcv1beta1.KeptnTaskDefinition{} + taskDefinition2 := &apilifecycle.KeptnTaskDefinition{} Eventually(func(g Gomega) { err := k8sClient.Get(context.TODO(), types.NamespacedName{ Namespace: namespace, @@ -100,14 +100,14 @@ var _ = Describe("Taskdefinition", Ordered, func() { Expect(err).To(BeNil()) By("Create TaskDefinition") - taskDefinition = &klcv1beta1.KeptnTaskDefinition{ + taskDefinition = &apilifecycle.KeptnTaskDefinition{ ObjectMeta: metav1.ObjectMeta{ Name: taskDefinitionName, Namespace: namespace, }, - Spec: klcv1beta1.KeptnTaskDefinitionSpec{ - Deno: &klcv1beta1.RuntimeSpec{ - ConfigMapReference: klcv1beta1.ConfigMapReference{ + Spec: apilifecycle.KeptnTaskDefinitionSpec{ + Deno: &apilifecycle.RuntimeSpec{ + ConfigMapReference: apilifecycle.ConfigMapReference{ Name: configmap.Name, }, }, @@ -119,7 +119,7 @@ var _ = Describe("Taskdefinition", Ordered, func() { By("Check if TaskDefinition was updated") - taskDefinition2 := &klcv1beta1.KeptnTaskDefinition{} + taskDefinition2 := &apilifecycle.KeptnTaskDefinition{} Eventually(func(g Gomega) { err := k8sClient.Get(context.TODO(), types.NamespacedName{ Namespace: namespace, @@ -151,14 +151,14 @@ var _ = Describe("Taskdefinition", Ordered, func() { Expect(err).To(BeNil()) By("Create TaskDefinition") - taskDefinition = &klcv1beta1.KeptnTaskDefinition{ + taskDefinition = &apilifecycle.KeptnTaskDefinition{ ObjectMeta: metav1.ObjectMeta{ Name: taskDefinitionName, Namespace: namespace, }, - Spec: klcv1beta1.KeptnTaskDefinitionSpec{ - Python: &klcv1beta1.RuntimeSpec{ - ConfigMapReference: klcv1beta1.ConfigMapReference{ + Spec: apilifecycle.KeptnTaskDefinitionSpec{ + Python: &apilifecycle.RuntimeSpec{ + ConfigMapReference: apilifecycle.ConfigMapReference{ Name: configmap.Name, }, }, @@ -170,7 +170,7 @@ var _ = Describe("Taskdefinition", Ordered, func() { By("Check if TaskDefinition was updated") - taskDefinition2 := &klcv1beta1.KeptnTaskDefinition{} + taskDefinition2 := &apilifecycle.KeptnTaskDefinition{} Eventually(func(g Gomega) { err := k8sClient.Get(context.TODO(), types.NamespacedName{ Namespace: namespace, @@ -187,14 +187,14 @@ var _ = Describe("Taskdefinition", Ordered, func() { It("TaskDefinition referencing non-existing Configmap", func() { By("Create TaskDefinition") - taskDefinition = &klcv1beta1.KeptnTaskDefinition{ + taskDefinition = &apilifecycle.KeptnTaskDefinition{ ObjectMeta: metav1.ObjectMeta{ Name: taskDefinitionName, Namespace: namespace, }, - Spec: klcv1beta1.KeptnTaskDefinitionSpec{ - Deno: &klcv1beta1.RuntimeSpec{ - ConfigMapReference: klcv1beta1.ConfigMapReference{ + Spec: apilifecycle.KeptnTaskDefinitionSpec{ + Deno: &apilifecycle.RuntimeSpec{ + ConfigMapReference: apilifecycle.ConfigMapReference{ Name: "my-configmap-non-existing", }, }, @@ -217,7 +217,7 @@ var _ = Describe("Taskdefinition", Ordered, func() { By("Check that TaskDefinition Status was not updated") - taskDefinition2 := &klcv1beta1.KeptnTaskDefinition{} + taskDefinition2 := &apilifecycle.KeptnTaskDefinition{} Eventually(func(g Gomega) { err := k8sClient.Get(context.TODO(), types.NamespacedName{ Namespace: namespace, diff --git a/lifecycle-operator/test/component/workload/workload_test.go b/lifecycle-operator/test/component/workload/workload_test.go index d4ca919427..068247b7dd 100644 --- a/lifecycle-operator/test/component/workload/workload_test.go +++ b/lifecycle-operator/test/component/workload/workload_test.go @@ -4,7 +4,7 @@ import ( "context" "fmt" - klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" + apilifecycle "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/test/component/common" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" @@ -30,8 +30,8 @@ var _ = Describe("Workload", Ordered, func() { }) Describe("Creation of WorkloadVersion from a new Workload", func() { var ( - workload *klcv1beta1.KeptnWorkload - workloadVersion *klcv1beta1.KeptnWorkloadVersion + workload *apilifecycle.KeptnWorkload + workloadVersion *apilifecycle.KeptnWorkloadVersion ) BeforeEach(func() { @@ -42,7 +42,7 @@ var _ = Describe("Workload", Ordered, func() { It("should create WorkloadVersion", func() { By("Check if WorkloadVersion was created") - workloadVersion = &klcv1beta1.KeptnWorkloadVersion{} + workloadVersion = &apilifecycle.KeptnWorkloadVersion{} Eventually(func(g Gomega) { err := k8sClient.Get(context.TODO(), types.NamespacedName{ Namespace: namespace, @@ -68,16 +68,16 @@ var _ = Describe("Workload", Ordered, func() { }) }) -func createWorkloadInCluster(name string, namespace string, version string, applicationName string) *klcv1beta1.KeptnWorkload { - workload := &klcv1beta1.KeptnWorkload{ +func createWorkloadInCluster(name string, namespace string, version string, applicationName string) *apilifecycle.KeptnWorkload { + workload := &apilifecycle.KeptnWorkload{ ObjectMeta: metav1.ObjectMeta{ Name: name, Namespace: namespace, }, - Spec: klcv1beta1.KeptnWorkloadSpec{ + Spec: apilifecycle.KeptnWorkloadSpec{ AppName: applicationName, Version: version, - ResourceReference: klcv1beta1.ResourceReference{UID: types.UID("uid"), Kind: "ReplicaSet", Name: "replicaset1"}, + ResourceReference: apilifecycle.ResourceReference{UID: types.UID("uid"), Kind: "ReplicaSet", Name: "replicaset1"}, }, } By("Invoking Reconciling for Create") diff --git a/lifecycle-operator/test/component/workloadversion/workloadversion_test.go b/lifecycle-operator/test/component/workloadversion/workloadversion_test.go index 3172bddd4a..6418cfe365 100644 --- a/lifecycle-operator/test/component/workloadversion/workloadversion_test.go +++ b/lifecycle-operator/test/component/workloadversion/workloadversion_test.go @@ -5,8 +5,8 @@ import ( "strings" "time" - klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" + apilifecycle "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1/common" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/test/component/common" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" @@ -32,8 +32,8 @@ var _ = Describe("WorkloadVersion", Ordered, func() { }) Describe("Creation of WorkloadVersion", func() { var ( - appVersion *klcv1beta1.KeptnAppVersion - wi *klcv1beta1.KeptnWorkloadVersion + appVersion *apilifecycle.KeptnAppVersion + wi *apilifecycle.KeptnWorkloadVersion ) Context("with a new AppVersions CRD", func() { @@ -44,13 +44,13 @@ var _ = Describe("WorkloadVersion", Ordered, func() { It("should fail if Workload not found in AppVersion", func() { wiName := "not-found" - wi = &klcv1beta1.KeptnWorkloadVersion{ + wi = &apilifecycle.KeptnWorkloadVersion{ ObjectMeta: metav1.ObjectMeta{ Name: appName, Namespace: namespace, }, - Spec: klcv1beta1.KeptnWorkloadVersionSpec{ - KeptnWorkloadSpec: klcv1beta1.KeptnWorkloadSpec{}, + Spec: apilifecycle.KeptnWorkloadVersionSpec{ + KeptnWorkloadSpec: apilifecycle.KeptnWorkloadSpec{}, WorkloadName: appName + "-wname-" + wiName, TraceId: map[string]string{"traceparent": "00-0f89f15e562489e2e171eca1cf9ba958-d2fa6dbbcbf7e29a-01"}, }, @@ -65,7 +65,7 @@ var _ = Describe("WorkloadVersion", Ordered, func() { Name: wi.Name, } Consistently(func(g Gomega) { - wi := &klcv1beta1.KeptnWorkloadVersion{} + wi := &apilifecycle.KeptnWorkloadVersion{} err := k8sClient.Get(ctx, wiNameObj, wi) g.Expect(err).To(BeNil()) g.Expect(wi).To(Not(BeNil())) @@ -101,7 +101,7 @@ var _ = Describe("WorkloadVersion", Ordered, func() { By("Setting the App PreDeploymentEvaluation Status to 'Succeeded'") - av := &klcv1beta1.KeptnAppVersion{} + av := &apilifecycle.KeptnAppVersion{} err = k8sClient.Get(ctx, types.NamespacedName{ Namespace: namespace, Name: appName, @@ -127,14 +127,14 @@ var _ = Describe("WorkloadVersion", Ordered, func() { Expect(err).To(BeNil()) By("Creating a WorkloadVersion that references the StatefulSet") - wi = &klcv1beta1.KeptnWorkloadVersion{ + wi = &apilifecycle.KeptnWorkloadVersion{ ObjectMeta: metav1.ObjectMeta{ Name: appName, Namespace: namespace, }, - Spec: klcv1beta1.KeptnWorkloadVersionSpec{ - KeptnWorkloadSpec: klcv1beta1.KeptnWorkloadSpec{ - ResourceReference: klcv1beta1.ResourceReference{ + Spec: apilifecycle.KeptnWorkloadVersionSpec{ + KeptnWorkloadSpec: apilifecycle.KeptnWorkloadSpec{ + ResourceReference: apilifecycle.ResourceReference{ UID: statefulSet.UID, Kind: "StatefulSet", Name: "my-statefulset", @@ -155,7 +155,7 @@ var _ = Describe("WorkloadVersion", Ordered, func() { Name: wi.Name, } Eventually(func(g Gomega) { - wi := &klcv1beta1.KeptnWorkloadVersion{} + wi := &apilifecycle.KeptnWorkloadVersion{} err := k8sClient.Get(ctx, wiNameObj, wi) g.Expect(err).To(BeNil()) g.Expect(wi.Status.DeploymentStatus).To(Equal(apicommon.StateSucceeded)) @@ -187,7 +187,7 @@ var _ = Describe("WorkloadVersion", Ordered, func() { By("Setting the App PreDeploymentEvaluation Status to 'Succeeded'") - av := &klcv1beta1.KeptnAppVersion{} + av := &apilifecycle.KeptnAppVersion{} err = k8sClient.Get(ctx, types.NamespacedName{ Namespace: namespace, Name: appName, @@ -212,14 +212,14 @@ var _ = Describe("WorkloadVersion", Ordered, func() { Expect(err).To(BeNil()) By("Creating a WorkloadVersion that references the DaemonSet") - wi = &klcv1beta1.KeptnWorkloadVersion{ + wi = &apilifecycle.KeptnWorkloadVersion{ ObjectMeta: metav1.ObjectMeta{ Name: appName, Namespace: namespace, }, - Spec: klcv1beta1.KeptnWorkloadVersionSpec{ - KeptnWorkloadSpec: klcv1beta1.KeptnWorkloadSpec{ - ResourceReference: klcv1beta1.ResourceReference{ + Spec: apilifecycle.KeptnWorkloadVersionSpec{ + KeptnWorkloadSpec: apilifecycle.KeptnWorkloadSpec{ + ResourceReference: apilifecycle.ResourceReference{ UID: daemonSet.UID, Kind: "DaemonSet", Name: "my-daemonset", @@ -240,24 +240,24 @@ var _ = Describe("WorkloadVersion", Ordered, func() { Name: wi.Name, } Eventually(func(g Gomega) { - wi := &klcv1beta1.KeptnWorkloadVersion{} + wi := &apilifecycle.KeptnWorkloadVersion{} err := k8sClient.Get(ctx, wiNameObj, wi) g.Expect(err).To(BeNil()) g.Expect(wi.Status.DeploymentStatus).To(Equal(apicommon.StateSucceeded)) }, "20s").Should(Succeed()) }) It("should be deprecated when pre-eval checks failed", func() { - evaluation := &klcv1beta1.KeptnEvaluation{ + evaluation := &apilifecycle.KeptnEvaluation{ ObjectMeta: metav1.ObjectMeta{ Name: "pre-eval-eval-def", Namespace: namespace, }, - Spec: klcv1beta1.KeptnEvaluationSpec{ + Spec: apilifecycle.KeptnEvaluationSpec{ EvaluationDefinition: "eval-def", Workload: appName + "-wname", WorkloadVersion: "2.0", Type: apicommon.PreDeploymentEvaluationCheckType, - FailureConditions: klcv1beta1.FailureConditions{ + FailureConditions: apilifecycle.FailureConditions{ Retries: 10, }, }, @@ -277,10 +277,10 @@ var _ = Describe("WorkloadVersion", Ordered, func() { }, evaluation) Expect(err).To(BeNil()) - evaluation.Status = klcv1beta1.KeptnEvaluationStatus{ + evaluation.Status = apilifecycle.KeptnEvaluationStatus{ OverallStatus: apicommon.StateFailed, RetryCount: 10, - EvaluationStatus: map[string]klcv1beta1.EvaluationStatusItem{ + EvaluationStatus: map[string]apilifecycle.EvaluationStatusItem{ "something": { Status: apicommon.StateFailed, Value: "10", @@ -293,13 +293,13 @@ var _ = Describe("WorkloadVersion", Ordered, func() { err = k8sClient.Status().Update(ctx, evaluation) Expect(err).To(BeNil()) - wi = &klcv1beta1.KeptnWorkloadVersion{ + wi = &apilifecycle.KeptnWorkloadVersion{ ObjectMeta: metav1.ObjectMeta{ Name: appName + "-wname-2.0", Namespace: namespace, }, - Spec: klcv1beta1.KeptnWorkloadVersionSpec{ - KeptnWorkloadSpec: klcv1beta1.KeptnWorkloadSpec{ + Spec: apilifecycle.KeptnWorkloadVersionSpec{ + KeptnWorkloadSpec: apilifecycle.KeptnWorkloadSpec{ Version: "2.0", AppName: appVersion.GetAppName(), PreDeploymentEvaluations: []string{"eval-def"}, @@ -313,12 +313,12 @@ var _ = Describe("WorkloadVersion", Ordered, func() { time.Sleep(5 * time.Second) - wi2 := &klcv1beta1.KeptnWorkloadVersion{} + wi2 := &apilifecycle.KeptnWorkloadVersion{} err = k8sClient.Get(ctx, types.NamespacedName{Namespace: wi.Namespace, Name: wi.Name}, wi2) Expect(err).To(BeNil()) Expect(wi2).To(Not(BeNil())) - wi2.Status = klcv1beta1.KeptnWorkloadVersionStatus{ + wi2.Status = apilifecycle.KeptnWorkloadVersionStatus{ PreDeploymentStatus: apicommon.StateSucceeded, PreDeploymentEvaluationStatus: apicommon.StateProgressing, DeploymentStatus: apicommon.StatePending, @@ -326,7 +326,7 @@ var _ = Describe("WorkloadVersion", Ordered, func() { PostDeploymentEvaluationStatus: apicommon.StatePending, CurrentPhase: apicommon.PhaseWorkloadPreEvaluation.ShortName, Status: apicommon.StateProgressing, - PreDeploymentEvaluationTaskStatus: []klcv1beta1.ItemStatus{ + PreDeploymentEvaluationTaskStatus: []apilifecycle.ItemStatus{ { Name: "pre-eval-eval-def", Status: apicommon.StateProgressing, @@ -345,7 +345,7 @@ var _ = Describe("WorkloadVersion", Ordered, func() { } //nolint:dupl Eventually(func(g Gomega) { - wi := &klcv1beta1.KeptnWorkloadVersion{} + wi := &apilifecycle.KeptnWorkloadVersion{} err := k8sClient.Get(ctx, wiNameObj, wi) g.Expect(err).To(BeNil()) g.Expect(wi).To(Not(BeNil())) @@ -390,18 +390,18 @@ var _ = Describe("WorkloadVersion", Ordered, func() { }) }) -func createAppVersionInCluster(name string, namespace string, version string) *klcv1beta1.KeptnAppVersion { - instance := &klcv1beta1.KeptnAppVersion{ +func createAppVersionInCluster(name string, namespace string, version string) *apilifecycle.KeptnAppVersion { + instance := &apilifecycle.KeptnAppVersion{ ObjectMeta: metav1.ObjectMeta{ Name: name, Namespace: namespace, Generation: 1, }, - Spec: klcv1beta1.KeptnAppVersionSpec{ + Spec: apilifecycle.KeptnAppVersionSpec{ AppName: name, - KeptnAppSpec: klcv1beta1.KeptnAppSpec{ + KeptnAppSpec: apilifecycle.KeptnAppSpec{ Version: version, - Workloads: []klcv1beta1.KeptnWorkloadRef{ + Workloads: []apilifecycle.KeptnWorkloadRef{ { Name: "wname", Version: "2.0", @@ -414,7 +414,7 @@ func createAppVersionInCluster(name string, namespace string, version string) *k Expect(common.IgnoreAlreadyExists(k8sClient.Create(ctx, instance))).Should(Succeed()) - av := &klcv1beta1.KeptnAppVersion{} + av := &apilifecycle.KeptnAppVersion{} err := k8sClient.Get(ctx, types.NamespacedName{ Namespace: namespace, Name: name, diff --git a/lifecycle-operator/test/e2e/suite_test.go b/lifecycle-operator/test/e2e/suite_test.go index 946ee33696..1dea05a912 100644 --- a/lifecycle-operator/test/e2e/suite_test.go +++ b/lifecycle-operator/test/e2e/suite_test.go @@ -24,7 +24,7 @@ import ( "testing" "time" - klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" + apilifecycle "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1" . "github.com/onsi/ginkgo/v2" "github.com/onsi/ginkgo/v2/types" . "github.com/onsi/gomega" @@ -71,7 +71,7 @@ var _ = BeforeSuite(func() { Expect(err).NotTo(HaveOccurred()) Expect(cfg).NotTo(BeNil()) // +kubebuilder:scaffold:scheme - err = klcv1beta1.AddToScheme(scheme.Scheme) + err = apilifecycle.AddToScheme(scheme.Scheme) Expect(err).NotTo(HaveOccurred()) k8sClient, err = client.New(cfg, client.Options{Scheme: scheme.Scheme}) diff --git a/lifecycle-operator/webhooks/pod_mutator/handlers/appcreationrequest_handler.go b/lifecycle-operator/webhooks/pod_mutator/handlers/appcreationrequest_handler.go index c31e8e7cc9..9d666b1476 100644 --- a/lifecycle-operator/webhooks/pod_mutator/handlers/appcreationrequest_handler.go +++ b/lifecycle-operator/webhooks/pod_mutator/handlers/appcreationrequest_handler.go @@ -5,8 +5,8 @@ import ( "fmt" "github.com/go-logr/logr" - klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" + apilifecycle "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1/common" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/eventsender" "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/propagation" @@ -28,7 +28,7 @@ func (a *AppCreationRequestHandler) Handle(ctx context.Context, pod *corev1.Pod, a.Log.Info("Searching for AppCreationRequest", "appCreationRequest", newAppCreationRequest.Name, "namespace", newAppCreationRequest.Namespace) - appCreationRequest := &klcv1beta1.KeptnAppCreationRequest{} + appCreationRequest := &apilifecycle.KeptnAppCreationRequest{} err := a.Client.Get(ctx, types.NamespacedName{Namespace: namespace, Name: newAppCreationRequest.Name}, appCreationRequest) if errors.IsNotFound(err) { return a.createResource(ctx, newAppCreationRequest) @@ -41,7 +41,7 @@ func (a *AppCreationRequestHandler) Handle(ctx context.Context, pod *corev1.Pod, return nil } -func (a *AppCreationRequestHandler) createResource(ctx context.Context, newAppCreationRequest *klcv1beta1.KeptnAppCreationRequest) error { +func (a *AppCreationRequestHandler) createResource(ctx context.Context, newAppCreationRequest *apilifecycle.KeptnAppCreationRequest) error { a.Log.Info("Creating app creation request", "appCreationRequest", newAppCreationRequest.Name, "namespace", newAppCreationRequest.Namespace) err := a.Client.Create(ctx, newAppCreationRequest) @@ -54,14 +54,14 @@ func (a *AppCreationRequestHandler) createResource(ctx context.Context, newAppCr return nil } -func generateResource(ctx context.Context, pod *corev1.Pod, namespace string) *klcv1beta1.KeptnAppCreationRequest { +func generateResource(ctx context.Context, pod *corev1.Pod, namespace string) *apilifecycle.KeptnAppCreationRequest { // create TraceContext // follow up with a Keptn propagator that JSON-encoded the OTel map into our own key traceContextCarrier := propagation.MapCarrier{} otel.GetTextMapPropagator().Inject(ctx, traceContextCarrier) - kacr := &klcv1beta1.KeptnAppCreationRequest{ + kacr := &apilifecycle.KeptnAppCreationRequest{ ObjectMeta: metav1.ObjectMeta{ Namespace: namespace, Annotations: traceContextCarrier, @@ -80,7 +80,7 @@ func generateResource(ctx context.Context, pod *corev1.Pod, namespace string) *k appName := getAppName(&pod.ObjectMeta) kacr.ObjectMeta.Name = appName - kacr.Spec = klcv1beta1.KeptnAppCreationRequestSpec{ + kacr.Spec = apilifecycle.KeptnAppCreationRequestSpec{ AppName: appName, } diff --git a/lifecycle-operator/webhooks/pod_mutator/handlers/appcreationrequest_handler_test.go b/lifecycle-operator/webhooks/pod_mutator/handlers/appcreationrequest_handler_test.go index 89c7a6a499..7ef618ad61 100644 --- a/lifecycle-operator/webhooks/pod_mutator/handlers/appcreationrequest_handler_test.go +++ b/lifecycle-operator/webhooks/pod_mutator/handlers/appcreationrequest_handler_test.go @@ -7,8 +7,8 @@ import ( "github.com/go-logr/logr" "github.com/go-logr/logr/testr" - klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" + apilifecycle "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1/common" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/eventsender" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/testcommon" "github.com/stretchr/testify/require" @@ -42,10 +42,10 @@ func TestAppHandlerHandle(t *testing.T) { }, }} - singleServiceCreationReq := &klcv1beta1.KeptnAppCreationRequest{ + singleServiceCreationReq := &apilifecycle.KeptnAppCreationRequest{ TypeMeta: metav1.TypeMeta{ Kind: "KeptnAppCreationRequest", - APIVersion: "lifecycle.keptn.sh/v1beta1", + APIVersion: "lifecycle.keptn.sh/v1", }, ObjectMeta: metav1.ObjectMeta{ Name: TestWorkload, @@ -55,7 +55,7 @@ func TestAppHandlerHandle(t *testing.T) { "keptn.sh/app-type": "single-service", }, }, - Spec: klcv1beta1.KeptnAppCreationRequestSpec{AppName: TestWorkload}, + Spec: apilifecycle.KeptnAppCreationRequestSpec{AppName: TestWorkload}, } tests := []struct { @@ -63,7 +63,7 @@ func TestAppHandlerHandle(t *testing.T) { client client.Client pod *corev1.Pod wanterr error - wantReq *klcv1beta1.KeptnAppCreationRequest + wantReq *apilifecycle.KeptnAppCreationRequest }{ { name: "Create AppCreationRequest inherit from workload", @@ -90,17 +90,17 @@ func TestAppHandlerHandle(t *testing.T) { }, }}, client: testcommon.NewTestClient(), - wantReq: &klcv1beta1.KeptnAppCreationRequest{ + wantReq: &apilifecycle.KeptnAppCreationRequest{ TypeMeta: metav1.TypeMeta{ Kind: "KeptnAppCreationRequest", - APIVersion: "lifecycle.keptn.sh/v1beta1", + APIVersion: "lifecycle.keptn.sh/v1", }, ObjectMeta: metav1.ObjectMeta{ Name: testApp, Namespace: namespace, ResourceVersion: "1", }, - Spec: klcv1beta1.KeptnAppCreationRequestSpec{AppName: testApp}, + Spec: apilifecycle.KeptnAppCreationRequestSpec{AppName: testApp}, }, }, { @@ -142,7 +142,7 @@ func TestAppHandlerHandle(t *testing.T) { } if tt.wantReq != nil { - creationReq := &klcv1beta1.KeptnAppCreationRequest{} + creationReq := &apilifecycle.KeptnAppCreationRequest{} err = tt.client.Get(context.TODO(), types.NamespacedName{Name: tt.wantReq.Name, Namespace: tt.wantReq.Namespace}, creationReq) require.Nil(t, err) require.Equal(t, tt.wantReq, creationReq) @@ -165,13 +165,13 @@ func TestAppHandlerCreateAppSucceeds(t *testing.T) { ctx := context.TODO() name := "myappcreationreq" - newAppCreationRequest := &klcv1beta1.KeptnAppCreationRequest{ + newAppCreationRequest := &apilifecycle.KeptnAppCreationRequest{ ObjectMeta: metav1.ObjectMeta{Name: name}, } err := appHandler.createResource(ctx, newAppCreationRequest) require.Nil(t, err) - creationReq := &klcv1beta1.KeptnAppCreationRequest{} + creationReq := &apilifecycle.KeptnAppCreationRequest{} err = fakeClient.Get(ctx, types.NamespacedName{Name: name}, creationReq) require.Nil(t, err) @@ -189,7 +189,7 @@ func TestAppHandlerCreateAppFails(t *testing.T) { } ctx := context.TODO() - newAppCreationRequest := &klcv1beta1.KeptnAppCreationRequest{ + newAppCreationRequest := &apilifecycle.KeptnAppCreationRequest{ ObjectMeta: metav1.ObjectMeta{}, } err := appHandler.createResource(ctx, newAppCreationRequest) diff --git a/lifecycle-operator/webhooks/pod_mutator/handlers/objectmeta.go b/lifecycle-operator/webhooks/pod_mutator/handlers/objectmeta.go index 15b3080637..b0c40db9db 100644 --- a/lifecycle-operator/webhooks/pod_mutator/handlers/objectmeta.go +++ b/lifecycle-operator/webhooks/pod_mutator/handlers/objectmeta.go @@ -5,7 +5,7 @@ import ( "hash/fnv" "strings" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1/common" operatorcommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/common" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/lifecycle-operator/webhooks/pod_mutator/handlers/objectmeta_test.go b/lifecycle-operator/webhooks/pod_mutator/handlers/objectmeta_test.go index 0c930bfab3..1559a32384 100644 --- a/lifecycle-operator/webhooks/pod_mutator/handlers/objectmeta_test.go +++ b/lifecycle-operator/webhooks/pod_mutator/handlers/objectmeta_test.go @@ -4,7 +4,7 @@ import ( "reflect" "testing" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1/common" "github.com/stretchr/testify/require" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/lifecycle-operator/webhooks/pod_mutator/handlers/pod_annotation.go b/lifecycle-operator/webhooks/pod_mutator/handlers/pod_annotation.go index ab8a8814dc..29ec81b090 100644 --- a/lifecycle-operator/webhooks/pod_mutator/handlers/pod_annotation.go +++ b/lifecycle-operator/webhooks/pod_mutator/handlers/pod_annotation.go @@ -6,7 +6,7 @@ import ( argov1alpha1 "github.com/argoproj/argo-rollouts/pkg/apis/rollouts/v1alpha1" "github.com/go-logr/logr" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1/common" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/lifecycle-operator/webhooks/pod_mutator/handlers/pod_annotation_test.go b/lifecycle-operator/webhooks/pod_mutator/handlers/pod_annotation_test.go index bdbcd13361..1eac1e25a3 100644 --- a/lifecycle-operator/webhooks/pod_mutator/handlers/pod_annotation_test.go +++ b/lifecycle-operator/webhooks/pod_mutator/handlers/pod_annotation_test.go @@ -6,7 +6,7 @@ import ( "github.com/go-logr/logr" "github.com/go-logr/logr/testr" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1/common" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/testcommon" "github.com/stretchr/testify/require" admissionv1 "k8s.io/api/admission/v1" diff --git a/lifecycle-operator/webhooks/pod_mutator/handlers/workload.go b/lifecycle-operator/webhooks/pod_mutator/handlers/workload.go index cf2f483dfc..be4f8ff2aa 100644 --- a/lifecycle-operator/webhooks/pod_mutator/handlers/workload.go +++ b/lifecycle-operator/webhooks/pod_mutator/handlers/workload.go @@ -7,8 +7,8 @@ import ( "strings" "github.com/go-logr/logr" - klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" + apilifecycle "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1/common" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/eventsender" "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/propagation" @@ -31,7 +31,7 @@ func (a *WorkloadHandler) Handle(ctx context.Context, pod *corev1.Pod, namespace a.Log.Info("Searching for workload") - workload := &klcv1beta1.KeptnWorkload{} + workload := &apilifecycle.KeptnWorkload{} err := a.Client.Get(ctx, types.NamespacedName{Namespace: namespace, Name: newWorkload.Name}, workload) if errors.IsNotFound(err) { return a.createWorkload(ctx, newWorkload) @@ -44,7 +44,7 @@ func (a *WorkloadHandler) Handle(ctx context.Context, pod *corev1.Pod, namespace return a.updateWorkload(ctx, workload, newWorkload) } -func (a *WorkloadHandler) updateWorkload(ctx context.Context, workload *klcv1beta1.KeptnWorkload, newWorkload *klcv1beta1.KeptnWorkload) error { +func (a *WorkloadHandler) updateWorkload(ctx context.Context, workload *apilifecycle.KeptnWorkload, newWorkload *apilifecycle.KeptnWorkload) error { if reflect.DeepEqual(workload.Spec, newWorkload.Spec) { a.Log.Info("Pod not changed, not updating anything") return nil @@ -63,7 +63,7 @@ func (a *WorkloadHandler) updateWorkload(ctx context.Context, workload *klcv1bet return nil } -func (a *WorkloadHandler) createWorkload(ctx context.Context, newWorkload *klcv1beta1.KeptnWorkload) error { +func (a *WorkloadHandler) createWorkload(ctx context.Context, newWorkload *apilifecycle.KeptnWorkload) error { a.Log.Info("Creating workload", "workload", newWorkload.Name) err := a.Client.Create(ctx, newWorkload) if err != nil { @@ -75,7 +75,7 @@ func (a *WorkloadHandler) createWorkload(ctx context.Context, newWorkload *klcv1 return nil } -func generateWorkload(ctx context.Context, pod *corev1.Pod, namespace string) *klcv1beta1.KeptnWorkload { +func generateWorkload(ctx context.Context, pod *corev1.Pod, namespace string) *apilifecycle.KeptnWorkload { version, _ := GetLabelOrAnnotation(&pod.ObjectMeta, apicommon.VersionAnnotation, apicommon.K8sRecommendedVersionAnnotations) version = strings.ToLower(version) preDeploymentTasks := getValuesForAnnotations(&pod.ObjectMeta, apicommon.PreDeploymentTaskAnnotation) @@ -90,7 +90,7 @@ func generateWorkload(ctx context.Context, pod *corev1.Pod, namespace string) *k ownerRef := GetOwnerReference(&pod.ObjectMeta) - return &klcv1beta1.KeptnWorkload{ + return &apilifecycle.KeptnWorkload{ ObjectMeta: metav1.ObjectMeta{ Name: getWorkloadName(&pod.ObjectMeta, applicationName), Namespace: namespace, @@ -99,10 +99,10 @@ func generateWorkload(ctx context.Context, pod *corev1.Pod, namespace string) *k ownerRef, }, }, - Spec: klcv1beta1.KeptnWorkloadSpec{ + Spec: apilifecycle.KeptnWorkloadSpec{ AppName: applicationName, Version: version, - ResourceReference: klcv1beta1.ResourceReference{UID: ownerRef.UID, Kind: ownerRef.Kind, Name: ownerRef.Name}, + ResourceReference: apilifecycle.ResourceReference{UID: ownerRef.UID, Kind: ownerRef.Kind, Name: ownerRef.Name}, PreDeploymentTasks: preDeploymentTasks, PostDeploymentTasks: postDeploymentTasks, PreDeploymentEvaluations: preDeploymentEvaluation, diff --git a/lifecycle-operator/webhooks/pod_mutator/handlers/workload_test.go b/lifecycle-operator/webhooks/pod_mutator/handlers/workload_test.go index ae5d0b4937..0c22f07232 100644 --- a/lifecycle-operator/webhooks/pod_mutator/handlers/workload_test.go +++ b/lifecycle-operator/webhooks/pod_mutator/handlers/workload_test.go @@ -6,8 +6,8 @@ import ( "testing" "github.com/go-logr/logr/testr" - klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" + apilifecycle "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1/common" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/eventsender" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/testcommon" "github.com/pkg/errors" @@ -32,15 +32,15 @@ func TestHandle(t *testing.T) { mockEventSender := eventsender.NewK8sSender(record.NewFakeRecorder(100)) log := testr.New(t) - workload := &klcv1beta1.KeptnWorkload{ + workload := &apilifecycle.KeptnWorkload{ ObjectMeta: metav1.ObjectMeta{ Name: "my-workload-my-workload", Namespace: namespace, }, } - wantWorkload := &klcv1beta1.KeptnWorkload{ - TypeMeta: metav1.TypeMeta{Kind: "KeptnWorkload", APIVersion: "lifecycle.keptn.sh/v1beta1"}, + wantWorkload := &apilifecycle.KeptnWorkload{ + TypeMeta: metav1.TypeMeta{Kind: "KeptnWorkload", APIVersion: "lifecycle.keptn.sh/v1"}, ObjectMeta: metav1.ObjectMeta{ Name: testAppWorkload, Namespace: namespace, @@ -49,7 +49,7 @@ func TestHandle(t *testing.T) { }, ResourceVersion: "1", }, - Spec: klcv1beta1.KeptnWorkloadSpec{ + Spec: apilifecycle.KeptnWorkloadSpec{ AppName: TestWorkload, Version: "0.1", Metadata: map[string]string{ @@ -75,7 +75,7 @@ func TestHandle(t *testing.T) { client client.Client pod *corev1.Pod wanterr error - wantWorkload *klcv1beta1.KeptnWorkload + wantWorkload *apilifecycle.KeptnWorkload }{ { name: "Create Workload", @@ -138,7 +138,7 @@ func TestHandle(t *testing.T) { } if tt.wantWorkload != nil { - actualWorkload := &klcv1beta1.KeptnWorkload{} + actualWorkload := &apilifecycle.KeptnWorkload{} err = tt.client.Get(context.TODO(), types.NamespacedName{Name: tt.wantWorkload.Name, Namespace: tt.wantWorkload.Namespace}, actualWorkload) require.Nil(t, err) require.Equal(t, tt.wantWorkload, actualWorkload) @@ -152,7 +152,7 @@ func TestUpdateWorkloadNoSpecChanges(t *testing.T) { mockEventSender := eventsender.NewK8sSender(record.NewFakeRecorder(100)) log := testr.New(t) - workload := &klcv1beta1.KeptnWorkload{ + workload := &apilifecycle.KeptnWorkload{ ObjectMeta: metav1.ObjectMeta{ Name: testAppWorkload, Namespace: namespace, @@ -172,7 +172,7 @@ func TestGenerateWorkload(t *testing.T) { testCases := []struct { name string podAnnotations map[string]string - expected *klcv1beta1.KeptnWorkload + expected *apilifecycle.KeptnWorkload }{ { name: "Pod with annotations", @@ -184,7 +184,7 @@ func TestGenerateWorkload(t *testing.T) { apicommon.PostDeploymentEvaluationAnnotation: "eval3,eval4", apicommon.K8sRecommendedAppAnnotations: "my-app", }, - expected: &klcv1beta1.KeptnWorkload{ + expected: &apilifecycle.KeptnWorkload{ ObjectMeta: metav1.ObjectMeta{ Name: getWorkloadName(&metav1.ObjectMeta{}, "my-app"), Namespace: "my-namespace", @@ -198,10 +198,10 @@ func TestGenerateWorkload(t *testing.T) { }, }, }, - Spec: klcv1beta1.KeptnWorkloadSpec{ + Spec: apilifecycle.KeptnWorkloadSpec{ AppName: "my-app", Version: "v1", - ResourceReference: klcv1beta1.ResourceReference{UID: "owner-uid", Kind: "Deployment", Name: "deployment-1"}, + ResourceReference: apilifecycle.ResourceReference{UID: "owner-uid", Kind: "Deployment", Name: "deployment-1"}, PreDeploymentTasks: []string{"task1", "task2"}, PostDeploymentTasks: []string{"task3", "task4"}, PreDeploymentEvaluations: []string{"eval1", "eval2"}, @@ -213,7 +213,7 @@ func TestGenerateWorkload(t *testing.T) { { name: "Pod with no annotations", podAnnotations: nil, - expected: &klcv1beta1.KeptnWorkload{ + expected: &apilifecycle.KeptnWorkload{ ObjectMeta: metav1.ObjectMeta{ Name: "-", Namespace: "my-namespace", @@ -225,8 +225,8 @@ func TestGenerateWorkload(t *testing.T) { UID: "owner-uid", }, }}, - Spec: klcv1beta1.KeptnWorkloadSpec{ - ResourceReference: klcv1beta1.ResourceReference{ + Spec: apilifecycle.KeptnWorkloadSpec{ + ResourceReference: apilifecycle.ResourceReference{ UID: "owner-uid", Kind: "Deployment", Name: "deployment-1", diff --git a/lifecycle-operator/webhooks/pod_mutator/pod_mutating_webhook.go b/lifecycle-operator/webhooks/pod_mutator/pod_mutating_webhook.go index 50c4efb116..2233a08746 100644 --- a/lifecycle-operator/webhooks/pod_mutator/pod_mutating_webhook.go +++ b/lifecycle-operator/webhooks/pod_mutator/pod_mutating_webhook.go @@ -7,7 +7,7 @@ import ( "net/http" "github.com/go-logr/logr" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1/common" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/eventsender" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/webhooks/pod_mutator/handlers" corev1 "k8s.io/api/core/v1" diff --git a/lifecycle-operator/webhooks/pod_mutator/pod_mutating_webhook_test.go b/lifecycle-operator/webhooks/pod_mutator/pod_mutating_webhook_test.go index 5e9291491c..9c490cc074 100644 --- a/lifecycle-operator/webhooks/pod_mutator/pod_mutating_webhook_test.go +++ b/lifecycle-operator/webhooks/pod_mutator/pod_mutating_webhook_test.go @@ -8,8 +8,8 @@ import ( "testing" "github.com/go-logr/logr/testr" - klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" + apilifecycle "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1/common" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/eventsender" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/testcommon" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/webhooks/pod_mutator/handlers" @@ -132,7 +132,7 @@ func TestPodMutatingWebhookHandleUnsupportedOwner(t *testing.T) { require.True(t, resp.Allowed) // if we get an unsupported owner for the pod, we expect not to have any Keptn resources to have been created - kacr := &klcv1beta1.KeptnAppCreationRequest{} + kacr := &apilifecycle.KeptnAppCreationRequest{} err := fakeClient.Get(context.Background(), types.NamespacedName{ Namespace: testNamespace, @@ -142,7 +142,7 @@ func TestPodMutatingWebhookHandleUnsupportedOwner(t *testing.T) { require.NotNil(t, err) require.True(t, k8serrors.IsNotFound(err)) - workload := &klcv1beta1.KeptnWorkload{} + workload := &apilifecycle.KeptnWorkload{} err = fakeClient.Get(context.TODO(), types.NamespacedName{ Namespace: testNamespace, @@ -204,7 +204,7 @@ func TestPodMutatingWebhookHandleSingleService(t *testing.T) { require.NotNil(t, resp) require.True(t, resp.Allowed) - kacr := &klcv1beta1.KeptnAppCreationRequest{} + kacr := &apilifecycle.KeptnAppCreationRequest{} err := fakeClient.Get(context.Background(), types.NamespacedName{ Namespace: testNamespace, @@ -216,7 +216,7 @@ func TestPodMutatingWebhookHandleSingleService(t *testing.T) { require.Equal(t, testWorkload, kacr.Spec.AppName) require.Equal(t, string(apicommon.AppTypeSingleService), kacr.Annotations[apicommon.AppTypeAnnotation]) - workload := &klcv1beta1.KeptnWorkload{} + workload := &apilifecycle.KeptnWorkload{} err = fakeClient.Get(context.TODO(), types.NamespacedName{ Namespace: testNamespace, @@ -225,10 +225,10 @@ func TestPodMutatingWebhookHandleSingleService(t *testing.T) { require.Nil(t, err) - require.Equal(t, klcv1beta1.KeptnWorkloadSpec{ + require.Equal(t, apilifecycle.KeptnWorkloadSpec{ AppName: kacr.Spec.AppName, Version: "0.1", - ResourceReference: klcv1beta1.ResourceReference{ + ResourceReference: apilifecycle.ResourceReference{ UID: "1234", Kind: "Deployment", Name: testDeployment, @@ -356,7 +356,7 @@ func TestPodMutatingWebhookHandleSchedulingGates(t *testing.T) { require.Equal(t, expectedValue, resp.Patches[1].Value) } - kacr := &klcv1beta1.KeptnAppCreationRequest{} + kacr := &apilifecycle.KeptnAppCreationRequest{} err := fakeClient.Get(context.Background(), types.NamespacedName{ Namespace: testNamespace, @@ -368,7 +368,7 @@ func TestPodMutatingWebhookHandleSchedulingGates(t *testing.T) { require.Equal(t, testWorkload, kacr.Spec.AppName) require.Equal(t, string(apicommon.AppTypeSingleService), kacr.Annotations[apicommon.AppTypeAnnotation]) - workload := &klcv1beta1.KeptnWorkload{} + workload := &apilifecycle.KeptnWorkload{} err = fakeClient.Get(context.TODO(), types.NamespacedName{ Namespace: testNamespace, @@ -377,10 +377,10 @@ func TestPodMutatingWebhookHandleSchedulingGates(t *testing.T) { require.Nil(t, err) - require.Equal(t, klcv1beta1.KeptnWorkloadSpec{ + require.Equal(t, apilifecycle.KeptnWorkloadSpec{ AppName: kacr.Spec.AppName, Version: "0.1", - ResourceReference: klcv1beta1.ResourceReference{ + ResourceReference: apilifecycle.ResourceReference{ UID: "1234", Kind: "Deployment", Name: testDeployment, @@ -396,7 +396,7 @@ func TestPodMutatingWebhookHandleSingleServiceAppCreationRequestAlreadyPresent(t apicommon.NamespaceEnabledAnnotation: "enabled", }, }, - }, &klcv1beta1.KeptnAppCreationRequest{ + }, &apilifecycle.KeptnAppCreationRequest{ TypeMeta: metav1.TypeMeta{}, ObjectMeta: metav1.ObjectMeta{ Name: testWorkload, @@ -408,7 +408,7 @@ func TestPodMutatingWebhookHandleSingleServiceAppCreationRequestAlreadyPresent(t "donotchange": "true", }, }, - Spec: klcv1beta1.KeptnAppCreationRequestSpec{ + Spec: apilifecycle.KeptnAppCreationRequestSpec{ AppName: testWorkload, }, }) @@ -453,7 +453,7 @@ func TestPodMutatingWebhookHandleSingleServiceAppCreationRequestAlreadyPresent(t require.NotNil(t, resp) require.True(t, resp.Allowed) - kacr := &klcv1beta1.KeptnAppCreationRequest{} + kacr := &apilifecycle.KeptnAppCreationRequest{} err := fakeClient.Get(context.Background(), types.NamespacedName{ Namespace: testNamespace, @@ -467,7 +467,7 @@ func TestPodMutatingWebhookHandleSingleServiceAppCreationRequestAlreadyPresent(t // verify that the previously created KACR has not been changed require.Equal(t, "true", kacr.Labels["donotchange"]) - workload := &klcv1beta1.KeptnWorkload{} + workload := &apilifecycle.KeptnWorkload{} err = fakeClient.Get(context.TODO(), types.NamespacedName{ Namespace: testNamespace, @@ -476,10 +476,10 @@ func TestPodMutatingWebhookHandleSingleServiceAppCreationRequestAlreadyPresent(t require.Nil(t, err) - require.Equal(t, klcv1beta1.KeptnWorkloadSpec{ + require.Equal(t, apilifecycle.KeptnWorkloadSpec{ AppName: kacr.Spec.AppName, Version: "0.1", - ResourceReference: klcv1beta1.ResourceReference{ + ResourceReference: apilifecycle.ResourceReference{ UID: "1234", Kind: "Deployment", Name: testDeployment, @@ -510,7 +510,7 @@ func TestPodMutatingWebhookHandleMultiService(t *testing.T) { require.NotNil(t, resp) require.True(t, resp.Allowed) - kacr := &klcv1beta1.KeptnAppCreationRequest{} + kacr := &apilifecycle.KeptnAppCreationRequest{} err := fakeClient.Get(context.Background(), types.NamespacedName{ Namespace: testNamespace, @@ -523,7 +523,7 @@ func TestPodMutatingWebhookHandleMultiService(t *testing.T) { // here we do not want a single-service annotation require.Empty(t, kacr.Annotations[apicommon.AppTypeAnnotation]) - workload := &klcv1beta1.KeptnWorkload{} + workload := &apilifecycle.KeptnWorkload{} err = fakeClient.Get(context.TODO(), types.NamespacedName{ Namespace: testNamespace, @@ -532,10 +532,10 @@ func TestPodMutatingWebhookHandleMultiService(t *testing.T) { require.Nil(t, err) - require.Equal(t, klcv1beta1.KeptnWorkloadSpec{ + require.Equal(t, apilifecycle.KeptnWorkloadSpec{ AppName: kacr.Spec.AppName, Version: "v0.1", - ResourceReference: klcv1beta1.ResourceReference{ + ResourceReference: apilifecycle.ResourceReference{ UID: "1234", Kind: "Deployment", Name: testDeployment, diff --git a/test/chainsaw/allowed-namespaces/simple-deployment-allowed/00-install.yaml b/test/chainsaw/allowed-namespaces/simple-deployment-allowed/00-install.yaml index fdc1df9f90..f0c132ec17 100644 --- a/test/chainsaw/allowed-namespaces/simple-deployment-allowed/00-install.yaml +++ b/test/chainsaw/allowed-namespaces/simple-deployment-allowed/00-install.yaml @@ -6,7 +6,7 @@ metadata: annotations: keptn.sh/lifecycle-toolkit: enabled --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnTaskDefinition metadata: name: pre-deployment-hello diff --git a/test/chainsaw/allowed-namespaces/simple-deployment-allowed/01-assert.yaml b/test/chainsaw/allowed-namespaces/simple-deployment-allowed/01-assert.yaml index 53cb97ffe2..1c4df589f2 100644 --- a/test/chainsaw/allowed-namespaces/simple-deployment-allowed/01-assert.yaml +++ b/test/chainsaw/allowed-namespaces/simple-deployment-allowed/01-assert.yaml @@ -1,10 +1,10 @@ -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnWorkload metadata: name: waiter-waiter namespace: allowed-ns-test --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnWorkloadVersion metadata: name: waiter-waiter-0.4 diff --git a/test/chainsaw/allowed-namespaces/simple-deployment-not-allowed/00-install.yaml b/test/chainsaw/allowed-namespaces/simple-deployment-not-allowed/00-install.yaml index c42edf21e9..2a6a53b803 100644 --- a/test/chainsaw/allowed-namespaces/simple-deployment-not-allowed/00-install.yaml +++ b/test/chainsaw/allowed-namespaces/simple-deployment-not-allowed/00-install.yaml @@ -6,7 +6,7 @@ metadata: annotations: keptn.sh/lifecycle-toolkit: enabled --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnTaskDefinition metadata: name: pre-deployment-hello diff --git a/test/chainsaw/allowed-namespaces/simple-deployment-not-allowed/chainsaw-test.yaml b/test/chainsaw/allowed-namespaces/simple-deployment-not-allowed/chainsaw-test.yaml index a7864e4228..e795c0f6e8 100755 --- a/test/chainsaw/allowed-namespaces/simple-deployment-not-allowed/chainsaw-test.yaml +++ b/test/chainsaw/allowed-namespaces/simple-deployment-not-allowed/chainsaw-test.yaml @@ -17,19 +17,19 @@ spec: # we expect none of these resources to be present - error: resource: - apiVersion: lifecycle.keptn.sh/v1beta1 + apiVersion: lifecycle.keptn.sh/v1 kind: KeptnTask metadata: namespace: not-allowed-ns-test - error: resource: - apiVersion: lifecycle.keptn.sh/v1beta1 + apiVersion: lifecycle.keptn.sh/v1 kind: KeptnWorkload metadata: namespace: not-allowed-ns-test - error: resource: - apiVersion: lifecycle.keptn.sh/v1beta1 + apiVersion: lifecycle.keptn.sh/v1 kind: KeptnApp metadata: namespace: not-allowed-ns-test diff --git a/test/chainsaw/integration/TTLSecondsAfterFinished-in-jobs/00-install.yaml b/test/chainsaw/integration/TTLSecondsAfterFinished-in-jobs/00-install.yaml index eec46d4b7d..9a7e553458 100644 --- a/test/chainsaw/integration/TTLSecondsAfterFinished-in-jobs/00-install.yaml +++ b/test/chainsaw/integration/TTLSecondsAfterFinished-in-jobs/00-install.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnTaskDefinition metadata: name: ttlsecondsafterfinished-task @@ -13,7 +13,7 @@ spec: args: - 'hello world' --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnTask metadata: name: ttlsecondstask-job diff --git a/test/chainsaw/integration/api-conversion-v1beta1-to-v1alpha/00-assert.yaml b/test/chainsaw/integration/api-conversion-v1-to-v1alpha/00-assert.yaml similarity index 100% rename from test/chainsaw/integration/api-conversion-v1beta1-to-v1alpha/00-assert.yaml rename to test/chainsaw/integration/api-conversion-v1-to-v1alpha/00-assert.yaml diff --git a/test/chainsaw/integration/api-conversion-v1beta1-to-v1alpha/00-install.yaml b/test/chainsaw/integration/api-conversion-v1-to-v1alpha/00-install.yaml similarity index 85% rename from test/chainsaw/integration/api-conversion-v1beta1-to-v1alpha/00-install.yaml rename to test/chainsaw/integration/api-conversion-v1-to-v1alpha/00-install.yaml index 41b6c2c786..863338cd77 100644 --- a/test/chainsaw/integration/api-conversion-v1beta1-to-v1alpha/00-install.yaml +++ b/test/chainsaw/integration/api-conversion-v1-to-v1alpha/00-install.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnApp metadata: name: "some-keptn-app2" @@ -6,7 +6,7 @@ spec: version: "1.2.3" revision: 123 --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnAppVersion metadata: name: "some-keptn-app-version-2" @@ -23,7 +23,7 @@ spec: - name: some-keptn-app2 version: 0.2.7 --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnWorkload metadata: name: some-keptn-app2 @@ -39,7 +39,7 @@ spec: name: my-replica-set uid: 957f825e-4025-4ea8-ad22-9292877ff7eb --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnWorkloadVersion metadata: name: some-keptn-app-2-0.1.0 @@ -58,14 +58,14 @@ spec: name: my-replica-set uid: 957f825e-4025-4ea8-ad22-9292877ff7eb --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnAppCreationRequest metadata: name: some-keptn-app2 spec: appName: podtato-head --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnTaskDefinition metadata: name: some-keptn-app-version-2-task @@ -75,7 +75,7 @@ spec: code: | console.log("Okay") --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnTask metadata: name: some-keptn-app-version-2 @@ -89,7 +89,7 @@ spec: workloadName: "some-keptn-app2" workloadVersion: "0.2.7" --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnEvaluationDefinition metadata: name: some-keptn-app-version-2 @@ -99,7 +99,7 @@ spec: keptnMetricRef: name: available-cpus --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnEvaluation metadata: name: some-keptn-app-version-2 diff --git a/test/chainsaw/integration/api-conversion-v1alpha-to-v1beta1/chainsaw-test.yaml b/test/chainsaw/integration/api-conversion-v1-to-v1alpha/chainsaw-test.yaml similarity index 89% rename from test/chainsaw/integration/api-conversion-v1alpha-to-v1beta1/chainsaw-test.yaml rename to test/chainsaw/integration/api-conversion-v1-to-v1alpha/chainsaw-test.yaml index 33af77305c..9940adc0b0 100755 --- a/test/chainsaw/integration/api-conversion-v1alpha-to-v1beta1/chainsaw-test.yaml +++ b/test/chainsaw/integration/api-conversion-v1-to-v1alpha/chainsaw-test.yaml @@ -2,7 +2,7 @@ apiVersion: chainsaw.kyverno.io/v1alpha1 kind: Test metadata: - name: api-conversion-v1alpha-to-v1beta1 + name: api-conversion-v1-to-v1alpha spec: steps: - name: step-00 diff --git a/test/chainsaw/integration/api-conversion-v1alpha-to-v1beta1/00-assert.yaml b/test/chainsaw/integration/api-conversion-v1alpha-to-v1/00-assert.yaml similarity index 85% rename from test/chainsaw/integration/api-conversion-v1alpha-to-v1beta1/00-assert.yaml rename to test/chainsaw/integration/api-conversion-v1alpha-to-v1/00-assert.yaml index 41b6c2c786..863338cd77 100644 --- a/test/chainsaw/integration/api-conversion-v1alpha-to-v1beta1/00-assert.yaml +++ b/test/chainsaw/integration/api-conversion-v1alpha-to-v1/00-assert.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnApp metadata: name: "some-keptn-app2" @@ -6,7 +6,7 @@ spec: version: "1.2.3" revision: 123 --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnAppVersion metadata: name: "some-keptn-app-version-2" @@ -23,7 +23,7 @@ spec: - name: some-keptn-app2 version: 0.2.7 --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnWorkload metadata: name: some-keptn-app2 @@ -39,7 +39,7 @@ spec: name: my-replica-set uid: 957f825e-4025-4ea8-ad22-9292877ff7eb --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnWorkloadVersion metadata: name: some-keptn-app-2-0.1.0 @@ -58,14 +58,14 @@ spec: name: my-replica-set uid: 957f825e-4025-4ea8-ad22-9292877ff7eb --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnAppCreationRequest metadata: name: some-keptn-app2 spec: appName: podtato-head --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnTaskDefinition metadata: name: some-keptn-app-version-2-task @@ -75,7 +75,7 @@ spec: code: | console.log("Okay") --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnTask metadata: name: some-keptn-app-version-2 @@ -89,7 +89,7 @@ spec: workloadName: "some-keptn-app2" workloadVersion: "0.2.7" --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnEvaluationDefinition metadata: name: some-keptn-app-version-2 @@ -99,7 +99,7 @@ spec: keptnMetricRef: name: available-cpus --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnEvaluation metadata: name: some-keptn-app-version-2 diff --git a/test/chainsaw/integration/api-conversion-v1alpha-to-v1beta1/00-install.yaml b/test/chainsaw/integration/api-conversion-v1alpha-to-v1/00-install.yaml similarity index 100% rename from test/chainsaw/integration/api-conversion-v1alpha-to-v1beta1/00-install.yaml rename to test/chainsaw/integration/api-conversion-v1alpha-to-v1/00-install.yaml diff --git a/test/chainsaw/integration/api-conversion-v1beta1-to-v1alpha/chainsaw-test.yaml b/test/chainsaw/integration/api-conversion-v1alpha-to-v1/chainsaw-test.yaml similarity index 89% rename from test/chainsaw/integration/api-conversion-v1beta1-to-v1alpha/chainsaw-test.yaml rename to test/chainsaw/integration/api-conversion-v1alpha-to-v1/chainsaw-test.yaml index 18ce8a4912..a88ce75a4d 100755 --- a/test/chainsaw/integration/api-conversion-v1beta1-to-v1alpha/chainsaw-test.yaml +++ b/test/chainsaw/integration/api-conversion-v1alpha-to-v1/chainsaw-test.yaml @@ -2,7 +2,7 @@ apiVersion: chainsaw.kyverno.io/v1alpha1 kind: Test metadata: - name: api-conversion-v1beta1-to-v1alpha + name: api-conversion-v1alpha-to-v1 spec: steps: - name: step-00 diff --git a/test/chainsaw/integration/app-creation-request/00-assert.yaml b/test/chainsaw/integration/app-creation-request/00-assert.yaml index 2b8382e822..81362576c9 100644 --- a/test/chainsaw/integration/app-creation-request/00-assert.yaml +++ b/test/chainsaw/integration/app-creation-request/00-assert.yaml @@ -1,6 +1,6 @@ # Check for the KeptnApp to be created - the KeptnAppCreationRequest will not be here anymore as it is # deleted after reconciliation -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnApp metadata: name: my-app diff --git a/test/chainsaw/integration/app-creation-request/00-install.yaml b/test/chainsaw/integration/app-creation-request/00-install.yaml index c9d18a32e7..225c925cac 100644 --- a/test/chainsaw/integration/app-creation-request/00-install.yaml +++ b/test/chainsaw/integration/app-creation-request/00-install.yaml @@ -1,11 +1,11 @@ -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnAppCreationRequest metadata: name: my-kacr spec: appName: my-app --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnWorkload metadata: name: my-app-my-workload diff --git a/test/chainsaw/integration/app-creation-request/01-assert.yaml b/test/chainsaw/integration/app-creation-request/01-assert.yaml index 3e208d184d..1e7ffe9e5a 100644 --- a/test/chainsaw/integration/app-creation-request/01-assert.yaml +++ b/test/chainsaw/integration/app-creation-request/01-assert.yaml @@ -1,6 +1,6 @@ # Check for the KeptnApp to be created - the KeptnAppCreationRequest will not be here anymore as it is # deleted after reconciliation -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnApp metadata: name: my-app diff --git a/test/chainsaw/integration/app-creation-request/01-install.yaml b/test/chainsaw/integration/app-creation-request/01-install.yaml index e48e8fb7f4..fe4d3e5717 100644 --- a/test/chainsaw/integration/app-creation-request/01-install.yaml +++ b/test/chainsaw/integration/app-creation-request/01-install.yaml @@ -1,11 +1,11 @@ -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnAppCreationRequest metadata: name: my-kacr spec: appName: my-app --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnWorkload metadata: name: my-app-my-workload @@ -17,7 +17,7 @@ spec: name: my-replica-set uid: 957f825e-4025-4ea8-ad22-9292877ff7eb --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnWorkload metadata: name: my-app-my-workload-2 diff --git a/test/chainsaw/integration/app-failing-post-evaluation/00-assert.yaml b/test/chainsaw/integration/app-failing-post-evaluation/00-assert.yaml index 5afbd60b81..293cfed386 100644 --- a/test/chainsaw/integration/app-failing-post-evaluation/00-assert.yaml +++ b/test/chainsaw/integration/app-failing-post-evaluation/00-assert.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnAppVersion metadata: name: podtato-head-0.1.0-6b86b273 diff --git a/test/chainsaw/integration/app-failing-post-evaluation/00-install.yaml b/test/chainsaw/integration/app-failing-post-evaluation/00-install.yaml index 440d53df3e..1ce217fac7 100644 --- a/test/chainsaw/integration/app-failing-post-evaluation/00-install.yaml +++ b/test/chainsaw/integration/app-failing-post-evaluation/00-install.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnAppContext metadata: name: podtato-head @@ -36,7 +36,7 @@ spec: - name: PODTATO_PORT value: "9000" --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnEvaluationDefinition metadata: name: available-cpus diff --git a/test/chainsaw/integration/app-failing-post-task/00-assert.yaml b/test/chainsaw/integration/app-failing-post-task/00-assert.yaml index 31b8ca905b..2ce746d615 100644 --- a/test/chainsaw/integration/app-failing-post-task/00-assert.yaml +++ b/test/chainsaw/integration/app-failing-post-task/00-assert.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnAppVersion metadata: name: podtato-head-0.1.0-6b86b273 diff --git a/test/chainsaw/integration/app-failing-post-task/00-install.yaml b/test/chainsaw/integration/app-failing-post-task/00-install.yaml index 52bc0636d3..0597693f87 100644 --- a/test/chainsaw/integration/app-failing-post-task/00-install.yaml +++ b/test/chainsaw/integration/app-failing-post-task/00-install.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnAppContext metadata: name: podtato-head @@ -36,7 +36,7 @@ spec: - name: PODTATO_PORT value: "9000" --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnTaskDefinition metadata: name: failing-task diff --git a/test/chainsaw/integration/app-failing-pre-evaluation-retry/00-assert.yaml b/test/chainsaw/integration/app-failing-pre-evaluation-retry/00-assert.yaml index 2669a9824f..355967bd73 100644 --- a/test/chainsaw/integration/app-failing-pre-evaluation-retry/00-assert.yaml +++ b/test/chainsaw/integration/app-failing-pre-evaluation-retry/00-assert.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnAppVersion metadata: name: podtato-head-0.1.0-6b86b273 @@ -11,7 +11,7 @@ status: status: Failed workloadOverallStatus: Deprecated --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnEvaluation spec: checkType: pre-eval @@ -21,7 +21,7 @@ spec: retries: 2 retryInterval: 3s --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnEvaluationDefinition metadata: name: available-cpus diff --git a/test/chainsaw/integration/app-failing-pre-evaluation-retry/00-install.yaml b/test/chainsaw/integration/app-failing-pre-evaluation-retry/00-install.yaml index 49a86c6900..23a74cf396 100644 --- a/test/chainsaw/integration/app-failing-pre-evaluation-retry/00-install.yaml +++ b/test/chainsaw/integration/app-failing-pre-evaluation-retry/00-install.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnAppContext metadata: name: podtato-head @@ -52,7 +52,7 @@ spec: targetPort: 9000 type: LoadBalancer --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnEvaluationDefinition metadata: name: available-cpus diff --git a/test/chainsaw/integration/app-failing-pre-evaluation/00-assert.yaml b/test/chainsaw/integration/app-failing-pre-evaluation/00-assert.yaml index 1d06c03c3b..e75bf486d2 100644 --- a/test/chainsaw/integration/app-failing-pre-evaluation/00-assert.yaml +++ b/test/chainsaw/integration/app-failing-pre-evaluation/00-assert.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnAppVersion metadata: name: podtato-head-0.1.0-6b86b273 @@ -11,7 +11,7 @@ status: status: Failed workloadOverallStatus: Deprecated --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnEvaluation spec: checkType: pre-eval @@ -21,7 +21,7 @@ spec: retries: 10 retryInterval: 5s --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnEvaluationDefinition metadata: name: available-cpus diff --git a/test/chainsaw/integration/app-failing-pre-evaluation/00-install.yaml b/test/chainsaw/integration/app-failing-pre-evaluation/00-install.yaml index 6acc764d24..024e3096fa 100644 --- a/test/chainsaw/integration/app-failing-pre-evaluation/00-install.yaml +++ b/test/chainsaw/integration/app-failing-pre-evaluation/00-install.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnAppContext metadata: name: podtato-head @@ -52,7 +52,7 @@ spec: targetPort: 9000 type: LoadBalancer --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnEvaluationDefinition metadata: name: available-cpus diff --git a/test/chainsaw/integration/app-failing-pre-task-retry/00-assert.yaml b/test/chainsaw/integration/app-failing-pre-task-retry/00-assert.yaml index a4079a906c..5a55920c70 100644 --- a/test/chainsaw/integration/app-failing-pre-task-retry/00-assert.yaml +++ b/test/chainsaw/integration/app-failing-pre-task-retry/00-assert.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnAppVersion metadata: name: podtato-head-0.1.0-6b86b273 @@ -11,7 +11,7 @@ status: status: Failed workloadOverallStatus: Deprecated --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnTask spec: context: diff --git a/test/chainsaw/integration/app-failing-pre-task-retry/00-install.yaml b/test/chainsaw/integration/app-failing-pre-task-retry/00-install.yaml index 08fc32dc2d..4e7026e631 100644 --- a/test/chainsaw/integration/app-failing-pre-task-retry/00-install.yaml +++ b/test/chainsaw/integration/app-failing-pre-task-retry/00-install.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnAppContext metadata: name: podtato-head @@ -36,7 +36,7 @@ spec: - name: PODTATO_PORT value: "9000" --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnTaskDefinition metadata: name: pre-task-retries diff --git a/test/chainsaw/integration/app-failing-pre-task-timeout/00-assert.yaml b/test/chainsaw/integration/app-failing-pre-task-timeout/00-assert.yaml index 1add66fdfa..f664493c45 100644 --- a/test/chainsaw/integration/app-failing-pre-task-timeout/00-assert.yaml +++ b/test/chainsaw/integration/app-failing-pre-task-timeout/00-assert.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnAppVersion metadata: name: podtato-head-0.1.0-6b86b273 @@ -11,7 +11,7 @@ status: status: Failed workloadOverallStatus: Deprecated --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnTask spec: context: diff --git a/test/chainsaw/integration/app-failing-pre-task-timeout/00-install.yaml b/test/chainsaw/integration/app-failing-pre-task-timeout/00-install.yaml index 3b310f2995..3c7e1f788a 100644 --- a/test/chainsaw/integration/app-failing-pre-task-timeout/00-install.yaml +++ b/test/chainsaw/integration/app-failing-pre-task-timeout/00-install.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnAppContext metadata: name: podtato-head @@ -36,7 +36,7 @@ spec: - name: PODTATO_PORT value: "9000" --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnTaskDefinition metadata: name: pre-task-timeout diff --git a/test/chainsaw/integration/app-failing-pre-task/00-assert.yaml b/test/chainsaw/integration/app-failing-pre-task/00-assert.yaml index e0f44beba4..10b99a6df2 100644 --- a/test/chainsaw/integration/app-failing-pre-task/00-assert.yaml +++ b/test/chainsaw/integration/app-failing-pre-task/00-assert.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnAppVersion metadata: name: podtato-head-0.1.0-6b86b273 diff --git a/test/chainsaw/integration/app-failing-pre-task/00-install.yaml b/test/chainsaw/integration/app-failing-pre-task/00-install.yaml index e2f4b532fd..72ee9e8229 100644 --- a/test/chainsaw/integration/app-failing-pre-task/00-install.yaml +++ b/test/chainsaw/integration/app-failing-pre-task/00-install.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnAppContext metadata: name: podtato-head @@ -36,7 +36,7 @@ spec: - name: PODTATO_PORT value: "9000" --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnTaskDefinition metadata: name: check-entry-service diff --git a/test/chainsaw/integration/app-one-taskdefinition-not-found/00-assert.yaml b/test/chainsaw/integration/app-one-taskdefinition-not-found/00-assert.yaml index 75209d3bea..3299c5bb0d 100644 --- a/test/chainsaw/integration/app-one-taskdefinition-not-found/00-assert.yaml +++ b/test/chainsaw/integration/app-one-taskdefinition-not-found/00-assert.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnAppVersion metadata: name: podtato-head-0.1.0-6b86b273 @@ -11,7 +11,7 @@ status: status: Progressing workloadOverallStatus: Pending --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnTask spec: context: diff --git a/test/chainsaw/integration/app-one-taskdefinition-not-found/00-install.yaml b/test/chainsaw/integration/app-one-taskdefinition-not-found/00-install.yaml index 49f9903ab8..3931da3116 100644 --- a/test/chainsaw/integration/app-one-taskdefinition-not-found/00-install.yaml +++ b/test/chainsaw/integration/app-one-taskdefinition-not-found/00-install.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnAppContext metadata: name: podtato-head @@ -37,7 +37,7 @@ spec: - name: PODTATO_PORT value: "9000" --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnTaskDefinition metadata: name: pre-task-timeout diff --git a/test/chainsaw/integration/container-runtime/00-assert.yaml b/test/chainsaw/integration/container-runtime/00-assert.yaml index 68b6825516..16749a5463 100644 --- a/test/chainsaw/integration/container-runtime/00-assert.yaml +++ b/test/chainsaw/integration/container-runtime/00-assert.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnWorkloadVersion metadata: name: waiter-waiter-0.4 @@ -14,7 +14,7 @@ status: status: Succeeded status: Succeeded --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnTask metadata: annotations: diff --git a/test/chainsaw/integration/container-runtime/00-install.yaml b/test/chainsaw/integration/container-runtime/00-install.yaml index eecf740d64..2bb086e65b 100644 --- a/test/chainsaw/integration/container-runtime/00-install.yaml +++ b/test/chainsaw/integration/container-runtime/00-install.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnTaskDefinition metadata: name: pre-deployment-sleep diff --git a/test/chainsaw/integration/imagepullsecret/00-assert.yaml b/test/chainsaw/integration/imagepullsecret/00-assert.yaml index e738966443..10c8e84d6a 100644 --- a/test/chainsaw/integration/imagepullsecret/00-assert.yaml +++ b/test/chainsaw/integration/imagepullsecret/00-assert.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnWorkloadVersion metadata: name: waiter-waiter-0.4 @@ -14,7 +14,7 @@ status: status: Succeeded status: Succeeded --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnTask metadata: annotations: diff --git a/test/chainsaw/integration/imagepullsecret/00-install.yaml b/test/chainsaw/integration/imagepullsecret/00-install.yaml index 97deb5e9f3..55a86742e8 100644 --- a/test/chainsaw/integration/imagepullsecret/00-install.yaml +++ b/test/chainsaw/integration/imagepullsecret/00-install.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnTaskDefinition metadata: name: pre-deployment-sleep diff --git a/test/chainsaw/integration/podtato-head-application-auto-app-discovery/00-assert.yaml b/test/chainsaw/integration/podtato-head-application-auto-app-discovery/00-assert.yaml index 04761132e7..c3e9f303fb 100644 --- a/test/chainsaw/integration/podtato-head-application-auto-app-discovery/00-assert.yaml +++ b/test/chainsaw/integration/podtato-head-application-auto-app-discovery/00-assert.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnApp metadata: name: podtato-head diff --git a/test/chainsaw/integration/podtato-head-application/00-assert.yaml b/test/chainsaw/integration/podtato-head-application/00-assert.yaml index 7928aae2a4..8fe56ee21d 100644 --- a/test/chainsaw/integration/podtato-head-application/00-assert.yaml +++ b/test/chainsaw/integration/podtato-head-application/00-assert.yaml @@ -1,9 +1,9 @@ -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnApp metadata: name: podtato-head --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnAppVersion metadata: name: podtato-head-95a0b0ddca-6b86b273 @@ -23,7 +23,7 @@ status: status: Succeeded workloadOverallStatus: Succeeded --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnWorkloadVersion metadata: name: podtato-head-podtato-head-entry-0.1.0 @@ -45,7 +45,7 @@ status: preDeploymentStatus: Succeeded status: Succeeded --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnWorkloadVersion metadata: name: podtato-head-podtato-head-hat-0.1.0 @@ -63,7 +63,7 @@ status: definitionName: check-entry-service status: Succeeded --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnWorkloadVersion metadata: name: podtato-head-podtato-head-left-arm-0.1.0 @@ -81,7 +81,7 @@ status: definitionName: check-entry-service status: Succeeded --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnWorkloadVersion metadata: name: podtato-head-podtato-head-left-leg-0.1.0 @@ -99,7 +99,7 @@ status: definitionName: check-entry-service status: Succeeded --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnWorkloadVersion metadata: name: podtato-head-podtato-head-right-arm-0.1.0 @@ -117,7 +117,7 @@ status: definitionName: check-entry-service status: Succeeded --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnWorkloadVersion metadata: name: podtato-head-podtato-head-right-leg-0.1.0 diff --git a/test/chainsaw/integration/podtato-head-application/00-install.yaml b/test/chainsaw/integration/podtato-head-application/00-install.yaml index a5943008d0..373f1db923 100644 --- a/test/chainsaw/integration/podtato-head-application/00-install.yaml +++ b/test/chainsaw/integration/podtato-head-application/00-install.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnAppContext metadata: name: podtato-head @@ -313,7 +313,7 @@ spec: targetPort: 9000 type: ClusterIP --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnTaskDefinition metadata: name: post-deployment-hello @@ -324,7 +324,7 @@ spec: code: | console.log("Post-Deployment Task has been executed"); --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnTaskDefinition metadata: name: pre-deployment-hello @@ -335,7 +335,7 @@ spec: code: | console.log("Pre-Deployment Task has been executed"); --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnTaskDefinition metadata: name: check-entry-service @@ -348,7 +348,7 @@ spec: map: url: http://podtato-head-entry:9000 --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnEvaluationDefinition metadata: name: available-cpus diff --git a/test/chainsaw/integration/restartable-app/00-assert.yaml b/test/chainsaw/integration/restartable-app/00-assert.yaml index 84e3dfae2c..bf0791cd4a 100644 --- a/test/chainsaw/integration/restartable-app/00-assert.yaml +++ b/test/chainsaw/integration/restartable-app/00-assert.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnAppVersion metadata: name: podtato-head-1.3-6b86b273 diff --git a/test/chainsaw/integration/restartable-app/00-install.yaml b/test/chainsaw/integration/restartable-app/00-install.yaml index 649bf1ed0c..979d9c7650 100644 --- a/test/chainsaw/integration/restartable-app/00-install.yaml +++ b/test/chainsaw/integration/restartable-app/00-install.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnApp metadata: name: podtato-head @@ -306,7 +306,7 @@ spec: targetPort: 9000 type: ClusterIP --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnTaskDefinition metadata: name: post-deployment-hello @@ -316,7 +316,7 @@ spec: code: | console.log("Post-Deployment Task has been executed"); --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnTaskDefinition metadata: name: check-entry-service diff --git a/test/chainsaw/integration/restartable-app/01-assert.yaml b/test/chainsaw/integration/restartable-app/01-assert.yaml index b15c7d1a97..36e271fead 100644 --- a/test/chainsaw/integration/restartable-app/01-assert.yaml +++ b/test/chainsaw/integration/restartable-app/01-assert.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnAppVersion metadata: name: podtato-head-1.3-d4735e3a @@ -11,7 +11,7 @@ status: status: Succeeded workloadOverallStatus: Succeeded --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnAppVersion metadata: name: podtato-head-1.3-6b86b273 @@ -24,7 +24,7 @@ status: status: Deprecated workloadOverallStatus: Deprecated --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnWorkloadVersion metadata: name: podtato-head-podtato-head-entry-0.1.0 @@ -40,7 +40,7 @@ status: preDeploymentStatus: Succeeded status: Succeeded --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnWorkloadVersion metadata: name: podtato-head-podtato-head-hat-0.1.0 @@ -56,7 +56,7 @@ status: definitionName: check-entry-service status: Succeeded --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnWorkloadVersion metadata: name: podtato-head-podtato-head-left-arm-0.1.0 @@ -72,7 +72,7 @@ status: definitionName: check-entry-service status: Succeeded --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnWorkloadVersion metadata: name: podtato-head-podtato-head-left-leg-0.1.0 @@ -88,7 +88,7 @@ status: definitionName: check-entry-service status: Succeeded --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnWorkloadVersion metadata: name: podtato-head-podtato-head-right-arm-0.1.0 @@ -104,7 +104,7 @@ status: definitionName: check-entry-service status: Succeeded --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnWorkloadVersion metadata: name: podtato-head-podtato-head-right-leg-0.1.0 diff --git a/test/chainsaw/integration/restartable-app/01-install.yaml b/test/chainsaw/integration/restartable-app/01-install.yaml index 729dfba49f..93b2b81e02 100644 --- a/test/chainsaw/integration/restartable-app/01-install.yaml +++ b/test/chainsaw/integration/restartable-app/01-install.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnApp metadata: name: podtato-head diff --git a/test/chainsaw/integration/restartable-app/02-assert.yaml b/test/chainsaw/integration/restartable-app/02-assert.yaml index fe7dc04199..a0fa9d94a0 100644 --- a/test/chainsaw/integration/restartable-app/02-assert.yaml +++ b/test/chainsaw/integration/restartable-app/02-assert.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnAppVersion metadata: name: podtato-head-1.3-4e074085 @@ -11,7 +11,7 @@ status: status: Succeeded workloadOverallStatus: Succeeded --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnAppVersion metadata: name: podtato-head-1.3-d4735e3a @@ -24,7 +24,7 @@ status: status: Deprecated workloadOverallStatus: Deprecated --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnAppVersion metadata: name: podtato-head-1.3-6b86b273 @@ -37,7 +37,7 @@ status: status: Deprecated workloadOverallStatus: Deprecated --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnWorkloadVersion metadata: name: podtato-head-podtato-head-entry-0.1.0 @@ -53,7 +53,7 @@ status: preDeploymentStatus: Succeeded status: Succeeded --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnWorkloadVersion metadata: name: podtato-head-podtato-head-hat-0.1.0 @@ -69,7 +69,7 @@ status: definitionName: check-entry-service status: Succeeded --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnWorkloadVersion metadata: name: podtato-head-podtato-head-left-arm-0.1.0 @@ -85,7 +85,7 @@ status: definitionName: check-entry-service status: Succeeded --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnWorkloadVersion metadata: name: podtato-head-podtato-head-left-leg-0.1.0 @@ -101,7 +101,7 @@ status: definitionName: check-entry-service status: Succeeded --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnWorkloadVersion metadata: name: podtato-head-podtato-head-right-arm-0.1.0 @@ -117,7 +117,7 @@ status: definitionName: check-entry-service status: Succeeded --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnWorkloadVersion metadata: name: podtato-head-podtato-head-right-leg-0.1.0 diff --git a/test/chainsaw/integration/restartable-app/02-install.yaml b/test/chainsaw/integration/restartable-app/02-install.yaml index a9d0f571e9..eebb675e16 100644 --- a/test/chainsaw/integration/restartable-app/02-install.yaml +++ b/test/chainsaw/integration/restartable-app/02-install.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnApp metadata: name: podtato-head diff --git a/test/chainsaw/integration/serviceaccount-in-jobs/00-install.yaml b/test/chainsaw/integration/serviceaccount-in-jobs/00-install.yaml index 36c15e69fa..66efb9ec81 100644 --- a/test/chainsaw/integration/serviceaccount-in-jobs/00-install.yaml +++ b/test/chainsaw/integration/serviceaccount-in-jobs/00-install.yaml @@ -4,7 +4,7 @@ metadata: name: keptn-serviceaccount automountServiceAccountToken: false --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnTaskDefinition metadata: name: task-serviceaccount @@ -21,7 +21,7 @@ spec: args: - 'hello world' --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnTask metadata: name: sendserviceaccount diff --git a/test/chainsaw/integration/simple-daemonset-annotated/00-install.yaml b/test/chainsaw/integration/simple-daemonset-annotated/00-install.yaml index dd7c48692f..773c040d67 100644 --- a/test/chainsaw/integration/simple-daemonset-annotated/00-install.yaml +++ b/test/chainsaw/integration/simple-daemonset-annotated/00-install.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnTaskDefinition metadata: name: pre-deployment-hello diff --git a/test/chainsaw/integration/simple-daemonset-annotated/01-assert.yaml b/test/chainsaw/integration/simple-daemonset-annotated/01-assert.yaml index afd72044fe..9f32247f13 100644 --- a/test/chainsaw/integration/simple-daemonset-annotated/01-assert.yaml +++ b/test/chainsaw/integration/simple-daemonset-annotated/01-assert.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnWorkload metadata: name: work-work @@ -8,7 +8,7 @@ spec: stage: dev --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnWorkloadVersion metadata: name: work-work-0.4 diff --git a/test/chainsaw/integration/simple-daemonset-annotated/02-assert.yaml b/test/chainsaw/integration/simple-daemonset-annotated/02-assert.yaml index 6b729154ea..de44bd197b 100644 --- a/test/chainsaw/integration/simple-daemonset-annotated/02-assert.yaml +++ b/test/chainsaw/integration/simple-daemonset-annotated/02-assert.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnWorkloadVersion metadata: name: work-work-0.5 diff --git a/test/chainsaw/integration/simple-deployment-annotated-with-app-context/00-assert.yaml b/test/chainsaw/integration/simple-deployment-annotated-with-app-context/00-assert.yaml index 54202f5b78..bc0293aba6 100644 --- a/test/chainsaw/integration/simple-deployment-annotated-with-app-context/00-assert.yaml +++ b/test/chainsaw/integration/simple-deployment-annotated-with-app-context/00-assert.yaml @@ -7,7 +7,7 @@ metadata: status: readyReplicas: 2 --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnWorkload metadata: name: waiter-waiter @@ -16,7 +16,7 @@ spec: commit-id: "1234" stage: dev --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnWorkloadVersion metadata: name: waiter-waiter-0.4 diff --git a/test/chainsaw/integration/simple-deployment-annotated-with-app-context/00-install.yaml b/test/chainsaw/integration/simple-deployment-annotated-with-app-context/00-install.yaml index 38ff879abb..f2efc37cff 100644 --- a/test/chainsaw/integration/simple-deployment-annotated-with-app-context/00-install.yaml +++ b/test/chainsaw/integration/simple-deployment-annotated-with-app-context/00-install.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnAppContext metadata: name: waiter @@ -6,7 +6,7 @@ spec: metadata: test-metadata: test-metadata --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnTaskDefinition metadata: name: pre-deployment-hello diff --git a/test/chainsaw/integration/simple-deployment-container-annotation/00-assert.yaml b/test/chainsaw/integration/simple-deployment-container-annotation/00-assert.yaml index 53c27ce37b..782690af60 100644 --- a/test/chainsaw/integration/simple-deployment-container-annotation/00-assert.yaml +++ b/test/chainsaw/integration/simple-deployment-container-annotation/00-assert.yaml @@ -1,9 +1,9 @@ -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnWorkload metadata: name: waiter-waiter --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnWorkloadVersion metadata: name: waiter-waiter-1.35 @@ -15,12 +15,12 @@ status: preDeploymentEvaluationStatus: Succeeded preDeploymentStatus: Succeeded --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnApp metadata: name: waiter --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnAppVersion metadata: name: waiter-1.35-6b86b273 diff --git a/test/chainsaw/integration/simple-deployment-container-annotation/01-assert.yaml b/test/chainsaw/integration/simple-deployment-container-annotation/01-assert.yaml index e07e77707f..2faa1b145d 100644 --- a/test/chainsaw/integration/simple-deployment-container-annotation/01-assert.yaml +++ b/test/chainsaw/integration/simple-deployment-container-annotation/01-assert.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnWorkload metadata: name: waiter-waiter @@ -7,7 +7,7 @@ spec: commit-id: "1234" stage: dev --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnWorkloadVersion metadata: name: waiter-waiter-1.36 @@ -23,12 +23,12 @@ status: preDeploymentEvaluationStatus: Succeeded preDeploymentStatus: Succeeded --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnApp metadata: name: waiter --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnAppVersion metadata: name: waiter-1.36-d4735e3a diff --git a/test/chainsaw/integration/simple-deployment-evaluation/00-assert.yaml b/test/chainsaw/integration/simple-deployment-evaluation/00-assert.yaml index 692a31c85c..03032a61fd 100644 --- a/test/chainsaw/integration/simple-deployment-evaluation/00-assert.yaml +++ b/test/chainsaw/integration/simple-deployment-evaluation/00-assert.yaml @@ -7,7 +7,7 @@ metadata: status: readyReplicas: 1 --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnWorkload metadata: name: waiter-waiter @@ -17,7 +17,7 @@ spec: stage: dev --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnWorkloadVersion metadata: name: waiter-waiter-0.4 diff --git a/test/chainsaw/integration/simple-deployment-evaluation/00-install.yaml b/test/chainsaw/integration/simple-deployment-evaluation/00-install.yaml index 2466b26108..b5c88b23b4 100644 --- a/test/chainsaw/integration/simple-deployment-evaluation/00-install.yaml +++ b/test/chainsaw/integration/simple-deployment-evaluation/00-install.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnEvaluationDefinition metadata: name: pre-deployment-hello diff --git a/test/chainsaw/integration/simple-deployment-k8s-recommended-label/00-assert.yaml b/test/chainsaw/integration/simple-deployment-k8s-recommended-label/00-assert.yaml index a22337b134..6369b1a1ae 100644 --- a/test/chainsaw/integration/simple-deployment-k8s-recommended-label/00-assert.yaml +++ b/test/chainsaw/integration/simple-deployment-k8s-recommended-label/00-assert.yaml @@ -7,7 +7,7 @@ metadata: status: readyReplicas: 1 --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnWorkload metadata: name: waiter-waiter @@ -16,7 +16,7 @@ spec: commit-id: "1234" stage: dev --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnWorkloadVersion metadata: name: waiter-waiter-0.4 @@ -32,12 +32,12 @@ status: preDeploymentEvaluationStatus: Succeeded preDeploymentStatus: Succeeded --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnApp metadata: name: waiter --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnAppVersion metadata: name: waiter-0.4-6b86b273 diff --git a/test/chainsaw/integration/simple-deployment-python-runtime/00-assert.yaml b/test/chainsaw/integration/simple-deployment-python-runtime/00-assert.yaml index a4f8062c65..71111c1ddf 100644 --- a/test/chainsaw/integration/simple-deployment-python-runtime/00-assert.yaml +++ b/test/chainsaw/integration/simple-deployment-python-runtime/00-assert.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnWorkloadVersion metadata: name: waiter-waiter-0.4 @@ -14,7 +14,7 @@ status: status: Succeeded status: Succeeded --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnTask metadata: annotations: diff --git a/test/chainsaw/integration/simple-deployment-python-runtime/00-install.yaml b/test/chainsaw/integration/simple-deployment-python-runtime/00-install.yaml index 026d1ff0c9..c83b02dfc8 100644 --- a/test/chainsaw/integration/simple-deployment-python-runtime/00-install.yaml +++ b/test/chainsaw/integration/simple-deployment-python-runtime/00-install.yaml @@ -6,7 +6,7 @@ type: Opaque data: SECURE_DATA: dG9rZW46IG15dG9rZW4= --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnTaskDefinition metadata: name: pre-deployment-hello diff --git a/test/chainsaw/integration/simple-deployment-recursive-task/00-assert.yaml b/test/chainsaw/integration/simple-deployment-recursive-task/00-assert.yaml index 274071fb8b..de110ea706 100644 --- a/test/chainsaw/integration/simple-deployment-recursive-task/00-assert.yaml +++ b/test/chainsaw/integration/simple-deployment-recursive-task/00-assert.yaml @@ -50,7 +50,7 @@ metadata: labels: task-definition: "child" ownerReferences: - - apiVersion: lifecycle.keptn.sh/v1beta1 + - apiVersion: lifecycle.keptn.sh/v1 blockOwnerDeletion: true controller: true kind: KeptnTask diff --git a/test/chainsaw/integration/simple-deployment-recursive-task/00-install.yaml b/test/chainsaw/integration/simple-deployment-recursive-task/00-install.yaml index 00eb55034b..b8f2ecbbb3 100644 --- a/test/chainsaw/integration/simple-deployment-recursive-task/00-install.yaml +++ b/test/chainsaw/integration/simple-deployment-recursive-task/00-install.yaml @@ -6,7 +6,7 @@ type: Opaque data: SECURE_DATA: dG9rZW46IG15dG9rZW4= --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnTaskDefinition metadata: name: pre-deployment-hello @@ -24,7 +24,7 @@ spec: user: "myuser" data: "mydata" --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnTaskDefinition metadata: name: pre-deployment-parent diff --git a/test/chainsaw/integration/simple-deployment-sanitize-version-number/00-assert.yaml b/test/chainsaw/integration/simple-deployment-sanitize-version-number/00-assert.yaml index 9458c88c01..eeedb7d944 100644 --- a/test/chainsaw/integration/simple-deployment-sanitize-version-number/00-assert.yaml +++ b/test/chainsaw/integration/simple-deployment-sanitize-version-number/00-assert.yaml @@ -7,12 +7,12 @@ metadata: status: readyReplicas: 1 --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnWorkload metadata: name: waiter-waiter --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnWorkloadVersion metadata: name: waiter-waiter-0.4.0-1 @@ -30,12 +30,12 @@ status: - status: Succeeded definitionName: pre-deployment-hello --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnApp metadata: name: waiter --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnAppVersion metadata: name: waiter-0.4.0-1-6b86b273 diff --git a/test/chainsaw/integration/simple-deployment-sanitize-version-number/00-install.yaml b/test/chainsaw/integration/simple-deployment-sanitize-version-number/00-install.yaml index d485071568..81366c037e 100644 --- a/test/chainsaw/integration/simple-deployment-sanitize-version-number/00-install.yaml +++ b/test/chainsaw/integration/simple-deployment-sanitize-version-number/00-install.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnTaskDefinition metadata: name: pre-deployment-hello diff --git a/test/chainsaw/integration/simple-deployment/00-assert.yaml b/test/chainsaw/integration/simple-deployment/00-assert.yaml index 53ad78b79c..0026c44603 100644 --- a/test/chainsaw/integration/simple-deployment/00-assert.yaml +++ b/test/chainsaw/integration/simple-deployment/00-assert.yaml @@ -7,12 +7,12 @@ metadata: status: readyReplicas: 1 --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnWorkload metadata: name: waiter-waiter --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnWorkloadVersion metadata: name: waiter-waiter-0.4 @@ -30,12 +30,12 @@ status: - status: Succeeded definitionName: pre-deployment-hello --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnApp metadata: name: waiter --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnAppVersion metadata: name: waiter-0.4-6b86b273 diff --git a/test/chainsaw/integration/simple-deployment/00-install.yaml b/test/chainsaw/integration/simple-deployment/00-install.yaml index d158f4c0ed..03c8a9b4dc 100644 --- a/test/chainsaw/integration/simple-deployment/00-install.yaml +++ b/test/chainsaw/integration/simple-deployment/00-install.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnTaskDefinition metadata: name: pre-deployment-hello diff --git a/test/chainsaw/integration/simple-statefulset-annotated/00-assert.yaml b/test/chainsaw/integration/simple-statefulset-annotated/00-assert.yaml index 47eaa8d60b..4d084f46fc 100644 --- a/test/chainsaw/integration/simple-statefulset-annotated/00-assert.yaml +++ b/test/chainsaw/integration/simple-statefulset-annotated/00-assert.yaml @@ -9,7 +9,7 @@ status: availableReplicas: 2 readyReplicas: 2 --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnWorkload metadata: name: work-work @@ -19,7 +19,7 @@ spec: stage: dev --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnWorkloadVersion metadata: name: work-work-0.4 diff --git a/test/chainsaw/integration/simple-statefulset-annotated/00-install.yaml b/test/chainsaw/integration/simple-statefulset-annotated/00-install.yaml index 06a8d8c898..b5f785bab7 100644 --- a/test/chainsaw/integration/simple-statefulset-annotated/00-install.yaml +++ b/test/chainsaw/integration/simple-statefulset-annotated/00-install.yaml @@ -1,6 +1,6 @@ --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnTaskDefinition metadata: name: pre-deployment-hello diff --git a/test/chainsaw/integration/simple-statefulset-annotated/02-assert.yaml b/test/chainsaw/integration/simple-statefulset-annotated/02-assert.yaml index 6b729154ea..de44bd197b 100644 --- a/test/chainsaw/integration/simple-statefulset-annotated/02-assert.yaml +++ b/test/chainsaw/integration/simple-statefulset-annotated/02-assert.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnWorkloadVersion metadata: name: work-work-0.5 diff --git a/test/chainsaw/integration/simple-task/00-install.yaml b/test/chainsaw/integration/simple-task/00-install.yaml index 68fc69f4d1..31ac99adf9 100644 --- a/test/chainsaw/integration/simple-task/00-install.yaml +++ b/test/chainsaw/integration/simple-task/00-install.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnTaskDefinition metadata: name: pre-deployment-hello @@ -9,7 +9,7 @@ spec: code: | console.log("Pre-Deployment Task has been executed"); --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnTask metadata: name: pre-deployment-hello-1234 diff --git a/test/chainsaw/integration/validate-taskdefinition/td_bad_container_deno.yaml b/test/chainsaw/integration/validate-taskdefinition/td_bad_container_deno.yaml index 59463793da..ba13753cff 100644 --- a/test/chainsaw/integration/validate-taskdefinition/td_bad_container_deno.yaml +++ b/test/chainsaw/integration/validate-taskdefinition/td_bad_container_deno.yaml @@ -1,5 +1,5 @@ # This TaskDefinition will not be accepted by the validation webhook as it contains both containerSpec and functionSpec -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnTaskDefinition metadata: name: badtaskdefinition4 diff --git a/test/chainsaw/integration/validate-taskdefinition/td_bad_container_python.yaml b/test/chainsaw/integration/validate-taskdefinition/td_bad_container_python.yaml index fcab3d35c5..d4a6485411 100644 --- a/test/chainsaw/integration/validate-taskdefinition/td_bad_container_python.yaml +++ b/test/chainsaw/integration/validate-taskdefinition/td_bad_container_python.yaml @@ -1,5 +1,5 @@ # This TaskDefinition will not be accepted by the validation webhook as it contains both containerSpec and functionSpec -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnTaskDefinition metadata: name: badtaskdefinition3 diff --git a/test/chainsaw/integration/validate-taskdefinition/td_bad_empty.yaml b/test/chainsaw/integration/validate-taskdefinition/td_bad_empty.yaml index 817a573d53..934a10b15a 100644 --- a/test/chainsaw/integration/validate-taskdefinition/td_bad_empty.yaml +++ b/test/chainsaw/integration/validate-taskdefinition/td_bad_empty.yaml @@ -1,5 +1,5 @@ # This TaskDefinition will not be accepted by the validation webhook as it doesn't contain either containerSpec or functionSpec -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnTaskDefinition metadata: name: badtaskdefinition2 diff --git a/test/chainsaw/integration/validate-taskdefinition/td_bad_function_python.yaml b/test/chainsaw/integration/validate-taskdefinition/td_bad_function_python.yaml index a4940d61c9..5875a9a02c 100644 --- a/test/chainsaw/integration/validate-taskdefinition/td_bad_function_python.yaml +++ b/test/chainsaw/integration/validate-taskdefinition/td_bad_function_python.yaml @@ -1,5 +1,5 @@ # This TaskDefinition will not be accepted by the validation webhook as it contains both containerSpec and functionSpec -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnTaskDefinition metadata: name: badtaskdefinition5 diff --git a/test/chainsaw/integration/validate-taskdefinition/td_bad_python_deno.yaml b/test/chainsaw/integration/validate-taskdefinition/td_bad_python_deno.yaml index 94d4b89442..e0e29f11ec 100644 --- a/test/chainsaw/integration/validate-taskdefinition/td_bad_python_deno.yaml +++ b/test/chainsaw/integration/validate-taskdefinition/td_bad_python_deno.yaml @@ -1,5 +1,5 @@ # This TaskDefinition will not be accepted by the validation webhook as it contains both containerSpec and functionSpec -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnTaskDefinition metadata: name: badtaskdefinition7 diff --git a/test/chainsaw/integration/validate-taskdefinition/td_good_container.yaml b/test/chainsaw/integration/validate-taskdefinition/td_good_container.yaml index dfdc597e22..637930321f 100644 --- a/test/chainsaw/integration/validate-taskdefinition/td_good_container.yaml +++ b/test/chainsaw/integration/validate-taskdefinition/td_good_container.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnTaskDefinition metadata: name: goodtaskdefinition1 diff --git a/test/chainsaw/integration/validate-taskdefinition/td_good_deno.yaml b/test/chainsaw/integration/validate-taskdefinition/td_good_deno.yaml index 1e88f73528..fe6f402526 100644 --- a/test/chainsaw/integration/validate-taskdefinition/td_good_deno.yaml +++ b/test/chainsaw/integration/validate-taskdefinition/td_good_deno.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnTaskDefinition metadata: name: goodtaskdefinition4 diff --git a/test/chainsaw/integration/validate-taskdefinition/td_good_function.yaml b/test/chainsaw/integration/validate-taskdefinition/td_good_function.yaml index 9c8355ca5b..abe696f06a 100644 --- a/test/chainsaw/integration/validate-taskdefinition/td_good_function.yaml +++ b/test/chainsaw/integration/validate-taskdefinition/td_good_function.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnTaskDefinition metadata: name: goodtaskdefinition2 diff --git a/test/chainsaw/integration/validate-taskdefinition/td_good_python.yaml b/test/chainsaw/integration/validate-taskdefinition/td_good_python.yaml index 5f5f88e178..022c01fd98 100644 --- a/test/chainsaw/integration/validate-taskdefinition/td_good_python.yaml +++ b/test/chainsaw/integration/validate-taskdefinition/td_good_python.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnTaskDefinition metadata: name: goodtaskdefinition3 diff --git a/test/chainsaw/integration/workload-version-failing-pre-task/00-assert.yaml b/test/chainsaw/integration/workload-version-failing-pre-task/00-assert.yaml index 157160918d..1e18627389 100644 --- a/test/chainsaw/integration/workload-version-failing-pre-task/00-assert.yaml +++ b/test/chainsaw/integration/workload-version-failing-pre-task/00-assert.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnAppVersion metadata: name: podtato-head-0.1.0-6b86b273 @@ -11,7 +11,7 @@ status: status: Failed workloadOverallStatus: Failed --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnWorkloadVersion metadata: name: podtato-head-podtato-head-entry-0.1.0 diff --git a/test/chainsaw/integration/workload-version-failing-pre-task/00-install.yaml b/test/chainsaw/integration/workload-version-failing-pre-task/00-install.yaml index 2266eb32e3..ea1cff4336 100644 --- a/test/chainsaw/integration/workload-version-failing-pre-task/00-install.yaml +++ b/test/chainsaw/integration/workload-version-failing-pre-task/00-install.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnTaskDefinition metadata: name: check-entry-service diff --git a/test/chainsaw/integration/workload-version-missing-evaluation/00-assert.yaml b/test/chainsaw/integration/workload-version-missing-evaluation/00-assert.yaml index 1fb68f64da..f1dda78300 100644 --- a/test/chainsaw/integration/workload-version-missing-evaluation/00-assert.yaml +++ b/test/chainsaw/integration/workload-version-missing-evaluation/00-assert.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnAppVersion metadata: name: podtato-head-0.1.0-6b86b273 @@ -11,7 +11,7 @@ status: status: Progressing workloadOverallStatus: Progressing --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnWorkloadVersion metadata: name: podtato-head-podtato-head-entry-0.1.0 diff --git a/test/chainsaw/integration/workload-version-missing-task/00-assert.yaml b/test/chainsaw/integration/workload-version-missing-task/00-assert.yaml index fa52b407c5..a6b4cc097f 100644 --- a/test/chainsaw/integration/workload-version-missing-task/00-assert.yaml +++ b/test/chainsaw/integration/workload-version-missing-task/00-assert.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnAppVersion metadata: name: podtato-head-0.1.0-6b86b273 @@ -11,7 +11,7 @@ status: status: Progressing workloadOverallStatus: Progressing --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnWorkloadVersion metadata: name: podtato-head-podtato-head-entry-0.1.0 diff --git a/test/chainsaw/non-blocking-deployment/00-assert.yaml b/test/chainsaw/non-blocking-deployment/00-assert.yaml index 4932c269d7..706330903b 100644 --- a/test/chainsaw/non-blocking-deployment/00-assert.yaml +++ b/test/chainsaw/non-blocking-deployment/00-assert.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnAppVersion metadata: name: podtato-head-0.1.0-6b86b273 @@ -29,7 +29,7 @@ status: name: podtato-head-entry version: 0.1.0 --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnWorkloadVersion metadata: generation: 1 diff --git a/test/chainsaw/non-blocking-deployment/00-install.yaml b/test/chainsaw/non-blocking-deployment/00-install.yaml index cbd5efd099..058d372a69 100644 --- a/test/chainsaw/non-blocking-deployment/00-install.yaml +++ b/test/chainsaw/non-blocking-deployment/00-install.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnAppContext metadata: name: podtato-head @@ -38,7 +38,7 @@ spec: - name: PODTATO_PORT value: "9000" --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnTaskDefinition metadata: name: failing-task diff --git a/test/chainsaw/non-blocking-deployment/01-assert.yaml b/test/chainsaw/non-blocking-deployment/01-assert.yaml index f001e74ec4..96d17e01b1 100644 --- a/test/chainsaw/non-blocking-deployment/01-assert.yaml +++ b/test/chainsaw/non-blocking-deployment/01-assert.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnAppVersion metadata: name: podtato-head-0.2.0-d4735e3a @@ -25,7 +25,7 @@ status: status: Failed workloadOverallStatus: Deprecated --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnWorkloadVersion metadata: generation: 1 diff --git a/test/chainsaw/non-blocking-deployment/01-install.yaml b/test/chainsaw/non-blocking-deployment/01-install.yaml index 708d0ca844..d27104b3e0 100644 --- a/test/chainsaw/non-blocking-deployment/01-install.yaml +++ b/test/chainsaw/non-blocking-deployment/01-install.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnAppContext metadata: name: podtato-head @@ -36,7 +36,7 @@ spec: - name: PODTATO_PORT value: "9000" --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnTaskDefinition metadata: name: failing-task diff --git a/test/chainsaw/scheduling-gates/simple-deployment-restart-pod/00-install.yaml b/test/chainsaw/scheduling-gates/simple-deployment-restart-pod/00-install.yaml index f33b817657..c401a33262 100644 --- a/test/chainsaw/scheduling-gates/simple-deployment-restart-pod/00-install.yaml +++ b/test/chainsaw/scheduling-gates/simple-deployment-restart-pod/00-install.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnTaskDefinition metadata: name: pre-deployment-hello diff --git a/test/chainsaw/scheduling-gates/simple-deployment-restart-pod/01-assert.yaml b/test/chainsaw/scheduling-gates/simple-deployment-restart-pod/01-assert.yaml index 7f5309c7d0..591e3a7344 100755 --- a/test/chainsaw/scheduling-gates/simple-deployment-restart-pod/01-assert.yaml +++ b/test/chainsaw/scheduling-gates/simple-deployment-restart-pod/01-assert.yaml @@ -1,9 +1,9 @@ -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnWorkload metadata: name: waiter-waiter --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnWorkloadVersion metadata: name: waiter-waiter-0.4 @@ -18,12 +18,12 @@ status: - definitionName: pre-deployment-hello status: Succeeded --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnApp metadata: name: waiter --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnAppVersion metadata: name: waiter-0.4-6b86b273 diff --git a/test/chainsaw/scheduling-gates/simple-deployment/00-install.yaml b/test/chainsaw/scheduling-gates/simple-deployment/00-install.yaml index f504dd5402..ddca4d93c5 100644 --- a/test/chainsaw/scheduling-gates/simple-deployment/00-install.yaml +++ b/test/chainsaw/scheduling-gates/simple-deployment/00-install.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnTaskDefinition metadata: name: pre-deployment-hello diff --git a/test/chainsaw/scheduling-gates/simple-deployment/01-assert.yaml b/test/chainsaw/scheduling-gates/simple-deployment/01-assert.yaml index 3e9e085153..33b7fc5239 100755 --- a/test/chainsaw/scheduling-gates/simple-deployment/01-assert.yaml +++ b/test/chainsaw/scheduling-gates/simple-deployment/01-assert.yaml @@ -1,9 +1,9 @@ -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnWorkload metadata: name: waiter-waiter --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnWorkloadVersion metadata: name: waiter-waiter-0.4 @@ -21,12 +21,12 @@ status: - definitionName: pre-deployment-hello status: Succeeded --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnApp metadata: name: waiter --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnAppVersion metadata: name: waiter-0.4-6b86b273 diff --git a/test/chainsaw/testmetrics/metrics-keda/metric.yaml b/test/chainsaw/testmetrics/metrics-keda/metric.yaml index d038bde6dd..0f2f546dcb 100644 --- a/test/chainsaw/testmetrics/metrics-keda/metric.yaml +++ b/test/chainsaw/testmetrics/metrics-keda/metric.yaml @@ -1,4 +1,4 @@ -apiVersion: metrics.keptn.sh/v1beta1 +apiVersion: metrics.keptn.sh/v1 kind: KeptnMetricsProvider metadata: name: my-provider @@ -6,7 +6,7 @@ spec: type: prometheus targetServer: (join('.', ['http://mockserver', $namespace, 'svc.cluster.local:1080'])) --- -apiVersion: metrics.keptn.sh/v1beta1 +apiVersion: metrics.keptn.sh/v1 kind: KeptnMetric metadata: name: test diff --git a/test/chainsaw/timeout-failure-deployment/00-assert.yaml b/test/chainsaw/timeout-failure-deployment/00-assert.yaml index 71fb343e2d..ccda9a6bb4 100644 --- a/test/chainsaw/timeout-failure-deployment/00-assert.yaml +++ b/test/chainsaw/timeout-failure-deployment/00-assert.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnAppVersion metadata: name: podtato-head-0.1.0-6b86b273 @@ -19,7 +19,7 @@ status: status: Failed workloadOverallStatus: Failed --- -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnWorkloadVersion metadata: generation: 1 diff --git a/test/chainsaw/traces/00-assert.yaml b/test/chainsaw/traces/00-assert.yaml index d19c29f497..b97887e042 100644 --- a/test/chainsaw/traces/00-assert.yaml +++ b/test/chainsaw/traces/00-assert.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1beta1 +apiVersion: lifecycle.keptn.sh/v1 kind: KeptnAppVersion metadata: name: keptnapp-0.0.1-6b86b273