From 7a9458a337f41dd2c8588d3e3602caec2865c712 Mon Sep 17 00:00:00 2001 From: odubajDT <93584209+odubajDT@users.noreply.github.com> Date: Wed, 10 Jan 2024 16:47:57 +0100 Subject: [PATCH] feat(lifecycle-operator)!: move API HUB version to v1beta1 (#2772) Signed-off-by: odubajDT Signed-off-by: Dubaj Co-authored-by: Dubaj Signed-off-by: vickysomtee --- .github/actions/spelling/expect.txt | 2 +- .../scripts/.helm-tests/default/result.yaml | 26 +- .../.helm-tests/lifecycle-only/result.yaml | 26 +- .../lifecycle-with-certs/result.yaml | 26 +- .../api-reference/lifecycle/v1beta1/index.md | 5 +- .../apis/lifecycle/v1alpha1/common/common.go | 8 +- .../lifecycle/v1alpha1/keptnapp_conversion.go | 12 +- .../v1alpha1/keptnapp_conversion_test.go | 34 +- .../v1alpha1/keptnappversion_conversion.go | 50 +- .../keptnappversion_conversion_test.go | 140 ++--- .../keptnevaluationprovider_conversion.go | 53 -- ...keptnevaluationprovider_conversion_test.go | 178 ------ .../keptnworkloadinstance_conversion.go | 203 ------- .../keptnworkloadinstance_conversion_test.go | 546 ------------------ .../v1alpha1/keptnworkloadinstance_test.go | 346 ----------- .../v1alpha1/keptnworkloadinstance_types.go | 312 ---------- .../apis/lifecycle/v1alpha2/common/common.go | 8 +- .../lifecycle/v1alpha2/keptnapp_conversion.go | 12 +- .../v1alpha2/keptnapp_conversion_test.go | 28 +- .../v1alpha2/keptnappversion_conversion.go | 50 +- .../keptnappversion_conversion_test.go | 142 ++--- .../keptnevaluationprovider_conversion.go | 59 -- ...keptnevaluationprovider_conversion_test.go | 188 ------ .../v1alpha2/keptnevaluationprovider_test.go | 125 ---- .../v1alpha2/keptnevaluationprovider_types.go | 12 - .../keptnworkloadinstance_conversion.go | 203 ------- .../keptnworkloadinstance_conversion_test.go | 546 ------------------ .../v1alpha2/keptnworkloadinstance_test.go | 410 ------------- .../v1alpha2/keptnworkloadinstance_types.go | 334 ----------- .../apis/lifecycle/v1alpha3/common/common.go | 4 + .../lifecycle/v1alpha3/keptnapp_conversion.go | 71 ++- .../keptnapp_conversion_test.go | 38 +- .../apis/lifecycle/v1alpha3/keptnapp_types.go | 1 - .../v1alpha3/keptnappcreationrequest_types.go | 1 - .../v1alpha3/keptnappversion_conversion.go | 235 +++++++- .../keptnappversion_conversion_test.go | 138 ++--- .../v1alpha3/keptnappversion_types.go | 1 - .../v1alpha3/keptnevaluation_types.go | 1 - .../keptnevaluationdefinition_types.go | 1 - .../keptnevaluationprovider_conversion.go | 6 - .../keptnevaluationprovider_webhook.go | 11 - .../v1alpha3/keptntask_conversion.go | 6 - .../lifecycle/v1alpha3/keptntask_types.go | 1 - .../v1alpha3/keptntaskdefinition_types.go | 1 - .../lifecycle/v1alpha3/keptnworkload_types.go | 1 - .../keptnworkloadinstance_conversion.go | 6 - .../v1alpha3/keptnworkloadinstance_test.go | 447 -------------- .../v1alpha3/keptnworkloadinstance_types.go | 342 ----------- .../v1alpha3/keptnworkloadinstance_webhook.go | 11 - .../v1alpha3/zz_generated.deepcopy.go | 2 +- .../v1alpha4/keptnworkloadversion_types.go | 1 - .../apis/lifecycle/v1beta1/common/common.go | 4 - .../lifecycle/v1beta1/keptnapp_conversion.go | 71 +-- .../apis/lifecycle/v1beta1/keptnapp_types.go | 1 + .../{v1alpha3 => v1beta1}/keptnapp_webhook.go | 2 +- .../v1beta1/keptnappcreationrequest_types.go | 4 +- .../v1beta1/keptnappversion_conversion.go | 235 +------- .../v1beta1/keptnappversion_types.go | 4 +- .../keptnappversion_webhook.go | 2 +- .../v1beta1/keptnevaluation_types.go | 4 +- .../keptnevaluationdefinition_types.go | 4 +- .../apis/lifecycle/v1beta1/keptntask_types.go | 4 +- .../v1beta1/keptntaskdefinition_types.go | 4 +- .../keptntaskdefinition_webhook.go | 4 +- .../keptntaskdefinition_webhook_test.go | 2 +- .../lifecycle/v1beta1/keptnworkload_types.go | 4 +- .../v1beta1/keptnworkloadversion_types.go | 13 + .../v1beta1/zz_generated.deepcopy.go | 52 +- lifecycle-operator/chart/README.md | 69 ++- .../chart/templates/deployment.yaml | 3 - .../keptnevaluationprovider-crd.yaml | 10 - .../templates/keptnworkloadinstance-crd.yaml | 10 - ...ycle-validating-webhook-configuration.yaml | 4 +- lifecycle-operator/chart/values.yaml | 2 - ...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/crd/kustomization.yaml | 4 +- lifecycle-operator/config/rbac/role.yaml | 8 - .../config/webhook/manifests.yaml | 4 +- .../evaluation/fake/evaluationhandler_mock.go | 10 +- .../controllers/common/evaluation/handler.go | 24 +- .../common/evaluation/handler_test.go | 100 ++-- .../common/eventsender/eventsender.go | 2 +- .../common/eventsender/eventsender_test.go | 49 +- .../common/eventsender/fake/event_mock.go | 2 +- .../controllers/common/helperfunctions.go | 18 +- .../common/helperfunctions_test.go | 62 +- .../common/phase/fake/handler_mock.go | 2 +- .../controllers/common/phase/handler.go | 2 +- .../controllers/common/phase/handler_test.go | 64 +- .../providers/keptnmetric/keptnmetric.go | 8 +- .../providers/keptnmetric/keptnmetric_test.go | 26 +- .../fake/schedulinggateshandler_mock.go | 16 +- .../common/schedulinggates/handler.go | 8 +- .../common/schedulinggates/handler_test.go | 67 ++- .../controllers/common/task/handler.go | 22 +- .../controllers/common/task/handler_test.go | 140 ++--- .../common/taskdefinition/handler.go | 28 +- .../common/taskdefinition/handler_test.go | 230 ++++---- .../common/telemetry/metrics_test.go | 168 +++--- .../common/telemetry/otel_utils.go | 21 +- .../common/telemetry/spanhandler_test.go | 13 +- .../controllers/common/testcommon/utils.go | 24 +- .../interfaces/activemetricsobject_test.go | 8 +- .../lifecycle/interfaces/eventobject_test.go | 8 +- .../interfaces/fake/phaseitem_mock.go | 56 +- .../lifecycle/interfaces/listitem_test.go | 10 +- .../interfaces/metricsobject_test.go | 8 +- .../lifecycle/interfaces/phaseitem.go | 28 +- .../lifecycle/interfaces/phaseitem_test.go | 28 +- .../lifecycle/interfaces/spanitem_test.go | 10 +- .../lifecycle/keptnapp/controller.go | 18 +- .../lifecycle/keptnapp/controller_test.go | 22 +- .../keptnappcreationrequest/controller.go | 4 +- .../controller_test.go | 162 +++--- .../lifecycle/keptnappversion/controller.go | 12 +- .../keptnappversion/controller_test.go | 45 +- .../reconcile_prepostdeployment.go | 6 +- .../reconcile_prepostevaluation.go | 6 +- .../reconcile_workloadsstate.go | 21 +- .../reconcile_workloadstate_test.go | 57 +- .../lifecycle/keptnevaluation/common.go | 4 +- .../lifecycle/keptnevaluation/common_test.go | 76 +-- .../lifecycle/keptnevaluation/controller.go | 27 +- .../keptnevaluation/controller_test.go | 50 +- .../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 | 26 +- .../keptnworkload/controller_test.go | 13 +- .../keptnworkloadversion/controller.go | 49 +- .../keptnworkloadversion/controller_test.go | 333 ++++++----- .../reconcile_deploymentstate.go | 19 +- .../reconcile_prepostdeployment.go | 6 +- .../reconcile_prepostevaluation.go | 6 +- lifecycle-operator/main.go | 27 +- .../groupversion_info.go | 6 +- .../keptnmetric_types.go | 52 +- .../zz_generated.deepcopy.go | 31 +- .../test/component/app/app_test.go | 12 +- .../component/appversion/appversion_test.go | 28 +- .../test/component/common/common.go | 19 +- .../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 | 17 +- .../workloadversion/workloadversion_test.go | 75 ++- 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 +- .../00-install.yaml | 4 +- .../integration/api-conversion/00-assert.yaml | 33 -- .../api-conversion/00-install.yaml | 39 +- .../integration/api-conversion/01-assert.yaml | 41 +- .../api-conversion/01-install.yaml | 33 -- .../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 +- .../app-failing-pre-evaluation/00-assert.yaml | 2 +- .../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 | 14 +- .../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-install.yaml | 2 +- .../01-assert.yaml | 4 +- .../00-assert.yaml | 8 +- .../01-assert.yaml | 8 +- .../00-install.yaml | 2 +- .../01-assert.yaml | 4 +- .../01-assert.yaml | 8 +- .../00-assert.yaml | 4 +- .../00-install.yaml | 2 +- .../00-install.yaml | 4 +- .../01-assert.yaml | 2 +- .../00-install.yaml | 2 +- .../01-assert.yaml | 8 +- .../simple-deployment/00-install.yaml | 2 +- .../simple-deployment/01-assert.yaml | 8 +- .../00-install.yaml | 2 +- .../01-assert.yaml | 4 +- .../02-assert.yaml | 2 +- test/integration/simple-task/00-install.yaml | 4 +- .../td_bad_container_deno.yaml | 2 +- .../td_bad_container_function.yaml | 2 +- .../td_bad_container_python.yaml | 2 +- .../validate-taskdefinition/td_bad_empty.yaml | 2 +- .../td_bad_function_deno.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 | 4 +- .../00-assert.yaml | 4 +- .../00-install.yaml | 2 +- .../simple-deployment/00-install.yaml | 2 +- .../simple-deployment/01-assert.yaml | 8 +- 253 files changed, 2454 insertions(+), 6967 deletions(-) delete mode 100644 lifecycle-operator/apis/lifecycle/v1alpha1/keptnevaluationprovider_conversion.go delete mode 100644 lifecycle-operator/apis/lifecycle/v1alpha1/keptnevaluationprovider_conversion_test.go delete mode 100644 lifecycle-operator/apis/lifecycle/v1alpha1/keptnworkloadinstance_conversion.go delete mode 100644 lifecycle-operator/apis/lifecycle/v1alpha1/keptnworkloadinstance_conversion_test.go delete mode 100644 lifecycle-operator/apis/lifecycle/v1alpha1/keptnworkloadinstance_test.go delete mode 100644 lifecycle-operator/apis/lifecycle/v1alpha2/keptnevaluationprovider_conversion.go delete mode 100644 lifecycle-operator/apis/lifecycle/v1alpha2/keptnevaluationprovider_conversion_test.go delete mode 100644 lifecycle-operator/apis/lifecycle/v1alpha2/keptnevaluationprovider_test.go delete mode 100644 lifecycle-operator/apis/lifecycle/v1alpha2/keptnworkloadinstance_conversion.go delete mode 100644 lifecycle-operator/apis/lifecycle/v1alpha2/keptnworkloadinstance_conversion_test.go delete mode 100644 lifecycle-operator/apis/lifecycle/v1alpha2/keptnworkloadinstance_test.go rename lifecycle-operator/apis/lifecycle/{v1beta1 => v1alpha3}/keptnapp_conversion_test.go (91%) rename lifecycle-operator/apis/lifecycle/{v1beta1 => v1alpha3}/keptnappversion_conversion_test.go (80%) delete mode 100644 lifecycle-operator/apis/lifecycle/v1alpha3/keptnevaluationprovider_conversion.go delete mode 100644 lifecycle-operator/apis/lifecycle/v1alpha3/keptnevaluationprovider_webhook.go delete mode 100644 lifecycle-operator/apis/lifecycle/v1alpha3/keptntask_conversion.go delete mode 100644 lifecycle-operator/apis/lifecycle/v1alpha3/keptnworkloadinstance_conversion.go delete mode 100644 lifecycle-operator/apis/lifecycle/v1alpha3/keptnworkloadinstance_test.go delete mode 100644 lifecycle-operator/apis/lifecycle/v1alpha3/keptnworkloadinstance_webhook.go rename lifecycle-operator/apis/lifecycle/{v1alpha3 => v1beta1}/keptnapp_webhook.go (91%) rename lifecycle-operator/apis/lifecycle/{v1alpha3 => v1beta1}/keptnappversion_webhook.go (91%) rename lifecycle-operator/apis/lifecycle/{v1alpha3 => v1beta1}/keptntaskdefinition_webhook.go (91%) rename lifecycle-operator/apis/lifecycle/{v1alpha3 => v1beta1}/keptntaskdefinition_webhook_test.go (99%) rename lifecycle-operator/test/api/metrics/{v1alpha3 => v1beta1}/groupversion_info.go (89%) rename lifecycle-operator/test/api/metrics/{v1alpha3 => v1beta1}/keptnmetric_types.go (53%) rename lifecycle-operator/test/api/metrics/{v1alpha3 => v1beta1}/zz_generated.deepcopy.go (84%) diff --git a/.github/actions/spelling/expect.txt b/.github/actions/spelling/expect.txt index 788526dfba7..de95b5933be 100644 --- a/.github/actions/spelling/expect.txt +++ b/.github/actions/spelling/expect.txt @@ -380,7 +380,7 @@ kwv lastmod lastword Lato -lfc +LFC Lifcycle lifecyclekeptnsh linkedin diff --git a/.github/scripts/.helm-tests/default/result.yaml b/.github/scripts/.helm-tests/default/result.yaml index 9cb1116197d..32be2642089 100644 --- a/.github/scripts/.helm-tests/default/result.yaml +++ b/.github/scripts/.helm-tests/default/result.yaml @@ -2685,16 +2685,6 @@ metadata: app.kubernetes.io/version: vmyversion helm.sh/chart: lifecycle-operator-0.1.0 spec: - conversion: - strategy: Webhook - webhook: - clientConfig: - service: - name: 'lifecycle-webhook-service' - namespace: 'helmtests' - path: /convert - conversionReviewVersions: - - v1 group: lifecycle.keptn.sh names: kind: KeptnEvaluationProvider @@ -7170,16 +7160,6 @@ metadata: app.kubernetes.io/version: vmyversion helm.sh/chart: lifecycle-operator-0.1.0 spec: - conversion: - strategy: Webhook - webhook: - clientConfig: - service: - name: 'lifecycle-webhook-service' - namespace: 'helmtests' - path: /convert - conversionReviewVersions: - - v1 group: lifecycle.keptn.sh names: kind: KeptnWorkloadInstance @@ -11953,8 +11933,6 @@ spec: value: "0" - name: KEPTN_WORKLOAD_VERSION_CONTROLLER_LOG_LEVEL value: "0" - - name: KEPTN_WORKLOAD_INSTANCE_CONTROLLER_LOG_LEVEL - value: "0" - name: KEPTN_DORA_METRICS_PORT value: "2222" - name: OPTIONS_CONTROLLER_LOG_LEVEL @@ -12321,14 +12299,14 @@ webhooks: service: name: 'lifecycle-webhook-service' namespace: 'helmtests' - path: /validate-lifecycle-keptn-sh-v1alpha3-keptntaskdefinition + path: /validate-lifecycle-keptn-sh-v1beta1-keptntaskdefinition failurePolicy: Fail name: vkeptntaskdefinition.kb.io rules: - apiGroups: - lifecycle.keptn.sh apiVersions: - - v1alpha3 + - v1beta1 operations: - CREATE - UPDATE diff --git a/.github/scripts/.helm-tests/lifecycle-only/result.yaml b/.github/scripts/.helm-tests/lifecycle-only/result.yaml index 657436aae05..2a67c4eb330 100644 --- a/.github/scripts/.helm-tests/lifecycle-only/result.yaml +++ b/.github/scripts/.helm-tests/lifecycle-only/result.yaml @@ -2631,16 +2631,6 @@ metadata: app.kubernetes.io/version: vmyversion helm.sh/chart: lifecycle-operator-0.1.0 spec: - conversion: - strategy: Webhook - webhook: - clientConfig: - service: - name: 'lifecycle-webhook-service' - namespace: 'helmtests' - path: /convert - conversionReviewVersions: - - v1 group: lifecycle.keptn.sh names: kind: KeptnEvaluationProvider @@ -7116,16 +7106,6 @@ metadata: app.kubernetes.io/version: vmyversion helm.sh/chart: lifecycle-operator-0.1.0 spec: - conversion: - strategy: Webhook - webhook: - clientConfig: - service: - name: 'lifecycle-webhook-service' - namespace: 'helmtests' - path: /convert - conversionReviewVersions: - - v1 group: lifecycle.keptn.sh names: kind: KeptnWorkloadInstance @@ -9440,8 +9420,6 @@ spec: value: "0" - name: KEPTN_WORKLOAD_VERSION_CONTROLLER_LOG_LEVEL value: "0" - - name: KEPTN_WORKLOAD_INSTANCE_CONTROLLER_LOG_LEVEL - value: "0" - name: KEPTN_DORA_METRICS_PORT value: "2222" - name: OPTIONS_CONTROLLER_LOG_LEVEL @@ -9649,14 +9627,14 @@ webhooks: service: name: 'lifecycle-webhook-service' namespace: 'helmtests' - path: /validate-lifecycle-keptn-sh-v1alpha3-keptntaskdefinition + path: /validate-lifecycle-keptn-sh-v1beta1-keptntaskdefinition failurePolicy: Fail name: vkeptntaskdefinition.kb.io rules: - apiGroups: - lifecycle.keptn.sh apiVersions: - - v1alpha3 + - v1beta1 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 d90fdc30ddd..c5fe1e15dfd 100644 --- a/.github/scripts/.helm-tests/lifecycle-with-certs/result.yaml +++ b/.github/scripts/.helm-tests/lifecycle-with-certs/result.yaml @@ -2663,16 +2663,6 @@ metadata: app.kubernetes.io/version: vmyversion helm.sh/chart: lifecycle-operator-0.1.0 spec: - conversion: - strategy: Webhook - webhook: - clientConfig: - service: - name: 'lifecycle-webhook-service' - namespace: 'helmtests' - path: /convert - conversionReviewVersions: - - v1 group: lifecycle.keptn.sh names: kind: KeptnEvaluationProvider @@ -7152,16 +7142,6 @@ metadata: app.kubernetes.io/version: vmyversion helm.sh/chart: lifecycle-operator-0.1.0 spec: - conversion: - strategy: Webhook - webhook: - clientConfig: - service: - name: 'lifecycle-webhook-service' - namespace: 'helmtests' - path: /convert - conversionReviewVersions: - - v1 group: lifecycle.keptn.sh names: kind: KeptnWorkloadInstance @@ -9756,8 +9736,6 @@ spec: value: "0" - name: KEPTN_WORKLOAD_VERSION_CONTROLLER_LOG_LEVEL value: "0" - - name: KEPTN_WORKLOAD_INSTANCE_CONTROLLER_LOG_LEVEL - value: "0" - name: KEPTN_DORA_METRICS_PORT value: "2222" - name: OPTIONS_CONTROLLER_LOG_LEVEL @@ -9968,14 +9946,14 @@ webhooks: service: name: 'lifecycle-webhook-service' namespace: 'helmtests' - path: /validate-lifecycle-keptn-sh-v1alpha3-keptntaskdefinition + path: /validate-lifecycle-keptn-sh-v1beta1-keptntaskdefinition failurePolicy: Fail name: vkeptntaskdefinition.kb.io rules: - apiGroups: - lifecycle.keptn.sh apiVersions: - - v1alpha3 + - v1beta1 operations: - CREATE - UPDATE diff --git a/docs-new/docs/reference/api-reference/lifecycle/v1beta1/index.md b/docs-new/docs/reference/api-reference/lifecycle/v1beta1/index.md index 94bffbb2878..3aed801c1ba 100644 --- a/docs-new/docs/reference/api-reference/lifecycle/v1beta1/index.md +++ b/docs-new/docs/reference/api-reference/lifecycle/v1beta1/index.md @@ -251,7 +251,7 @@ _Appears in:_ | `preDeploymentEvaluations` _string array_ | PreDeploymentEvaluations is a list of all evaluations to be performed during the pre-deployment phase of the KeptnApp. The items of this list refer to the names of KeptnEvaluationDefinitions located in the same namespace as the KeptnApp, or in the Keptn namespace. || x | | `postDeploymentEvaluations` _string array_ | PostDeploymentEvaluations is a list of all evaluations to be performed during the post-deployment phase of the KeptnApp. The items of this list refer to the names of KeptnEvaluationDefinitions located in the same namespace as the KeptnApp, or in the Keptn namespace. || x | | `metadata` _object (keys:string, values:string)_ | Refer to Kubernetes API documentation for fields of `metadata`. || ✓ | -| `traceLinks` _string array_ | TraceLinks are links to trace IDs for tracking. || ✓ | +| `traceLinks` _string array_ | TraceLinks are links to OpenTelemetry span IDs for tracking. These links establish relationships between spans across different services, enabling distributed tracing. For more information on OpenTelemetry span links, refer to the documentation: https://opentelemetry.io/docs/concepts/signals/traces/#span-links || ✓ | #### KeptnAppContextStatus @@ -263,6 +263,9 @@ KeptnAppContextStatus defines the observed state of KeptnAppContext _Appears in:_ - [KeptnAppContext](#keptnappcontext) +| Field | Description | Default | Optional | +| --- | --- | --- | --- | +| `status` _string_ | unused field || ✓ | #### KeptnAppCreationRequest diff --git a/lifecycle-operator/apis/lifecycle/v1alpha1/common/common.go b/lifecycle-operator/apis/lifecycle/v1alpha1/common/common.go index abd94a1302c..5828115776f 100644 --- a/lifecycle-operator/apis/lifecycle/v1alpha1/common/common.go +++ b/lifecycle-operator/apis/lifecycle/v1alpha1/common/common.go @@ -32,10 +32,10 @@ const MaxWorkloadNameLength = 25 const MaxTaskNameLength = 25 const MaxVersionLength = 12 -var ErrCannotCastKeptnEvaluationProvider = errors.New("cannot cast KeptnEvaluationDefinition to v1alpha3") -var ErrCannotCastKeptnAppVersion = errors.New("cannot cast KeptnAppVersion to v1alpha3") -var ErrCannotCastKeptnApp = errors.New("cannot cast KeptnApp to v1alpha3") -var ErrCannotCastKeptnWorkloadInstance = errors.New("cannot cast KeptnWorkloadInstance to v1alpha3") +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") // 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 80b545455dc..a51656a6760 100644 --- a/lifecycle-operator/apis/lifecycle/v1alpha1/keptnapp_conversion.go +++ b/lifecycle-operator/apis/lifecycle/v1alpha1/keptnapp_conversion.go @@ -4,13 +4,13 @@ import ( "fmt" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha1/common" - "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3" + "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 (v1alpha3.KeptnApp) +// ConvertTo converts the src v1alpha1.KeptnApp to the hub version (v1beta1.KeptnApp) func (src *KeptnApp) ConvertTo(dstRaw conversion.Hub) error { - dst, ok := dstRaw.(*v1alpha3.KeptnApp) + dst, ok := dstRaw.(*v1beta1.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, v1alpha3.KeptnWorkloadRef{ + dst.Spec.Workloads = append(dst.Spec.Workloads, v1beta1.KeptnWorkloadRef{ Name: srcWl.Name, Version: srcWl.Version, }) @@ -40,9 +40,9 @@ func (src *KeptnApp) ConvertTo(dstRaw conversion.Hub) error { return nil } -// ConvertFrom converts from the hub version (v1alpha3.KeptnApp) to this version (v1alpha1.KeptnApp) +// ConvertFrom converts from the hub version (v1beta1.KeptnApp) to this version (v1alpha1.KeptnApp) func (dst *KeptnApp) ConvertFrom(srcRaw conversion.Hub) error { - src, ok := srcRaw.(*v1alpha3.KeptnApp) + src, ok := srcRaw.(*v1beta1.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 8ef7c9150d8..67730ecf83d 100644 --- a/lifecycle-operator/apis/lifecycle/v1alpha1/keptnapp_conversion_test.go +++ b/lifecycle-operator/apis/lifecycle/v1alpha1/keptnapp_conversion_test.go @@ -4,7 +4,7 @@ import ( "testing" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha1/common" - "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3" + "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" "github.com/stretchr/testify/require" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" v2 "sigs.k8s.io/controller-runtime/pkg/webhook/conversion/testdata/api/v2" @@ -13,16 +13,16 @@ import ( func TestKeptnApp_ConvertFrom(t *testing.T) { tests := []struct { name string - srcObj *v1alpha3.KeptnApp + srcObj *v1beta1.KeptnApp wantErr bool wantObj *KeptnApp }{ { - name: "Test that conversion from v1alpha3 to v1alpha1 works", - srcObj: &v1alpha3.KeptnApp{ + name: "Test that conversion from v1beta1 to v1alpha1 works", + srcObj: &v1beta1.KeptnApp{ TypeMeta: v1.TypeMeta{ Kind: "KeptnApp", - APIVersion: "lifecycle.keptn.sh/v1alpha3", + APIVersion: "lifecycle.keptn.sh/v1beta1", }, ObjectMeta: v1.ObjectMeta{ Name: "some-keptn-app-name", @@ -34,10 +34,10 @@ func TestKeptnApp_ConvertFrom(t *testing.T) { "some-annotation": "some-annotation-value", }, }, - Spec: v1alpha3.KeptnAppSpec{ + Spec: v1beta1.KeptnAppSpec{ Version: "1.2.3", Revision: 1, - Workloads: []v1alpha3.KeptnWorkloadRef{ + Workloads: []v1beta1.KeptnWorkloadRef{ { Name: "workload-1", Version: "1.2.3", @@ -60,7 +60,7 @@ func TestKeptnApp_ConvertFrom(t *testing.T) { "some-pre-evaluation-task2", }, }, - Status: v1alpha3.KeptnAppStatus{ + Status: v1beta1.KeptnAppStatus{ CurrentVersion: "1.2.3", }, }, @@ -130,10 +130,10 @@ func TestKeptnApp_ConvertTo(t *testing.T) { name string src *KeptnApp wantErr bool - wantObj *v1alpha3.KeptnApp + wantObj *v1beta1.KeptnApp }{ { - name: "Test that conversion from v1alpha1 to v1alpha3 works", + name: "Test that conversion from v1alpha1 to v1beta1 works", src: &KeptnApp{ TypeMeta: v1.TypeMeta{ Kind: "KeptnApp", @@ -179,7 +179,7 @@ func TestKeptnApp_ConvertTo(t *testing.T) { }, }, wantErr: false, - wantObj: &v1alpha3.KeptnApp{ + wantObj: &v1beta1.KeptnApp{ ObjectMeta: v1.ObjectMeta{ Name: "some-keptn-app-name", Namespace: "", @@ -190,10 +190,10 @@ func TestKeptnApp_ConvertTo(t *testing.T) { "some-annotation": "some-annotation-value", }, }, - Spec: v1alpha3.KeptnAppSpec{ + Spec: v1beta1.KeptnAppSpec{ Version: "1.2.3", Revision: 1, - Workloads: []v1alpha3.KeptnWorkloadRef{ + Workloads: []v1beta1.KeptnWorkloadRef{ { Name: "workload-1", Version: "1.2.3", @@ -216,7 +216,7 @@ func TestKeptnApp_ConvertTo(t *testing.T) { "some-pre-evaluation-task2", }, }, - Status: v1alpha3.KeptnAppStatus{ + Status: v1beta1.KeptnAppStatus{ CurrentVersion: "1.2.3", }, }, @@ -224,11 +224,11 @@ func TestKeptnApp_ConvertTo(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - dst := v1alpha3.KeptnApp{ + dst := v1beta1.KeptnApp{ TypeMeta: v1.TypeMeta{}, ObjectMeta: v1.ObjectMeta{}, - Spec: v1alpha3.KeptnAppSpec{}, - Status: v1alpha3.KeptnAppStatus{}, + Spec: v1beta1.KeptnAppSpec{}, + Status: v1beta1.KeptnAppStatus{}, } if err := tt.src.ConvertTo(&dst); (err != nil) != tt.wantErr { t.Errorf("ConvertTo() error = %v, wantErr %v", err, tt.wantErr) diff --git a/lifecycle-operator/apis/lifecycle/v1alpha1/keptnappversion_conversion.go b/lifecycle-operator/apis/lifecycle/v1alpha1/keptnappversion_conversion.go index 54760f487f3..1bfaeb025ac 100644 --- a/lifecycle-operator/apis/lifecycle/v1alpha1/keptnappversion_conversion.go +++ b/lifecycle-operator/apis/lifecycle/v1alpha1/keptnappversion_conversion.go @@ -4,17 +4,17 @@ import ( "fmt" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha1/common" - "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3" - v1alpha3common "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 v1alpha1.KeptnAppVersion to the hub version (v1alpha3.KeptnAppVersion) +// ConvertTo converts the src v1alpha1.KeptnAppVersion to the hub version (v1beta1.KeptnAppVersion) // //nolint:gocyclo func (src *KeptnAppVersion) ConvertTo(dstRaw conversion.Hub) error { - dst, ok := dstRaw.(*v1alpha3.KeptnAppVersion) + dst, ok := dstRaw.(*v1beta1.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, v1alpha3.KeptnWorkloadRef{ + dst.Spec.Workloads = append(dst.Spec.Workloads, v1beta1.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 = v1alpha3common.KeptnState(src.Status.PreDeploymentStatus) - dst.Status.PostDeploymentStatus = v1alpha3common.KeptnState(src.Status.PostDeploymentStatus) - dst.Status.PreDeploymentEvaluationStatus = v1alpha3common.KeptnState(src.Status.PreDeploymentEvaluationStatus) - dst.Status.PostDeploymentEvaluationStatus = v1alpha3common.KeptnState(src.Status.PostDeploymentEvaluationStatus) - dst.Status.WorkloadOverallStatus = v1alpha3common.KeptnState(src.Status.WorkloadOverallStatus) - dst.Status.Status = v1alpha3common.KeptnState(src.Status.Status) + 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) for _, srcWls := range src.Status.WorkloadStatus { - dst.Status.WorkloadStatus = append(dst.Status.WorkloadStatus, v1alpha3.WorkloadStatus{ - Workload: v1alpha3.KeptnWorkloadRef{ + dst.Status.WorkloadStatus = append(dst.Status.WorkloadStatus, v1beta1.WorkloadStatus{ + Workload: v1beta1.KeptnWorkloadRef{ Name: srcWls.Workload.Name, Version: srcWls.Workload.Version, }, - Status: v1alpha3common.KeptnState(srcWls.Status), + Status: v1beta1common.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, v1alpha3.ItemStatus{ + dst.Status.PreDeploymentTaskStatus = append(dst.Status.PreDeploymentTaskStatus, v1beta1.ItemStatus{ DefinitionName: item.TaskDefinitionName, - Status: v1alpha3common.KeptnState(item.Status), + Status: v1beta1common.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, v1alpha3.ItemStatus{ + dst.Status.PostDeploymentTaskStatus = append(dst.Status.PostDeploymentTaskStatus, v1beta1.ItemStatus{ DefinitionName: item.TaskDefinitionName, - Status: v1alpha3common.KeptnState(item.Status), + Status: v1beta1common.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, v1alpha3.ItemStatus{ + dst.Status.PreDeploymentEvaluationTaskStatus = append(dst.Status.PreDeploymentEvaluationTaskStatus, v1beta1.ItemStatus{ DefinitionName: item.EvaluationDefinitionName, - Status: v1alpha3common.KeptnState(item.Status), + Status: v1beta1common.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, v1alpha3.ItemStatus{ + dst.Status.PostDeploymentEvaluationTaskStatus = append(dst.Status.PostDeploymentEvaluationTaskStatus, v1beta1.ItemStatus{ DefinitionName: item.EvaluationDefinitionName, - Status: v1alpha3common.KeptnState(item.Status), + Status: v1beta1common.KeptnState(item.Status), Name: item.EvaluationName, StartTime: item.StartTime, EndTime: item.EndTime, }) } - dst.Status.PhaseTraceIDs = make(v1alpha3common.PhaseTraceID, len(src.Status.PhaseTraceIDs)) + 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 { @@ -122,11 +122,11 @@ func (src *KeptnAppVersion) ConvertTo(dstRaw conversion.Hub) error { return nil } -// ConvertFrom converts from the hub version (v1alpha3.KeptnAppVersion) to this version (v1alpha1.KeptnAppVersion) +// ConvertFrom converts from the hub version (v1beta1.KeptnAppVersion) to this version (v1alpha1.KeptnAppVersion) // //nolint:gocyclo func (dst *KeptnAppVersion) ConvertFrom(srcRaw conversion.Hub) error { - src, ok := srcRaw.(*v1alpha3.KeptnAppVersion) + src, ok := srcRaw.(*v1beta1.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 4ca42bbf8ab..47b89fab6b8 100644 --- a/lifecycle-operator/apis/lifecycle/v1alpha1/keptnappversion_conversion_test.go +++ b/lifecycle-operator/apis/lifecycle/v1alpha1/keptnappversion_conversion_test.go @@ -5,8 +5,8 @@ import ( "testing" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha1/common" - "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3" - v1alpha3common "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" @@ -16,16 +16,16 @@ import ( func TestKeptnAppVersion_ConvertFrom(t *testing.T) { tests := []struct { name string - srcObj *v1alpha3.KeptnAppVersion + srcObj *v1beta1.KeptnAppVersion wantErr bool wantObj *KeptnAppVersion }{ { - name: "Test that conversion from v1alpha3 to v1alpha1 works", - srcObj: &v1alpha3.KeptnAppVersion{ + name: "Test that conversion from v1beta1 to v1alpha1 works", + srcObj: &v1beta1.KeptnAppVersion{ TypeMeta: v1.TypeMeta{ Kind: "KeptnAppVersion", - APIVersion: "lifecycle.keptn.sh/v1alpha3", + APIVersion: "lifecycle.keptn.sh/v1beta1", }, ObjectMeta: v1.ObjectMeta{ Name: "some-keptn-app-name", @@ -37,11 +37,11 @@ func TestKeptnAppVersion_ConvertFrom(t *testing.T) { "some-annotation": "some-annotation-value", }, }, - Spec: v1alpha3.KeptnAppVersionSpec{ - KeptnAppSpec: v1alpha3.KeptnAppSpec{ + Spec: v1beta1.KeptnAppVersionSpec{ + KeptnAppSpec: v1beta1.KeptnAppSpec{ Version: "1.2.3", Revision: 1, - Workloads: []v1alpha3.KeptnWorkloadRef{ + Workloads: []v1beta1.KeptnWorkloadRef{ { Name: "workload-1", Version: "1.2.3", @@ -71,78 +71,78 @@ func TestKeptnAppVersion_ConvertFrom(t *testing.T) { "key2": "value2", }, }, - Status: v1alpha3.KeptnAppVersionStatus{ - PreDeploymentStatus: v1alpha3common.StateFailed, - PostDeploymentStatus: v1alpha3common.StateFailed, - PreDeploymentEvaluationStatus: v1alpha3common.StateFailed, - PostDeploymentEvaluationStatus: v1alpha3common.StateFailed, - WorkloadOverallStatus: v1alpha3common.StateFailed, - WorkloadStatus: []v1alpha3.WorkloadStatus{ - { - Workload: v1alpha3.KeptnWorkloadRef{ + Status: v1beta1.KeptnAppVersionStatus{ + PreDeploymentStatus: v1beta1common.StateFailed, + PostDeploymentStatus: v1beta1common.StateFailed, + PreDeploymentEvaluationStatus: v1beta1common.StateFailed, + PostDeploymentEvaluationStatus: v1beta1common.StateFailed, + WorkloadOverallStatus: v1beta1common.StateFailed, + WorkloadStatus: []v1beta1.WorkloadStatus{ + { + Workload: v1beta1.KeptnWorkloadRef{ Name: "name1", Version: "1", }, - Status: v1alpha3common.StateFailed, + Status: v1beta1common.StateFailed, }, { - Workload: v1alpha3.KeptnWorkloadRef{ + Workload: v1beta1.KeptnWorkloadRef{ Name: "name2", Version: "2", }, - Status: v1alpha3common.StateFailed, + Status: v1beta1common.StateFailed, }, }, CurrentPhase: "phase", - PreDeploymentTaskStatus: []v1alpha3.ItemStatus{ + PreDeploymentTaskStatus: []v1beta1.ItemStatus{ { DefinitionName: "def1", Name: "name1", - Status: v1alpha3common.StateFailed, + Status: v1beta1common.StateFailed, }, { DefinitionName: "def12", Name: "name12", - Status: v1alpha3common.StateFailed, + Status: v1beta1common.StateFailed, }, }, - PostDeploymentTaskStatus: []v1alpha3.ItemStatus{ + PostDeploymentTaskStatus: []v1beta1.ItemStatus{ { DefinitionName: "def2", Name: "name2", - Status: v1alpha3common.StateFailed, + Status: v1beta1common.StateFailed, }, { DefinitionName: "def22", Name: "name22", - Status: v1alpha3common.StateFailed, + Status: v1beta1common.StateFailed, }, }, - PreDeploymentEvaluationTaskStatus: []v1alpha3.ItemStatus{ + PreDeploymentEvaluationTaskStatus: []v1beta1.ItemStatus{ { DefinitionName: "def3", Name: "name3", - Status: v1alpha3common.StateFailed, + Status: v1beta1common.StateFailed, }, { DefinitionName: "def32", Name: "name32", - Status: v1alpha3common.StateFailed, + Status: v1beta1common.StateFailed, }, }, - PostDeploymentEvaluationTaskStatus: []v1alpha3.ItemStatus{ + PostDeploymentEvaluationTaskStatus: []v1beta1.ItemStatus{ { DefinitionName: "def4", Name: "name4", - Status: v1alpha3common.StateFailed, + Status: v1beta1common.StateFailed, }, { DefinitionName: "def42", Name: "name42", - Status: v1alpha3common.StateFailed, + Status: v1beta1common.StateFailed, }, }, - PhaseTraceIDs: v1alpha3common.PhaseTraceID{ + PhaseTraceIDs: v1beta1common.PhaseTraceID{ "key": propagation.MapCarrier{ "key1": "value1", "key2": "value2", @@ -152,7 +152,7 @@ func TestKeptnAppVersion_ConvertFrom(t *testing.T) { "key222": "value222", }, }, - Status: v1alpha3common.StateFailed, + Status: v1beta1common.StateFailed, }, }, wantErr: false, @@ -309,10 +309,10 @@ func TestKeptnAppVersion_ConvertTo(t *testing.T) { name string src *KeptnAppVersion wantErr bool - wantObj *v1alpha3.KeptnAppVersion + wantObj *v1beta1.KeptnAppVersion }{ { - name: "Test that conversion from v1alpha1 to v1alpha3 works", + name: "Test that conversion from v1alpha1 to v1beta1 works", src: &KeptnAppVersion{ TypeMeta: v1.TypeMeta{ Kind: "KeptnAppVersion", @@ -446,7 +446,7 @@ func TestKeptnAppVersion_ConvertTo(t *testing.T) { }, }, wantErr: false, - wantObj: &v1alpha3.KeptnAppVersion{ + wantObj: &v1beta1.KeptnAppVersion{ ObjectMeta: v1.ObjectMeta{ Name: "some-keptn-app-name", Namespace: "", @@ -457,11 +457,11 @@ func TestKeptnAppVersion_ConvertTo(t *testing.T) { "some-annotation": "some-annotation-value", }, }, - Spec: v1alpha3.KeptnAppVersionSpec{ - KeptnAppSpec: v1alpha3.KeptnAppSpec{ + Spec: v1beta1.KeptnAppVersionSpec{ + KeptnAppSpec: v1beta1.KeptnAppSpec{ Version: "1.2.3", Revision: 1, - Workloads: []v1alpha3.KeptnWorkloadRef{ + Workloads: []v1beta1.KeptnWorkloadRef{ { Name: "workload-1", Version: "1.2.3", @@ -491,78 +491,78 @@ func TestKeptnAppVersion_ConvertTo(t *testing.T) { "key2": "value2", }, }, - Status: v1alpha3.KeptnAppVersionStatus{ - PreDeploymentStatus: v1alpha3common.StateFailed, - PostDeploymentStatus: v1alpha3common.StateFailed, - PreDeploymentEvaluationStatus: v1alpha3common.StateFailed, - PostDeploymentEvaluationStatus: v1alpha3common.StateFailed, - WorkloadOverallStatus: v1alpha3common.StateFailed, - WorkloadStatus: []v1alpha3.WorkloadStatus{ - { - Workload: v1alpha3.KeptnWorkloadRef{ + Status: v1beta1.KeptnAppVersionStatus{ + PreDeploymentStatus: v1beta1common.StateFailed, + PostDeploymentStatus: v1beta1common.StateFailed, + PreDeploymentEvaluationStatus: v1beta1common.StateFailed, + PostDeploymentEvaluationStatus: v1beta1common.StateFailed, + WorkloadOverallStatus: v1beta1common.StateFailed, + WorkloadStatus: []v1beta1.WorkloadStatus{ + { + Workload: v1beta1.KeptnWorkloadRef{ Name: "name1", Version: "1", }, - Status: v1alpha3common.StateFailed, + Status: v1beta1common.StateFailed, }, { - Workload: v1alpha3.KeptnWorkloadRef{ + Workload: v1beta1.KeptnWorkloadRef{ Name: "name2", Version: "2", }, - Status: v1alpha3common.StateFailed, + Status: v1beta1common.StateFailed, }, }, CurrentPhase: "phase", - PreDeploymentTaskStatus: []v1alpha3.ItemStatus{ + PreDeploymentTaskStatus: []v1beta1.ItemStatus{ { DefinitionName: "def1", Name: "name1", - Status: v1alpha3common.StateFailed, + Status: v1beta1common.StateFailed, }, { DefinitionName: "def12", Name: "name12", - Status: v1alpha3common.StateFailed, + Status: v1beta1common.StateFailed, }, }, - PostDeploymentTaskStatus: []v1alpha3.ItemStatus{ + PostDeploymentTaskStatus: []v1beta1.ItemStatus{ { DefinitionName: "def2", Name: "name2", - Status: v1alpha3common.StateFailed, + Status: v1beta1common.StateFailed, }, { DefinitionName: "def22", Name: "name22", - Status: v1alpha3common.StateFailed, + Status: v1beta1common.StateFailed, }, }, - PreDeploymentEvaluationTaskStatus: []v1alpha3.ItemStatus{ + PreDeploymentEvaluationTaskStatus: []v1beta1.ItemStatus{ { DefinitionName: "def3", Name: "name3", - Status: v1alpha3common.StateFailed, + Status: v1beta1common.StateFailed, }, { DefinitionName: "def32", Name: "name32", - Status: v1alpha3common.StateFailed, + Status: v1beta1common.StateFailed, }, }, - PostDeploymentEvaluationTaskStatus: []v1alpha3.ItemStatus{ + PostDeploymentEvaluationTaskStatus: []v1beta1.ItemStatus{ { DefinitionName: "def4", Name: "name4", - Status: v1alpha3common.StateFailed, + Status: v1beta1common.StateFailed, }, { DefinitionName: "def42", Name: "name42", - Status: v1alpha3common.StateFailed, + Status: v1beta1common.StateFailed, }, }, - PhaseTraceIDs: v1alpha3common.PhaseTraceID{ + PhaseTraceIDs: v1beta1common.PhaseTraceID{ "key": propagation.MapCarrier{ "key1": "value1", "key2": "value2", @@ -572,18 +572,18 @@ func TestKeptnAppVersion_ConvertTo(t *testing.T) { "key222": "value222", }, }, - Status: v1alpha3common.StateFailed, + Status: v1beta1common.StateFailed, }, }, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - dst := v1alpha3.KeptnAppVersion{ + dst := v1beta1.KeptnAppVersion{ TypeMeta: v1.TypeMeta{}, ObjectMeta: v1.ObjectMeta{}, - Spec: v1alpha3.KeptnAppVersionSpec{}, - Status: v1alpha3.KeptnAppVersionStatus{}, + Spec: v1beta1.KeptnAppVersionSpec{}, + Status: v1beta1.KeptnAppVersionStatus{}, } if err := tt.src.ConvertTo(&dst); (err != nil) != tt.wantErr { t.Errorf("ConvertTo() error = %v, wantErr %v", err, tt.wantErr) diff --git a/lifecycle-operator/apis/lifecycle/v1alpha1/keptnevaluationprovider_conversion.go b/lifecycle-operator/apis/lifecycle/v1alpha1/keptnevaluationprovider_conversion.go deleted file mode 100644 index 0707ef0def5..00000000000 --- a/lifecycle-operator/apis/lifecycle/v1alpha1/keptnevaluationprovider_conversion.go +++ /dev/null @@ -1,53 +0,0 @@ -package v1alpha1 - -import ( - "fmt" - - "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha1/common" - "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3" - corev1 "k8s.io/api/core/v1" - "sigs.k8s.io/controller-runtime/pkg/conversion" -) - -// ConvertTo converts the src v1alpha1.KeptnEvaluationProvider to the hub version (v1alpha3.KeptnEvaluationProvider) -func (src *KeptnEvaluationProvider) ConvertTo(dstRaw conversion.Hub) error { - dst, ok := dstRaw.(*v1alpha3.KeptnEvaluationProvider) - - if !ok { - return fmt.Errorf("type %T %w", dstRaw, common.ErrCannotCastKeptnEvaluationProvider) - } - - // Copy equal stuff to new object - // DO NOT COPY TypeMeta - dst.ObjectMeta = src.ObjectMeta - - dst.Spec.TargetServer = src.Spec.TargetServer - - // Set sensible defaults for new fields - dst.Spec.SecretKeyRef = corev1.SecretKeySelector{ - LocalObjectReference: corev1.LocalObjectReference{ - Name: src.Spec.SecretName, - }, - Key: "apiToken", - } - - return nil -} - -// ConvertFrom converts from the hub version (v1alpha3.KeptnEvaluationProvider) to this version (v1alpha1.KeptnEvaluationProvider) -func (dst *KeptnEvaluationProvider) ConvertFrom(srcRaw conversion.Hub) error { - src, ok := srcRaw.(*v1alpha3.KeptnEvaluationProvider) - - if !ok { - return fmt.Errorf("type %T %w", srcRaw, common.ErrCannotCastKeptnEvaluationProvider) - } - - // Copy equal stuff to new object - // DO NOT COPY TypeMeta - dst.ObjectMeta = src.ObjectMeta - - dst.Spec.TargetServer = src.Spec.TargetServer - dst.Spec.SecretName = src.Spec.SecretKeyRef.Name - - return nil -} diff --git a/lifecycle-operator/apis/lifecycle/v1alpha1/keptnevaluationprovider_conversion_test.go b/lifecycle-operator/apis/lifecycle/v1alpha1/keptnevaluationprovider_conversion_test.go deleted file mode 100644 index f0831624d6f..00000000000 --- a/lifecycle-operator/apis/lifecycle/v1alpha1/keptnevaluationprovider_conversion_test.go +++ /dev/null @@ -1,178 +0,0 @@ -package v1alpha1 - -import ( - "testing" - - "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha1/common" - "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3" - "github.com/stretchr/testify/require" - corev1 "k8s.io/api/core/v1" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - v2 "sigs.k8s.io/controller-runtime/pkg/webhook/conversion/testdata/api/v2" -) - -func TestKeptnEvalProvider_ConvertFrom(t *testing.T) { - tests := []struct { - name string - srcObj *v1alpha3.KeptnEvaluationProvider - wantErr bool - wantObj *KeptnEvaluationProvider - }{ - { - name: "Test that conversion from v1alpha3 to v1alpha1 works", - srcObj: &v1alpha3.KeptnEvaluationProvider{ - TypeMeta: v1.TypeMeta{ - Kind: "KeptnEvaluationProvider", - APIVersion: "lifecycle.keptn.sh/v1alpha3", - }, - ObjectMeta: v1.ObjectMeta{ - Name: "some-keptn-app-name", - Namespace: "", - Labels: map[string]string{ - "some-label": "some-label-value", - }, - Annotations: map[string]string{ - "some-annotation": "some-annotation-value", - }, - }, - Spec: v1alpha3.KeptnEvaluationProviderSpec{ - TargetServer: "my-server", - SecretKeyRef: corev1.SecretKeySelector{ - LocalObjectReference: corev1.LocalObjectReference{ - Name: "my-secret-name", - }, - Key: "my-secret-key", - }, - }, - }, - wantErr: false, - wantObj: &KeptnEvaluationProvider{ - ObjectMeta: v1.ObjectMeta{ - Name: "some-keptn-app-name", - Namespace: "", - Labels: map[string]string{ - "some-label": "some-label-value", - }, - Annotations: map[string]string{ - "some-annotation": "some-annotation-value", - }, - }, - Spec: KeptnEvaluationProviderSpec{ - TargetServer: "my-server", - SecretName: "my-secret-name", - }, - }, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - dst := &KeptnEvaluationProvider{ - TypeMeta: v1.TypeMeta{}, - ObjectMeta: v1.ObjectMeta{}, - Spec: KeptnEvaluationProviderSpec{}, - } - if err := dst.ConvertFrom(tt.srcObj); (err != nil) != tt.wantErr { - t.Errorf("ConvertFrom() error = %v, wantErr %v", err, tt.wantErr) - } - if tt.wantObj != nil { - require.Equal(t, tt.wantObj, dst, "Object was not converted correctly") - } - }) - } -} - -func TestKeptnEvalProvider_ConvertTo(t *testing.T) { - tests := []struct { - name string - src *KeptnEvaluationProvider - wantErr bool - wantObj *v1alpha3.KeptnEvaluationProvider - }{ - { - name: "Test that conversion from v1alpha1 to v1alpha3 works", - src: &KeptnEvaluationProvider{ - TypeMeta: v1.TypeMeta{ - Kind: "KeptnEvaluationProvider", - APIVersion: "lifecycle.keptn.sh/v1alpha1", - }, - ObjectMeta: v1.ObjectMeta{ - Name: "some-keptn-app-name", - Namespace: "", - Labels: map[string]string{ - "some-label": "some-label-value", - }, - Annotations: map[string]string{ - "some-annotation": "some-annotation-value", - }, - }, - Spec: KeptnEvaluationProviderSpec{ - TargetServer: "my-server", - SecretName: "my-secret-name", - }, - }, - wantErr: false, - wantObj: &v1alpha3.KeptnEvaluationProvider{ - ObjectMeta: v1.ObjectMeta{ - Name: "some-keptn-app-name", - Namespace: "", - Labels: map[string]string{ - "some-label": "some-label-value", - }, - Annotations: map[string]string{ - "some-annotation": "some-annotation-value", - }, - }, - Spec: v1alpha3.KeptnEvaluationProviderSpec{ - TargetServer: "my-server", - SecretKeyRef: corev1.SecretKeySelector{ - LocalObjectReference: corev1.LocalObjectReference{ - Name: "my-secret-name", - }, - Key: "apiToken", - }, - }, - }, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - dst := v1alpha3.KeptnEvaluationProvider{ - TypeMeta: v1.TypeMeta{}, - ObjectMeta: v1.ObjectMeta{}, - Spec: v1alpha3.KeptnEvaluationProviderSpec{}, - } - if err := tt.src.ConvertTo(&dst); (err != nil) != tt.wantErr { - t.Errorf("ConvertTo() error = %v, wantErr %v", err, tt.wantErr) - } - if tt.wantObj != nil { - require.Equal(t, tt.wantObj, &dst, "Object was not converted correctly") - } - }) - } -} - -func TestKeptnEvalProvider_ConvertFrom_Errorcase(t *testing.T) { - // A random different object is used here to simulate a different API version - testObj := v2.ExternalJob{} - - dst := &KeptnEvaluationProvider{} - - if err := dst.ConvertFrom(&testObj); err == nil { - t.Errorf("ConvertFrom() error = %v", err) - } else { - require.ErrorIs(t, err, common.ErrCannotCastKeptnEvaluationProvider) - } -} - -func TestKeptnEvalProvider_ConvertTo_Errorcase(t *testing.T) { - testObj := KeptnEvaluationProvider{} - - // A random different object is used here to simulate a different API version - dst := v2.ExternalJob{} - - if err := testObj.ConvertTo(&dst); err == nil { - t.Errorf("ConvertTo() error = %v", err) - } else { - require.ErrorIs(t, err, common.ErrCannotCastKeptnEvaluationProvider) - } -} diff --git a/lifecycle-operator/apis/lifecycle/v1alpha1/keptnworkloadinstance_conversion.go b/lifecycle-operator/apis/lifecycle/v1alpha1/keptnworkloadinstance_conversion.go deleted file mode 100644 index 83e0b11c6dd..00000000000 --- a/lifecycle-operator/apis/lifecycle/v1alpha1/keptnworkloadinstance_conversion.go +++ /dev/null @@ -1,203 +0,0 @@ -package v1alpha1 - -import ( - "fmt" - - "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha1/common" - "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3" - v1alpha3common "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3/common" - "go.opentelemetry.io/otel/propagation" - "sigs.k8s.io/controller-runtime/pkg/conversion" -) - -// ConvertTo converts the src v1alpha1.KeptnWorkloadInstance to the hub version (v1alpha3.KeptnWorkloadInstance) -func (src *KeptnWorkloadInstance) ConvertTo(dstRaw conversion.Hub) error { - dst, ok := dstRaw.(*v1alpha3.KeptnWorkloadInstance) - - if !ok { - return fmt.Errorf("type %T %w", dstRaw, common.ErrCannotCastKeptnWorkloadInstance) - } - - // Copy equal stuff to new object - // DO NOT COPY TypeMeta - dst.ObjectMeta = src.ObjectMeta - - dst.Spec.AppName = src.Spec.AppName - dst.Spec.Version = src.Spec.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.ResourceReference = v1alpha3.ResourceReference{ - UID: src.Spec.ResourceReference.UID, - Kind: src.Spec.ResourceReference.Kind, - Name: src.Spec.ResourceReference.Name, - } - - dst.Spec.WorkloadName = src.Spec.WorkloadName - 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 = v1alpha3common.KeptnState(src.Status.PreDeploymentStatus) - dst.Status.PostDeploymentStatus = v1alpha3common.KeptnState(src.Status.PostDeploymentStatus) - dst.Status.PreDeploymentEvaluationStatus = v1alpha3common.KeptnState(src.Status.PreDeploymentEvaluationStatus) - dst.Status.PostDeploymentEvaluationStatus = v1alpha3common.KeptnState(src.Status.PostDeploymentEvaluationStatus) - dst.Status.DeploymentStatus = v1alpha3common.KeptnState(src.Status.DeploymentStatus) - dst.Status.Status = v1alpha3common.KeptnState(src.Status.Status) - - dst.Status.CurrentPhase = src.Status.CurrentPhase - - // Convert changed fields - for _, item := range src.Status.PreDeploymentTaskStatus { - dst.Status.PreDeploymentTaskStatus = append(dst.Status.PreDeploymentTaskStatus, v1alpha3.ItemStatus{ - DefinitionName: item.TaskDefinitionName, - Status: v1alpha3common.KeptnState(item.Status), - Name: item.TaskName, - StartTime: item.StartTime, - EndTime: item.EndTime, - }) - } - - for _, item := range src.Status.PostDeploymentTaskStatus { - dst.Status.PostDeploymentTaskStatus = append(dst.Status.PostDeploymentTaskStatus, v1alpha3.ItemStatus{ - DefinitionName: item.TaskDefinitionName, - Status: v1alpha3common.KeptnState(item.Status), - Name: item.TaskName, - StartTime: item.StartTime, - EndTime: item.EndTime, - }) - } - - for _, item := range src.Status.PreDeploymentEvaluationTaskStatus { - dst.Status.PreDeploymentEvaluationTaskStatus = append(dst.Status.PreDeploymentEvaluationTaskStatus, v1alpha3.ItemStatus{ - DefinitionName: item.EvaluationDefinitionName, - Status: v1alpha3common.KeptnState(item.Status), - Name: item.EvaluationName, - StartTime: item.StartTime, - EndTime: item.EndTime, - }) - } - - for _, item := range src.Status.PostDeploymentEvaluationTaskStatus { - dst.Status.PostDeploymentEvaluationTaskStatus = append(dst.Status.PostDeploymentEvaluationTaskStatus, v1alpha3.ItemStatus{ - DefinitionName: item.EvaluationDefinitionName, - Status: v1alpha3common.KeptnState(item.Status), - Name: item.EvaluationName, - StartTime: item.StartTime, - EndTime: item.EndTime, - }) - } - - dst.Status.PhaseTraceIDs = make(v1alpha3common.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 (v1alpha3.KeptnWorkloadInstance) to this version (v1alpha1.KeptnWorkloadInstance) -func (dst *KeptnWorkloadInstance) ConvertFrom(srcRaw conversion.Hub) error { - src, ok := srcRaw.(*v1alpha3.KeptnWorkloadInstance) - - if !ok { - return fmt.Errorf("type %T %w", srcRaw, common.ErrCannotCastKeptnWorkloadInstance) - } - - // Copy equal stuff to new object - // DO NOT COPY TypeMeta - dst.ObjectMeta = src.ObjectMeta - - dst.Spec.AppName = src.Spec.AppName - dst.Spec.Version = src.Spec.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.ResourceReference = ResourceReference{ - UID: src.Spec.ResourceReference.UID, - Kind: src.Spec.ResourceReference.Kind, - Name: src.Spec.ResourceReference.Name, - } - - dst.Spec.WorkloadName = src.Spec.WorkloadName - 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 = 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.DeploymentStatus = common.KeptnState(src.Status.DeploymentStatus) - dst.Status.Status = common.KeptnState(src.Status.Status) - - dst.Status.CurrentPhase = src.Status.CurrentPhase - - // Convert changed fields - for _, item := range src.Status.PreDeploymentTaskStatus { - dst.Status.PreDeploymentTaskStatus = append(dst.Status.PreDeploymentTaskStatus, TaskStatus{ - TaskDefinitionName: item.DefinitionName, - Status: common.KeptnState(item.Status), - TaskName: item.Name, - StartTime: item.StartTime, - EndTime: item.EndTime, - }) - } - - for _, item := range src.Status.PostDeploymentTaskStatus { - dst.Status.PostDeploymentTaskStatus = append(dst.Status.PostDeploymentTaskStatus, TaskStatus{ - TaskDefinitionName: item.DefinitionName, - Status: common.KeptnState(item.Status), - TaskName: item.Name, - StartTime: item.StartTime, - EndTime: item.EndTime, - }) - } - - for _, item := range src.Status.PreDeploymentEvaluationTaskStatus { - dst.Status.PreDeploymentEvaluationTaskStatus = append(dst.Status.PreDeploymentEvaluationTaskStatus, EvaluationStatus{ - EvaluationDefinitionName: item.DefinitionName, - Status: common.KeptnState(item.Status), - EvaluationName: item.Name, - StartTime: item.StartTime, - EndTime: item.EndTime, - }) - } - - for _, item := range src.Status.PostDeploymentEvaluationTaskStatus { - dst.Status.PostDeploymentEvaluationTaskStatus = append(dst.Status.PostDeploymentEvaluationTaskStatus, EvaluationStatus{ - EvaluationDefinitionName: item.DefinitionName, - Status: common.KeptnState(item.Status), - EvaluationName: 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/v1alpha1/keptnworkloadinstance_conversion_test.go b/lifecycle-operator/apis/lifecycle/v1alpha1/keptnworkloadinstance_conversion_test.go deleted file mode 100644 index 02dddf6723a..00000000000 --- a/lifecycle-operator/apis/lifecycle/v1alpha1/keptnworkloadinstance_conversion_test.go +++ /dev/null @@ -1,546 +0,0 @@ -//nolint:dupl -package v1alpha1 - -import ( - "testing" - - "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha1/common" - "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3" - v1alpha3common "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3/common" - "github.com/stretchr/testify/require" - "go.opentelemetry.io/otel/propagation" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/types" - v2 "sigs.k8s.io/controller-runtime/pkg/webhook/conversion/testdata/api/v2" -) - -func TestKeptnWorkloadInstance_ConvertFrom(t *testing.T) { - tests := []struct { - name string - srcObj *v1alpha3.KeptnWorkloadInstance - wantErr bool - wantObj *KeptnWorkloadInstance - }{ - { - name: "Test that conversion from v1alpha3 to v1alpha1 works", - srcObj: &v1alpha3.KeptnWorkloadInstance{ - TypeMeta: v1.TypeMeta{ - Kind: "KeptnWorkloadInstance", - APIVersion: "lifecycle.keptn.sh/v1alpha3", - }, - ObjectMeta: v1.ObjectMeta{ - Name: "some-keptn-app-name", - Namespace: "", - Labels: map[string]string{ - "some-label": "some-label-value", - }, - Annotations: map[string]string{ - "some-annotation": "some-annotation-value", - }, - }, - Spec: v1alpha3.KeptnWorkloadInstanceSpec{ - KeptnWorkloadSpec: v1alpha3.KeptnWorkloadSpec{ - Version: "1.2.3", - ResourceReference: v1alpha3.ResourceReference{ - UID: types.UID("1"), - Kind: "Pod", - Name: "pod", - }, - PreDeploymentTasks: []string{ - "some-pre-deployment-task1", - }, - PostDeploymentTasks: []string{ - "some-post-deployment-task2", - }, - PreDeploymentEvaluations: []string{ - "some-pre-evaluation-task1", - }, - PostDeploymentEvaluations: []string{ - "some-pre-evaluation-task2", - }, - AppName: "app", - }, - WorkloadName: "workload", - PreviousVersion: "1.0", - TraceId: map[string]string{ - "key1": "value1", - "key2": "value2", - }, - }, - Status: v1alpha3.KeptnWorkloadInstanceStatus{ - PreDeploymentStatus: v1alpha3common.StateFailed, - PostDeploymentStatus: v1alpha3common.StateFailed, - PreDeploymentEvaluationStatus: v1alpha3common.StateFailed, - PostDeploymentEvaluationStatus: v1alpha3common.StateFailed, - DeploymentStatus: v1alpha3common.StateFailed, - CurrentPhase: "phase", - PreDeploymentTaskStatus: []v1alpha3.ItemStatus{ - { - DefinitionName: "def1", - Name: "name1", - Status: v1alpha3common.StateFailed, - }, - { - DefinitionName: "def12", - Name: "name12", - Status: v1alpha3common.StateFailed, - }, - }, - PostDeploymentTaskStatus: []v1alpha3.ItemStatus{ - { - DefinitionName: "def2", - Name: "name2", - Status: v1alpha3common.StateFailed, - }, - { - DefinitionName: "def22", - Name: "name22", - Status: v1alpha3common.StateFailed, - }, - }, - PreDeploymentEvaluationTaskStatus: []v1alpha3.ItemStatus{ - { - DefinitionName: "def3", - Name: "name3", - Status: v1alpha3common.StateFailed, - }, - { - DefinitionName: "def32", - Name: "name32", - Status: v1alpha3common.StateFailed, - }, - }, - PostDeploymentEvaluationTaskStatus: []v1alpha3.ItemStatus{ - { - DefinitionName: "def4", - Name: "name4", - Status: v1alpha3common.StateFailed, - }, - { - DefinitionName: "def42", - Name: "name42", - Status: v1alpha3common.StateFailed, - }, - }, - PhaseTraceIDs: v1alpha3common.PhaseTraceID{ - "key": propagation.MapCarrier{ - "key1": "value1", - "key2": "value2", - }, - "key22": propagation.MapCarrier{ - "key122": "value122", - "key222": "value222", - }, - }, - Status: v1alpha3common.StateFailed, - }, - }, - wantErr: false, - wantObj: &KeptnWorkloadInstance{ - ObjectMeta: v1.ObjectMeta{ - Name: "some-keptn-app-name", - Namespace: "", - Labels: map[string]string{ - "some-label": "some-label-value", - }, - Annotations: map[string]string{ - "some-annotation": "some-annotation-value", - }, - }, - Spec: KeptnWorkloadInstanceSpec{ - KeptnWorkloadSpec: KeptnWorkloadSpec{ - Version: "1.2.3", - ResourceReference: ResourceReference{ - UID: types.UID("1"), - Kind: "Pod", - Name: "pod", - }, - PreDeploymentTasks: []string{ - "some-pre-deployment-task1", - }, - PostDeploymentTasks: []string{ - "some-post-deployment-task2", - }, - PreDeploymentEvaluations: []string{ - "some-pre-evaluation-task1", - }, - PostDeploymentEvaluations: []string{ - "some-pre-evaluation-task2", - }, - AppName: "app", - }, - WorkloadName: "workload", - PreviousVersion: "1.0", - TraceId: map[string]string{ - "key1": "value1", - "key2": "value2", - }, - }, - Status: KeptnWorkloadInstanceStatus{ - PreDeploymentStatus: common.StateFailed, - PostDeploymentStatus: common.StateFailed, - PreDeploymentEvaluationStatus: common.StateFailed, - PostDeploymentEvaluationStatus: common.StateFailed, - DeploymentStatus: common.StateFailed, - CurrentPhase: "phase", - PreDeploymentTaskStatus: []TaskStatus{ - { - TaskDefinitionName: "def1", - TaskName: "name1", - Status: common.StateFailed, - }, - { - TaskDefinitionName: "def12", - TaskName: "name12", - Status: common.StateFailed, - }, - }, - PostDeploymentTaskStatus: []TaskStatus{ - { - TaskDefinitionName: "def2", - TaskName: "name2", - Status: common.StateFailed, - }, - { - TaskDefinitionName: "def22", - TaskName: "name22", - Status: common.StateFailed, - }, - }, - PreDeploymentEvaluationTaskStatus: []EvaluationStatus{ - { - EvaluationDefinitionName: "def3", - EvaluationName: "name3", - Status: common.StateFailed, - }, - { - EvaluationDefinitionName: "def32", - EvaluationName: "name32", - Status: common.StateFailed, - }, - }, - PostDeploymentEvaluationTaskStatus: []EvaluationStatus{ - { - EvaluationDefinitionName: "def4", - EvaluationName: "name4", - Status: common.StateFailed, - }, - { - EvaluationDefinitionName: "def42", - EvaluationName: "name42", - Status: common.StateFailed, - }, - }, - PhaseTraceIDs: common.PhaseTraceID{ - "key": propagation.MapCarrier{ - "key1": "value1", - "key2": "value2", - }, - "key22": propagation.MapCarrier{ - "key122": "value122", - "key222": "value222", - }, - }, - Status: common.StateFailed, - }, - }, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - dst := &KeptnWorkloadInstance{ - TypeMeta: v1.TypeMeta{}, - ObjectMeta: v1.ObjectMeta{}, - Spec: KeptnWorkloadInstanceSpec{}, - Status: KeptnWorkloadInstanceStatus{}, - } - if err := dst.ConvertFrom(tt.srcObj); (err != nil) != tt.wantErr { - t.Errorf("ConvertFrom() error = %v, wantErr %v", err, tt.wantErr) - } - if tt.wantObj != nil { - require.Equal(t, tt.wantObj, dst, "Object was not converted correctly") - } - }) - } -} - -func TestKeptnWorkloadInstance_ConvertTo(t *testing.T) { - tests := []struct { - name string - src *KeptnWorkloadInstance - wantErr bool - wantObj *v1alpha3.KeptnWorkloadInstance - }{ - { - name: "Test that conversion from v1alpha1 to v1alpha3 works", - src: &KeptnWorkloadInstance{ - TypeMeta: v1.TypeMeta{ - Kind: "KeptnWorkloadInstance", - APIVersion: "lifecycle.keptn.sh/v1alpha1", - }, - ObjectMeta: v1.ObjectMeta{ - Name: "some-keptn-app-name", - Namespace: "", - Labels: map[string]string{ - "some-label": "some-label-value", - }, - Annotations: map[string]string{ - "some-annotation": "some-annotation-value", - }, - }, - Spec: KeptnWorkloadInstanceSpec{ - KeptnWorkloadSpec: KeptnWorkloadSpec{ - Version: "1.2.3", - ResourceReference: ResourceReference{ - UID: types.UID("1"), - Kind: "Pod", - Name: "pod", - }, - PreDeploymentTasks: []string{ - "some-pre-deployment-task1", - }, - PostDeploymentTasks: []string{ - "some-post-deployment-task2", - }, - PreDeploymentEvaluations: []string{ - "some-pre-evaluation-task1", - }, - PostDeploymentEvaluations: []string{ - "some-pre-evaluation-task2", - }, - AppName: "app", - }, - WorkloadName: "workload", - PreviousVersion: "1.0", - TraceId: map[string]string{ - "key1": "value1", - "key2": "value2", - }, - }, - Status: KeptnWorkloadInstanceStatus{ - PreDeploymentStatus: common.StateFailed, - PostDeploymentStatus: common.StateFailed, - PreDeploymentEvaluationStatus: common.StateFailed, - PostDeploymentEvaluationStatus: common.StateFailed, - DeploymentStatus: common.StateFailed, - CurrentPhase: "phase", - PreDeploymentTaskStatus: []TaskStatus{ - { - TaskDefinitionName: "def1", - TaskName: "name1", - Status: common.StateFailed, - }, - { - TaskDefinitionName: "def12", - TaskName: "name12", - Status: common.StateFailed, - }, - }, - PostDeploymentTaskStatus: []TaskStatus{ - { - TaskDefinitionName: "def2", - TaskName: "name2", - Status: common.StateFailed, - }, - { - TaskDefinitionName: "def22", - TaskName: "name22", - Status: common.StateFailed, - }, - }, - PreDeploymentEvaluationTaskStatus: []EvaluationStatus{ - { - EvaluationDefinitionName: "def3", - EvaluationName: "name3", - Status: common.StateFailed, - }, - { - EvaluationDefinitionName: "def32", - EvaluationName: "name32", - Status: common.StateFailed, - }, - }, - PostDeploymentEvaluationTaskStatus: []EvaluationStatus{ - { - EvaluationDefinitionName: "def4", - EvaluationName: "name4", - Status: common.StateFailed, - }, - { - EvaluationDefinitionName: "def42", - EvaluationName: "name42", - Status: common.StateFailed, - }, - }, - PhaseTraceIDs: common.PhaseTraceID{ - "key": propagation.MapCarrier{ - "key1": "value1", - "key2": "value2", - }, - "key22": propagation.MapCarrier{ - "key122": "value122", - "key222": "value222", - }, - }, - Status: common.StateFailed, - }, - }, - wantErr: false, - wantObj: &v1alpha3.KeptnWorkloadInstance{ - ObjectMeta: v1.ObjectMeta{ - Name: "some-keptn-app-name", - Namespace: "", - Labels: map[string]string{ - "some-label": "some-label-value", - }, - Annotations: map[string]string{ - "some-annotation": "some-annotation-value", - }, - }, - Spec: v1alpha3.KeptnWorkloadInstanceSpec{ - KeptnWorkloadSpec: v1alpha3.KeptnWorkloadSpec{ - Version: "1.2.3", - ResourceReference: v1alpha3.ResourceReference{ - UID: types.UID("1"), - Kind: "Pod", - Name: "pod", - }, - PreDeploymentTasks: []string{ - "some-pre-deployment-task1", - }, - PostDeploymentTasks: []string{ - "some-post-deployment-task2", - }, - PreDeploymentEvaluations: []string{ - "some-pre-evaluation-task1", - }, - PostDeploymentEvaluations: []string{ - "some-pre-evaluation-task2", - }, - AppName: "app", - }, - WorkloadName: "workload", - PreviousVersion: "1.0", - TraceId: map[string]string{ - "key1": "value1", - "key2": "value2", - }, - }, - Status: v1alpha3.KeptnWorkloadInstanceStatus{ - PreDeploymentStatus: v1alpha3common.StateFailed, - PostDeploymentStatus: v1alpha3common.StateFailed, - PreDeploymentEvaluationStatus: v1alpha3common.StateFailed, - PostDeploymentEvaluationStatus: v1alpha3common.StateFailed, - DeploymentStatus: v1alpha3common.StateFailed, - CurrentPhase: "phase", - PreDeploymentTaskStatus: []v1alpha3.ItemStatus{ - { - DefinitionName: "def1", - Name: "name1", - Status: v1alpha3common.StateFailed, - }, - { - DefinitionName: "def12", - Name: "name12", - Status: v1alpha3common.StateFailed, - }, - }, - PostDeploymentTaskStatus: []v1alpha3.ItemStatus{ - { - DefinitionName: "def2", - Name: "name2", - Status: v1alpha3common.StateFailed, - }, - { - DefinitionName: "def22", - Name: "name22", - Status: v1alpha3common.StateFailed, - }, - }, - PreDeploymentEvaluationTaskStatus: []v1alpha3.ItemStatus{ - { - DefinitionName: "def3", - Name: "name3", - Status: v1alpha3common.StateFailed, - }, - { - DefinitionName: "def32", - Name: "name32", - Status: v1alpha3common.StateFailed, - }, - }, - PostDeploymentEvaluationTaskStatus: []v1alpha3.ItemStatus{ - { - DefinitionName: "def4", - Name: "name4", - Status: v1alpha3common.StateFailed, - }, - { - DefinitionName: "def42", - Name: "name42", - Status: v1alpha3common.StateFailed, - }, - }, - PhaseTraceIDs: v1alpha3common.PhaseTraceID{ - "key": propagation.MapCarrier{ - "key1": "value1", - "key2": "value2", - }, - "key22": propagation.MapCarrier{ - "key122": "value122", - "key222": "value222", - }, - }, - Status: v1alpha3common.StateFailed, - }, - }, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - dst := v1alpha3.KeptnWorkloadInstance{ - TypeMeta: v1.TypeMeta{}, - ObjectMeta: v1.ObjectMeta{}, - Spec: v1alpha3.KeptnWorkloadInstanceSpec{}, - Status: v1alpha3.KeptnWorkloadInstanceStatus{}, - } - if err := tt.src.ConvertTo(&dst); (err != nil) != tt.wantErr { - t.Errorf("ConvertTo() error = %v, wantErr %v", err, tt.wantErr) - } - if tt.wantObj != nil { - require.Equal(t, tt.wantObj, &dst, "Object was not converted correctly") - } - }) - } -} - -func TestKeptnWorkloadInstance_ConvertFrom_Errorcase(t *testing.T) { - // A random different object is used here to simulate a different API version - testObj := v2.ExternalJob{} - - dst := &KeptnWorkloadInstance{ - TypeMeta: v1.TypeMeta{}, - ObjectMeta: v1.ObjectMeta{}, - Spec: KeptnWorkloadInstanceSpec{}, - Status: KeptnWorkloadInstanceStatus{}, - } - - if err := dst.ConvertFrom(&testObj); err == nil { - t.Errorf("ConvertFrom() error = %v", err) - } else { - require.ErrorIs(t, err, common.ErrCannotCastKeptnWorkloadInstance) - } -} - -func TestKeptnWorkloadInstance_ConvertTo_Errorcase(t *testing.T) { - testObj := KeptnWorkloadInstance{} - - // A random different object is used here to simulate a different API version - dst := v2.ExternalJob{} - - if err := testObj.ConvertTo(&dst); err == nil { - t.Errorf("ConvertTo() error = %v", err) - } else { - require.ErrorIs(t, err, common.ErrCannotCastKeptnWorkloadInstance) - } -} diff --git a/lifecycle-operator/apis/lifecycle/v1alpha1/keptnworkloadinstance_test.go b/lifecycle-operator/apis/lifecycle/v1alpha1/keptnworkloadinstance_test.go deleted file mode 100644 index 3eadaabb926..00000000000 --- a/lifecycle-operator/apis/lifecycle/v1alpha1/keptnworkloadinstance_test.go +++ /dev/null @@ -1,346 +0,0 @@ -package v1alpha1 - -import ( - "testing" - "time" - - "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha1/common" - "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" -) - -//nolint:dupl -func TestKeptnWorkloadInstance(t *testing.T) { - workload := &KeptnWorkloadInstance{ - ObjectMeta: metav1.ObjectMeta{ - Name: "workload", - Namespace: "namespace", - }, - Status: KeptnWorkloadInstanceStatus{ - PreDeploymentStatus: common.StateFailed, - PreDeploymentEvaluationStatus: common.StateFailed, - PostDeploymentStatus: common.StateFailed, - PostDeploymentEvaluationStatus: common.StateFailed, - DeploymentStatus: common.StateFailed, - Status: common.StateFailed, - PreDeploymentTaskStatus: []TaskStatus{ - { - TaskDefinitionName: "defname", - Status: common.StateFailed, - TaskName: "taskname", - }, - }, - PostDeploymentTaskStatus: []TaskStatus{ - { - TaskDefinitionName: "defname2", - Status: common.StateFailed, - TaskName: "taskname2", - }, - }, - PreDeploymentEvaluationTaskStatus: []EvaluationStatus{ - { - EvaluationDefinitionName: "defname3", - Status: common.StateFailed, - EvaluationName: "taskname3", - }, - }, - PostDeploymentEvaluationTaskStatus: []EvaluationStatus{ - { - EvaluationDefinitionName: "defname4", - Status: common.StateFailed, - EvaluationName: "taskname4", - }, - }, - CurrentPhase: common.PhaseAppDeployment.ShortName, - }, - Spec: KeptnWorkloadInstanceSpec{ - KeptnWorkloadSpec: KeptnWorkloadSpec{ - PreDeploymentTasks: []string{"task1", "task2"}, - PostDeploymentTasks: []string{"task3", "task4"}, - PreDeploymentEvaluations: []string{"task5", "task6"}, - PostDeploymentEvaluations: []string{"task7", "task8"}, - Version: "version", - AppName: "appname", - }, - PreviousVersion: "prev", - WorkloadName: "workloadname", - TraceId: map[string]string{"traceparent": "trace1"}, - }, - } - - require.True(t, workload.IsPreDeploymentCompleted()) - require.False(t, workload.IsPreDeploymentSucceeded()) - require.True(t, workload.IsPreDeploymentFailed()) - - require.True(t, workload.IsPreDeploymentEvaluationCompleted()) - require.False(t, workload.IsPreDeploymentEvaluationSucceeded()) - require.True(t, workload.IsPreDeploymentEvaluationFailed()) - - require.True(t, workload.IsPostDeploymentCompleted()) - require.False(t, workload.IsPostDeploymentSucceeded()) - require.True(t, workload.IsPostDeploymentFailed()) - - require.True(t, workload.IsPostDeploymentEvaluationCompleted()) - require.False(t, workload.IsPostDeploymentEvaluationSucceeded()) - require.True(t, workload.IsPostDeploymentEvaluationFailed()) - - require.True(t, workload.IsDeploymentCompleted()) - require.False(t, workload.IsDeploymentSucceeded()) - require.True(t, workload.IsDeploymentFailed()) - - require.False(t, workload.IsEndTimeSet()) - require.False(t, workload.IsStartTimeSet()) - - workload.SetStartTime() - workload.SetEndTime() - - require.True(t, workload.IsEndTimeSet()) - require.True(t, workload.IsStartTimeSet()) - - require.Equal(t, []attribute.KeyValue{ - common.AppName.String("appname"), - common.WorkloadName.String("workloadname"), - common.WorkloadVersion.String("version"), - common.WorkloadNamespace.String("namespace"), - }, workload.GetActiveMetricsAttributes()) - - require.Equal(t, []attribute.KeyValue{ - common.AppName.String("appname"), - common.WorkloadName.String("workloadname"), - common.WorkloadVersion.String("version"), - common.WorkloadNamespace.String("namespace"), - common.WorkloadStatus.String(string(common.StateFailed)), - }, workload.GetMetricsAttributes()) - - require.Equal(t, []attribute.KeyValue{ - common.AppName.String("appname"), - common.WorkloadName.String("workloadname"), - common.WorkloadVersion.String("version"), - common.WorkloadPreviousVersion.String("prev"), - }, workload.GetDurationMetricsAttributes()) - - require.Equal(t, common.StateFailed, workload.GetState()) - - require.Equal(t, []string{"task1", "task2"}, workload.GetPreDeploymentTasks()) - require.Equal(t, []string{"task3", "task4"}, workload.GetPostDeploymentTasks()) - require.Equal(t, []string{"task5", "task6"}, workload.GetPreDeploymentEvaluations()) - require.Equal(t, []string{"task7", "task8"}, workload.GetPostDeploymentEvaluations()) - - require.Equal(t, []TaskStatus{ - { - TaskDefinitionName: "defname", - Status: common.StateFailed, - TaskName: "taskname", - }, - }, workload.GetPreDeploymentTaskStatus()) - - require.Equal(t, []TaskStatus{ - { - TaskDefinitionName: "defname2", - Status: common.StateFailed, - TaskName: "taskname2", - }, - }, workload.GetPostDeploymentTaskStatus()) - - require.Equal(t, []EvaluationStatus{ - { - EvaluationDefinitionName: "defname3", - Status: common.StateFailed, - EvaluationName: "taskname3", - }, - }, workload.GetPreDeploymentEvaluationTaskStatus()) - - require.Equal(t, []EvaluationStatus{ - { - EvaluationDefinitionName: "defname4", - Status: common.StateFailed, - EvaluationName: "taskname4", - }, - }, workload.GetPostDeploymentEvaluationTaskStatus()) - - require.Equal(t, "appname", workload.GetAppName()) - require.Equal(t, "prev", workload.GetPreviousVersion()) - require.Equal(t, "workloadname", workload.GetParentName()) - require.Equal(t, "namespace", workload.GetNamespace()) - - workload.SetState(common.StatePending) - require.Equal(t, common.StatePending, workload.GetState()) - - require.True(t, !workload.GetStartTime().IsZero()) - require.True(t, !workload.GetEndTime().IsZero()) - - workload.SetCurrentPhase(common.PhaseAppDeployment.LongName) - require.Equal(t, common.PhaseAppDeployment.LongName, workload.GetCurrentPhase()) - - workload.Status.EndTime = v1.Time{Time: time.Time{}} - workload.Complete() - require.True(t, !workload.GetEndTime().IsZero()) - - require.Equal(t, "version", workload.GetVersion()) - - require.Equal(t, "trace1.workloadname.version.phase", workload.GetSpanKey("phase")) - - task := workload.GenerateTask("taskdef", common.PostDeploymentCheckType) - require.Equal(t, KeptnTaskSpec{ - AppName: workload.GetAppName(), - WorkloadVersion: workload.GetVersion(), - Workload: workload.GetParentName(), - TaskDefinition: "taskdef", - Parameters: TaskParameters{}, - SecureParameters: SecureParameters{}, - Type: common.PostDeploymentCheckType, - }, task.Spec) - - evaluation := workload.GenerateEvaluation("taskdef", common.PostDeploymentCheckType) - require.Equal(t, KeptnEvaluationSpec{ - AppName: workload.GetAppName(), - WorkloadVersion: workload.GetVersion(), - Workload: workload.GetParentName(), - EvaluationDefinition: "taskdef", - Type: common.PostDeploymentCheckType, - RetryInterval: metav1.Duration{ - Duration: 5 * time.Second, - }, - }, evaluation.Spec) - - require.Equal(t, "workload", workload.GetSpanName("")) - - require.Equal(t, "workloadname/phase", workload.GetSpanName("phase")) - - require.Equal(t, []attribute.KeyValue{ - common.AppName.String("appname"), - common.WorkloadName.String("workloadname"), - common.WorkloadVersion.String("version"), - common.WorkloadNamespace.String("namespace"), - }, workload.GetSpanAttributes()) -} - -//nolint:dupl -func TestKeptnWorkloadInstance_CancelRemainingPhases(t *testing.T) { - workloadInstance := KeptnWorkloadInstance{ - Status: KeptnWorkloadInstanceStatus{ - PreDeploymentStatus: common.StatePending, - PreDeploymentEvaluationStatus: common.StatePending, - PostDeploymentStatus: common.StatePending, - PostDeploymentEvaluationStatus: common.StatePending, - DeploymentStatus: common.StatePending, - Status: common.StatePending, - }, - } - - tests := []struct { - workloadInstance KeptnWorkloadInstance - phase common.KeptnPhaseType - want KeptnWorkloadInstance - }{ - { - workloadInstance: workloadInstance, - phase: common.PhaseWorkloadPostEvaluation, - want: KeptnWorkloadInstance{ - Status: KeptnWorkloadInstanceStatus{ - PreDeploymentStatus: common.StatePending, - PreDeploymentEvaluationStatus: common.StatePending, - PostDeploymentStatus: common.StatePending, - PostDeploymentEvaluationStatus: common.StatePending, - DeploymentStatus: common.StatePending, - Status: common.StatePending, - }, - }, - }, - { - workloadInstance: workloadInstance, - phase: common.PhaseAppPreEvaluation, - want: KeptnWorkloadInstance{ - Status: KeptnWorkloadInstanceStatus{ - PreDeploymentStatus: common.StateCancelled, - PreDeploymentEvaluationStatus: common.StateCancelled, - PostDeploymentStatus: common.StateCancelled, - PostDeploymentEvaluationStatus: common.StateCancelled, - DeploymentStatus: common.StateCancelled, - Status: common.StateFailed, - }, - }, - }, - { - workloadInstance: workloadInstance, - phase: common.PhaseWorkloadPreEvaluation, - want: KeptnWorkloadInstance{ - Status: KeptnWorkloadInstanceStatus{ - PreDeploymentStatus: common.StatePending, - PreDeploymentEvaluationStatus: common.StatePending, - PostDeploymentStatus: common.StateCancelled, - PostDeploymentEvaluationStatus: common.StateCancelled, - DeploymentStatus: common.StateCancelled, - Status: common.StateFailed, - }, - }, - }, - } - - for _, tt := range tests { - t.Run("", func(t *testing.T) { - tt.workloadInstance.CancelRemainingPhases(tt.phase) - require.Equal(t, tt.want, tt.workloadInstance) - }) - } -} - -func TestKeptnWorkloadInstance_SetPhaseTraceID(t *testing.T) { - app := KeptnWorkloadInstance{ - Status: KeptnWorkloadInstanceStatus{}, - } - - app.SetPhaseTraceID(common.PhaseAppDeployment.ShortName, propagation.MapCarrier{ - "name3": "trace3", - }) - - require.Equal(t, KeptnWorkloadInstance{ - Status: KeptnWorkloadInstanceStatus{ - PhaseTraceIDs: common.PhaseTraceID{ - common.PhaseAppDeployment.ShortName: propagation.MapCarrier{ - "name3": "trace3", - }, - }, - }, - }, app) - - app.SetPhaseTraceID(common.PhaseWorkloadDeployment.LongName, propagation.MapCarrier{ - "name2": "trace2", - }) - - require.Equal(t, KeptnWorkloadInstance{ - Status: KeptnWorkloadInstanceStatus{ - PhaseTraceIDs: common.PhaseTraceID{ - common.PhaseAppDeployment.ShortName: propagation.MapCarrier{ - "name3": "trace3", - }, - common.PhaseWorkloadDeployment.ShortName: propagation.MapCarrier{ - "name2": "trace2", - }, - }, - }, - }, app) -} - -func TestKeptnWorkloadInstanceList(t *testing.T) { - list := KeptnWorkloadInstanceList{ - Items: []KeptnWorkloadInstance{ - { - ObjectMeta: metav1.ObjectMeta{ - Name: "obj1", - }, - }, - { - ObjectMeta: metav1.ObjectMeta{ - Name: "obj2", - }, - }, - }, - } - - got := list.GetItems() - require.Len(t, got, 2) -} diff --git a/lifecycle-operator/apis/lifecycle/v1alpha1/keptnworkloadinstance_types.go b/lifecycle-operator/apis/lifecycle/v1alpha1/keptnworkloadinstance_types.go index 837fd362017..45d3d18307f 100644 --- a/lifecycle-operator/apis/lifecycle/v1alpha1/keptnworkloadinstance_types.go +++ b/lifecycle-operator/apis/lifecycle/v1alpha1/keptnworkloadinstance_types.go @@ -17,15 +17,8 @@ limitations under the License. package v1alpha1 import ( - "fmt" - "time" - "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha1/common" - "go.opentelemetry.io/otel/attribute" - "go.opentelemetry.io/otel/propagation" - "go.opentelemetry.io/otel/trace" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "sigs.k8s.io/controller-runtime/pkg/client" ) // EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! @@ -146,308 +139,3 @@ type KeptnWorkloadInstanceList struct { func init() { SchemeBuilder.Register(&KeptnWorkloadInstance{}, &KeptnWorkloadInstanceList{}) } - -func (w KeptnWorkloadInstanceList) GetItems() []client.Object { - var b []client.Object - for _, i := range w.Items { - b = append(b, &i) - } - return b -} - -func (w KeptnWorkloadInstance) IsPreDeploymentCompleted() bool { - return w.Status.PreDeploymentStatus.IsCompleted() -} - -func (w KeptnWorkloadInstance) IsPreDeploymentEvaluationCompleted() bool { - return w.Status.PreDeploymentEvaluationStatus.IsCompleted() -} - -func (w KeptnWorkloadInstance) IsPreDeploymentSucceeded() bool { - return w.Status.PreDeploymentStatus.IsSucceeded() -} - -func (w KeptnWorkloadInstance) IsPreDeploymentFailed() bool { - return w.Status.PreDeploymentStatus.IsFailed() -} - -func (w KeptnWorkloadInstance) IsPreDeploymentEvaluationSucceeded() bool { - return w.Status.PreDeploymentEvaluationStatus.IsSucceeded() -} - -func (w KeptnWorkloadInstance) IsPreDeploymentEvaluationFailed() bool { - return w.Status.PreDeploymentEvaluationStatus.IsFailed() -} - -func (w KeptnWorkloadInstance) IsPostDeploymentCompleted() bool { - return w.Status.PostDeploymentStatus.IsCompleted() -} - -func (w KeptnWorkloadInstance) IsPostDeploymentEvaluationCompleted() bool { - return w.Status.PostDeploymentEvaluationStatus.IsCompleted() -} - -func (w KeptnWorkloadInstance) IsPostDeploymentSucceeded() bool { - return w.Status.PostDeploymentStatus.IsSucceeded() -} - -func (w KeptnWorkloadInstance) IsPostDeploymentFailed() bool { - return w.Status.PostDeploymentStatus.IsFailed() -} - -func (w KeptnWorkloadInstance) IsPostDeploymentEvaluationSucceeded() bool { - return w.Status.PostDeploymentEvaluationStatus.IsSucceeded() -} - -func (w KeptnWorkloadInstance) IsPostDeploymentEvaluationFailed() bool { - return w.Status.PostDeploymentEvaluationStatus.IsFailed() -} - -func (w KeptnWorkloadInstance) IsDeploymentCompleted() bool { - return w.Status.DeploymentStatus.IsCompleted() -} - -func (w KeptnWorkloadInstance) IsDeploymentSucceeded() bool { - return w.Status.DeploymentStatus.IsSucceeded() -} - -func (w KeptnWorkloadInstance) IsDeploymentFailed() bool { - return w.Status.DeploymentStatus.IsFailed() -} - -func (w *KeptnWorkloadInstance) SetStartTime() { - if w.Status.StartTime.IsZero() { - w.Status.StartTime = metav1.NewTime(time.Now().UTC()) - } -} - -func (w *KeptnWorkloadInstance) SetEndTime() { - if w.Status.EndTime.IsZero() { - w.Status.EndTime = metav1.NewTime(time.Now().UTC()) - } -} - -func (w *KeptnWorkloadInstance) IsStartTimeSet() bool { - return !w.Status.StartTime.IsZero() -} - -func (w *KeptnWorkloadInstance) IsEndTimeSet() bool { - return !w.Status.EndTime.IsZero() -} - -func (w KeptnWorkloadInstance) GetStartTime() time.Time { - return w.Status.StartTime.Time -} - -func (w KeptnWorkloadInstance) GetEndTime() time.Time { - return w.Status.EndTime.Time -} - -func (w *KeptnWorkloadInstance) Complete() { - w.SetEndTime() -} - -func (t *TaskStatus) SetStartTime() { - if t.StartTime.IsZero() { - t.StartTime = metav1.NewTime(time.Now().UTC()) - } -} - -func (t *TaskStatus) SetEndTime() { - if t.EndTime.IsZero() { - t.EndTime = metav1.NewTime(time.Now().UTC()) - } -} - -func (e *EvaluationStatus) SetStartTime() { - if e.StartTime.IsZero() { - e.StartTime = metav1.NewTime(time.Now().UTC()) - } -} - -func (e *EvaluationStatus) SetEndTime() { - if e.EndTime.IsZero() { - e.EndTime = metav1.NewTime(time.Now().UTC()) - } -} - -func (w KeptnWorkloadInstance) GetActiveMetricsAttributes() []attribute.KeyValue { - return []attribute.KeyValue{ - common.AppName.String(w.Spec.AppName), - common.WorkloadName.String(w.Spec.WorkloadName), - common.WorkloadVersion.String(w.Spec.Version), - common.WorkloadNamespace.String(w.Namespace), - } -} - -func (w KeptnWorkloadInstance) GetMetricsAttributes() []attribute.KeyValue { - return []attribute.KeyValue{ - common.AppName.String(w.Spec.AppName), - common.WorkloadName.String(w.Spec.WorkloadName), - common.WorkloadVersion.String(w.Spec.Version), - common.WorkloadNamespace.String(w.Namespace), - common.WorkloadStatus.String(string(w.Status.Status)), - } -} - -func (w KeptnWorkloadInstance) GetDurationMetricsAttributes() []attribute.KeyValue { - return []attribute.KeyValue{ - common.AppName.String(w.Spec.AppName), - common.WorkloadName.String(w.Spec.WorkloadName), - common.WorkloadVersion.String(w.Spec.Version), - common.WorkloadPreviousVersion.String(w.Spec.PreviousVersion), - } -} - -func (w KeptnWorkloadInstance) GetState() common.KeptnState { - return w.Status.Status -} - -func (w KeptnWorkloadInstance) GetPreDeploymentTasks() []string { - return w.Spec.PreDeploymentTasks -} - -func (w KeptnWorkloadInstance) GetPostDeploymentTasks() []string { - return w.Spec.PostDeploymentTasks -} - -func (w KeptnWorkloadInstance) GetPreDeploymentTaskStatus() []TaskStatus { - return w.Status.PreDeploymentTaskStatus -} - -func (w KeptnWorkloadInstance) GetPostDeploymentTaskStatus() []TaskStatus { - return w.Status.PostDeploymentTaskStatus -} - -func (w KeptnWorkloadInstance) GetPreDeploymentEvaluations() []string { - return w.Spec.PreDeploymentEvaluations -} - -func (w KeptnWorkloadInstance) GetPostDeploymentEvaluations() []string { - return w.Spec.PostDeploymentEvaluations -} - -func (w KeptnWorkloadInstance) GetPreDeploymentEvaluationTaskStatus() []EvaluationStatus { - return w.Status.PreDeploymentEvaluationTaskStatus -} - -func (w KeptnWorkloadInstance) GetPostDeploymentEvaluationTaskStatus() []EvaluationStatus { - return w.Status.PostDeploymentEvaluationTaskStatus -} - -func (w KeptnWorkloadInstance) GetAppName() string { - return w.Spec.AppName -} - -func (w KeptnWorkloadInstance) GetPreviousVersion() string { - return w.Spec.PreviousVersion -} - -func (w KeptnWorkloadInstance) GetParentName() string { - return w.Spec.WorkloadName -} - -func (w KeptnWorkloadInstance) GetNamespace() string { - return w.Namespace -} - -func (w *KeptnWorkloadInstance) SetState(state common.KeptnState) { - w.Status.Status = state -} - -func (w KeptnWorkloadInstance) GetCurrentPhase() string { - return w.Status.CurrentPhase -} - -func (w *KeptnWorkloadInstance) SetCurrentPhase(phase string) { - w.Status.CurrentPhase = phase -} - -func (w KeptnWorkloadInstance) GetVersion() string { - return w.Spec.Version -} - -func (w KeptnWorkloadInstance) GenerateTask(taskDefinition string, checkType common.CheckType) KeptnTask { - return KeptnTask{ - ObjectMeta: metav1.ObjectMeta{ - Name: common.GenerateTaskName(checkType, taskDefinition), - Namespace: w.Namespace, - }, - Spec: KeptnTaskSpec{ - AppName: w.GetAppName(), - WorkloadVersion: w.GetVersion(), - Workload: w.GetParentName(), - TaskDefinition: taskDefinition, - Parameters: TaskParameters{}, - SecureParameters: SecureParameters{}, - Type: checkType, - }, - } -} - -func (w KeptnWorkloadInstance) GenerateEvaluation(evaluationDefinition string, checkType common.CheckType) KeptnEvaluation { - return KeptnEvaluation{ - ObjectMeta: metav1.ObjectMeta{ - Name: common.GenerateEvaluationName(checkType, evaluationDefinition), - Namespace: w.Namespace, - }, - Spec: KeptnEvaluationSpec{ - AppName: w.GetAppName(), - WorkloadVersion: w.GetVersion(), - Workload: w.GetParentName(), - EvaluationDefinition: evaluationDefinition, - Type: checkType, - RetryInterval: metav1.Duration{ - Duration: 5 * time.Second, - }, - }, - } -} - -func (w KeptnWorkloadInstance) GetSpanAttributes() []attribute.KeyValue { - return []attribute.KeyValue{ - common.AppName.String(w.Spec.AppName), - common.WorkloadName.String(w.Spec.WorkloadName), - common.WorkloadVersion.String(w.Spec.Version), - common.WorkloadNamespace.String(w.Namespace), - } -} - -func (w KeptnWorkloadInstance) GetSpanKey(phase string) string { - return fmt.Sprintf("%s.%s.%s.%s", w.Spec.TraceId["traceparent"], w.Spec.WorkloadName, w.Spec.Version, phase) -} - -func (w KeptnWorkloadInstance) GetSpanName(phase string) string { - if phase == "" { - return w.Name - } - return fmt.Sprintf("%s/%s", w.Spec.WorkloadName, phase) -} - -func (w KeptnWorkloadInstance) SetSpanAttributes(span trace.Span) { - span.SetAttributes(w.GetSpanAttributes()...) -} - -func (w *KeptnWorkloadInstance) CancelRemainingPhases(phase common.KeptnPhaseType) { - // no need to cancel anything when post-eval tasks fail - if phase == common.PhaseWorkloadPostEvaluation { - return - } - // cancel everything if app pre-eval tasks have failed - if phase == common.PhaseAppPreEvaluation { - w.Status.PreDeploymentStatus = common.StateCancelled - w.Status.PreDeploymentEvaluationStatus = common.StateCancelled - } - // cancel deployment and post-deployment tasks if workload pre-eval tasks have failed - w.Status.DeploymentStatus = common.StateCancelled - w.Status.PostDeploymentStatus = common.StateCancelled - w.Status.PostDeploymentEvaluationStatus = common.StateCancelled - w.Status.Status = common.StateFailed -} - -func (w *KeptnWorkloadInstance) SetPhaseTraceID(phase string, carrier propagation.MapCarrier) { - if w.Status.PhaseTraceIDs == nil { - w.Status.PhaseTraceIDs = common.PhaseTraceID{} - } - w.Status.PhaseTraceIDs[common.GetShortPhaseName(phase)] = carrier -} diff --git a/lifecycle-operator/apis/lifecycle/v1alpha2/common/common.go b/lifecycle-operator/apis/lifecycle/v1alpha2/common/common.go index 8c0c2c9bedc..28130dabdab 100644 --- a/lifecycle-operator/apis/lifecycle/v1alpha2/common/common.go +++ b/lifecycle-operator/apis/lifecycle/v1alpha2/common/common.go @@ -31,10 +31,10 @@ const MaxWorkloadNameLength = 25 const MaxTaskNameLength = 25 const MaxVersionLength = 12 -var ErrCannotCastKeptnAppVersion = errors.New("cannot cast KeptnAppVersion to v1alpha3") -var ErrCannotCastKeptnApp = errors.New("cannot cast KeptnApp to v1alpha3") -var ErrCannotCastKeptnWorkloadInstance = errors.New("cannot cast KeptnWorkloadInstance to v1alpha3") -var ErrCannotCastKeptnEvaluationProvider = errors.New("cannot cast KeptnEvaluationDefinition to v1alpha3") +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") // 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 412ea140711..34c6a07689d 100644 --- a/lifecycle-operator/apis/lifecycle/v1alpha2/keptnapp_conversion.go +++ b/lifecycle-operator/apis/lifecycle/v1alpha2/keptnapp_conversion.go @@ -4,13 +4,13 @@ import ( "fmt" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha2/common" - "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3" + "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 (v1alpha3.KeptnApp) +// ConvertTo converts the src v1alpha2.KeptnApp to the hub version (v1beta1.KeptnApp) func (src *KeptnApp) ConvertTo(dstRaw conversion.Hub) error { - dst, ok := dstRaw.(*v1alpha3.KeptnApp) + dst, ok := dstRaw.(*v1beta1.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, v1alpha3.KeptnWorkloadRef{ + dst.Spec.Workloads = append(dst.Spec.Workloads, v1beta1.KeptnWorkloadRef{ Name: srcWl.Name, Version: srcWl.Version, }) @@ -39,9 +39,9 @@ func (src *KeptnApp) ConvertTo(dstRaw conversion.Hub) error { return nil } -// ConvertFrom converts from the hub version (v1alpha3.KeptnApp) to this version (v1alpha3.KeptnApp) +// ConvertFrom converts from the hub version (v1beta1.KeptnApp) to this version (v1alpha2.KeptnApp) func (dst *KeptnApp) ConvertFrom(srcRaw conversion.Hub) error { - src, ok := srcRaw.(*v1alpha3.KeptnApp) + src, ok := srcRaw.(*v1beta1.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 b9dc50cdeb9..152ed3040ba 100644 --- a/lifecycle-operator/apis/lifecycle/v1alpha2/keptnapp_conversion_test.go +++ b/lifecycle-operator/apis/lifecycle/v1alpha2/keptnapp_conversion_test.go @@ -4,7 +4,7 @@ import ( "testing" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha2/common" - "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3" + "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" "github.com/stretchr/testify/require" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" v2 "sigs.k8s.io/controller-runtime/pkg/webhook/conversion/testdata/api/v2" @@ -13,13 +13,13 @@ import ( func TestKeptnApp_ConvertFrom(t *testing.T) { tests := []struct { name string - srcObj *v1alpha3.KeptnApp + srcObj *v1beta1.KeptnApp wantErr bool wantObj *KeptnApp }{ { name: "Test that conversion from v1alpha3 to v1alpha3 works", - srcObj: &v1alpha3.KeptnApp{ + srcObj: &v1beta1.KeptnApp{ TypeMeta: v1.TypeMeta{ Kind: "KeptnApp", APIVersion: "lifecycle.keptn.sh/v1alpha3", @@ -34,10 +34,10 @@ func TestKeptnApp_ConvertFrom(t *testing.T) { "some-annotation": "some-annotation-value", }, }, - Spec: v1alpha3.KeptnAppSpec{ + Spec: v1beta1.KeptnAppSpec{ Version: "1.2.3", Revision: 1, - Workloads: []v1alpha3.KeptnWorkloadRef{ + Workloads: []v1beta1.KeptnWorkloadRef{ { Name: "workload-1", Version: "1.2.3", @@ -60,7 +60,7 @@ func TestKeptnApp_ConvertFrom(t *testing.T) { "some-pre-evaluation-task2", }, }, - Status: v1alpha3.KeptnAppStatus{ + Status: v1beta1.KeptnAppStatus{ CurrentVersion: "1.2.3", }, }, @@ -131,7 +131,7 @@ func TestKeptnApp_ConvertTo(t *testing.T) { name string src *KeptnApp wantErr bool - wantObj *v1alpha3.KeptnApp + wantObj *v1beta1.KeptnApp }{ { name: "Test that conversion from v1alpha3 to v1alpha3 works", @@ -181,7 +181,7 @@ func TestKeptnApp_ConvertTo(t *testing.T) { }, }, wantErr: false, - wantObj: &v1alpha3.KeptnApp{ + wantObj: &v1beta1.KeptnApp{ ObjectMeta: v1.ObjectMeta{ Name: "some-keptn-app-name", Namespace: "", @@ -192,10 +192,10 @@ func TestKeptnApp_ConvertTo(t *testing.T) { "some-annotation": "some-annotation-value", }, }, - Spec: v1alpha3.KeptnAppSpec{ + Spec: v1beta1.KeptnAppSpec{ Version: "1.2.3", Revision: 1, - Workloads: []v1alpha3.KeptnWorkloadRef{ + Workloads: []v1beta1.KeptnWorkloadRef{ { Name: "workload-1", Version: "1.2.3", @@ -218,7 +218,7 @@ func TestKeptnApp_ConvertTo(t *testing.T) { "some-pre-evaluation-task2", }, }, - Status: v1alpha3.KeptnAppStatus{ + Status: v1beta1.KeptnAppStatus{ CurrentVersion: "1.2.3", }, }, @@ -226,11 +226,11 @@ func TestKeptnApp_ConvertTo(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - dst := v1alpha3.KeptnApp{ + dst := v1beta1.KeptnApp{ TypeMeta: v1.TypeMeta{}, ObjectMeta: v1.ObjectMeta{}, - Spec: v1alpha3.KeptnAppSpec{}, - Status: v1alpha3.KeptnAppStatus{}, + Spec: v1beta1.KeptnAppSpec{}, + Status: v1beta1.KeptnAppStatus{}, } if err := tt.src.ConvertTo(&dst); (err != nil) != tt.wantErr { t.Errorf("ConvertTo() error = %v, wantErr %v", err, tt.wantErr) diff --git a/lifecycle-operator/apis/lifecycle/v1alpha2/keptnappversion_conversion.go b/lifecycle-operator/apis/lifecycle/v1alpha2/keptnappversion_conversion.go index 847108a0c44..5a03253a49d 100644 --- a/lifecycle-operator/apis/lifecycle/v1alpha2/keptnappversion_conversion.go +++ b/lifecycle-operator/apis/lifecycle/v1alpha2/keptnappversion_conversion.go @@ -4,17 +4,17 @@ import ( "fmt" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha2/common" - "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3" - v1alpha3common "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 (v1alpha3.KeptnAppVersion) +// ConvertTo converts the src v1alpha2.KeptnAppVersion to the hub version (v1beta1.KeptnAppVersion) // //nolint:gocyclo func (src *KeptnAppVersion) ConvertTo(dstRaw conversion.Hub) error { - dst, ok := dstRaw.(*v1alpha3.KeptnAppVersion) + dst, ok := dstRaw.(*v1beta1.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, v1alpha3.KeptnWorkloadRef{ + dst.Spec.Workloads = append(dst.Spec.Workloads, v1beta1.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 = v1alpha3common.KeptnState(src.Status.PreDeploymentStatus) - dst.Status.PostDeploymentStatus = v1alpha3common.KeptnState(src.Status.PostDeploymentStatus) - dst.Status.PreDeploymentEvaluationStatus = v1alpha3common.KeptnState(src.Status.PreDeploymentEvaluationStatus) - dst.Status.PostDeploymentEvaluationStatus = v1alpha3common.KeptnState(src.Status.PostDeploymentEvaluationStatus) - dst.Status.WorkloadOverallStatus = v1alpha3common.KeptnState(src.Status.WorkloadOverallStatus) - dst.Status.Status = v1alpha3common.KeptnState(src.Status.Status) + 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) for _, srcWls := range src.Status.WorkloadStatus { - dst.Status.WorkloadStatus = append(dst.Status.WorkloadStatus, v1alpha3.WorkloadStatus{ - Workload: v1alpha3.KeptnWorkloadRef{ + dst.Status.WorkloadStatus = append(dst.Status.WorkloadStatus, v1beta1.WorkloadStatus{ + Workload: v1beta1.KeptnWorkloadRef{ Name: srcWls.Workload.Name, Version: srcWls.Workload.Version, }, - Status: v1alpha3common.KeptnState(srcWls.Status), + Status: v1beta1common.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, v1alpha3.ItemStatus{ + dst.Status.PreDeploymentTaskStatus = append(dst.Status.PreDeploymentTaskStatus, v1beta1.ItemStatus{ DefinitionName: item.DefinitionName, - Status: v1alpha3common.KeptnState(item.Status), + Status: v1beta1common.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, v1alpha3.ItemStatus{ + dst.Status.PostDeploymentTaskStatus = append(dst.Status.PostDeploymentTaskStatus, v1beta1.ItemStatus{ DefinitionName: item.DefinitionName, - Status: v1alpha3common.KeptnState(item.Status), + Status: v1beta1common.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, v1alpha3.ItemStatus{ + dst.Status.PreDeploymentEvaluationTaskStatus = append(dst.Status.PreDeploymentEvaluationTaskStatus, v1beta1.ItemStatus{ DefinitionName: item.DefinitionName, - Status: v1alpha3common.KeptnState(item.Status), + Status: v1beta1common.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, v1alpha3.ItemStatus{ + dst.Status.PostDeploymentEvaluationTaskStatus = append(dst.Status.PostDeploymentEvaluationTaskStatus, v1beta1.ItemStatus{ DefinitionName: item.DefinitionName, - Status: v1alpha3common.KeptnState(item.Status), + Status: v1beta1common.KeptnState(item.Status), Name: item.Name, StartTime: item.StartTime, EndTime: item.EndTime, }) } - dst.Status.PhaseTraceIDs = make(v1alpha3common.PhaseTraceID, len(src.Status.PhaseTraceIDs)) + 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 { @@ -122,11 +122,11 @@ func (src *KeptnAppVersion) ConvertTo(dstRaw conversion.Hub) error { return nil } -// ConvertFrom converts from the hub version (v1alpha3.KeptnAppVersion) to this version (v1alpha3.KeptnAppVersion) +// ConvertFrom converts from the hub version (v1beta1.KeptnAppVersion) to this version (v1alpha2.KeptnAppVersion) // //nolint:gocyclo func (dst *KeptnAppVersion) ConvertFrom(srcRaw conversion.Hub) error { - src, ok := srcRaw.(*v1alpha3.KeptnAppVersion) + src, ok := srcRaw.(*v1beta1.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 dfcbe40e761..f078be1301c 100644 --- a/lifecycle-operator/apis/lifecycle/v1alpha2/keptnappversion_conversion_test.go +++ b/lifecycle-operator/apis/lifecycle/v1alpha2/keptnappversion_conversion_test.go @@ -5,8 +5,8 @@ import ( "testing" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha2/common" - "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3" - v1alpha3common "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" @@ -16,16 +16,16 @@ import ( func TestKeptnAppVersion_ConvertFrom(t *testing.T) { tests := []struct { name string - srcObj *v1alpha3.KeptnAppVersion + srcObj *v1beta1.KeptnAppVersion wantErr bool wantObj *KeptnAppVersion }{ { - name: "Test that conversion from v1alpha3 to v1alpha3 works", - srcObj: &v1alpha3.KeptnAppVersion{ + name: "Test that conversion from v1beta1 to v1beta1 works", + srcObj: &v1beta1.KeptnAppVersion{ TypeMeta: v1.TypeMeta{ Kind: "KeptnAppVersion", - APIVersion: "lifecycle.keptn.sh/v1alpha3", + APIVersion: "lifecycle.keptn.sh/v1beta1", }, ObjectMeta: v1.ObjectMeta{ Name: "some-keptn-app-name", @@ -37,11 +37,11 @@ func TestKeptnAppVersion_ConvertFrom(t *testing.T) { "some-annotation": "some-annotation-value", }, }, - Spec: v1alpha3.KeptnAppVersionSpec{ - KeptnAppSpec: v1alpha3.KeptnAppSpec{ + Spec: v1beta1.KeptnAppVersionSpec{ + KeptnAppSpec: v1beta1.KeptnAppSpec{ Version: "1.2.3", Revision: 1, - Workloads: []v1alpha3.KeptnWorkloadRef{ + Workloads: []v1beta1.KeptnWorkloadRef{ { Name: "workload-1", Version: "1.2.3", @@ -71,78 +71,78 @@ func TestKeptnAppVersion_ConvertFrom(t *testing.T) { "key2": "value2", }, }, - Status: v1alpha3.KeptnAppVersionStatus{ - PreDeploymentStatus: v1alpha3common.StateFailed, - PostDeploymentStatus: v1alpha3common.StateFailed, - PreDeploymentEvaluationStatus: v1alpha3common.StateFailed, - PostDeploymentEvaluationStatus: v1alpha3common.StateFailed, - WorkloadOverallStatus: v1alpha3common.StateFailed, - WorkloadStatus: []v1alpha3.WorkloadStatus{ - { - Workload: v1alpha3.KeptnWorkloadRef{ + Status: v1beta1.KeptnAppVersionStatus{ + PreDeploymentStatus: v1beta1common.StateFailed, + PostDeploymentStatus: v1beta1common.StateFailed, + PreDeploymentEvaluationStatus: v1beta1common.StateFailed, + PostDeploymentEvaluationStatus: v1beta1common.StateFailed, + WorkloadOverallStatus: v1beta1common.StateFailed, + WorkloadStatus: []v1beta1.WorkloadStatus{ + { + Workload: v1beta1.KeptnWorkloadRef{ Name: "name1", Version: "1", }, - Status: v1alpha3common.StateFailed, + Status: v1beta1common.StateFailed, }, { - Workload: v1alpha3.KeptnWorkloadRef{ + Workload: v1beta1.KeptnWorkloadRef{ Name: "name2", Version: "2", }, - Status: v1alpha3common.StateFailed, + Status: v1beta1common.StateFailed, }, }, CurrentPhase: "phase", - PreDeploymentTaskStatus: []v1alpha3.ItemStatus{ + PreDeploymentTaskStatus: []v1beta1.ItemStatus{ { DefinitionName: "def1", Name: "name1", - Status: v1alpha3common.StateFailed, + Status: v1beta1common.StateFailed, }, { DefinitionName: "def12", Name: "name12", - Status: v1alpha3common.StateFailed, + Status: v1beta1common.StateFailed, }, }, - PostDeploymentTaskStatus: []v1alpha3.ItemStatus{ + PostDeploymentTaskStatus: []v1beta1.ItemStatus{ { DefinitionName: "def2", Name: "name2", - Status: v1alpha3common.StateFailed, + Status: v1beta1common.StateFailed, }, { DefinitionName: "def22", Name: "name22", - Status: v1alpha3common.StateFailed, + Status: v1beta1common.StateFailed, }, }, - PreDeploymentEvaluationTaskStatus: []v1alpha3.ItemStatus{ + PreDeploymentEvaluationTaskStatus: []v1beta1.ItemStatus{ { DefinitionName: "def3", Name: "name3", - Status: v1alpha3common.StateFailed, + Status: v1beta1common.StateFailed, }, { DefinitionName: "def32", Name: "name32", - Status: v1alpha3common.StateFailed, + Status: v1beta1common.StateFailed, }, }, - PostDeploymentEvaluationTaskStatus: []v1alpha3.ItemStatus{ + PostDeploymentEvaluationTaskStatus: []v1beta1.ItemStatus{ { DefinitionName: "def4", Name: "name4", - Status: v1alpha3common.StateFailed, + Status: v1beta1common.StateFailed, }, { DefinitionName: "def42", Name: "name42", - Status: v1alpha3common.StateFailed, + Status: v1beta1common.StateFailed, }, }, - PhaseTraceIDs: v1alpha3common.PhaseTraceID{ + PhaseTraceIDs: v1beta1common.PhaseTraceID{ "key": propagation.MapCarrier{ "key1": "value1", "key2": "value2", @@ -152,7 +152,7 @@ func TestKeptnAppVersion_ConvertFrom(t *testing.T) { "key222": "value222", }, }, - Status: v1alpha3common.StateFailed, + Status: v1beta1common.StateFailed, }, }, wantErr: false, @@ -309,14 +309,14 @@ func TestKeptnAppVersion_ConvertTo(t *testing.T) { name string src *KeptnAppVersion wantErr bool - wantObj *v1alpha3.KeptnAppVersion + wantObj *v1beta1.KeptnAppVersion }{ { - name: "Test that conversion from v1alpha3 to v1alpha3 works", + name: "Test that conversion from v1beta1 to v1beta1 works", src: &KeptnAppVersion{ TypeMeta: v1.TypeMeta{ Kind: "KeptnAppVersion", - APIVersion: "lifecycle.keptn.sh/v1alpha3", + APIVersion: "lifecycle.keptn.sh/v1beta1", }, ObjectMeta: v1.ObjectMeta{ Name: "some-keptn-app-name", @@ -446,7 +446,7 @@ func TestKeptnAppVersion_ConvertTo(t *testing.T) { }, }, wantErr: false, - wantObj: &v1alpha3.KeptnAppVersion{ + wantObj: &v1beta1.KeptnAppVersion{ ObjectMeta: v1.ObjectMeta{ Name: "some-keptn-app-name", Namespace: "", @@ -457,11 +457,11 @@ func TestKeptnAppVersion_ConvertTo(t *testing.T) { "some-annotation": "some-annotation-value", }, }, - Spec: v1alpha3.KeptnAppVersionSpec{ - KeptnAppSpec: v1alpha3.KeptnAppSpec{ + Spec: v1beta1.KeptnAppVersionSpec{ + KeptnAppSpec: v1beta1.KeptnAppSpec{ Version: "1.2.3", Revision: 1, - Workloads: []v1alpha3.KeptnWorkloadRef{ + Workloads: []v1beta1.KeptnWorkloadRef{ { Name: "workload-1", Version: "1.2.3", @@ -491,78 +491,78 @@ func TestKeptnAppVersion_ConvertTo(t *testing.T) { "key2": "value2", }, }, - Status: v1alpha3.KeptnAppVersionStatus{ - PreDeploymentStatus: v1alpha3common.StateFailed, - PostDeploymentStatus: v1alpha3common.StateFailed, - PreDeploymentEvaluationStatus: v1alpha3common.StateFailed, - PostDeploymentEvaluationStatus: v1alpha3common.StateFailed, - WorkloadOverallStatus: v1alpha3common.StateFailed, - WorkloadStatus: []v1alpha3.WorkloadStatus{ - { - Workload: v1alpha3.KeptnWorkloadRef{ + Status: v1beta1.KeptnAppVersionStatus{ + PreDeploymentStatus: v1beta1common.StateFailed, + PostDeploymentStatus: v1beta1common.StateFailed, + PreDeploymentEvaluationStatus: v1beta1common.StateFailed, + PostDeploymentEvaluationStatus: v1beta1common.StateFailed, + WorkloadOverallStatus: v1beta1common.StateFailed, + WorkloadStatus: []v1beta1.WorkloadStatus{ + { + Workload: v1beta1.KeptnWorkloadRef{ Name: "name1", Version: "1", }, - Status: v1alpha3common.StateFailed, + Status: v1beta1common.StateFailed, }, { - Workload: v1alpha3.KeptnWorkloadRef{ + Workload: v1beta1.KeptnWorkloadRef{ Name: "name2", Version: "2", }, - Status: v1alpha3common.StateFailed, + Status: v1beta1common.StateFailed, }, }, CurrentPhase: "phase", - PreDeploymentTaskStatus: []v1alpha3.ItemStatus{ + PreDeploymentTaskStatus: []v1beta1.ItemStatus{ { DefinitionName: "def1", Name: "name1", - Status: v1alpha3common.StateFailed, + Status: v1beta1common.StateFailed, }, { DefinitionName: "def12", Name: "name12", - Status: v1alpha3common.StateFailed, + Status: v1beta1common.StateFailed, }, }, - PostDeploymentTaskStatus: []v1alpha3.ItemStatus{ + PostDeploymentTaskStatus: []v1beta1.ItemStatus{ { DefinitionName: "def2", Name: "name2", - Status: v1alpha3common.StateFailed, + Status: v1beta1common.StateFailed, }, { DefinitionName: "def22", Name: "name22", - Status: v1alpha3common.StateFailed, + Status: v1beta1common.StateFailed, }, }, - PreDeploymentEvaluationTaskStatus: []v1alpha3.ItemStatus{ + PreDeploymentEvaluationTaskStatus: []v1beta1.ItemStatus{ { DefinitionName: "def3", Name: "name3", - Status: v1alpha3common.StateFailed, + Status: v1beta1common.StateFailed, }, { DefinitionName: "def32", Name: "name32", - Status: v1alpha3common.StateFailed, + Status: v1beta1common.StateFailed, }, }, - PostDeploymentEvaluationTaskStatus: []v1alpha3.ItemStatus{ + PostDeploymentEvaluationTaskStatus: []v1beta1.ItemStatus{ { DefinitionName: "def4", Name: "name4", - Status: v1alpha3common.StateFailed, + Status: v1beta1common.StateFailed, }, { DefinitionName: "def42", Name: "name42", - Status: v1alpha3common.StateFailed, + Status: v1beta1common.StateFailed, }, }, - PhaseTraceIDs: v1alpha3common.PhaseTraceID{ + PhaseTraceIDs: v1beta1common.PhaseTraceID{ "key": propagation.MapCarrier{ "key1": "value1", "key2": "value2", @@ -572,18 +572,18 @@ func TestKeptnAppVersion_ConvertTo(t *testing.T) { "key222": "value222", }, }, - Status: v1alpha3common.StateFailed, + Status: v1beta1common.StateFailed, }, }, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - dst := v1alpha3.KeptnAppVersion{ + dst := v1beta1.KeptnAppVersion{ TypeMeta: v1.TypeMeta{}, ObjectMeta: v1.ObjectMeta{}, - Spec: v1alpha3.KeptnAppVersionSpec{}, - Status: v1alpha3.KeptnAppVersionStatus{}, + Spec: v1beta1.KeptnAppVersionSpec{}, + Status: v1beta1.KeptnAppVersionStatus{}, } if err := tt.src.ConvertTo(&dst); (err != nil) != tt.wantErr { t.Errorf("ConvertTo() error = %v, wantErr %v", err, tt.wantErr) diff --git a/lifecycle-operator/apis/lifecycle/v1alpha2/keptnevaluationprovider_conversion.go b/lifecycle-operator/apis/lifecycle/v1alpha2/keptnevaluationprovider_conversion.go deleted file mode 100644 index 5d62b63c25a..00000000000 --- a/lifecycle-operator/apis/lifecycle/v1alpha2/keptnevaluationprovider_conversion.go +++ /dev/null @@ -1,59 +0,0 @@ -package v1alpha2 - -import ( - "fmt" - - "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha2/common" - "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3" - corev1 "k8s.io/api/core/v1" - "sigs.k8s.io/controller-runtime/pkg/conversion" -) - -// ConvertTo converts the src v1alpha2.KeptnEvaluationProvider to the hub version (v1alpha3.KeptnEvaluationProvider) -func (src *KeptnEvaluationProvider) ConvertTo(dstRaw conversion.Hub) error { - dst, ok := dstRaw.(*v1alpha3.KeptnEvaluationProvider) - - if !ok { - return fmt.Errorf("type %T %w", dstRaw, common.ErrCannotCastKeptnEvaluationProvider) - } - - // Copy equal stuff to new object - // DO NOT COPY TypeMeta - dst.ObjectMeta = src.ObjectMeta - - dst.Spec.TargetServer = src.Spec.TargetServer - - // Set sensible defaults for new fields - dst.Spec.SecretKeyRef = corev1.SecretKeySelector{ - LocalObjectReference: corev1.LocalObjectReference{ - Name: src.Spec.SecretKeyRef.Name, - }, - Key: src.Spec.SecretKeyRef.Key, - } - - return nil -} - -// ConvertFrom converts from the hub version (v1alpha3.KeptnEvaluationProvider) to this version (v1alpha2.KeptnEvaluationProvider) -func (dst *KeptnEvaluationProvider) ConvertFrom(srcRaw conversion.Hub) error { - src, ok := srcRaw.(*v1alpha3.KeptnEvaluationProvider) - - if !ok { - return fmt.Errorf("type %T %w", srcRaw, common.ErrCannotCastKeptnEvaluationProvider) - } - - // Copy equal stuff to new object - // DO NOT COPY TypeMeta - dst.ObjectMeta = src.ObjectMeta - - dst.Spec.TargetServer = src.Spec.TargetServer - // Set sensible defaults for new fields - dst.Spec.SecretKeyRef = corev1.SecretKeySelector{ - LocalObjectReference: corev1.LocalObjectReference{ - Name: src.Spec.SecretKeyRef.Name, - }, - Key: src.Spec.SecretKeyRef.Key, - } - - return nil -} diff --git a/lifecycle-operator/apis/lifecycle/v1alpha2/keptnevaluationprovider_conversion_test.go b/lifecycle-operator/apis/lifecycle/v1alpha2/keptnevaluationprovider_conversion_test.go deleted file mode 100644 index 6a2f3ecdeaf..00000000000 --- a/lifecycle-operator/apis/lifecycle/v1alpha2/keptnevaluationprovider_conversion_test.go +++ /dev/null @@ -1,188 +0,0 @@ -package v1alpha2 - -import ( - "testing" - - "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha2/common" - "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3" - "github.com/stretchr/testify/require" - corev1 "k8s.io/api/core/v1" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - v2 "sigs.k8s.io/controller-runtime/pkg/webhook/conversion/testdata/api/v2" -) - -func TestKeptnEvalProvider_ConvertFrom(t *testing.T) { - tests := []struct { - name string - srcObj *v1alpha3.KeptnEvaluationProvider - wantErr bool - wantObj *KeptnEvaluationProvider - }{ - { - name: "Test that conversion from v1alpha3 to v1alpha2 works", - srcObj: &v1alpha3.KeptnEvaluationProvider{ - TypeMeta: v1.TypeMeta{ - Kind: "KeptnEvaluationProvider", - APIVersion: "lifecycle.keptn.sh/v1alpha3", - }, - ObjectMeta: v1.ObjectMeta{ - Name: "some-keptn-app-name", - Namespace: "", - Labels: map[string]string{ - "some-label": "some-label-value", - }, - Annotations: map[string]string{ - "some-annotation": "some-annotation-value", - }, - }, - Spec: v1alpha3.KeptnEvaluationProviderSpec{ - TargetServer: "my-server", - SecretKeyRef: corev1.SecretKeySelector{ - LocalObjectReference: corev1.LocalObjectReference{ - Name: "my-secret-name", - }, - Key: "my-secret-key", - }, - }, - }, - wantErr: false, - wantObj: &KeptnEvaluationProvider{ - ObjectMeta: v1.ObjectMeta{ - Name: "some-keptn-app-name", - Namespace: "", - Labels: map[string]string{ - "some-label": "some-label-value", - }, - Annotations: map[string]string{ - "some-annotation": "some-annotation-value", - }, - }, - Spec: KeptnEvaluationProviderSpec{ - TargetServer: "my-server", - SecretKeyRef: corev1.SecretKeySelector{ - LocalObjectReference: corev1.LocalObjectReference{ - Name: "my-secret-name", - }, - Key: "my-secret-key", - }, - }, - }, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - dst := &KeptnEvaluationProvider{ - TypeMeta: v1.TypeMeta{}, - ObjectMeta: v1.ObjectMeta{}, - Spec: KeptnEvaluationProviderSpec{}, - } - if err := dst.ConvertFrom(tt.srcObj); (err != nil) != tt.wantErr { - t.Errorf("ConvertFrom() error = %v, wantErr %v", err, tt.wantErr) - } - if tt.wantObj != nil { - require.Equal(t, tt.wantObj, dst, "Object was not converted correctly") - } - }) - } -} - -func TestKeptnEvalProvider_ConvertTo(t *testing.T) { - tests := []struct { - name string - src *KeptnEvaluationProvider - wantErr bool - wantObj *v1alpha3.KeptnEvaluationProvider - }{ - { - name: "Test that conversion from v1alpha2 to v1alpha3 works", - src: &KeptnEvaluationProvider{ - TypeMeta: v1.TypeMeta{ - Kind: "KeptnEvaluationProvider", - APIVersion: "lifecycle.keptn.sh/v1alpha2", - }, - ObjectMeta: v1.ObjectMeta{ - Name: "some-keptn-app-name", - Namespace: "", - Labels: map[string]string{ - "some-label": "some-label-value", - }, - Annotations: map[string]string{ - "some-annotation": "some-annotation-value", - }, - }, - Spec: KeptnEvaluationProviderSpec{ - TargetServer: "my-server", - SecretKeyRef: corev1.SecretKeySelector{ - LocalObjectReference: corev1.LocalObjectReference{ - Name: "my-secret-name", - }, - Key: "apiToken", - }, - }, - }, - wantErr: false, - wantObj: &v1alpha3.KeptnEvaluationProvider{ - ObjectMeta: v1.ObjectMeta{ - Name: "some-keptn-app-name", - Namespace: "", - Labels: map[string]string{ - "some-label": "some-label-value", - }, - Annotations: map[string]string{ - "some-annotation": "some-annotation-value", - }, - }, - Spec: v1alpha3.KeptnEvaluationProviderSpec{ - TargetServer: "my-server", - SecretKeyRef: corev1.SecretKeySelector{ - LocalObjectReference: corev1.LocalObjectReference{ - Name: "my-secret-name", - }, - Key: "apiToken", - }, - }, - }, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - dst := v1alpha3.KeptnEvaluationProvider{ - TypeMeta: v1.TypeMeta{}, - ObjectMeta: v1.ObjectMeta{}, - Spec: v1alpha3.KeptnEvaluationProviderSpec{}, - } - if err := tt.src.ConvertTo(&dst); (err != nil) != tt.wantErr { - t.Errorf("ConvertTo() error = %v, wantErr %v", err, tt.wantErr) - } - if tt.wantObj != nil { - require.Equal(t, tt.wantObj, &dst, "Object was not converted correctly") - } - }) - } -} - -func TestKeptnEvalProvider_ConvertFrom_Errorcase(t *testing.T) { - // A random different object is used here to simulate a different API version - testObj := v2.ExternalJob{} - - dst := &KeptnEvaluationProvider{} - - if err := dst.ConvertFrom(&testObj); err == nil { - t.Errorf("ConvertFrom() error = %v", err) - } else { - require.ErrorIs(t, err, common.ErrCannotCastKeptnEvaluationProvider) - } -} - -func TestKeptnEvalProvider_ConvertTo_Errorcase(t *testing.T) { - testObj := KeptnEvaluationProvider{} - - // A random different object is used here to simulate a different API version - dst := v2.ExternalJob{} - - if err := testObj.ConvertTo(&dst); err == nil { - t.Errorf("ConvertTo() error = %v", err) - } else { - require.ErrorIs(t, err, common.ErrCannotCastKeptnEvaluationProvider) - } -} diff --git a/lifecycle-operator/apis/lifecycle/v1alpha2/keptnevaluationprovider_test.go b/lifecycle-operator/apis/lifecycle/v1alpha2/keptnevaluationprovider_test.go deleted file mode 100644 index 7947ca545b1..00000000000 --- a/lifecycle-operator/apis/lifecycle/v1alpha2/keptnevaluationprovider_test.go +++ /dev/null @@ -1,125 +0,0 @@ -/* -Copyright 2022. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package v1alpha2 - -import ( - "testing" - - "github.com/stretchr/testify/require" - corev1 "k8s.io/api/core/v1" -) - -func TestHasKey(t *testing.T) { - tests := []struct { - name string - provider KeptnEvaluationProvider - result bool - }{ - { - name: "Correct Definition", - provider: KeptnEvaluationProvider{ - Spec: KeptnEvaluationProviderSpec{ - TargetServer: "", - SecretKeyRef: corev1.SecretKeySelector{ - LocalObjectReference: corev1.LocalObjectReference{ - Name: "mysecret", - }, - Key: "mykey", - }, - }, - }, - result: true, - }, - { - name: "Missing key", - provider: KeptnEvaluationProvider{ - Spec: KeptnEvaluationProviderSpec{ - TargetServer: "", - SecretKeyRef: corev1.SecretKeySelector{ - LocalObjectReference: corev1.LocalObjectReference{ - Name: "mysecret", - }, - Key: "", - }, - }, - }, - result: false, - }, - { - name: "Missing name", - provider: KeptnEvaluationProvider{ - Spec: KeptnEvaluationProviderSpec{ - TargetServer: "", - SecretKeyRef: corev1.SecretKeySelector{ - LocalObjectReference: corev1.LocalObjectReference{ - Name: "", - }, - Key: "mykey", - }, - }, - }, - result: false, - }, - { - name: "Key made by spaces", - provider: KeptnEvaluationProvider{ - Spec: KeptnEvaluationProviderSpec{ - TargetServer: "", - SecretKeyRef: corev1.SecretKeySelector{ - LocalObjectReference: corev1.LocalObjectReference{ - Name: "mysecret", - }, - Key: " ", - }, - }, - }, - result: false, - }, - { - name: "Name made by spaces", - provider: KeptnEvaluationProvider{ - Spec: KeptnEvaluationProviderSpec{ - TargetServer: "", - SecretKeyRef: corev1.SecretKeySelector{ - LocalObjectReference: corev1.LocalObjectReference{ - Name: " ", - }, - Key: "mykey", - }, - }, - }, - result: false, - }, - { - name: "Empty secret struct", - provider: KeptnEvaluationProvider{ - Spec: KeptnEvaluationProviderSpec{ - TargetServer: "", - SecretKeyRef: corev1.SecretKeySelector{}, - }, - }, - result: false, - }, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - require.Equal(t, tt.result, tt.provider.HasSecretDefined()) - }) - - } -} diff --git a/lifecycle-operator/apis/lifecycle/v1alpha2/keptnevaluationprovider_types.go b/lifecycle-operator/apis/lifecycle/v1alpha2/keptnevaluationprovider_types.go index 7cbb0fa8fcf..e237cc7994e 100644 --- a/lifecycle-operator/apis/lifecycle/v1alpha2/keptnevaluationprovider_types.go +++ b/lifecycle-operator/apis/lifecycle/v1alpha2/keptnevaluationprovider_types.go @@ -17,8 +17,6 @@ limitations under the License. package v1alpha2 import ( - "strings" - corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -63,13 +61,3 @@ type KeptnEvaluationProviderList struct { func init() { SchemeBuilder.Register(&KeptnEvaluationProvider{}, &KeptnEvaluationProviderList{}) } - -func (p *KeptnEvaluationProvider) HasSecretDefined() bool { - if p.Spec.SecretKeyRef == (corev1.SecretKeySelector{}) { - return false - } - if strings.TrimSpace(p.Spec.SecretKeyRef.Name) == "" || strings.TrimSpace(p.Spec.SecretKeyRef.Key) == "" { - return false - } - return true -} diff --git a/lifecycle-operator/apis/lifecycle/v1alpha2/keptnworkloadinstance_conversion.go b/lifecycle-operator/apis/lifecycle/v1alpha2/keptnworkloadinstance_conversion.go deleted file mode 100644 index f6812c09957..00000000000 --- a/lifecycle-operator/apis/lifecycle/v1alpha2/keptnworkloadinstance_conversion.go +++ /dev/null @@ -1,203 +0,0 @@ -package v1alpha2 - -import ( - "fmt" - - "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha2/common" - "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3" - v1alpha3common "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3/common" - "go.opentelemetry.io/otel/propagation" - "sigs.k8s.io/controller-runtime/pkg/conversion" -) - -// ConvertTo converts the src v1alpha3.KeptnWorkloadInstance to the hub version (v1alpha3.KeptnWorkloadInstance) -func (src *KeptnWorkloadInstance) ConvertTo(dstRaw conversion.Hub) error { - dst, ok := dstRaw.(*v1alpha3.KeptnWorkloadInstance) - - if !ok { - return fmt.Errorf("type %T %w", dstRaw, common.ErrCannotCastKeptnWorkloadInstance) - } - - // Copy equal stuff to new object - // DO NOT COPY TypeMeta - dst.ObjectMeta = src.ObjectMeta - - dst.Spec.AppName = src.Spec.AppName - dst.Spec.Version = src.Spec.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.ResourceReference = v1alpha3.ResourceReference{ - UID: src.Spec.ResourceReference.UID, - Kind: src.Spec.ResourceReference.Kind, - Name: src.Spec.ResourceReference.Name, - } - - dst.Spec.WorkloadName = src.Spec.WorkloadName - 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 = v1alpha3common.KeptnState(src.Status.PreDeploymentStatus) - dst.Status.PostDeploymentStatus = v1alpha3common.KeptnState(src.Status.PostDeploymentStatus) - dst.Status.PreDeploymentEvaluationStatus = v1alpha3common.KeptnState(src.Status.PreDeploymentEvaluationStatus) - dst.Status.PostDeploymentEvaluationStatus = v1alpha3common.KeptnState(src.Status.PostDeploymentEvaluationStatus) - dst.Status.DeploymentStatus = v1alpha3common.KeptnState(src.Status.DeploymentStatus) - dst.Status.Status = v1alpha3common.KeptnState(src.Status.Status) - - dst.Status.CurrentPhase = src.Status.CurrentPhase - - // Convert changed fields - for _, item := range src.Status.PreDeploymentTaskStatus { - dst.Status.PreDeploymentTaskStatus = append(dst.Status.PreDeploymentTaskStatus, v1alpha3.ItemStatus{ - DefinitionName: item.DefinitionName, - Status: v1alpha3common.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, v1alpha3.ItemStatus{ - DefinitionName: item.DefinitionName, - Status: v1alpha3common.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, v1alpha3.ItemStatus{ - DefinitionName: item.DefinitionName, - Status: v1alpha3common.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, v1alpha3.ItemStatus{ - DefinitionName: item.DefinitionName, - Status: v1alpha3common.KeptnState(item.Status), - Name: item.Name, - StartTime: item.StartTime, - EndTime: item.EndTime, - }) - } - - dst.Status.PhaseTraceIDs = make(v1alpha3common.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 (v1alpha3.KeptnWorkloadInstance) to this version (v1alpha3.KeptnWorkloadInstance) -func (dst *KeptnWorkloadInstance) ConvertFrom(srcRaw conversion.Hub) error { - src, ok := srcRaw.(*v1alpha3.KeptnWorkloadInstance) - - if !ok { - return fmt.Errorf("type %T %w", srcRaw, common.ErrCannotCastKeptnWorkloadInstance) - } - - // Copy equal stuff to new object - // DO NOT COPY TypeMeta - dst.ObjectMeta = src.ObjectMeta - - dst.Spec.AppName = src.Spec.AppName - dst.Spec.Version = src.Spec.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.ResourceReference = ResourceReference{ - UID: src.Spec.ResourceReference.UID, - Kind: src.Spec.ResourceReference.Kind, - Name: src.Spec.ResourceReference.Name, - } - - dst.Spec.WorkloadName = src.Spec.WorkloadName - 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 = 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.DeploymentStatus = common.KeptnState(src.Status.DeploymentStatus) - dst.Status.Status = common.KeptnState(src.Status.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, - }) - } - - 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/v1alpha2/keptnworkloadinstance_conversion_test.go b/lifecycle-operator/apis/lifecycle/v1alpha2/keptnworkloadinstance_conversion_test.go deleted file mode 100644 index 10d46f2e24c..00000000000 --- a/lifecycle-operator/apis/lifecycle/v1alpha2/keptnworkloadinstance_conversion_test.go +++ /dev/null @@ -1,546 +0,0 @@ -//nolint:dupl -package v1alpha2 - -import ( - "testing" - - "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha2/common" - "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3" - v1alpha3common "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3/common" - "github.com/stretchr/testify/require" - "go.opentelemetry.io/otel/propagation" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/types" - v2 "sigs.k8s.io/controller-runtime/pkg/webhook/conversion/testdata/api/v2" -) - -func TestKeptnWorkloadInstance_ConvertFrom(t *testing.T) { - tests := []struct { - name string - srcObj *v1alpha3.KeptnWorkloadInstance - wantErr bool - wantObj *KeptnWorkloadInstance - }{ - { - name: "Test that conversion from v1alpha2 to v1alpha3 works", - srcObj: &v1alpha3.KeptnWorkloadInstance{ - TypeMeta: v1.TypeMeta{ - Kind: "KeptnWorkloadInstance", - APIVersion: "lifecycle.keptn.sh/v1alpha2", - }, - ObjectMeta: v1.ObjectMeta{ - Name: "some-keptn-app-name", - Namespace: "", - Labels: map[string]string{ - "some-label": "some-label-value", - }, - Annotations: map[string]string{ - "some-annotation": "some-annotation-value", - }, - }, - Spec: v1alpha3.KeptnWorkloadInstanceSpec{ - KeptnWorkloadSpec: v1alpha3.KeptnWorkloadSpec{ - Version: "1.2.3", - ResourceReference: v1alpha3.ResourceReference{ - UID: types.UID("1"), - Kind: "Pod", - Name: "pod", - }, - PreDeploymentTasks: []string{ - "some-pre-deployment-task1", - }, - PostDeploymentTasks: []string{ - "some-post-deployment-task2", - }, - PreDeploymentEvaluations: []string{ - "some-pre-evaluation-task1", - }, - PostDeploymentEvaluations: []string{ - "some-pre-evaluation-task2", - }, - AppName: "app", - }, - WorkloadName: "workload", - PreviousVersion: "1.0", - TraceId: map[string]string{ - "key1": "value1", - "key2": "value2", - }, - }, - Status: v1alpha3.KeptnWorkloadInstanceStatus{ - PreDeploymentStatus: v1alpha3common.StateFailed, - PostDeploymentStatus: v1alpha3common.StateFailed, - PreDeploymentEvaluationStatus: v1alpha3common.StateFailed, - PostDeploymentEvaluationStatus: v1alpha3common.StateFailed, - DeploymentStatus: v1alpha3common.StateFailed, - CurrentPhase: "phase", - PreDeploymentTaskStatus: []v1alpha3.ItemStatus{ - { - DefinitionName: "def1", - Name: "name1", - Status: v1alpha3common.StateFailed, - }, - { - DefinitionName: "def12", - Name: "name12", - Status: v1alpha3common.StateFailed, - }, - }, - PostDeploymentTaskStatus: []v1alpha3.ItemStatus{ - { - DefinitionName: "def2", - Name: "name2", - Status: v1alpha3common.StateFailed, - }, - { - DefinitionName: "def22", - Name: "name22", - Status: v1alpha3common.StateFailed, - }, - }, - PreDeploymentEvaluationTaskStatus: []v1alpha3.ItemStatus{ - { - DefinitionName: "def3", - Name: "name3", - Status: v1alpha3common.StateFailed, - }, - { - DefinitionName: "def32", - Name: "name32", - Status: v1alpha3common.StateFailed, - }, - }, - PostDeploymentEvaluationTaskStatus: []v1alpha3.ItemStatus{ - { - DefinitionName: "def4", - Name: "name4", - Status: v1alpha3common.StateFailed, - }, - { - DefinitionName: "def42", - Name: "name42", - Status: v1alpha3common.StateFailed, - }, - }, - PhaseTraceIDs: v1alpha3common.PhaseTraceID{ - "key": propagation.MapCarrier{ - "key1": "value1", - "key2": "value2", - }, - "key22": propagation.MapCarrier{ - "key122": "value122", - "key222": "value222", - }, - }, - Status: v1alpha3common.StateFailed, - }, - }, - wantErr: false, - wantObj: &KeptnWorkloadInstance{ - ObjectMeta: v1.ObjectMeta{ - Name: "some-keptn-app-name", - Namespace: "", - Labels: map[string]string{ - "some-label": "some-label-value", - }, - Annotations: map[string]string{ - "some-annotation": "some-annotation-value", - }, - }, - Spec: KeptnWorkloadInstanceSpec{ - KeptnWorkloadSpec: KeptnWorkloadSpec{ - Version: "1.2.3", - ResourceReference: ResourceReference{ - UID: types.UID("1"), - Kind: "Pod", - Name: "pod", - }, - PreDeploymentTasks: []string{ - "some-pre-deployment-task1", - }, - PostDeploymentTasks: []string{ - "some-post-deployment-task2", - }, - PreDeploymentEvaluations: []string{ - "some-pre-evaluation-task1", - }, - PostDeploymentEvaluations: []string{ - "some-pre-evaluation-task2", - }, - AppName: "app", - }, - WorkloadName: "workload", - PreviousVersion: "1.0", - TraceId: map[string]string{ - "key1": "value1", - "key2": "value2", - }, - }, - Status: KeptnWorkloadInstanceStatus{ - PreDeploymentStatus: common.StateFailed, - PostDeploymentStatus: common.StateFailed, - PreDeploymentEvaluationStatus: common.StateFailed, - PostDeploymentEvaluationStatus: common.StateFailed, - DeploymentStatus: common.StateFailed, - CurrentPhase: "phase", - PreDeploymentTaskStatus: []ItemStatus{ - { - DefinitionName: "def1", - Name: "name1", - Status: common.StateFailed, - }, - { - DefinitionName: "def12", - Name: "name12", - Status: common.StateFailed, - }, - }, - PostDeploymentTaskStatus: []ItemStatus{ - { - DefinitionName: "def2", - Name: "name2", - Status: common.StateFailed, - }, - { - DefinitionName: "def22", - Name: "name22", - Status: common.StateFailed, - }, - }, - PreDeploymentEvaluationTaskStatus: []ItemStatus{ - { - DefinitionName: "def3", - Name: "name3", - Status: common.StateFailed, - }, - { - DefinitionName: "def32", - Name: "name32", - Status: common.StateFailed, - }, - }, - PostDeploymentEvaluationTaskStatus: []ItemStatus{ - { - DefinitionName: "def4", - Name: "name4", - Status: common.StateFailed, - }, - { - DefinitionName: "def42", - Name: "name42", - Status: common.StateFailed, - }, - }, - PhaseTraceIDs: common.PhaseTraceID{ - "key": propagation.MapCarrier{ - "key1": "value1", - "key2": "value2", - }, - "key22": propagation.MapCarrier{ - "key122": "value122", - "key222": "value222", - }, - }, - Status: common.StateFailed, - }, - }, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - dst := &KeptnWorkloadInstance{ - TypeMeta: v1.TypeMeta{}, - ObjectMeta: v1.ObjectMeta{}, - Spec: KeptnWorkloadInstanceSpec{}, - Status: KeptnWorkloadInstanceStatus{}, - } - if err := dst.ConvertFrom(tt.srcObj); (err != nil) != tt.wantErr { - t.Errorf("ConvertFrom() error = %v, wantErr %v", err, tt.wantErr) - } - if tt.wantObj != nil { - require.Equal(t, tt.wantObj, dst, "Object was not converted correctly") - } - }) - } -} - -func TestKeptnWorkloadInstance_ConvertTo(t *testing.T) { - tests := []struct { - name string - src *KeptnWorkloadInstance - wantErr bool - wantObj *v1alpha3.KeptnWorkloadInstance - }{ - { - name: "Test that conversion from v1alpha3 to v1alpha2 works", - src: &KeptnWorkloadInstance{ - TypeMeta: v1.TypeMeta{ - Kind: "KeptnWorkloadInstance", - APIVersion: "lifecycle.keptn.sh/v1alpha3", - }, - ObjectMeta: v1.ObjectMeta{ - Name: "some-keptn-app-name", - Namespace: "", - Labels: map[string]string{ - "some-label": "some-label-value", - }, - Annotations: map[string]string{ - "some-annotation": "some-annotation-value", - }, - }, - Spec: KeptnWorkloadInstanceSpec{ - KeptnWorkloadSpec: KeptnWorkloadSpec{ - Version: "1.2.3", - ResourceReference: ResourceReference{ - UID: types.UID("1"), - Kind: "Pod", - Name: "pod", - }, - PreDeploymentTasks: []string{ - "some-pre-deployment-task1", - }, - PostDeploymentTasks: []string{ - "some-post-deployment-task2", - }, - PreDeploymentEvaluations: []string{ - "some-pre-evaluation-task1", - }, - PostDeploymentEvaluations: []string{ - "some-pre-evaluation-task2", - }, - AppName: "app", - }, - WorkloadName: "workload", - PreviousVersion: "1.0", - TraceId: map[string]string{ - "key1": "value1", - "key2": "value2", - }, - }, - Status: KeptnWorkloadInstanceStatus{ - PreDeploymentStatus: common.StateFailed, - PostDeploymentStatus: common.StateFailed, - PreDeploymentEvaluationStatus: common.StateFailed, - PostDeploymentEvaluationStatus: common.StateFailed, - DeploymentStatus: common.StateFailed, - CurrentPhase: "phase", - PreDeploymentTaskStatus: []ItemStatus{ - { - DefinitionName: "def1", - Name: "name1", - Status: common.StateFailed, - }, - { - DefinitionName: "def12", - Name: "name12", - Status: common.StateFailed, - }, - }, - PostDeploymentTaskStatus: []ItemStatus{ - { - DefinitionName: "def2", - Name: "name2", - Status: common.StateFailed, - }, - { - DefinitionName: "def22", - Name: "name22", - Status: common.StateFailed, - }, - }, - PreDeploymentEvaluationTaskStatus: []ItemStatus{ - { - DefinitionName: "def3", - Name: "name3", - Status: common.StateFailed, - }, - { - DefinitionName: "def32", - Name: "name32", - Status: common.StateFailed, - }, - }, - PostDeploymentEvaluationTaskStatus: []ItemStatus{ - { - DefinitionName: "def4", - Name: "name4", - Status: common.StateFailed, - }, - { - DefinitionName: "def42", - Name: "name42", - Status: common.StateFailed, - }, - }, - PhaseTraceIDs: common.PhaseTraceID{ - "key": propagation.MapCarrier{ - "key1": "value1", - "key2": "value2", - }, - "key22": propagation.MapCarrier{ - "key122": "value122", - "key222": "value222", - }, - }, - Status: common.StateFailed, - }, - }, - wantErr: false, - wantObj: &v1alpha3.KeptnWorkloadInstance{ - ObjectMeta: v1.ObjectMeta{ - Name: "some-keptn-app-name", - Namespace: "", - Labels: map[string]string{ - "some-label": "some-label-value", - }, - Annotations: map[string]string{ - "some-annotation": "some-annotation-value", - }, - }, - Spec: v1alpha3.KeptnWorkloadInstanceSpec{ - KeptnWorkloadSpec: v1alpha3.KeptnWorkloadSpec{ - Version: "1.2.3", - ResourceReference: v1alpha3.ResourceReference{ - UID: types.UID("1"), - Kind: "Pod", - Name: "pod", - }, - PreDeploymentTasks: []string{ - "some-pre-deployment-task1", - }, - PostDeploymentTasks: []string{ - "some-post-deployment-task2", - }, - PreDeploymentEvaluations: []string{ - "some-pre-evaluation-task1", - }, - PostDeploymentEvaluations: []string{ - "some-pre-evaluation-task2", - }, - AppName: "app", - }, - WorkloadName: "workload", - PreviousVersion: "1.0", - TraceId: map[string]string{ - "key1": "value1", - "key2": "value2", - }, - }, - Status: v1alpha3.KeptnWorkloadInstanceStatus{ - PreDeploymentStatus: v1alpha3common.StateFailed, - PostDeploymentStatus: v1alpha3common.StateFailed, - PreDeploymentEvaluationStatus: v1alpha3common.StateFailed, - PostDeploymentEvaluationStatus: v1alpha3common.StateFailed, - DeploymentStatus: v1alpha3common.StateFailed, - CurrentPhase: "phase", - PreDeploymentTaskStatus: []v1alpha3.ItemStatus{ - { - DefinitionName: "def1", - Name: "name1", - Status: v1alpha3common.StateFailed, - }, - { - DefinitionName: "def12", - Name: "name12", - Status: v1alpha3common.StateFailed, - }, - }, - PostDeploymentTaskStatus: []v1alpha3.ItemStatus{ - { - DefinitionName: "def2", - Name: "name2", - Status: v1alpha3common.StateFailed, - }, - { - DefinitionName: "def22", - Name: "name22", - Status: v1alpha3common.StateFailed, - }, - }, - PreDeploymentEvaluationTaskStatus: []v1alpha3.ItemStatus{ - { - DefinitionName: "def3", - Name: "name3", - Status: v1alpha3common.StateFailed, - }, - { - DefinitionName: "def32", - Name: "name32", - Status: v1alpha3common.StateFailed, - }, - }, - PostDeploymentEvaluationTaskStatus: []v1alpha3.ItemStatus{ - { - DefinitionName: "def4", - Name: "name4", - Status: v1alpha3common.StateFailed, - }, - { - DefinitionName: "def42", - Name: "name42", - Status: v1alpha3common.StateFailed, - }, - }, - PhaseTraceIDs: v1alpha3common.PhaseTraceID{ - "key": propagation.MapCarrier{ - "key1": "value1", - "key2": "value2", - }, - "key22": propagation.MapCarrier{ - "key122": "value122", - "key222": "value222", - }, - }, - Status: v1alpha3common.StateFailed, - }, - }, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - dst := v1alpha3.KeptnWorkloadInstance{ - TypeMeta: v1.TypeMeta{}, - ObjectMeta: v1.ObjectMeta{}, - Spec: v1alpha3.KeptnWorkloadInstanceSpec{}, - Status: v1alpha3.KeptnWorkloadInstanceStatus{}, - } - if err := tt.src.ConvertTo(&dst); (err != nil) != tt.wantErr { - t.Errorf("ConvertTo() error = %v, wantErr %v", err, tt.wantErr) - } - if tt.wantObj != nil { - require.Equal(t, tt.wantObj, &dst, "Object was not converted correctly") - } - }) - } -} - -func TestKeptnWorkloadInstance_ConvertFrom_Errorcase(t *testing.T) { - // A random different object is used here to simulate a different API version - testObj := v2.ExternalJob{} - - dst := &KeptnWorkloadInstance{ - TypeMeta: v1.TypeMeta{}, - ObjectMeta: v1.ObjectMeta{}, - Spec: KeptnWorkloadInstanceSpec{}, - Status: KeptnWorkloadInstanceStatus{}, - } - - if err := dst.ConvertFrom(&testObj); err == nil { - t.Errorf("ConvertFrom() error = %v", err) - } else { - require.ErrorIs(t, err, common.ErrCannotCastKeptnWorkloadInstance) - } -} - -func TestKeptnWorkloadInstance_ConvertTo_Errorcase(t *testing.T) { - testObj := KeptnWorkloadInstance{} - - // A random different object is used here to simulate a different API version - dst := v2.ExternalJob{} - - if err := testObj.ConvertTo(&dst); err == nil { - t.Errorf("ConvertTo() error = %v", err) - } else { - require.ErrorIs(t, err, common.ErrCannotCastKeptnWorkloadInstance) - } -} diff --git a/lifecycle-operator/apis/lifecycle/v1alpha2/keptnworkloadinstance_test.go b/lifecycle-operator/apis/lifecycle/v1alpha2/keptnworkloadinstance_test.go deleted file mode 100644 index 6f433e9b553..00000000000 --- a/lifecycle-operator/apis/lifecycle/v1alpha2/keptnworkloadinstance_test.go +++ /dev/null @@ -1,410 +0,0 @@ -package v1alpha2 - -import ( - "testing" - "time" - - "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha2/common" - "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 TestKeptnWorkloadInstance(t *testing.T) { - workload := &KeptnWorkloadInstance{ - ObjectMeta: metav1.ObjectMeta{ - Name: "workload", - Namespace: "namespace", - }, - Status: KeptnWorkloadInstanceStatus{ - PreDeploymentStatus: common.StateFailed, - PreDeploymentEvaluationStatus: common.StateFailed, - PostDeploymentStatus: common.StateFailed, - PostDeploymentEvaluationStatus: common.StateFailed, - DeploymentStatus: common.StateFailed, - Status: common.StateFailed, - PreDeploymentTaskStatus: []ItemStatus{ - { - DefinitionName: "defname", - Status: common.StateFailed, - Name: "taskname", - }, - }, - PostDeploymentTaskStatus: []ItemStatus{ - { - DefinitionName: "defname2", - Status: common.StateFailed, - Name: "taskname2", - }, - }, - PreDeploymentEvaluationTaskStatus: []ItemStatus{ - { - DefinitionName: "defname3", - Status: common.StateFailed, - Name: "taskname3", - }, - }, - PostDeploymentEvaluationTaskStatus: []ItemStatus{ - { - DefinitionName: "defname4", - Status: common.StateFailed, - Name: "taskname4", - }, - }, - CurrentPhase: common.PhaseAppDeployment.ShortName, - }, - Spec: KeptnWorkloadInstanceSpec{ - KeptnWorkloadSpec: KeptnWorkloadSpec{ - PreDeploymentTasks: []string{"task1", "task2"}, - PostDeploymentTasks: []string{"task3", "task4"}, - PreDeploymentEvaluations: []string{"task5", "task6"}, - PostDeploymentEvaluations: []string{"task7", "task8"}, - Version: "version", - AppName: "appname", - }, - PreviousVersion: "prev", - WorkloadName: "workloadname", - TraceId: map[string]string{"traceparent": "trace1"}, - }, - } - - require.True(t, workload.IsPreDeploymentCompleted()) - require.False(t, workload.IsPreDeploymentSucceeded()) - require.True(t, workload.IsPreDeploymentFailed()) - - require.True(t, workload.IsPreDeploymentEvaluationCompleted()) - require.False(t, workload.IsPreDeploymentEvaluationSucceeded()) - require.True(t, workload.IsPreDeploymentEvaluationFailed()) - - require.True(t, workload.IsPostDeploymentCompleted()) - require.False(t, workload.IsPostDeploymentSucceeded()) - require.True(t, workload.IsPostDeploymentFailed()) - - require.True(t, workload.IsPostDeploymentEvaluationCompleted()) - require.False(t, workload.IsPostDeploymentEvaluationSucceeded()) - require.True(t, workload.IsPostDeploymentEvaluationFailed()) - - require.True(t, workload.IsDeploymentCompleted()) - require.False(t, workload.IsDeploymentSucceeded()) - require.True(t, workload.IsDeploymentFailed()) - - require.False(t, workload.IsEndTimeSet()) - require.False(t, workload.IsStartTimeSet()) - - workload.SetStartTime() - workload.SetEndTime() - - require.True(t, workload.IsEndTimeSet()) - require.True(t, workload.IsStartTimeSet()) - - require.Equal(t, []attribute.KeyValue{ - common.AppName.String("appname"), - common.WorkloadName.String("workloadname"), - common.WorkloadVersion.String("version"), - common.WorkloadNamespace.String("namespace"), - }, workload.GetActiveMetricsAttributes()) - - require.Equal(t, []attribute.KeyValue{ - common.AppName.String("appname"), - common.WorkloadName.String("workloadname"), - common.WorkloadVersion.String("version"), - common.WorkloadNamespace.String("namespace"), - common.WorkloadStatus.String(string(common.StateFailed)), - }, workload.GetMetricsAttributes()) - - require.Equal(t, []attribute.KeyValue{ - common.AppName.String("appname"), - common.WorkloadName.String("workloadname"), - common.WorkloadVersion.String("version"), - common.WorkloadPreviousVersion.String("prev"), - }, workload.GetDurationMetricsAttributes()) - - require.Equal(t, common.StateFailed, workload.GetState()) - - require.Equal(t, []string{"task1", "task2"}, workload.GetPreDeploymentTasks()) - require.Equal(t, []string{"task3", "task4"}, workload.GetPostDeploymentTasks()) - require.Equal(t, []string{"task5", "task6"}, workload.GetPreDeploymentEvaluations()) - require.Equal(t, []string{"task7", "task8"}, workload.GetPostDeploymentEvaluations()) - - require.Equal(t, []ItemStatus{ - { - DefinitionName: "defname", - Status: common.StateFailed, - Name: "taskname", - }, - }, workload.GetPreDeploymentTaskStatus()) - - require.Equal(t, []ItemStatus{ - { - DefinitionName: "defname2", - Status: common.StateFailed, - Name: "taskname2", - }, - }, workload.GetPostDeploymentTaskStatus()) - - require.Equal(t, []ItemStatus{ - { - DefinitionName: "defname3", - Status: common.StateFailed, - Name: "taskname3", - }, - }, workload.GetPreDeploymentEvaluationTaskStatus()) - - require.Equal(t, []ItemStatus{ - { - DefinitionName: "defname4", - Status: common.StateFailed, - Name: "taskname4", - }, - }, workload.GetPostDeploymentEvaluationTaskStatus()) - - require.Equal(t, "appname", workload.GetAppName()) - require.Equal(t, "prev", workload.GetPreviousVersion()) - require.Equal(t, "workloadname", workload.GetParentName()) - require.Equal(t, "namespace", workload.GetNamespace()) - - workload.SetState(common.StatePending) - require.Equal(t, common.StatePending, workload.GetState()) - - require.True(t, !workload.GetStartTime().IsZero()) - require.True(t, !workload.GetEndTime().IsZero()) - - workload.SetCurrentPhase(common.PhaseAppDeployment.LongName) - require.Equal(t, common.PhaseAppDeployment.LongName, workload.GetCurrentPhase()) - - workload.Status.EndTime = v1.Time{Time: time.Time{}} - workload.Complete() - require.True(t, !workload.GetEndTime().IsZero()) - - require.Equal(t, "version", workload.GetVersion()) - - require.Equal(t, "trace1.workloadname.version.phase", workload.GetSpanKey("phase")) - - task := workload.GenerateTask("taskdef", common.PostDeploymentCheckType) - require.Equal(t, KeptnTaskSpec{ - AppName: workload.GetAppName(), - WorkloadVersion: workload.GetVersion(), - Workload: workload.GetParentName(), - TaskDefinition: "taskdef", - Parameters: TaskParameters{}, - SecureParameters: SecureParameters{}, - Type: common.PostDeploymentCheckType, - }, task.Spec) - - evaluation := workload.GenerateEvaluation("taskdef", common.PostDeploymentCheckType) - require.Equal(t, KeptnEvaluationSpec{ - AppName: workload.GetAppName(), - WorkloadVersion: workload.GetVersion(), - Workload: workload.GetParentName(), - EvaluationDefinition: "taskdef", - Type: common.PostDeploymentCheckType, - RetryInterval: metav1.Duration{ - Duration: 5 * time.Second, - }, - }, evaluation.Spec) - - require.Equal(t, "workload", workload.GetSpanName("")) - - require.Equal(t, "workloadname/phase", workload.GetSpanName("phase")) - - require.Equal(t, []attribute.KeyValue{ - common.AppName.String("appname"), - common.WorkloadName.String("workloadname"), - common.WorkloadVersion.String("version"), - common.WorkloadNamespace.String("namespace"), - }, workload.GetSpanAttributes()) - - require.Equal(t, map[string]string{ - "appName": "appname", - "workloadName": "workloadname", - "workloadVersion": "version", - "workloadInstanceName": "workload", - }, workload.GetEventAnnotations()) -} - -//nolint:dupl -func TestKeptnWorkloadInstance_DeprecateRemainingPhases(t *testing.T) { - workloadInstance := KeptnWorkloadInstance{ - Status: KeptnWorkloadInstanceStatus{ - PreDeploymentStatus: common.StatePending, - PreDeploymentEvaluationStatus: common.StatePending, - PostDeploymentStatus: common.StatePending, - PostDeploymentEvaluationStatus: common.StatePending, - DeploymentStatus: common.StatePending, - Status: common.StatePending, - }, - } - - tests := []struct { - workloadInstance KeptnWorkloadInstance - phase common.KeptnPhaseType - want KeptnWorkloadInstance - }{ - { - workloadInstance: workloadInstance, - phase: common.PhaseWorkloadPostEvaluation, - want: KeptnWorkloadInstance{ - Status: KeptnWorkloadInstanceStatus{ - PreDeploymentStatus: common.StatePending, - PreDeploymentEvaluationStatus: common.StatePending, - PostDeploymentStatus: common.StatePending, - PostDeploymentEvaluationStatus: common.StatePending, - DeploymentStatus: common.StatePending, - Status: common.StatePending, - }, - }, - }, - { - workloadInstance: workloadInstance, - phase: common.PhaseWorkloadPostDeployment, - want: KeptnWorkloadInstance{ - Status: KeptnWorkloadInstanceStatus{ - PreDeploymentStatus: common.StatePending, - PreDeploymentEvaluationStatus: common.StatePending, - PostDeploymentStatus: common.StatePending, - PostDeploymentEvaluationStatus: common.StateDeprecated, - DeploymentStatus: common.StatePending, - Status: common.StateFailed, - }, - }, - }, - { - workloadInstance: workloadInstance, - phase: common.PhaseWorkloadDeployment, - want: KeptnWorkloadInstance{ - Status: KeptnWorkloadInstanceStatus{ - PreDeploymentStatus: common.StatePending, - PreDeploymentEvaluationStatus: common.StatePending, - PostDeploymentStatus: common.StateDeprecated, - PostDeploymentEvaluationStatus: common.StateDeprecated, - DeploymentStatus: common.StatePending, - Status: common.StateFailed, - }, - }, - }, - { - workloadInstance: workloadInstance, - phase: common.PhaseWorkloadPreEvaluation, - want: KeptnWorkloadInstance{ - Status: KeptnWorkloadInstanceStatus{ - PreDeploymentStatus: common.StatePending, - PreDeploymentEvaluationStatus: common.StatePending, - PostDeploymentStatus: common.StateDeprecated, - PostDeploymentEvaluationStatus: common.StateDeprecated, - DeploymentStatus: common.StateDeprecated, - Status: common.StateFailed, - }, - }, - }, - { - workloadInstance: workloadInstance, - phase: common.PhaseWorkloadPreDeployment, - want: KeptnWorkloadInstance{ - Status: KeptnWorkloadInstanceStatus{ - PreDeploymentStatus: common.StatePending, - PreDeploymentEvaluationStatus: common.StateDeprecated, - PostDeploymentStatus: common.StateDeprecated, - PostDeploymentEvaluationStatus: common.StateDeprecated, - DeploymentStatus: common.StateDeprecated, - Status: common.StateFailed, - }, - }, - }, - { - workloadInstance: workloadInstance, - phase: common.PhaseDeprecated, - want: KeptnWorkloadInstance{ - Status: KeptnWorkloadInstanceStatus{ - PreDeploymentStatus: common.StateDeprecated, - PreDeploymentEvaluationStatus: common.StateDeprecated, - PostDeploymentStatus: common.StateDeprecated, - PostDeploymentEvaluationStatus: common.StateDeprecated, - DeploymentStatus: common.StateDeprecated, - Status: common.StateDeprecated, - }, - }, - }, - { - workloadInstance: workloadInstance, - phase: common.PhaseAppPreDeployment, - want: KeptnWorkloadInstance{ - Status: KeptnWorkloadInstanceStatus{ - PreDeploymentStatus: common.StatePending, - PreDeploymentEvaluationStatus: common.StatePending, - PostDeploymentStatus: common.StatePending, - PostDeploymentEvaluationStatus: common.StatePending, - DeploymentStatus: common.StatePending, - Status: common.StateFailed, - }, - }, - }, - } - - for _, tt := range tests { - t.Run("", func(t *testing.T) { - tt.workloadInstance.DeprecateRemainingPhases(tt.phase) - require.Equal(t, tt.want, tt.workloadInstance) - }) - } -} - -func TestKeptnWorkloadInstance_SetPhaseTraceID(t *testing.T) { - app := KeptnWorkloadInstance{ - Status: KeptnWorkloadInstanceStatus{}, - } - - app.SetPhaseTraceID(common.PhaseAppDeployment.ShortName, propagation.MapCarrier{ - "name3": "trace3", - }) - - require.Equal(t, KeptnWorkloadInstance{ - Status: KeptnWorkloadInstanceStatus{ - PhaseTraceIDs: common.PhaseTraceID{ - common.PhaseAppDeployment.ShortName: propagation.MapCarrier{ - "name3": "trace3", - }, - }, - }, - }, app) - - app.SetPhaseTraceID(common.PhaseWorkloadDeployment.LongName, propagation.MapCarrier{ - "name2": "trace2", - }) - - require.Equal(t, KeptnWorkloadInstance{ - Status: KeptnWorkloadInstanceStatus{ - PhaseTraceIDs: common.PhaseTraceID{ - common.PhaseAppDeployment.ShortName: propagation.MapCarrier{ - "name3": "trace3", - }, - common.PhaseWorkloadDeployment.ShortName: propagation.MapCarrier{ - "name2": "trace2", - }, - }, - }, - }, app) -} - -func TestKeptnWorkloadInstanceList(t *testing.T) { - list := KeptnWorkloadInstanceList{ - Items: []KeptnWorkloadInstance{ - { - ObjectMeta: metav1.ObjectMeta{ - Name: "obj1", - }, - }, - { - ObjectMeta: metav1.ObjectMeta{ - Name: "obj2", - }, - }, - }, - } - - got := list.GetItems() - require.Len(t, got, 2) - require.Equal(t, "obj1", got[0].GetName()) - require.Equal(t, "obj2", got[1].GetName()) -} diff --git a/lifecycle-operator/apis/lifecycle/v1alpha2/keptnworkloadinstance_types.go b/lifecycle-operator/apis/lifecycle/v1alpha2/keptnworkloadinstance_types.go index 521e709cdc9..f9a97fdc8f5 100644 --- a/lifecycle-operator/apis/lifecycle/v1alpha2/keptnworkloadinstance_types.go +++ b/lifecycle-operator/apis/lifecycle/v1alpha2/keptnworkloadinstance_types.go @@ -17,15 +17,8 @@ limitations under the License. package v1alpha2 import ( - "fmt" - "time" - "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha2/common" - "go.opentelemetry.io/otel/attribute" - "go.opentelemetry.io/otel/propagation" - "go.opentelemetry.io/otel/trace" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "sigs.k8s.io/controller-runtime/pkg/client" ) // EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! @@ -133,330 +126,3 @@ type KeptnWorkloadInstanceList struct { func init() { SchemeBuilder.Register(&KeptnWorkloadInstance{}, &KeptnWorkloadInstanceList{}) } - -func (w KeptnWorkloadInstanceList) GetItems() []client.Object { - var b []client.Object - for i := 0; i < len(w.Items); i++ { - b = append(b, &w.Items[i]) - } - return b -} - -func (w KeptnWorkloadInstance) IsPreDeploymentCompleted() bool { - return w.Status.PreDeploymentStatus.IsCompleted() -} - -func (w KeptnWorkloadInstance) IsPreDeploymentEvaluationCompleted() bool { - return w.Status.PreDeploymentEvaluationStatus.IsCompleted() -} - -func (w KeptnWorkloadInstance) IsPreDeploymentSucceeded() bool { - return w.Status.PreDeploymentStatus.IsSucceeded() -} - -func (w KeptnWorkloadInstance) IsPreDeploymentFailed() bool { - return w.Status.PreDeploymentStatus.IsFailed() -} - -func (w KeptnWorkloadInstance) IsPreDeploymentEvaluationSucceeded() bool { - return w.Status.PreDeploymentEvaluationStatus.IsSucceeded() -} - -func (w KeptnWorkloadInstance) IsPreDeploymentEvaluationFailed() bool { - return w.Status.PreDeploymentEvaluationStatus.IsFailed() -} - -func (w KeptnWorkloadInstance) IsPostDeploymentCompleted() bool { - return w.Status.PostDeploymentStatus.IsCompleted() -} - -func (w KeptnWorkloadInstance) IsPostDeploymentEvaluationCompleted() bool { - return w.Status.PostDeploymentEvaluationStatus.IsCompleted() -} - -func (w KeptnWorkloadInstance) IsPostDeploymentSucceeded() bool { - return w.Status.PostDeploymentStatus.IsSucceeded() -} - -func (w KeptnWorkloadInstance) IsPostDeploymentFailed() bool { - return w.Status.PostDeploymentStatus.IsFailed() -} - -func (w KeptnWorkloadInstance) IsPostDeploymentEvaluationSucceeded() bool { - return w.Status.PostDeploymentEvaluationStatus.IsSucceeded() -} - -func (w KeptnWorkloadInstance) IsPostDeploymentEvaluationFailed() bool { - return w.Status.PostDeploymentEvaluationStatus.IsFailed() -} - -func (w KeptnWorkloadInstance) IsDeploymentCompleted() bool { - return w.Status.DeploymentStatus.IsCompleted() -} - -func (w KeptnWorkloadInstance) IsDeploymentSucceeded() bool { - return w.Status.DeploymentStatus.IsSucceeded() -} - -func (w KeptnWorkloadInstance) IsDeploymentFailed() bool { - return w.Status.DeploymentStatus.IsFailed() -} - -func (w *KeptnWorkloadInstance) SetStartTime() { - if w.Status.StartTime.IsZero() { - w.Status.StartTime = metav1.NewTime(time.Now().UTC()) - } -} - -func (w *KeptnWorkloadInstance) SetEndTime() { - if w.Status.EndTime.IsZero() { - w.Status.EndTime = metav1.NewTime(time.Now().UTC()) - } -} - -func (w *KeptnWorkloadInstance) IsStartTimeSet() bool { - return !w.Status.StartTime.IsZero() -} - -func (w *KeptnWorkloadInstance) IsEndTimeSet() bool { - return !w.Status.EndTime.IsZero() -} - -func (w KeptnWorkloadInstance) GetStartTime() time.Time { - return w.Status.StartTime.Time -} - -func (w KeptnWorkloadInstance) GetEndTime() time.Time { - return w.Status.EndTime.Time -} - -func (w *KeptnWorkloadInstance) Complete() { - w.SetEndTime() -} - -func (e *ItemStatus) SetStartTime() { - if e.StartTime.IsZero() { - e.StartTime = metav1.NewTime(time.Now().UTC()) - } -} - -func (e *ItemStatus) SetEndTime() { - if e.EndTime.IsZero() { - e.EndTime = metav1.NewTime(time.Now().UTC()) - } -} - -func (w KeptnWorkloadInstance) GetActiveMetricsAttributes() []attribute.KeyValue { - return []attribute.KeyValue{ - common.AppName.String(w.Spec.AppName), - common.WorkloadName.String(w.Spec.WorkloadName), - common.WorkloadVersion.String(w.Spec.Version), - common.WorkloadNamespace.String(w.Namespace), - } -} - -func (w KeptnWorkloadInstance) GetMetricsAttributes() []attribute.KeyValue { - return []attribute.KeyValue{ - common.AppName.String(w.Spec.AppName), - common.WorkloadName.String(w.Spec.WorkloadName), - common.WorkloadVersion.String(w.Spec.Version), - common.WorkloadNamespace.String(w.Namespace), - common.WorkloadStatus.String(string(w.Status.Status)), - } -} - -func (w KeptnWorkloadInstance) GetDurationMetricsAttributes() []attribute.KeyValue { - return []attribute.KeyValue{ - common.AppName.String(w.Spec.AppName), - common.WorkloadName.String(w.Spec.WorkloadName), - common.WorkloadVersion.String(w.Spec.Version), - common.WorkloadPreviousVersion.String(w.Spec.PreviousVersion), - } -} - -func (w KeptnWorkloadInstance) GetState() common.KeptnState { - return w.Status.Status -} - -func (w KeptnWorkloadInstance) GetPreDeploymentTasks() []string { - return w.Spec.PreDeploymentTasks -} - -func (w KeptnWorkloadInstance) GetPostDeploymentTasks() []string { - return w.Spec.PostDeploymentTasks -} - -func (w KeptnWorkloadInstance) GetPreDeploymentTaskStatus() []ItemStatus { - return w.Status.PreDeploymentTaskStatus -} - -func (w KeptnWorkloadInstance) GetPostDeploymentTaskStatus() []ItemStatus { - return w.Status.PostDeploymentTaskStatus -} - -func (w KeptnWorkloadInstance) GetPreDeploymentEvaluations() []string { - return w.Spec.PreDeploymentEvaluations -} - -func (w KeptnWorkloadInstance) GetPostDeploymentEvaluations() []string { - return w.Spec.PostDeploymentEvaluations -} - -func (w KeptnWorkloadInstance) GetPreDeploymentEvaluationTaskStatus() []ItemStatus { - return w.Status.PreDeploymentEvaluationTaskStatus -} - -func (w KeptnWorkloadInstance) GetPostDeploymentEvaluationTaskStatus() []ItemStatus { - return w.Status.PostDeploymentEvaluationTaskStatus -} - -func (w KeptnWorkloadInstance) GetAppName() string { - return w.Spec.AppName -} - -func (w KeptnWorkloadInstance) GetPreviousVersion() string { - return w.Spec.PreviousVersion -} - -func (w KeptnWorkloadInstance) GetParentName() string { - return w.Spec.WorkloadName -} - -func (w KeptnWorkloadInstance) GetNamespace() string { - return w.Namespace -} - -func (w *KeptnWorkloadInstance) SetState(state common.KeptnState) { - w.Status.Status = state -} - -func (w KeptnWorkloadInstance) GetCurrentPhase() string { - return w.Status.CurrentPhase -} - -func (w *KeptnWorkloadInstance) SetCurrentPhase(phase string) { - w.Status.CurrentPhase = phase -} - -func (w KeptnWorkloadInstance) GetVersion() string { - return w.Spec.Version -} - -func (w KeptnWorkloadInstance) GenerateTask(taskDefinition string, checkType common.CheckType) KeptnTask { - return KeptnTask{ - ObjectMeta: metav1.ObjectMeta{ - Name: common.GenerateTaskName(checkType, taskDefinition), - Namespace: w.Namespace, - }, - Spec: KeptnTaskSpec{ - AppName: w.GetAppName(), - WorkloadVersion: w.GetVersion(), - Workload: w.GetParentName(), - TaskDefinition: taskDefinition, - Parameters: TaskParameters{}, - SecureParameters: SecureParameters{}, - Type: checkType, - }, - } -} - -func (w KeptnWorkloadInstance) GenerateEvaluation(evaluationDefinition string, checkType common.CheckType) KeptnEvaluation { - return KeptnEvaluation{ - ObjectMeta: metav1.ObjectMeta{ - Name: common.GenerateEvaluationName(checkType, evaluationDefinition), - Namespace: w.Namespace, - }, - Spec: KeptnEvaluationSpec{ - AppName: w.GetAppName(), - WorkloadVersion: w.GetVersion(), - Workload: w.GetParentName(), - EvaluationDefinition: evaluationDefinition, - Type: checkType, - RetryInterval: metav1.Duration{ - Duration: 5 * time.Second, - }, - }, - } -} - -func (w KeptnWorkloadInstance) GetSpanAttributes() []attribute.KeyValue { - return []attribute.KeyValue{ - common.AppName.String(w.Spec.AppName), - common.WorkloadName.String(w.Spec.WorkloadName), - common.WorkloadVersion.String(w.Spec.Version), - common.WorkloadNamespace.String(w.Namespace), - } -} - -func (w KeptnWorkloadInstance) GetSpanKey(phase string) string { - return fmt.Sprintf("%s.%s.%s.%s", w.Spec.TraceId["traceparent"], w.Spec.WorkloadName, w.Spec.Version, phase) -} - -func (w KeptnWorkloadInstance) GetSpanName(phase string) string { - if phase == "" { - return w.Name - } - return fmt.Sprintf("%s/%s", w.Spec.WorkloadName, phase) -} - -func (w KeptnWorkloadInstance) SetSpanAttributes(span trace.Span) { - span.SetAttributes(w.GetSpanAttributes()...) -} - -//nolint:dupl -func (w *KeptnWorkloadInstance) DeprecateRemainingPhases(phase common.KeptnPhaseType) { - // no need to deprecate anything when post-eval tasks fail - if phase == common.PhaseWorkloadPostEvaluation { - return - } - // deprecate post evaluation when post tasks failed - if phase == common.PhaseWorkloadPostDeployment { - w.Status.PostDeploymentEvaluationStatus = common.StateDeprecated - } - // deprecate post evaluation and tasks when app deployment failed - if phase == common.PhaseWorkloadDeployment { - w.Status.PostDeploymentStatus = common.StateDeprecated - w.Status.PostDeploymentEvaluationStatus = common.StateDeprecated - } - // deprecate app deployment, post tasks and evaluations if app pre-eval failed - if phase == common.PhaseWorkloadPreEvaluation { - w.Status.PostDeploymentStatus = common.StateDeprecated - w.Status.PostDeploymentEvaluationStatus = common.StateDeprecated - w.Status.DeploymentStatus = common.StateDeprecated - } - // deprecate pre evaluations, app deployment and post tasks and evaluations when pre-tasks failed - if phase == common.PhaseWorkloadPreDeployment { - w.Status.PostDeploymentStatus = common.StateDeprecated - w.Status.PostDeploymentEvaluationStatus = common.StateDeprecated - w.Status.DeploymentStatus = common.StateDeprecated - w.Status.PreDeploymentEvaluationStatus = common.StateDeprecated - } - // deprecate completely everything - if phase == common.PhaseDeprecated { - w.Status.PostDeploymentStatus = common.StateDeprecated - w.Status.PostDeploymentEvaluationStatus = common.StateDeprecated - w.Status.DeploymentStatus = common.StateDeprecated - w.Status.PreDeploymentEvaluationStatus = common.StateDeprecated - w.Status.PreDeploymentStatus = common.StateDeprecated - w.Status.Status = common.StateDeprecated - return - } - - w.Status.Status = common.StateFailed -} - -func (w *KeptnWorkloadInstance) SetPhaseTraceID(phase string, carrier propagation.MapCarrier) { - if w.Status.PhaseTraceIDs == nil { - w.Status.PhaseTraceIDs = common.PhaseTraceID{} - } - w.Status.PhaseTraceIDs[common.GetShortPhaseName(phase)] = carrier -} - -func (w KeptnWorkloadInstance) GetEventAnnotations() map[string]string { - return map[string]string{ - "appName": w.Spec.AppName, - "workloadName": w.Spec.WorkloadName, - "workloadVersion": w.Spec.Version, - "workloadInstanceName": w.Name, - } -} diff --git a/lifecycle-operator/apis/lifecycle/v1alpha3/common/common.go b/lifecycle-operator/apis/lifecycle/v1alpha3/common/common.go index 801a517c39e..5167ff14fa3 100644 --- a/lifecycle-operator/apis/lifecycle/v1alpha3/common/common.go +++ b/lifecycle-operator/apis/lifecycle/v1alpha3/common/common.go @@ -3,6 +3,7 @@ package common import ( "crypto/sha256" "encoding/hex" + "errors" "math/rand" "strconv" @@ -39,6 +40,9 @@ const MaxK8sObjectLength = 253 type AppType string +var ErrCannotCastKeptnAppVersion = errors.New("cannot cast KeptnAppVersion to v1beta1") +var ErrCannotCastKeptnApp = errors.New("cannot cast KeptnApp to v1beta1") + const ( AppTypeSingleService AppType = "single-service" AppTypeMultiService AppType = "multi-service" diff --git a/lifecycle-operator/apis/lifecycle/v1alpha3/keptnapp_conversion.go b/lifecycle-operator/apis/lifecycle/v1alpha3/keptnapp_conversion.go index d637cdaff76..f13d7919786 100644 --- a/lifecycle-operator/apis/lifecycle/v1alpha3/keptnapp_conversion.go +++ b/lifecycle-operator/apis/lifecycle/v1alpha3/keptnapp_conversion.go @@ -1,6 +1,71 @@ package v1alpha3 -// 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" + + "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) +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.Spec.PreDeploymentTasks = src.Spec.PreDeploymentTasks + dst.Spec.PostDeploymentTasks = src.Spec.PostDeploymentTasks + dst.Spec.PreDeploymentEvaluations = src.Spec.PreDeploymentEvaluations + dst.Spec.PostDeploymentEvaluations = src.Spec.PostDeploymentEvaluations + + 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 (v1alpha3.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.Spec.PreDeploymentTasks = src.Spec.PreDeploymentTasks + dst.Spec.PostDeploymentTasks = src.Spec.PostDeploymentTasks + dst.Spec.PreDeploymentEvaluations = src.Spec.PreDeploymentEvaluations + dst.Spec.PostDeploymentEvaluations = src.Spec.PostDeploymentEvaluations + + dst.Status.CurrentVersion = src.Status.CurrentVersion + + dst.Spec.Revision = src.Spec.Revision + + return nil } diff --git a/lifecycle-operator/apis/lifecycle/v1beta1/keptnapp_conversion_test.go b/lifecycle-operator/apis/lifecycle/v1alpha3/keptnapp_conversion_test.go similarity index 91% rename from lifecycle-operator/apis/lifecycle/v1beta1/keptnapp_conversion_test.go rename to lifecycle-operator/apis/lifecycle/v1alpha3/keptnapp_conversion_test.go index e1ab29d828c..8c471ce5419 100644 --- a/lifecycle-operator/apis/lifecycle/v1beta1/keptnapp_conversion_test.go +++ b/lifecycle-operator/apis/lifecycle/v1alpha3/keptnapp_conversion_test.go @@ -1,10 +1,10 @@ -package v1beta1 +package v1alpha3 import ( "testing" - "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3" - "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" + "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" v2 "sigs.k8s.io/controller-runtime/pkg/webhook/conversion/testdata/api/v2" @@ -13,16 +13,16 @@ import ( func TestKeptnApp_ConvertFrom(t *testing.T) { tests := []struct { name string - srcObj *v1alpha3.KeptnApp + srcObj *v1beta1.KeptnApp wantErr bool wantObj *KeptnApp }{ { - name: "Test that conversion from v1alpha3 to v1beta1 works", - srcObj: &v1alpha3.KeptnApp{ + name: "Test that conversion from v1beta1 to v1alpha3 works", + srcObj: &v1beta1.KeptnApp{ TypeMeta: v1.TypeMeta{ Kind: "KeptnApp", - APIVersion: "lifecycle.keptn.sh/v1alpha3", + APIVersion: "lifecycle.keptn.sh/v1beta1", }, ObjectMeta: v1.ObjectMeta{ Name: "some-keptn-app-name", @@ -34,10 +34,10 @@ func TestKeptnApp_ConvertFrom(t *testing.T) { "some-annotation": "some-annotation-value", }, }, - Spec: v1alpha3.KeptnAppSpec{ + Spec: v1beta1.KeptnAppSpec{ Version: "1.2.3", Revision: 1, - Workloads: []v1alpha3.KeptnWorkloadRef{ + Workloads: []v1beta1.KeptnWorkloadRef{ { Name: "workload-1", Version: "1.2.3", @@ -60,7 +60,7 @@ func TestKeptnApp_ConvertFrom(t *testing.T) { "some-pre-evaluation-task2", }, }, - Status: v1alpha3.KeptnAppStatus{ + Status: v1beta1.KeptnAppStatus{ CurrentVersion: "1.2.3", }, }, @@ -131,10 +131,10 @@ func TestKeptnApp_ConvertTo(t *testing.T) { name string src *KeptnApp wantErr bool - wantObj *v1alpha3.KeptnApp + wantObj *v1beta1.KeptnApp }{ { - name: "Test that conversion from v1beta1 to v1alpha3 works", + name: "Test that conversion from v1alpha3 to v1beta1 works", src: &KeptnApp{ TypeMeta: v1.TypeMeta{ Kind: "KeptnApp", @@ -181,7 +181,7 @@ func TestKeptnApp_ConvertTo(t *testing.T) { }, }, wantErr: false, - wantObj: &v1alpha3.KeptnApp{ + wantObj: &v1beta1.KeptnApp{ ObjectMeta: v1.ObjectMeta{ Name: "some-keptn-app-name", Namespace: "", @@ -192,10 +192,10 @@ func TestKeptnApp_ConvertTo(t *testing.T) { "some-annotation": "some-annotation-value", }, }, - Spec: v1alpha3.KeptnAppSpec{ + Spec: v1beta1.KeptnAppSpec{ Version: "1.2.3", Revision: 1, - Workloads: []v1alpha3.KeptnWorkloadRef{ + Workloads: []v1beta1.KeptnWorkloadRef{ { Name: "workload-1", Version: "1.2.3", @@ -218,7 +218,7 @@ func TestKeptnApp_ConvertTo(t *testing.T) { "some-pre-evaluation-task2", }, }, - Status: v1alpha3.KeptnAppStatus{ + Status: v1beta1.KeptnAppStatus{ CurrentVersion: "1.2.3", }, }, @@ -226,11 +226,11 @@ func TestKeptnApp_ConvertTo(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - dst := v1alpha3.KeptnApp{ + dst := v1beta1.KeptnApp{ TypeMeta: v1.TypeMeta{}, ObjectMeta: v1.ObjectMeta{}, - Spec: v1alpha3.KeptnAppSpec{}, - Status: v1alpha3.KeptnAppStatus{}, + Spec: v1beta1.KeptnAppSpec{}, + Status: v1beta1.KeptnAppStatus{}, } if err := tt.src.ConvertTo(&dst); (err != nil) != tt.wantErr { t.Errorf("ConvertTo() error = %v, wantErr %v", err, tt.wantErr) diff --git a/lifecycle-operator/apis/lifecycle/v1alpha3/keptnapp_types.go b/lifecycle-operator/apis/lifecycle/v1alpha3/keptnapp_types.go index 90ce4ffdf0b..490c2d413e8 100644 --- a/lifecycle-operator/apis/lifecycle/v1alpha3/keptnapp_types.go +++ b/lifecycle-operator/apis/lifecycle/v1alpha3/keptnapp_types.go @@ -81,7 +81,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/v1alpha3/keptnappcreationrequest_types.go b/lifecycle-operator/apis/lifecycle/v1alpha3/keptnappcreationrequest_types.go index 42514716f66..61ffd26d89a 100644 --- a/lifecycle-operator/apis/lifecycle/v1alpha3/keptnappcreationrequest_types.go +++ b/lifecycle-operator/apis/lifecycle/v1alpha3/keptnappcreationrequest_types.go @@ -34,7 +34,6 @@ type KeptnAppCreationRequestSpec struct { // +kubebuilder:object:root=true // +kubebuilder:subresource:status -// +kubebuilder:storageversion // KeptnAppCreationRequest is the Schema for the keptnappcreationrequests API type KeptnAppCreationRequest struct { diff --git a/lifecycle-operator/apis/lifecycle/v1alpha3/keptnappversion_conversion.go b/lifecycle-operator/apis/lifecycle/v1alpha3/keptnappversion_conversion.go index 3d72ef34401..b45079e201b 100644 --- a/lifecycle-operator/apis/lifecycle/v1alpha3/keptnappversion_conversion.go +++ b/lifecycle-operator/apis/lifecycle/v1alpha3/keptnappversion_conversion.go @@ -1,6 +1,235 @@ package v1alpha3 -// 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" + + "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) +// +//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.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.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, + }) + } + + 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 (v1alpha3.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.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.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, + }) + } + + 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/v1beta1/keptnappversion_conversion_test.go b/lifecycle-operator/apis/lifecycle/v1alpha3/keptnappversion_conversion_test.go similarity index 80% rename from lifecycle-operator/apis/lifecycle/v1beta1/keptnappversion_conversion_test.go rename to lifecycle-operator/apis/lifecycle/v1alpha3/keptnappversion_conversion_test.go index 91921458d3d..f94bcc10267 100644 --- a/lifecycle-operator/apis/lifecycle/v1beta1/keptnappversion_conversion_test.go +++ b/lifecycle-operator/apis/lifecycle/v1alpha3/keptnappversion_conversion_test.go @@ -1,12 +1,12 @@ //nolint:dupl -package v1beta1 +package v1alpha3 import ( "testing" - "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3" - v1alpha3common "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3/common" - "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/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" @@ -16,13 +16,13 @@ import ( func TestKeptnAppVersion_ConvertFrom(t *testing.T) { tests := []struct { name string - srcObj *v1alpha3.KeptnAppVersion + srcObj *v1beta1.KeptnAppVersion wantErr bool wantObj *KeptnAppVersion }{ { name: "Test that conversion from v1beta1 to v1alpha3 works", - srcObj: &v1alpha3.KeptnAppVersion{ + srcObj: &v1beta1.KeptnAppVersion{ TypeMeta: v1.TypeMeta{ Kind: "KeptnAppVersion", APIVersion: "lifecycle.keptn.sh/v1beta1", @@ -37,11 +37,11 @@ func TestKeptnAppVersion_ConvertFrom(t *testing.T) { "some-annotation": "some-annotation-value", }, }, - Spec: v1alpha3.KeptnAppVersionSpec{ - KeptnAppSpec: v1alpha3.KeptnAppSpec{ + Spec: v1beta1.KeptnAppVersionSpec{ + KeptnAppSpec: v1beta1.KeptnAppSpec{ Version: "1.2.3", Revision: 1, - Workloads: []v1alpha3.KeptnWorkloadRef{ + Workloads: []v1beta1.KeptnWorkloadRef{ { Name: "workload-1", Version: "1.2.3", @@ -71,78 +71,78 @@ func TestKeptnAppVersion_ConvertFrom(t *testing.T) { "key2": "value2", }, }, - Status: v1alpha3.KeptnAppVersionStatus{ - PreDeploymentStatus: v1alpha3common.StateFailed, - PostDeploymentStatus: v1alpha3common.StateFailed, - PreDeploymentEvaluationStatus: v1alpha3common.StateFailed, - PostDeploymentEvaluationStatus: v1alpha3common.StateFailed, - WorkloadOverallStatus: v1alpha3common.StateFailed, - WorkloadStatus: []v1alpha3.WorkloadStatus{ - { - Workload: v1alpha3.KeptnWorkloadRef{ + Status: v1beta1.KeptnAppVersionStatus{ + PreDeploymentStatus: v1beta1common.StateFailed, + PostDeploymentStatus: v1beta1common.StateFailed, + PreDeploymentEvaluationStatus: v1beta1common.StateFailed, + PostDeploymentEvaluationStatus: v1beta1common.StateFailed, + WorkloadOverallStatus: v1beta1common.StateFailed, + WorkloadStatus: []v1beta1.WorkloadStatus{ + { + Workload: v1beta1.KeptnWorkloadRef{ Name: "name1", Version: "1", }, - Status: v1alpha3common.StateFailed, + Status: v1beta1common.StateFailed, }, { - Workload: v1alpha3.KeptnWorkloadRef{ + Workload: v1beta1.KeptnWorkloadRef{ Name: "name2", Version: "2", }, - Status: v1alpha3common.StateFailed, + Status: v1beta1common.StateFailed, }, }, CurrentPhase: "phase", - PreDeploymentTaskStatus: []v1alpha3.ItemStatus{ + PreDeploymentTaskStatus: []v1beta1.ItemStatus{ { DefinitionName: "def1", Name: "name1", - Status: v1alpha3common.StateFailed, + Status: v1beta1common.StateFailed, }, { DefinitionName: "def12", Name: "name12", - Status: v1alpha3common.StateFailed, + Status: v1beta1common.StateFailed, }, }, - PostDeploymentTaskStatus: []v1alpha3.ItemStatus{ + PostDeploymentTaskStatus: []v1beta1.ItemStatus{ { DefinitionName: "def2", Name: "name2", - Status: v1alpha3common.StateFailed, + Status: v1beta1common.StateFailed, }, { DefinitionName: "def22", Name: "name22", - Status: v1alpha3common.StateFailed, + Status: v1beta1common.StateFailed, }, }, - PreDeploymentEvaluationTaskStatus: []v1alpha3.ItemStatus{ + PreDeploymentEvaluationTaskStatus: []v1beta1.ItemStatus{ { DefinitionName: "def3", Name: "name3", - Status: v1alpha3common.StateFailed, + Status: v1beta1common.StateFailed, }, { DefinitionName: "def32", Name: "name32", - Status: v1alpha3common.StateFailed, + Status: v1beta1common.StateFailed, }, }, - PostDeploymentEvaluationTaskStatus: []v1alpha3.ItemStatus{ + PostDeploymentEvaluationTaskStatus: []v1beta1.ItemStatus{ { DefinitionName: "def4", Name: "name4", - Status: v1alpha3common.StateFailed, + Status: v1beta1common.StateFailed, }, { DefinitionName: "def42", Name: "name42", - Status: v1alpha3common.StateFailed, + Status: v1beta1common.StateFailed, }, }, - PhaseTraceIDs: v1alpha3common.PhaseTraceID{ + PhaseTraceIDs: v1beta1common.PhaseTraceID{ "key": propagation.MapCarrier{ "key1": "value1", "key2": "value2", @@ -152,7 +152,7 @@ func TestKeptnAppVersion_ConvertFrom(t *testing.T) { "key222": "value222", }, }, - Status: v1alpha3common.StateFailed, + Status: v1beta1common.StateFailed, }, }, wantErr: false, @@ -310,7 +310,7 @@ func TestKeptnAppVersion_ConvertTo(t *testing.T) { name string src *KeptnAppVersion wantErr bool - wantObj *v1alpha3.KeptnAppVersion + wantObj *v1beta1.KeptnAppVersion }{ { name: "Test that conversion from v1beta1 to v1alpha3 works", @@ -448,7 +448,7 @@ func TestKeptnAppVersion_ConvertTo(t *testing.T) { }, }, wantErr: false, - wantObj: &v1alpha3.KeptnAppVersion{ + wantObj: &v1beta1.KeptnAppVersion{ ObjectMeta: v1.ObjectMeta{ Name: "some-keptn-app-name", Namespace: "", @@ -459,11 +459,11 @@ func TestKeptnAppVersion_ConvertTo(t *testing.T) { "some-annotation": "some-annotation-value", }, }, - Spec: v1alpha3.KeptnAppVersionSpec{ - KeptnAppSpec: v1alpha3.KeptnAppSpec{ + Spec: v1beta1.KeptnAppVersionSpec{ + KeptnAppSpec: v1beta1.KeptnAppSpec{ Version: "1.2.3", Revision: 1, - Workloads: []v1alpha3.KeptnWorkloadRef{ + Workloads: []v1beta1.KeptnWorkloadRef{ { Name: "workload-1", Version: "1.2.3", @@ -493,78 +493,78 @@ func TestKeptnAppVersion_ConvertTo(t *testing.T) { "key2": "value2", }, }, - Status: v1alpha3.KeptnAppVersionStatus{ - PreDeploymentStatus: v1alpha3common.StateFailed, - PostDeploymentStatus: v1alpha3common.StateFailed, - PreDeploymentEvaluationStatus: v1alpha3common.StateFailed, - PostDeploymentEvaluationStatus: v1alpha3common.StateFailed, - WorkloadOverallStatus: v1alpha3common.StateFailed, - WorkloadStatus: []v1alpha3.WorkloadStatus{ - { - Workload: v1alpha3.KeptnWorkloadRef{ + Status: v1beta1.KeptnAppVersionStatus{ + PreDeploymentStatus: v1beta1common.StateFailed, + PostDeploymentStatus: v1beta1common.StateFailed, + PreDeploymentEvaluationStatus: v1beta1common.StateFailed, + PostDeploymentEvaluationStatus: v1beta1common.StateFailed, + WorkloadOverallStatus: v1beta1common.StateFailed, + WorkloadStatus: []v1beta1.WorkloadStatus{ + { + Workload: v1beta1.KeptnWorkloadRef{ Name: "name1", Version: "1", }, - Status: v1alpha3common.StateFailed, + Status: v1beta1common.StateFailed, }, { - Workload: v1alpha3.KeptnWorkloadRef{ + Workload: v1beta1.KeptnWorkloadRef{ Name: "name2", Version: "2", }, - Status: v1alpha3common.StateFailed, + Status: v1beta1common.StateFailed, }, }, CurrentPhase: "phase", - PreDeploymentTaskStatus: []v1alpha3.ItemStatus{ + PreDeploymentTaskStatus: []v1beta1.ItemStatus{ { DefinitionName: "def1", Name: "name1", - Status: v1alpha3common.StateFailed, + Status: v1beta1common.StateFailed, }, { DefinitionName: "def12", Name: "name12", - Status: v1alpha3common.StateFailed, + Status: v1beta1common.StateFailed, }, }, - PostDeploymentTaskStatus: []v1alpha3.ItemStatus{ + PostDeploymentTaskStatus: []v1beta1.ItemStatus{ { DefinitionName: "def2", Name: "name2", - Status: v1alpha3common.StateFailed, + Status: v1beta1common.StateFailed, }, { DefinitionName: "def22", Name: "name22", - Status: v1alpha3common.StateFailed, + Status: v1beta1common.StateFailed, }, }, - PreDeploymentEvaluationTaskStatus: []v1alpha3.ItemStatus{ + PreDeploymentEvaluationTaskStatus: []v1beta1.ItemStatus{ { DefinitionName: "def3", Name: "name3", - Status: v1alpha3common.StateFailed, + Status: v1beta1common.StateFailed, }, { DefinitionName: "def32", Name: "name32", - Status: v1alpha3common.StateFailed, + Status: v1beta1common.StateFailed, }, }, - PostDeploymentEvaluationTaskStatus: []v1alpha3.ItemStatus{ + PostDeploymentEvaluationTaskStatus: []v1beta1.ItemStatus{ { DefinitionName: "def4", Name: "name4", - Status: v1alpha3common.StateFailed, + Status: v1beta1common.StateFailed, }, { DefinitionName: "def42", Name: "name42", - Status: v1alpha3common.StateFailed, + Status: v1beta1common.StateFailed, }, }, - PhaseTraceIDs: v1alpha3common.PhaseTraceID{ + PhaseTraceIDs: v1beta1common.PhaseTraceID{ "key": propagation.MapCarrier{ "key1": "value1", "key2": "value2", @@ -574,18 +574,18 @@ func TestKeptnAppVersion_ConvertTo(t *testing.T) { "key222": "value222", }, }, - Status: v1alpha3common.StateFailed, + Status: v1beta1common.StateFailed, }, }, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - dst := v1alpha3.KeptnAppVersion{ + dst := v1beta1.KeptnAppVersion{ TypeMeta: v1.TypeMeta{}, ObjectMeta: v1.ObjectMeta{}, - Spec: v1alpha3.KeptnAppVersionSpec{}, - Status: v1alpha3.KeptnAppVersionStatus{}, + Spec: v1beta1.KeptnAppVersionSpec{}, + Status: v1beta1.KeptnAppVersionStatus{}, } if err := tt.src.ConvertTo(&dst); (err != nil) != tt.wantErr { t.Errorf("ConvertTo() error = %v, wantErr %v", err, tt.wantErr) diff --git a/lifecycle-operator/apis/lifecycle/v1alpha3/keptnappversion_types.go b/lifecycle-operator/apis/lifecycle/v1alpha3/keptnappversion_types.go index cf830da7904..c8dd39bddf2 100644 --- a/lifecycle-operator/apis/lifecycle/v1alpha3/keptnappversion_types.go +++ b/lifecycle-operator/apis/lifecycle/v1alpha3/keptnappversion_types.go @@ -111,7 +111,6 @@ 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/v1alpha3/keptnevaluation_types.go b/lifecycle-operator/apis/lifecycle/v1alpha3/keptnevaluation_types.go index 14b292d32e0..088a5fc7ebc 100644 --- a/lifecycle-operator/apis/lifecycle/v1alpha3/keptnevaluation_types.go +++ b/lifecycle-operator/apis/lifecycle/v1alpha3/keptnevaluation_types.go @@ -103,7 +103,6 @@ type EvaluationStatusItem struct { // +kubebuilder:object:root=true // +kubebuilder:subresource:status -// +kubebuilder:storageversion // +kubebuilder:resource:path=keptnevaluations,shortName=ke // +kubebuilder:printcolumn:name="AppName",type=string,JSONPath=`.spec.appName` // +kubebuilder:printcolumn:name="AppVersion",type=string,JSONPath=`.spec.appVersion` diff --git a/lifecycle-operator/apis/lifecycle/v1alpha3/keptnevaluationdefinition_types.go b/lifecycle-operator/apis/lifecycle/v1alpha3/keptnevaluationdefinition_types.go index 93ff92fdaca..6bef5689745 100644 --- a/lifecycle-operator/apis/lifecycle/v1alpha3/keptnevaluationdefinition_types.go +++ b/lifecycle-operator/apis/lifecycle/v1alpha3/keptnevaluationdefinition_types.go @@ -48,7 +48,6 @@ type KeptnMetricReference struct { // +kubebuilder:object:root=true // +kubebuilder:subresource:status -// +kubebuilder:storageversion // +kubebuilder:resource:path=keptnevaluationdefinitions,shortName=ked // KeptnEvaluationDefinition is the Schema for the keptnevaluationdefinitions API diff --git a/lifecycle-operator/apis/lifecycle/v1alpha3/keptnevaluationprovider_conversion.go b/lifecycle-operator/apis/lifecycle/v1alpha3/keptnevaluationprovider_conversion.go deleted file mode 100644 index 684ab094d56..00000000000 --- a/lifecycle-operator/apis/lifecycle/v1alpha3/keptnevaluationprovider_conversion.go +++ /dev/null @@ -1,6 +0,0 @@ -package v1alpha3 - -// Hub is the stub function to make the API conversion pattern with hub and spokes complete -func (*KeptnEvaluationProvider) Hub() { - // Hub() needed to implement interface -} diff --git a/lifecycle-operator/apis/lifecycle/v1alpha3/keptnevaluationprovider_webhook.go b/lifecycle-operator/apis/lifecycle/v1alpha3/keptnevaluationprovider_webhook.go deleted file mode 100644 index f8e24a0dbd6..00000000000 --- a/lifecycle-operator/apis/lifecycle/v1alpha3/keptnevaluationprovider_webhook.go +++ /dev/null @@ -1,11 +0,0 @@ -package v1alpha3 - -import ( - ctrl "sigs.k8s.io/controller-runtime" -) - -func (r *KeptnEvaluationProvider) SetupWebhookWithManager(mgr ctrl.Manager) error { - return ctrl.NewWebhookManagedBy(mgr). - For(r). - Complete() -} diff --git a/lifecycle-operator/apis/lifecycle/v1alpha3/keptntask_conversion.go b/lifecycle-operator/apis/lifecycle/v1alpha3/keptntask_conversion.go deleted file mode 100644 index 9f3ce38f4d5..00000000000 --- a/lifecycle-operator/apis/lifecycle/v1alpha3/keptntask_conversion.go +++ /dev/null @@ -1,6 +0,0 @@ -package v1alpha3 - -// Hub is the stub function to make the API conversion pattern with hub and spokes complete -func (kt *KeptnTask) Hub() { - // Hub() needed to implement interface -} diff --git a/lifecycle-operator/apis/lifecycle/v1alpha3/keptntask_types.go b/lifecycle-operator/apis/lifecycle/v1alpha3/keptntask_types.go index c12701487ef..7c159529017 100644 --- a/lifecycle-operator/apis/lifecycle/v1alpha3/keptntask_types.go +++ b/lifecycle-operator/apis/lifecycle/v1alpha3/keptntask_types.go @@ -130,7 +130,6 @@ type KeptnTaskStatus struct { // +kubebuilder:object:root=true // +kubebuilder:subresource:status -// +kubebuilder:storageversion // +kubebuilder:printcolumn:name="AppName",type=string,JSONPath=`.spec.app` // +kubebuilder:printcolumn:name="AppVersion",type=string,JSONPath=`.spec.appVersion` // +kubebuilder:printcolumn:name="WorkloadName",type=string,JSONPath=`.spec.workload` diff --git a/lifecycle-operator/apis/lifecycle/v1alpha3/keptntaskdefinition_types.go b/lifecycle-operator/apis/lifecycle/v1alpha3/keptntaskdefinition_types.go index 24f7c16f399..199284ffbbb 100644 --- a/lifecycle-operator/apis/lifecycle/v1alpha3/keptntaskdefinition_types.go +++ b/lifecycle-operator/apis/lifecycle/v1alpha3/keptntaskdefinition_types.go @@ -152,7 +152,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/v1alpha3/keptnworkload_types.go b/lifecycle-operator/apis/lifecycle/v1alpha3/keptnworkload_types.go index 7efe481e689..9b96d0e6cd9 100644 --- a/lifecycle-operator/apis/lifecycle/v1alpha3/keptnworkload_types.go +++ b/lifecycle-operator/apis/lifecycle/v1alpha3/keptnworkload_types.go @@ -72,7 +72,6 @@ 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/v1alpha3/keptnworkloadinstance_conversion.go b/lifecycle-operator/apis/lifecycle/v1alpha3/keptnworkloadinstance_conversion.go deleted file mode 100644 index d92ffaa43c6..00000000000 --- a/lifecycle-operator/apis/lifecycle/v1alpha3/keptnworkloadinstance_conversion.go +++ /dev/null @@ -1,6 +0,0 @@ -package v1alpha3 - -// Hub is the stub function to make the API conversion pattern with hub and spokes complete -func (*KeptnWorkloadInstance) Hub() { - // Hub() needed to implement interface -} diff --git a/lifecycle-operator/apis/lifecycle/v1alpha3/keptnworkloadinstance_test.go b/lifecycle-operator/apis/lifecycle/v1alpha3/keptnworkloadinstance_test.go deleted file mode 100644 index 8781e7da268..00000000000 --- a/lifecycle-operator/apis/lifecycle/v1alpha3/keptnworkloadinstance_test.go +++ /dev/null @@ -1,447 +0,0 @@ -package v1alpha3 - -import ( - "testing" - "time" - - "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3/common" - "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 TestKeptnWorkloadInstance(t *testing.T) { - workload := &KeptnWorkloadInstance{ - ObjectMeta: metav1.ObjectMeta{ - Name: "workload", - Namespace: "namespace", - }, - Status: KeptnWorkloadInstanceStatus{ - PreDeploymentStatus: common.StateFailed, - PreDeploymentEvaluationStatus: common.StateFailed, - PostDeploymentStatus: common.StateFailed, - PostDeploymentEvaluationStatus: common.StateFailed, - DeploymentStatus: common.StateFailed, - Status: common.StateFailed, - PreDeploymentTaskStatus: []ItemStatus{ - { - DefinitionName: "defname", - Status: common.StateFailed, - Name: "taskname", - }, - }, - PostDeploymentTaskStatus: []ItemStatus{ - { - DefinitionName: "defname2", - Status: common.StateFailed, - Name: "taskname2", - }, - }, - PreDeploymentEvaluationTaskStatus: []ItemStatus{ - { - DefinitionName: "defname3", - Status: common.StateFailed, - Name: "taskname3", - }, - }, - PostDeploymentEvaluationTaskStatus: []ItemStatus{ - { - DefinitionName: "defname4", - Status: common.StateFailed, - Name: "taskname4", - }, - }, - CurrentPhase: common.PhaseAppDeployment.ShortName, - }, - Spec: KeptnWorkloadInstanceSpec{ - KeptnWorkloadSpec: KeptnWorkloadSpec{ - PreDeploymentTasks: []string{"task1", "task2"}, - PostDeploymentTasks: []string{"task3", "task4"}, - PreDeploymentEvaluations: []string{"task5", "task6"}, - PostDeploymentEvaluations: []string{"task7", "task8"}, - Version: "version", - AppName: "appname", - }, - PreviousVersion: "prev", - WorkloadName: "workloadname", - TraceId: map[string]string{"traceparent": "trace1"}, - }, - } - - require.True(t, workload.IsPreDeploymentCompleted()) - require.False(t, workload.IsPreDeploymentSucceeded()) - require.True(t, workload.IsPreDeploymentFailed()) - - require.True(t, workload.IsPreDeploymentEvaluationCompleted()) - require.False(t, workload.IsPreDeploymentEvaluationSucceeded()) - require.True(t, workload.IsPreDeploymentEvaluationFailed()) - - require.True(t, workload.IsPostDeploymentCompleted()) - require.False(t, workload.IsPostDeploymentSucceeded()) - require.True(t, workload.IsPostDeploymentFailed()) - - require.True(t, workload.IsPostDeploymentEvaluationCompleted()) - require.False(t, workload.IsPostDeploymentEvaluationSucceeded()) - require.True(t, workload.IsPostDeploymentEvaluationFailed()) - - require.True(t, workload.IsDeploymentCompleted()) - require.False(t, workload.IsDeploymentSucceeded()) - require.True(t, workload.IsDeploymentFailed()) - - require.False(t, workload.IsEndTimeSet()) - require.False(t, workload.IsStartTimeSet()) - - workload.SetStartTime() - workload.SetEndTime() - - require.True(t, workload.IsEndTimeSet()) - require.True(t, workload.IsStartTimeSet()) - - require.Equal(t, []attribute.KeyValue{ - common.AppName.String("appname"), - common.WorkloadName.String("workloadname"), - common.WorkloadVersion.String("version"), - common.WorkloadNamespace.String("namespace"), - }, workload.GetActiveMetricsAttributes()) - - require.Equal(t, []attribute.KeyValue{ - common.AppName.String("appname"), - common.WorkloadName.String("workloadname"), - common.WorkloadVersion.String("version"), - common.WorkloadNamespace.String("namespace"), - common.WorkloadStatus.String(string(common.StateFailed)), - }, workload.GetMetricsAttributes()) - - require.Equal(t, []attribute.KeyValue{ - common.AppName.String("appname"), - common.WorkloadName.String("workloadname"), - common.WorkloadVersion.String("version"), - common.WorkloadPreviousVersion.String("prev"), - }, workload.GetDurationMetricsAttributes()) - - require.Equal(t, common.StateFailed, workload.GetState()) - - require.Equal(t, []string{"task1", "task2"}, workload.GetPreDeploymentTasks()) - require.Equal(t, []string{"task3", "task4"}, workload.GetPostDeploymentTasks()) - require.Equal(t, []string{"task5", "task6"}, workload.GetPreDeploymentEvaluations()) - require.Equal(t, []string{"task7", "task8"}, workload.GetPostDeploymentEvaluations()) - - require.Equal(t, []ItemStatus{ - { - DefinitionName: "defname", - Status: common.StateFailed, - Name: "taskname", - }, - }, workload.GetPreDeploymentTaskStatus()) - - require.Equal(t, []ItemStatus{ - { - DefinitionName: "defname2", - Status: common.StateFailed, - Name: "taskname2", - }, - }, workload.GetPostDeploymentTaskStatus()) - - require.Equal(t, []ItemStatus{ - { - DefinitionName: "defname3", - Status: common.StateFailed, - Name: "taskname3", - }, - }, workload.GetPreDeploymentEvaluationTaskStatus()) - - require.Equal(t, []ItemStatus{ - { - DefinitionName: "defname4", - Status: common.StateFailed, - Name: "taskname4", - }, - }, workload.GetPostDeploymentEvaluationTaskStatus()) - - require.Equal(t, "appname", workload.GetAppName()) - require.Equal(t, "prev", workload.GetPreviousVersion()) - require.Equal(t, "workloadname", workload.GetParentName()) - require.Equal(t, "namespace", workload.GetNamespace()) - - workload.SetState(common.StatePending) - require.Equal(t, common.StatePending, workload.GetState()) - - require.True(t, !workload.GetStartTime().IsZero()) - require.True(t, !workload.GetEndTime().IsZero()) - - workload.SetCurrentPhase(common.PhaseAppDeployment.LongName) - require.Equal(t, common.PhaseAppDeployment.LongName, workload.GetCurrentPhase()) - - workload.Status.EndTime = v1.Time{Time: time.Time{}} - workload.Complete() - require.True(t, !workload.GetEndTime().IsZero()) - - require.Equal(t, "version", workload.GetVersion()) - - require.Equal(t, "trace1.workloadname.version.phase", workload.GetSpanKey("phase")) - - retries := int32(5) - task := workload.GenerateTask(KeptnTaskDefinition{ - ObjectMeta: v1.ObjectMeta{ - Name: "task-def", - Labels: map[string]string{ - "label1": "label2", - }, - Annotations: map[string]string{ - "annotation1": "annotation2", - }, - }, - Spec: KeptnTaskDefinitionSpec{ - Timeout: v1.Duration{ - Duration: 5 * time.Second, - }, - Retries: &retries, - }, - }, common.PostDeploymentCheckType) - require.Equal(t, KeptnTaskSpec{ - Context: TaskContext{ - AppName: workload.GetAppName(), - WorkloadVersion: workload.GetVersion(), - WorkloadName: workload.GetParentName(), - TaskType: string(common.PostDeploymentCheckType), - ObjectType: "Workload", - }, - TaskDefinition: "task-def", - Parameters: TaskParameters{}, - SecureParameters: SecureParameters{}, - Type: common.PostDeploymentCheckType, - Timeout: v1.Duration{ - Duration: 5 * time.Second, - }, - Retries: &retries, - }, task.Spec) - - require.Equal(t, map[string]string{ - "label1": "label2", - }, task.Labels) - - require.Equal(t, map[string]string{ - "annotation1": "annotation2", - }, task.Annotations) - - evaluation := workload.GenerateEvaluation(KeptnEvaluationDefinition{ - ObjectMeta: v1.ObjectMeta{ - Name: "eval-def", - }, - }, common.PostDeploymentCheckType) - require.Equal(t, KeptnEvaluationSpec{ - AppName: workload.GetAppName(), - WorkloadVersion: workload.GetVersion(), - Workload: workload.GetParentName(), - EvaluationDefinition: "eval-def", - Type: common.PostDeploymentCheckType, - RetryInterval: metav1.Duration{ - Duration: 5 * time.Second, - }, - }, evaluation.Spec) - - require.Equal(t, "workload", workload.GetSpanName("")) - - require.Equal(t, "workloadname/phase", workload.GetSpanName("phase")) - - require.Equal(t, []attribute.KeyValue{ - common.AppName.String("appname"), - common.WorkloadName.String("workloadname"), - common.WorkloadVersion.String("version"), - common.WorkloadNamespace.String("namespace"), - }, workload.GetSpanAttributes()) - - require.Equal(t, map[string]string{ - "appName": "appname", - "workloadName": "workloadname", - "workloadVersion": "version", - "workloadInstanceName": "workload", - }, workload.GetEventAnnotations()) -} - -//nolint:dupl -func TestKeptnWorkloadInstance_DeprecateRemainingPhases(t *testing.T) { - workloadInstance := KeptnWorkloadInstance{ - Status: KeptnWorkloadInstanceStatus{ - PreDeploymentStatus: common.StatePending, - PreDeploymentEvaluationStatus: common.StatePending, - PostDeploymentStatus: common.StatePending, - PostDeploymentEvaluationStatus: common.StatePending, - DeploymentStatus: common.StatePending, - Status: common.StatePending, - }, - } - - tests := []struct { - workloadInstance KeptnWorkloadInstance - phase common.KeptnPhaseType - want KeptnWorkloadInstance - }{ - { - workloadInstance: workloadInstance, - phase: common.PhaseWorkloadPostEvaluation, - want: KeptnWorkloadInstance{ - Status: KeptnWorkloadInstanceStatus{ - PreDeploymentStatus: common.StatePending, - PreDeploymentEvaluationStatus: common.StatePending, - PostDeploymentStatus: common.StatePending, - PostDeploymentEvaluationStatus: common.StatePending, - DeploymentStatus: common.StatePending, - Status: common.StatePending, - }, - }, - }, - { - workloadInstance: workloadInstance, - phase: common.PhaseWorkloadPostDeployment, - want: KeptnWorkloadInstance{ - Status: KeptnWorkloadInstanceStatus{ - PreDeploymentStatus: common.StatePending, - PreDeploymentEvaluationStatus: common.StatePending, - PostDeploymentStatus: common.StatePending, - PostDeploymentEvaluationStatus: common.StateDeprecated, - DeploymentStatus: common.StatePending, - Status: common.StateFailed, - }, - }, - }, - { - workloadInstance: workloadInstance, - phase: common.PhaseWorkloadDeployment, - want: KeptnWorkloadInstance{ - Status: KeptnWorkloadInstanceStatus{ - PreDeploymentStatus: common.StatePending, - PreDeploymentEvaluationStatus: common.StatePending, - PostDeploymentStatus: common.StateDeprecated, - PostDeploymentEvaluationStatus: common.StateDeprecated, - DeploymentStatus: common.StatePending, - Status: common.StateFailed, - }, - }, - }, - { - workloadInstance: workloadInstance, - phase: common.PhaseWorkloadPreEvaluation, - want: KeptnWorkloadInstance{ - Status: KeptnWorkloadInstanceStatus{ - PreDeploymentStatus: common.StatePending, - PreDeploymentEvaluationStatus: common.StatePending, - PostDeploymentStatus: common.StateDeprecated, - PostDeploymentEvaluationStatus: common.StateDeprecated, - DeploymentStatus: common.StateDeprecated, - Status: common.StateFailed, - }, - }, - }, - { - workloadInstance: workloadInstance, - phase: common.PhaseWorkloadPreDeployment, - want: KeptnWorkloadInstance{ - Status: KeptnWorkloadInstanceStatus{ - PreDeploymentStatus: common.StatePending, - PreDeploymentEvaluationStatus: common.StateDeprecated, - PostDeploymentStatus: common.StateDeprecated, - PostDeploymentEvaluationStatus: common.StateDeprecated, - DeploymentStatus: common.StateDeprecated, - Status: common.StateFailed, - }, - }, - }, - { - workloadInstance: workloadInstance, - phase: common.PhaseDeprecated, - want: KeptnWorkloadInstance{ - Status: KeptnWorkloadInstanceStatus{ - PreDeploymentStatus: common.StateDeprecated, - PreDeploymentEvaluationStatus: common.StateDeprecated, - PostDeploymentStatus: common.StateDeprecated, - PostDeploymentEvaluationStatus: common.StateDeprecated, - DeploymentStatus: common.StateDeprecated, - Status: common.StateDeprecated, - }, - }, - }, - { - workloadInstance: workloadInstance, - phase: common.PhaseAppPreDeployment, - want: KeptnWorkloadInstance{ - Status: KeptnWorkloadInstanceStatus{ - PreDeploymentStatus: common.StatePending, - PreDeploymentEvaluationStatus: common.StatePending, - PostDeploymentStatus: common.StatePending, - PostDeploymentEvaluationStatus: common.StatePending, - DeploymentStatus: common.StatePending, - Status: common.StateFailed, - }, - }, - }, - } - - for _, tt := range tests { - t.Run("", func(t *testing.T) { - tt.workloadInstance.DeprecateRemainingPhases(tt.phase) - require.Equal(t, tt.want, tt.workloadInstance) - }) - } -} - -func TestKeptnWorkloadInstance_SetPhaseTraceID(t *testing.T) { - app := KeptnWorkloadInstance{ - Status: KeptnWorkloadInstanceStatus{}, - } - - app.SetPhaseTraceID(common.PhaseAppDeployment.ShortName, propagation.MapCarrier{ - "name3": "trace3", - }) - - require.Equal(t, KeptnWorkloadInstance{ - Status: KeptnWorkloadInstanceStatus{ - PhaseTraceIDs: common.PhaseTraceID{ - common.PhaseAppDeployment.ShortName: propagation.MapCarrier{ - "name3": "trace3", - }, - }, - }, - }, app) - - app.SetPhaseTraceID(common.PhaseWorkloadDeployment.LongName, propagation.MapCarrier{ - "name2": "trace2", - }) - - require.Equal(t, KeptnWorkloadInstance{ - Status: KeptnWorkloadInstanceStatus{ - PhaseTraceIDs: common.PhaseTraceID{ - common.PhaseAppDeployment.ShortName: propagation.MapCarrier{ - "name3": "trace3", - }, - common.PhaseWorkloadDeployment.ShortName: propagation.MapCarrier{ - "name2": "trace2", - }, - }, - }, - }, app) -} - -func TestKeptnWorkloadInstanceList(t *testing.T) { - list := KeptnWorkloadInstanceList{ - Items: []KeptnWorkloadInstance{ - { - ObjectMeta: metav1.ObjectMeta{ - Name: "obj1", - }, - }, - { - ObjectMeta: metav1.ObjectMeta{ - Name: "obj2", - }, - }, - }, - } - - got := list.GetItems() - require.Len(t, got, 2) - require.Equal(t, "obj1", got[0].GetName()) - require.Equal(t, "obj2", got[1].GetName()) -} diff --git a/lifecycle-operator/apis/lifecycle/v1alpha3/keptnworkloadinstance_types.go b/lifecycle-operator/apis/lifecycle/v1alpha3/keptnworkloadinstance_types.go index 9c33ac9c698..72e1005ec7a 100644 --- a/lifecycle-operator/apis/lifecycle/v1alpha3/keptnworkloadinstance_types.go +++ b/lifecycle-operator/apis/lifecycle/v1alpha3/keptnworkloadinstance_types.go @@ -17,15 +17,8 @@ limitations under the License. package v1alpha3 import ( - "fmt" - "time" - "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3/common" - "go.opentelemetry.io/otel/attribute" - "go.opentelemetry.io/otel/propagation" - "go.opentelemetry.io/otel/trace" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "sigs.k8s.io/controller-runtime/pkg/client" ) // EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! @@ -160,338 +153,3 @@ type KeptnWorkloadInstanceList struct { func init() { SchemeBuilder.Register(&KeptnWorkloadInstance{}, &KeptnWorkloadInstanceList{}) } - -func (w KeptnWorkloadInstanceList) GetItems() []client.Object { - var b []client.Object - for i := 0; i < len(w.Items); i++ { - b = append(b, &w.Items[i]) - } - return b -} - -func (w KeptnWorkloadInstance) IsPreDeploymentCompleted() bool { - return w.Status.PreDeploymentStatus.IsCompleted() -} - -func (w KeptnWorkloadInstance) IsPreDeploymentEvaluationCompleted() bool { - return w.Status.PreDeploymentEvaluationStatus.IsCompleted() -} - -func (w KeptnWorkloadInstance) IsPreDeploymentSucceeded() bool { - return w.Status.PreDeploymentStatus.IsSucceeded() -} - -func (w KeptnWorkloadInstance) IsPreDeploymentFailed() bool { - return w.Status.PreDeploymentStatus.IsFailed() -} - -func (w KeptnWorkloadInstance) IsPreDeploymentEvaluationSucceeded() bool { - return w.Status.PreDeploymentEvaluationStatus.IsSucceeded() -} - -func (w KeptnWorkloadInstance) IsPreDeploymentEvaluationFailed() bool { - return w.Status.PreDeploymentEvaluationStatus.IsFailed() -} - -func (w KeptnWorkloadInstance) IsPostDeploymentCompleted() bool { - return w.Status.PostDeploymentStatus.IsCompleted() -} - -func (w KeptnWorkloadInstance) IsPostDeploymentEvaluationCompleted() bool { - return w.Status.PostDeploymentEvaluationStatus.IsCompleted() -} - -func (w KeptnWorkloadInstance) IsPostDeploymentSucceeded() bool { - return w.Status.PostDeploymentStatus.IsSucceeded() -} - -func (w KeptnWorkloadInstance) IsPostDeploymentFailed() bool { - return w.Status.PostDeploymentStatus.IsFailed() -} - -func (w KeptnWorkloadInstance) IsPostDeploymentEvaluationSucceeded() bool { - return w.Status.PostDeploymentEvaluationStatus.IsSucceeded() -} - -func (w KeptnWorkloadInstance) IsPostDeploymentEvaluationFailed() bool { - return w.Status.PostDeploymentEvaluationStatus.IsFailed() -} - -func (w KeptnWorkloadInstance) IsDeploymentCompleted() bool { - return w.Status.DeploymentStatus.IsCompleted() -} - -func (w KeptnWorkloadInstance) IsDeploymentSucceeded() bool { - return w.Status.DeploymentStatus.IsSucceeded() -} - -func (w KeptnWorkloadInstance) IsDeploymentFailed() bool { - return w.Status.DeploymentStatus.IsFailed() -} - -func (w *KeptnWorkloadInstance) SetStartTime() { - if w.Status.StartTime.IsZero() { - w.Status.StartTime = metav1.NewTime(time.Now().UTC()) - } -} - -func (w *KeptnWorkloadInstance) SetEndTime() { - if w.Status.EndTime.IsZero() { - w.Status.EndTime = metav1.NewTime(time.Now().UTC()) - } -} - -func (w *KeptnWorkloadInstance) IsStartTimeSet() bool { - return !w.Status.StartTime.IsZero() -} - -func (w *KeptnWorkloadInstance) IsEndTimeSet() bool { - return !w.Status.EndTime.IsZero() -} - -func (w KeptnWorkloadInstance) GetStartTime() time.Time { - return w.Status.StartTime.Time -} - -func (w KeptnWorkloadInstance) GetEndTime() time.Time { - return w.Status.EndTime.Time -} - -func (w *KeptnWorkloadInstance) Complete() { - w.SetEndTime() -} - -func (e *ItemStatus) SetStartTime() { - if e.StartTime.IsZero() { - e.StartTime = metav1.NewTime(time.Now().UTC()) - } -} - -func (e *ItemStatus) SetEndTime() { - if e.EndTime.IsZero() { - e.EndTime = metav1.NewTime(time.Now().UTC()) - } -} - -func (w KeptnWorkloadInstance) GetActiveMetricsAttributes() []attribute.KeyValue { - return []attribute.KeyValue{ - common.AppName.String(w.Spec.AppName), - common.WorkloadName.String(w.Spec.WorkloadName), - common.WorkloadVersion.String(w.Spec.Version), - common.WorkloadNamespace.String(w.Namespace), - } -} - -func (w KeptnWorkloadInstance) GetMetricsAttributes() []attribute.KeyValue { - return []attribute.KeyValue{ - common.AppName.String(w.Spec.AppName), - common.WorkloadName.String(w.Spec.WorkloadName), - common.WorkloadVersion.String(w.Spec.Version), - common.WorkloadNamespace.String(w.Namespace), - common.WorkloadStatus.String(string(w.Status.Status)), - } -} - -func (w KeptnWorkloadInstance) GetDurationMetricsAttributes() []attribute.KeyValue { - return []attribute.KeyValue{ - common.AppName.String(w.Spec.AppName), - common.WorkloadName.String(w.Spec.WorkloadName), - common.WorkloadVersion.String(w.Spec.Version), - common.WorkloadPreviousVersion.String(w.Spec.PreviousVersion), - } -} - -func (w KeptnWorkloadInstance) GetState() common.KeptnState { - return w.Status.Status -} - -func (w KeptnWorkloadInstance) GetPreDeploymentTasks() []string { - return w.Spec.PreDeploymentTasks -} - -func (w KeptnWorkloadInstance) GetPostDeploymentTasks() []string { - return w.Spec.PostDeploymentTasks -} - -func (w KeptnWorkloadInstance) GetPreDeploymentTaskStatus() []ItemStatus { - return w.Status.PreDeploymentTaskStatus -} - -func (w KeptnWorkloadInstance) GetPostDeploymentTaskStatus() []ItemStatus { - return w.Status.PostDeploymentTaskStatus -} - -func (w KeptnWorkloadInstance) GetPreDeploymentEvaluations() []string { - return w.Spec.PreDeploymentEvaluations -} - -func (w KeptnWorkloadInstance) GetPostDeploymentEvaluations() []string { - return w.Spec.PostDeploymentEvaluations -} - -func (w KeptnWorkloadInstance) GetPreDeploymentEvaluationTaskStatus() []ItemStatus { - return w.Status.PreDeploymentEvaluationTaskStatus -} - -func (w KeptnWorkloadInstance) GetPostDeploymentEvaluationTaskStatus() []ItemStatus { - return w.Status.PostDeploymentEvaluationTaskStatus -} - -func (w KeptnWorkloadInstance) GetAppName() string { - return w.Spec.AppName -} - -func (w KeptnWorkloadInstance) GetPreviousVersion() string { - return w.Spec.PreviousVersion -} - -func (w KeptnWorkloadInstance) GetParentName() string { - return w.Spec.WorkloadName -} - -func (w KeptnWorkloadInstance) GetNamespace() string { - return w.Namespace -} - -func (w *KeptnWorkloadInstance) SetState(state common.KeptnState) { - w.Status.Status = state -} - -func (w KeptnWorkloadInstance) GetCurrentPhase() string { - return w.Status.CurrentPhase -} - -func (w *KeptnWorkloadInstance) SetCurrentPhase(phase string) { - w.Status.CurrentPhase = phase -} - -func (w KeptnWorkloadInstance) GetVersion() string { - return w.Spec.Version -} - -func (w KeptnWorkloadInstance) GenerateTask(taskDefinition KeptnTaskDefinition, checkType common.CheckType) KeptnTask { - return KeptnTask{ - ObjectMeta: metav1.ObjectMeta{ - Name: common.GenerateTaskName(checkType, taskDefinition.Name), - Namespace: w.Namespace, - Labels: taskDefinition.Labels, - Annotations: taskDefinition.Annotations, - }, - Spec: KeptnTaskSpec{ - Context: TaskContext{ - WorkloadName: w.GetParentName(), - AppName: w.GetAppName(), - WorkloadVersion: w.GetVersion(), - TaskType: string(checkType), - ObjectType: "Workload", - }, - TaskDefinition: taskDefinition.Name, - Parameters: TaskParameters{}, - SecureParameters: SecureParameters{}, - Type: checkType, - Retries: taskDefinition.Spec.Retries, - Timeout: taskDefinition.Spec.Timeout, - }, - } -} - -func (w KeptnWorkloadInstance) GenerateEvaluation(evaluationDefinition KeptnEvaluationDefinition, checkType common.CheckType) KeptnEvaluation { - return KeptnEvaluation{ - ObjectMeta: metav1.ObjectMeta{ - Name: common.GenerateEvaluationName(checkType, evaluationDefinition.Name), - Namespace: w.Namespace, - }, - Spec: KeptnEvaluationSpec{ - AppName: w.GetAppName(), - WorkloadVersion: w.GetVersion(), - Workload: w.GetParentName(), - EvaluationDefinition: evaluationDefinition.Name, - Type: checkType, - RetryInterval: metav1.Duration{ - Duration: 5 * time.Second, - }, - }, - } -} - -func (w KeptnWorkloadInstance) GetSpanAttributes() []attribute.KeyValue { - return []attribute.KeyValue{ - common.AppName.String(w.Spec.AppName), - common.WorkloadName.String(w.Spec.WorkloadName), - common.WorkloadVersion.String(w.Spec.Version), - common.WorkloadNamespace.String(w.Namespace), - } -} - -func (w KeptnWorkloadInstance) GetSpanKey(phase string) string { - return fmt.Sprintf("%s.%s.%s.%s", w.Spec.TraceId["traceparent"], w.Spec.WorkloadName, w.Spec.Version, phase) -} - -func (w KeptnWorkloadInstance) GetSpanName(phase string) string { - if phase == "" { - return w.Name - } - return fmt.Sprintf("%s/%s", w.Spec.WorkloadName, phase) -} - -func (w KeptnWorkloadInstance) SetSpanAttributes(span trace.Span) { - span.SetAttributes(w.GetSpanAttributes()...) -} - -//nolint:dupl -func (w *KeptnWorkloadInstance) DeprecateRemainingPhases(phase common.KeptnPhaseType) { - // no need to deprecate anything when post-eval tasks fail - if phase == common.PhaseWorkloadPostEvaluation { - return - } - // deprecate post evaluation when post tasks failed - if phase == common.PhaseWorkloadPostDeployment { - w.Status.PostDeploymentEvaluationStatus = common.StateDeprecated - } - // deprecate post evaluation and tasks when app deployment failed - if phase == common.PhaseWorkloadDeployment { - w.Status.PostDeploymentStatus = common.StateDeprecated - w.Status.PostDeploymentEvaluationStatus = common.StateDeprecated - } - // deprecate app deployment, post tasks and evaluations if app pre-eval failed - if phase == common.PhaseWorkloadPreEvaluation { - w.Status.PostDeploymentStatus = common.StateDeprecated - w.Status.PostDeploymentEvaluationStatus = common.StateDeprecated - w.Status.DeploymentStatus = common.StateDeprecated - } - // deprecate pre evaluations, app deployment and post tasks and evaluations when pre-tasks failed - if phase == common.PhaseWorkloadPreDeployment { - w.Status.PostDeploymentStatus = common.StateDeprecated - w.Status.PostDeploymentEvaluationStatus = common.StateDeprecated - w.Status.DeploymentStatus = common.StateDeprecated - w.Status.PreDeploymentEvaluationStatus = common.StateDeprecated - } - // deprecate completely everything - if phase == common.PhaseDeprecated { - w.Status.PostDeploymentStatus = common.StateDeprecated - w.Status.PostDeploymentEvaluationStatus = common.StateDeprecated - w.Status.DeploymentStatus = common.StateDeprecated - w.Status.PreDeploymentEvaluationStatus = common.StateDeprecated - w.Status.PreDeploymentStatus = common.StateDeprecated - w.Status.Status = common.StateDeprecated - return - } - - w.Status.Status = common.StateFailed -} - -func (w *KeptnWorkloadInstance) SetPhaseTraceID(phase string, carrier propagation.MapCarrier) { - if w.Status.PhaseTraceIDs == nil { - w.Status.PhaseTraceIDs = common.PhaseTraceID{} - } - w.Status.PhaseTraceIDs[common.GetShortPhaseName(phase)] = carrier -} - -func (w KeptnWorkloadInstance) GetEventAnnotations() map[string]string { - return map[string]string{ - "appName": w.Spec.AppName, - "workloadName": w.Spec.WorkloadName, - "workloadVersion": w.Spec.Version, - "workloadInstanceName": w.Name, - } -} diff --git a/lifecycle-operator/apis/lifecycle/v1alpha3/keptnworkloadinstance_webhook.go b/lifecycle-operator/apis/lifecycle/v1alpha3/keptnworkloadinstance_webhook.go deleted file mode 100644 index 4a98c167ee4..00000000000 --- a/lifecycle-operator/apis/lifecycle/v1alpha3/keptnworkloadinstance_webhook.go +++ /dev/null @@ -1,11 +0,0 @@ -package v1alpha3 - -import ( - ctrl "sigs.k8s.io/controller-runtime" -) - -func (r *KeptnWorkloadInstance) SetupWebhookWithManager(mgr ctrl.Manager) error { - return ctrl.NewWebhookManagedBy(mgr). - For(r). - Complete() -} diff --git a/lifecycle-operator/apis/lifecycle/v1alpha3/zz_generated.deepcopy.go b/lifecycle-operator/apis/lifecycle/v1alpha3/zz_generated.deepcopy.go index f4fccd613ca..47f3cf2ca4e 100644 --- a/lifecycle-operator/apis/lifecycle/v1alpha3/zz_generated.deepcopy.go +++ b/lifecycle-operator/apis/lifecycle/v1alpha3/zz_generated.deepcopy.go @@ -24,7 +24,7 @@ import ( "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3/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/apis/lifecycle/v1alpha4/keptnworkloadversion_types.go b/lifecycle-operator/apis/lifecycle/v1alpha4/keptnworkloadversion_types.go index 154ee618394..6da9506bd86 100644 --- a/lifecycle-operator/apis/lifecycle/v1alpha4/keptnworkloadversion_types.go +++ b/lifecycle-operator/apis/lifecycle/v1alpha4/keptnworkloadversion_types.go @@ -102,7 +102,6 @@ type KeptnWorkloadVersionStatus struct { // +kubebuilder:object:root=true // +kubebuilder:resource:path=keptnworkloadversions,shortName=kwv // +kubebuilder:subresource:status -// +kubebuilder:storageversion // +kubebuilder:printcolumn:name="AppName",type=string,JSONPath=`.spec.app` // +kubebuilder:printcolumn:name="WorkloadName",type=string,JSONPath=`.spec.workloadName` // +kubebuilder:printcolumn:name="WorkloadVersion",type=string,JSONPath=`.spec.version` diff --git a/lifecycle-operator/apis/lifecycle/v1beta1/common/common.go b/lifecycle-operator/apis/lifecycle/v1beta1/common/common.go index f3d81d56c5e..bebfa1ce9be 100644 --- a/lifecycle-operator/apis/lifecycle/v1beta1/common/common.go +++ b/lifecycle-operator/apis/lifecycle/v1beta1/common/common.go @@ -3,7 +3,6 @@ package common import ( "crypto/sha256" "encoding/hex" - "errors" "math/rand" "strconv" @@ -38,9 +37,6 @@ const ContainerNameAnnotation = "keptn.sh/container" const MinKeptnNameLen = 80 const MaxK8sObjectLength = 253 -var ErrCannotCastKeptnAppVersion = errors.New("cannot cast KeptnAppVersion to v1alpha3") -var ErrCannotCastKeptnApp = errors.New("cannot cast KeptnApp to v1alpha3") - type AppType string const ( diff --git a/lifecycle-operator/apis/lifecycle/v1beta1/keptnapp_conversion.go b/lifecycle-operator/apis/lifecycle/v1beta1/keptnapp_conversion.go index 5ed40ae1a58..946767780bc 100644 --- a/lifecycle-operator/apis/lifecycle/v1beta1/keptnapp_conversion.go +++ b/lifecycle-operator/apis/lifecycle/v1beta1/keptnapp_conversion.go @@ -1,71 +1,6 @@ package v1beta1 -import ( - "fmt" - - "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3" - "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 (v1alpha3.KeptnApp) -func (src *KeptnApp) ConvertTo(dstRaw conversion.Hub) error { - dst, ok := dstRaw.(*v1alpha3.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, v1alpha3.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.Status.CurrentVersion = src.Status.CurrentVersion - - dst.Spec.Revision = src.Spec.Revision - - return nil -} - -// ConvertFrom converts from the hub version (v1alpha3.KeptnApp) to this version (v1beta1.KeptnApp) -func (dst *KeptnApp) ConvertFrom(srcRaw conversion.Hub) error { - src, ok := srcRaw.(*v1alpha3.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.Spec.PreDeploymentTasks = src.Spec.PreDeploymentTasks - dst.Spec.PostDeploymentTasks = src.Spec.PostDeploymentTasks - dst.Spec.PreDeploymentEvaluations = src.Spec.PreDeploymentEvaluations - dst.Spec.PostDeploymentEvaluations = src.Spec.PostDeploymentEvaluations - - 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/v1beta1/keptnapp_types.go b/lifecycle-operator/apis/lifecycle/v1beta1/keptnapp_types.go index ba2642bc3ee..27a6fb745cd 100644 --- a/lifecycle-operator/apis/lifecycle/v1beta1/keptnapp_types.go +++ b/lifecycle-operator/apis/lifecycle/v1beta1/keptnapp_types.go @@ -81,6 +81,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/v1alpha3/keptnapp_webhook.go b/lifecycle-operator/apis/lifecycle/v1beta1/keptnapp_webhook.go similarity index 91% rename from lifecycle-operator/apis/lifecycle/v1alpha3/keptnapp_webhook.go rename to lifecycle-operator/apis/lifecycle/v1beta1/keptnapp_webhook.go index 413422c6e05..5d280f77c81 100644 --- a/lifecycle-operator/apis/lifecycle/v1alpha3/keptnapp_webhook.go +++ b/lifecycle-operator/apis/lifecycle/v1beta1/keptnapp_webhook.go @@ -1,4 +1,4 @@ -package v1alpha3 +package v1beta1 import ( ctrl "sigs.k8s.io/controller-runtime" diff --git a/lifecycle-operator/apis/lifecycle/v1beta1/keptnappcreationrequest_types.go b/lifecycle-operator/apis/lifecycle/v1beta1/keptnappcreationrequest_types.go index 828fa6952e5..9aa4ac385ac 100644 --- a/lifecycle-operator/apis/lifecycle/v1beta1/keptnappcreationrequest_types.go +++ b/lifecycle-operator/apis/lifecycle/v1beta1/keptnappcreationrequest_types.go @@ -23,9 +23,6 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) -// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! -// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. - // KeptnAppCreationRequestSpec defines the desired state of KeptnAppCreationRequest type KeptnAppCreationRequestSpec struct { // AppName is the name of the KeptnApp the KeptnAppCreationRequest should create if no user-defined object with that name is found. @@ -33,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/v1beta1/keptnappversion_conversion.go b/lifecycle-operator/apis/lifecycle/v1beta1/keptnappversion_conversion.go index 7177db9c1a1..4380e2bbd85 100644 --- a/lifecycle-operator/apis/lifecycle/v1beta1/keptnappversion_conversion.go +++ b/lifecycle-operator/apis/lifecycle/v1beta1/keptnappversion_conversion.go @@ -1,235 +1,6 @@ package v1beta1 -import ( - "fmt" - - "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3" - v1alpha3common "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3/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 v1beta1.KeptnAppVersion to the hub version (v1alpha3.KeptnAppVersion) -// -//nolint:gocyclo -func (src *KeptnAppVersion) ConvertTo(dstRaw conversion.Hub) error { - dst, ok := dstRaw.(*v1alpha3.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, v1alpha3.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.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 = v1alpha3common.KeptnState(src.Status.PreDeploymentStatus) - dst.Status.PostDeploymentStatus = v1alpha3common.KeptnState(src.Status.PostDeploymentStatus) - dst.Status.PreDeploymentEvaluationStatus = v1alpha3common.KeptnState(src.Status.PreDeploymentEvaluationStatus) - dst.Status.PostDeploymentEvaluationStatus = v1alpha3common.KeptnState(src.Status.PostDeploymentEvaluationStatus) - dst.Status.WorkloadOverallStatus = v1alpha3common.KeptnState(src.Status.WorkloadOverallStatus) - dst.Status.Status = v1alpha3common.KeptnState(src.Status.Status) - - for _, srcWls := range src.Status.WorkloadStatus { - dst.Status.WorkloadStatus = append(dst.Status.WorkloadStatus, v1alpha3.WorkloadStatus{ - Workload: v1alpha3.KeptnWorkloadRef{ - Name: srcWls.Workload.Name, - Version: srcWls.Workload.Version, - }, - Status: v1alpha3common.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, v1alpha3.ItemStatus{ - DefinitionName: item.DefinitionName, - Status: v1alpha3common.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, v1alpha3.ItemStatus{ - DefinitionName: item.DefinitionName, - Status: v1alpha3common.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, v1alpha3.ItemStatus{ - DefinitionName: item.DefinitionName, - Status: v1alpha3common.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, v1alpha3.ItemStatus{ - DefinitionName: item.DefinitionName, - Status: v1alpha3common.KeptnState(item.Status), - Name: item.Name, - StartTime: item.StartTime, - EndTime: item.EndTime, - }) - } - - dst.Status.PhaseTraceIDs = make(v1alpha3common.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 (v1alpha3.KeptnAppVersion) to this version (v1alpha3.KeptnAppVersion) -// -//nolint:gocyclo -func (dst *KeptnAppVersion) ConvertFrom(srcRaw conversion.Hub) error { - src, ok := srcRaw.(*v1alpha3.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.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.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, - }) - } - - 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/v1beta1/keptnappversion_types.go b/lifecycle-operator/apis/lifecycle/v1beta1/keptnappversion_types.go index 04ba0270a38..eb0de7a91b5 100644 --- a/lifecycle-operator/apis/lifecycle/v1beta1/keptnappversion_types.go +++ b/lifecycle-operator/apis/lifecycle/v1beta1/keptnappversion_types.go @@ -28,9 +28,6 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" ) -// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! -// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. - // KeptnAppVersionSpec defines the desired state of KeptnAppVersion type KeptnAppVersionSpec struct { KeptnAppSpec `json:",inline"` @@ -112,6 +109,7 @@ 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/v1alpha3/keptnappversion_webhook.go b/lifecycle-operator/apis/lifecycle/v1beta1/keptnappversion_webhook.go similarity index 91% rename from lifecycle-operator/apis/lifecycle/v1alpha3/keptnappversion_webhook.go rename to lifecycle-operator/apis/lifecycle/v1beta1/keptnappversion_webhook.go index 984fd70d6a1..48387d96124 100644 --- a/lifecycle-operator/apis/lifecycle/v1alpha3/keptnappversion_webhook.go +++ b/lifecycle-operator/apis/lifecycle/v1beta1/keptnappversion_webhook.go @@ -1,4 +1,4 @@ -package v1alpha3 +package v1beta1 import ( ctrl "sigs.k8s.io/controller-runtime" diff --git a/lifecycle-operator/apis/lifecycle/v1beta1/keptnevaluation_types.go b/lifecycle-operator/apis/lifecycle/v1beta1/keptnevaluation_types.go index 59df6e9bf37..ef2cc7de981 100644 --- a/lifecycle-operator/apis/lifecycle/v1beta1/keptnevaluation_types.go +++ b/lifecycle-operator/apis/lifecycle/v1beta1/keptnevaluation_types.go @@ -27,9 +27,6 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" ) -// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! -// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. - // KeptnEvaluationSpec defines the desired state of KeptnEvaluation type KeptnEvaluationSpec struct { // Workload defines the KeptnWorkload for which the KeptnEvaluation is done. @@ -102,6 +99,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/v1beta1/keptnevaluationdefinition_types.go b/lifecycle-operator/apis/lifecycle/v1beta1/keptnevaluationdefinition_types.go index 74614aa8883..9da5fd5c26d 100644 --- a/lifecycle-operator/apis/lifecycle/v1beta1/keptnevaluationdefinition_types.go +++ b/lifecycle-operator/apis/lifecycle/v1beta1/keptnevaluationdefinition_types.go @@ -20,9 +20,6 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) -// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! -// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. - // KeptnEvaluationDefinitionSpec defines the desired state of KeptnEvaluationDefinition type KeptnEvaluationDefinitionSpec struct { // Objectives is a list of objectives that have to be met for a KeptnEvaluation referencing this @@ -47,6 +44,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/v1beta1/keptntask_types.go b/lifecycle-operator/apis/lifecycle/v1beta1/keptntask_types.go index e8feced65ce..5a34c1e82c8 100644 --- a/lifecycle-operator/apis/lifecycle/v1beta1/keptntask_types.go +++ b/lifecycle-operator/apis/lifecycle/v1beta1/keptntask_types.go @@ -27,9 +27,6 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" ) -// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! -// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. - // KeptnTaskSpec defines the desired state of KeptnTask type KeptnTaskSpec struct { // TaskDefinition refers to the name of the KeptnTaskDefinition @@ -129,6 +126,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/v1beta1/keptntaskdefinition_types.go b/lifecycle-operator/apis/lifecycle/v1beta1/keptntaskdefinition_types.go index 08fea1a5125..5c125bc28af 100644 --- a/lifecycle-operator/apis/lifecycle/v1beta1/keptntaskdefinition_types.go +++ b/lifecycle-operator/apis/lifecycle/v1beta1/keptntaskdefinition_types.go @@ -21,9 +21,6 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) -// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! -// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. - // KeptnTaskDefinitionSpec defines the desired state of KeptnTaskDefinition type KeptnTaskDefinitionSpec struct { // Deprecated @@ -152,6 +149,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/v1alpha3/keptntaskdefinition_webhook.go b/lifecycle-operator/apis/lifecycle/v1beta1/keptntaskdefinition_webhook.go similarity index 91% rename from lifecycle-operator/apis/lifecycle/v1alpha3/keptntaskdefinition_webhook.go rename to lifecycle-operator/apis/lifecycle/v1beta1/keptntaskdefinition_webhook.go index 412c9c9230d..4ad0d39faa3 100644 --- a/lifecycle-operator/apis/lifecycle/v1alpha3/keptntaskdefinition_webhook.go +++ b/lifecycle-operator/apis/lifecycle/v1beta1/keptntaskdefinition_webhook.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v1alpha3 +package v1beta1 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-v1alpha3-keptntaskdefinition,mutating=false,failurePolicy=fail,sideEffects=None,groups=lifecycle.keptn.sh,resources=keptntaskdefinitions,verbs=create;update,versions=v1alpha3,name=vkeptntaskdefinition.kb.io,admissionReviewVersions=v1 +//+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 var _ webhook.Validator = &KeptnTaskDefinition{} diff --git a/lifecycle-operator/apis/lifecycle/v1alpha3/keptntaskdefinition_webhook_test.go b/lifecycle-operator/apis/lifecycle/v1beta1/keptntaskdefinition_webhook_test.go similarity index 99% rename from lifecycle-operator/apis/lifecycle/v1alpha3/keptntaskdefinition_webhook_test.go rename to lifecycle-operator/apis/lifecycle/v1beta1/keptntaskdefinition_webhook_test.go index 26ef76abf38..268463ceca5 100644 --- a/lifecycle-operator/apis/lifecycle/v1alpha3/keptntaskdefinition_webhook_test.go +++ b/lifecycle-operator/apis/lifecycle/v1beta1/keptntaskdefinition_webhook_test.go @@ -1,4 +1,4 @@ -package v1alpha3 +package v1beta1 import ( "testing" diff --git a/lifecycle-operator/apis/lifecycle/v1beta1/keptnworkload_types.go b/lifecycle-operator/apis/lifecycle/v1beta1/keptnworkload_types.go index a15d9c7ba63..f057fd3c21b 100644 --- a/lifecycle-operator/apis/lifecycle/v1beta1/keptnworkload_types.go +++ b/lifecycle-operator/apis/lifecycle/v1beta1/keptnworkload_types.go @@ -27,9 +27,6 @@ import ( "k8s.io/apimachinery/pkg/types" ) -// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! -// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. - // KeptnWorkloadSpec defines the desired state of KeptnWorkload type KeptnWorkloadSpec struct { // AppName is the name of the KeptnApp containing the KeptnWorkload. @@ -71,6 +68,7 @@ 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 7a44dfb058b..8845f319466 100644 --- a/lifecycle-operator/apis/lifecycle/v1beta1/keptnworkloadversion_types.go +++ b/lifecycle-operator/apis/lifecycle/v1beta1/keptnworkloadversion_types.go @@ -117,6 +117,7 @@ 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` @@ -237,6 +238,18 @@ func (w *KeptnWorkloadVersion) SetEndTime() { } } +func (e *ItemStatus) SetStartTime() { + if e.StartTime.IsZero() { + e.StartTime = metav1.NewTime(time.Now().UTC()) + } +} + +func (e *ItemStatus) SetEndTime() { + if e.EndTime.IsZero() { + e.EndTime = metav1.NewTime(time.Now().UTC()) + } +} + func (w *KeptnWorkloadVersion) IsStartTimeSet() bool { return !w.Status.StartTime.IsZero() } diff --git a/lifecycle-operator/apis/lifecycle/v1beta1/zz_generated.deepcopy.go b/lifecycle-operator/apis/lifecycle/v1beta1/zz_generated.deepcopy.go index 2cc991a2774..41cdb57bc3b 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" - 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. @@ -82,6 +82,41 @@ func (in *ContainerSpec) DeepCopy() *ContainerSpec { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DeploymentTaskSpec) DeepCopyInto(out *DeploymentTaskSpec) { + *out = *in + if in.PreDeploymentTasks != nil { + in, out := &in.PreDeploymentTasks, &out.PreDeploymentTasks + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.PostDeploymentTasks != nil { + in, out := &in.PostDeploymentTasks, &out.PostDeploymentTasks + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.PreDeploymentEvaluations != nil { + in, out := &in.PreDeploymentEvaluations, &out.PreDeploymentEvaluations + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.PostDeploymentEvaluations != nil { + in, out := &in.PostDeploymentEvaluations, &out.PostDeploymentEvaluations + *out = make([]string, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DeploymentTaskSpec. +func (in *DeploymentTaskSpec) DeepCopy() *DeploymentTaskSpec { + if in == nil { + return nil + } + out := new(DeploymentTaskSpec) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *EvaluationStatusItem) DeepCopyInto(out *EvaluationStatusItem) { *out = *in @@ -206,7 +241,7 @@ func (in *KeptnAppContext) DeepCopyInto(out *KeptnAppContext) { *out = *in out.TypeMeta = in.TypeMeta in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - out.Spec = in.Spec + in.Spec.DeepCopyInto(&out.Spec) out.Status = in.Status } @@ -263,6 +298,19 @@ func (in *KeptnAppContextList) DeepCopyObject() runtime.Object { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *KeptnAppContextSpec) DeepCopyInto(out *KeptnAppContextSpec) { *out = *in + in.DeploymentTaskSpec.DeepCopyInto(&out.DeploymentTaskSpec) + if in.Metadata != nil { + in, out := &in.Metadata, &out.Metadata + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + if in.TraceLinks != nil { + in, out := &in.TraceLinks, &out.TraceLinks + *out = make([]string, len(*in)) + copy(*out, *in) + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KeptnAppContextSpec. diff --git a/lifecycle-operator/chart/README.md b/lifecycle-operator/chart/README.md index fd39f55f974..b601cb0f066 100644 --- a/lifecycle-operator/chart/README.md +++ b/lifecycle-operator/chart/README.md @@ -30,41 +30,40 @@ and application health checks ### Keptn Lifecycle Operator controller -| Name | Description | Value | -| --------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- | ------------------------------------- | -| `lifecycleOperator.containerSecurityContext` | Sets security context privileges | | -| `lifecycleOperator.containerSecurityContext.allowPrivilegeEscalation` | | `false` | -| `lifecycleOperator.containerSecurityContext.capabilities.drop` | | `["ALL"]` | -| `lifecycleOperator.containerSecurityContext.privileged` | | `false` | -| `lifecycleOperator.containerSecurityContext.runAsGroup` | | `65532` | -| `lifecycleOperator.containerSecurityContext.runAsNonRoot` | | `true` | -| `lifecycleOperator.containerSecurityContext.runAsUser` | | `65532` | -| `lifecycleOperator.containerSecurityContext.seccompProfile.type` | | `RuntimeDefault` | -| `lifecycleOperator.env.functionRunnerImage` | specify image for deno task runtime | `ghcr.io/keptn/deno-runtime:v1.0.2` | -| `lifecycleOperator.env.keptnAppControllerLogLevel` | sets the log level of Keptn App Controller | `0` | -| `lifecycleOperator.env.keptnAppCreationRequestControllerLogLevel` | sets the log level of Keptn App Creation Request Controller | `0` | -| `lifecycleOperator.env.keptnAppVersionControllerLogLevel` | sets the log level of Keptn AppVersion Controller | `0` | -| `lifecycleOperator.env.keptnEvaluationControllerLogLevel` | sets the log level of Keptn Evaluation Controller | `0` | -| `lifecycleOperator.env.keptnTaskControllerLogLevel` | sets the log level of Keptn Task Controller | `0` | -| `lifecycleOperator.env.keptnTaskDefinitionControllerLogLevel` | sets the log level of Keptn TaskDefinition Controller | `0` | -| `lifecycleOperator.env.keptnWorkloadControllerLogLevel` | sets the log level of Keptn Workload Controller | `0` | -| `lifecycleOperator.env.keptnWorkloadVersionControllerLogLevel` | sets the log level of Keptn WorkloadVersion Controller | `0` | -| `lifecycleOperator.env.keptnWorkloadInstanceControllerLogLevel` | Deprecated: Use keptnWorkloadVersionControllerLogLevel instead. Sets the log level of Keptn WorkloadVersion Controller | `0` | -| `lifecycleOperator.env.keptnDoraMetricsPort` | sets the port for accessing lifecycle metrics in prometheus format | `2222` | -| `lifecycleOperator.env.optionsControllerLogLevel` | sets the log level of Keptn Options Controller | `0` | -| `lifecycleOperator.env.pythonRunnerImage` | specify image for python task runtime | `ghcr.io/keptn/python-runtime:v1.0.1` | -| `lifecycleOperator.image.registry` | specify the container registry for the lifecycle-operator image | `ghcr.io` | -| `lifecycleOperator.image.repository` | specify registry for manager image | `keptn/lifecycle-operator` | -| `lifecycleOperator.image.tag` | select tag for manager image | `v0.8.3` | -| `lifecycleOperator.imagePullPolicy` | specify pull policy for manager image | `Always` | -| `lifecycleOperator.livenessProbe` | custom livenessprobe for manager container | | -| `lifecycleOperator.readinessProbe` | custom readinessprobe for manager container | | -| `lifecycleOperator.resources` | specify limits and requests for manager container | | -| `lifecycleOperator.nodeSelector` | add custom nodes selector to lifecycle operator | `{}` | -| `lifecycleOperator.replicas` | customize number of installed lifecycle operator replicas | `1` | -| `lifecycleOperator.tolerations` | add custom tolerations to lifecycle operator | `[]` | -| `lifecycleOperator.topologySpreadConstraints` | add custom topology constraints to lifecycle operator | `[]` | -| `lifecycleOperatorMetricsService` | Adjust settings here to change the k8s service for scraping Prometheus metrics | | +| Name | Description | Value | +| --------------------------------------------------------------------- | ------------------------------------------------------------------------------ | ------------------------------------- | +| `lifecycleOperator.containerSecurityContext` | Sets security context privileges | | +| `lifecycleOperator.containerSecurityContext.allowPrivilegeEscalation` | | `false` | +| `lifecycleOperator.containerSecurityContext.capabilities.drop` | | `["ALL"]` | +| `lifecycleOperator.containerSecurityContext.privileged` | | `false` | +| `lifecycleOperator.containerSecurityContext.runAsGroup` | | `65532` | +| `lifecycleOperator.containerSecurityContext.runAsNonRoot` | | `true` | +| `lifecycleOperator.containerSecurityContext.runAsUser` | | `65532` | +| `lifecycleOperator.containerSecurityContext.seccompProfile.type` | | `RuntimeDefault` | +| `lifecycleOperator.env.functionRunnerImage` | specify image for deno task runtime | `ghcr.io/keptn/deno-runtime:v1.0.2` | +| `lifecycleOperator.env.keptnAppControllerLogLevel` | sets the log level of Keptn App Controller | `0` | +| `lifecycleOperator.env.keptnAppCreationRequestControllerLogLevel` | sets the log level of Keptn App Creation Request Controller | `0` | +| `lifecycleOperator.env.keptnAppVersionControllerLogLevel` | sets the log level of Keptn AppVersion Controller | `0` | +| `lifecycleOperator.env.keptnEvaluationControllerLogLevel` | sets the log level of Keptn Evaluation Controller | `0` | +| `lifecycleOperator.env.keptnTaskControllerLogLevel` | sets the log level of Keptn Task Controller | `0` | +| `lifecycleOperator.env.keptnTaskDefinitionControllerLogLevel` | sets the log level of Keptn TaskDefinition Controller | `0` | +| `lifecycleOperator.env.keptnWorkloadControllerLogLevel` | sets the log level of Keptn Workload Controller | `0` | +| `lifecycleOperator.env.keptnWorkloadVersionControllerLogLevel` | sets the log level of Keptn WorkloadVersion Controller | `0` | +| `lifecycleOperator.env.keptnDoraMetricsPort` | sets the port for accessing lifecycle metrics in prometheus format | `2222` | +| `lifecycleOperator.env.optionsControllerLogLevel` | sets the log level of Keptn Options Controller | `0` | +| `lifecycleOperator.env.pythonRunnerImage` | specify image for python task runtime | `ghcr.io/keptn/python-runtime:v1.0.1` | +| `lifecycleOperator.image.registry` | specify the container registry for the lifecycle-operator image | `ghcr.io` | +| `lifecycleOperator.image.repository` | specify registry for manager image | `keptn/lifecycle-operator` | +| `lifecycleOperator.image.tag` | select tag for manager image | `v0.8.3` | +| `lifecycleOperator.imagePullPolicy` | specify pull policy for manager image | `Always` | +| `lifecycleOperator.livenessProbe` | custom livenessprobe for manager container | | +| `lifecycleOperator.readinessProbe` | custom readinessprobe for manager container | | +| `lifecycleOperator.resources` | specify limits and requests for manager container | | +| `lifecycleOperator.nodeSelector` | add custom nodes selector to lifecycle operator | `{}` | +| `lifecycleOperator.replicas` | customize number of installed lifecycle operator replicas | `1` | +| `lifecycleOperator.tolerations` | add custom tolerations to lifecycle operator | `[]` | +| `lifecycleOperator.topologySpreadConstraints` | add custom topology constraints to lifecycle operator | `[]` | +| `lifecycleOperatorMetricsService` | Adjust settings here to change the k8s service for scraping Prometheus metrics | | ### Global diff --git a/lifecycle-operator/chart/templates/deployment.yaml b/lifecycle-operator/chart/templates/deployment.yaml index 5ea3a08ad6b..e8f42fe96cd 100644 --- a/lifecycle-operator/chart/templates/deployment.yaml +++ b/lifecycle-operator/chart/templates/deployment.yaml @@ -94,9 +94,6 @@ spec: - name: KEPTN_WORKLOAD_VERSION_CONTROLLER_LOG_LEVEL value: {{ .Values.lifecycleOperator.env.keptnWorkloadVersionControllerLogLevel | quote }} - - name: KEPTN_WORKLOAD_INSTANCE_CONTROLLER_LOG_LEVEL - value: {{ .Values.lifecycleOperator.env.keptnWorkloadInstanceControllerLogLevel - | quote }} - name: KEPTN_DORA_METRICS_PORT value: {{ .Values.lifecycleOperator.env.keptnDoraMetricsPort | quote }} - name: OPTIONS_CONTROLLER_LOG_LEVEL diff --git a/lifecycle-operator/chart/templates/keptnevaluationprovider-crd.yaml b/lifecycle-operator/chart/templates/keptnevaluationprovider-crd.yaml index b027681af70..b887f45fb9d 100644 --- a/lifecycle-operator/chart/templates/keptnevaluationprovider-crd.yaml +++ b/lifecycle-operator/chart/templates/keptnevaluationprovider-crd.yaml @@ -12,16 +12,6 @@ metadata: keptn.sh/inject-cert: "true" {{- include "common.labels.standard" ( dict "context" . ) | nindent 4 }} spec: - conversion: - strategy: Webhook - webhook: - clientConfig: - service: - name: 'lifecycle-webhook-service' - namespace: '{{ .Release.Namespace }}' - path: /convert - conversionReviewVersions: - - v1 group: lifecycle.keptn.sh names: kind: KeptnEvaluationProvider diff --git a/lifecycle-operator/chart/templates/keptnworkloadinstance-crd.yaml b/lifecycle-operator/chart/templates/keptnworkloadinstance-crd.yaml index 646aa587764..fdc36179541 100644 --- a/lifecycle-operator/chart/templates/keptnworkloadinstance-crd.yaml +++ b/lifecycle-operator/chart/templates/keptnworkloadinstance-crd.yaml @@ -12,16 +12,6 @@ metadata: keptn.sh/inject-cert: "true" {{- include "common.labels.standard" ( dict "context" . ) | nindent 4 }} spec: - conversion: - strategy: Webhook - webhook: - clientConfig: - service: - name: 'lifecycle-webhook-service' - namespace: '{{ .Release.Namespace }}' - path: /convert - conversionReviewVersions: - - v1 group: lifecycle.keptn.sh names: kind: KeptnWorkloadInstance diff --git a/lifecycle-operator/chart/templates/lifecycle-validating-webhook-configuration.yaml b/lifecycle-operator/chart/templates/lifecycle-validating-webhook-configuration.yaml index 7e0962d44d7..5f3f4f3839d 100644 --- a/lifecycle-operator/chart/templates/lifecycle-validating-webhook-configuration.yaml +++ b/lifecycle-operator/chart/templates/lifecycle-validating-webhook-configuration.yaml @@ -15,14 +15,14 @@ webhooks: service: name: 'lifecycle-webhook-service' namespace: '{{ .Release.Namespace }}' - path: /validate-lifecycle-keptn-sh-v1alpha3-keptntaskdefinition + path: /validate-lifecycle-keptn-sh-v1beta1-keptntaskdefinition failurePolicy: Fail name: vkeptntaskdefinition.kb.io rules: - apiGroups: - lifecycle.keptn.sh apiVersions: - - v1alpha3 + - v1beta1 operations: - CREATE - UPDATE diff --git a/lifecycle-operator/chart/values.yaml b/lifecycle-operator/chart/values.yaml index 311f6886fee..3baf6f25539 100644 --- a/lifecycle-operator/chart/values.yaml +++ b/lifecycle-operator/chart/values.yaml @@ -87,8 +87,6 @@ lifecycleOperator: keptnWorkloadControllerLogLevel: "0" ## @param lifecycleOperator.env.keptnWorkloadVersionControllerLogLevel sets the log level of Keptn WorkloadVersion Controller keptnWorkloadVersionControllerLogLevel: "0" -## @param lifecycleOperator.env.keptnWorkloadInstanceControllerLogLevel Deprecated: Use keptnWorkloadVersionControllerLogLevel instead. Sets the log level of Keptn WorkloadVersion Controller - keptnWorkloadInstanceControllerLogLevel: "0" ## @param lifecycleOperator.env.keptnDoraMetricsPort sets the port for accessing lifecycle metrics in prometheus format keptnDoraMetricsPort: "2222" ## @param lifecycleOperator.env.optionsControllerLogLevel sets the log level of Keptn Options Controller 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 58988e36439..32b5042ce10 100644 --- a/lifecycle-operator/config/crd/bases/lifecycle.keptn.sh_keptnappcreationrequests.yaml +++ b/lifecycle-operator/config/crd/bases/lifecycle.keptn.sh_keptnappcreationrequests.yaml @@ -47,7 +47,7 @@ spec: type: string type: object served: true - storage: true + storage: false subresources: status: {} - name: v1beta1 @@ -83,6 +83,6 @@ spec: type: string type: object served: true - storage: false + storage: true 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 f8dd62f8ec8..c70bc9d3a59 100644 --- a/lifecycle-operator/config/crd/bases/lifecycle.keptn.sh_keptnapps.yaml +++ b/lifecycle-operator/config/crd/bases/lifecycle.keptn.sh_keptnapps.yaml @@ -239,7 +239,7 @@ spec: type: object type: object served: true - storage: true + storage: false subresources: status: {} - name: v1beta1 @@ -336,6 +336,6 @@ spec: type: object type: object served: true - storage: false + storage: true 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 a1ca58549c0..78416941efa 100644 --- a/lifecycle-operator/config/crd/bases/lifecycle.keptn.sh_keptnappversions.yaml +++ b/lifecycle-operator/config/crd/bases/lifecycle.keptn.sh_keptnappversions.yaml @@ -833,7 +833,7 @@ spec: type: object type: object served: true - storage: true + storage: false subresources: status: {} - additionalPrinterColumns: @@ -1158,6 +1158,6 @@ spec: type: object type: object served: true - storage: false + storage: true 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 bad28c6b02b..48a656c0875 100644 --- a/lifecycle-operator/config/crd/bases/lifecycle.keptn.sh_keptnevaluationdefinitions.yaml +++ b/lifecycle-operator/config/crd/bases/lifecycle.keptn.sh_keptnevaluationdefinitions.yaml @@ -177,7 +177,7 @@ spec: type: string type: object served: true - storage: true + storage: false subresources: status: {} - name: v1beta1 @@ -239,6 +239,6 @@ spec: type: string type: object served: true - storage: false + storage: true 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 b078d5f32ad..27a8be084d9 100644 --- a/lifecycle-operator/config/crd/bases/lifecycle.keptn.sh_keptnevaluations.yaml +++ b/lifecycle-operator/config/crd/bases/lifecycle.keptn.sh_keptnevaluations.yaml @@ -375,7 +375,7 @@ spec: type: object type: object served: true - storage: true + storage: false subresources: status: {} - additionalPrinterColumns: @@ -519,6 +519,6 @@ spec: type: object type: object served: true - storage: false + storage: true 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 96c74f3cb2b..f905b145f98 100644 --- a/lifecycle-operator/config/crd/bases/lifecycle.keptn.sh_keptntaskdefinitions.yaml +++ b/lifecycle-operator/config/crd/bases/lifecycle.keptn.sh_keptntaskdefinitions.yaml @@ -1733,7 +1733,7 @@ spec: type: object type: object served: true - storage: true + storage: false subresources: status: {} - name: v1beta1 @@ -3313,6 +3313,6 @@ spec: type: object type: object served: true - storage: false + storage: true 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 095a2b38ab5..63900497b55 100644 --- a/lifecycle-operator/config/crd/bases/lifecycle.keptn.sh_keptntasks.yaml +++ b/lifecycle-operator/config/crd/bases/lifecycle.keptn.sh_keptntasks.yaml @@ -398,7 +398,7 @@ spec: type: object type: object served: true - storage: true + storage: false subresources: status: {} - additionalPrinterColumns: @@ -553,6 +553,6 @@ spec: type: object type: object served: true - storage: false + storage: true 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 e4319ecaed3..56c3f8fceaf 100644 --- a/lifecycle-operator/config/crd/bases/lifecycle.keptn.sh_keptnworkloads.yaml +++ b/lifecycle-operator/config/crd/bases/lifecycle.keptn.sh_keptnworkloads.yaml @@ -276,7 +276,7 @@ spec: type: object type: object served: true - storage: true + storage: false subresources: status: {} - additionalPrinterColumns: @@ -381,6 +381,6 @@ spec: type: object type: object served: true - storage: false + storage: true 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 cbed1c0c0f6..46a1a599094 100644 --- a/lifecycle-operator/config/crd/bases/lifecycle.keptn.sh_keptnworkloadversions.yaml +++ b/lifecycle-operator/config/crd/bases/lifecycle.keptn.sh_keptnworkloadversions.yaml @@ -320,7 +320,7 @@ spec: type: object type: object served: true - storage: true + storage: false subresources: status: {} - additionalPrinterColumns: @@ -627,6 +627,6 @@ spec: type: object type: object served: true - storage: false + storage: true subresources: status: {} diff --git a/lifecycle-operator/config/crd/kustomization.yaml b/lifecycle-operator/config/crd/kustomization.yaml index a702e83915f..eb709e7b234 100644 --- a/lifecycle-operator/config/crd/kustomization.yaml +++ b/lifecycle-operator/config/crd/kustomization.yaml @@ -30,12 +30,12 @@ labels: keptn.sh/inject-cert: "true" patches: - path: patches/webhook_in_lifecycle_keptnapps.yaml - - path: patches/webhook_in_lifecycle_keptnworkloadinstances.yaml - path: patches/webhook_in_lifecycle_keptnappversions.yaml - - path: patches/webhook_in_lifecycle_keptnevaluationproviders.yaml # [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix. # patches here are for enabling the conversion webhook for each CRD +# - path: patches/webhook_in_lifecycle_keptnworkloadinstances.yaml # - path: patches/webhook_in_lifecycle_keptntaskdefinitions.yaml +# - path: patches/webhook_in_lifecycle_keptnevaluationproviders.yaml # - path: patches/webhook_in_lifecycle_keptntasks.yaml # - path: patches/webhook_in_lifecycle_keptnworkloads.yaml # - path: patches/webhook_in_lifecycle_keptnevaluationdefinitions.yaml diff --git a/lifecycle-operator/config/rbac/role.yaml b/lifecycle-operator/config/rbac/role.yaml index ac88486eebf..26125ccaa4f 100644 --- a/lifecycle-operator/config/rbac/role.yaml +++ b/lifecycle-operator/config/rbac/role.yaml @@ -205,14 +205,6 @@ rules: - get - list - watch -- apiGroups: - - lifecycle.keptn.sh - resources: - - keptnevaluationproviders - verbs: - - get - - list - - watch - apiGroups: - lifecycle.keptn.sh resources: diff --git a/lifecycle-operator/config/webhook/manifests.yaml b/lifecycle-operator/config/webhook/manifests.yaml index b53d4e79421..03e319b23a3 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-v1alpha3-keptntaskdefinition + path: /validate-lifecycle-keptn-sh-v1beta1-keptntaskdefinition failurePolicy: Fail name: vkeptntaskdefinition.kb.io rules: - apiGroups: - lifecycle.keptn.sh apiVersions: - - v1alpha3 + - v1beta1 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 e36f23a086c..8626fcf2027 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" - klcv1alpha3 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3/common" + klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/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) ([]klcv1alpha3.ItemStatus, apicommon.StatusSummary, error) { +// ReconcileEvaluationsFunc: func(ctx context.Context, phaseCtx context.Context, reconcileObject client.Object, evaluationCreateAttributes evaluation.CreateEvaluationAttributes) ([]klcv1beta1.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) ([]klcv1alpha3.ItemStatus, apicommon.StatusSummary, error) + ReconcileEvaluationsFunc func(ctx context.Context, phaseCtx context.Context, reconcileObject client.Object, evaluationCreateAttributes evaluation.CreateEvaluationAttributes) ([]klcv1beta1.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) ([]klcv1alpha3.ItemStatus, apicommon.StatusSummary, error) { +func (mock *MockEvaluationHandler) ReconcileEvaluations(ctx context.Context, phaseCtx context.Context, reconcileObject client.Object, evaluationCreateAttributes evaluation.CreateEvaluationAttributes) ([]klcv1beta1.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 a9b7dad15f5..0974abb2d09 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" - klcv1alpha3 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3/common" + klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/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) ([]klcv1alpha3.ItemStatus, apicommon.StatusSummary, error) + ReconcileEvaluations(ctx context.Context, phaseCtx context.Context, reconcileObject client.Object, evaluationCreateAttributes CreateEvaluationAttributes) ([]klcv1beta1.ItemStatus, apicommon.StatusSummary, error) } type Handler struct { @@ -38,7 +38,7 @@ type Handler struct { type CreateEvaluationAttributes struct { SpanName string - Definition klcv1alpha3.KeptnEvaluationDefinition + Definition klcv1beta1.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) ([]klcv1alpha3.ItemStatus, apicommon.StatusSummary, error) { +func (r Handler) ReconcileEvaluations(ctx context.Context, phaseCtx context.Context, reconcileObject client.Object, evaluationCreateAttributes CreateEvaluationAttributes) ([]klcv1beta1.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 []klcv1alpha3.ItemStatus + var newStatus []klcv1beta1.ItemStatus for _, evaluationName := range evaluations { oldstatus := common.GetOldStatus(evaluationName, statuses) evaluationStatus := common.GetItemStatus(evaluationName, statuses) - evaluation := &klcv1alpha3.KeptnEvaluation{} + evaluation := &klcv1beta1.KeptnEvaluation{} evaluationExists := false if oldstatus != evaluationStatus.Status { @@ -153,7 +153,7 @@ func (r Handler) CreateKeptnEvaluation(ctx context.Context, reconcileObject clie return newEvaluation.Name, nil } -func (r Handler) emitEvaluationFailureEvents(evaluation *klcv1alpha3.KeptnEvaluation, spanTrace trace.Span, piWrapper *interfaces.PhaseItemWrapper) { +func (r Handler) emitEvaluationFailureEvents(evaluation *klcv1beta1.KeptnEvaluation, spanTrace trace.Span, piWrapper *interfaces.PhaseItemWrapper) { k8sEventMessage := "evaluation failed" for k, v := range evaluation.Status.EvaluationStatus { if v.Status == apicommon.StateFailed { @@ -165,9 +165,9 @@ func (r Handler) emitEvaluationFailureEvents(evaluation *klcv1alpha3.KeptnEvalua r.EventSender.Emit(apicommon.PhaseReconcileEvaluation, "Warning", evaluation, apicommon.PhaseStateFailed, k8sEventMessage, piWrapper.GetVersion()) } -func (r Handler) setupEvaluations(evaluationCreateAttributes CreateEvaluationAttributes, piWrapper *interfaces.PhaseItemWrapper) ([]string, []klcv1alpha3.ItemStatus) { +func (r Handler) setupEvaluations(evaluationCreateAttributes CreateEvaluationAttributes, piWrapper *interfaces.PhaseItemWrapper) ([]string, []klcv1beta1.ItemStatus) { var evaluations []string - var statuses []klcv1alpha3.ItemStatus + var statuses []klcv1beta1.ItemStatus switch evaluationCreateAttributes.CheckType { case apicommon.PreDeploymentEvaluationCheckType: @@ -180,7 +180,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 *klcv1alpha3.KeptnEvaluation, evaluationStatus *klcv1alpha3.ItemStatus) error { +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 { evaluationCreateAttributes.Definition.Name = evaluationName evaluationName, err := r.CreateKeptnEvaluation(ctx, reconcileObject, evaluationCreateAttributes) if err != nil { @@ -196,7 +196,7 @@ func (r Handler) handleEvaluationNotExists(ctx context.Context, phaseCtx context return nil } -func (r Handler) handleEvaluationExists(phaseCtx context.Context, piWrapper *interfaces.PhaseItemWrapper, evaluation *klcv1alpha3.KeptnEvaluation, evaluationStatus *klcv1alpha3.ItemStatus) { +func (r Handler) handleEvaluationExists(phaseCtx context.Context, piWrapper *interfaces.PhaseItemWrapper, evaluation *klcv1beta1.KeptnEvaluation, evaluationStatus *klcv1beta1.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 43655bd575c..e3ef967c7ca 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/v1alpha3" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3/common" + "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/eventsender" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/telemetry" telemetryfake "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/telemetry/fake" @@ -29,9 +29,9 @@ func TestEvaluationHandler(t *testing.T) { name string object client.Object createAttr CreateEvaluationAttributes - wantStatus []v1alpha3.ItemStatus + wantStatus []v1beta1.ItemStatus wantSummary apicommon.StatusSummary - evalObj v1alpha3.KeptnEvaluation + evalObj v1beta1.KeptnEvaluation wantErr error getSpanCalls int unbindSpanCalls int @@ -39,8 +39,8 @@ func TestEvaluationHandler(t *testing.T) { }{ { name: "cannot unwrap object", - object: &v1alpha3.KeptnEvaluation{}, - evalObj: v1alpha3.KeptnEvaluation{}, + object: &v1beta1.KeptnEvaluation{}, + evalObj: v1beta1.KeptnEvaluation{}, createAttr: CreateEvaluationAttributes{}, wantStatus: nil, wantSummary: apicommon.StatusSummary{}, @@ -50,18 +50,18 @@ func TestEvaluationHandler(t *testing.T) { }, { name: "no evaluations", - object: &v1alpha3.KeptnAppVersion{}, - evalObj: v1alpha3.KeptnEvaluation{}, + object: &v1beta1.KeptnAppVersion{}, + evalObj: v1beta1.KeptnEvaluation{}, createAttr: CreateEvaluationAttributes{ SpanName: "", - Definition: v1alpha3.KeptnEvaluationDefinition{ + Definition: v1beta1.KeptnEvaluationDefinition{ ObjectMeta: v1.ObjectMeta{ Name: "", }, }, CheckType: apicommon.PreDeploymentEvaluationCheckType, }, - wantStatus: []v1alpha3.ItemStatus(nil), + wantStatus: []v1beta1.ItemStatus(nil), wantSummary: apicommon.StatusSummary{}, wantErr: nil, getSpanCalls: 0, @@ -69,24 +69,24 @@ func TestEvaluationHandler(t *testing.T) { }, { name: "evaluation not started", - object: &v1alpha3.KeptnAppVersion{ - Spec: v1alpha3.KeptnAppVersionSpec{ - KeptnAppSpec: v1alpha3.KeptnAppSpec{ + object: &v1beta1.KeptnAppVersion{ + Spec: v1beta1.KeptnAppVersionSpec{ + KeptnAppSpec: v1beta1.KeptnAppSpec{ PreDeploymentEvaluations: []string{"eval-def"}, }, }, }, - evalObj: v1alpha3.KeptnEvaluation{}, + evalObj: v1beta1.KeptnEvaluation{}, createAttr: CreateEvaluationAttributes{ SpanName: "", - Definition: v1alpha3.KeptnEvaluationDefinition{ + Definition: v1beta1.KeptnEvaluationDefinition{ ObjectMeta: v1.ObjectMeta{ Name: "eval-def", }, }, CheckType: apicommon.PreDeploymentEvaluationCheckType, }, - wantStatus: []v1alpha3.ItemStatus{ + wantStatus: []v1beta1.ItemStatus{ { DefinitionName: "eval-def", Status: apicommon.StatePending, @@ -100,15 +100,15 @@ func TestEvaluationHandler(t *testing.T) { }, { name: "already done evaluation", - object: &v1alpha3.KeptnAppVersion{ - Spec: v1alpha3.KeptnAppVersionSpec{ - KeptnAppSpec: v1alpha3.KeptnAppSpec{ + object: &v1beta1.KeptnAppVersion{ + Spec: v1beta1.KeptnAppVersionSpec{ + KeptnAppSpec: v1beta1.KeptnAppSpec{ PreDeploymentEvaluations: []string{"eval-def"}, }, }, - Status: v1alpha3.KeptnAppVersionStatus{ + Status: v1beta1.KeptnAppVersionStatus{ PreDeploymentEvaluationStatus: apicommon.StateSucceeded, - PreDeploymentEvaluationTaskStatus: []v1alpha3.ItemStatus{ + PreDeploymentEvaluationTaskStatus: []v1beta1.ItemStatus{ { DefinitionName: "eval-def", Status: apicommon.StateSucceeded, @@ -117,17 +117,17 @@ func TestEvaluationHandler(t *testing.T) { }, }, }, - evalObj: v1alpha3.KeptnEvaluation{}, + evalObj: v1beta1.KeptnEvaluation{}, createAttr: CreateEvaluationAttributes{ SpanName: "", - Definition: v1alpha3.KeptnEvaluationDefinition{ + Definition: v1beta1.KeptnEvaluationDefinition{ ObjectMeta: v1.ObjectMeta{ Name: "eval-def", }, }, CheckType: apicommon.PreDeploymentEvaluationCheckType, }, - wantStatus: []v1alpha3.ItemStatus{ + wantStatus: []v1beta1.ItemStatus{ { DefinitionName: "eval-def", Status: apicommon.StateSucceeded, @@ -141,18 +141,18 @@ func TestEvaluationHandler(t *testing.T) { }, { name: "failed evaluation", - object: &v1alpha3.KeptnAppVersion{ + object: &v1beta1.KeptnAppVersion{ ObjectMeta: v1.ObjectMeta{ Namespace: "namespace", }, - Spec: v1alpha3.KeptnAppVersionSpec{ - KeptnAppSpec: v1alpha3.KeptnAppSpec{ + Spec: v1beta1.KeptnAppVersionSpec{ + KeptnAppSpec: v1beta1.KeptnAppSpec{ PreDeploymentEvaluations: []string{"eval-def"}, }, }, - Status: v1alpha3.KeptnAppVersionStatus{ + Status: v1beta1.KeptnAppVersionStatus{ PreDeploymentEvaluationStatus: apicommon.StateSucceeded, - PreDeploymentEvaluationTaskStatus: []v1alpha3.ItemStatus{ + PreDeploymentEvaluationTaskStatus: []v1beta1.ItemStatus{ { DefinitionName: "eval-def", Status: apicommon.StateProgressing, @@ -161,14 +161,14 @@ func TestEvaluationHandler(t *testing.T) { }, }, }, - evalObj: v1alpha3.KeptnEvaluation{ + evalObj: v1beta1.KeptnEvaluation{ ObjectMeta: v1.ObjectMeta{ Namespace: "namespace", Name: "pre-eval-eval-def-", }, - Status: v1alpha3.KeptnEvaluationStatus{ + Status: v1beta1.KeptnEvaluationStatus{ OverallStatus: apicommon.StateFailed, - EvaluationStatus: map[string]v1alpha3.EvaluationStatusItem{ + EvaluationStatus: map[string]v1beta1.EvaluationStatusItem{ "my-target": { Value: "1", Status: apicommon.StateFailed, @@ -179,14 +179,14 @@ func TestEvaluationHandler(t *testing.T) { }, createAttr: CreateEvaluationAttributes{ SpanName: "", - Definition: v1alpha3.KeptnEvaluationDefinition{ + Definition: v1beta1.KeptnEvaluationDefinition{ ObjectMeta: v1.ObjectMeta{ Name: "eval-def", }, }, CheckType: apicommon.PreDeploymentEvaluationCheckType, }, - wantStatus: []v1alpha3.ItemStatus{ + wantStatus: []v1beta1.ItemStatus{ { DefinitionName: "eval-def", Status: apicommon.StateFailed, @@ -203,18 +203,18 @@ func TestEvaluationHandler(t *testing.T) { }, { name: "succeeded evaluation", - object: &v1alpha3.KeptnAppVersion{ + object: &v1beta1.KeptnAppVersion{ ObjectMeta: v1.ObjectMeta{ Namespace: "namespace", }, - Spec: v1alpha3.KeptnAppVersionSpec{ - KeptnAppSpec: v1alpha3.KeptnAppSpec{ + Spec: v1beta1.KeptnAppVersionSpec{ + KeptnAppSpec: v1beta1.KeptnAppSpec{ PreDeploymentEvaluations: []string{"eval-def"}, }, }, - Status: v1alpha3.KeptnAppVersionStatus{ + Status: v1beta1.KeptnAppVersionStatus{ PreDeploymentEvaluationStatus: apicommon.StateSucceeded, - PreDeploymentEvaluationTaskStatus: []v1alpha3.ItemStatus{ + PreDeploymentEvaluationTaskStatus: []v1beta1.ItemStatus{ { DefinitionName: "eval-def", Status: apicommon.StateProgressing, @@ -223,25 +223,25 @@ func TestEvaluationHandler(t *testing.T) { }, }, }, - evalObj: v1alpha3.KeptnEvaluation{ + evalObj: v1beta1.KeptnEvaluation{ ObjectMeta: v1.ObjectMeta{ Namespace: "namespace", Name: "pre-eval-eval-def-", }, - Status: v1alpha3.KeptnEvaluationStatus{ + Status: v1beta1.KeptnEvaluationStatus{ OverallStatus: apicommon.StateSucceeded, }, }, createAttr: CreateEvaluationAttributes{ SpanName: "", - Definition: v1alpha3.KeptnEvaluationDefinition{ + Definition: v1beta1.KeptnEvaluationDefinition{ ObjectMeta: v1.ObjectMeta{ Name: "eval-def", }, }, CheckType: apicommon.PreDeploymentEvaluationCheckType, }, - wantStatus: []v1alpha3.ItemStatus{ + wantStatus: []v1beta1.ItemStatus{ { DefinitionName: "eval-def", Status: apicommon.StateSucceeded, @@ -257,7 +257,7 @@ func TestEvaluationHandler(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - err := v1alpha3.AddToScheme(scheme.Scheme) + err := v1beta1.AddToScheme(scheme.Scheme) require.Nil(t, err) spanHandlerMock := telemetryfake.ISpanHandlerMock{ GetSpanFunc: func(ctx context.Context, tracer telemetry.ITracer, reconcileObject client.Object, phase string) (context.Context, trace.Span, error) { @@ -313,26 +313,26 @@ func TestEvaluationHandler_createEvaluation(t *testing.T) { }{ { name: "cannot unwrap object", - object: &v1alpha3.KeptnEvaluation{}, + object: &v1beta1.KeptnEvaluation{}, createAttr: CreateEvaluationAttributes{}, wantName: "", wantErr: controllererrors.ErrCannotWrapToPhaseItem, }, { name: "created evaluation", - object: &v1alpha3.KeptnAppVersion{ + object: &v1beta1.KeptnAppVersion{ ObjectMeta: v1.ObjectMeta{ Namespace: "namespace", }, - Spec: v1alpha3.KeptnAppVersionSpec{ - KeptnAppSpec: v1alpha3.KeptnAppSpec{ + Spec: v1beta1.KeptnAppVersionSpec{ + KeptnAppSpec: v1beta1.KeptnAppSpec{ PreDeploymentEvaluations: []string{"eval-def"}, }, }, }, createAttr: CreateEvaluationAttributes{ SpanName: "", - Definition: v1alpha3.KeptnEvaluationDefinition{ + Definition: v1beta1.KeptnEvaluationDefinition{ ObjectMeta: v1.ObjectMeta{ Name: "eval-def", }, @@ -346,7 +346,7 @@ func TestEvaluationHandler_createEvaluation(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - err := v1alpha3.AddToScheme(scheme.Scheme) + err := v1beta1.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 ef70d2d462e..d8898f317a6 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/v1alpha3/common" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/config" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/lifecycle/interfaces" diff --git a/lifecycle-operator/controllers/common/eventsender/eventsender_test.go b/lifecycle-operator/controllers/common/eventsender/eventsender_test.go index dcf727e52c2..f8e12493354 100644 --- a/lifecycle-operator/controllers/common/eventsender/eventsender_test.go +++ b/lifecycle-operator/controllers/common/eventsender/eventsender_test.go @@ -10,9 +10,8 @@ import ( "time" ce "github.com/cloudevents/sdk-go/v2" - "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3" - "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3/common" - "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha4" + "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" + "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/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" @@ -27,7 +26,7 @@ func TestEventSender_SendK8sEvent(t *testing.T) { fakeRecorder := record.NewFakeRecorder(100) eventSender := NewK8sSender(fakeRecorder) - eventSender.Emit(common.PhaseAppDeployment, "pre-event", &v1alpha3.KeptnAppVersion{ + eventSender.Emit(common.PhaseAppDeployment, "pre-event", &v1beta1.KeptnAppVersion{ ObjectMeta: v1.ObjectMeta{ Name: "app", Namespace: "ns", @@ -78,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, &v1alpha3.KeptnAppVersion{ + ceSender.Emit(phase, eventType, &v1beta1.KeptnAppVersion{ ObjectMeta: v1.ObjectMeta{ Name: name, Namespace: ns, @@ -126,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", &v1alpha3.KeptnAppVersion{ + ceSender.Emit(common.PhaseAppCompleted, "type", &v1beta1.KeptnAppVersion{ ObjectMeta: v1.ObjectMeta{ Name: "app", Namespace: "ns", @@ -230,7 +229,7 @@ func Test_setEventMessage(t *testing.T) { }, } - appVersion := &v1alpha3.KeptnAppVersion{ + appVersion := &v1beta1.KeptnAppVersion{ ObjectMeta: v1.ObjectMeta{ Name: "app", Namespace: "namespace", @@ -256,12 +255,12 @@ func Test_setAnnotations(t *testing.T) { }, { name: "empty object", - object: &v1alpha3.KeptnEvaluationDefinition{}, + object: &v1beta1.KeptnEvaluationDefinition{}, want: nil, }, { name: "unknown object", - object: &v1alpha3.KeptnEvaluationDefinition{ + object: &v1beta1.KeptnEvaluationDefinition{ ObjectMeta: v1.ObjectMeta{ Name: "def", Namespace: "namespace", @@ -276,7 +275,7 @@ func Test_setAnnotations(t *testing.T) { }, { name: "object with traceparent", - object: &v1alpha3.KeptnEvaluationDefinition{ + object: &v1beta1.KeptnEvaluationDefinition{ ObjectMeta: v1.ObjectMeta{ Name: "def", Namespace: "namespace", @@ -294,13 +293,13 @@ func Test_setAnnotations(t *testing.T) { }, { name: "KeptnApp", - object: &v1alpha3.KeptnApp{ + object: &v1beta1.KeptnApp{ ObjectMeta: v1.ObjectMeta{ Name: "app", Namespace: "namespace", Generation: 1, }, - Spec: v1alpha3.KeptnAppSpec{ + Spec: v1beta1.KeptnAppSpec{ Version: "1.0.0", }, }, @@ -316,14 +315,14 @@ func Test_setAnnotations(t *testing.T) { }, { name: "KeptnAppVersion", - object: &v1alpha3.KeptnAppVersion{ + object: &v1beta1.KeptnAppVersion{ ObjectMeta: v1.ObjectMeta{ Name: "appVersion", Namespace: "namespace", }, - Spec: v1alpha3.KeptnAppVersionSpec{ + Spec: v1beta1.KeptnAppVersionSpec{ AppName: "app", - KeptnAppSpec: v1alpha3.KeptnAppSpec{ + KeptnAppSpec: v1beta1.KeptnAppSpec{ Version: "1.0.0", }, }, @@ -340,12 +339,12 @@ func Test_setAnnotations(t *testing.T) { }, { name: "KeptnWorkload", - object: &v1alpha3.KeptnWorkload{ + object: &v1beta1.KeptnWorkload{ ObjectMeta: v1.ObjectMeta{ Name: "workload", Namespace: "namespace", }, - Spec: v1alpha3.KeptnWorkloadSpec{ + Spec: v1beta1.KeptnWorkloadSpec{ AppName: "app", Version: "1.0.0", }, @@ -362,13 +361,13 @@ func Test_setAnnotations(t *testing.T) { }, { name: "KeptnWorkloadVersion", - object: &v1alpha4.KeptnWorkloadVersion{ + object: &v1beta1.KeptnWorkloadVersion{ ObjectMeta: v1.ObjectMeta{ Name: "workloadVersion", Namespace: "namespace", }, - Spec: v1alpha4.KeptnWorkloadVersionSpec{ - KeptnWorkloadSpec: v1alpha3.KeptnWorkloadSpec{ + Spec: v1beta1.KeptnWorkloadVersionSpec{ + KeptnWorkloadSpec: v1beta1.KeptnWorkloadSpec{ AppName: "app", Version: "1.0.0", }, @@ -388,14 +387,14 @@ func Test_setAnnotations(t *testing.T) { }, { name: "KeptnTask", - object: &v1alpha3.KeptnTask{ + object: &v1beta1.KeptnTask{ ObjectMeta: v1.ObjectMeta{ Name: "task", Namespace: "namespace", }, - Spec: v1alpha3.KeptnTaskSpec{ + Spec: v1beta1.KeptnTaskSpec{ TaskDefinition: "def", - Context: v1alpha3.TaskContext{ + Context: v1beta1.TaskContext{ WorkloadName: "workload", AppName: "app", AppVersion: "1.0.0", @@ -418,12 +417,12 @@ func Test_setAnnotations(t *testing.T) { }, { name: "KeptnEvaluation", - object: &v1alpha3.KeptnEvaluation{ + object: &v1beta1.KeptnEvaluation{ ObjectMeta: v1.ObjectMeta{ Name: "eval", Namespace: "namespace", }, - Spec: v1alpha3.KeptnEvaluationSpec{ + Spec: v1beta1.KeptnEvaluationSpec{ AppName: "app", AppVersion: "1.0.0", Workload: "workload", diff --git a/lifecycle-operator/controllers/common/eventsender/fake/event_mock.go b/lifecycle-operator/controllers/common/eventsender/fake/event_mock.go index 78b7cb7563a..40196168425 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/v1alpha3/common" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/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 0bbeab69795..4d3fd0d10ee 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" - klcv1alpha3 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3/common" + klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/config" k8serrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/types" @@ -15,13 +15,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 []klcv1alpha3.ItemStatus) klcv1alpha3.ItemStatus { +func GetItemStatus(name string, instanceStatus []klcv1beta1.ItemStatus) klcv1beta1.ItemStatus { for _, status := range instanceStatus { if status.DefinitionName == name { return status } } - return klcv1alpha3.ItemStatus{ + return klcv1beta1.ItemStatus{ DefinitionName: name, Status: apicommon.StatePending, Name: "", @@ -29,7 +29,7 @@ func GetItemStatus(name string, instanceStatus []klcv1alpha3.ItemStatus) klcv1al } // GetOldStatus retrieves the state of the task/evaluation -func GetOldStatus(name string, statuses []klcv1alpha3.ItemStatus) apicommon.KeptnState { +func GetOldStatus(name string, statuses []klcv1beta1.ItemStatus) apicommon.KeptnState { var oldstatus apicommon.KeptnState for _, ts := range statuses { if ts.DefinitionName == name { @@ -46,16 +46,16 @@ func CopyMap[M1 ~map[K]V, M2 ~map[K]V, K comparable, V any](dst M1, src M2) { } } -func GetTaskDefinition(k8sclient client.Client, log logr.Logger, ctx context.Context, definitionName string, namespace string) (*klcv1alpha3.KeptnTaskDefinition, error) { - definition := &klcv1alpha3.KeptnTaskDefinition{} +func GetTaskDefinition(k8sclient client.Client, log logr.Logger, ctx context.Context, definitionName string, namespace string) (*klcv1beta1.KeptnTaskDefinition, error) { + definition := &klcv1beta1.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) (*klcv1alpha3.KeptnEvaluationDefinition, error) { - definition := &klcv1alpha3.KeptnEvaluationDefinition{} +func GetEvaluationDefinition(k8sclient client.Client, log logr.Logger, ctx context.Context, definitionName string, namespace string) (*klcv1beta1.KeptnEvaluationDefinition, error) { + definition := &klcv1beta1.KeptnEvaluationDefinition{} if err := getObject(k8sclient, log, ctx, definitionName, namespace, definition); err != nil { return nil, err } diff --git a/lifecycle-operator/controllers/common/helperfunctions_test.go b/lifecycle-operator/controllers/common/helperfunctions_test.go index 191539a9aa0..cf66d63f2a7 100644 --- a/lifecycle-operator/controllers/common/helperfunctions_test.go +++ b/lifecycle-operator/controllers/common/helperfunctions_test.go @@ -4,8 +4,8 @@ import ( "context" "testing" - klcv1alpha3 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3/common" + klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/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" @@ -19,19 +19,19 @@ import ( func Test_GetItemStatus(t *testing.T) { tests := []struct { name string - inStatus []klcv1alpha3.ItemStatus - want klcv1alpha3.ItemStatus + inStatus []klcv1beta1.ItemStatus + want klcv1beta1.ItemStatus }{ { name: "non-existing", - inStatus: []klcv1alpha3.ItemStatus{ + inStatus: []klcv1beta1.ItemStatus{ { DefinitionName: "def-name", Name: "name", Status: apicommon.StatePending, }, }, - want: klcv1alpha3.ItemStatus{ + want: klcv1beta1.ItemStatus{ DefinitionName: "non-existing", Status: apicommon.StatePending, Name: "", @@ -39,14 +39,14 @@ func Test_GetItemStatus(t *testing.T) { }, { name: "def-name", - inStatus: []klcv1alpha3.ItemStatus{ + inStatus: []klcv1beta1.ItemStatus{ { DefinitionName: "def-name", Name: "name", Status: apicommon.StateProgressing, }, }, - want: klcv1alpha3.ItemStatus{ + want: klcv1beta1.ItemStatus{ DefinitionName: "def-name", Name: "name", Status: apicommon.StateProgressing, @@ -54,8 +54,8 @@ func Test_GetItemStatus(t *testing.T) { }, { name: "empty", - inStatus: []klcv1alpha3.ItemStatus{}, - want: klcv1alpha3.ItemStatus{ + inStatus: []klcv1beta1.ItemStatus{}, + want: klcv1beta1.ItemStatus{ DefinitionName: "empty", Status: apicommon.StatePending, Name: "", @@ -72,22 +72,22 @@ func Test_GetItemStatus(t *testing.T) { func Test_GetOldStatus(t *testing.T) { tests := []struct { - statuses []klcv1alpha3.ItemStatus + statuses []klcv1beta1.ItemStatus definitionName string want apicommon.KeptnState }{ { - statuses: []klcv1alpha3.ItemStatus{}, + statuses: []klcv1beta1.ItemStatus{}, definitionName: "", want: "", }, { - statuses: []klcv1alpha3.ItemStatus{}, + statuses: []klcv1beta1.ItemStatus{}, definitionName: "defName", want: "", }, { - statuses: []klcv1alpha3.ItemStatus{ + statuses: []klcv1beta1.ItemStatus{ { DefinitionName: "defName", Status: apicommon.StateFailed, @@ -98,7 +98,7 @@ func Test_GetOldStatus(t *testing.T) { want: "", }, { - statuses: []klcv1alpha3.ItemStatus{ + statuses: []klcv1beta1.ItemStatus{ { DefinitionName: "defName", Status: apicommon.StateFailed, @@ -121,15 +121,15 @@ func Test_GetOldStatus(t *testing.T) { func Test_GetTaskDefinition(t *testing.T) { tests := []struct { name string - taskDef *klcv1alpha3.KeptnTaskDefinition + taskDef *klcv1beta1.KeptnTaskDefinition taskDefName string taskDefNamespace string - out *klcv1alpha3.KeptnTaskDefinition + out *klcv1beta1.KeptnTaskDefinition wantError bool }{ { name: "taskDef not found", - taskDef: &klcv1alpha3.KeptnTaskDefinition{ + taskDef: &klcv1beta1.KeptnTaskDefinition{ ObjectMeta: v1.ObjectMeta{ Name: "taskDef", Namespace: "some-other-namespace", @@ -142,7 +142,7 @@ func Test_GetTaskDefinition(t *testing.T) { }, { name: "taskDef found", - taskDef: &klcv1alpha3.KeptnTaskDefinition{ + taskDef: &klcv1beta1.KeptnTaskDefinition{ ObjectMeta: v1.ObjectMeta{ Name: "taskDef", Namespace: "some-namespace", @@ -150,7 +150,7 @@ func Test_GetTaskDefinition(t *testing.T) { }, taskDefName: "taskDef", taskDefNamespace: "some-namespace", - out: &klcv1alpha3.KeptnTaskDefinition{ + out: &klcv1beta1.KeptnTaskDefinition{ ObjectMeta: v1.ObjectMeta{ Name: "taskDef", Namespace: "some-namespace", @@ -160,7 +160,7 @@ func Test_GetTaskDefinition(t *testing.T) { }, { name: "taskDef found in default Keptn namespace", - taskDef: &klcv1alpha3.KeptnTaskDefinition{ + taskDef: &klcv1beta1.KeptnTaskDefinition{ ObjectMeta: v1.ObjectMeta{ Name: "taskDef", Namespace: testcommon.KeptnNamespace, @@ -168,7 +168,7 @@ func Test_GetTaskDefinition(t *testing.T) { }, taskDefName: "taskDef", taskDefNamespace: "some-namespace", - out: &klcv1alpha3.KeptnTaskDefinition{ + out: &klcv1beta1.KeptnTaskDefinition{ ObjectMeta: v1.ObjectMeta{ Name: "taskDef", Namespace: testcommon.KeptnNamespace, @@ -178,7 +178,7 @@ func Test_GetTaskDefinition(t *testing.T) { }, } - err := klcv1alpha3.AddToScheme(scheme.Scheme) + err := klcv1beta1.AddToScheme(scheme.Scheme) require.Nil(t, err) config.Instance().SetDefaultNamespace(testcommon.KeptnNamespace) @@ -205,15 +205,15 @@ func Test_GetTaskDefinition(t *testing.T) { func Test_GetEvaluationDefinition(t *testing.T) { tests := []struct { name string - evalDef *klcv1alpha3.KeptnEvaluationDefinition + evalDef *klcv1beta1.KeptnEvaluationDefinition evalDefName string evalDefNamespace string - out *klcv1alpha3.KeptnEvaluationDefinition + out *klcv1beta1.KeptnEvaluationDefinition wantError bool }{ { name: "evalDef not found", - evalDef: &klcv1alpha3.KeptnEvaluationDefinition{ + evalDef: &klcv1beta1.KeptnEvaluationDefinition{ ObjectMeta: v1.ObjectMeta{ Name: "evalDef", Namespace: "some-other-namespace", @@ -226,7 +226,7 @@ func Test_GetEvaluationDefinition(t *testing.T) { }, { name: "evalDef found", - evalDef: &klcv1alpha3.KeptnEvaluationDefinition{ + evalDef: &klcv1beta1.KeptnEvaluationDefinition{ ObjectMeta: v1.ObjectMeta{ Name: "evalDef", Namespace: "some-namespace", @@ -234,7 +234,7 @@ func Test_GetEvaluationDefinition(t *testing.T) { }, evalDefName: "evalDef", evalDefNamespace: "some-namespace", - out: &klcv1alpha3.KeptnEvaluationDefinition{ + out: &klcv1beta1.KeptnEvaluationDefinition{ ObjectMeta: v1.ObjectMeta{ Name: "evalDef", Namespace: "some-namespace", @@ -244,7 +244,7 @@ func Test_GetEvaluationDefinition(t *testing.T) { }, { name: "evalDef found in default Keptn namespace", - evalDef: &klcv1alpha3.KeptnEvaluationDefinition{ + evalDef: &klcv1beta1.KeptnEvaluationDefinition{ ObjectMeta: v1.ObjectMeta{ Name: "evalDef", Namespace: testcommon.KeptnNamespace, @@ -252,7 +252,7 @@ func Test_GetEvaluationDefinition(t *testing.T) { }, evalDefName: "evalDef", evalDefNamespace: "some-namespace", - out: &klcv1alpha3.KeptnEvaluationDefinition{ + out: &klcv1beta1.KeptnEvaluationDefinition{ ObjectMeta: v1.ObjectMeta{ Name: "evalDef", Namespace: testcommon.KeptnNamespace, @@ -262,7 +262,7 @@ func Test_GetEvaluationDefinition(t *testing.T) { }, } - err := klcv1alpha3.AddToScheme(scheme.Scheme) + err := klcv1beta1.AddToScheme(scheme.Scheme) require.Nil(t, err) config.Instance().SetDefaultNamespace(testcommon.KeptnNamespace) diff --git a/lifecycle-operator/controllers/common/phase/fake/handler_mock.go b/lifecycle-operator/controllers/common/phase/fake/handler_mock.go index 4e70a216c54..428dd3baf78 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/v1alpha3/common" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/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 3551ef05968..fb144d8050f 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/v1alpha3/common" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/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 d2833e21edd..4ae55ccb4c0 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/v1alpha3" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3/common" + "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/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 *v1alpha3.KeptnAppVersion + object *v1beta1.KeptnAppVersion phase apicommon.KeptnPhaseType reconcilePhase func(phaseCtx context.Context) (apicommon.KeptnState, error) - wantObject *v1alpha3.KeptnAppVersion + wantObject *v1beta1.KeptnAppVersion want PhaseResult wantErr error endTimeSet bool @@ -37,15 +37,15 @@ func TestHandler(t *testing.T) { handler: Handler{ SpanHandler: &telemetry.Handler{}, }, - object: &v1alpha3.KeptnAppVersion{ - Status: v1alpha3.KeptnAppVersionStatus{ + object: &v1beta1.KeptnAppVersion{ + Status: v1beta1.KeptnAppVersionStatus{ Status: apicommon.StateDeprecated, }, }, want: PhaseResult{Continue: false, Result: ctrl.Result{}}, wantErr: nil, - wantObject: &v1alpha3.KeptnAppVersion{ - Status: v1alpha3.KeptnAppVersionStatus{ + wantObject: &v1beta1.KeptnAppVersion{ + Status: v1beta1.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: &v1alpha3.KeptnAppVersion{ - Status: v1alpha3.KeptnAppVersionStatus{ + object: &v1beta1.KeptnAppVersion{ + Status: v1beta1.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: &v1alpha3.KeptnAppVersion{ - Status: v1alpha3.KeptnAppVersionStatus{ + wantObject: &v1beta1.KeptnAppVersion{ + Status: v1beta1.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: &v1alpha3.KeptnAppVersion{ - Status: v1alpha3.KeptnAppVersionStatus{ + object: &v1beta1.KeptnAppVersion{ + Status: v1beta1.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: &v1alpha3.KeptnAppVersion{ - Status: v1alpha3.KeptnAppVersionStatus{ + wantObject: &v1beta1.KeptnAppVersion{ + Status: v1beta1.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: &v1alpha3.KeptnAppVersion{ - Status: v1alpha3.KeptnAppVersionStatus{ + object: &v1beta1.KeptnAppVersion{ + Status: v1beta1.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: &v1alpha3.KeptnAppVersion{ - Status: v1alpha3.KeptnAppVersionStatus{ + wantObject: &v1beta1.KeptnAppVersion{ + Status: v1beta1.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: &v1alpha3.KeptnAppVersion{ - Status: v1alpha3.KeptnAppVersionStatus{ + object: &v1beta1.KeptnAppVersion{ + Status: v1beta1.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: &v1alpha3.KeptnAppVersion{ - Status: v1alpha3.KeptnAppVersionStatus{ + wantObject: &v1beta1.KeptnAppVersion{ + Status: v1beta1.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: &v1alpha3.KeptnAppVersion{ - Status: v1alpha3.KeptnAppVersionStatus{ + object: &v1beta1.KeptnAppVersion{ + Status: v1beta1.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: &v1alpha3.KeptnAppVersion{ - Status: v1alpha3.KeptnAppVersionStatus{ + wantObject: &v1beta1.KeptnAppVersion{ + Status: v1beta1.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: &v1alpha3.KeptnAppVersion{ - Status: v1alpha3.KeptnAppVersionStatus{ + object: &v1beta1.KeptnAppVersion{ + Status: v1beta1.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: &v1alpha3.KeptnAppVersion{ - Status: v1alpha3.KeptnAppVersionStatus{ + wantObject: &v1beta1.KeptnAppVersion{ + Status: v1beta1.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 85770aaeb81..0855dd40188 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" - klcv1alpha3 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3" + klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" "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 klcv1alpha3.Objective, namespace string) (string, []byte, error) { +func (p *KeptnMetricProvider) FetchData(ctx context.Context, objective klcv1beta1.Objective, namespace string) (string, []byte, error) { metric, err := p.GetKeptnMetric(ctx, objective, namespace) if err != nil { return "", nil, err @@ -41,11 +41,11 @@ func (p *KeptnMetricProvider) FetchData(ctx context.Context, objective klcv1alph return value, []byte(rawValue), nil } -func (p *KeptnMetricProvider) GetKeptnMetric(ctx context.Context, objective klcv1alpha3.Objective, namespace string) (*unstructured.Unstructured, error) { +func (p *KeptnMetricProvider) GetKeptnMetric(ctx context.Context, objective klcv1beta1.Objective, namespace string) (*unstructured.Unstructured, error) { metric := &unstructured.Unstructured{ Object: map[string]interface{}{ "kind": "KeptnMetric", - "apiVersion": "metrics.keptn.sh/v1alpha3", + "apiVersion": "metrics.keptn.sh/v1beta1", }, } diff --git a/lifecycle-operator/controllers/common/providers/keptnmetric/keptnmetric_test.go b/lifecycle-operator/controllers/common/providers/keptnmetric/keptnmetric_test.go index 2acbcfff11e..24f7a802c57 100644 --- a/lifecycle-operator/controllers/common/providers/keptnmetric/keptnmetric_test.go +++ b/lifecycle-operator/controllers/common/providers/keptnmetric/keptnmetric_test.go @@ -4,10 +4,10 @@ import ( "context" "testing" - klcv1alpha3 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3" + klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" "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/v1alpha3" + metricsapi "github.com/keptn/lifecycle-toolkit/lifecycle-operator/test/api/metrics/v1beta1" "github.com/stretchr/testify/require" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" @@ -88,8 +88,8 @@ func Test_keptnmetric(t *testing.T) { K8sClient: client, } - obj := klcv1alpha3.Objective{ - KeptnMetricRef: klcv1alpha3.KeptnMetricReference{ + obj := klcv1beta1.Objective{ + KeptnMetricRef: klcv1beta1.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 klcv1alpha3.Objective + objective klcv1beta1.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: klcv1alpha3.Objective{ - KeptnMetricRef: klcv1alpha3.KeptnMetricReference{ + objective: klcv1beta1.Objective{ + KeptnMetricRef: klcv1beta1.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: klcv1alpha3.Objective{ - KeptnMetricRef: klcv1alpha3.KeptnMetricReference{ + objective: klcv1beta1.Objective{ + KeptnMetricRef: klcv1beta1.KeptnMetricReference{ Name: "metric", Namespace: "my-namespace", }, @@ -159,8 +159,8 @@ func Test_Getkeptnmetric(t *testing.T) { }, { name: "objective without namespace and existing keptnmetric", - objective: klcv1alpha3.Objective{ - KeptnMetricRef: klcv1alpha3.KeptnMetricReference{ + objective: klcv1beta1.Objective{ + KeptnMetricRef: klcv1beta1.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: klcv1alpha3.Objective{ - KeptnMetricRef: klcv1alpha3.KeptnMetricReference{ + objective: klcv1beta1.Objective{ + KeptnMetricRef: klcv1beta1.KeptnMetricReference{ Name: "metric", }, }, diff --git a/lifecycle-operator/controllers/common/schedulinggates/fake/schedulinggateshandler_mock.go b/lifecycle-operator/controllers/common/schedulinggates/fake/schedulinggateshandler_mock.go index 4bc32d856ad..b25a7adba83 100644 --- a/lifecycle-operator/controllers/common/schedulinggates/fake/schedulinggateshandler_mock.go +++ b/lifecycle-operator/controllers/common/schedulinggates/fake/schedulinggateshandler_mock.go @@ -5,7 +5,7 @@ package fake import ( "context" - klcv1alpha4 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha4" + klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" "sync" ) @@ -18,7 +18,7 @@ import ( // EnabledFunc: func() bool { // panic("mock out the Enabled method") // }, -// RemoveGatesFunc: func(ctx context.Context, workloadVersion *klcv1alpha4.KeptnWorkloadVersion) error { +// RemoveGatesFunc: func(ctx context.Context, workloadVersion *klcv1beta1.KeptnWorkloadVersion) error { // panic("mock out the RemoveGates method") // }, // } @@ -32,7 +32,7 @@ type ISchedulingGatesHandlerMock struct { EnabledFunc func() bool // RemoveGatesFunc mocks the RemoveGates method. - RemoveGatesFunc func(ctx context.Context, workloadVersion *klcv1alpha4.KeptnWorkloadVersion) error + RemoveGatesFunc func(ctx context.Context, workloadVersion *klcv1beta1.KeptnWorkloadVersion) error // calls tracks calls to the methods. calls struct { @@ -44,7 +44,7 @@ type ISchedulingGatesHandlerMock struct { // Ctx is the ctx argument value. Ctx context.Context // WorkloadVersion is the workloadVersion argument value. - WorkloadVersion *klcv1alpha4.KeptnWorkloadVersion + WorkloadVersion *klcv1beta1.KeptnWorkloadVersion } } lockEnabled sync.RWMutex @@ -79,13 +79,13 @@ func (mock *ISchedulingGatesHandlerMock) EnabledCalls() []struct { } // RemoveGates calls RemoveGatesFunc. -func (mock *ISchedulingGatesHandlerMock) RemoveGates(ctx context.Context, workloadVersion *klcv1alpha4.KeptnWorkloadVersion) error { +func (mock *ISchedulingGatesHandlerMock) RemoveGates(ctx context.Context, workloadVersion *klcv1beta1.KeptnWorkloadVersion) error { if mock.RemoveGatesFunc == nil { panic("ISchedulingGatesHandlerMock.RemoveGatesFunc: method is nil but ISchedulingGatesHandler.RemoveGates was just called") } callInfo := struct { Ctx context.Context - WorkloadVersion *klcv1alpha4.KeptnWorkloadVersion + WorkloadVersion *klcv1beta1.KeptnWorkloadVersion }{ Ctx: ctx, WorkloadVersion: workloadVersion, @@ -102,11 +102,11 @@ func (mock *ISchedulingGatesHandlerMock) RemoveGates(ctx context.Context, worklo // len(mockedISchedulingGatesHandler.RemoveGatesCalls()) func (mock *ISchedulingGatesHandlerMock) RemoveGatesCalls() []struct { Ctx context.Context - WorkloadVersion *klcv1alpha4.KeptnWorkloadVersion + WorkloadVersion *klcv1beta1.KeptnWorkloadVersion } { var calls []struct { Ctx context.Context - WorkloadVersion *klcv1alpha4.KeptnWorkloadVersion + WorkloadVersion *klcv1beta1.KeptnWorkloadVersion } mock.lockRemoveGates.RLock() calls = mock.calls.RemoveGates diff --git a/lifecycle-operator/controllers/common/schedulinggates/handler.go b/lifecycle-operator/controllers/common/schedulinggates/handler.go index 12cdeff4fa8..28016ec2217 100644 --- a/lifecycle-operator/controllers/common/schedulinggates/handler.go +++ b/lifecycle-operator/controllers/common/schedulinggates/handler.go @@ -4,8 +4,8 @@ import ( "context" "github.com/go-logr/logr" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3/common" - klcv1alpha4 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha4" + klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" controllererrors "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/errors" v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/types" @@ -14,7 +14,7 @@ import ( //go:generate moq -pkg fake -skip-ensure -out ./fake/schedulinggateshandler_mock.go . ISchedulingGatesHandler type ISchedulingGatesHandler interface { - RemoveGates(ctx context.Context, workloadVersion *klcv1alpha4.KeptnWorkloadVersion) error + RemoveGates(ctx context.Context, workloadVersion *klcv1beta1.KeptnWorkloadVersion) error Enabled() bool } @@ -39,7 +39,7 @@ func NewHandler(c client.Client, l logr.Logger, enabled bool) *Handler { } } -func (h *Handler) RemoveGates(ctx context.Context, workloadVersion *klcv1alpha4.KeptnWorkloadVersion) error { +func (h *Handler) RemoveGates(ctx context.Context, workloadVersion *klcv1beta1.KeptnWorkloadVersion) error { switch workloadVersion.Spec.ResourceReference.Kind { case "Pod": return h.removeGates(ctx, h.Client, workloadVersion.Spec.ResourceReference.Name, workloadVersion.Namespace) diff --git a/lifecycle-operator/controllers/common/schedulinggates/handler_test.go b/lifecycle-operator/controllers/common/schedulinggates/handler_test.go index 229301d037a..cb9b10ea4d4 100644 --- a/lifecycle-operator/controllers/common/schedulinggates/handler_test.go +++ b/lifecycle-operator/controllers/common/schedulinggates/handler_test.go @@ -5,9 +5,8 @@ import ( "fmt" "testing" - klcv1alpha3 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3/common" - klcv1alpha4 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha4" + klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" controllererrors "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/errors" "github.com/stretchr/testify/require" corev1 "k8s.io/api/core/v1" @@ -102,7 +101,7 @@ func Test_RemovePodGates(t *testing.T) { }, } - err := klcv1alpha3.AddToScheme(scheme.Scheme) + err := klcv1beta1.AddToScheme(scheme.Scheme) require.Nil(t, err) for _, tt := range tests { @@ -195,7 +194,7 @@ func Test_GetPodsOfOwner(t *testing.T) { }, } - err := klcv1alpha3.AddToScheme(scheme.Scheme) + err := klcv1beta1.AddToScheme(scheme.Scheme) require.Nil(t, err) for _, tt := range tests { @@ -224,16 +223,16 @@ func Test_SchedulingGatesHandler_IsSchedulingGatesEnabledRemoveGates(t *testing. tests := []struct { name string handler Handler - wi *klcv1alpha4.KeptnWorkloadVersion + wi *klcv1beta1.KeptnWorkloadVersion wantErr error }{ { name: "unsuported resource ref", handler: Handler{}, - wi: &klcv1alpha4.KeptnWorkloadVersion{ - Spec: klcv1alpha4.KeptnWorkloadVersionSpec{ - KeptnWorkloadSpec: klcv1alpha3.KeptnWorkloadSpec{ - ResourceReference: klcv1alpha3.ResourceReference{ + wi: &klcv1beta1.KeptnWorkloadVersion{ + Spec: klcv1beta1.KeptnWorkloadVersionSpec{ + KeptnWorkloadSpec: klcv1beta1.KeptnWorkloadSpec{ + ResourceReference: klcv1beta1.ResourceReference{ Kind: "unsupported", }, }, @@ -248,10 +247,10 @@ func Test_SchedulingGatesHandler_IsSchedulingGatesEnabledRemoveGates(t *testing. return nil }, }, - wi: &klcv1alpha4.KeptnWorkloadVersion{ - Spec: klcv1alpha4.KeptnWorkloadVersionSpec{ - KeptnWorkloadSpec: klcv1alpha3.KeptnWorkloadSpec{ - ResourceReference: klcv1alpha3.ResourceReference{ + wi: &klcv1beta1.KeptnWorkloadVersion{ + Spec: klcv1beta1.KeptnWorkloadVersionSpec{ + KeptnWorkloadSpec: klcv1beta1.KeptnWorkloadSpec{ + ResourceReference: klcv1beta1.ResourceReference{ Kind: "Pod", }, }, @@ -266,10 +265,10 @@ func Test_SchedulingGatesHandler_IsSchedulingGatesEnabledRemoveGates(t *testing. return fmt.Errorf("pod") }, }, - wi: &klcv1alpha4.KeptnWorkloadVersion{ - Spec: klcv1alpha4.KeptnWorkloadVersionSpec{ - KeptnWorkloadSpec: klcv1alpha3.KeptnWorkloadSpec{ - ResourceReference: klcv1alpha3.ResourceReference{ + wi: &klcv1beta1.KeptnWorkloadVersion{ + Spec: klcv1beta1.KeptnWorkloadVersionSpec{ + KeptnWorkloadSpec: klcv1beta1.KeptnWorkloadSpec{ + ResourceReference: klcv1beta1.ResourceReference{ Kind: "Pod", }, }, @@ -287,10 +286,10 @@ func Test_SchedulingGatesHandler_IsSchedulingGatesEnabledRemoveGates(t *testing. return []string{"podName"}, nil }, }, - wi: &klcv1alpha4.KeptnWorkloadVersion{ - Spec: klcv1alpha4.KeptnWorkloadVersionSpec{ - KeptnWorkloadSpec: klcv1alpha3.KeptnWorkloadSpec{ - ResourceReference: klcv1alpha3.ResourceReference{ + wi: &klcv1beta1.KeptnWorkloadVersion{ + Spec: klcv1beta1.KeptnWorkloadVersionSpec{ + KeptnWorkloadSpec: klcv1beta1.KeptnWorkloadSpec{ + ResourceReference: klcv1beta1.ResourceReference{ Kind: "ReplicaSet", }, }, @@ -305,10 +304,10 @@ func Test_SchedulingGatesHandler_IsSchedulingGatesEnabledRemoveGates(t *testing. return []string{}, nil }, }, - wi: &klcv1alpha4.KeptnWorkloadVersion{ - Spec: klcv1alpha4.KeptnWorkloadVersionSpec{ - KeptnWorkloadSpec: klcv1alpha3.KeptnWorkloadSpec{ - ResourceReference: klcv1alpha3.ResourceReference{ + wi: &klcv1beta1.KeptnWorkloadVersion{ + Spec: klcv1beta1.KeptnWorkloadVersionSpec{ + KeptnWorkloadSpec: klcv1beta1.KeptnWorkloadSpec{ + ResourceReference: klcv1beta1.ResourceReference{ Kind: "ReplicaSet", }, }, @@ -323,10 +322,10 @@ func Test_SchedulingGatesHandler_IsSchedulingGatesEnabledRemoveGates(t *testing. return []string{}, fmt.Errorf("err") }, }, - wi: &klcv1alpha4.KeptnWorkloadVersion{ - Spec: klcv1alpha4.KeptnWorkloadVersionSpec{ - KeptnWorkloadSpec: klcv1alpha3.KeptnWorkloadSpec{ - ResourceReference: klcv1alpha3.ResourceReference{ + wi: &klcv1beta1.KeptnWorkloadVersion{ + Spec: klcv1beta1.KeptnWorkloadVersionSpec{ + KeptnWorkloadSpec: klcv1beta1.KeptnWorkloadSpec{ + ResourceReference: klcv1beta1.ResourceReference{ Kind: "ReplicaSet", }, }, @@ -344,10 +343,10 @@ func Test_SchedulingGatesHandler_IsSchedulingGatesEnabledRemoveGates(t *testing. return []string{"podName"}, nil }, }, - wi: &klcv1alpha4.KeptnWorkloadVersion{ - Spec: klcv1alpha4.KeptnWorkloadVersionSpec{ - KeptnWorkloadSpec: klcv1alpha3.KeptnWorkloadSpec{ - ResourceReference: klcv1alpha3.ResourceReference{ + wi: &klcv1beta1.KeptnWorkloadVersion{ + Spec: klcv1beta1.KeptnWorkloadVersionSpec{ + KeptnWorkloadSpec: klcv1beta1.KeptnWorkloadSpec{ + ResourceReference: klcv1beta1.ResourceReference{ Kind: "ReplicaSet", }, }, diff --git a/lifecycle-operator/controllers/common/task/handler.go b/lifecycle-operator/controllers/common/task/handler.go index 980b5fd0a94..ba565597a39 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" - klcv1alpha3 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3/common" + klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/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" @@ -33,12 +33,12 @@ type Handler struct { type CreateTaskAttributes struct { SpanName string - Definition klcv1alpha3.KeptnTaskDefinition + Definition klcv1beta1.KeptnTaskDefinition CheckType apicommon.CheckType } //nolint:gocognit,gocyclo -func (r Handler) ReconcileTasks(ctx context.Context, phaseCtx context.Context, reconcileObject client.Object, taskCreateAttributes CreateTaskAttributes) ([]klcv1alpha3.ItemStatus, apicommon.StatusSummary, error) { +func (r Handler) ReconcileTasks(ctx context.Context, phaseCtx context.Context, reconcileObject client.Object, taskCreateAttributes CreateTaskAttributes) ([]klcv1beta1.ItemStatus, apicommon.StatusSummary, error) { piWrapper, err := interfaces.NewPhaseItemWrapperFromClientObject(reconcileObject) if err != nil { return nil, apicommon.StatusSummary{}, err @@ -51,12 +51,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 []klcv1alpha3.ItemStatus + var newStatus []klcv1beta1.ItemStatus for _, taskDefinitionName := range tasks { oldstatus := common.GetOldStatus(taskDefinitionName, statuses) taskStatus := common.GetItemStatus(taskDefinitionName, statuses) - task := &klcv1alpha3.KeptnTask{} + task := &klcv1beta1.KeptnTask{} taskExists := false if oldstatus != taskStatus.Status { @@ -147,13 +147,13 @@ func (r Handler) CreateKeptnTask(ctx context.Context, namespace string, reconcil return newTask.Name, nil } -func (r Handler) setTaskFailureEvents(task *klcv1alpha3.KeptnTask, spanTrace trace.Span) { +func (r Handler) setTaskFailureEvents(task *klcv1beta1.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, []klcv1alpha3.ItemStatus) { +func (r Handler) setupTasks(taskCreateAttributes CreateTaskAttributes, piWrapper *interfaces.PhaseItemWrapper) ([]string, []klcv1beta1.ItemStatus) { var tasks []string - var statuses []klcv1alpha3.ItemStatus + var statuses []klcv1beta1.ItemStatus switch taskCreateAttributes.CheckType { case apicommon.PreDeploymentCheckType: @@ -166,7 +166,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 *klcv1alpha3.KeptnTask, taskStatus *klcv1alpha3.ItemStatus) error { +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 { definition, err := common.GetTaskDefinition(r.Client, r.Log, ctx, taskName, piWrapper.GetNamespace()) if err != nil { return controllererrors.ErrCannotGetKeptnTaskDefinition @@ -186,7 +186,7 @@ func (r Handler) handleTaskNotExists(ctx context.Context, phaseCtx context.Conte return nil } -func (r Handler) handleTaskExists(phaseCtx context.Context, task *klcv1alpha3.KeptnTask, taskStatus *klcv1alpha3.ItemStatus) { +func (r Handler) handleTaskExists(phaseCtx context.Context, task *klcv1beta1.KeptnTask, taskStatus *klcv1beta1.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 3ce0d7a8193..b241865695b 100644 --- a/lifecycle-operator/controllers/common/task/handler_test.go +++ b/lifecycle-operator/controllers/common/task/handler_test.go @@ -5,8 +5,8 @@ import ( "strings" "testing" - "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3/common" + "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/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" @@ -30,18 +30,18 @@ func TestTaskHandler(t *testing.T) { name string object client.Object createAttr CreateTaskAttributes - wantStatus []v1alpha3.ItemStatus + wantStatus []v1beta1.ItemStatus wantSummary apicommon.StatusSummary - taskObj v1alpha3.KeptnTask - taskDef *v1alpha3.KeptnTaskDefinition + taskObj v1beta1.KeptnTask + taskDef *v1beta1.KeptnTaskDefinition wantErr error getSpanCalls int unbindSpanCalls int }{ { name: "cannot unwrap object", - object: &v1alpha3.KeptnTask{}, - taskObj: v1alpha3.KeptnTask{}, + object: &v1beta1.KeptnTask{}, + taskObj: v1beta1.KeptnTask{}, createAttr: CreateTaskAttributes{}, wantStatus: nil, wantSummary: apicommon.StatusSummary{}, @@ -51,14 +51,14 @@ func TestTaskHandler(t *testing.T) { }, { name: "no tasks", - object: &v1alpha3.KeptnAppVersion{}, - taskObj: v1alpha3.KeptnTask{}, + object: &v1beta1.KeptnAppVersion{}, + taskObj: v1beta1.KeptnTask{}, createAttr: CreateTaskAttributes{ SpanName: "", - Definition: v1alpha3.KeptnTaskDefinition{}, + Definition: v1beta1.KeptnTaskDefinition{}, CheckType: apicommon.PreDeploymentCheckType, }, - wantStatus: []v1alpha3.ItemStatus(nil), + wantStatus: []v1beta1.ItemStatus(nil), wantSummary: apicommon.StatusSummary{}, wantErr: nil, getSpanCalls: 0, @@ -66,20 +66,20 @@ func TestTaskHandler(t *testing.T) { }, { name: "task not started - could not find taskDefinition", - object: &v1alpha3.KeptnAppVersion{ + object: &v1beta1.KeptnAppVersion{ ObjectMeta: v1.ObjectMeta{ Namespace: "namespace", }, - Spec: v1alpha3.KeptnAppVersionSpec{ - KeptnAppSpec: v1alpha3.KeptnAppSpec{ + Spec: v1beta1.KeptnAppVersionSpec{ + KeptnAppSpec: v1beta1.KeptnAppSpec{ PreDeploymentTasks: []string{"task-def"}, }, }, }, - taskObj: v1alpha3.KeptnTask{}, + taskObj: v1beta1.KeptnTask{}, createAttr: CreateTaskAttributes{ SpanName: "", - Definition: v1alpha3.KeptnTaskDefinition{ + Definition: v1beta1.KeptnTaskDefinition{ ObjectMeta: v1.ObjectMeta{ Name: "task-def", }, @@ -94,33 +94,33 @@ func TestTaskHandler(t *testing.T) { }, { name: "tasks not started - could not find taskDefinition of one task", - object: &v1alpha3.KeptnAppVersion{ + object: &v1beta1.KeptnAppVersion{ ObjectMeta: v1.ObjectMeta{ Namespace: "namespace", }, - Spec: v1alpha3.KeptnAppVersionSpec{ - KeptnAppSpec: v1alpha3.KeptnAppSpec{ + Spec: v1beta1.KeptnAppVersionSpec{ + KeptnAppSpec: v1beta1.KeptnAppSpec{ PreDeploymentTasks: []string{"task-def", "other-task-def"}, }, }, }, - taskDef: &v1alpha3.KeptnTaskDefinition{ + taskDef: &v1beta1.KeptnTaskDefinition{ ObjectMeta: v1.ObjectMeta{ Namespace: testcommon.KeptnNamespace, Name: "task-def", }, }, - taskObj: v1alpha3.KeptnTask{}, + taskObj: v1beta1.KeptnTask{}, createAttr: CreateTaskAttributes{ SpanName: "", - Definition: v1alpha3.KeptnTaskDefinition{ + Definition: v1beta1.KeptnTaskDefinition{ ObjectMeta: v1.ObjectMeta{ Name: "task-def", }, }, CheckType: apicommon.PreDeploymentCheckType, }, - wantStatus: []v1alpha3.ItemStatus{ + wantStatus: []v1beta1.ItemStatus{ { DefinitionName: "task-def", Status: apicommon.StatePending, @@ -134,33 +134,33 @@ func TestTaskHandler(t *testing.T) { }, { name: "task not started - taskDefinition in default Keptn namespace", - object: &v1alpha3.KeptnAppVersion{ + object: &v1beta1.KeptnAppVersion{ ObjectMeta: v1.ObjectMeta{ Namespace: "namespace", }, - Spec: v1alpha3.KeptnAppVersionSpec{ - KeptnAppSpec: v1alpha3.KeptnAppSpec{ + Spec: v1beta1.KeptnAppVersionSpec{ + KeptnAppSpec: v1beta1.KeptnAppSpec{ PreDeploymentTasks: []string{"task-def"}, }, }, }, - taskDef: &v1alpha3.KeptnTaskDefinition{ + taskDef: &v1beta1.KeptnTaskDefinition{ ObjectMeta: v1.ObjectMeta{ Namespace: testcommon.KeptnNamespace, Name: "task-def", }, }, - taskObj: v1alpha3.KeptnTask{}, + taskObj: v1beta1.KeptnTask{}, createAttr: CreateTaskAttributes{ SpanName: "", - Definition: v1alpha3.KeptnTaskDefinition{ + Definition: v1beta1.KeptnTaskDefinition{ ObjectMeta: v1.ObjectMeta{ Name: "task-def", }, }, CheckType: apicommon.PreDeploymentCheckType, }, - wantStatus: []v1alpha3.ItemStatus{ + wantStatus: []v1beta1.ItemStatus{ { DefinitionName: "task-def", Status: apicommon.StatePending, @@ -174,33 +174,33 @@ func TestTaskHandler(t *testing.T) { }, { name: "task not started", - object: &v1alpha3.KeptnAppVersion{ + object: &v1beta1.KeptnAppVersion{ ObjectMeta: v1.ObjectMeta{ Namespace: "namespace", }, - Spec: v1alpha3.KeptnAppVersionSpec{ - KeptnAppSpec: v1alpha3.KeptnAppSpec{ + Spec: v1beta1.KeptnAppVersionSpec{ + KeptnAppSpec: v1beta1.KeptnAppSpec{ PreDeploymentTasks: []string{"task-def"}, }, }, }, - taskDef: &v1alpha3.KeptnTaskDefinition{ + taskDef: &v1beta1.KeptnTaskDefinition{ ObjectMeta: v1.ObjectMeta{ Namespace: "namespace", Name: "task-def", }, }, - taskObj: v1alpha3.KeptnTask{}, + taskObj: v1beta1.KeptnTask{}, createAttr: CreateTaskAttributes{ SpanName: "", - Definition: v1alpha3.KeptnTaskDefinition{ + Definition: v1beta1.KeptnTaskDefinition{ ObjectMeta: v1.ObjectMeta{ Name: "task-def", }, }, CheckType: apicommon.PreDeploymentCheckType, }, - wantStatus: []v1alpha3.ItemStatus{ + wantStatus: []v1beta1.ItemStatus{ { DefinitionName: "task-def", Status: apicommon.StatePending, @@ -214,15 +214,15 @@ func TestTaskHandler(t *testing.T) { }, { name: "already done task", - object: &v1alpha3.KeptnAppVersion{ - Spec: v1alpha3.KeptnAppVersionSpec{ - KeptnAppSpec: v1alpha3.KeptnAppSpec{ + object: &v1beta1.KeptnAppVersion{ + Spec: v1beta1.KeptnAppVersionSpec{ + KeptnAppSpec: v1beta1.KeptnAppSpec{ PreDeploymentTasks: []string{"task-def"}, }, }, - Status: v1alpha3.KeptnAppVersionStatus{ + Status: v1beta1.KeptnAppVersionStatus{ PreDeploymentStatus: apicommon.StateSucceeded, - PreDeploymentTaskStatus: []v1alpha3.ItemStatus{ + PreDeploymentTaskStatus: []v1beta1.ItemStatus{ { DefinitionName: "task-def", Status: apicommon.StateSucceeded, @@ -231,17 +231,17 @@ func TestTaskHandler(t *testing.T) { }, }, }, - taskObj: v1alpha3.KeptnTask{}, + taskObj: v1beta1.KeptnTask{}, createAttr: CreateTaskAttributes{ SpanName: "", - Definition: v1alpha3.KeptnTaskDefinition{ + Definition: v1beta1.KeptnTaskDefinition{ ObjectMeta: v1.ObjectMeta{ Name: "task-def", }, }, CheckType: apicommon.PreDeploymentCheckType, }, - wantStatus: []v1alpha3.ItemStatus{ + wantStatus: []v1beta1.ItemStatus{ { DefinitionName: "task-def", Status: apicommon.StateSucceeded, @@ -255,18 +255,18 @@ func TestTaskHandler(t *testing.T) { }, { name: "failed task", - object: &v1alpha3.KeptnAppVersion{ + object: &v1beta1.KeptnAppVersion{ ObjectMeta: v1.ObjectMeta{ Namespace: "namespace", }, - Spec: v1alpha3.KeptnAppVersionSpec{ - KeptnAppSpec: v1alpha3.KeptnAppSpec{ + Spec: v1beta1.KeptnAppVersionSpec{ + KeptnAppSpec: v1beta1.KeptnAppSpec{ PreDeploymentTasks: []string{"task-def"}, }, }, - Status: v1alpha3.KeptnAppVersionStatus{ + Status: v1beta1.KeptnAppVersionStatus{ PreDeploymentStatus: apicommon.StateSucceeded, - PreDeploymentTaskStatus: []v1alpha3.ItemStatus{ + PreDeploymentTaskStatus: []v1beta1.ItemStatus{ { DefinitionName: "task-def", Status: apicommon.StateProgressing, @@ -275,25 +275,25 @@ func TestTaskHandler(t *testing.T) { }, }, }, - taskObj: v1alpha3.KeptnTask{ + taskObj: v1beta1.KeptnTask{ ObjectMeta: v1.ObjectMeta{ Namespace: "namespace", Name: "pre-task-def-", }, - Status: v1alpha3.KeptnTaskStatus{ + Status: v1beta1.KeptnTaskStatus{ Status: apicommon.StateFailed, }, }, createAttr: CreateTaskAttributes{ SpanName: "", - Definition: v1alpha3.KeptnTaskDefinition{ + Definition: v1beta1.KeptnTaskDefinition{ ObjectMeta: v1.ObjectMeta{ Name: "task-def", }, }, CheckType: apicommon.PreDeploymentCheckType, }, - wantStatus: []v1alpha3.ItemStatus{ + wantStatus: []v1beta1.ItemStatus{ { DefinitionName: "task-def", Status: apicommon.StateFailed, @@ -307,18 +307,18 @@ func TestTaskHandler(t *testing.T) { }, { name: "succeeded task", - object: &v1alpha3.KeptnAppVersion{ + object: &v1beta1.KeptnAppVersion{ ObjectMeta: v1.ObjectMeta{ Namespace: "namespace", }, - Spec: v1alpha3.KeptnAppVersionSpec{ - KeptnAppSpec: v1alpha3.KeptnAppSpec{ + Spec: v1beta1.KeptnAppVersionSpec{ + KeptnAppSpec: v1beta1.KeptnAppSpec{ PreDeploymentTasks: []string{"task-def"}, }, }, - Status: v1alpha3.KeptnAppVersionStatus{ + Status: v1beta1.KeptnAppVersionStatus{ PreDeploymentStatus: apicommon.StateSucceeded, - PreDeploymentTaskStatus: []v1alpha3.ItemStatus{ + PreDeploymentTaskStatus: []v1beta1.ItemStatus{ { DefinitionName: "task-def", Status: apicommon.StateProgressing, @@ -327,25 +327,25 @@ func TestTaskHandler(t *testing.T) { }, }, }, - taskObj: v1alpha3.KeptnTask{ + taskObj: v1beta1.KeptnTask{ ObjectMeta: v1.ObjectMeta{ Namespace: "namespace", Name: "pre-task-def-", }, - Status: v1alpha3.KeptnTaskStatus{ + Status: v1beta1.KeptnTaskStatus{ Status: apicommon.StateSucceeded, }, }, createAttr: CreateTaskAttributes{ SpanName: "", - Definition: v1alpha3.KeptnTaskDefinition{ + Definition: v1beta1.KeptnTaskDefinition{ ObjectMeta: v1.ObjectMeta{ Name: "task-def", }, }, CheckType: apicommon.PreDeploymentCheckType, }, - wantStatus: []v1alpha3.ItemStatus{ + wantStatus: []v1beta1.ItemStatus{ { DefinitionName: "task-def", Status: apicommon.StateSucceeded, @@ -362,7 +362,7 @@ func TestTaskHandler(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - err := v1alpha3.AddToScheme(scheme.Scheme) + err := v1beta1.AddToScheme(scheme.Scheme) require.Nil(t, err) spanHandlerMock := telemetryfake.ISpanHandlerMock{ GetSpanFunc: func(ctx context.Context, tracer telemetry.ITracer, reconcileObject client.Object, phase string) (context.Context, trace.Span, error) { @@ -412,19 +412,19 @@ func TestTaskHandler_createTask(t *testing.T) { }{ { name: "cannot unwrap object", - object: &v1alpha3.KeptnEvaluation{}, + object: &v1beta1.KeptnEvaluation{}, createAttr: CreateTaskAttributes{}, wantName: "", wantErr: controllererrors.ErrCannotWrapToPhaseItem, }, { name: "created task", - object: &v1alpha3.KeptnAppVersion{ + object: &v1beta1.KeptnAppVersion{ ObjectMeta: v1.ObjectMeta{ Namespace: "namespace", }, - Spec: v1alpha3.KeptnAppVersionSpec{ - KeptnAppSpec: v1alpha3.KeptnAppSpec{ + Spec: v1beta1.KeptnAppVersionSpec{ + KeptnAppSpec: v1beta1.KeptnAppSpec{ PreDeploymentTasks: []string{"task-def"}, }, }, @@ -432,7 +432,7 @@ func TestTaskHandler_createTask(t *testing.T) { createAttr: CreateTaskAttributes{ SpanName: "", CheckType: apicommon.PreDeploymentCheckType, - Definition: v1alpha3.KeptnTaskDefinition{ + Definition: v1beta1.KeptnTaskDefinition{ ObjectMeta: v1.ObjectMeta{ Name: "task-def", }, @@ -445,7 +445,7 @@ func TestTaskHandler_createTask(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - err := v1alpha3.AddToScheme(scheme.Scheme) + err := v1beta1.AddToScheme(scheme.Scheme) require.Nil(t, err) handler := Handler{ SpanHandler: &telemetryfake.ISpanHandlerMock{}, diff --git a/lifecycle-operator/controllers/common/taskdefinition/handler.go b/lifecycle-operator/controllers/common/taskdefinition/handler.go index cedd56e2f0c..70c4b6e4ee2 100644 --- a/lifecycle-operator/controllers/common/taskdefinition/handler.go +++ b/lifecycle-operator/controllers/common/taskdefinition/handler.go @@ -4,8 +4,8 @@ import ( "os" "reflect" - klcv1alpha3 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3/common" + klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" ) const ( @@ -17,7 +17,7 @@ const ( PythonScriptKey = "python" ) -func GetRuntimeSpec(def *klcv1alpha3.KeptnTaskDefinition) *klcv1alpha3.RuntimeSpec { +func GetRuntimeSpec(def *klcv1beta1.KeptnTaskDefinition) *klcv1beta1.RuntimeSpec { if !IsRuntimeEmpty(def.Spec.Function) { return def.Spec.Function @@ -32,23 +32,23 @@ func GetRuntimeSpec(def *klcv1alpha3.KeptnTaskDefinition) *klcv1alpha3.RuntimeSp return nil } -func IsRuntimeEmpty(spec *klcv1alpha3.RuntimeSpec) bool { - return spec == nil || reflect.DeepEqual(spec, &klcv1alpha3.RuntimeSpec{}) +func IsRuntimeEmpty(spec *klcv1beta1.RuntimeSpec) bool { + return spec == nil || reflect.DeepEqual(spec, &klcv1beta1.RuntimeSpec{}) } -func IsContainerEmpty(spec *klcv1alpha3.ContainerSpec) bool { - return spec == nil || reflect.DeepEqual(spec, &klcv1alpha3.ContainerSpec{}) +func IsContainerEmpty(spec *klcv1beta1.ContainerSpec) bool { + return spec == nil || reflect.DeepEqual(spec, &klcv1beta1.ContainerSpec{}) } -func IsVolumeMountPresent(spec *klcv1alpha3.ContainerSpec) bool { +func IsVolumeMountPresent(spec *klcv1beta1.ContainerSpec) bool { return spec != nil && spec.Container != nil && spec.VolumeMounts != nil && len(spec.VolumeMounts) > 0 } -func IsInline(spec *klcv1alpha3.RuntimeSpec) bool { - return spec != nil && !reflect.DeepEqual(spec.Inline, klcv1alpha3.Inline{}) +func IsInline(spec *klcv1beta1.RuntimeSpec) bool { + return spec != nil && !reflect.DeepEqual(spec.Inline, klcv1beta1.Inline{}) } -func GetRuntimeImage(def *klcv1alpha3.KeptnTaskDefinition) string { +func GetRuntimeImage(def *klcv1beta1.KeptnTaskDefinition) string { image := os.Getenv(FunctionRuntimeImageKey) if !IsRuntimeEmpty(def.Spec.Python) && IsRuntimeEmpty(def.Spec.Function) && IsRuntimeEmpty(def.Spec.Deno) { image = os.Getenv(PythonRuntimeImageKey) @@ -56,14 +56,14 @@ func GetRuntimeImage(def *klcv1alpha3.KeptnTaskDefinition) string { return image } -func GetCmName(functionName string, spec *klcv1alpha3.RuntimeSpec) string { +func GetCmName(functionName string, spec *klcv1beta1.RuntimeSpec) string { if IsInline(spec) { return "keptnfn-" + apicommon.TruncateString(functionName, 245) } return spec.ConfigMapReference.Name } -func GetRuntimeMountPath(def *klcv1alpha3.KeptnTaskDefinition) string { +func GetRuntimeMountPath(def *klcv1beta1.KeptnTaskDefinition) string { path := FunctionScriptMountPath if !IsRuntimeEmpty(def.Spec.Python) && IsRuntimeEmpty(def.Spec.Function) && IsRuntimeEmpty(def.Spec.Deno) { path = PythonScriptMountPath @@ -72,7 +72,7 @@ func GetRuntimeMountPath(def *klcv1alpha3.KeptnTaskDefinition) string { } // check if either the functions or container spec is set -func SpecExists(definition *klcv1alpha3.KeptnTaskDefinition) bool { +func SpecExists(definition *klcv1beta1.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 1b0de69de26..43cd80a5004 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" - klcv1alpha3 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3" + klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" "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 *klcv1alpha3.KeptnTaskDefinition + def *klcv1beta1.KeptnTaskDefinition want string }{ { name: PythonScriptKey, - def: &klcv1alpha3.KeptnTaskDefinition{ - Spec: klcv1alpha3.KeptnTaskDefinitionSpec{ - Python: &klcv1alpha3.RuntimeSpec{ - HttpReference: klcv1alpha3.HttpReference{ + def: &klcv1beta1.KeptnTaskDefinition{ + Spec: klcv1beta1.KeptnTaskDefinitionSpec{ + Python: &klcv1beta1.RuntimeSpec{ + HttpReference: klcv1beta1.HttpReference{ Url: "testy.com", }, }, @@ -32,10 +32,10 @@ func TestGetRuntimeImage(t *testing.T) { want: PythonScriptKey, }, { name: FunctionScriptKey, - def: &klcv1alpha3.KeptnTaskDefinition{ - Spec: klcv1alpha3.KeptnTaskDefinitionSpec{ - Deno: &klcv1alpha3.RuntimeSpec{ - HttpReference: klcv1alpha3.HttpReference{ + def: &klcv1beta1.KeptnTaskDefinition{ + Spec: klcv1beta1.KeptnTaskDefinitionSpec{ + Deno: &klcv1beta1.RuntimeSpec{ + HttpReference: klcv1beta1.HttpReference{ Url: "testy.com", }, }, @@ -44,10 +44,10 @@ func TestGetRuntimeImage(t *testing.T) { want: FunctionScriptKey, }, { name: "default function", - def: &klcv1alpha3.KeptnTaskDefinition{ - Spec: klcv1alpha3.KeptnTaskDefinitionSpec{ - Function: &klcv1alpha3.RuntimeSpec{ - HttpReference: klcv1alpha3.HttpReference{ + def: &klcv1beta1.KeptnTaskDefinition{ + Spec: klcv1beta1.KeptnTaskDefinitionSpec{ + Function: &klcv1beta1.RuntimeSpec{ + HttpReference: klcv1beta1.HttpReference{ Url: "testy.com", }, }, @@ -57,15 +57,15 @@ func TestGetRuntimeImage(t *testing.T) { }, { name: "default and python defined, default wins", - def: &klcv1alpha3.KeptnTaskDefinition{ - Spec: klcv1alpha3.KeptnTaskDefinitionSpec{ - Function: &klcv1alpha3.RuntimeSpec{ - HttpReference: klcv1alpha3.HttpReference{ + def: &klcv1beta1.KeptnTaskDefinition{ + Spec: klcv1beta1.KeptnTaskDefinitionSpec{ + Function: &klcv1beta1.RuntimeSpec{ + HttpReference: klcv1beta1.HttpReference{ Url: "testy.com", }, }, - Python: &klcv1alpha3.RuntimeSpec{ - HttpReference: klcv1alpha3.HttpReference{ + Python: &klcv1beta1.RuntimeSpec{ + HttpReference: klcv1beta1.HttpReference{ Url: "testy.com", }, }, @@ -75,15 +75,15 @@ func TestGetRuntimeImage(t *testing.T) { }, { name: "deno and python defined, deno wins", - def: &klcv1alpha3.KeptnTaskDefinition{ - Spec: klcv1alpha3.KeptnTaskDefinitionSpec{ - Deno: &klcv1alpha3.RuntimeSpec{ - HttpReference: klcv1alpha3.HttpReference{ + def: &klcv1beta1.KeptnTaskDefinition{ + Spec: klcv1beta1.KeptnTaskDefinitionSpec{ + Deno: &klcv1beta1.RuntimeSpec{ + HttpReference: klcv1beta1.HttpReference{ Url: "testy.com", }, }, - Python: &klcv1alpha3.RuntimeSpec{ - HttpReference: klcv1alpha3.HttpReference{ + Python: &klcv1beta1.RuntimeSpec{ + HttpReference: klcv1beta1.HttpReference{ Url: "testy.com", }, }, @@ -104,109 +104,109 @@ func TestGetRuntimeImage(t *testing.T) { func TestGetRuntimeSpec(t *testing.T) { tests := []struct { name string - def *klcv1alpha3.KeptnTaskDefinition - want *klcv1alpha3.RuntimeSpec + def *klcv1beta1.KeptnTaskDefinition + want *klcv1beta1.RuntimeSpec }{ { name: PythonScriptKey, - def: &klcv1alpha3.KeptnTaskDefinition{ - Spec: klcv1alpha3.KeptnTaskDefinitionSpec{ - Python: &klcv1alpha3.RuntimeSpec{ - HttpReference: klcv1alpha3.HttpReference{ + def: &klcv1beta1.KeptnTaskDefinition{ + Spec: klcv1beta1.KeptnTaskDefinitionSpec{ + Python: &klcv1beta1.RuntimeSpec{ + HttpReference: klcv1beta1.HttpReference{ Url: "testy.com", }, }, }, }, - want: &klcv1alpha3.RuntimeSpec{ - HttpReference: klcv1alpha3.HttpReference{ + want: &klcv1beta1.RuntimeSpec{ + HttpReference: klcv1beta1.HttpReference{ Url: "testy.com", }, }, }, { name: FunctionScriptKey, - def: &klcv1alpha3.KeptnTaskDefinition{ - Spec: klcv1alpha3.KeptnTaskDefinitionSpec{ - Deno: &klcv1alpha3.RuntimeSpec{ - HttpReference: klcv1alpha3.HttpReference{ + def: &klcv1beta1.KeptnTaskDefinition{ + Spec: klcv1beta1.KeptnTaskDefinitionSpec{ + Deno: &klcv1beta1.RuntimeSpec{ + HttpReference: klcv1beta1.HttpReference{ Url: "testy.com", }, }, }, }, - want: &klcv1alpha3.RuntimeSpec{ - HttpReference: klcv1alpha3.HttpReference{ + want: &klcv1beta1.RuntimeSpec{ + HttpReference: klcv1beta1.HttpReference{ Url: "testy.com", }, }, }, { name: "default function", - def: &klcv1alpha3.KeptnTaskDefinition{ - Spec: klcv1alpha3.KeptnTaskDefinitionSpec{ - Function: &klcv1alpha3.RuntimeSpec{ - HttpReference: klcv1alpha3.HttpReference{ + def: &klcv1beta1.KeptnTaskDefinition{ + Spec: klcv1beta1.KeptnTaskDefinitionSpec{ + Function: &klcv1beta1.RuntimeSpec{ + HttpReference: klcv1beta1.HttpReference{ Url: "testy.com", }, }, }, }, - want: &klcv1alpha3.RuntimeSpec{ - HttpReference: klcv1alpha3.HttpReference{ + want: &klcv1beta1.RuntimeSpec{ + HttpReference: klcv1beta1.HttpReference{ Url: "testy.com", }, }, }, { name: "default function & python exist", - def: &klcv1alpha3.KeptnTaskDefinition{ - Spec: klcv1alpha3.KeptnTaskDefinitionSpec{ - Function: &klcv1alpha3.RuntimeSpec{ - HttpReference: klcv1alpha3.HttpReference{ + def: &klcv1beta1.KeptnTaskDefinition{ + Spec: klcv1beta1.KeptnTaskDefinitionSpec{ + Function: &klcv1beta1.RuntimeSpec{ + HttpReference: klcv1beta1.HttpReference{ Url: "testy.com", }, }, - Python: &klcv1alpha3.RuntimeSpec{ - HttpReference: klcv1alpha3.HttpReference{ + Python: &klcv1beta1.RuntimeSpec{ + HttpReference: klcv1beta1.HttpReference{ Url: "nottesty.com", }, }, }, }, - want: &klcv1alpha3.RuntimeSpec{ - HttpReference: klcv1alpha3.HttpReference{ + want: &klcv1beta1.RuntimeSpec{ + HttpReference: klcv1beta1.HttpReference{ Url: "testy.com", }, }, }, { name: "default function empty & python exists ", - def: &klcv1alpha3.KeptnTaskDefinition{ - Spec: klcv1alpha3.KeptnTaskDefinitionSpec{ - Function: &klcv1alpha3.RuntimeSpec{ - HttpReference: klcv1alpha3.HttpReference{ + def: &klcv1beta1.KeptnTaskDefinition{ + Spec: klcv1beta1.KeptnTaskDefinitionSpec{ + Function: &klcv1beta1.RuntimeSpec{ + HttpReference: klcv1beta1.HttpReference{ Url: "", }, }, - Python: &klcv1alpha3.RuntimeSpec{ - HttpReference: klcv1alpha3.HttpReference{ + Python: &klcv1beta1.RuntimeSpec{ + HttpReference: klcv1beta1.HttpReference{ Url: "testy.com", }, }, }, }, - want: &klcv1alpha3.RuntimeSpec{ - HttpReference: klcv1alpha3.HttpReference{ + want: &klcv1beta1.RuntimeSpec{ + HttpReference: klcv1beta1.HttpReference{ Url: "testy.com", }, }, }, { name: "only container spec exists ", - def: &klcv1alpha3.KeptnTaskDefinition{ - Spec: klcv1alpha3.KeptnTaskDefinitionSpec{ - Container: &klcv1alpha3.ContainerSpec{ + def: &klcv1beta1.KeptnTaskDefinition{ + Spec: klcv1beta1.KeptnTaskDefinitionSpec{ + Container: &klcv1beta1.ContainerSpec{ Container: &corev1.Container{ Name: "myc", }, @@ -229,14 +229,14 @@ func TestGetRuntimeMountPath(t *testing.T) { tests := []struct { name string - def *klcv1alpha3.KeptnTaskDefinition + def *klcv1beta1.KeptnTaskDefinition want string }{ { name: "default function", - def: &klcv1alpha3.KeptnTaskDefinition{ - Spec: klcv1alpha3.KeptnTaskDefinitionSpec{ - Function: &klcv1alpha3.RuntimeSpec{ + def: &klcv1beta1.KeptnTaskDefinition{ + Spec: klcv1beta1.KeptnTaskDefinitionSpec{ + Function: &klcv1beta1.RuntimeSpec{ CmdParameters: "hi", }, }, @@ -245,9 +245,9 @@ func TestGetRuntimeMountPath(t *testing.T) { }, { name: "deno", - def: &klcv1alpha3.KeptnTaskDefinition{ - Spec: klcv1alpha3.KeptnTaskDefinitionSpec{ - Deno: &klcv1alpha3.RuntimeSpec{ + def: &klcv1beta1.KeptnTaskDefinition{ + Spec: klcv1beta1.KeptnTaskDefinitionSpec{ + Deno: &klcv1beta1.RuntimeSpec{ CmdParameters: "hi", }, }, @@ -256,9 +256,9 @@ func TestGetRuntimeMountPath(t *testing.T) { }, { name: PythonScriptKey, - def: &klcv1alpha3.KeptnTaskDefinition{ - Spec: klcv1alpha3.KeptnTaskDefinitionSpec{ - Python: &klcv1alpha3.RuntimeSpec{ + def: &klcv1beta1.KeptnTaskDefinition{ + Spec: klcv1beta1.KeptnTaskDefinitionSpec{ + Python: &klcv1beta1.RuntimeSpec{ CmdParameters: "hi", }, }, @@ -267,15 +267,15 @@ func TestGetRuntimeMountPath(t *testing.T) { }, { name: "default and python defined, default wins", - def: &klcv1alpha3.KeptnTaskDefinition{ - Spec: klcv1alpha3.KeptnTaskDefinitionSpec{ - Function: &klcv1alpha3.RuntimeSpec{ - HttpReference: klcv1alpha3.HttpReference{ + def: &klcv1beta1.KeptnTaskDefinition{ + Spec: klcv1beta1.KeptnTaskDefinitionSpec{ + Function: &klcv1beta1.RuntimeSpec{ + HttpReference: klcv1beta1.HttpReference{ Url: "testy.com", }, }, - Python: &klcv1alpha3.RuntimeSpec{ - HttpReference: klcv1alpha3.HttpReference{ + Python: &klcv1beta1.RuntimeSpec{ + HttpReference: klcv1beta1.HttpReference{ Url: "testy.com", }, }, @@ -285,15 +285,15 @@ func TestGetRuntimeMountPath(t *testing.T) { }, { name: "deno and python defined, deno wins", - def: &klcv1alpha3.KeptnTaskDefinition{ - Spec: klcv1alpha3.KeptnTaskDefinitionSpec{ - Deno: &klcv1alpha3.RuntimeSpec{ - HttpReference: klcv1alpha3.HttpReference{ + def: &klcv1beta1.KeptnTaskDefinition{ + Spec: klcv1beta1.KeptnTaskDefinitionSpec{ + Deno: &klcv1beta1.RuntimeSpec{ + HttpReference: klcv1beta1.HttpReference{ Url: "testy.com", }, }, - Python: &klcv1alpha3.RuntimeSpec{ - HttpReference: klcv1alpha3.HttpReference{ + Python: &klcv1beta1.RuntimeSpec{ + HttpReference: klcv1beta1.HttpReference{ Url: "testy.com", }, }, @@ -314,7 +314,7 @@ func TestGetRuntimeMountPath(t *testing.T) { func TestIsRuntimeEmpty(t *testing.T) { tests := []struct { name string - spec *klcv1alpha3.RuntimeSpec + spec *klcv1beta1.RuntimeSpec want bool }{ { @@ -324,8 +324,8 @@ func TestIsRuntimeEmpty(t *testing.T) { }, { name: "not empty", - spec: &klcv1alpha3.RuntimeSpec{ - HttpReference: klcv1alpha3.HttpReference{Url: "hello.com"}, + spec: &klcv1beta1.RuntimeSpec{ + HttpReference: klcv1beta1.HttpReference{Url: "hello.com"}, }, want: false, }, @@ -342,7 +342,7 @@ func TestIsRuntimeEmpty(t *testing.T) { func TestIsContianerEmpty(t *testing.T) { tests := []struct { name string - spec *klcv1alpha3.ContainerSpec + spec *klcv1beta1.ContainerSpec want bool }{ { @@ -352,7 +352,7 @@ func TestIsContianerEmpty(t *testing.T) { }, { name: "not empty", - spec: &klcv1alpha3.ContainerSpec{ + spec: &klcv1beta1.ContainerSpec{ Container: &corev1.Container{ Name: "name", }, @@ -373,20 +373,20 @@ func TestIsInline(t *testing.T) { var tests = []struct { name string - spec *klcv1alpha3.RuntimeSpec + spec *klcv1beta1.RuntimeSpec want bool }{ { name: "empty inline", - spec: &klcv1alpha3.RuntimeSpec{ - Inline: klcv1alpha3.Inline{}, + spec: &klcv1beta1.RuntimeSpec{ + Inline: klcv1beta1.Inline{}, }, want: false, }, { name: "code in inline", - spec: &klcv1alpha3.RuntimeSpec{ - Inline: klcv1alpha3.Inline{ + spec: &klcv1beta1.RuntimeSpec{ + Inline: klcv1beta1.Inline{ Code: "testcode", }, }, @@ -411,12 +411,12 @@ func TestIsVolumeMountPresent(t *testing.T) { var tests = []struct { name string - spec *klcv1alpha3.ContainerSpec + spec *klcv1beta1.ContainerSpec want bool }{ { name: "with mount", - spec: &klcv1alpha3.ContainerSpec{ + spec: &klcv1beta1.ContainerSpec{ Container: &corev1.Container{ VolumeMounts: []corev1.VolumeMount{ { @@ -434,14 +434,14 @@ func TestIsVolumeMountPresent(t *testing.T) { }, { name: "no container", - spec: &klcv1alpha3.ContainerSpec{ + spec: &klcv1beta1.ContainerSpec{ Container: nil, }, want: false, }, { name: "no mount", - spec: &klcv1alpha3.ContainerSpec{ + spec: &klcv1beta1.ContainerSpec{ Container: &corev1.Container{}, }, want: false, @@ -460,14 +460,14 @@ func TestSpecExists(t *testing.T) { tests := []struct { name string - definition *klcv1alpha3.KeptnTaskDefinition + definition *klcv1beta1.KeptnTaskDefinition want bool }{ { name: "container spec", - definition: &klcv1alpha3.KeptnTaskDefinition{ - Spec: klcv1alpha3.KeptnTaskDefinitionSpec{ - Container: &klcv1alpha3.ContainerSpec{ + definition: &klcv1beta1.KeptnTaskDefinition{ + Spec: klcv1beta1.KeptnTaskDefinitionSpec{ + Container: &klcv1beta1.ContainerSpec{ Container: &corev1.Container{ Name: "mytestcontainer", }, @@ -478,9 +478,9 @@ func TestSpecExists(t *testing.T) { }, { name: "runtime spec", - definition: &klcv1alpha3.KeptnTaskDefinition{ - Spec: klcv1alpha3.KeptnTaskDefinitionSpec{ - Python: &klcv1alpha3.RuntimeSpec{ + definition: &klcv1beta1.KeptnTaskDefinition{ + Spec: klcv1beta1.KeptnTaskDefinitionSpec{ + Python: &klcv1beta1.RuntimeSpec{ CmdParameters: "ciaoPy", }, }, @@ -507,14 +507,14 @@ func TestGetCmName(t *testing.T) { tests := []struct { name string functionName string - spec *klcv1alpha3.RuntimeSpec + spec *klcv1beta1.RuntimeSpec want string }{ { name: "inline func", functionName: "funcName", - spec: &klcv1alpha3.RuntimeSpec{ - Inline: klcv1alpha3.Inline{ + spec: &klcv1beta1.RuntimeSpec{ + Inline: klcv1beta1.Inline{ Code: "code", }, }, @@ -523,8 +523,8 @@ func TestGetCmName(t *testing.T) { { name: "inline func long name", functionName: "funcNamelooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong", - spec: &klcv1alpha3.RuntimeSpec{ - Inline: klcv1alpha3.Inline{ + spec: &klcv1beta1.RuntimeSpec{ + Inline: klcv1beta1.Inline{ Code: "code", }, }, @@ -533,8 +533,8 @@ func TestGetCmName(t *testing.T) { { name: "non inline func", functionName: "funcName", - spec: &klcv1alpha3.RuntimeSpec{ - ConfigMapReference: klcv1alpha3.ConfigMapReference{ + spec: &klcv1beta1.RuntimeSpec{ + ConfigMapReference: klcv1beta1.ConfigMapReference{ Name: "configMapName", }, }, diff --git a/lifecycle-operator/controllers/common/telemetry/metrics_test.go b/lifecycle-operator/controllers/common/telemetry/metrics_test.go index 3f6ec0bc3e0..838f2c7eebb 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" - lifecyclev1alpha3 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3" + lifecyclev1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" 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: &lifecyclev1alpha3.KeptnAppList{}, - clientObjects: &lifecyclev1alpha3.KeptnAppList{}, + list: &lifecyclev1beta1.KeptnAppList{}, + clientObjects: &lifecyclev1beta1.KeptnAppList{}, err: controllererrors.ErrCannotWrapToListItem, gauge: nil, }, { name: "no endtime set", - list: &lifecyclev1alpha3.KeptnAppVersionList{}, - clientObjects: &lifecyclev1alpha3.KeptnAppVersionList{ - Items: []lifecyclev1alpha3.KeptnAppVersion{ + list: &lifecyclev1beta1.KeptnAppVersionList{}, + clientObjects: &lifecyclev1beta1.KeptnAppVersionList{ + Items: []lifecyclev1beta1.KeptnAppVersion{ { - Status: lifecyclev1alpha3.KeptnAppVersionStatus{}, + Status: lifecyclev1beta1.KeptnAppVersionStatus{}, }, }, }, @@ -49,18 +49,18 @@ func TestMetrics_ObserveDeploymentDuration(t *testing.T) { }, { name: "endtime set", - list: &lifecyclev1alpha3.KeptnAppVersionList{}, - clientObjects: &lifecyclev1alpha3.KeptnAppVersionList{ - Items: []lifecyclev1alpha3.KeptnAppVersion{ + list: &lifecyclev1beta1.KeptnAppVersionList{}, + clientObjects: &lifecyclev1beta1.KeptnAppVersionList{ + Items: []lifecyclev1beta1.KeptnAppVersion{ { - Spec: lifecyclev1alpha3.KeptnAppVersionSpec{ - KeptnAppSpec: lifecyclev1alpha3.KeptnAppSpec{ + Spec: lifecyclev1beta1.KeptnAppVersionSpec{ + KeptnAppSpec: lifecyclev1beta1.KeptnAppSpec{ Version: "version", }, AppName: "appName", PreviousVersion: "previousVersion", }, - Status: lifecyclev1alpha3.KeptnAppVersionStatus{ + Status: lifecyclev1beta1.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 := lifecyclev1alpha3.AddToScheme(scheme.Scheme) + err := lifecyclev1beta1.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: &lifecyclev1alpha3.KeptnAppList{}, - clientObjects: &lifecyclev1alpha3.KeptnAppList{}, + list: &lifecyclev1beta1.KeptnAppList{}, + clientObjects: &lifecyclev1beta1.KeptnAppList{}, err: controllererrors.ErrCannotWrapToListItem, }, { name: "no endtime set - active instances", - list: &lifecyclev1alpha3.KeptnAppVersionList{}, - clientObjects: &lifecyclev1alpha3.KeptnAppVersionList{ - Items: []lifecyclev1alpha3.KeptnAppVersion{ + list: &lifecyclev1beta1.KeptnAppVersionList{}, + clientObjects: &lifecyclev1beta1.KeptnAppVersionList{ + Items: []lifecyclev1beta1.KeptnAppVersion{ { ObjectMeta: metav1.ObjectMeta{ Namespace: "namespace", }, - Spec: lifecyclev1alpha3.KeptnAppVersionSpec{ - KeptnAppSpec: lifecyclev1alpha3.KeptnAppSpec{ + Spec: lifecyclev1beta1.KeptnAppVersionSpec{ + KeptnAppSpec: lifecyclev1beta1.KeptnAppSpec{ Version: "version", }, AppName: "appName", PreviousVersion: "previousVersion", }, - Status: lifecyclev1alpha3.KeptnAppVersionStatus{}, + Status: lifecyclev1beta1.KeptnAppVersionStatus{}, }, }, }, @@ -121,21 +121,21 @@ func TestMetrics_ObserveActiveInstances(t *testing.T) { }, { name: "endtime set - no active instances", - list: &lifecyclev1alpha3.KeptnAppVersionList{}, - clientObjects: &lifecyclev1alpha3.KeptnAppVersionList{ - Items: []lifecyclev1alpha3.KeptnAppVersion{ + list: &lifecyclev1beta1.KeptnAppVersionList{}, + clientObjects: &lifecyclev1beta1.KeptnAppVersionList{ + Items: []lifecyclev1beta1.KeptnAppVersion{ { ObjectMeta: metav1.ObjectMeta{ Namespace: "namespace", }, - Spec: lifecyclev1alpha3.KeptnAppVersionSpec{ - KeptnAppSpec: lifecyclev1alpha3.KeptnAppSpec{ + Spec: lifecyclev1beta1.KeptnAppVersionSpec{ + KeptnAppSpec: lifecyclev1beta1.KeptnAppSpec{ Version: "version", }, AppName: "appName", PreviousVersion: "previousVersion", }, - Status: lifecyclev1alpha3.KeptnAppVersionStatus{ + Status: lifecyclev1beta1.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 := lifecyclev1alpha3.AddToScheme(scheme.Scheme) + err := lifecyclev1beta1.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: &lifecyclev1alpha3.KeptnAppList{}, - clientObjects: &lifecyclev1alpha3.KeptnAppList{}, + list: &lifecyclev1beta1.KeptnAppList{}, + clientObjects: &lifecyclev1beta1.KeptnAppList{}, err: controllererrors.ErrCannotWrapToListItem, }, { name: "no previous version", - list: &lifecyclev1alpha3.KeptnAppVersionList{}, - clientObjects: &lifecyclev1alpha3.KeptnAppVersionList{ - Items: []lifecyclev1alpha3.KeptnAppVersion{ + list: &lifecyclev1beta1.KeptnAppVersionList{}, + clientObjects: &lifecyclev1beta1.KeptnAppVersionList{ + Items: []lifecyclev1beta1.KeptnAppVersion{ { ObjectMeta: metav1.ObjectMeta{ Namespace: "namespace", }, - Spec: lifecyclev1alpha3.KeptnAppVersionSpec{ - KeptnAppSpec: lifecyclev1alpha3.KeptnAppSpec{ + Spec: lifecyclev1beta1.KeptnAppVersionSpec{ + KeptnAppSpec: lifecyclev1beta1.KeptnAppSpec{ Version: "version", }, AppName: "appName", @@ -198,15 +198,15 @@ func TestMetrics_ObserveDeploymentInterval(t *testing.T) { }, { name: "previous version - no previous object", - list: &lifecyclev1alpha3.KeptnAppVersionList{}, - clientObjects: &lifecyclev1alpha3.KeptnAppVersionList{ - Items: []lifecyclev1alpha3.KeptnAppVersion{ + list: &lifecyclev1beta1.KeptnAppVersionList{}, + clientObjects: &lifecyclev1beta1.KeptnAppVersionList{ + Items: []lifecyclev1beta1.KeptnAppVersion{ { ObjectMeta: metav1.ObjectMeta{ Namespace: "namespace", }, - Spec: lifecyclev1alpha3.KeptnAppVersionSpec{ - KeptnAppSpec: lifecyclev1alpha3.KeptnAppSpec{ + Spec: lifecyclev1beta1.KeptnAppVersionSpec{ + KeptnAppSpec: lifecyclev1beta1.KeptnAppSpec{ Version: "version", }, AppName: "appName", @@ -219,17 +219,17 @@ func TestMetrics_ObserveDeploymentInterval(t *testing.T) { }, { name: "previous version - object found but no endtime", - list: &lifecyclev1alpha3.KeptnAppVersionList{}, - previous: &lifecyclev1alpha3.KeptnAppVersion{}, - clientObjects: &lifecyclev1alpha3.KeptnAppVersionList{ - Items: []lifecyclev1alpha3.KeptnAppVersion{ + list: &lifecyclev1beta1.KeptnAppVersionList{}, + previous: &lifecyclev1beta1.KeptnAppVersion{}, + clientObjects: &lifecyclev1beta1.KeptnAppVersionList{ + Items: []lifecyclev1beta1.KeptnAppVersion{ { ObjectMeta: metav1.ObjectMeta{ Name: "appName-version", Namespace: "namespace", }, - Spec: lifecyclev1alpha3.KeptnAppVersionSpec{ - KeptnAppSpec: lifecyclev1alpha3.KeptnAppSpec{ + Spec: lifecyclev1beta1.KeptnAppVersionSpec{ + KeptnAppSpec: lifecyclev1beta1.KeptnAppSpec{ Version: "version", }, AppName: "appName", @@ -241,8 +241,8 @@ func TestMetrics_ObserveDeploymentInterval(t *testing.T) { Name: "appName-previousVersion", Namespace: "namespace", }, - Spec: lifecyclev1alpha3.KeptnAppVersionSpec{ - KeptnAppSpec: lifecyclev1alpha3.KeptnAppSpec{ + Spec: lifecyclev1beta1.KeptnAppVersionSpec{ + KeptnAppSpec: lifecyclev1beta1.KeptnAppSpec{ Version: "previousVersion", }, AppName: "appName", @@ -255,23 +255,23 @@ func TestMetrics_ObserveDeploymentInterval(t *testing.T) { }, { name: "previous version - object found with endtime", - list: &lifecyclev1alpha3.KeptnAppVersionList{}, - previous: &lifecyclev1alpha3.KeptnAppVersion{}, - clientObjects: &lifecyclev1alpha3.KeptnAppVersionList{ - Items: []lifecyclev1alpha3.KeptnAppVersion{ + list: &lifecyclev1beta1.KeptnAppVersionList{}, + previous: &lifecyclev1beta1.KeptnAppVersion{}, + clientObjects: &lifecyclev1beta1.KeptnAppVersionList{ + Items: []lifecyclev1beta1.KeptnAppVersion{ { ObjectMeta: metav1.ObjectMeta{ Name: "appName-version", Namespace: "namespace", }, - Spec: lifecyclev1alpha3.KeptnAppVersionSpec{ - KeptnAppSpec: lifecyclev1alpha3.KeptnAppSpec{ + Spec: lifecyclev1beta1.KeptnAppVersionSpec{ + KeptnAppSpec: lifecyclev1beta1.KeptnAppSpec{ Version: "version", }, AppName: "appName", PreviousVersion: "previousVersion", }, - Status: lifecyclev1alpha3.KeptnAppVersionStatus{ + Status: lifecyclev1beta1.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: lifecyclev1alpha3.KeptnAppVersionSpec{ - KeptnAppSpec: lifecyclev1alpha3.KeptnAppSpec{ + Spec: lifecyclev1beta1.KeptnAppVersionSpec{ + KeptnAppSpec: lifecyclev1beta1.KeptnAppSpec{ Version: "previousVersion", }, AppName: "appName", PreviousVersion: "", }, - Status: lifecyclev1alpha3.KeptnAppVersionStatus{ + Status: lifecyclev1beta1.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: &lifecyclev1alpha3.KeptnAppVersionList{}, - previous: &lifecyclev1alpha3.KeptnAppVersion{}, - clientObjects: &lifecyclev1alpha3.KeptnAppVersionList{ - Items: []lifecyclev1alpha3.KeptnAppVersion{ + list: &lifecyclev1beta1.KeptnAppVersionList{}, + previous: &lifecyclev1beta1.KeptnAppVersion{}, + clientObjects: &lifecyclev1beta1.KeptnAppVersionList{ + Items: []lifecyclev1beta1.KeptnAppVersion{ { ObjectMeta: metav1.ObjectMeta{ Name: "appName-version-1", Namespace: "namespace", Generation: 1, }, - Spec: lifecyclev1alpha3.KeptnAppVersionSpec{ - KeptnAppSpec: lifecyclev1alpha3.KeptnAppSpec{ + Spec: lifecyclev1beta1.KeptnAppVersionSpec{ + KeptnAppSpec: lifecyclev1beta1.KeptnAppSpec{ Version: "version", }, AppName: "appName", PreviousVersion: "previousVersion", }, - Status: lifecyclev1alpha3.KeptnAppVersionStatus{ + Status: lifecyclev1beta1.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: lifecyclev1alpha3.KeptnAppVersionSpec{ - KeptnAppSpec: lifecyclev1alpha3.KeptnAppSpec{ + Spec: lifecyclev1beta1.KeptnAppVersionSpec{ + KeptnAppSpec: lifecyclev1beta1.KeptnAppSpec{ Version: "previousVersion", }, AppName: "appName", PreviousVersion: "", }, - Status: lifecyclev1alpha3.KeptnAppVersionStatus{ + Status: lifecyclev1beta1.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: lifecyclev1alpha3.KeptnAppVersionSpec{ - KeptnAppSpec: lifecyclev1alpha3.KeptnAppSpec{ + Spec: lifecyclev1beta1.KeptnAppVersionSpec{ + KeptnAppSpec: lifecyclev1beta1.KeptnAppSpec{ Version: "previousVersion", }, AppName: "appName", PreviousVersion: "", }, - Status: lifecyclev1alpha3.KeptnAppVersionStatus{ + Status: lifecyclev1beta1.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 := lifecyclev1alpha3.AddToScheme(scheme.Scheme) + err := lifecyclev1beta1.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 := &lifecyclev1alpha3.KeptnAppVersionList{ - Items: []lifecyclev1alpha3.KeptnAppVersion{ + appVersions := &lifecyclev1beta1.KeptnAppVersionList{ + Items: []lifecyclev1beta1.KeptnAppVersion{ { ObjectMeta: metav1.ObjectMeta{ Name: "my-app-1.0.0-1", Generation: 1, }, - Spec: lifecyclev1alpha3.KeptnAppVersionSpec{ - KeptnAppSpec: lifecyclev1alpha3.KeptnAppSpec{ + Spec: lifecyclev1beta1.KeptnAppVersionSpec{ + KeptnAppSpec: lifecyclev1beta1.KeptnAppSpec{ Version: "1.0.0", }, AppName: "my-app", }, - Status: lifecyclev1alpha3.KeptnAppVersionStatus{ + Status: lifecyclev1beta1.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: lifecyclev1alpha3.KeptnAppVersionSpec{ - KeptnAppSpec: lifecyclev1alpha3.KeptnAppSpec{ + Spec: lifecyclev1beta1.KeptnAppVersionSpec{ + KeptnAppSpec: lifecyclev1beta1.KeptnAppSpec{ Version: "1.0.0", }, AppName: "my-app", }, - Status: lifecyclev1alpha3.KeptnAppVersionStatus{ + Status: lifecyclev1beta1.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: lifecyclev1alpha3.KeptnAppVersionSpec{ - KeptnAppSpec: lifecyclev1alpha3.KeptnAppSpec{ + Spec: lifecyclev1beta1.KeptnAppVersionSpec{ + KeptnAppSpec: lifecyclev1beta1.KeptnAppSpec{ Version: "1.1.0", }, AppName: "my-app", PreviousVersion: "1.0.0", }, - Status: lifecyclev1alpha3.KeptnAppVersionStatus{ + Status: lifecyclev1beta1.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 a3fd632fcb2..ccf8b341ea7 100644 --- a/lifecycle-operator/controllers/common/telemetry/otel_utils.go +++ b/lifecycle-operator/controllers/common/telemetry/otel_utils.go @@ -7,9 +7,8 @@ import ( "sync" "time" - lifecyclev1alpha3 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3" - "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3/common" - lifecyclev1alpha4 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha4" + lifecyclev1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" + "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/lifecycle/interfaces" "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc" @@ -218,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, &lifecyclev1alpha3.KeptnAppVersionList{}, appDeploymentDurationGauge, observer) + err := ObserveDeploymentDuration(ctx, mgr, &lifecyclev1beta1.KeptnAppVersionList{}, appDeploymentDurationGauge, observer) if err != nil { logger.Error(err, "unable to gather app deployment durations") } - err = ObserveDeploymentDuration(ctx, mgr, &lifecyclev1alpha4.KeptnWorkloadVersionList{}, workloadDeploymentDurationGauge, observer) + err = ObserveDeploymentDuration(ctx, mgr, &lifecyclev1beta1.KeptnWorkloadVersionList{}, workloadDeploymentDurationGauge, observer) if err != nil { logger.Error(err, "unable to gather workload deployment durations") } @@ -231,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, &lifecyclev1alpha3.KeptnAppVersionList{}, appDeploymentIntervalGauge, observer) + err := ObserveDeploymentInterval(ctx, mgr, &lifecyclev1beta1.KeptnAppVersionList{}, appDeploymentIntervalGauge, observer) if err != nil { logger.Error(err, "unable to gather app deployment intervals") } - err = ObserveDeploymentInterval(ctx, mgr, &lifecyclev1alpha4.KeptnWorkloadVersionList{}, workloadDeploymentIntervalGauge, observer) + err = ObserveDeploymentInterval(ctx, mgr, &lifecyclev1beta1.KeptnWorkloadVersionList{}, workloadDeploymentIntervalGauge, observer) if err != nil { logger.Error(err, "unable to gather workload deployment intervals") } @@ -244,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, &lifecyclev1alpha4.KeptnWorkloadVersionList{}, deploymentActiveGauge, observer) + err := ObserveActiveInstances(ctx, mgr, &lifecyclev1beta1.KeptnWorkloadVersionList{}, deploymentActiveGauge, observer) if err != nil { logger.Error(err, "unable to gather active deployments") } - err = ObserveActiveInstances(ctx, mgr, &lifecyclev1alpha3.KeptnAppVersionList{}, appActiveGauge, observer) + err = ObserveActiveInstances(ctx, mgr, &lifecyclev1beta1.KeptnAppVersionList{}, appActiveGauge, observer) if err != nil { logger.Error(err, "unable to gather active apps") } - err = ObserveActiveInstances(ctx, mgr, &lifecyclev1alpha3.KeptnTaskList{}, taskActiveGauge, observer) + err = ObserveActiveInstances(ctx, mgr, &lifecyclev1beta1.KeptnTaskList{}, taskActiveGauge, observer) if err != nil { logger.Error(err, "unable to gather active tasks") } - err = ObserveActiveInstances(ctx, mgr, &lifecyclev1alpha3.KeptnEvaluationList{}, evaluationActiveGauge, observer) + err = ObserveActiveInstances(ctx, mgr, &lifecyclev1beta1.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 9bde007a892..70807dee2f0 100644 --- a/lifecycle-operator/controllers/common/telemetry/spanhandler_test.go +++ b/lifecycle-operator/controllers/common/telemetry/spanhandler_test.go @@ -4,16 +4,15 @@ import ( "context" "testing" - "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3/common" - "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha4" + "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" "github.com/stretchr/testify/require" "go.opentelemetry.io/otel" "sigs.k8s.io/controller-runtime/pkg/client" ) func TestSpanHandler_GetAndUnbindSpan_WorkloadVersion(t *testing.T) { - wi := &v1alpha4.KeptnWorkloadVersion{} + wi := &v1beta1.KeptnWorkloadVersion{} wi.Spec.TraceId = make(map[string]string, 1) wi.Spec.TraceId["test"] = "test" wi.Spec.AppName = "test" @@ -23,7 +22,7 @@ func TestSpanHandler_GetAndUnbindSpan_WorkloadVersion(t *testing.T) { } func TestSpanHandler_GetAndUnbindSpan_AppVersion(t *testing.T) { - av := &v1alpha3.KeptnAppVersion{} + av := &v1beta1.KeptnAppVersion{} av.Spec.TraceId = make(map[string]string, 1) av.Spec.TraceId["test"] = "test" av.Spec.AppName = "test" @@ -50,7 +49,7 @@ func doAssert(t *testing.T, obj client.Object) { } func TestSpanHandler_GetSpan(t *testing.T) { - wi := &v1alpha4.KeptnWorkloadVersion{} + wi := &v1beta1.KeptnWorkloadVersion{} wi.Spec.TraceId = make(map[string]string, 1) wi.Spec.TraceId["traceparent"] = "test-parent" wi.Spec.AppName = "test" @@ -73,7 +72,7 @@ func TestSpanHandler_GetSpan(t *testing.T) { require.Equal(t, ctx, ctx2) require.Equal(t, span, span2) - wi2 := &v1alpha4.KeptnWorkloadVersion{} + wi2 := &v1beta1.KeptnWorkloadVersion{} wi2.Spec.TraceId = make(map[string]string, 1) wi2.Spec.TraceId["traceparent"] = "test-parent2" wi2.Spec.AppName = "test2" diff --git a/lifecycle-operator/controllers/common/testcommon/utils.go b/lifecycle-operator/controllers/common/testcommon/utils.go index d759943f4b9..76c1494cb9a 100644 --- a/lifecycle-operator/controllers/common/testcommon/utils.go +++ b/lifecycle-operator/controllers/common/testcommon/utils.go @@ -3,9 +3,8 @@ package testcommon import ( "fmt" - klcv1alpha3 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3/common" - lfcv1alpha4 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha4" + klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" optionsv1alpha1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/options/v1alpha1" "go.opentelemetry.io/otel/metric" sdkmetric "go.opentelemetry.io/otel/sdk/metric" @@ -31,38 +30,37 @@ func SetupSchemes() { utilruntime.Must(clientgoscheme.AddToScheme(scheme.Scheme)) utilruntime.Must(corev1.AddToScheme(scheme.Scheme)) utilruntime.Must(apiv1.AddToScheme(scheme.Scheme)) - utilruntime.Must(klcv1alpha3.AddToScheme(scheme.Scheme)) - utilruntime.Must(lfcv1alpha4.AddToScheme(scheme.Scheme)) + utilruntime.Must(klcv1beta1.AddToScheme(scheme.Scheme)) utilruntime.Must(optionsv1alpha1.AddToScheme(scheme.Scheme)) } -func GetApp(name string) *klcv1alpha3.KeptnApp { - app := &klcv1alpha3.KeptnApp{ +func GetApp(name string) *klcv1beta1.KeptnApp { + app := &klcv1beta1.KeptnApp{ TypeMeta: metav1.TypeMeta{}, ObjectMeta: metav1.ObjectMeta{ Name: name, Namespace: "default", Generation: 1, }, - Spec: klcv1alpha3.KeptnAppSpec{ + Spec: klcv1beta1.KeptnAppSpec{ Version: "1.0.0", }, - Status: klcv1alpha3.KeptnAppStatus{}, + Status: klcv1beta1.KeptnAppStatus{}, } return app } -func ReturnAppVersion(namespace string, appName string, version string, workloads []klcv1alpha3.KeptnWorkloadRef, status klcv1alpha3.KeptnAppVersionStatus) *klcv1alpha3.KeptnAppVersion { +func ReturnAppVersion(namespace string, appName string, version string, workloads []klcv1beta1.KeptnWorkloadRef, status klcv1beta1.KeptnAppVersionStatus) *klcv1beta1.KeptnAppVersion { appVersionName := fmt.Sprintf("%s-%s", appName, version) - app := &klcv1alpha3.KeptnAppVersion{ + app := &klcv1beta1.KeptnAppVersion{ TypeMeta: metav1.TypeMeta{}, ObjectMeta: metav1.ObjectMeta{ Name: appVersionName, Namespace: namespace, Generation: 1, }, - Spec: klcv1alpha3.KeptnAppVersionSpec{ - KeptnAppSpec: klcv1alpha3.KeptnAppSpec{ + Spec: klcv1beta1.KeptnAppVersionSpec{ + KeptnAppSpec: klcv1beta1.KeptnAppSpec{ Version: version, Workloads: workloads, }, diff --git a/lifecycle-operator/controllers/lifecycle/interfaces/activemetricsobject_test.go b/lifecycle-operator/controllers/lifecycle/interfaces/activemetricsobject_test.go index f14fb8ba509..62a68cc7dfa 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/v1alpha3" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3/common" + "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/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 := v1alpha3.KeptnAppVersion{ - Status: v1alpha3.KeptnAppVersionStatus{ + appVersion := v1beta1.KeptnAppVersion{ + Status: v1beta1.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 20ff4d82f04..2d82820bc69 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/v1alpha3" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3/common" + "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/lifecycle/interfaces/fake" "github.com/stretchr/testify/require" ) func TestEventObjectWrapper(t *testing.T) { - appVersion := v1alpha3.KeptnAppVersion{ - Status: v1alpha3.KeptnAppVersionStatus{ + appVersion := v1beta1.KeptnAppVersion{ + Status: v1beta1.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 2393116ccae..33d0e2a1756 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 ( - klcv1alpha3 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3/common" + klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/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 klcv1alpha3.KeptnEvaluationDefinition, checkType apicommon.CheckType) klcv1alpha3.KeptnEvaluation { +// GenerateEvaluationFunc: func(evaluationDefinition klcv1beta1.KeptnEvaluationDefinition, checkType apicommon.CheckType) klcv1beta1.KeptnEvaluation { // panic("mock out the GenerateEvaluation method") // }, -// GenerateTaskFunc: func(taskDefinition klcv1alpha3.KeptnTaskDefinition, checkType apicommon.CheckType) klcv1alpha3.KeptnTask { +// GenerateTaskFunc: func(taskDefinition klcv1beta1.KeptnTaskDefinition, checkType apicommon.CheckType) klcv1beta1.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() []klcv1alpha3.ItemStatus { +// GetPostDeploymentEvaluationTaskStatusFunc: func() []klcv1beta1.ItemStatus { // panic("mock out the GetPostDeploymentEvaluationTaskStatus method") // }, // GetPostDeploymentEvaluationsFunc: func() []string { // panic("mock out the GetPostDeploymentEvaluations method") // }, -// GetPostDeploymentTaskStatusFunc: func() []klcv1alpha3.ItemStatus { +// GetPostDeploymentTaskStatusFunc: func() []klcv1beta1.ItemStatus { // panic("mock out the GetPostDeploymentTaskStatus method") // }, // GetPostDeploymentTasksFunc: func() []string { // panic("mock out the GetPostDeploymentTasks method") // }, -// GetPreDeploymentEvaluationTaskStatusFunc: func() []klcv1alpha3.ItemStatus { +// GetPreDeploymentEvaluationTaskStatusFunc: func() []klcv1beta1.ItemStatus { // panic("mock out the GetPreDeploymentEvaluationTaskStatus method") // }, // GetPreDeploymentEvaluationsFunc: func() []string { // panic("mock out the GetPreDeploymentEvaluations method") // }, -// GetPreDeploymentTaskStatusFunc: func() []klcv1alpha3.ItemStatus { +// GetPreDeploymentTaskStatusFunc: func() []klcv1beta1.ItemStatus { // panic("mock out the GetPreDeploymentTaskStatus method") // }, // GetPreDeploymentTasksFunc: func() []string { @@ -110,10 +110,10 @@ type PhaseItemMock struct { DeprecateRemainingPhasesFunc func(phase apicommon.KeptnPhaseType) // GenerateEvaluationFunc mocks the GenerateEvaluation method. - GenerateEvaluationFunc func(evaluationDefinition klcv1alpha3.KeptnEvaluationDefinition, checkType apicommon.CheckType) klcv1alpha3.KeptnEvaluation + GenerateEvaluationFunc func(evaluationDefinition klcv1beta1.KeptnEvaluationDefinition, checkType apicommon.CheckType) klcv1beta1.KeptnEvaluation // GenerateTaskFunc mocks the GenerateTask method. - GenerateTaskFunc func(taskDefinition klcv1alpha3.KeptnTaskDefinition, checkType apicommon.CheckType) klcv1alpha3.KeptnTask + GenerateTaskFunc func(taskDefinition klcv1beta1.KeptnTaskDefinition, checkType apicommon.CheckType) klcv1beta1.KeptnTask // GetAppNameFunc mocks the GetAppName method. GetAppNameFunc func() string @@ -131,25 +131,25 @@ type PhaseItemMock struct { GetParentNameFunc func() string // GetPostDeploymentEvaluationTaskStatusFunc mocks the GetPostDeploymentEvaluationTaskStatus method. - GetPostDeploymentEvaluationTaskStatusFunc func() []klcv1alpha3.ItemStatus + GetPostDeploymentEvaluationTaskStatusFunc func() []klcv1beta1.ItemStatus // GetPostDeploymentEvaluationsFunc mocks the GetPostDeploymentEvaluations method. GetPostDeploymentEvaluationsFunc func() []string // GetPostDeploymentTaskStatusFunc mocks the GetPostDeploymentTaskStatus method. - GetPostDeploymentTaskStatusFunc func() []klcv1alpha3.ItemStatus + GetPostDeploymentTaskStatusFunc func() []klcv1beta1.ItemStatus // GetPostDeploymentTasksFunc mocks the GetPostDeploymentTasks method. GetPostDeploymentTasksFunc func() []string // GetPreDeploymentEvaluationTaskStatusFunc mocks the GetPreDeploymentEvaluationTaskStatus method. - GetPreDeploymentEvaluationTaskStatusFunc func() []klcv1alpha3.ItemStatus + GetPreDeploymentEvaluationTaskStatusFunc func() []klcv1beta1.ItemStatus // GetPreDeploymentEvaluationsFunc mocks the GetPreDeploymentEvaluations method. GetPreDeploymentEvaluationsFunc func() []string // GetPreDeploymentTaskStatusFunc mocks the GetPreDeploymentTaskStatus method. - GetPreDeploymentTaskStatusFunc func() []klcv1alpha3.ItemStatus + GetPreDeploymentTaskStatusFunc func() []klcv1beta1.ItemStatus // GetPreDeploymentTasksFunc mocks the GetPreDeploymentTasks method. GetPreDeploymentTasksFunc func() []string @@ -194,14 +194,14 @@ type PhaseItemMock struct { // GenerateEvaluation holds details about calls to the GenerateEvaluation method. GenerateEvaluation []struct { // EvaluationDefinition is the evaluationDefinition argument value. - EvaluationDefinition klcv1alpha3.KeptnEvaluationDefinition + EvaluationDefinition klcv1beta1.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 klcv1alpha3.KeptnTaskDefinition + TaskDefinition klcv1beta1.KeptnTaskDefinition // CheckType is the checkType argument value. CheckType apicommon.CheckType } @@ -366,12 +366,12 @@ func (mock *PhaseItemMock) DeprecateRemainingPhasesCalls() []struct { } // GenerateEvaluation calls GenerateEvaluationFunc. -func (mock *PhaseItemMock) GenerateEvaluation(evaluationDefinition klcv1alpha3.KeptnEvaluationDefinition, checkType apicommon.CheckType) klcv1alpha3.KeptnEvaluation { +func (mock *PhaseItemMock) GenerateEvaluation(evaluationDefinition klcv1beta1.KeptnEvaluationDefinition, checkType apicommon.CheckType) klcv1beta1.KeptnEvaluation { if mock.GenerateEvaluationFunc == nil { panic("PhaseItemMock.GenerateEvaluationFunc: method is nil but PhaseItem.GenerateEvaluation was just called") } callInfo := struct { - EvaluationDefinition klcv1alpha3.KeptnEvaluationDefinition + EvaluationDefinition klcv1beta1.KeptnEvaluationDefinition CheckType apicommon.CheckType }{ EvaluationDefinition: evaluationDefinition, @@ -388,11 +388,11 @@ func (mock *PhaseItemMock) GenerateEvaluation(evaluationDefinition klcv1alpha3.K // // len(mockedPhaseItem.GenerateEvaluationCalls()) func (mock *PhaseItemMock) GenerateEvaluationCalls() []struct { - EvaluationDefinition klcv1alpha3.KeptnEvaluationDefinition + EvaluationDefinition klcv1beta1.KeptnEvaluationDefinition CheckType apicommon.CheckType } { var calls []struct { - EvaluationDefinition klcv1alpha3.KeptnEvaluationDefinition + EvaluationDefinition klcv1beta1.KeptnEvaluationDefinition CheckType apicommon.CheckType } mock.lockGenerateEvaluation.RLock() @@ -402,12 +402,12 @@ func (mock *PhaseItemMock) GenerateEvaluationCalls() []struct { } // GenerateTask calls GenerateTaskFunc. -func (mock *PhaseItemMock) GenerateTask(taskDefinition klcv1alpha3.KeptnTaskDefinition, checkType apicommon.CheckType) klcv1alpha3.KeptnTask { +func (mock *PhaseItemMock) GenerateTask(taskDefinition klcv1beta1.KeptnTaskDefinition, checkType apicommon.CheckType) klcv1beta1.KeptnTask { if mock.GenerateTaskFunc == nil { panic("PhaseItemMock.GenerateTaskFunc: method is nil but PhaseItem.GenerateTask was just called") } callInfo := struct { - TaskDefinition klcv1alpha3.KeptnTaskDefinition + TaskDefinition klcv1beta1.KeptnTaskDefinition CheckType apicommon.CheckType }{ TaskDefinition: taskDefinition, @@ -424,11 +424,11 @@ func (mock *PhaseItemMock) GenerateTask(taskDefinition klcv1alpha3.KeptnTaskDefi // // len(mockedPhaseItem.GenerateTaskCalls()) func (mock *PhaseItemMock) GenerateTaskCalls() []struct { - TaskDefinition klcv1alpha3.KeptnTaskDefinition + TaskDefinition klcv1beta1.KeptnTaskDefinition CheckType apicommon.CheckType } { var calls []struct { - TaskDefinition klcv1alpha3.KeptnTaskDefinition + TaskDefinition klcv1beta1.KeptnTaskDefinition CheckType apicommon.CheckType } mock.lockGenerateTask.RLock() @@ -573,7 +573,7 @@ func (mock *PhaseItemMock) GetParentNameCalls() []struct { } // GetPostDeploymentEvaluationTaskStatus calls GetPostDeploymentEvaluationTaskStatusFunc. -func (mock *PhaseItemMock) GetPostDeploymentEvaluationTaskStatus() []klcv1alpha3.ItemStatus { +func (mock *PhaseItemMock) GetPostDeploymentEvaluationTaskStatus() []klcv1beta1.ItemStatus { if mock.GetPostDeploymentEvaluationTaskStatusFunc == nil { panic("PhaseItemMock.GetPostDeploymentEvaluationTaskStatusFunc: method is nil but PhaseItem.GetPostDeploymentEvaluationTaskStatus was just called") } @@ -627,7 +627,7 @@ func (mock *PhaseItemMock) GetPostDeploymentEvaluationsCalls() []struct { } // GetPostDeploymentTaskStatus calls GetPostDeploymentTaskStatusFunc. -func (mock *PhaseItemMock) GetPostDeploymentTaskStatus() []klcv1alpha3.ItemStatus { +func (mock *PhaseItemMock) GetPostDeploymentTaskStatus() []klcv1beta1.ItemStatus { if mock.GetPostDeploymentTaskStatusFunc == nil { panic("PhaseItemMock.GetPostDeploymentTaskStatusFunc: method is nil but PhaseItem.GetPostDeploymentTaskStatus was just called") } @@ -681,7 +681,7 @@ func (mock *PhaseItemMock) GetPostDeploymentTasksCalls() []struct { } // GetPreDeploymentEvaluationTaskStatus calls GetPreDeploymentEvaluationTaskStatusFunc. -func (mock *PhaseItemMock) GetPreDeploymentEvaluationTaskStatus() []klcv1alpha3.ItemStatus { +func (mock *PhaseItemMock) GetPreDeploymentEvaluationTaskStatus() []klcv1beta1.ItemStatus { if mock.GetPreDeploymentEvaluationTaskStatusFunc == nil { panic("PhaseItemMock.GetPreDeploymentEvaluationTaskStatusFunc: method is nil but PhaseItem.GetPreDeploymentEvaluationTaskStatus was just called") } @@ -735,7 +735,7 @@ func (mock *PhaseItemMock) GetPreDeploymentEvaluationsCalls() []struct { } // GetPreDeploymentTaskStatus calls GetPreDeploymentTaskStatusFunc. -func (mock *PhaseItemMock) GetPreDeploymentTaskStatus() []klcv1alpha3.ItemStatus { +func (mock *PhaseItemMock) GetPreDeploymentTaskStatus() []klcv1beta1.ItemStatus { if mock.GetPreDeploymentTaskStatusFunc == nil { panic("PhaseItemMock.GetPreDeploymentTaskStatusFunc: method is nil but PhaseItem.GetPreDeploymentTaskStatus was just called") } diff --git a/lifecycle-operator/controllers/lifecycle/interfaces/listitem_test.go b/lifecycle-operator/controllers/lifecycle/interfaces/listitem_test.go index c4a775f4a89..a4d9a632457 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/v1alpha3" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3/common" + "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/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 := v1alpha3.KeptnAppVersionList{ - Items: []v1alpha3.KeptnAppVersion{ + appVersionList := v1beta1.KeptnAppVersionList{ + Items: []v1beta1.KeptnAppVersion{ { - Status: v1alpha3.KeptnAppVersionStatus{ + Status: v1beta1.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 91c2b3c59d2..7cf1f8c13a0 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/v1alpha3" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3/common" + "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/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 := v1alpha3.KeptnAppVersion{ - Status: v1alpha3.KeptnAppVersionStatus{ + appVersion := v1beta1.KeptnAppVersion{ + Status: v1beta1.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 ce5d7b06471..14578f09c15 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" - klcv1alpha3 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3/common" + klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/errors" "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/trace" @@ -30,14 +30,14 @@ type PhaseItem interface { GetAppName() string GetPreDeploymentTasks() []string GetPostDeploymentTasks() []string - GetPreDeploymentTaskStatus() []klcv1alpha3.ItemStatus - GetPostDeploymentTaskStatus() []klcv1alpha3.ItemStatus + GetPreDeploymentTaskStatus() []klcv1beta1.ItemStatus + GetPostDeploymentTaskStatus() []klcv1beta1.ItemStatus GetPreDeploymentEvaluations() []string GetPostDeploymentEvaluations() []string - GetPreDeploymentEvaluationTaskStatus() []klcv1alpha3.ItemStatus - GetPostDeploymentEvaluationTaskStatus() []klcv1alpha3.ItemStatus - GenerateTask(taskDefinition klcv1alpha3.KeptnTaskDefinition, checkType apicommon.CheckType) klcv1alpha3.KeptnTask - GenerateEvaluation(evaluationDefinition klcv1alpha3.KeptnEvaluationDefinition, checkType apicommon.CheckType) klcv1alpha3.KeptnEvaluation + GetPreDeploymentEvaluationTaskStatus() []klcv1beta1.ItemStatus + GetPostDeploymentEvaluationTaskStatus() []klcv1beta1.ItemStatus + GenerateTask(taskDefinition klcv1beta1.KeptnTaskDefinition, checkType apicommon.CheckType) klcv1beta1.KeptnTask + GenerateEvaluation(evaluationDefinition klcv1beta1.KeptnEvaluationDefinition, checkType apicommon.CheckType) klcv1beta1.KeptnEvaluation GetSpanAttributes() []attribute.KeyValue SetSpanAttributes(span trace.Span) DeprecateRemainingPhases(phase apicommon.KeptnPhaseType) @@ -115,11 +115,11 @@ func (pw PhaseItemWrapper) GetPostDeploymentTasks() []string { return pw.Obj.GetPostDeploymentTasks() } -func (pw PhaseItemWrapper) GetPreDeploymentTaskStatus() []klcv1alpha3.ItemStatus { +func (pw PhaseItemWrapper) GetPreDeploymentTaskStatus() []klcv1beta1.ItemStatus { return pw.Obj.GetPreDeploymentTaskStatus() } -func (pw PhaseItemWrapper) GetPostDeploymentTaskStatus() []klcv1alpha3.ItemStatus { +func (pw PhaseItemWrapper) GetPostDeploymentTaskStatus() []klcv1beta1.ItemStatus { return pw.Obj.GetPostDeploymentTaskStatus() } @@ -131,19 +131,19 @@ func (pw PhaseItemWrapper) GetPostDeploymentEvaluations() []string { return pw.Obj.GetPostDeploymentEvaluations() } -func (pw PhaseItemWrapper) GetPreDeploymentEvaluationTaskStatus() []klcv1alpha3.ItemStatus { +func (pw PhaseItemWrapper) GetPreDeploymentEvaluationTaskStatus() []klcv1beta1.ItemStatus { return pw.Obj.GetPreDeploymentEvaluationTaskStatus() } -func (pw PhaseItemWrapper) GetPostDeploymentEvaluationTaskStatus() []klcv1alpha3.ItemStatus { +func (pw PhaseItemWrapper) GetPostDeploymentEvaluationTaskStatus() []klcv1beta1.ItemStatus { return pw.Obj.GetPostDeploymentEvaluationTaskStatus() } -func (pw PhaseItemWrapper) GenerateTask(taskDefinition klcv1alpha3.KeptnTaskDefinition, checkType apicommon.CheckType) klcv1alpha3.KeptnTask { +func (pw PhaseItemWrapper) GenerateTask(taskDefinition klcv1beta1.KeptnTaskDefinition, checkType apicommon.CheckType) klcv1beta1.KeptnTask { return pw.Obj.GenerateTask(taskDefinition, checkType) } -func (pw PhaseItemWrapper) GenerateEvaluation(evaluationDefinition klcv1alpha3.KeptnEvaluationDefinition, checkType apicommon.CheckType) klcv1alpha3.KeptnEvaluation { +func (pw PhaseItemWrapper) GenerateEvaluation(evaluationDefinition klcv1beta1.KeptnEvaluationDefinition, checkType apicommon.CheckType) klcv1beta1.KeptnEvaluation { return pw.Obj.GenerateEvaluation(evaluationDefinition, checkType) } diff --git a/lifecycle-operator/controllers/lifecycle/interfaces/phaseitem_test.go b/lifecycle-operator/controllers/lifecycle/interfaces/phaseitem_test.go index 082b7053813..b1dd6ef9d96 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/v1alpha3" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3/common" + "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/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 := &v1alpha3.KeptnAppVersion{ - Status: v1alpha3.KeptnAppVersionStatus{ + appVersion := &v1beta1.KeptnAppVersion{ + Status: v1beta1.KeptnAppVersionStatus{ Status: apicommon.StateFailed, CurrentPhase: "test", }, @@ -77,10 +77,10 @@ func TestPhaseItem(t *testing.T) { GetPostDeploymentTasksFunc: func() []string { return nil }, - GetPreDeploymentTaskStatusFunc: func() []v1alpha3.ItemStatus { + GetPreDeploymentTaskStatusFunc: func() []v1beta1.ItemStatus { return nil }, - GetPostDeploymentTaskStatusFunc: func() []v1alpha3.ItemStatus { + GetPostDeploymentTaskStatusFunc: func() []v1beta1.ItemStatus { return nil }, GetPreDeploymentEvaluationsFunc: func() []string { @@ -89,17 +89,17 @@ func TestPhaseItem(t *testing.T) { GetPostDeploymentEvaluationsFunc: func() []string { return nil }, - GetPreDeploymentEvaluationTaskStatusFunc: func() []v1alpha3.ItemStatus { + GetPreDeploymentEvaluationTaskStatusFunc: func() []v1beta1.ItemStatus { return nil }, - GetPostDeploymentEvaluationTaskStatusFunc: func() []v1alpha3.ItemStatus { + GetPostDeploymentEvaluationTaskStatusFunc: func() []v1beta1.ItemStatus { return nil }, - GenerateTaskFunc: func(taskDefinition v1alpha3.KeptnTaskDefinition, checkType apicommon.CheckType) v1alpha3.KeptnTask { - return v1alpha3.KeptnTask{} + GenerateTaskFunc: func(taskDefinition v1beta1.KeptnTaskDefinition, checkType apicommon.CheckType) v1beta1.KeptnTask { + return v1beta1.KeptnTask{} }, - GenerateEvaluationFunc: func(evaluationDefinition v1alpha3.KeptnEvaluationDefinition, checkType apicommon.CheckType) v1alpha3.KeptnEvaluation { - return v1alpha3.KeptnEvaluation{} + GenerateEvaluationFunc: func(evaluationDefinition v1beta1.KeptnEvaluationDefinition, checkType apicommon.CheckType) v1beta1.KeptnEvaluation { + return v1beta1.KeptnEvaluation{} }, SetSpanAttributesFunc: func(span trace.Span) { }, @@ -175,10 +175,10 @@ func TestPhaseItem(t *testing.T) { _ = wrapper.GetPostDeploymentEvaluationTaskStatus() require.Len(t, phaseItemMock.GetPostDeploymentEvaluationTaskStatusCalls(), 1) - _ = wrapper.GenerateTask(v1alpha3.KeptnTaskDefinition{}, apicommon.PostDeploymentCheckType) + _ = wrapper.GenerateTask(v1beta1.KeptnTaskDefinition{}, apicommon.PostDeploymentCheckType) require.Len(t, phaseItemMock.GenerateTaskCalls(), 1) - _ = wrapper.GenerateEvaluation(v1alpha3.KeptnEvaluationDefinition{}, apicommon.PostDeploymentCheckType) + _ = wrapper.GenerateEvaluation(v1beta1.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 910340d9f2d..a44ef9c4d96 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/v1alpha3" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3/common" + "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/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 := &v1alpha3.KeptnEvaluation{ + evaluation := &v1beta1.KeptnEvaluation{ ObjectMeta: v1.ObjectMeta{ Name: "evaluation", }, - Spec: v1alpha3.KeptnEvaluationSpec{ + Spec: v1beta1.KeptnEvaluationSpec{ AppName: "app", AppVersion: "appversion", Type: apicommon.PostDeploymentCheckType, }, - Status: v1alpha3.KeptnEvaluationStatus{ + Status: v1beta1.KeptnEvaluationStatus{ OverallStatus: apicommon.StateFailed, }, } diff --git a/lifecycle-operator/controllers/lifecycle/keptnapp/controller.go b/lifecycle-operator/controllers/lifecycle/keptnapp/controller.go index c5593be42c9..3385d894cea 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" - klcv1alpha3 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3" - "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3/common" + klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" + "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/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" @@ -68,7 +68,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 := &klcv1alpha3.KeptnApp{} + app := &klcv1beta1.KeptnApp{} err := r.Get(ctx, req.NamespacedName, app) if errors.IsNotFound(err) { return reconcile.Result{}, nil @@ -82,7 +82,7 @@ func (r *KeptnAppReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c r.Log.Info("Reconciling Keptn App", "app", app.Name) - appVersion := &klcv1alpha3.KeptnAppVersion{} + appVersion := &klcv1beta1.KeptnAppVersion{} // Try to find the AppVersion err = r.Get(ctx, types.NamespacedName{Namespace: app.Namespace, Name: app.GetAppVersionName()}, appVersion) @@ -120,11 +120,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(&klcv1alpha3.KeptnApp{}, builder.WithPredicates(predicate.GenerationChangedPredicate{})). + For(&klcv1beta1.KeptnApp{}, builder.WithPredicates(predicate.GenerationChangedPredicate{})). Complete(r) } -func (r *KeptnAppReconciler) createAppVersion(ctx context.Context, app *klcv1alpha3.KeptnApp) (*klcv1alpha3.KeptnAppVersion, error) { +func (r *KeptnAppReconciler) createAppVersion(ctx context.Context, app *klcv1beta1.KeptnApp) (*klcv1beta1.KeptnAppVersion, error) { previousVersion := "" if app.Spec.Version != app.Status.CurrentVersion { @@ -141,7 +141,7 @@ func (r *KeptnAppReconciler) createAppVersion(ctx context.Context, app *klcv1alp return &appVersion, err } -func (r *KeptnAppReconciler) handleGenerationBump(ctx context.Context, app *klcv1alpha3.KeptnApp) error { +func (r *KeptnAppReconciler) handleGenerationBump(ctx context.Context, app *klcv1beta1.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()) @@ -152,11 +152,11 @@ func (r *KeptnAppReconciler) handleGenerationBump(ctx context.Context, app *klcv return nil } -func (r *KeptnAppReconciler) deprecateAppVersions(ctx context.Context, app *klcv1alpha3.KeptnApp) error { +func (r *KeptnAppReconciler) deprecateAppVersions(ctx context.Context, app *klcv1beta1.KeptnApp) error { var lastResultErr error lastResultErr = nil for i := app.Generation - 1; i > 0; i-- { - deprecatedAppVersion := &klcv1alpha3.KeptnAppVersion{} + deprecatedAppVersion := &klcv1beta1.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 aa604e563ab..31081210300 100644 --- a/lifecycle-operator/controllers/lifecycle/keptnapp/controller_test.go +++ b/lifecycle-operator/controllers/lifecycle/keptnapp/controller_test.go @@ -6,8 +6,8 @@ import ( "reflect" "testing" - lfcv1alpha3 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3/common" + lfcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/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" @@ -24,17 +24,17 @@ import ( // Example Unit test on help function func TestKeptnAppReconciler_createAppVersionSuccess(t *testing.T) { - app := &lfcv1alpha3.KeptnApp{ + app := &lfcv1beta1.KeptnApp{ TypeMeta: metav1.TypeMeta{}, ObjectMeta: metav1.ObjectMeta{ Name: "my-app", Namespace: "default", Generation: 1, }, - Spec: lfcv1alpha3.KeptnAppSpec{ + Spec: lfcv1beta1.KeptnAppSpec{ Version: "1.0.0", }, - Status: lfcv1alpha3.KeptnAppStatus{}, + Status: lfcv1beta1.KeptnAppStatus{}, } r, _ := setupReconciler() @@ -53,11 +53,11 @@ func TestKeptnAppReconciler_createAppVersionWithLongName(t *testing.T) { //nolint:gci trimmedName := `loremipsumissimplydummytextoftheprintingandtypesettingindustryloremipsumissimplydummytextoftheprintingandtypesettingindustryloremipsumissimplydummytextoftheprintingandtypesettingindustryloremipsumissimplydummytextoftheprintingandtypeset-version-5feceb66` - app := &lfcv1alpha3.KeptnApp{ + app := &lfcv1beta1.KeptnApp{ ObjectMeta: metav1.ObjectMeta{ Name: longName, }, - Spec: lfcv1alpha3.KeptnAppSpec{ + Spec: lfcv1beta1.KeptnAppSpec{ Version: "version", }, } @@ -115,7 +115,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, lfcv1alpha3.KeptnAppVersionStatus{Status: apicommon.StateSucceeded}) + appver := testcommon.ReturnAppVersion("default", "myfinishedapp", "1.0.0-6b86b273", nil, lfcv1beta1.KeptnAppVersionStatus{Status: apicommon.StateSucceeded}) r, _ := setupReconciler(app, appfin, appver) for _, tt := range tests { @@ -127,7 +127,7 @@ func TestKeptnAppReconciler_reconcile(t *testing.T) { return } if tt.appVersionName != "" { - keptnappversion := &lfcv1alpha3.KeptnAppVersion{} + keptnappversion := &lfcv1beta1.KeptnAppVersion{} err = r.Client.Get(context.TODO(), types.NamespacedName{Namespace: "default", Name: "myapp-1.0.0-6b86b273"}, keptnappversion) require.Nil(t, err) } @@ -141,7 +141,7 @@ func TestKeptnAppReconciler_deprecateAppVersions(t *testing.T) { app := testcommon.GetApp("myapp") app.Spec.Revision = uint(2) app.Generation = int64(2) - appVersion := &lfcv1alpha3.KeptnAppVersion{ + appVersion := &lfcv1beta1.KeptnAppVersion{ ObjectMeta: metav1.ObjectMeta{ Name: "myapp-1.0.0-6b86b273", Namespace: "default", @@ -158,7 +158,7 @@ func TestKeptnAppReconciler_deprecateAppVersions(t *testing.T) { require.Nil(t, err) - keptnappversion := &lfcv1alpha3.KeptnAppVersion{} + keptnappversion := &lfcv1beta1.KeptnAppVersion{} err = r.Client.Get(context.TODO(), types.NamespacedName{Namespace: "default", Name: "myapp-1.0.0-d4735e3a"}, keptnappversion) require.Nil(t, err) diff --git a/lifecycle-operator/controllers/lifecycle/keptnappcreationrequest/controller.go b/lifecycle-operator/controllers/lifecycle/keptnappcreationrequest/controller.go index d9c013cc897..915ceedc23d 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/v1alpha3" - "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3/common" + lifecycle "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" + "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/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" diff --git a/lifecycle-operator/controllers/lifecycle/keptnappcreationrequest/controller_test.go b/lifecycle-operator/controllers/lifecycle/keptnappcreationrequest/controller_test.go index 45d183093a7..b5fefbc0e71 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" - klcv1alpha3 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3" + klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" "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 := &klcv1alpha3.KeptnAppCreationRequest{ + kacr := &klcv1beta1.KeptnAppCreationRequest{ ObjectMeta: metav1.ObjectMeta{ Name: "my-kacr", Namespace: namespace, CreationTimestamp: metav1.Time{Time: theClock.Now()}, }, - Spec: klcv1alpha3.KeptnAppCreationRequestSpec{ + Spec: klcv1beta1.KeptnAppCreationRequestSpec{ AppName: appName, }, } @@ -41,12 +41,12 @@ func TestKeptnAppCreationRequestReconciler_CreateAppAfterTimeout_SingleWorkload( err := fakeClient.Create(context.TODO(), kacr) require.Nil(t, err) - workload1 := &klcv1alpha3.KeptnWorkload{ + workload1 := &klcv1beta1.KeptnWorkload{ ObjectMeta: metav1.ObjectMeta{ Name: "w1", Namespace: namespace, }, - Spec: klcv1alpha3.KeptnWorkloadSpec{ + Spec: klcv1beta1.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 := &klcv1alpha3.KeptnApp{} + kApp := &klcv1beta1.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, klcv1alpha3.KeptnWorkloadRef{ + require.Contains(t, kApp.Spec.Workloads, klcv1beta1.KeptnWorkloadRef{ Name: workload1.Name, Version: workload1.Spec.Version, }) // verify that the creationRequest has been deleted - cr := &klcv1alpha3.KeptnAppCreationRequest{} + cr := &klcv1beta1.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 := &klcv1alpha3.KeptnAppCreationRequest{ + kacr := &klcv1beta1.KeptnAppCreationRequest{ ObjectMeta: metav1.ObjectMeta{ Name: "my-kacr", Namespace: namespace, CreationTimestamp: metav1.Time{Time: theClock.Now()}, }, - Spec: klcv1alpha3.KeptnAppCreationRequestSpec{ + Spec: klcv1beta1.KeptnAppCreationRequestSpec{ AppName: appName, }, } @@ -120,23 +120,23 @@ func TestKeptnAppCreationRequestReconciler_CreateAppAfterTimeout(t *testing.T) { err := fakeClient.Create(context.TODO(), kacr) require.Nil(t, err) - workload1 := &klcv1alpha3.KeptnWorkload{ + workload1 := &klcv1beta1.KeptnWorkload{ ObjectMeta: metav1.ObjectMeta{ Name: "w1", Namespace: namespace, }, - Spec: klcv1alpha3.KeptnWorkloadSpec{ + Spec: klcv1beta1.KeptnWorkloadSpec{ AppName: appName, Version: "1.0", }, } - workload2 := &klcv1alpha3.KeptnWorkload{ + workload2 := &klcv1beta1.KeptnWorkload{ ObjectMeta: metav1.ObjectMeta{ Name: "w2", Namespace: namespace, }, - Spec: klcv1alpha3.KeptnWorkloadSpec{ + Spec: klcv1beta1.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 := &klcv1alpha3.KeptnApp{} + kApp := &klcv1beta1.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, klcv1alpha3.KeptnWorkloadRef{ + require.Contains(t, kApp.Spec.Workloads, klcv1beta1.KeptnWorkloadRef{ Name: workload1.Name, Version: workload1.Spec.Version, }) - require.Contains(t, kApp.Spec.Workloads, klcv1alpha3.KeptnWorkloadRef{ + require.Contains(t, kApp.Spec.Workloads, klcv1beta1.KeptnWorkloadRef{ Name: workload2.Name, Version: workload2.Spec.Version, }) // verify that the creationRequest has been deleted - cr := &klcv1alpha3.KeptnAppCreationRequest{} + cr := &klcv1beta1.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 := &klcv1alpha3.KeptnAppCreationRequest{ + kacr := &klcv1beta1.KeptnAppCreationRequest{ ObjectMeta: metav1.ObjectMeta{ Name: "my-kacr", Namespace: namespace, CreationTimestamp: metav1.Time{Time: theClock.Now()}, }, - Spec: klcv1alpha3.KeptnAppCreationRequestSpec{ + Spec: klcv1beta1.KeptnAppCreationRequestSpec{ AppName: appName, }, } @@ -213,12 +213,12 @@ func TestKeptnAppCreationRequestReconciler_UpdateWorkloadsWithNewWorkload(t *tes err := fakeClient.Create(context.TODO(), kacr) require.Nil(t, err) - workload1 := &klcv1alpha3.KeptnWorkload{ + workload1 := &klcv1beta1.KeptnWorkload{ ObjectMeta: metav1.ObjectMeta{ Name: "w1", Namespace: namespace, }, - Spec: klcv1alpha3.KeptnWorkloadSpec{ + Spec: klcv1beta1.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 := &klcv1alpha3.KeptnApp{} + kApp := &klcv1beta1.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, klcv1alpha3.KeptnWorkloadRef{ + require.Contains(t, kApp.Spec.Workloads, klcv1beta1.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 := &klcv1alpha3.KeptnAppCreationRequest{} + cr := &klcv1beta1.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 := &klcv1alpha3.KeptnWorkload{ + workload2 := &klcv1beta1.KeptnWorkload{ ObjectMeta: metav1.ObjectMeta{ Name: "w2", Namespace: namespace, }, - Spec: klcv1alpha3.KeptnWorkloadSpec{ + Spec: klcv1beta1.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 := &klcv1alpha3.KeptnAppCreationRequest{ + newKACR := &klcv1beta1.KeptnAppCreationRequest{ ObjectMeta: metav1.ObjectMeta{ Name: "my-kacr", Namespace: namespace, CreationTimestamp: metav1.Time{Time: theClock.Now()}, }, - Spec: klcv1alpha3.KeptnAppCreationRequestSpec{ + Spec: klcv1beta1.KeptnAppCreationRequestSpec{ AppName: appName, }, } @@ -307,7 +307,7 @@ func TestKeptnAppCreationRequestReconciler_UpdateWorkloadsWithNewWorkload(t *tes require.False(t, res.Requeue) require.Zero(t, res.RequeueAfter) - kApp = &klcv1alpha3.KeptnApp{} + kApp = &klcv1beta1.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, klcv1alpha3.KeptnWorkloadRef{ + require.Contains(t, kApp.Spec.Workloads, klcv1beta1.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, klcv1alpha3.KeptnWorkloadRef{ + require.Contains(t, kApp.Spec.Workloads, klcv1beta1.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 := &klcv1alpha3.KeptnAppCreationRequest{ + kacr := &klcv1beta1.KeptnAppCreationRequest{ ObjectMeta: metav1.ObjectMeta{ Name: "my-kacr", Namespace: namespace, CreationTimestamp: metav1.Time{Time: theClock.Now()}, }, - Spec: klcv1alpha3.KeptnAppCreationRequestSpec{ + Spec: klcv1beta1.KeptnAppCreationRequestSpec{ AppName: appName, }, } @@ -346,12 +346,12 @@ func TestKeptnAppCreationRequestReconciler_UpdateWorkloadsWithNewVersion(t *test err := fakeClient.Create(context.TODO(), kacr) require.Nil(t, err) - workload1 := &klcv1alpha3.KeptnWorkload{ + workload1 := &klcv1beta1.KeptnWorkload{ ObjectMeta: metav1.ObjectMeta{ Name: "w1", Namespace: namespace, }, - Spec: klcv1alpha3.KeptnWorkloadSpec{ + Spec: klcv1beta1.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 := &klcv1alpha3.KeptnApp{} + kApp := &klcv1beta1.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, klcv1alpha3.KeptnWorkloadRef{ + require.Contains(t, kApp.Spec.Workloads, klcv1beta1.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 := &klcv1alpha3.KeptnAppCreationRequest{} + cr := &klcv1beta1.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 := &klcv1alpha3.KeptnAppCreationRequest{ + newKACR := &klcv1beta1.KeptnAppCreationRequest{ ObjectMeta: metav1.ObjectMeta{ Name: "my-kacr", Namespace: namespace, CreationTimestamp: metav1.Time{Time: theClock.Now()}, }, - Spec: klcv1alpha3.KeptnAppCreationRequestSpec{ + Spec: klcv1beta1.KeptnAppCreationRequestSpec{ AppName: appName, }, } @@ -429,7 +429,7 @@ func TestKeptnAppCreationRequestReconciler_UpdateWorkloadsWithNewVersion(t *test require.False(t, res.Requeue) require.Zero(t, res.RequeueAfter) - kApp = &klcv1alpha3.KeptnApp{} + kApp = &klcv1beta1.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, klcv1alpha3.KeptnWorkloadRef{ + require.Contains(t, kApp.Spec.Workloads, klcv1beta1.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 := &klcv1alpha3.KeptnAppCreationRequest{ + kacr := &klcv1beta1.KeptnAppCreationRequest{ ObjectMeta: metav1.ObjectMeta{ Name: "my-kacr", Namespace: namespace, CreationTimestamp: metav1.Time{Time: theClock.Now()}, }, - Spec: klcv1alpha3.KeptnAppCreationRequestSpec{ + Spec: klcv1beta1.KeptnAppCreationRequestSpec{ AppName: appName, }, } @@ -464,12 +464,12 @@ func TestKeptnAppCreationRequestReconciler_RemoveWorkload(t *testing.T) { err := fakeClient.Create(context.TODO(), kacr) require.Nil(t, err) - workload1 := &klcv1alpha3.KeptnWorkload{ + workload1 := &klcv1beta1.KeptnWorkload{ ObjectMeta: metav1.ObjectMeta{ Name: "w1", Namespace: namespace, }, - Spec: klcv1alpha3.KeptnWorkloadSpec{ + Spec: klcv1beta1.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 := &klcv1alpha3.KeptnWorkload{ + workload2 := &klcv1beta1.KeptnWorkload{ ObjectMeta: metav1.ObjectMeta{ Name: "w2", Namespace: namespace, }, - Spec: klcv1alpha3.KeptnWorkloadSpec{ + Spec: klcv1beta1.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 := &klcv1alpha3.KeptnApp{} + kApp := &klcv1beta1.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, klcv1alpha3.KeptnWorkloadRef{ + require.Contains(t, kApp.Spec.Workloads, klcv1beta1.KeptnWorkloadRef{ Name: workload1.Name, Version: workload1.Spec.Version, }) - require.Contains(t, kApp.Spec.Workloads, klcv1alpha3.KeptnWorkloadRef{ + require.Contains(t, kApp.Spec.Workloads, klcv1beta1.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 := &klcv1alpha3.KeptnAppCreationRequest{} + cr := &klcv1beta1.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 := &klcv1alpha3.KeptnAppCreationRequest{ + newKACR := &klcv1beta1.KeptnAppCreationRequest{ ObjectMeta: metav1.ObjectMeta{ Name: "my-kacr", Namespace: namespace, CreationTimestamp: metav1.Time{Time: theClock.Now()}, }, - Spec: klcv1alpha3.KeptnAppCreationRequestSpec{ + Spec: klcv1beta1.KeptnAppCreationRequestSpec{ AppName: appName, }, } @@ -562,7 +562,7 @@ func TestKeptnAppCreationRequestReconciler_RemoveWorkload(t *testing.T) { require.False(t, res.Requeue) require.Zero(t, res.RequeueAfter) - kApp = &klcv1alpha3.KeptnApp{} + kApp = &klcv1beta1.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, klcv1alpha3.KeptnWorkloadRef{ + require.Contains(t, kApp.Spec.Workloads, klcv1beta1.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 := &klcv1alpha3.KeptnAppCreationRequest{ + kacr := &klcv1beta1.KeptnAppCreationRequest{ ObjectMeta: metav1.ObjectMeta{ Name: "my-kacr", Namespace: namespace, CreationTimestamp: metav1.Time{Time: theClock.Now()}, }, - Spec: klcv1alpha3.KeptnAppCreationRequestSpec{ + Spec: klcv1beta1.KeptnAppCreationRequestSpec{ AppName: appName, }, } @@ -597,12 +597,12 @@ func TestKeptnAppCreationRequestReconciler_DoNotOverwriteUserDefinedApp(t *testi err := fakeClient.Create(context.TODO(), kacr) require.Nil(t, err) - existingApp := &klcv1alpha3.KeptnApp{ + existingApp := &klcv1beta1.KeptnApp{ ObjectMeta: metav1.ObjectMeta{ Name: appName, Namespace: namespace, }, - Spec: klcv1alpha3.KeptnAppSpec{ + Spec: klcv1beta1.KeptnAppSpec{ Version: "1.0", }, } @@ -628,7 +628,7 @@ func TestKeptnAppCreationRequestReconciler_DoNotOverwriteUserDefinedApp(t *testi require.False(t, res.Requeue) require.Zero(t, res.RequeueAfter) - kApp := &klcv1alpha3.KeptnApp{} + kApp := &klcv1beta1.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 := &klcv1alpha3.KeptnAppCreationRequest{} + cr := &klcv1beta1.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 := klcv1alpha3.AddToScheme(scheme) + err := klcv1beta1.AddToScheme(scheme) require.Nil(t, err) workloadAppIndexer := func(obj client.Object) []string { - workload, _ := obj.(*klcv1alpha3.KeptnWorkload) + workload, _ := obj.(*klcv1beta1.KeptnWorkload) return []string{workload.Spec.AppName} } - fakeClient := k8sfake.NewClientBuilder().WithScheme(scheme).WithObjects().WithIndex(&klcv1alpha3.KeptnWorkload{}, "spec.app", workloadAppIndexer).Build() + fakeClient := k8sfake.NewClientBuilder().WithScheme(scheme).WithObjects().WithIndex(&klcv1beta1.KeptnWorkload{}, "spec.app", workloadAppIndexer).Build() theClock := clock.NewMock() r := &KeptnAppCreationRequestReconciler{ @@ -690,23 +690,23 @@ func TestKeptnAppCreationRequestReconciler_getWorkloads(t *testing.T) { appName := "my-app" - workload1 := &klcv1alpha3.KeptnWorkload{ + workload1 := &klcv1beta1.KeptnWorkload{ ObjectMeta: metav1.ObjectMeta{ Name: "workloadA", Namespace: namespace, }, - Spec: klcv1alpha3.KeptnWorkloadSpec{ + Spec: klcv1beta1.KeptnWorkloadSpec{ AppName: appName, Version: "1.0", }, } - workload2 := &klcv1alpha3.KeptnWorkload{ + workload2 := &klcv1beta1.KeptnWorkload{ ObjectMeta: metav1.ObjectMeta{ Name: "workloadB", Namespace: namespace, }, - Spec: klcv1alpha3.KeptnWorkloadSpec{ + Spec: klcv1beta1.KeptnWorkloadSpec{ AppName: appName, Version: "1.0", }, @@ -714,41 +714,41 @@ func TestKeptnAppCreationRequestReconciler_getWorkloads(t *testing.T) { type args struct { ctx context.Context - creationRequest *klcv1alpha3.KeptnAppCreationRequest + creationRequest *klcv1beta1.KeptnAppCreationRequest } tests := []struct { name string args args - workloadsInCluster []klcv1alpha3.KeptnWorkload - want []klcv1alpha3.KeptnWorkload + workloadsInCluster []klcv1beta1.KeptnWorkload + want []klcv1beta1.KeptnWorkload wantErr bool }{ { name: "get workloads in alphabetical order - already sorted", args: args{ ctx: context.Background(), - creationRequest: &klcv1alpha3.KeptnAppCreationRequest{ - Spec: klcv1alpha3.KeptnAppCreationRequestSpec{ + creationRequest: &klcv1beta1.KeptnAppCreationRequest{ + Spec: klcv1beta1.KeptnAppCreationRequestSpec{ AppName: appName, }, }, }, - workloadsInCluster: []klcv1alpha3.KeptnWorkload{*workload1, *workload2}, - want: []klcv1alpha3.KeptnWorkload{*workload1, *workload2}, + workloadsInCluster: []klcv1beta1.KeptnWorkload{*workload1, *workload2}, + want: []klcv1beta1.KeptnWorkload{*workload1, *workload2}, wantErr: false, }, { name: "get workloads in alphabetical order - not sorted", args: args{ ctx: context.Background(), - creationRequest: &klcv1alpha3.KeptnAppCreationRequest{ - Spec: klcv1alpha3.KeptnAppCreationRequestSpec{ + creationRequest: &klcv1beta1.KeptnAppCreationRequest{ + Spec: klcv1beta1.KeptnAppCreationRequestSpec{ AppName: appName, }, }, }, - workloadsInCluster: []klcv1alpha3.KeptnWorkload{*workload2, *workload1}, - want: []klcv1alpha3.KeptnWorkload{*workload1, *workload2}, + workloadsInCluster: []klcv1beta1.KeptnWorkload{*workload2, *workload1}, + want: []klcv1beta1.KeptnWorkload{*workload1, *workload2}, wantErr: false, }, } diff --git a/lifecycle-operator/controllers/lifecycle/keptnappversion/controller.go b/lifecycle-operator/controllers/lifecycle/keptnappversion/controller.go index eb4dfb84f7e..a4a85ea668a 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" - klcv1alpha3 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3/common" + klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" controllercommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/evaluation" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/eventsender" @@ -79,7 +79,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 := &klcv1alpha3.KeptnAppVersion{} + appVersion := &klcv1beta1.KeptnAppVersion{} err := r.Get(ctx, req.NamespacedName, appVersion) if errors.IsNotFound(err) { return reconcile.Result{}, nil @@ -162,7 +162,7 @@ func (r *KeptnAppVersionReconciler) Reconcile(ctx context.Context, req ctrl.Requ return r.finishKeptnAppVersionReconcile(ctx, appVersion, spanAppTrace) } -func (r *KeptnAppVersionReconciler) finishKeptnAppVersionReconcile(ctx context.Context, appVersion *klcv1alpha3.KeptnAppVersion, spanAppTrace trace.Span) (ctrl.Result, error) { +func (r *KeptnAppVersionReconciler) finishKeptnAppVersionReconcile(ctx context.Context, appVersion *klcv1beta1.KeptnAppVersion, spanAppTrace trace.Span) (ctrl.Result, error) { if !appVersion.IsEndTimeSet() { appVersion.Status.CurrentPhase = apicommon.PhaseCompleted.ShortName @@ -193,7 +193,7 @@ func (r *KeptnAppVersionReconciler) finishKeptnAppVersionReconcile(ctx context.C return ctrl.Result{}, nil } -func (r *KeptnAppVersionReconciler) setupSpansContexts(ctx context.Context, appVersion *klcv1alpha3.KeptnAppVersion) (context.Context, func()) { +func (r *KeptnAppVersionReconciler) setupSpansContexts(ctx context.Context, appVersion *klcv1beta1.KeptnAppVersion) (context.Context, func()) { appVersion.SetStartTime() appTraceContextCarrier := propagation.MapCarrier(appVersion.Spec.TraceId) @@ -213,7 +213,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(&klcv1alpha3.KeptnAppVersion{}, builder.WithPredicates(predicate.GenerationChangedPredicate{})). + For(&klcv1beta1.KeptnAppVersion{}, builder.WithPredicates(predicate.GenerationChangedPredicate{})). Complete(r) } diff --git a/lifecycle-operator/controllers/lifecycle/keptnappversion/controller_test.go b/lifecycle-operator/controllers/lifecycle/keptnappversion/controller_test.go index 7180de1695a..c64542d6cd4 100644 --- a/lifecycle-operator/controllers/lifecycle/keptnappversion/controller_test.go +++ b/lifecycle-operator/controllers/lifecycle/keptnappversion/controller_test.go @@ -7,9 +7,8 @@ import ( "strings" "testing" - lfcv1alpha3 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3/common" - lfcv1alpha4 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha4" + lfcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/evaluation" evalfake "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/evaluation/fake" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/eventsender" @@ -39,7 +38,7 @@ const CONTEXTID contextID = "start" // this test checks if the chain of reconcile events is correct func TestKeptnAppVersionReconciler_reconcile(t *testing.T) { - pendingStatus := lfcv1alpha3.KeptnAppVersionStatus{ + pendingStatus := lfcv1beta1.KeptnAppVersionStatus{ CurrentPhase: "", Status: apicommon.StatePending, PreDeploymentStatus: apicommon.StatePending, @@ -113,11 +112,11 @@ func TestKeptnAppVersionReconciler_reconcile(t *testing.T) { func TestKeptnAppVersionReconciler_ReconcileFailed(t *testing.T) { - status := lfcv1alpha3.KeptnAppVersionStatus{ + status := lfcv1beta1.KeptnAppVersionStatus{ CurrentPhase: apicommon.PhaseAppPreDeployment.ShortName, Status: apicommon.StateProgressing, PreDeploymentStatus: apicommon.StateProgressing, - PreDeploymentTaskStatus: []lfcv1alpha3.ItemStatus{ + PreDeploymentTaskStatus: []lfcv1beta1.ItemStatus{ { Name: "pre-task", DefinitionName: "task", @@ -131,15 +130,15 @@ func TestKeptnAppVersionReconciler_ReconcileFailed(t *testing.T) { } appVersionName := fmt.Sprintf("%s-%s", "myapp", "1.0.0") - app := &lfcv1alpha3.KeptnAppVersion{ + app := &lfcv1beta1.KeptnAppVersion{ TypeMeta: metav1.TypeMeta{}, ObjectMeta: metav1.ObjectMeta{ Name: appVersionName, Namespace: "default", Generation: 1, }, - Spec: lfcv1alpha3.KeptnAppVersionSpec{ - KeptnAppSpec: lfcv1alpha3.KeptnAppSpec{ + Spec: lfcv1beta1.KeptnAppVersionSpec{ + KeptnAppSpec: lfcv1beta1.KeptnAppSpec{ Version: "1.0.0", PreDeploymentTasks: []string{ "task", @@ -202,19 +201,19 @@ func TestKeptnAppVersionReconciler_ReconcileReachCompletion(t *testing.T) { require.False(t, result.Requeue) } -func createFinishedAppVersionStatus() lfcv1alpha3.KeptnAppVersionStatus { - return lfcv1alpha3.KeptnAppVersionStatus{ +func createFinishedAppVersionStatus() lfcv1beta1.KeptnAppVersionStatus { + return lfcv1beta1.KeptnAppVersionStatus{ CurrentPhase: apicommon.PhaseCompleted.ShortName, PreDeploymentStatus: apicommon.StateSucceeded, PostDeploymentStatus: apicommon.StateSucceeded, PreDeploymentEvaluationStatus: apicommon.StateSucceeded, PostDeploymentEvaluationStatus: apicommon.StateSucceeded, - PreDeploymentTaskStatus: []lfcv1alpha3.ItemStatus{{Status: apicommon.StateSucceeded}}, - PostDeploymentTaskStatus: []lfcv1alpha3.ItemStatus{{Status: apicommon.StateSucceeded}}, - PreDeploymentEvaluationTaskStatus: []lfcv1alpha3.ItemStatus{{Status: apicommon.StateSucceeded}}, - PostDeploymentEvaluationTaskStatus: []lfcv1alpha3.ItemStatus{{Status: 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}}, WorkloadOverallStatus: apicommon.StateSucceeded, - WorkloadStatus: []lfcv1alpha3.WorkloadStatus{{Status: apicommon.StateSucceeded}}, + WorkloadStatus: []lfcv1beta1.WorkloadStatus{{Status: apicommon.StateSucceeded}}, Status: apicommon.StateSucceeded, } } @@ -271,12 +270,12 @@ func setupReconciler(objs ...client.Object) (*KeptnAppVersionReconciler, chan st } workloadVersionIndexer := func(obj client.Object) []string { - workloadVersion, _ := obj.(*lfcv1alpha4.KeptnWorkloadVersion) + workloadVersion, _ := obj.(*lfcv1beta1.KeptnWorkloadVersion) return []string{workloadVersion.Spec.AppName} } testcommon.SetupSchemes() - fakeClient := fake.NewClientBuilder().WithObjects(objs...).WithStatusSubresource(objs...).WithScheme(scheme.Scheme).WithObjects().WithIndex(&lfcv1alpha4.KeptnWorkloadVersion{}, "spec.app", workloadVersionIndexer).Build() + fakeClient := fake.NewClientBuilder().WithObjects(objs...).WithStatusSubresource(objs...).WithScheme(scheme.Scheme).WithObjects().WithIndex(&lfcv1beta1.KeptnWorkloadVersion{}, "spec.app", workloadVersionIndexer).Build() recorder := record.NewFakeRecorder(100) r := &KeptnAppVersionReconciler{ @@ -288,8 +287,8 @@ func setupReconciler(objs ...client.Object) (*KeptnAppVersionReconciler, chan st SpanHandler: spanRecorder, Meters: testcommon.InitAppMeters(), EvaluationHandler: &evalfake.MockEvaluationHandler{ - ReconcileEvaluationsFunc: func(ctx context.Context, phaseCtx context.Context, reconcileObject client.Object, evaluationCreateAttributes evaluation.CreateEvaluationAttributes) ([]lfcv1alpha3.ItemStatus, apicommon.StatusSummary, error) { - return []lfcv1alpha3.ItemStatus{}, apicommon.StatusSummary{}, nil + 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 }, }, } @@ -301,7 +300,7 @@ func TestKeptnApVersionReconciler_setupSpansContexts(t *testing.T) { r := setupReconcilerWithMeters() type args struct { ctx context.Context - appVersion *lfcv1alpha3.KeptnAppVersion + appVersion *lfcv1beta1.KeptnAppVersion } tests := []struct { name string @@ -312,8 +311,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: &lfcv1alpha3.KeptnAppVersion{ - Spec: lfcv1alpha3.KeptnAppVersionSpec{TraceId: map[string]string{ + appVersion: &lfcv1beta1.KeptnAppVersion{ + Spec: lfcv1beta1.KeptnAppVersionSpec{TraceId: map[string]string{ "traceparent": "00-52527d549a7b33653017ce960be09dfc-a38a5a8d179a88b5-01", }}, }, diff --git a/lifecycle-operator/controllers/lifecycle/keptnappversion/reconcile_prepostdeployment.go b/lifecycle-operator/controllers/lifecycle/keptnappversion/reconcile_prepostdeployment.go index da471616e50..e0a8eeb1153 100644 --- a/lifecycle-operator/controllers/lifecycle/keptnappversion/reconcile_prepostdeployment.go +++ b/lifecycle-operator/controllers/lifecycle/keptnappversion/reconcile_prepostdeployment.go @@ -5,12 +5,12 @@ import ( "context" "fmt" - klcv1alpha3 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3/common" + klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/task" ) -func (r *KeptnAppVersionReconciler) reconcilePrePostDeployment(ctx context.Context, phaseCtx context.Context, appVersion *klcv1alpha3.KeptnAppVersion, checkType apicommon.CheckType) (apicommon.KeptnState, error) { +func (r *KeptnAppVersionReconciler) reconcilePrePostDeployment(ctx context.Context, phaseCtx context.Context, appVersion *klcv1beta1.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 822df6df4f6..11629cdc541 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" - klcv1alpha3 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3/common" + klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/evaluation" ) -func (r *KeptnAppVersionReconciler) reconcilePrePostEvaluation(ctx context.Context, phaseCtx context.Context, appVersion *klcv1alpha3.KeptnAppVersion, checkType apicommon.CheckType) (apicommon.KeptnState, error) { +func (r *KeptnAppVersionReconciler) reconcilePrePostEvaluation(ctx context.Context, phaseCtx context.Context, appVersion *klcv1beta1.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 c84c5df5711..6ab02a8c4ad 100644 --- a/lifecycle-operator/controllers/lifecycle/keptnappversion/reconcile_workloadsstate.go +++ b/lifecycle-operator/controllers/lifecycle/keptnappversion/reconcile_workloadsstate.go @@ -4,14 +4,13 @@ import ( "context" "fmt" - klcv1alpha3 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3/common" - klcv1alpha4 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha4" + klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/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 *klcv1alpha3.KeptnAppVersion) (apicommon.KeptnState, error) { +func (r *KeptnAppVersionReconciler) reconcileWorkloads(ctx context.Context, appVersion *klcv1beta1.KeptnAppVersion) (apicommon.KeptnState, error) { r.Log.Info("Reconciling Workloads") var summary apicommon.StatusSummary summary.Total = len(appVersion.Spec.Workloads) @@ -24,7 +23,7 @@ func (r *KeptnAppVersionReconciler) reconcileWorkloads(ctx context.Context, appV return apicommon.StateUnknown, r.handleUnaccessibleWorkloadVersionList(ctx, appVersion) } - newStatus := make([]klcv1alpha3.WorkloadStatus, 0, len(appVersion.Spec.Workloads)) + newStatus := make([]klcv1beta1.WorkloadStatus, 0, len(appVersion.Spec.Workloads)) for _, w := range appVersion.Spec.Workloads { r.Log.Info("Reconciling workload " + w.Name) workloadStatus := apicommon.StatePending @@ -45,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, klcv1alpha3.WorkloadStatus{ + newStatus = append(newStatus, klcv1beta1.WorkloadStatus{ Workload: w, Status: workloadStatus, }) @@ -64,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) (*klcv1alpha4.KeptnWorkloadVersionList, error) { - workloadVersionList := &klcv1alpha4.KeptnWorkloadVersionList{} +func (r *KeptnAppVersionReconciler) getWorkloadVersionList(ctx context.Context, namespace string, appName string) (*klcv1beta1.KeptnWorkloadVersionList, error) { + workloadVersionList := &klcv1beta1.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 *klcv1alpha3.KeptnAppVersion) error { - newStatus := make([]klcv1alpha3.WorkloadStatus, 0, len(appVersion.Spec.Workloads)) +func (r *KeptnAppVersionReconciler) handleUnaccessibleWorkloadVersionList(ctx context.Context, appVersion *klcv1beta1.KeptnAppVersion) error { + newStatus := make([]klcv1beta1.WorkloadStatus, 0, len(appVersion.Spec.Workloads)) for _, w := range appVersion.Spec.Workloads { - newStatus = append(newStatus, klcv1alpha3.WorkloadStatus{ + newStatus = append(newStatus, klcv1beta1.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 c6757274716..62ac8419b81 100644 --- a/lifecycle-operator/controllers/lifecycle/keptnappversion/reconcile_workloadstate_test.go +++ b/lifecycle-operator/controllers/lifecycle/keptnappversion/reconcile_workloadstate_test.go @@ -4,9 +4,8 @@ import ( "context" "testing" - lfcv1alpha3 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3/common" - lfcv1alpha4 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha4" + lfcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" "github.com/stretchr/testify/require" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" @@ -14,12 +13,12 @@ import ( //nolint:dogsled func TestKeptnAppVersionReconciler_reconcileWorkloads_noWorkloads(t *testing.T) { - appVersion := &lfcv1alpha3.KeptnAppVersion{ + appVersion := &lfcv1beta1.KeptnAppVersion{ ObjectMeta: v1.ObjectMeta{ Name: "appversion", Namespace: "default", }, - Spec: lfcv1alpha3.KeptnAppVersionSpec{ + Spec: lfcv1beta1.KeptnAppVersionSpec{ AppName: "app", }, } @@ -37,14 +36,14 @@ func TestKeptnAppVersionReconciler_reconcileWorkloads_noWorkloads(t *testing.T) //nolint:dogsled func TestKeptnAppVersionReconciler_reconcileWorkloads(t *testing.T) { - appVersion := &lfcv1alpha3.KeptnAppVersion{ + appVersion := &lfcv1beta1.KeptnAppVersion{ ObjectMeta: v1.ObjectMeta{ Name: "appversion", Namespace: "default", }, - Spec: lfcv1alpha3.KeptnAppVersionSpec{ - KeptnAppSpec: lfcv1alpha3.KeptnAppSpec{ - Workloads: []lfcv1alpha3.KeptnWorkloadRef{ + Spec: lfcv1beta1.KeptnAppVersionSpec{ + KeptnAppSpec: lfcv1beta1.KeptnAppSpec{ + Workloads: []lfcv1beta1.KeptnWorkloadRef{ { Name: "workload", Version: "ver1", @@ -66,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, []lfcv1alpha3.WorkloadStatus{ + require.Equal(t, []lfcv1beta1.WorkloadStatus{ { - Workload: lfcv1alpha3.KeptnWorkloadRef{ + Workload: lfcv1beta1.KeptnWorkloadRef{ Name: "workload", Version: "ver1", }, @@ -78,13 +77,13 @@ func TestKeptnAppVersionReconciler_reconcileWorkloads(t *testing.T) { // Creating WorkloadInstace that is not part of the App -> should stay Pending - wi1 := &lfcv1alpha4.KeptnWorkloadVersion{ + wi1 := &lfcv1beta1.KeptnWorkloadVersion{ ObjectMeta: v1.ObjectMeta{ Name: "workload", Namespace: "default", }, - Spec: lfcv1alpha4.KeptnWorkloadVersionSpec{ - KeptnWorkloadSpec: lfcv1alpha3.KeptnWorkloadSpec{ + Spec: lfcv1beta1.KeptnWorkloadVersionSpec{ + KeptnWorkloadSpec: lfcv1beta1.KeptnWorkloadSpec{ AppName: "app2", }, }, @@ -101,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, []lfcv1alpha3.WorkloadStatus{ + require.Equal(t, []lfcv1beta1.WorkloadStatus{ { - Workload: lfcv1alpha3.KeptnWorkloadRef{ + Workload: lfcv1beta1.KeptnWorkloadRef{ Name: "workload", Version: "ver1", }, @@ -113,13 +112,13 @@ func TestKeptnAppVersionReconciler_reconcileWorkloads(t *testing.T) { // Creating WorkloadVersion of App with progressing state -> appVersion should be Progressing - wi2 := &lfcv1alpha4.KeptnWorkloadVersion{ + wi2 := &lfcv1beta1.KeptnWorkloadVersion{ ObjectMeta: v1.ObjectMeta{ Name: "app-workload-ver1", Namespace: "default", }, - Spec: lfcv1alpha4.KeptnWorkloadVersionSpec{ - KeptnWorkloadSpec: lfcv1alpha3.KeptnWorkloadSpec{ + Spec: lfcv1beta1.KeptnWorkloadVersionSpec{ + KeptnWorkloadSpec: lfcv1beta1.KeptnWorkloadSpec{ AppName: "app", }, }, @@ -143,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, []lfcv1alpha3.WorkloadStatus{ + require.Equal(t, []lfcv1beta1.WorkloadStatus{ { - Workload: lfcv1alpha3.KeptnWorkloadRef{ + Workload: lfcv1beta1.KeptnWorkloadRef{ Name: "workload", Version: "ver1", }, @@ -170,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, []lfcv1alpha3.WorkloadStatus{ + require.Equal(t, []lfcv1beta1.WorkloadStatus{ { - Workload: lfcv1alpha3.KeptnWorkloadRef{ + Workload: lfcv1beta1.KeptnWorkloadRef{ Name: "workload", Version: "ver1", }, @@ -183,14 +182,14 @@ func TestKeptnAppVersionReconciler_reconcileWorkloads(t *testing.T) { //nolint:dogsled func TestKeptnAppVersionReconciler_handleUnaccessibleWorkloadVersionList(t *testing.T) { - appVersion := &lfcv1alpha3.KeptnAppVersion{ + appVersion := &lfcv1beta1.KeptnAppVersion{ ObjectMeta: v1.ObjectMeta{ Name: "appversion", Namespace: "default", }, - Spec: lfcv1alpha3.KeptnAppVersionSpec{ - KeptnAppSpec: lfcv1alpha3.KeptnAppSpec{ - Workloads: []lfcv1alpha3.KeptnWorkloadRef{ + Spec: lfcv1beta1.KeptnAppVersionSpec{ + KeptnAppSpec: lfcv1beta1.KeptnAppSpec{ + Workloads: []lfcv1beta1.KeptnWorkloadRef{ { Name: "workload", Version: "ver1", @@ -209,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, []lfcv1alpha3.WorkloadStatus{ + require.Equal(t, []lfcv1beta1.WorkloadStatus{ { - Workload: lfcv1alpha3.KeptnWorkloadRef{ + Workload: lfcv1beta1.KeptnWorkloadRef{ Name: "workload", Version: "ver1", }, diff --git a/lifecycle-operator/controllers/lifecycle/keptnevaluation/common.go b/lifecycle-operator/controllers/lifecycle/keptnevaluation/common.go index 0b6750751b3..a02cc84e963 100644 --- a/lifecycle-operator/controllers/lifecycle/keptnevaluation/common.go +++ b/lifecycle-operator/controllers/lifecycle/keptnevaluation/common.go @@ -5,10 +5,10 @@ import ( "math" "strconv" - klcv1alpha3 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3" + klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" ) -func checkValue(objective klcv1alpha3.Objective, item *klcv1alpha3.EvaluationStatusItem) (bool, error) { +func checkValue(objective klcv1beta1.Objective, item *klcv1beta1.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 521dae65277..4f62c3c4d00 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" - klcv1alpha3 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3" + klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" "github.com/stretchr/testify/require" ) func TestCheckValue(t *testing.T) { tests := []struct { name string - obj klcv1alpha3.Objective - item *klcv1alpha3.EvaluationStatusItem + obj klcv1beta1.Objective + item *klcv1beta1.EvaluationStatusItem result bool err bool }{ { name: "empty values", - obj: klcv1alpha3.Objective{}, - item: &klcv1alpha3.EvaluationStatusItem{}, + obj: klcv1beta1.Objective{}, + item: &klcv1beta1.EvaluationStatusItem{}, result: false, err: true, }, { name: "garbage values", - obj: klcv1alpha3.Objective{ - KeptnMetricRef: klcv1alpha3.KeptnMetricReference{ + obj: klcv1beta1.Objective{ + KeptnMetricRef: klcv1beta1.KeptnMetricReference{ Name: "testytest", Namespace: "default", }, EvaluationTarget: "testytest", }, - item: &klcv1alpha3.EvaluationStatusItem{ + item: &klcv1beta1.EvaluationStatusItem{ Value: "testytest", Status: "testytest", Message: "testytest", @@ -41,14 +41,14 @@ func TestCheckValue(t *testing.T) { }, { name: "Item nan", - obj: klcv1alpha3.Objective{ - KeptnMetricRef: klcv1alpha3.KeptnMetricReference{ + obj: klcv1beta1.Objective{ + KeptnMetricRef: klcv1beta1.KeptnMetricReference{ Name: "testytest", Namespace: "default", }, EvaluationTarget: "10", }, - item: &klcv1alpha3.EvaluationStatusItem{ + item: &klcv1beta1.EvaluationStatusItem{ Value: "nan", Status: "all good", Message: "all good", @@ -58,14 +58,14 @@ func TestCheckValue(t *testing.T) { }, { name: "garbage comparison", - obj: klcv1alpha3.Objective{ - KeptnMetricRef: klcv1alpha3.KeptnMetricReference{ + obj: klcv1beta1.Objective{ + KeptnMetricRef: klcv1beta1.KeptnMetricReference{ Name: "testytest", Namespace: "default", }, EvaluationTarget: "testytest", }, - item: &klcv1alpha3.EvaluationStatusItem{ + item: &klcv1beta1.EvaluationStatusItem{ Value: "10", Status: "all good", Message: "all good", @@ -75,14 +75,14 @@ func TestCheckValue(t *testing.T) { }, { name: "objective nan", - obj: klcv1alpha3.Objective{ - KeptnMetricRef: klcv1alpha3.KeptnMetricReference{ + obj: klcv1beta1.Objective{ + KeptnMetricRef: klcv1beta1.KeptnMetricReference{ Name: "testytest", Namespace: "default", }, EvaluationTarget: "nan", }, - item: &klcv1alpha3.EvaluationStatusItem{ + item: &klcv1beta1.EvaluationStatusItem{ Value: "10", Status: "all good", Message: "all good", @@ -92,14 +92,14 @@ func TestCheckValue(t *testing.T) { }, { name: "10>10", - obj: klcv1alpha3.Objective{ - KeptnMetricRef: klcv1alpha3.KeptnMetricReference{ + obj: klcv1beta1.Objective{ + KeptnMetricRef: klcv1beta1.KeptnMetricReference{ Name: "testytest", Namespace: "default", }, EvaluationTarget: ">10", }, - item: &klcv1alpha3.EvaluationStatusItem{ + item: &klcv1beta1.EvaluationStatusItem{ Value: "10", Status: "all good", Message: "all good", @@ -109,14 +109,14 @@ func TestCheckValue(t *testing.T) { }, { name: "9>10", - obj: klcv1alpha3.Objective{ - KeptnMetricRef: klcv1alpha3.KeptnMetricReference{ + obj: klcv1beta1.Objective{ + KeptnMetricRef: klcv1beta1.KeptnMetricReference{ Name: "testytest", Namespace: "default", }, EvaluationTarget: ">10", }, - item: &klcv1alpha3.EvaluationStatusItem{ + item: &klcv1beta1.EvaluationStatusItem{ Value: "9", Status: "all good", Message: "all good", @@ -126,14 +126,14 @@ func TestCheckValue(t *testing.T) { }, { name: "11>10", - obj: klcv1alpha3.Objective{ - KeptnMetricRef: klcv1alpha3.KeptnMetricReference{ + obj: klcv1beta1.Objective{ + KeptnMetricRef: klcv1beta1.KeptnMetricReference{ Name: "testytest", Namespace: "default", }, EvaluationTarget: ">10", }, - item: &klcv1alpha3.EvaluationStatusItem{ + item: &klcv1beta1.EvaluationStatusItem{ Value: "11", Status: "all good", Message: "all good", @@ -143,14 +143,14 @@ func TestCheckValue(t *testing.T) { }, { name: "10<10", - obj: klcv1alpha3.Objective{ - KeptnMetricRef: klcv1alpha3.KeptnMetricReference{ + obj: klcv1beta1.Objective{ + KeptnMetricRef: klcv1beta1.KeptnMetricReference{ Name: "testytest", Namespace: "default", }, EvaluationTarget: "<10", }, - item: &klcv1alpha3.EvaluationStatusItem{ + item: &klcv1beta1.EvaluationStatusItem{ Value: "10", Status: "all good", Message: "all good", @@ -160,14 +160,14 @@ func TestCheckValue(t *testing.T) { }, { name: "9<10", - obj: klcv1alpha3.Objective{ - KeptnMetricRef: klcv1alpha3.KeptnMetricReference{ + obj: klcv1beta1.Objective{ + KeptnMetricRef: klcv1beta1.KeptnMetricReference{ Name: "testytest", Namespace: "default", }, EvaluationTarget: "<10", }, - item: &klcv1alpha3.EvaluationStatusItem{ + item: &klcv1beta1.EvaluationStatusItem{ Value: "9", Status: "all good", Message: "all good", @@ -177,14 +177,14 @@ func TestCheckValue(t *testing.T) { }, { name: "11<10", - obj: klcv1alpha3.Objective{ - KeptnMetricRef: klcv1alpha3.KeptnMetricReference{ + obj: klcv1beta1.Objective{ + KeptnMetricRef: klcv1beta1.KeptnMetricReference{ Name: "testytest", Namespace: "default", }, EvaluationTarget: "<10", }, - item: &klcv1alpha3.EvaluationStatusItem{ + item: &klcv1beta1.EvaluationStatusItem{ Value: "11", Status: "all good", Message: "all good", @@ -194,14 +194,14 @@ func TestCheckValue(t *testing.T) { }, { name: "invalid op", - obj: klcv1alpha3.Objective{ - KeptnMetricRef: klcv1alpha3.KeptnMetricReference{ + obj: klcv1beta1.Objective{ + KeptnMetricRef: klcv1beta1.KeptnMetricReference{ Name: "testytest", Namespace: "default", }, EvaluationTarget: "-10", }, - item: &klcv1alpha3.EvaluationStatusItem{ + item: &klcv1beta1.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 c7a013f95aa..e3940f8c903 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" - klcv1alpha3 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3/common" + klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/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" @@ -49,7 +49,6 @@ type KeptnEvaluationReconciler struct { // +kubebuilder:rbac:groups=lifecycle.keptn.sh,resources=keptnevaluations,verbs=get;list;watch;create;update;patch;delete // +kubebuilder:rbac:groups=lifecycle.keptn.sh,resources=keptnevaluations/status,verbs=get;update;patch // +kubebuilder:rbac:groups=lifecycle.keptn.sh,resources=keptnevaluations/finalizers,verbs=update -// +kubebuilder:rbac:groups=lifecycle.keptn.sh,resources=keptnevaluationproviders,verbs=get;list;watch // +kubebuilder:rbac:groups=lifecycle.keptn.sh,resources=keptnevaluationdefinitions,verbs=get;list;watch // +kubebuilder:rbac:groups=metrics.keptn.sh,resources=keptnmetrics,verbs=get;list;watch @@ -64,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 := &klcv1alpha3.KeptnEvaluation{} + evaluation := &klcv1beta1.KeptnEvaluation{} if err := r.Client.Get(ctx, req.NamespacedName, evaluation); err != nil { if errors.IsNotFound(err) { @@ -113,7 +112,7 @@ func (r *KeptnEvaluationReconciler) Reconcile(ctx context.Context, req ctrl.Requ } -func (r *KeptnEvaluationReconciler) handleEvaluationIncomplete(ctx context.Context, evaluation *klcv1alpha3.KeptnEvaluation) error { +func (r *KeptnEvaluationReconciler) handleEvaluationIncomplete(ctx context.Context, evaluation *klcv1beta1.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 { @@ -125,7 +124,7 @@ func (r *KeptnEvaluationReconciler) handleEvaluationIncomplete(ctx context.Conte } -func (r *KeptnEvaluationReconciler) handleEvaluationExceededRetries(ctx context.Context, evaluation *klcv1alpha3.KeptnEvaluation) { +func (r *KeptnEvaluationReconciler) handleEvaluationExceededRetries(ctx context.Context, evaluation *klcv1beta1.KeptnEvaluation) { r.EventSender.Emit(apicommon.PhaseReconcileEvaluation, "Warning", evaluation, apicommon.PhaseStateReconcileTimeout, "retryCount exceeded", "") evaluation.Status.OverallStatus = apicommon.StateFailed err := r.updateFinishedEvaluationMetrics(ctx, evaluation) @@ -134,12 +133,12 @@ func (r *KeptnEvaluationReconciler) handleEvaluationExceededRetries(ctx context. } } -func (r *KeptnEvaluationReconciler) performEvaluation(ctx context.Context, evaluation *klcv1alpha3.KeptnEvaluation, evaluationDefinition *klcv1alpha3.KeptnEvaluationDefinition) *klcv1alpha3.KeptnEvaluation { +func (r *KeptnEvaluationReconciler) performEvaluation(ctx context.Context, evaluation *klcv1beta1.KeptnEvaluation, evaluationDefinition *klcv1beta1.KeptnEvaluationDefinition) *klcv1beta1.KeptnEvaluation { statusSummary := apicommon.StatusSummary{Total: len(evaluationDefinition.Spec.Objectives)} - newStatus := make(map[string]klcv1alpha3.EvaluationStatusItem) + newStatus := make(map[string]klcv1beta1.EvaluationStatusItem) if evaluation.Status.EvaluationStatus == nil { - evaluation.Status.EvaluationStatus = make(map[string]klcv1alpha3.EvaluationStatusItem) + evaluation.Status.EvaluationStatus = make(map[string]klcv1beta1.EvaluationStatusItem) } provider := &keptnmetric.KeptnMetricProvider{ @@ -162,7 +161,7 @@ func (r *KeptnEvaluationReconciler) performEvaluation(ctx context.Context, evalu return evaluation } -func (r *KeptnEvaluationReconciler) evaluateObjective(ctx context.Context, evaluation *klcv1alpha3.KeptnEvaluation, statusSummary apicommon.StatusSummary, newStatus map[string]klcv1alpha3.EvaluationStatusItem, objective klcv1alpha3.Objective, provider *keptnmetric.KeptnMetricProvider) (map[string]klcv1alpha3.EvaluationStatusItem, apicommon.StatusSummary) { +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) { if _, ok := evaluation.Status.EvaluationStatus[objective.KeptnMetricRef.Name]; !ok { evaluation.AddEvaluationStatus(objective) } @@ -172,7 +171,7 @@ func (r *KeptnEvaluationReconciler) evaluateObjective(ctx context.Context, evalu return newStatus, statusSummary } // resolving the SLI value - statusItem := &klcv1alpha3.EvaluationStatusItem{ + statusItem := &klcv1beta1.EvaluationStatusItem{ Status: apicommon.StateFailed, } @@ -201,13 +200,13 @@ func (r *KeptnEvaluationReconciler) evaluateObjective(ctx context.Context, evalu return updateStatusSummary(statusSummary, statusItem, newStatus, objective) } -func updateStatusSummary(statusSummary apicommon.StatusSummary, statusItem *klcv1alpha3.EvaluationStatusItem, newStatus map[string]klcv1alpha3.EvaluationStatusItem, objective klcv1alpha3.Objective) (map[string]klcv1alpha3.EvaluationStatusItem, apicommon.StatusSummary) { +func updateStatusSummary(statusSummary apicommon.StatusSummary, statusItem *klcv1beta1.EvaluationStatusItem, newStatus map[string]klcv1beta1.EvaluationStatusItem, objective klcv1beta1.Objective) (map[string]klcv1beta1.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 *klcv1alpha3.KeptnEvaluation) error { +func (r *KeptnEvaluationReconciler) updateFinishedEvaluationMetrics(ctx context.Context, evaluation *klcv1beta1.KeptnEvaluation) error { evaluation.SetEndTime() err := r.Client.Status().Update(ctx, evaluation) @@ -232,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(&klcv1alpha3.KeptnEvaluation{}, builder.WithPredicates(predicate.GenerationChangedPredicate{})). + For(&klcv1beta1.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 8b6ca742358..08f72caa10c 100644 --- a/lifecycle-operator/controllers/lifecycle/keptnevaluation/controller_test.go +++ b/lifecycle-operator/controllers/lifecycle/keptnevaluation/controller_test.go @@ -6,12 +6,12 @@ import ( "testing" "github.com/go-logr/logr" - klcv1alpha3 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3" - "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3/common" + klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" + "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/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" - metricsapi "github.com/keptn/lifecycle-toolkit/lifecycle-operator/test/api/metrics/v1alpha3" + metricsapi "github.com/keptn/lifecycle-toolkit/lifecycle-operator/test/api/metrics/v1beta1" "github.com/stretchr/testify/require" "go.opentelemetry.io/otel/sdk/metric" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -37,15 +37,15 @@ func TestKeptnEvaluationReconciler_Reconcile_FailEvaluation(t *testing.T) { }, } - evaluationDefinition := &klcv1alpha3.KeptnEvaluationDefinition{ + evaluationDefinition := &klcv1beta1.KeptnEvaluationDefinition{ ObjectMeta: metav1.ObjectMeta{ Name: "my-definition", Namespace: namespace, }, - Spec: klcv1alpha3.KeptnEvaluationDefinitionSpec{ - Objectives: []klcv1alpha3.Objective{ + Spec: klcv1beta1.KeptnEvaluationDefinitionSpec{ + Objectives: []klcv1beta1.Objective{ { - KeptnMetricRef: klcv1alpha3.KeptnMetricReference{ + KeptnMetricRef: klcv1beta1.KeptnMetricReference{ Name: metric.Name, Namespace: namespace, }, @@ -55,12 +55,12 @@ func TestKeptnEvaluationReconciler_Reconcile_FailEvaluation(t *testing.T) { }, } - evaluation := &klcv1alpha3.KeptnEvaluation{ + evaluation := &klcv1beta1.KeptnEvaluation{ ObjectMeta: metav1.ObjectMeta{ Name: "my-evaluation", Namespace: namespace, }, - Spec: klcv1alpha3.KeptnEvaluationSpec{ + Spec: klcv1beta1.KeptnEvaluationSpec{ EvaluationDefinition: evaluationDefinition.Name, Retries: 1, }, @@ -80,7 +80,7 @@ func TestKeptnEvaluationReconciler_Reconcile_FailEvaluation(t *testing.T) { require.Nil(t, err) require.True(t, reconcile.Requeue) - updatedEvaluation := &klcv1alpha3.KeptnEvaluation{} + updatedEvaluation := &klcv1beta1.KeptnEvaluation{} err = fakeClient.Get(context.TODO(), types.NamespacedName{ Namespace: namespace, Name: evaluation.Name, @@ -106,15 +106,15 @@ func TestKeptnEvaluationReconciler_Reconcile_SucceedEvaluation(t *testing.T) { }, } - evaluationDefinition := &klcv1alpha3.KeptnEvaluationDefinition{ + evaluationDefinition := &klcv1beta1.KeptnEvaluationDefinition{ ObjectMeta: metav1.ObjectMeta{ Name: "my-definition", Namespace: namespace, }, - Spec: klcv1alpha3.KeptnEvaluationDefinitionSpec{ - Objectives: []klcv1alpha3.Objective{ + Spec: klcv1beta1.KeptnEvaluationDefinitionSpec{ + Objectives: []klcv1beta1.Objective{ { - KeptnMetricRef: klcv1alpha3.KeptnMetricReference{ + KeptnMetricRef: klcv1beta1.KeptnMetricReference{ Name: metric.Name, Namespace: namespace, }, @@ -124,12 +124,12 @@ func TestKeptnEvaluationReconciler_Reconcile_SucceedEvaluation(t *testing.T) { }, } - evaluation := &klcv1alpha3.KeptnEvaluation{ + evaluation := &klcv1beta1.KeptnEvaluation{ ObjectMeta: metav1.ObjectMeta{ Name: "my-evaluation", Namespace: namespace, }, - Spec: klcv1alpha3.KeptnEvaluationSpec{ + Spec: klcv1beta1.KeptnEvaluationSpec{ EvaluationDefinition: evaluationDefinition.Name, Retries: 1, }, @@ -149,7 +149,7 @@ func TestKeptnEvaluationReconciler_Reconcile_SucceedEvaluation(t *testing.T) { require.Nil(t, err) require.False(t, reconcile.Requeue) - updatedEvaluation := &klcv1alpha3.KeptnEvaluation{} + updatedEvaluation := &klcv1beta1.KeptnEvaluation{} err = fakeClient.Get(context.TODO(), types.NamespacedName{ Namespace: namespace, Name: evaluation.Name, @@ -175,15 +175,15 @@ func TestKeptnEvaluationReconciler_Reconcile_SucceedEvaluation_withDefinitionInD }, } - evaluationDefinition := &klcv1alpha3.KeptnEvaluationDefinition{ + evaluationDefinition := &klcv1beta1.KeptnEvaluationDefinition{ ObjectMeta: metav1.ObjectMeta{ Name: "my-definition", Namespace: "keptn", }, - Spec: klcv1alpha3.KeptnEvaluationDefinitionSpec{ - Objectives: []klcv1alpha3.Objective{ + Spec: klcv1beta1.KeptnEvaluationDefinitionSpec{ + Objectives: []klcv1beta1.Objective{ { - KeptnMetricRef: klcv1alpha3.KeptnMetricReference{ + KeptnMetricRef: klcv1beta1.KeptnMetricReference{ Name: metric.Name, Namespace: namespace, }, @@ -193,12 +193,12 @@ func TestKeptnEvaluationReconciler_Reconcile_SucceedEvaluation_withDefinitionInD }, } - evaluation := &klcv1alpha3.KeptnEvaluation{ + evaluation := &klcv1beta1.KeptnEvaluation{ ObjectMeta: metav1.ObjectMeta{ Name: "my-evaluation", Namespace: namespace, }, - Spec: klcv1alpha3.KeptnEvaluationSpec{ + Spec: klcv1beta1.KeptnEvaluationSpec{ EvaluationDefinition: evaluationDefinition.Name, Retries: 1, }, @@ -218,7 +218,7 @@ func TestKeptnEvaluationReconciler_Reconcile_SucceedEvaluation_withDefinitionInD require.Nil(t, err) require.False(t, reconcile.Requeue) - updatedEvaluation := &klcv1alpha3.KeptnEvaluation{} + updatedEvaluation := &klcv1beta1.KeptnEvaluation{} err = fakeClient.Get(context.TODO(), types.NamespacedName{ Namespace: namespace, Name: evaluation.Name, @@ -233,7 +233,7 @@ func TestKeptnEvaluationReconciler_Reconcile_SucceedEvaluation_withDefinitionInD func setupReconcilerAndClient(t *testing.T, objects ...client.Object) (*KeptnEvaluationReconciler, client.Client) { scheme := runtime.NewScheme() - err := klcv1alpha3.AddToScheme(scheme) + err := klcv1beta1.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 ae0fa7c0701..fc0be35da8d 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" - klcv1alpha3 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3" + klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" "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 klcv1alpha3.ContainerSpec - taskSpec klcv1alpha3.KeptnTaskSpec + containerSpec klcv1beta1.ContainerSpec + taskSpec klcv1beta1.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 8294a2a82a9..9c0336ba359 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/v1alpha3" + "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" "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: v1alpha3.ContainerSpec{ + containerSpec: v1beta1.ContainerSpec{ Container: &v1.Container{ Image: "image", }, @@ -39,13 +39,13 @@ func TestContainerBuilder_CreateContainerWithVolumes(t *testing.T) { { name: "defined, adding context", builder: ContainerBuilder{ - containerSpec: v1alpha3.ContainerSpec{ + containerSpec: v1beta1.ContainerSpec{ Container: &v1.Container{ Image: "image", }, }, - taskSpec: v1alpha3.KeptnTaskSpec{ - Context: v1alpha3.TaskContext{ + taskSpec: v1beta1.KeptnTaskSpec{ + Context: v1beta1.TaskContext{ WorkloadName: "my-workload", }, }, @@ -63,7 +63,7 @@ func TestContainerBuilder_CreateContainerWithVolumes(t *testing.T) { { name: "defined, replacing context", builder: ContainerBuilder{ - containerSpec: v1alpha3.ContainerSpec{ + containerSpec: v1beta1.ContainerSpec{ Container: &v1.Container{ Image: "image", Env: []v1.EnvVar{ @@ -74,8 +74,8 @@ func TestContainerBuilder_CreateContainerWithVolumes(t *testing.T) { }, }, }, - taskSpec: v1alpha3.KeptnTaskSpec{ - Context: v1alpha3.TaskContext{ + taskSpec: v1beta1.KeptnTaskSpec{ + Context: v1beta1.TaskContext{ WorkloadName: "my-workload", }, }, @@ -93,7 +93,7 @@ func TestContainerBuilder_CreateContainerWithVolumes(t *testing.T) { { name: "nil", builder: ContainerBuilder{ - containerSpec: v1alpha3.ContainerSpec{ + containerSpec: v1beta1.ContainerSpec{ Container: nil, }, }, @@ -123,7 +123,7 @@ func TestContainerBuilder_CreateVolume(t *testing.T) { { name: "defined without volume", builder: ContainerBuilder{ - containerSpec: v1alpha3.ContainerSpec{ + containerSpec: v1beta1.ContainerSpec{ Container: &v1.Container{ Image: "image", }, @@ -134,7 +134,7 @@ func TestContainerBuilder_CreateVolume(t *testing.T) { { name: "defined with volume", builder: ContainerBuilder{ - containerSpec: v1alpha3.ContainerSpec{ + containerSpec: v1beta1.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: v1alpha3.ContainerSpec{ + containerSpec: v1beta1.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 *v1alpha3.ContainerSpec + spec *v1beta1.ContainerSpec want *v1.Volume }{ { name: "defined", - spec: &v1alpha3.ContainerSpec{ + spec: &v1beta1.ContainerSpec{ Container: &v1.Container{ Image: "image", VolumeMounts: []v1.VolumeMount{ @@ -226,7 +226,7 @@ func Test_GenerateVolumes(t *testing.T) { }, { name: "empty", - spec: &v1alpha3.ContainerSpec{}, + spec: &v1beta1.ContainerSpec{}, want: nil, }, } @@ -243,12 +243,12 @@ func Test_GenerateVolumes(t *testing.T) { func Test_GetVolumeSource(t *testing.T) { tests := []struct { name string - spec *v1alpha3.ContainerSpec + spec *v1beta1.ContainerSpec want *v1.EmptyDirVolumeSource }{ { name: "not set limits", - spec: &v1alpha3.ContainerSpec{ + spec: &v1beta1.ContainerSpec{ Container: &v1.Container{ Image: "image", Resources: v1.ResourceRequirements{ @@ -263,7 +263,7 @@ func Test_GetVolumeSource(t *testing.T) { }, { name: "set limits", - spec: &v1alpha3.ContainerSpec{ + spec: &v1beta1.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 143739c6972..7b34d16151e 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" - klcv1alpha3 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3/common" + klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/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 := &klcv1alpha3.KeptnTask{} + task := &klcv1beta1.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(&klcv1alpha3.KeptnTask{}, builder.WithPredicates(predicate.GenerationChangedPredicate{})). + For(&klcv1beta1.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 beeb012035e..ec30d8c5e88 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" - klcv1alpha3 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3" + klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" "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 *klcv1alpha3.KeptnTask - containerSpec *klcv1alpha3.ContainerSpec - funcSpec *klcv1alpha3.RuntimeSpec + task *klcv1beta1.KeptnTask + containerSpec *klcv1beta1.ContainerSpec + funcSpec *klcv1beta1.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 a5a04273093..1fc9eed2571 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/v1alpha3" + "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" "github.com/stretchr/testify/require" v1 "k8s.io/api/core/v1" ) func Test_getJobRunnerBuilder(t *testing.T) { runtimeBuilderOptions := BuilderOptions{ - funcSpec: &v1alpha3.RuntimeSpec{ - Inline: v1alpha3.Inline{ + funcSpec: &v1beta1.RuntimeSpec{ + Inline: v1beta1.Inline{ Code: "some code", }, }, } containerBuilderOptions := BuilderOptions{ - containerSpec: &v1alpha3.ContainerSpec{ + containerSpec: &v1beta1.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 9b3905a386c..87cb55d1e3f 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" - klcv1alpha3 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3/common" + klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/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 *klcv1alpha3.KeptnTask) error { +func (r *KeptnTaskReconciler) createJob(ctx context.Context, req ctrl.Request, task *klcv1beta1.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 *klcv1alpha3.KeptnTask, definition *klcv1alpha3.KeptnTaskDefinition) (string, error) { +func (r *KeptnTaskReconciler) createFunctionJob(ctx context.Context, req ctrl.Request, task *klcv1beta1.KeptnTask, definition *klcv1beta1.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 *klcv1alpha3.KeptnTask) { +func (r *KeptnTaskReconciler) updateTaskStatus(job *batchv1.Job, task *klcv1beta1.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 *klcv1alpha3.KeptnTask, definition *klcv1alpha3.KeptnTaskDefinition, request ctrl.Request) (*batchv1.Job, error) { +func (r *KeptnTaskReconciler) generateJob(ctx context.Context, task *klcv1beta1.KeptnTask, definition *klcv1beta1.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 e162e2e420a..dcff9ba1c81 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" - klcv1alpha3 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3/common" + klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/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 := klcv1alpha3.AddToScheme(fakeClient.Scheme()) + err := klcv1beta1.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) *klcv1alpha3.KeptnTask { - return &klcv1alpha3.KeptnTask{ +func makeTask(name, namespace string, taskDefinitionName string) *klcv1beta1.KeptnTask { + return &klcv1beta1.KeptnTask{ ObjectMeta: metav1.ObjectMeta{ Name: name, Namespace: namespace, @@ -290,8 +290,8 @@ func makeTask(name, namespace string, taskDefinitionName string) *klcv1alpha3.Ke "annotation1": "annotation2", }, }, - Spec: klcv1alpha3.KeptnTaskSpec{ - Context: klcv1alpha3.TaskContext{ + Spec: klcv1beta1.KeptnTaskSpec{ + Context: klcv1beta1.TaskContext{ WorkloadName: "my-workload", AppName: "my-app", AppVersion: "0.1.0", @@ -304,8 +304,8 @@ func makeTask(name, namespace string, taskDefinitionName string) *klcv1alpha3.Ke } } -func makeTaskDefinitionWithConfigmapRef(name, namespace, configMapName string) *klcv1alpha3.KeptnTaskDefinition { - return &klcv1alpha3.KeptnTaskDefinition{ +func makeTaskDefinitionWithConfigmapRef(name, namespace, configMapName string) *klcv1beta1.KeptnTaskDefinition { + return &klcv1beta1.KeptnTaskDefinition{ ObjectMeta: metav1.ObjectMeta{ Name: name, Namespace: namespace, @@ -316,13 +316,13 @@ func makeTaskDefinitionWithConfigmapRef(name, namespace, configMapName string) * "annotation1": "annotation2", }, }, - Spec: klcv1alpha3.KeptnTaskDefinitionSpec{ - Function: &klcv1alpha3.RuntimeSpec{ - ConfigMapReference: klcv1alpha3.ConfigMapReference{ + Spec: klcv1beta1.KeptnTaskDefinitionSpec{ + Function: &klcv1beta1.RuntimeSpec{ + ConfigMapReference: klcv1beta1.ConfigMapReference{ Name: configMapName, }, - Parameters: klcv1alpha3.TaskParameters{Inline: map[string]string{"foo": "bar"}}, - SecureParameters: klcv1alpha3.SecureParameters{Secret: "my-secret"}, + Parameters: klcv1beta1.TaskParameters{Inline: map[string]string{"foo": "bar"}}, + SecureParameters: klcv1beta1.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) *klcv1alpha3.KeptnTaskDefinition { - return &klcv1alpha3.KeptnTaskDefinition{ +func makeTaskDefinitionWithServiceAccount(name, namespace, serviceAccountName string, token *bool, ttlSeconds *int32, imagePullSecrets []v1.LocalObjectReference) *klcv1beta1.KeptnTaskDefinition { + return &klcv1beta1.KeptnTaskDefinition{ ObjectMeta: metav1.ObjectMeta{ Name: name, Namespace: namespace, @@ -352,15 +352,15 @@ func makeTaskDefinitionWithServiceAccount(name, namespace, serviceAccountName st "annotation1": "annotation2", }, }, - Spec: klcv1alpha3.KeptnTaskDefinitionSpec{ - Container: &klcv1alpha3.ContainerSpec{ + Spec: klcv1beta1.KeptnTaskDefinitionSpec{ + Container: &klcv1beta1.ContainerSpec{ Container: &v1.Container{}, }, ImagePullSecrets: imagePullSecrets, - ServiceAccount: &klcv1alpha3.ServiceAccountSpec{ + ServiceAccount: &klcv1beta1.ServiceAccountSpec{ Name: serviceAccountName, }, - AutomountServiceAccountToken: &klcv1alpha3.AutomountServiceAccountTokenSpec{ + AutomountServiceAccountToken: &klcv1beta1.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 3e762787be0..a8048376a93 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" - klcv1alpha3 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3/common" + klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/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 klcv1alpha3.TaskContext + Context klcv1beta1.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 *klcv1alpha3.RuntimeSpec, name string, namespace string, configMap string) (RuntimeExecutionParams, bool, error) { +func (fb *RuntimeBuilder) parseRuntimeTaskDefinition(spec *klcv1beta1.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 != (klcv1alpha3.FunctionReference{}) { + if spec.FunctionReference != (klcv1beta1.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 cac22dedb6a..c2c773f3729 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" - klcv1alpha3 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3/common" + klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/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 := &klcv1alpha3.KeptnTaskDefinition{ + def := &klcv1beta1.KeptnTaskDefinition{ ObjectMeta: metav1.ObjectMeta{ Name: "mytaskdef", Namespace: "default", }, - Spec: klcv1alpha3.KeptnTaskDefinitionSpec{ - Function: &klcv1alpha3.RuntimeSpec{ - FunctionReference: klcv1alpha3.FunctionReference{ + Spec: klcv1beta1.KeptnTaskDefinitionSpec{ + Function: &klcv1beta1.RuntimeSpec{ + FunctionReference: klcv1beta1.FunctionReference{ Name: "mytaskdef", }}}, } - paramDef := &klcv1alpha3.KeptnTaskDefinition{ + paramDef := &klcv1beta1.KeptnTaskDefinition{ ObjectMeta: metav1.ObjectMeta{ Name: "mytd", Namespace: "default", }, - Spec: klcv1alpha3.KeptnTaskDefinitionSpec{ - Function: &klcv1alpha3.RuntimeSpec{ - FunctionReference: klcv1alpha3.FunctionReference{ + Spec: klcv1beta1.KeptnTaskDefinitionSpec{ + Function: &klcv1beta1.RuntimeSpec{ + FunctionReference: klcv1beta1.FunctionReference{ Name: "mytd"}, - Parameters: klcv1alpha3.TaskParameters{ + Parameters: klcv1beta1.TaskParameters{ Inline: map[string]string{Data: "mydata"}, }, - SecureParameters: klcv1alpha3.SecureParameters{ + SecureParameters: klcv1beta1.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 := &klcv1alpha3.KeptnTaskDefinition{ + def := &klcv1beta1.KeptnTaskDefinition{ ObjectMeta: metav1.ObjectMeta{ Name: "mytaskdef", Namespace: "default", }, - Spec: klcv1alpha3.KeptnTaskDefinitionSpec{ - Function: &klcv1alpha3.RuntimeSpec{ - Parameters: klcv1alpha3.TaskParameters{ + Spec: klcv1beta1.KeptnTaskDefinitionSpec{ + Function: &klcv1beta1.RuntimeSpec{ + Parameters: klcv1beta1.TaskParameters{ Inline: map[string]string{"DATA2": "parent_data"}, }, - SecureParameters: klcv1alpha3.SecureParameters{ + SecureParameters: klcv1beta1.SecureParameters{ Secret: "parent_secret", }, }, }, - Status: klcv1alpha3.KeptnTaskDefinitionStatus{ - Function: klcv1alpha3.FunctionStatus{ + Status: klcv1beta1.KeptnTaskDefinitionStatus{ + Function: klcv1beta1.FunctionStatus{ ConfigMap: "mymap", }, }, } - paramDef := &klcv1alpha3.KeptnTaskDefinition{ + paramDef := &klcv1beta1.KeptnTaskDefinition{ ObjectMeta: metav1.ObjectMeta{ Name: "mytd", Namespace: "default", }, - Spec: klcv1alpha3.KeptnTaskDefinitionSpec{ - Deno: &klcv1alpha3.RuntimeSpec{ - FunctionReference: klcv1alpha3.FunctionReference{ + Spec: klcv1beta1.KeptnTaskDefinitionSpec{ + Deno: &klcv1beta1.RuntimeSpec{ + FunctionReference: klcv1beta1.FunctionReference{ Name: def.Name}, - Parameters: klcv1alpha3.TaskParameters{ + Parameters: klcv1beta1.TaskParameters{ Inline: map[string]string{"DATA1": "child_data"}, }, - SecureParameters: klcv1alpha3.SecureParameters{ + SecureParameters: klcv1beta1.SecureParameters{ Secret: "child_pw", }, }, }, - Status: klcv1alpha3.KeptnTaskDefinitionStatus{ - Function: klcv1alpha3.FunctionStatus{ + Status: klcv1beta1.KeptnTaskDefinitionStatus{ + Function: klcv1beta1.FunctionStatus{ ConfigMap: "mychildmap", }, }, } - parentPy := &klcv1alpha3.KeptnTaskDefinition{ + parentPy := &klcv1beta1.KeptnTaskDefinition{ ObjectMeta: metav1.ObjectMeta{ Name: "parentPy", Namespace: "default", }, - Spec: klcv1alpha3.KeptnTaskDefinitionSpec{ - Python: &klcv1alpha3.RuntimeSpec{ - HttpReference: klcv1alpha3.HttpReference{Url: "donothing"}, + Spec: klcv1beta1.KeptnTaskDefinitionSpec{ + Python: &klcv1beta1.RuntimeSpec{ + HttpReference: klcv1beta1.HttpReference{Url: "donothing"}, }}, } - defJS := &klcv1alpha3.KeptnTaskDefinition{ + defJS := &klcv1beta1.KeptnTaskDefinition{ ObjectMeta: metav1.ObjectMeta{ Name: "myJS", Namespace: "default", }, - Spec: klcv1alpha3.KeptnTaskDefinitionSpec{ - Deno: &klcv1alpha3.RuntimeSpec{ - FunctionReference: klcv1alpha3.FunctionReference{ + Spec: klcv1beta1.KeptnTaskDefinitionSpec{ + Deno: &klcv1beta1.RuntimeSpec{ + FunctionReference: klcv1beta1.FunctionReference{ Name: parentPy.Name}, }, }, - Status: klcv1alpha3.KeptnTaskDefinitionStatus{ - Function: klcv1alpha3.FunctionStatus{ + Status: klcv1beta1.KeptnTaskDefinitionStatus{ + Function: klcv1beta1.FunctionStatus{ ConfigMap: "myJSChildmap", }, }, @@ -223,7 +223,7 @@ func TestJSBuilder_getParams(t *testing.T) { Parameters: def.Spec.Function.Parameters.Inline, SecureParameters: def.Spec.Function.SecureParameters.Secret, URL: def.Spec.Function.HttpReference.Url, - Context: klcv1alpha3.TaskContext{ + Context: klcv1beta1.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.Function.HttpReference.Url, // uses parent - Context: klcv1alpha3.TaskContext{ + Context: klcv1beta1.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: klcv1alpha3.TaskContext{ + Context: klcv1beta1.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 ae22ebd9dd4..5482548c239 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" - klcv1alpha3 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3" + klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" 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 := &klcv1alpha3.KeptnTaskDefinition{} + definition := &klcv1beta1.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(&klcv1alpha3.KeptnTaskDefinition{}). + For(&klcv1beta1.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 1734b6c2422..fa87aa8b5cf 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" - klcv1alpha3 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3/common" + klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/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 *klcv1alpha3.RuntimeSpec, name string, namespace string) *corev1.ConfigMap { +func (r *KeptnTaskDefinitionReconciler) generateConfigMap(spec *klcv1beta1.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 *klcv1alpha3.KeptnTaskDefinition) { +func (r *KeptnTaskDefinitionReconciler) updateTaskDefinitionStatus(functionCm *corev1.ConfigMap, definition *klcv1beta1.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 b0d4759a22d..bb53dc86b55 100644 --- a/lifecycle-operator/controllers/lifecycle/keptnworkload/controller.go +++ b/lifecycle-operator/controllers/lifecycle/keptnworkload/controller.go @@ -21,10 +21,8 @@ import ( "fmt" "github.com/go-logr/logr" - klcv1alpha3 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3" - "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3/common" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3/common" - klcv1alpha4 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha4" + klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" + "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/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 +71,7 @@ func (r *KeptnWorkloadReconciler) Reconcile(ctx context.Context, req ctrl.Reques requestInfo := controllercommon.GetRequestInfo(req) r.Log.Info("Searching for workload", "requestInfo", requestInfo) - workload := &klcv1alpha3.KeptnWorkload{} + workload := &klcv1beta1.KeptnWorkload{} err := r.Get(ctx, req.NamespacedName, workload) if errors.IsNotFound(err) { return reconcile.Result{}, nil @@ -87,7 +85,7 @@ func (r *KeptnWorkloadReconciler) Reconcile(ctx context.Context, req ctrl.Reques r.Log.Info("Reconciling Keptn Workload", "workload", workload.Name, "requestInfo", requestInfo) - workloadVersion := &klcv1alpha4.KeptnWorkloadVersion{} + workloadVersion := &klcv1beta1.KeptnWorkloadVersion{} workloadVersionName := operatorcommon.CreateResourceName(common.MaxK8sObjectLength, common.MinKeptnNameLen, workload.Name, workload.Spec.Version) // Try to find the workload instance @@ -101,7 +99,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") - r.EventSender.Emit(apicommon.PhaseCreateWorkloadVersion, "Warning", workloadVersion, apicommon.PhaseStateFailed, "could not create KeptnWorkloadVersion ", workloadVersion.Spec.Version) + r.EventSender.Emit(common.PhaseCreateWorkloadVersion, "Warning", workloadVersion, common.PhaseStateFailed, "could not create KeptnWorkloadVersion ", workloadVersion.Spec.Version) return ctrl.Result{}, err } workload.Status.CurrentVersion = workload.Spec.Version @@ -121,18 +119,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(), &klcv1alpha3.KeptnWorkload{}, "spec.app", func(rawObj client.Object) []string { - workload := rawObj.(*klcv1alpha3.KeptnWorkload) + if err := mgr.GetFieldIndexer().IndexField(context.Background(), &klcv1beta1.KeptnWorkload{}, "spec.app", func(rawObj client.Object) []string { + workload := rawObj.(*klcv1beta1.KeptnWorkload) return []string{workload.Spec.AppName} }); err != nil { return err } return ctrl.NewControllerManagedBy(mgr). - For(&klcv1alpha3.KeptnWorkload{}, builder.WithPredicates(predicate.GenerationChangedPredicate{})). + For(&klcv1beta1.KeptnWorkload{}, builder.WithPredicates(predicate.GenerationChangedPredicate{})). Complete(r) } -func (r *KeptnWorkloadReconciler) createWorkloadVersion(ctx context.Context, workload *klcv1alpha3.KeptnWorkload) (*klcv1alpha4.KeptnWorkloadVersion, error) { +func (r *KeptnWorkloadReconciler) createWorkloadVersion(ctx context.Context, workload *klcv1beta1.KeptnWorkload) (*klcv1beta1.KeptnWorkloadVersion, error) { // create TraceContext // follow up with a Keptn propagator that JSON-encoded the OTel map into our own key traceContextCarrier := propagation.MapCarrier{} @@ -152,14 +150,14 @@ func (r *KeptnWorkloadReconciler) createWorkloadVersion(ctx context.Context, wor return &workloadVersion, err } -func generateWorkloadVersion(previousVersion string, traceContextCarrier map[string]string, w *klcv1alpha3.KeptnWorkload) klcv1alpha4.KeptnWorkloadVersion { - return klcv1alpha4.KeptnWorkloadVersion{ +func generateWorkloadVersion(previousVersion string, traceContextCarrier map[string]string, w *klcv1beta1.KeptnWorkload) klcv1beta1.KeptnWorkloadVersion { + return klcv1beta1.KeptnWorkloadVersion{ ObjectMeta: metav1.ObjectMeta{ Annotations: traceContextCarrier, Name: operatorcommon.CreateResourceName(common.MaxK8sObjectLength, common.MinKeptnNameLen, w.Name, w.Spec.Version), Namespace: w.Namespace, }, - Spec: klcv1alpha4.KeptnWorkloadVersionSpec{ + Spec: klcv1beta1.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 c37d20058d1..d025517d716 100644 --- a/lifecycle-operator/controllers/lifecycle/keptnworkload/controller_test.go +++ b/lifecycle-operator/controllers/lifecycle/keptnworkload/controller_test.go @@ -3,33 +3,32 @@ package keptnworkload import ( "testing" - klcv1alpha3 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3" - klcv1alpha4 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha4" + klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" "github.com/stretchr/testify/require" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) func TestKeptnWorkload(t *testing.T) { - workload := &klcv1alpha3.KeptnWorkload{ + workload := &klcv1beta1.KeptnWorkload{ ObjectMeta: metav1.ObjectMeta{ Name: "workload", Namespace: "namespace", }, - Spec: klcv1alpha3.KeptnWorkloadSpec{ + Spec: klcv1beta1.KeptnWorkloadSpec{ Version: "version", AppName: "app", }, } workloadVersion := generateWorkloadVersion("prev", map[string]string{}, workload) - require.Equal(t, klcv1alpha4.KeptnWorkloadVersion{ + require.Equal(t, klcv1beta1.KeptnWorkloadVersion{ ObjectMeta: metav1.ObjectMeta{ Annotations: map[string]string{}, Name: "workload-version", Namespace: "namespace", }, - Spec: klcv1alpha4.KeptnWorkloadVersionSpec{ - KeptnWorkloadSpec: klcv1alpha3.KeptnWorkloadSpec{ + Spec: klcv1beta1.KeptnWorkloadVersionSpec{ + KeptnWorkloadSpec: klcv1beta1.KeptnWorkloadSpec{ Version: "version", AppName: "app", }, diff --git a/lifecycle-operator/controllers/lifecycle/keptnworkloadversion/controller.go b/lifecycle-operator/controllers/lifecycle/keptnworkloadversion/controller.go index aa35cb48cdc..af2da2589d6 100644 --- a/lifecycle-operator/controllers/lifecycle/keptnworkloadversion/controller.go +++ b/lifecycle-operator/controllers/lifecycle/keptnworkloadversion/controller.go @@ -22,9 +22,8 @@ import ( "time" "github.com/go-logr/logr" - klcv1alpha3 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3/common" - klcv1alpha4 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha4" + klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" controllercommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/evaluation" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/eventsender" @@ -85,7 +84,7 @@ func (r *KeptnWorkloadVersionReconciler) Reconcile(ctx context.Context, req ctrl r.Log.Info("Searching for KeptnWorkloadVersion", "requestInfo", requestInfo) // retrieve workload version - workloadVersion := &klcv1alpha4.KeptnWorkloadVersion{} + workloadVersion := &klcv1beta1.KeptnWorkloadVersion{} err := r.Get(ctx, req.NamespacedName, workloadVersion) if errors.IsNotFound(err) { return reconcile.Result{}, nil @@ -153,7 +152,7 @@ func (r *KeptnWorkloadVersionReconciler) Reconcile(ctx context.Context, req ctrl return r.finishKeptnWorkloadVersionReconcile(ctx, workloadVersion, spanWorkloadTrace) } -func (r *KeptnWorkloadVersionReconciler) doPreDeploymentTaskPhase(ctx context.Context, workloadVersion *klcv1alpha4.KeptnWorkloadVersion, ctxWorkloadTrace context.Context) (phase.PhaseResult, error) { +func (r *KeptnWorkloadVersionReconciler) doPreDeploymentTaskPhase(ctx context.Context, workloadVersion *klcv1beta1.KeptnWorkloadVersion, ctxWorkloadTrace context.Context) (phase.PhaseResult, error) { if !workloadVersion.IsPreDeploymentSucceeded() { reconcilePre := func(phaseCtx context.Context) (apicommon.KeptnState, error) { return r.reconcilePrePostDeployment(ctx, phaseCtx, workloadVersion, apicommon.PreDeploymentCheckType) @@ -171,7 +170,7 @@ func (r *KeptnWorkloadVersionReconciler) doPreDeploymentTaskPhase(ctx context.Co }, nil } -func (r *KeptnWorkloadVersionReconciler) doPreDeploymentEvaluationPhase(ctx context.Context, workloadVersion *klcv1alpha4.KeptnWorkloadVersion, ctxWorkloadTrace context.Context) (phase.PhaseResult, error) { +func (r *KeptnWorkloadVersionReconciler) doPreDeploymentEvaluationPhase(ctx context.Context, workloadVersion *klcv1beta1.KeptnWorkloadVersion, ctxWorkloadTrace context.Context) (phase.PhaseResult, error) { if !workloadVersion.IsPreDeploymentEvaluationSucceeded() { reconcilePreEval := func(phaseCtx context.Context) (apicommon.KeptnState, error) { return r.reconcilePrePostEvaluation(ctx, phaseCtx, workloadVersion, apicommon.PreDeploymentEvaluationCheckType) @@ -189,7 +188,7 @@ func (r *KeptnWorkloadVersionReconciler) doPreDeploymentEvaluationPhase(ctx cont }, nil } -func (r *KeptnWorkloadVersionReconciler) doDeploymentPhase(ctx context.Context, workloadVersion *klcv1alpha4.KeptnWorkloadVersion, ctxWorkloadTrace context.Context) (phase.PhaseResult, error) { +func (r *KeptnWorkloadVersionReconciler) doDeploymentPhase(ctx context.Context, workloadVersion *klcv1beta1.KeptnWorkloadVersion, ctxWorkloadTrace context.Context) (phase.PhaseResult, error) { if !workloadVersion.IsDeploymentSucceeded() { reconcileWorkloadVersion := func(phaseCtx context.Context) (apicommon.KeptnState, error) { return r.reconcileDeployment(ctx, workloadVersion) @@ -207,7 +206,7 @@ func (r *KeptnWorkloadVersionReconciler) doDeploymentPhase(ctx context.Context, }, nil } -func (r *KeptnWorkloadVersionReconciler) doPostDeploymentTaskPhase(ctx context.Context, workloadVersion *klcv1alpha4.KeptnWorkloadVersion, ctxWorkloadTrace context.Context) (phase.PhaseResult, error) { +func (r *KeptnWorkloadVersionReconciler) doPostDeploymentTaskPhase(ctx context.Context, workloadVersion *klcv1beta1.KeptnWorkloadVersion, ctxWorkloadTrace context.Context) (phase.PhaseResult, error) { if !workloadVersion.IsPostDeploymentCompleted() { reconcilePost := func(phaseCtx context.Context) (apicommon.KeptnState, error) { return r.reconcilePrePostDeployment(ctx, phaseCtx, workloadVersion, apicommon.PostDeploymentCheckType) @@ -225,7 +224,7 @@ func (r *KeptnWorkloadVersionReconciler) doPostDeploymentTaskPhase(ctx context.C }, nil } -func (r *KeptnWorkloadVersionReconciler) doPostDeploymentEvaluationPhase(ctx context.Context, workloadVersion *klcv1alpha4.KeptnWorkloadVersion, ctxWorkloadTrace context.Context) (phase.PhaseResult, error) { +func (r *KeptnWorkloadVersionReconciler) doPostDeploymentEvaluationPhase(ctx context.Context, workloadVersion *klcv1beta1.KeptnWorkloadVersion, ctxWorkloadTrace context.Context) (phase.PhaseResult, error) { if !workloadVersion.IsPostDeploymentEvaluationSucceeded() { reconcilePostEval := func(phaseCtx context.Context) (apicommon.KeptnState, error) { return r.reconcilePrePostEvaluation(ctx, phaseCtx, workloadVersion, apicommon.PostDeploymentEvaluationCheckType) @@ -243,7 +242,7 @@ func (r *KeptnWorkloadVersionReconciler) doPostDeploymentEvaluationPhase(ctx con }, nil } -func (r *KeptnWorkloadVersionReconciler) finishKeptnWorkloadVersionReconcile(ctx context.Context, workloadVersion *klcv1alpha4.KeptnWorkloadVersion, spanWorkloadTrace trace.Span) (ctrl.Result, error) { +func (r *KeptnWorkloadVersionReconciler) finishKeptnWorkloadVersionReconcile(ctx context.Context, workloadVersion *klcv1beta1.KeptnWorkloadVersion, spanWorkloadTrace trace.Span) (ctrl.Result, error) { if !workloadVersion.IsEndTimeSet() { workloadVersion.Status.CurrentPhase = apicommon.PhaseCompleted.ShortName workloadVersion.Status.Status = apicommon.StateSucceeded @@ -275,28 +274,28 @@ 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(), &klcv1alpha4.KeptnWorkloadVersion{}, "spec.app", func(rawObj client.Object) []string { - workloadVersion := rawObj.(*klcv1alpha4.KeptnWorkloadVersion) + if err := mgr.GetFieldIndexer().IndexField(context.Background(), &klcv1beta1.KeptnWorkloadVersion{}, "spec.app", func(rawObj client.Object) []string { + workloadVersion := rawObj.(*klcv1beta1.KeptnWorkloadVersion) return []string{workloadVersion.Spec.AppName} }); err != nil { return err } return ctrl.NewControllerManagedBy(mgr). // predicate disabling the auto reconciliation after updating the object status - For(&klcv1alpha4.KeptnWorkloadVersion{}, builder.WithPredicates(predicate.GenerationChangedPredicate{})). + For(&klcv1beta1.KeptnWorkloadVersion{}, builder.WithPredicates(predicate.GenerationChangedPredicate{})). Complete(r) } -func (r *KeptnWorkloadVersionReconciler) sendUnfinishedPreEvaluationEvents(appPreEvalStatus apicommon.KeptnState, phase apicommon.KeptnPhaseType, workloadVersion *klcv1alpha4.KeptnWorkloadVersion) { +func (r *KeptnWorkloadVersionReconciler) sendUnfinishedPreEvaluationEvents(appPreEvalStatus apicommon.KeptnState, phase apicommon.KeptnPhaseType, workloadVersion *klcv1beta1.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 *klcv1alpha4.KeptnWorkloadVersion) func(workloadVersion *klcv1alpha4.KeptnWorkloadVersion) { +func (r *KeptnWorkloadVersionReconciler) getCompletionFunc(ctx context.Context, workloadVersion *klcv1beta1.KeptnWorkloadVersion) func(workloadVersion *klcv1beta1.KeptnWorkloadVersion) { workloadVersion.SetStartTime() - endFunc := func(workloadVersion *klcv1alpha4.KeptnWorkloadVersion) { + endFunc := func(workloadVersion *klcv1beta1.KeptnWorkloadVersion) { if workloadVersion.IsEndTimeSet() { r.Log.Info("Increasing deployment count") attrs := workloadVersion.GetMetricsAttributes() @@ -307,7 +306,7 @@ func (r *KeptnWorkloadVersionReconciler) getCompletionFunc(ctx context.Context, return endFunc } -func (r *KeptnWorkloadVersionReconciler) checkPreEvaluationStatusOfApp(ctx context.Context, workloadVersion *klcv1alpha4.KeptnWorkloadVersion) (bool, error) { +func (r *KeptnWorkloadVersionReconciler) checkPreEvaluationStatusOfApp(ctx context.Context, workloadVersion *klcv1beta1.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 @@ -345,12 +344,12 @@ func (r *KeptnWorkloadVersionReconciler) checkPreEvaluationStatusOfApp(ctx conte return false, nil } -func (r *KeptnWorkloadVersionReconciler) getAppVersionForWorkloadVersion(ctx context.Context, wli *klcv1alpha4.KeptnWorkloadVersion) (bool, klcv1alpha3.KeptnAppVersion, error) { - apps := &klcv1alpha3.KeptnAppVersionList{} +func (r *KeptnWorkloadVersionReconciler) getAppVersionForWorkloadVersion(ctx context.Context, wli *klcv1beta1.KeptnWorkloadVersion) (bool, klcv1beta1.KeptnAppVersion, error) { + apps := &klcv1beta1.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, klcv1alpha3.KeptnAppVersion{}, err + return false, klcv1beta1.KeptnAppVersion{}, err } // due to effectivity reasons deprecated KeptnAppVersions are removed from the list, as there is @@ -365,7 +364,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, klcv1alpha3.KeptnAppVersion{}, nil + return false, klcv1beta1.KeptnAppVersion{}, nil } return true, latestVersion, nil } @@ -374,8 +373,8 @@ func (r *KeptnWorkloadVersionReconciler) getTracer() telemetry.ITracer { return r.TracerFactory.GetTracer(traceComponentName) } -func getLatestAppVersion(apps *klcv1alpha3.KeptnAppVersionList, wli *klcv1alpha4.KeptnWorkloadVersion) (bool, klcv1alpha3.KeptnAppVersion, error) { - latestVersion := klcv1alpha3.KeptnAppVersion{} +func getLatestAppVersion(apps *klcv1beta1.KeptnAppVersionList, wli *klcv1beta1.KeptnWorkloadVersion) (bool, klcv1beta1.KeptnAppVersion, error) { + latestVersion := klcv1beta1.KeptnAppVersion{} workloadFound := false for _, app := range apps.Items { @@ -394,10 +393,10 @@ func getLatestAppVersion(apps *klcv1alpha3.KeptnAppVersionList, wli *klcv1alpha4 return workloadFound, latestVersion, nil } -func isNewer(app klcv1alpha3.KeptnAppVersion, latestVersion klcv1alpha3.KeptnAppVersion) bool { +func isNewer(app klcv1beta1.KeptnAppVersion, latestVersion klcv1beta1.KeptnAppVersion) bool { return app.ObjectMeta.CreationTimestamp.Time.After(latestVersion.ObjectMeta.CreationTimestamp.Time) || latestVersion.CreationTimestamp.Time.IsZero() } -func workloadMatchesApp(appWorkload klcv1alpha3.KeptnWorkloadRef, wli *klcv1alpha4.KeptnWorkloadVersion, app klcv1alpha3.KeptnAppVersion) bool { +func workloadMatchesApp(appWorkload klcv1beta1.KeptnWorkloadRef, wli *klcv1beta1.KeptnWorkloadVersion, app klcv1beta1.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 e0d07478fab..5709addfe57 100644 --- a/lifecycle-operator/controllers/lifecycle/keptnworkloadversion/controller_test.go +++ b/lifecycle-operator/controllers/lifecycle/keptnworkloadversion/controller_test.go @@ -8,9 +8,8 @@ import ( "testing" "time" - klcv1alpha3 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3/common" - klcv1alpha4 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha4" + klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/evaluation" evaluationfake "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/evaluation/fake" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/eventsender" @@ -211,7 +210,7 @@ func TestKeptnWorkloadVersionReconciler_IsPodRunning(t *testing.T) { r := &KeptnWorkloadVersionReconciler{ Client: k8sfake.NewClientBuilder().WithLists(podList).Build(), } - isPodRunning, err := r.isPodRunning(context.TODO(), klcv1alpha3.ResourceReference{UID: "pod1"}, "node1") + isPodRunning, err := r.isPodRunning(context.TODO(), klcv1beta1.ResourceReference{UID: "pod1"}, "node1") testrequire.Nil(t, err) if !isPodRunning { t.Errorf("Wrong!") @@ -220,7 +219,7 @@ func TestKeptnWorkloadVersionReconciler_IsPodRunning(t *testing.T) { r2 := &KeptnWorkloadVersionReconciler{ Client: k8sfake.NewClientBuilder().WithLists(podList2).Build(), } - isPodRunning, err = r2.isPodRunning(context.TODO(), klcv1alpha3.ResourceReference{UID: "pod1"}, "node1") + isPodRunning, err = r2.isPodRunning(context.TODO(), klcv1beta1.ResourceReference{UID: "pod1"}, "node1") testrequire.Nil(t, err) if isPodRunning { t.Errorf("Wrong!") @@ -308,59 +307,59 @@ func Test_getAppVersionForWorkloadVersion(t *testing.T) { now := time.Now() tests := []struct { name string - wli *klcv1alpha4.KeptnWorkloadVersion - list *klcv1alpha3.KeptnAppVersionList + wli *klcv1beta1.KeptnWorkloadVersion + list *klcv1beta1.KeptnAppVersionList wantFound bool - wantAppVersion klcv1alpha3.KeptnAppVersion + wantAppVersion klcv1beta1.KeptnAppVersion wantErr bool }{ { name: "no appVersions", - wli: &klcv1alpha4.KeptnWorkloadVersion{ + wli: &klcv1beta1.KeptnWorkloadVersion{ ObjectMeta: metav1.ObjectMeta{ Name: "my-workloadVersion", Namespace: "default", }, - Spec: klcv1alpha4.KeptnWorkloadVersionSpec{ - KeptnWorkloadSpec: klcv1alpha3.KeptnWorkloadSpec{ + Spec: klcv1beta1.KeptnWorkloadVersionSpec{ + KeptnWorkloadSpec: klcv1beta1.KeptnWorkloadSpec{ AppName: "my-app", Version: "1.0", }, WorkloadName: "my-app-my-workload", }, }, - list: &klcv1alpha3.KeptnAppVersionList{}, + list: &klcv1beta1.KeptnAppVersionList{}, wantFound: false, - wantAppVersion: klcv1alpha3.KeptnAppVersion{}, + wantAppVersion: klcv1beta1.KeptnAppVersion{}, wantErr: false, }, { name: "appVersion found", - wli: &klcv1alpha4.KeptnWorkloadVersion{ + wli: &klcv1beta1.KeptnWorkloadVersion{ ObjectMeta: metav1.ObjectMeta{ Name: "my-workloadVersion", Namespace: "default", }, - Spec: klcv1alpha4.KeptnWorkloadVersionSpec{ - KeptnWorkloadSpec: klcv1alpha3.KeptnWorkloadSpec{ + Spec: klcv1beta1.KeptnWorkloadVersionSpec{ + KeptnWorkloadSpec: klcv1beta1.KeptnWorkloadSpec{ AppName: "my-app", Version: "1.0", }, WorkloadName: "my-app-my-workload", }, }, - list: &klcv1alpha3.KeptnAppVersionList{ - Items: []klcv1alpha3.KeptnAppVersion{ + list: &klcv1beta1.KeptnAppVersionList{ + Items: []klcv1beta1.KeptnAppVersion{ { ObjectMeta: metav1.ObjectMeta{ Name: "my-app", Namespace: "default", CreationTimestamp: metav1.Time{Time: now}, }, - Spec: klcv1alpha3.KeptnAppVersionSpec{ - KeptnAppSpec: klcv1alpha3.KeptnAppSpec{ + Spec: klcv1beta1.KeptnAppVersionSpec{ + KeptnAppSpec: klcv1beta1.KeptnAppSpec{ Version: "1.0", - Workloads: []klcv1alpha3.KeptnWorkloadRef{ + Workloads: []klcv1beta1.KeptnWorkloadRef{ { Name: "my-workload", Version: "1.0", @@ -376,10 +375,10 @@ func Test_getAppVersionForWorkloadVersion(t *testing.T) { Namespace: "default", CreationTimestamp: metav1.Time{Time: now.Add(5 * time.Second)}, }, - Spec: klcv1alpha3.KeptnAppVersionSpec{ - KeptnAppSpec: klcv1alpha3.KeptnAppSpec{ + Spec: klcv1beta1.KeptnAppVersionSpec{ + KeptnAppSpec: klcv1beta1.KeptnAppSpec{ Version: "2.0", - Workloads: []klcv1alpha3.KeptnWorkloadRef{ + Workloads: []klcv1beta1.KeptnWorkloadRef{ { Name: "my-workload", Version: "1.0", @@ -392,16 +391,16 @@ func Test_getAppVersionForWorkloadVersion(t *testing.T) { }, }, wantFound: true, - wantAppVersion: klcv1alpha3.KeptnAppVersion{ + wantAppVersion: klcv1beta1.KeptnAppVersion{ ObjectMeta: metav1.ObjectMeta{ Name: "my-app2", Namespace: "default", ResourceVersion: "999", }, - Spec: klcv1alpha3.KeptnAppVersionSpec{ - KeptnAppSpec: klcv1alpha3.KeptnAppSpec{ + Spec: klcv1beta1.KeptnAppVersionSpec{ + KeptnAppSpec: klcv1beta1.KeptnAppSpec{ Version: "2.0", - Workloads: []klcv1alpha3.KeptnWorkloadRef{ + Workloads: []klcv1beta1.KeptnWorkloadRef{ { Name: "my-workload", Version: "1.0", @@ -415,30 +414,30 @@ func Test_getAppVersionForWorkloadVersion(t *testing.T) { }, { name: "appVersion deprecated", - wli: &klcv1alpha4.KeptnWorkloadVersion{ + wli: &klcv1beta1.KeptnWorkloadVersion{ ObjectMeta: metav1.ObjectMeta{ Name: "my-workloadVersion", Namespace: "default", }, - Spec: klcv1alpha4.KeptnWorkloadVersionSpec{ - KeptnWorkloadSpec: klcv1alpha3.KeptnWorkloadSpec{ + Spec: klcv1beta1.KeptnWorkloadVersionSpec{ + KeptnWorkloadSpec: klcv1beta1.KeptnWorkloadSpec{ AppName: "my-app", Version: "1.0", }, WorkloadName: "my-app-my-workload", }, }, - list: &klcv1alpha3.KeptnAppVersionList{ - Items: []klcv1alpha3.KeptnAppVersion{ + list: &klcv1beta1.KeptnAppVersionList{ + Items: []klcv1beta1.KeptnAppVersion{ { ObjectMeta: metav1.ObjectMeta{ Name: "my-app", Namespace: "default", }, - Spec: klcv1alpha3.KeptnAppVersionSpec{ - KeptnAppSpec: klcv1alpha3.KeptnAppSpec{ + Spec: klcv1beta1.KeptnAppVersionSpec{ + KeptnAppSpec: klcv1beta1.KeptnAppSpec{ Version: "1.0", - Workloads: []klcv1alpha3.KeptnWorkloadRef{ + Workloads: []klcv1beta1.KeptnWorkloadRef{ { Name: "my-workload", Version: "1.0", @@ -447,7 +446,7 @@ func Test_getAppVersionForWorkloadVersion(t *testing.T) { }, AppName: "my-app", }, - Status: klcv1alpha3.KeptnAppVersionStatus{ + Status: klcv1beta1.KeptnAppVersionStatus{ Status: apicommon.StateDeprecated, }, }, @@ -456,10 +455,10 @@ func Test_getAppVersionForWorkloadVersion(t *testing.T) { Name: "my-app2", Namespace: "default", }, - Spec: klcv1alpha3.KeptnAppVersionSpec{ - KeptnAppSpec: klcv1alpha3.KeptnAppSpec{ + Spec: klcv1beta1.KeptnAppVersionSpec{ + KeptnAppSpec: klcv1beta1.KeptnAppSpec{ Version: "2.0", - Workloads: []klcv1alpha3.KeptnWorkloadRef{ + Workloads: []klcv1beta1.KeptnWorkloadRef{ { Name: "my-workload", Version: "1.0", @@ -468,42 +467,42 @@ func Test_getAppVersionForWorkloadVersion(t *testing.T) { }, AppName: "my-app", }, - Status: klcv1alpha3.KeptnAppVersionStatus{ + Status: klcv1beta1.KeptnAppVersionStatus{ Status: apicommon.StateDeprecated, }, }, }, }, wantFound: false, - wantAppVersion: klcv1alpha3.KeptnAppVersion{}, + wantAppVersion: klcv1beta1.KeptnAppVersion{}, wantErr: false, }, { name: "no workload for appversion", - wli: &klcv1alpha4.KeptnWorkloadVersion{ + wli: &klcv1beta1.KeptnWorkloadVersion{ ObjectMeta: metav1.ObjectMeta{ Name: "my-workloadVersion3", Namespace: "default", }, - Spec: klcv1alpha4.KeptnWorkloadVersionSpec{ - KeptnWorkloadSpec: klcv1alpha3.KeptnWorkloadSpec{ + Spec: klcv1beta1.KeptnWorkloadVersionSpec{ + KeptnWorkloadSpec: klcv1beta1.KeptnWorkloadSpec{ AppName: "my-app333", Version: "1.0.0", }, WorkloadName: "my-app-my-workload", }, }, - list: &klcv1alpha3.KeptnAppVersionList{ - Items: []klcv1alpha3.KeptnAppVersion{ + list: &klcv1beta1.KeptnAppVersionList{ + Items: []klcv1beta1.KeptnAppVersion{ { ObjectMeta: metav1.ObjectMeta{ Name: "my-app", Namespace: "default", }, - Spec: klcv1alpha3.KeptnAppVersionSpec{ - KeptnAppSpec: klcv1alpha3.KeptnAppSpec{ + Spec: klcv1beta1.KeptnAppVersionSpec{ + KeptnAppSpec: klcv1beta1.KeptnAppSpec{ Version: "1.0", - Workloads: []klcv1alpha3.KeptnWorkloadRef{ + Workloads: []klcv1beta1.KeptnWorkloadRef{ { Name: "my-workload", Version: "1.0", @@ -518,10 +517,10 @@ func Test_getAppVersionForWorkloadVersion(t *testing.T) { Name: "my-app2", Namespace: "default", }, - Spec: klcv1alpha3.KeptnAppVersionSpec{ - KeptnAppSpec: klcv1alpha3.KeptnAppSpec{ + Spec: klcv1beta1.KeptnAppVersionSpec{ + KeptnAppSpec: klcv1beta1.KeptnAppSpec{ Version: "2.0", - Workloads: []klcv1alpha3.KeptnWorkloadRef{ + Workloads: []klcv1beta1.KeptnWorkloadRef{ { Name: "my-workload", Version: "1.0", @@ -534,14 +533,14 @@ func Test_getAppVersionForWorkloadVersion(t *testing.T) { }, }, wantFound: false, - wantAppVersion: klcv1alpha3.KeptnAppVersion{}, + wantAppVersion: klcv1beta1.KeptnAppVersion{}, wantErr: false, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - err := klcv1alpha3.AddToScheme(scheme.Scheme) + err := klcv1beta1.AddToScheme(scheme.Scheme) require.Nil(t, err) r := &KeptnWorkloadVersionReconciler{ Client: k8sfake.NewClientBuilder().WithLists(tt.list).Build(), @@ -563,31 +562,31 @@ func Test_getLatestAppVersion(t *testing.T) { now := time.Now() type args struct { - apps *klcv1alpha3.KeptnAppVersionList - wli *klcv1alpha4.KeptnWorkloadVersion + apps *klcv1beta1.KeptnAppVersionList + wli *klcv1beta1.KeptnWorkloadVersion } tests := []struct { name string args args wantFound bool - wantAppVersion klcv1alpha3.KeptnAppVersion + wantAppVersion klcv1beta1.KeptnAppVersion wantErr bool }{ { name: "app version found", args: args{ - apps: &klcv1alpha3.KeptnAppVersionList{ - Items: []klcv1alpha3.KeptnAppVersion{ + apps: &klcv1beta1.KeptnAppVersionList{ + Items: []klcv1beta1.KeptnAppVersion{ { ObjectMeta: metav1.ObjectMeta{ Name: "my-app", Namespace: "default", CreationTimestamp: metav1.Time{Time: now}, }, - Spec: klcv1alpha3.KeptnAppVersionSpec{ - KeptnAppSpec: klcv1alpha3.KeptnAppSpec{ + Spec: klcv1beta1.KeptnAppVersionSpec{ + KeptnAppSpec: klcv1beta1.KeptnAppSpec{ Version: "1.0", - Workloads: []klcv1alpha3.KeptnWorkloadRef{ + Workloads: []klcv1beta1.KeptnWorkloadRef{ { Name: "my-workload", Version: "1.0", @@ -603,10 +602,10 @@ func Test_getLatestAppVersion(t *testing.T) { Namespace: "default", CreationTimestamp: metav1.Time{Time: now.Add(5 * time.Second)}, }, - Spec: klcv1alpha3.KeptnAppVersionSpec{ - KeptnAppSpec: klcv1alpha3.KeptnAppSpec{ + Spec: klcv1beta1.KeptnAppVersionSpec{ + KeptnAppSpec: klcv1beta1.KeptnAppSpec{ Version: "2.0", - Workloads: []klcv1alpha3.KeptnWorkloadRef{ + Workloads: []klcv1beta1.KeptnWorkloadRef{ { Name: "my-workload", Version: "1.0", @@ -618,13 +617,13 @@ func Test_getLatestAppVersion(t *testing.T) { }, }, }, - wli: &klcv1alpha4.KeptnWorkloadVersion{ + wli: &klcv1beta1.KeptnWorkloadVersion{ ObjectMeta: metav1.ObjectMeta{ Name: "my-workloadVersion", Namespace: "default", }, - Spec: klcv1alpha4.KeptnWorkloadVersionSpec{ - KeptnWorkloadSpec: klcv1alpha3.KeptnWorkloadSpec{ + Spec: klcv1beta1.KeptnWorkloadVersionSpec{ + KeptnWorkloadSpec: klcv1beta1.KeptnWorkloadSpec{ AppName: "my-app", Version: "1.0", }, @@ -633,16 +632,16 @@ func Test_getLatestAppVersion(t *testing.T) { }, }, wantFound: true, - wantAppVersion: klcv1alpha3.KeptnAppVersion{ + wantAppVersion: klcv1beta1.KeptnAppVersion{ ObjectMeta: metav1.ObjectMeta{ Name: "my-app", Namespace: "default", CreationTimestamp: metav1.Time{Time: now.Add(5 * time.Second)}, }, - Spec: klcv1alpha3.KeptnAppVersionSpec{ - KeptnAppSpec: klcv1alpha3.KeptnAppSpec{ + Spec: klcv1beta1.KeptnAppVersionSpec{ + KeptnAppSpec: klcv1beta1.KeptnAppSpec{ Version: "2.0", - Workloads: []klcv1alpha3.KeptnWorkloadRef{ + Workloads: []klcv1beta1.KeptnWorkloadRef{ { Name: "my-workload", Version: "1.0", @@ -657,17 +656,17 @@ func Test_getLatestAppVersion(t *testing.T) { { name: "app version not found", args: args{ - apps: &klcv1alpha3.KeptnAppVersionList{ - Items: []klcv1alpha3.KeptnAppVersion{ + apps: &klcv1beta1.KeptnAppVersionList{ + Items: []klcv1beta1.KeptnAppVersion{ { ObjectMeta: metav1.ObjectMeta{ Name: "my-app", Namespace: "default", }, - Spec: klcv1alpha3.KeptnAppVersionSpec{ - KeptnAppSpec: klcv1alpha3.KeptnAppSpec{ + Spec: klcv1beta1.KeptnAppVersionSpec{ + KeptnAppSpec: klcv1beta1.KeptnAppSpec{ Version: "1.0", - Workloads: []klcv1alpha3.KeptnWorkloadRef{ + Workloads: []klcv1beta1.KeptnWorkloadRef{ { Name: "my-other-workload", Version: "1.0", @@ -679,13 +678,13 @@ func Test_getLatestAppVersion(t *testing.T) { }, }, }, - wli: &klcv1alpha4.KeptnWorkloadVersion{ + wli: &klcv1beta1.KeptnWorkloadVersion{ ObjectMeta: metav1.ObjectMeta{ Name: "my-workloadVersion", Namespace: "default", }, - Spec: klcv1alpha4.KeptnWorkloadVersionSpec{ - KeptnWorkloadSpec: klcv1alpha3.KeptnWorkloadSpec{ + Spec: klcv1beta1.KeptnWorkloadVersionSpec{ + KeptnWorkloadSpec: klcv1beta1.KeptnWorkloadSpec{ AppName: "my-app", Version: "1.0", }, @@ -694,22 +693,22 @@ func Test_getLatestAppVersion(t *testing.T) { }, }, wantFound: false, - wantAppVersion: klcv1alpha3.KeptnAppVersion{}, + wantAppVersion: klcv1beta1.KeptnAppVersion{}, wantErr: false, }, { name: "app version list empty", args: args{ - apps: &klcv1alpha3.KeptnAppVersionList{ - Items: []klcv1alpha3.KeptnAppVersion{}, + apps: &klcv1beta1.KeptnAppVersionList{ + Items: []klcv1beta1.KeptnAppVersion{}, }, - wli: &klcv1alpha4.KeptnWorkloadVersion{ + wli: &klcv1beta1.KeptnWorkloadVersion{ ObjectMeta: metav1.ObjectMeta{ Name: "my-workloadVersion", Namespace: "default", }, - Spec: klcv1alpha4.KeptnWorkloadVersionSpec{ - KeptnWorkloadSpec: klcv1alpha3.KeptnWorkloadSpec{ + Spec: klcv1beta1.KeptnWorkloadVersionSpec{ + KeptnWorkloadSpec: klcv1beta1.KeptnWorkloadSpec{ AppName: "my-app", Version: "1.0", }, @@ -718,7 +717,7 @@ func Test_getLatestAppVersion(t *testing.T) { }, }, wantFound: false, - wantAppVersion: klcv1alpha3.KeptnAppVersion{}, + wantAppVersion: klcv1beta1.KeptnAppVersion{}, wantErr: false, }, } @@ -745,14 +744,14 @@ func TestKeptnWorkloadVersionReconciler_ReconcileReachCompletion(t *testing.T) { testNamespace := "some-ns" - wi := &klcv1alpha4.KeptnWorkloadVersion{ + wi := &klcv1beta1.KeptnWorkloadVersion{ TypeMeta: metav1.TypeMeta{}, ObjectMeta: metav1.ObjectMeta{ Name: "some-wi", Namespace: testNamespace, }, - Spec: klcv1alpha4.KeptnWorkloadVersionSpec{ - KeptnWorkloadSpec: klcv1alpha3.KeptnWorkloadSpec{ + Spec: klcv1beta1.KeptnWorkloadVersionSpec{ + KeptnWorkloadSpec: klcv1beta1.KeptnWorkloadSpec{ AppName: "some-app", Version: "1.0.0", }, @@ -760,7 +759,7 @@ func TestKeptnWorkloadVersionReconciler_ReconcileReachCompletion(t *testing.T) { PreviousVersion: "", TraceId: nil, }, - Status: klcv1alpha4.KeptnWorkloadVersionStatus{ + Status: klcv1beta1.KeptnWorkloadVersionStatus{ DeploymentStatus: apicommon.StateSucceeded, PreDeploymentStatus: apicommon.StateSucceeded, PostDeploymentStatus: apicommon.StateSucceeded, @@ -777,13 +776,13 @@ func TestKeptnWorkloadVersionReconciler_ReconcileReachCompletion(t *testing.T) { testNamespace, "some-app", "1.0.0", - []klcv1alpha3.KeptnWorkloadRef{ + []klcv1beta1.KeptnWorkloadRef{ { Name: "some-workload", Version: "1.0.0", }, }, - klcv1alpha3.KeptnAppVersionStatus{ + klcv1beta1.KeptnAppVersionStatus{ PreDeploymentEvaluationStatus: apicommon.StateSucceeded, }, ) @@ -826,14 +825,14 @@ func TestKeptnWorkloadVersionReconciler_ReconcileReachCompletion_SchedulingGates testNamespace := "some-ns" - wi := &klcv1alpha4.KeptnWorkloadVersion{ + wi := &klcv1beta1.KeptnWorkloadVersion{ TypeMeta: metav1.TypeMeta{}, ObjectMeta: metav1.ObjectMeta{ Name: "some-wi", Namespace: testNamespace, }, - Spec: klcv1alpha4.KeptnWorkloadVersionSpec{ - KeptnWorkloadSpec: klcv1alpha3.KeptnWorkloadSpec{ + Spec: klcv1beta1.KeptnWorkloadVersionSpec{ + KeptnWorkloadSpec: klcv1beta1.KeptnWorkloadSpec{ AppName: "some-app", Version: "1.0.0", }, @@ -841,7 +840,7 @@ func TestKeptnWorkloadVersionReconciler_ReconcileReachCompletion_SchedulingGates PreviousVersion: "", TraceId: nil, }, - Status: klcv1alpha4.KeptnWorkloadVersionStatus{ + Status: klcv1beta1.KeptnWorkloadVersionStatus{ DeploymentStatus: apicommon.StateSucceeded, PreDeploymentStatus: apicommon.StateSucceeded, PostDeploymentStatus: apicommon.StateSucceeded, @@ -858,19 +857,19 @@ func TestKeptnWorkloadVersionReconciler_ReconcileReachCompletion_SchedulingGates testNamespace, "some-app", "1.0.0", - []klcv1alpha3.KeptnWorkloadRef{ + []klcv1beta1.KeptnWorkloadRef{ { Name: "some-workload", Version: "1.0.0", }, }, - klcv1alpha3.KeptnAppVersionStatus{ + klcv1beta1.KeptnAppVersionStatus{ PreDeploymentEvaluationStatus: apicommon.StateSucceeded, }, ) schedulingGatesMock := &schedulinggatesfake.ISchedulingGatesHandlerMock{ - RemoveGatesFunc: func(ctx context.Context, workloadVersion *klcv1alpha4.KeptnWorkloadVersion) error { + RemoveGatesFunc: func(ctx context.Context, workloadVersion *klcv1beta1.KeptnWorkloadVersion) error { return nil }, EnabledFunc: func() bool { @@ -917,14 +916,14 @@ func TestKeptnWorkloadVersionReconciler_RemoveGates_fail(t *testing.T) { testNamespace := "some-ns" - wi := &klcv1alpha4.KeptnWorkloadVersion{ + wi := &klcv1beta1.KeptnWorkloadVersion{ TypeMeta: metav1.TypeMeta{}, ObjectMeta: metav1.ObjectMeta{ Name: "some-wi", Namespace: testNamespace, }, - Spec: klcv1alpha4.KeptnWorkloadVersionSpec{ - KeptnWorkloadSpec: klcv1alpha3.KeptnWorkloadSpec{ + Spec: klcv1beta1.KeptnWorkloadVersionSpec{ + KeptnWorkloadSpec: klcv1beta1.KeptnWorkloadSpec{ AppName: "some-app", Version: "1.0.0", }, @@ -932,7 +931,7 @@ func TestKeptnWorkloadVersionReconciler_RemoveGates_fail(t *testing.T) { PreviousVersion: "", TraceId: nil, }, - Status: klcv1alpha4.KeptnWorkloadVersionStatus{ + Status: klcv1beta1.KeptnWorkloadVersionStatus{ DeploymentStatus: apicommon.StateSucceeded, PreDeploymentStatus: apicommon.StateSucceeded, PostDeploymentStatus: apicommon.StateSucceeded, @@ -949,19 +948,19 @@ func TestKeptnWorkloadVersionReconciler_RemoveGates_fail(t *testing.T) { testNamespace, "some-app", "1.0.0", - []klcv1alpha3.KeptnWorkloadRef{ + []klcv1beta1.KeptnWorkloadRef{ { Name: "some-workload", Version: "1.0.0", }, }, - klcv1alpha3.KeptnAppVersionStatus{ + klcv1beta1.KeptnAppVersionStatus{ PreDeploymentEvaluationStatus: apicommon.StateSucceeded, }, ) r, _, _ := setupReconciler(wi, app) r.SchedulingGatesHandler = &schedulinggatesfake.ISchedulingGatesHandlerMock{ - RemoveGatesFunc: func(ctx context.Context, workloadVersion *klcv1alpha4.KeptnWorkloadVersion) error { + RemoveGatesFunc: func(ctx context.Context, workloadVersion *klcv1beta1.KeptnWorkloadVersion) error { return fmt.Errorf("err") }, EnabledFunc: func() bool { @@ -988,14 +987,14 @@ func TestKeptnWorkloadVersionReconciler_ReconcileFailed(t *testing.T) { testNamespace := "some-ns" - wi := &klcv1alpha4.KeptnWorkloadVersion{ + wi := &klcv1beta1.KeptnWorkloadVersion{ TypeMeta: metav1.TypeMeta{}, ObjectMeta: metav1.ObjectMeta{ Name: "some-wi", Namespace: testNamespace, }, - Spec: klcv1alpha4.KeptnWorkloadVersionSpec{ - KeptnWorkloadSpec: klcv1alpha3.KeptnWorkloadSpec{ + Spec: klcv1beta1.KeptnWorkloadVersionSpec{ + KeptnWorkloadSpec: klcv1beta1.KeptnWorkloadSpec{ AppName: "some-app", Version: "1.0.0", PreDeploymentTasks: []string{ @@ -1006,7 +1005,7 @@ func TestKeptnWorkloadVersionReconciler_ReconcileFailed(t *testing.T) { PreviousVersion: "", TraceId: nil, }, - Status: klcv1alpha4.KeptnWorkloadVersionStatus{ + Status: klcv1beta1.KeptnWorkloadVersionStatus{ DeploymentStatus: apicommon.StatePending, PreDeploymentStatus: apicommon.StateProgressing, PostDeploymentStatus: apicommon.StatePending, @@ -1014,7 +1013,7 @@ func TestKeptnWorkloadVersionReconciler_ReconcileFailed(t *testing.T) { PostDeploymentEvaluationStatus: apicommon.StatePending, CurrentPhase: apicommon.PhaseWorkloadPreDeployment.ShortName, Status: apicommon.StateProgressing, - PreDeploymentTaskStatus: []klcv1alpha3.ItemStatus{ + PreDeploymentTaskStatus: []klcv1beta1.ItemStatus{ { Name: "pre-task", DefinitionName: "task", @@ -1029,13 +1028,13 @@ func TestKeptnWorkloadVersionReconciler_ReconcileFailed(t *testing.T) { testNamespace, "some-app", "1.0.0", - []klcv1alpha3.KeptnWorkloadRef{ + []klcv1beta1.KeptnWorkloadRef{ { Name: "some-workload", Version: "1.0.0", }, }, - klcv1alpha3.KeptnAppVersionStatus{ + klcv1beta1.KeptnAppVersionStatus{ PreDeploymentEvaluationStatus: apicommon.StateSucceeded, }, ) @@ -1092,14 +1091,14 @@ func TestKeptnWorkloadVersionReconciler_ReconcilePreDeploymentEvaluationUnexpect testNamespace := "some-ns" - wi := &klcv1alpha4.KeptnWorkloadVersion{ + wi := &klcv1beta1.KeptnWorkloadVersion{ TypeMeta: metav1.TypeMeta{}, ObjectMeta: metav1.ObjectMeta{ Name: "some-wi", Namespace: testNamespace, }, - Spec: klcv1alpha4.KeptnWorkloadVersionSpec{ - KeptnWorkloadSpec: klcv1alpha3.KeptnWorkloadSpec{ + Spec: klcv1beta1.KeptnWorkloadVersionSpec{ + KeptnWorkloadSpec: klcv1beta1.KeptnWorkloadSpec{ AppName: "some-app", Version: "1.0.0", PreDeploymentEvaluations: []string{"my-pre-evaluation"}, @@ -1108,7 +1107,7 @@ func TestKeptnWorkloadVersionReconciler_ReconcilePreDeploymentEvaluationUnexpect PreviousVersion: "", TraceId: nil, }, - Status: klcv1alpha4.KeptnWorkloadVersionStatus{ + Status: klcv1beta1.KeptnWorkloadVersionStatus{ CurrentPhase: apicommon.PhaseWorkloadPreDeployment.ShortName, StartTime: metav1.Time{}, EndTime: metav1.Time{}, @@ -1119,13 +1118,13 @@ func TestKeptnWorkloadVersionReconciler_ReconcilePreDeploymentEvaluationUnexpect testNamespace, "some-app", "1.0.0", - []klcv1alpha3.KeptnWorkloadRef{ + []klcv1beta1.KeptnWorkloadRef{ { Name: "some-workload", Version: "1.0.0", }, }, - klcv1alpha3.KeptnAppVersionStatus{ + klcv1beta1.KeptnAppVersionStatus{ PreDeploymentEvaluationStatus: apicommon.StateSucceeded, }, ) @@ -1134,7 +1133,7 @@ func TestKeptnWorkloadVersionReconciler_ReconcilePreDeploymentEvaluationUnexpect mockEvaluationHandler := r.EvaluationHandler.(*evaluationfake.MockEvaluationHandler) - mockEvaluationHandler.ReconcileEvaluationsFunc = func(ctx context.Context, phaseCtx context.Context, reconcileObject client.Object, evaluationCreateAttributes evaluation.CreateEvaluationAttributes) ([]klcv1alpha3.ItemStatus, apicommon.StatusSummary, error) { + mockEvaluationHandler.ReconcileEvaluationsFunc = func(ctx context.Context, phaseCtx context.Context, reconcileObject client.Object, evaluationCreateAttributes evaluation.CreateEvaluationAttributes) ([]klcv1beta1.ItemStatus, apicommon.StatusSummary, error) { return nil, apicommon.StatusSummary{}, errors.New("unexpected error") } @@ -1188,23 +1187,23 @@ func setupReconciler(objs ...client.Object) (*KeptnWorkloadVersionReconciler, ch SpanHandler: &telemetry.Handler{}, TracerFactory: tf, EvaluationHandler: &evaluationfake.MockEvaluationHandler{ - ReconcileEvaluationsFunc: func(ctx context.Context, phaseCtx context.Context, reconcileObject client.Object, evaluationCreateAttributes evaluation.CreateEvaluationAttributes) ([]klcv1alpha3.ItemStatus, apicommon.StatusSummary, error) { - return []klcv1alpha3.ItemStatus{}, apicommon.StatusSummary{}, nil + 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 }, }, } return r, recorder.Events, tr } -func makeWorkloadVersionWithRef(objectMeta metav1.ObjectMeta, refKind string) *klcv1alpha4.KeptnWorkloadVersion { - workloadVersion := &klcv1alpha4.KeptnWorkloadVersion{ +func makeWorkloadVersionWithRef(objectMeta metav1.ObjectMeta, refKind string) *klcv1beta1.KeptnWorkloadVersion { + workloadVersion := &klcv1beta1.KeptnWorkloadVersion{ ObjectMeta: metav1.ObjectMeta{ Name: "my-wli", Namespace: "default", }, - Spec: klcv1alpha4.KeptnWorkloadVersionSpec{ - KeptnWorkloadSpec: klcv1alpha3.KeptnWorkloadSpec{ - ResourceReference: klcv1alpha3.ResourceReference{ + Spec: klcv1beta1.KeptnWorkloadVersionSpec{ + KeptnWorkloadSpec: klcv1beta1.KeptnWorkloadSpec{ + ResourceReference: klcv1beta1.ResourceReference{ UID: objectMeta.UID, Name: objectMeta.Name, Kind: refKind, @@ -1218,9 +1217,9 @@ func makeWorkloadVersionWithRef(objectMeta metav1.ObjectMeta, refKind string) *k func TestKeptnWorkloadVersionReconciler_checkPreEvaluationStatusOfAppCannotRetrieveApp(t *testing.T) { r, _, _ := setupReconciler() - wv := &klcv1alpha4.KeptnWorkloadVersion{ - Spec: klcv1alpha4.KeptnWorkloadVersionSpec{ - KeptnWorkloadSpec: klcv1alpha3.KeptnWorkloadSpec{}, + wv := &klcv1beta1.KeptnWorkloadVersion{ + Spec: klcv1beta1.KeptnWorkloadVersionSpec{ + KeptnWorkloadSpec: klcv1beta1.KeptnWorkloadSpec{}, }, } @@ -1241,9 +1240,9 @@ func TestKeptnWorkloadVersionReconciler_checkPreEvaluationStatusOfAppCannotRetri func TestKeptnWorkloadVersionReconciler_checkPreEvaluationStatusOfAppAppNotFound(t *testing.T) { r, _, _ := setupReconciler() - wv := &klcv1alpha4.KeptnWorkloadVersion{ - Spec: klcv1alpha4.KeptnWorkloadVersionSpec{ - KeptnWorkloadSpec: klcv1alpha3.KeptnWorkloadSpec{ + wv := &klcv1beta1.KeptnWorkloadVersion{ + Spec: klcv1beta1.KeptnWorkloadVersionSpec{ + KeptnWorkloadSpec: klcv1beta1.KeptnWorkloadSpec{ AppName: "my-unknown-app", }, }, @@ -1256,13 +1255,13 @@ func TestKeptnWorkloadVersionReconciler_checkPreEvaluationStatusOfAppAppNotFound } func TestKeptnWorkloadVersionReconciler_checkPreEvaluationStatusOfAppAppPreTasksNotFinished(t *testing.T) { - appVersion := &klcv1alpha3.KeptnAppVersion{ + appVersion := &klcv1beta1.KeptnAppVersion{ ObjectMeta: metav1.ObjectMeta{}, - Spec: klcv1alpha3.KeptnAppVersionSpec{ + Spec: klcv1beta1.KeptnAppVersionSpec{ AppName: "my-app", - KeptnAppSpec: klcv1alpha3.KeptnAppSpec{ + KeptnAppSpec: klcv1beta1.KeptnAppSpec{ Version: "1.0", - Workloads: []klcv1alpha3.KeptnWorkloadRef{ + Workloads: []klcv1beta1.KeptnWorkloadRef{ { Name: "my-workload", Version: "1.0", @@ -1274,12 +1273,12 @@ func TestKeptnWorkloadVersionReconciler_checkPreEvaluationStatusOfAppAppPreTasks r, _, _ := setupReconciler(appVersion) - wv := &klcv1alpha4.KeptnWorkloadVersion{ + wv := &klcv1beta1.KeptnWorkloadVersion{ ObjectMeta: metav1.ObjectMeta{ Name: "my-app-my-workload-1.0", }, - Spec: klcv1alpha4.KeptnWorkloadVersionSpec{ - KeptnWorkloadSpec: klcv1alpha3.KeptnWorkloadSpec{ + Spec: klcv1beta1.KeptnWorkloadVersionSpec{ + KeptnWorkloadSpec: klcv1beta1.KeptnWorkloadSpec{ AppName: "my-app", Version: "1.0", }, @@ -1294,15 +1293,15 @@ func TestKeptnWorkloadVersionReconciler_checkPreEvaluationStatusOfAppAppPreTasks } func TestKeptnWorkloadVersionReconciler_checkPreEvaluationStatusOfAppUpdateTraceID(t *testing.T) { - appVersion := &klcv1alpha3.KeptnAppVersion{ + appVersion := &klcv1beta1.KeptnAppVersion{ ObjectMeta: metav1.ObjectMeta{ Name: "my-app-version", }, - Spec: klcv1alpha3.KeptnAppVersionSpec{ + Spec: klcv1beta1.KeptnAppVersionSpec{ AppName: "my-app", - KeptnAppSpec: klcv1alpha3.KeptnAppSpec{ + KeptnAppSpec: klcv1beta1.KeptnAppSpec{ Version: "1.0", - Workloads: []klcv1alpha3.KeptnWorkloadRef{ + Workloads: []klcv1beta1.KeptnWorkloadRef{ { Name: "my-workload", Version: "1.0", @@ -1310,7 +1309,7 @@ func TestKeptnWorkloadVersionReconciler_checkPreEvaluationStatusOfAppUpdateTrace }, }, }, - Status: klcv1alpha3.KeptnAppVersionStatus{ + Status: klcv1beta1.KeptnAppVersionStatus{ PreDeploymentEvaluationStatus: apicommon.StateSucceeded, PhaseTraceIDs: map[string]propagation.MapCarrier{ apicommon.PhaseAppDeployment.ShortName: map[string]string{"traceparent": "parent-id"}, @@ -1318,12 +1317,12 @@ func TestKeptnWorkloadVersionReconciler_checkPreEvaluationStatusOfAppUpdateTrace }, } - wv := &klcv1alpha4.KeptnWorkloadVersion{ + wv := &klcv1beta1.KeptnWorkloadVersion{ ObjectMeta: metav1.ObjectMeta{ Name: "my-app-my-workload-1.0", }, - Spec: klcv1alpha4.KeptnWorkloadVersionSpec{ - KeptnWorkloadSpec: klcv1alpha3.KeptnWorkloadSpec{ + Spec: klcv1beta1.KeptnWorkloadVersionSpec{ + KeptnWorkloadSpec: klcv1beta1.KeptnWorkloadSpec{ AppName: "my-app", Version: "1.0", }, @@ -1333,7 +1332,7 @@ func TestKeptnWorkloadVersionReconciler_checkPreEvaluationStatusOfAppUpdateTrace r, _, _ := setupReconciler(appVersion, wv) - appVersion.Status = klcv1alpha3.KeptnAppVersionStatus{ + appVersion.Status = klcv1beta1.KeptnAppVersionStatus{ PreDeploymentEvaluationStatus: apicommon.StateSucceeded, PhaseTraceIDs: map[string]propagation.MapCarrier{ apicommon.PhaseAppDeployment.ShortName: map[string]string{"traceparent": "parent-id"}, @@ -1357,16 +1356,16 @@ func TestKeptnWorkloadVersionReconciler_checkPreEvaluationStatusOfAppUpdateTrace } func TestKeptnWorkloadVersionReconciler_checkPreEvaluationStatusOfAppUpdateTraceIDWithAppVersionSpecTraceID(t *testing.T) { - appVersion := &klcv1alpha3.KeptnAppVersion{ + appVersion := &klcv1beta1.KeptnAppVersion{ ObjectMeta: metav1.ObjectMeta{ Name: "my-app-version", }, - Spec: klcv1alpha3.KeptnAppVersionSpec{ + Spec: klcv1beta1.KeptnAppVersionSpec{ AppName: "my-app", TraceId: map[string]string{"traceparent": "parent-id"}, - KeptnAppSpec: klcv1alpha3.KeptnAppSpec{ + KeptnAppSpec: klcv1beta1.KeptnAppSpec{ Version: "1.0", - Workloads: []klcv1alpha3.KeptnWorkloadRef{ + Workloads: []klcv1beta1.KeptnWorkloadRef{ { Name: "my-workload", Version: "1.0", @@ -1376,12 +1375,12 @@ func TestKeptnWorkloadVersionReconciler_checkPreEvaluationStatusOfAppUpdateTrace }, } - wv := &klcv1alpha4.KeptnWorkloadVersion{ + wv := &klcv1beta1.KeptnWorkloadVersion{ ObjectMeta: metav1.ObjectMeta{ Name: "my-app-my-workload-1.0", }, - Spec: klcv1alpha4.KeptnWorkloadVersionSpec{ - KeptnWorkloadSpec: klcv1alpha3.KeptnWorkloadSpec{ + Spec: klcv1beta1.KeptnWorkloadVersionSpec{ + KeptnWorkloadSpec: klcv1beta1.KeptnWorkloadSpec{ AppName: "my-app", Version: "1.0", }, @@ -1391,7 +1390,7 @@ func TestKeptnWorkloadVersionReconciler_checkPreEvaluationStatusOfAppUpdateTrace r, _, _ := setupReconciler(appVersion, wv) - appVersion.Status = klcv1alpha3.KeptnAppVersionStatus{ + appVersion.Status = klcv1beta1.KeptnAppVersionStatus{ PreDeploymentEvaluationStatus: apicommon.StateSucceeded, } @@ -1412,16 +1411,16 @@ func TestKeptnWorkloadVersionReconciler_checkPreEvaluationStatusOfAppUpdateTrace } func TestKeptnWorkloadVersionReconciler_checkPreEvaluationStatusOfAppErrorWhenUpdatingWorkloadVersion(t *testing.T) { - appVersion := &klcv1alpha3.KeptnAppVersion{ + appVersion := &klcv1beta1.KeptnAppVersion{ ObjectMeta: metav1.ObjectMeta{ Name: "my-app-version", }, - Spec: klcv1alpha3.KeptnAppVersionSpec{ + Spec: klcv1beta1.KeptnAppVersionSpec{ AppName: "my-app", TraceId: map[string]string{"traceparent": "parent-id"}, - KeptnAppSpec: klcv1alpha3.KeptnAppSpec{ + KeptnAppSpec: klcv1beta1.KeptnAppSpec{ Version: "1.0", - Workloads: []klcv1alpha3.KeptnWorkloadRef{ + Workloads: []klcv1beta1.KeptnWorkloadRef{ { Name: "my-workload", Version: "1.0", @@ -1431,12 +1430,12 @@ func TestKeptnWorkloadVersionReconciler_checkPreEvaluationStatusOfAppErrorWhenUp }, } - wv := &klcv1alpha4.KeptnWorkloadVersion{ + wv := &klcv1beta1.KeptnWorkloadVersion{ ObjectMeta: metav1.ObjectMeta{ Name: "my-app-my-workload-1.0", }, - Spec: klcv1alpha4.KeptnWorkloadVersionSpec{ - KeptnWorkloadSpec: klcv1alpha3.KeptnWorkloadSpec{ + Spec: klcv1beta1.KeptnWorkloadVersionSpec{ + KeptnWorkloadSpec: klcv1beta1.KeptnWorkloadSpec{ AppName: "my-app", Version: "1.0", }, @@ -1455,7 +1454,7 @@ func TestKeptnWorkloadVersionReconciler_checkPreEvaluationStatusOfAppErrorWhenUp r.Client = fakeClient - appVersion.Status = klcv1alpha3.KeptnAppVersionStatus{ + appVersion.Status = klcv1beta1.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 97adba5a510..027d8ef7059 100644 --- a/lifecycle-operator/controllers/lifecycle/keptnworkloadversion/reconcile_deploymentstate.go +++ b/lifecycle-operator/controllers/lifecycle/keptnworkloadversion/reconcile_deploymentstate.go @@ -4,9 +4,8 @@ import ( "context" argov1alpha1 "github.com/argoproj/argo-rollouts/pkg/apis/rollouts/v1alpha1" - klcv1alpha3 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3/common" - klcv1alpha4 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha4" + klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" controllererrors "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/errors" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" @@ -14,7 +13,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" ) -func (r *KeptnWorkloadVersionReconciler) reconcileDeployment(ctx context.Context, workloadVersion *klcv1alpha4.KeptnWorkloadVersion) (apicommon.KeptnState, error) { +func (r *KeptnWorkloadVersionReconciler) reconcileDeployment(ctx context.Context, workloadVersion *klcv1beta1.KeptnWorkloadVersion) (apicommon.KeptnState, error) { var isRunning bool var err error @@ -47,7 +46,7 @@ func (r *KeptnWorkloadVersionReconciler) reconcileDeployment(ctx context.Context return workloadVersion.Status.DeploymentStatus, nil } -func (r *KeptnWorkloadVersionReconciler) isReplicaSetRunning(ctx context.Context, resource klcv1alpha3.ResourceReference, namespace string) (bool, error) { +func (r *KeptnWorkloadVersionReconciler) isReplicaSetRunning(ctx context.Context, resource klcv1beta1.ResourceReference, namespace string) (bool, error) { rep := appsv1.ReplicaSet{} err := r.Client.Get(ctx, types.NamespacedName{Name: resource.Name, Namespace: namespace}, &rep) if err != nil { @@ -56,14 +55,14 @@ func (r *KeptnWorkloadVersionReconciler) isReplicaSetRunning(ctx context.Context for _, ownerRef := range rep.OwnerReferences { if ownerRef.Kind == "Rollout" { - return r.isRolloutRunning(ctx, klcv1alpha3.ResourceReference{Name: ownerRef.Name, UID: ownerRef.UID}, namespace) + return r.isRolloutRunning(ctx, klcv1beta1.ResourceReference{Name: ownerRef.Name, UID: ownerRef.UID}, namespace) } } return *rep.Spec.Replicas == rep.Status.AvailableReplicas, nil } -func (r *KeptnWorkloadVersionReconciler) isDaemonSetRunning(ctx context.Context, resource klcv1alpha3.ResourceReference, namespace string) (bool, error) { +func (r *KeptnWorkloadVersionReconciler) isDaemonSetRunning(ctx context.Context, resource klcv1beta1.ResourceReference, namespace string) (bool, error) { daemonSet := &appsv1.DaemonSet{} err := r.Client.Get(ctx, types.NamespacedName{Name: resource.Name, Namespace: namespace}, daemonSet) if err != nil { @@ -72,7 +71,7 @@ func (r *KeptnWorkloadVersionReconciler) isDaemonSetRunning(ctx context.Context, return daemonSet.Status.DesiredNumberScheduled == daemonSet.Status.NumberReady, nil } -func (r *KeptnWorkloadVersionReconciler) isPodRunning(ctx context.Context, resource klcv1alpha3.ResourceReference, namespace string) (bool, error) { +func (r *KeptnWorkloadVersionReconciler) isPodRunning(ctx context.Context, resource klcv1beta1.ResourceReference, namespace string) (bool, error) { podList := &corev1.PodList{} if err := r.Client.List(ctx, podList, client.InNamespace(namespace)); err != nil { return false, err @@ -88,7 +87,7 @@ func (r *KeptnWorkloadVersionReconciler) isPodRunning(ctx context.Context, resou return false, nil } -func (r *KeptnWorkloadVersionReconciler) isStatefulSetRunning(ctx context.Context, resource klcv1alpha3.ResourceReference, namespace string) (bool, error) { +func (r *KeptnWorkloadVersionReconciler) isStatefulSetRunning(ctx context.Context, resource klcv1beta1.ResourceReference, namespace string) (bool, error) { sts := appsv1.StatefulSet{} err := r.Client.Get(ctx, types.NamespacedName{Name: resource.Name, Namespace: namespace}, &sts) if err != nil { @@ -97,7 +96,7 @@ func (r *KeptnWorkloadVersionReconciler) isStatefulSetRunning(ctx context.Contex return *sts.Spec.Replicas == sts.Status.AvailableReplicas, nil } -func (r *KeptnWorkloadVersionReconciler) isRolloutRunning(ctx context.Context, resource klcv1alpha3.ResourceReference, namespace string) (bool, error) { +func (r *KeptnWorkloadVersionReconciler) isRolloutRunning(ctx context.Context, resource klcv1beta1.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 18a54670ba2..f567dae41c7 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" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3/common" - klcv1alpha4 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha4" + klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/task" ) -func (r *KeptnWorkloadVersionReconciler) reconcilePrePostDeployment(ctx context.Context, phaseCtx context.Context, workloadVersion *klcv1alpha4.KeptnWorkloadVersion, checkType apicommon.CheckType) (apicommon.KeptnState, error) { +func (r *KeptnWorkloadVersionReconciler) reconcilePrePostDeployment(ctx context.Context, phaseCtx context.Context, workloadVersion *klcv1beta1.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 cb844b8563e..2fd8bcd7292 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" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3/common" - klcv1alpha4 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha4" + klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/evaluation" ) -func (r *KeptnWorkloadVersionReconciler) reconcilePrePostEvaluation(ctx context.Context, phaseCtx context.Context, workloadVersion *klcv1alpha4.KeptnWorkloadVersion, checkType apicommon.CheckType) (apicommon.KeptnState, error) { +func (r *KeptnWorkloadVersionReconciler) reconcilePrePostEvaluation(ctx context.Context, phaseCtx context.Context, workloadVersion *klcv1beta1.KeptnWorkloadVersion, checkType apicommon.CheckType) (apicommon.KeptnState, error) { evaluationCreateAttributes := evaluation.CreateEvaluationAttributes{ SpanName: fmt.Sprintf(apicommon.CreateWorkloadEvalSpanName, checkType), CheckType: checkType, diff --git a/lifecycle-operator/main.go b/lifecycle-operator/main.go index 3560dc1938c..67a9a0d1742 100644 --- a/lifecycle-operator/main.go +++ b/lifecycle-operator/main.go @@ -99,7 +99,6 @@ type envConfig struct { KeptnTaskDefinitionControllerLogLevel int `envconfig:"KEPTN_TASK_DEFINITION_CONTROLLER_LOG_LEVEL" default:"0"` KeptnWorkloadControllerLogLevel int `envconfig:"KEPTN_WORKLOAD_CONTROLLER_LOG_LEVEL" default:"0"` KeptnWorkloadVersionControllerLogLevel int `envconfig:"KEPTN_WORKLOAD_VERSION_CONTROLLER_LOG_LEVEL" default:"0"` - KeptnWorkloadInstanceControllerLogLevel int `envconfig:"KEPTN_WORKLOAD_INSTANCE_CONTROLLER_LOG_LEVEL" default:"0"` KeptnDoraMetricsPort int `envconfig:"KEPTN_DORA_METRICS_PORT" default:"2222"` KeptnOptionsControllerLogLevel int `envconfig:"OPTIONS_CONTROLLER_LOG_LEVEL" default:"0"` @@ -273,7 +272,7 @@ func main() { setupLog.Error(err, "unable to create controller", "controller", "KeptnWorkload") os.Exit(1) } - workloadVersionLogger := ctrl.Log.WithName("KeptnWorkloadVersion Controller").V(determineWorkloadVersionControllerLogLevel(env.KeptnWorkloadVersionControllerLogLevel, env.KeptnWorkloadInstanceControllerLogLevel)) + workloadVersionLogger := ctrl.Log.WithName("KeptnWorkloadVersion Controller").V(env.KeptnWorkloadVersionControllerLogLevel) workloadVersionRecorder := mgr.GetEventRecorderFor("keptnworkloadversion-controller") workloadVersionEventSender := eventsender.NewEventMultiplexer(workloadVersionLogger, workloadVersionRecorder, ceClient) workloadVersionEvaluationHandler := evaluation.NewHandler( @@ -365,23 +364,15 @@ func main() { os.Exit(1) } - if err = (&lifecyclev1alpha3.KeptnApp{}).SetupWebhookWithManager(mgr); err != nil { + if err = (&lifecyclev1beta1.KeptnApp{}).SetupWebhookWithManager(mgr); err != nil { setupLog.Error(err, "unable to create webhook", "webhook", "KeptnApp") os.Exit(1) } - if err = (&lifecyclev1alpha3.KeptnEvaluationProvider{}).SetupWebhookWithManager(mgr); err != nil { - setupLog.Error(err, "unable to create webhook", "webhook", "KeptnEvaluationProvider") - os.Exit(1) - } - if err = (&lifecyclev1alpha3.KeptnAppVersion{}).SetupWebhookWithManager(mgr); err != nil { + if err = (&lifecyclev1beta1.KeptnAppVersion{}).SetupWebhookWithManager(mgr); err != nil { setupLog.Error(err, "unable to create webhook", "webhook", "KeptnAppVersion") os.Exit(1) } - if err = (&lifecyclev1alpha3.KeptnWorkloadInstance{}).SetupWebhookWithManager(mgr); err != nil { - setupLog.Error(err, "unable to create webhook", "webhook", "KeptnWorkloadInstance") - os.Exit(1) - } - if err = (&lifecyclev1alpha3.KeptnTaskDefinition{}).SetupWebhookWithManager(mgr); err != nil { + if err = (&lifecyclev1beta1.KeptnTaskDefinition{}).SetupWebhookWithManager(mgr); err != nil { setupLog.Error(err, "unable to create webhook", "webhook", "KeptnTaskDefinition") os.Exit(1) } @@ -448,13 +439,3 @@ func serveMetrics(metricsPort int) { return } } - -func determineWorkloadVersionControllerLogLevel(version int, instance int) int { - // if deprecated env.KeptnWorkloadInstanceControllerLogLevel is set and - // env.KeptnWorkloadVersionControllerLogLevel has default value (not set) - if instance != 0 && version == 0 { - return instance - } - - return version -} diff --git a/lifecycle-operator/test/api/metrics/v1alpha3/groupversion_info.go b/lifecycle-operator/test/api/metrics/v1beta1/groupversion_info.go similarity index 89% rename from lifecycle-operator/test/api/metrics/v1alpha3/groupversion_info.go rename to lifecycle-operator/test/api/metrics/v1beta1/groupversion_info.go index 07215ea3ca1..45a142ffb53 100644 --- a/lifecycle-operator/test/api/metrics/v1alpha3/groupversion_info.go +++ b/lifecycle-operator/test/api/metrics/v1beta1/groupversion_info.go @@ -14,10 +14,10 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Package v1alpha3 contains API Schema definitions for the metrics v1alpha3 API group +// Package v1beta1 contains API Schema definitions for the metrics v1beta1 API group // +kubebuilder:object:generate=true // +groupName=metrics.keptn.sh -package v1alpha3 +package v1beta1 import ( "k8s.io/apimachinery/pkg/runtime/schema" @@ -26,7 +26,7 @@ import ( var ( // GroupVersion is group version used to register these objects - GroupVersion = schema.GroupVersion{Group: "metrics.keptn.sh", Version: "v1alpha3"} + GroupVersion = schema.GroupVersion{Group: "metrics.keptn.sh", Version: "v1beta1"} // SchemeBuilder is used to add go types to the GroupVersionKind scheme SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} diff --git a/lifecycle-operator/test/api/metrics/v1alpha3/keptnmetric_types.go b/lifecycle-operator/test/api/metrics/v1beta1/keptnmetric_types.go similarity index 53% rename from lifecycle-operator/test/api/metrics/v1alpha3/keptnmetric_types.go rename to lifecycle-operator/test/api/metrics/v1beta1/keptnmetric_types.go index 6e47f2ed2b8..fb96f59a78a 100644 --- a/lifecycle-operator/test/api/metrics/v1alpha3/keptnmetric_types.go +++ b/lifecycle-operator/test/api/metrics/v1beta1/keptnmetric_types.go @@ -1,4 +1,4 @@ -package v1alpha3 +package v1beta1 import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -13,19 +13,27 @@ type KeptnMetricSpec struct { // FetchIntervalSeconds represents the update frequency in seconds that is used to update the metric FetchIntervalSeconds uint `json:"fetchIntervalSeconds"` // Range represents the time range for which data is to be queried + // +optional Range *RangeSpec `json:"range,omitempty"` } // KeptnMetricStatus defines the observed state of KeptnMetric type KeptnMetricStatus struct { // Value represents the resulting value - Value string `json:"value"` + // +optional + Value string `json:"value,omitempty"` // RawValue represents the resulting value in raw format - RawValue []byte `json:"rawValue"` + // +optional + RawValue []byte `json:"rawValue,omitempty"` // LastUpdated represents the time when the status data was last updated - LastUpdated metav1.Time `json:"lastUpdated"` + // +optional + LastUpdated metav1.Time `json:"lastUpdated,omitempty"` // ErrMsg represents the error details when the query could not be evaluated + // +optional ErrMsg string `json:"errMsg,omitempty"` + // IntervalResults contain a slice of all the interval results + // +optional + IntervalResults []IntervalResult `json:"intervalResults,omitempty"` } // ProviderRef represents the provider object @@ -38,21 +46,51 @@ type ProviderRef struct { type RangeSpec struct { // Interval specifies the duration of the time interval for the data query // +kubebuilder:default:="5m" + // +optional Interval string `json:"interval,omitempty"` + // Step represents the query resolution step width for the data query + // +optional + Step string `json:"step,omitempty"` + // Aggregation defines the type of aggregation function to be applied on the data. Accepted values: p90, p95, p99, max, min, avg, median + // +kubebuilder:validation:Enum:=p90;p95;p99;max;min;avg;median + // +optional + Aggregation string `json:"aggregation,omitempty"` + // StoredResults indicates the upper limit of how many past results should be stored in the status of a KeptnMetric + // +kubebuilder:validation:Maximum:=255 + // +optional + StoredResults uint `json:"storedResults,omitempty"` +} + +type IntervalResult struct { + // Value represents the resulting value + Value string `json:"value"` + // Range represents the time range for which this data was queried + Range *RangeSpec `json:"range"` + // LastUpdated represents the time when the status data was last updated + LastUpdated metav1.Time `json:"lastUpdated"` + // ErrMsg represents the error details when the query could not be evaluated + // +optional + ErrMsg string `json:"errMsg,omitempty"` } // KeptnMetric is the Schema for the keptnmetrics API type KeptnMetric struct { - metav1.TypeMeta `json:",inline"` + metav1.TypeMeta `json:",inline"` + // +optional metav1.ObjectMeta `json:"metadata,omitempty"` - Spec KeptnMetricSpec `json:"spec,omitempty"` + // +optional + Spec KeptnMetricSpec `json:"spec,omitempty"` + // +optional Status KeptnMetricStatus `json:"status,omitempty"` } -// KeptnMetricList contains a list of KeptnMetric +// +kubebuilder:object:root=true + +// KeptnMetricList contains a list of KeptnMetric resources type KeptnMetricList struct { metav1.TypeMeta `json:",inline"` + // +optional metav1.ListMeta `json:"metadata,omitempty"` Items []KeptnMetric `json:"items"` } diff --git a/lifecycle-operator/test/api/metrics/v1alpha3/zz_generated.deepcopy.go b/lifecycle-operator/test/api/metrics/v1beta1/zz_generated.deepcopy.go similarity index 84% rename from lifecycle-operator/test/api/metrics/v1alpha3/zz_generated.deepcopy.go rename to lifecycle-operator/test/api/metrics/v1beta1/zz_generated.deepcopy.go index 19da21d3265..18550747824 100644 --- a/lifecycle-operator/test/api/metrics/v1alpha3/zz_generated.deepcopy.go +++ b/lifecycle-operator/test/api/metrics/v1beta1/zz_generated.deepcopy.go @@ -1,5 +1,4 @@ //go:build !ignore_autogenerated -// +build !ignore_autogenerated /* Copyright 2023. @@ -19,12 +18,33 @@ limitations under the License. // Code generated by controller-gen. DO NOT EDIT. -package v1alpha3 +package v1beta1 import ( "k8s.io/apimachinery/pkg/runtime" ) +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *IntervalResult) DeepCopyInto(out *IntervalResult) { + *out = *in + if in.Range != nil { + in, out := &in.Range, &out.Range + *out = new(RangeSpec) + **out = **in + } + in.LastUpdated.DeepCopyInto(&out.LastUpdated) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IntervalResult. +func (in *IntervalResult) DeepCopy() *IntervalResult { + if in == nil { + return nil + } + out := new(IntervalResult) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *KeptnMetric) DeepCopyInto(out *KeptnMetric) { *out = *in @@ -114,6 +134,13 @@ func (in *KeptnMetricStatus) DeepCopyInto(out *KeptnMetricStatus) { copy(*out, *in) } in.LastUpdated.DeepCopyInto(&out.LastUpdated) + if in.IntervalResults != nil { + in, out := &in.IntervalResults, &out.IntervalResults + *out = make([]IntervalResult, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KeptnMetricStatus. diff --git a/lifecycle-operator/test/component/app/app_test.go b/lifecycle-operator/test/component/app/app_test.go index f724dcf98b4..15efa014cde 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" - klcv1alpha3 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3" + klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" "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 *klcv1alpha3.KeptnApp + instance *klcv1beta1.KeptnApp ) BeforeEach(func() { @@ -49,16 +49,16 @@ var _ = Describe("App", Ordered, func() { }) }) -func createInstanceInCluster(name string, namespace string, version string) *klcv1alpha3.KeptnApp { - instance := &klcv1alpha3.KeptnApp{ +func createInstanceInCluster(name string, namespace string, version string) *klcv1beta1.KeptnApp { + instance := &klcv1beta1.KeptnApp{ ObjectMeta: metav1.ObjectMeta{ Name: name, Namespace: namespace, Generation: 1, }, - Spec: klcv1alpha3.KeptnAppSpec{ + Spec: klcv1beta1.KeptnAppSpec{ Version: version, - Workloads: []klcv1alpha3.KeptnWorkloadRef{ + Workloads: []klcv1beta1.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 1cd4a403adc..6e44b1fdee6 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" - klcv1alpha3 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3/common" + klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/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 *klcv1alpha3.KeptnAppVersion + av *klcv1beta1.KeptnAppVersion ) Context("reconcile a new AppVersions CRD", func() { @@ -40,12 +40,12 @@ var _ = Describe("Appversion", Ordered, func() { }) It("should be deprecated when pre-eval checks failed", func() { - evaluation := &klcv1alpha3.KeptnEvaluation{ + evaluation := &klcv1beta1.KeptnEvaluation{ ObjectMeta: metav1.ObjectMeta{ Name: "pre-eval-eval-def-appversion", Namespace: namespace, }, - Spec: klcv1alpha3.KeptnEvaluationSpec{ + Spec: klcv1beta1.KeptnEvaluationSpec{ EvaluationDefinition: "eval-def-appversion", AppName: appName, AppVersion: version, @@ -68,10 +68,10 @@ var _ = Describe("Appversion", Ordered, func() { }, evaluation) Expect(err).To(BeNil()) - evaluation.Status = klcv1alpha3.KeptnEvaluationStatus{ + evaluation.Status = klcv1beta1.KeptnEvaluationStatus{ OverallStatus: apicommon.StateFailed, RetryCount: 10, - EvaluationStatus: map[string]klcv1alpha3.EvaluationStatusItem{ + EvaluationStatus: map[string]klcv1beta1.EvaluationStatusItem{ "something": { Status: apicommon.StateFailed, Value: "10", @@ -84,14 +84,14 @@ var _ = Describe("Appversion", Ordered, func() { err = k8sClient.Status().Update(ctx, evaluation) Expect(err).To(BeNil()) - av = &klcv1alpha3.KeptnAppVersion{ + av = &klcv1beta1.KeptnAppVersion{ ObjectMeta: metav1.ObjectMeta{ Name: appName + "-" + version, Namespace: namespace, }, - Spec: klcv1alpha3.KeptnAppVersionSpec{ + Spec: klcv1beta1.KeptnAppVersionSpec{ AppName: appName, - KeptnAppSpec: klcv1alpha3.KeptnAppSpec{ + KeptnAppSpec: klcv1beta1.KeptnAppSpec{ Version: version, PreDeploymentEvaluations: []string{"eval-def-appversion"}, }, @@ -103,12 +103,12 @@ var _ = Describe("Appversion", Ordered, func() { time.Sleep(5 * time.Second) - av2 := &klcv1alpha3.KeptnAppVersion{} + av2 := &klcv1beta1.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 = klcv1alpha3.KeptnAppVersionStatus{ + av2.Status = klcv1beta1.KeptnAppVersionStatus{ PreDeploymentStatus: apicommon.StateSucceeded, PreDeploymentEvaluationStatus: apicommon.StateProgressing, WorkloadOverallStatus: apicommon.StatePending, @@ -116,7 +116,7 @@ var _ = Describe("Appversion", Ordered, func() { PostDeploymentEvaluationStatus: apicommon.StatePending, CurrentPhase: apicommon.PhaseWorkloadPreEvaluation.ShortName, Status: apicommon.StateProgressing, - PreDeploymentEvaluationTaskStatus: []klcv1alpha3.ItemStatus{ + PreDeploymentEvaluationTaskStatus: []klcv1beta1.ItemStatus{ { Name: "pre-eval-eval-def-appversion", Status: apicommon.StateProgressing, @@ -135,7 +135,7 @@ var _ = Describe("Appversion", Ordered, func() { } //nolint:dupl Eventually(func(g Gomega) { - av := &klcv1alpha3.KeptnAppVersion{} + av := &klcv1beta1.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 2286a1abf0f..a830b4ac71c 100644 --- a/lifecycle-operator/test/component/common/common.go +++ b/lifecycle-operator/test/component/common/common.go @@ -8,11 +8,10 @@ import ( "strings" "time" - klcv1alpha3 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3/common" - klcv1alpha4 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha4" + klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/telemetry" - metricsapi "github.com/keptn/lifecycle-toolkit/lifecycle-operator/test/api/metrics/v1alpha3" + metricsapi "github.com/keptn/lifecycle-toolkit/lifecycle-operator/test/api/metrics/v1beta1" . "github.com/onsi/ginkgo/v2" ginkgotypes "github.com/onsi/ginkgo/v2/types" . "github.com/onsi/gomega" @@ -100,13 +99,13 @@ func MakeKeptnDefaultNamespace(k8sClient client.Client, name string) *v1.Namespa return ns } -func DeleteAppInCluster(ctx context.Context, k8sClient client.Client, instance *klcv1alpha3.KeptnApp) { +func DeleteAppInCluster(ctx context.Context, k8sClient client.Client, instance *klcv1beta1.KeptnApp) { By("Cleaning Up KeptnApp CRD ") err := k8sClient.Delete(ctx, instance) LogErrorIfPresent(err) } -func AssertResourceUpdated(ctx context.Context, k8sClient client.Client, instance *klcv1alpha3.KeptnApp) *klcv1alpha3.KeptnAppVersion { +func AssertResourceUpdated(ctx context.Context, k8sClient client.Client, instance *klcv1beta1.KeptnApp) *klcv1beta1.KeptnAppVersion { appVersion := GetAppVersion(ctx, k8sClient, instance) @@ -118,13 +117,13 @@ func AssertResourceUpdated(ctx context.Context, k8sClient client.Client, instanc return appVersion } -func GetAppVersion(ctx context.Context, k8sClient client.Client, instance *klcv1alpha3.KeptnApp) *klcv1alpha3.KeptnAppVersion { +func GetAppVersion(ctx context.Context, k8sClient client.Client, instance *klcv1beta1.KeptnApp) *klcv1beta1.KeptnAppVersion { appvName := types.NamespacedName{ Namespace: instance.Namespace, Name: instance.GetAppVersionName(), } - appVersion := &klcv1alpha3.KeptnAppVersion{} + appVersion := &klcv1beta1.KeptnAppVersion{} By("Retrieving Created app version") Eventually(func() error { return k8sClient.Get(ctx, appvName, appVersion) @@ -170,9 +169,7 @@ func InitSuite() (context.Context, ctrl.Manager, *otelsdk.TracerProvider, *sdkte Expect(cfg).NotTo(BeNil()) // +kubebuilder:scaffold:scheme - err = klcv1alpha3.AddToScheme(scheme.Scheme) - Expect(err).NotTo(HaveOccurred()) - err = klcv1alpha4.AddToScheme(scheme.Scheme) + err = klcv1beta1.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 0e334b70f43..cf93b276453 100644 --- a/lifecycle-operator/test/component/evaluation/evaluation_test.go +++ b/lifecycle-operator/test/component/evaluation/evaluation_test.go @@ -5,9 +5,9 @@ import ( "fmt" "time" - klcv1alpha3 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3/common" - metricsapi "github.com/keptn/lifecycle-toolkit/lifecycle-operator/test/api/metrics/v1alpha3" + klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" + metricsapi "github.com/keptn/lifecycle-toolkit/lifecycle-operator/test/api/metrics/v1beta1" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/test/component/common" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" @@ -35,8 +35,8 @@ var _ = Describe("Evaluation", Ordered, func() { Describe("Testing reconcile Evaluation scenario when using KeptnMetric instead of provider directly", func() { var ( - evaluationDefinition *klcv1alpha3.KeptnEvaluationDefinition - evaluation *klcv1alpha3.KeptnEvaluation + evaluationDefinition *klcv1beta1.KeptnEvaluationDefinition + evaluation *klcv1beta1.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 := &klcv1alpha3.KeptnEvaluationDefinition{} + evaluationdef := &klcv1beta1.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(klcv1alpha3.Objective{ - KeptnMetricRef: klcv1alpha3.KeptnMetricReference{ + g.Expect(evaluationdef.Spec.Objectives[0]).To(Equal(klcv1beta1.Objective{ + KeptnMetricRef: klcv1beta1.KeptnMetricReference{ Name: metricName, Namespace: namespaceName, }, @@ -88,7 +88,7 @@ var _ = Describe("Evaluation", Ordered, func() { By("Check that the evaluation passed") - evaluation2 := &klcv1alpha3.KeptnEvaluation{} + evaluation2 := &klcv1beta1.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]klcv1alpha3.EvaluationStatusItem{ + g.Expect(evaluation2.Status.EvaluationStatus).To(Equal(map[string]klcv1beta1.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 := &klcv1alpha3.KeptnEvaluationDefinition{} + evaluationdef := &klcv1beta1.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(klcv1alpha3.Objective{ - KeptnMetricRef: klcv1alpha3.KeptnMetricReference{ + g.Expect(evaluationdef.Spec.Objectives[0]).To(Equal(klcv1beta1.Objective{ + KeptnMetricRef: klcv1beta1.KeptnMetricReference{ Name: metricName, Namespace: KeptnNamespace, }, @@ -157,7 +157,7 @@ var _ = Describe("Evaluation", Ordered, func() { By("Check that the evaluation passed") - evaluation2 := &klcv1alpha3.KeptnEvaluation{} + evaluation2 := &klcv1beta1.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]klcv1alpha3.EvaluationStatusItem{ + g.Expect(evaluation2.Status.EvaluationStatus).To(Equal(map[string]klcv1beta1.EvaluationStatusItem{ metricName: { Value: "5", Status: apicommon.StateSucceeded, @@ -195,7 +195,7 @@ var _ = Describe("Evaluation", Ordered, func() { By("Check that the evaluation failed") - evaluation2 := &klcv1alpha3.KeptnEvaluation{} + evaluation2 := &klcv1beta1.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]klcv1alpha3.EvaluationStatusItem{ + g.Expect(evaluation2.Status.EvaluationStatus).To(Equal(map[string]klcv1beta1.EvaluationStatusItem{ metricName: { Value: "", Status: apicommon.StateFailed, @@ -226,7 +226,7 @@ var _ = Describe("Evaluation", Ordered, func() { By("Check that the evaluation failed") - evaluation2 := &klcv1alpha3.KeptnEvaluation{} + evaluation2 := &klcv1beta1.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]klcv1alpha3.EvaluationStatusItem{ + g.Expect(evaluation2.Status.EvaluationStatus).To(Equal(map[string]klcv1beta1.EvaluationStatusItem{ metricName: { Value: "", Status: apicommon.StateFailed, @@ -257,16 +257,16 @@ var _ = Describe("Evaluation", Ordered, func() { }) }) -func makeEvaluationDefinition(name string, namespaceName string, objectiveName string) *klcv1alpha3.KeptnEvaluationDefinition { - evalDef := &klcv1alpha3.KeptnEvaluationDefinition{ +func makeEvaluationDefinition(name string, namespaceName string, objectiveName string) *klcv1beta1.KeptnEvaluationDefinition { + evalDef := &klcv1beta1.KeptnEvaluationDefinition{ ObjectMeta: metav1.ObjectMeta{ Name: name, Namespace: namespaceName, }, - Spec: klcv1alpha3.KeptnEvaluationDefinitionSpec{ - Objectives: []klcv1alpha3.Objective{ + Spec: klcv1beta1.KeptnEvaluationDefinitionSpec{ + Objectives: []klcv1beta1.Objective{ { - KeptnMetricRef: klcv1alpha3.KeptnMetricReference{ + KeptnMetricRef: klcv1beta1.KeptnMetricReference{ Name: objectiveName, Namespace: namespaceName, }, @@ -303,13 +303,13 @@ func makeKeptnMetric(name string, namespaceName string) *metricsapi.KeptnMetric return metric } -func makeEvaluation(name string, namespaceName string, evaluationDefinition string) *klcv1alpha3.KeptnEvaluation { - eval := &klcv1alpha3.KeptnEvaluation{ +func makeEvaluation(name string, namespaceName string, evaluationDefinition string) *klcv1beta1.KeptnEvaluation { + eval := &klcv1beta1.KeptnEvaluation{ ObjectMeta: metav1.ObjectMeta{ Name: name, Namespace: namespaceName, }, - Spec: klcv1alpha3.KeptnEvaluationSpec{ + Spec: klcv1beta1.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 aac39b4a439..6bffce8b50e 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" - klcv1alpha3 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3" + klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" "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 []*klcv1alpha3.KeptnApp // Shelf is declared here - appVersions []*klcv1alpha3.KeptnAppVersion + apps []*klcv1beta1.KeptnApp // Shelf is declared here + appVersions []*klcv1beta1.KeptnAppVersion metrics Metric ) BeforeEach(func() { for i := 0; i < LOAD; i++ { - instance := &klcv1alpha3.KeptnApp{ + instance := &klcv1beta1.KeptnApp{ ObjectMeta: metav1.ObjectMeta{ Name: fmt.Sprintf("app-%d", i), Namespace: "default", }, - Spec: klcv1alpha3.KeptnAppSpec{ + Spec: klcv1beta1.KeptnAppSpec{ Version: "1.2.3", - Workloads: []klcv1alpha3.KeptnWorkloadRef{ + Workloads: []klcv1beta1.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 52190628b83..bf299521c72 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" - klcv1alpha3 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3/common" + klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/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 *klcv1alpha3.KeptnTaskDefinition - task *klcv1alpha3.KeptnTask + taskDefinition *klcv1beta1.KeptnTaskDefinition + task *klcv1beta1.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) *klcv1alpha3.KeptnTask { - task := &klcv1alpha3.KeptnTask{ +func makeTask(name string, namespace, taskDefinitionName string) *klcv1beta1.KeptnTask { + task := &klcv1beta1.KeptnTask{ ObjectMeta: metav1.ObjectMeta{ Name: name, Namespace: namespace, @@ -255,8 +255,8 @@ func makeTask(name string, namespace, taskDefinitionName string) *klcv1alpha3.Ke "annotation1": "annotation2", }, }, - Spec: klcv1alpha3.KeptnTaskSpec{ - Context: klcv1alpha3.TaskContext{ + Spec: klcv1beta1.KeptnTaskSpec{ + Context: klcv1beta1.TaskContext{ WorkloadName: "my-workload", AppName: "my-app", AppVersion: "0.1.0", @@ -271,7 +271,7 @@ func makeTask(name string, namespace, taskDefinitionName string) *klcv1alpha3.Ke return task } -func makeTaskDefinition(taskDefinitionName, namespace string) *klcv1alpha3.KeptnTaskDefinition { +func makeTaskDefinition(taskDefinitionName, namespace string) *klcv1beta1.KeptnTaskDefinition { cmName := "my-cm" cm := &v1.ConfigMap{ ObjectMeta: metav1.ObjectMeta{ @@ -286,14 +286,14 @@ func makeTaskDefinition(taskDefinitionName, namespace string) *klcv1alpha3.Keptn err := k8sClient.Create(context.TODO(), cm) Expect(err).To(BeNil()) - taskDefinition := &klcv1alpha3.KeptnTaskDefinition{ + taskDefinition := &klcv1beta1.KeptnTaskDefinition{ ObjectMeta: metav1.ObjectMeta{ Name: taskDefinitionName, Namespace: namespace, }, - Spec: klcv1alpha3.KeptnTaskDefinitionSpec{ - Function: &klcv1alpha3.RuntimeSpec{ - ConfigMapReference: klcv1alpha3.ConfigMapReference{ + Spec: klcv1beta1.KeptnTaskDefinitionSpec{ + Function: &klcv1beta1.RuntimeSpec{ + ConfigMapReference: klcv1beta1.ConfigMapReference{ Name: cmName, }, }, @@ -318,15 +318,15 @@ func makeTaskDefinition(taskDefinitionName, namespace string) *klcv1alpha3.Keptn return taskDefinition } -func makeContainerTaskDefinition(taskDefinitionName, namespace string) *klcv1alpha3.KeptnTaskDefinition { +func makeContainerTaskDefinition(taskDefinitionName, namespace string) *klcv1beta1.KeptnTaskDefinition { - taskDefinition := &klcv1alpha3.KeptnTaskDefinition{ + taskDefinition := &klcv1beta1.KeptnTaskDefinition{ ObjectMeta: metav1.ObjectMeta{ Name: taskDefinitionName, Namespace: namespace, }, - Spec: klcv1alpha3.KeptnTaskDefinitionSpec{ - Container: &klcv1alpha3.ContainerSpec{ + Spec: klcv1beta1.KeptnTaskDefinitionSpec{ + Container: &klcv1beta1.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 10405d58389..5b68f6fdbed 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" - klcv1alpha3 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3" + klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" "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 *klcv1alpha3.KeptnTaskDefinition + taskDefinition *klcv1beta1.KeptnTaskDefinition configmap *v1.ConfigMap ) Context("Reconcile TaskDefinition", func() { @@ -36,14 +36,14 @@ var _ = Describe("Taskdefinition", Ordered, func() { It("create ConfigMap from inline function", func() { By("Create TaskDefinition") - taskDefinition = &klcv1alpha3.KeptnTaskDefinition{ + taskDefinition = &klcv1beta1.KeptnTaskDefinition{ ObjectMeta: metav1.ObjectMeta{ Name: taskDefinitionName, Namespace: namespace, }, - Spec: klcv1alpha3.KeptnTaskDefinitionSpec{ - Function: &klcv1alpha3.RuntimeSpec{ - Inline: klcv1alpha3.Inline{ + Spec: klcv1beta1.KeptnTaskDefinitionSpec{ + Function: &klcv1beta1.RuntimeSpec{ + Inline: klcv1beta1.Inline{ Code: "console.log(Hello);", }, }, @@ -68,7 +68,7 @@ var _ = Describe("Taskdefinition", Ordered, func() { By("Check if TaskDefinition was updated") - taskDefinition2 := &klcv1alpha3.KeptnTaskDefinition{} + taskDefinition2 := &klcv1beta1.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 = &klcv1alpha3.KeptnTaskDefinition{ + taskDefinition = &klcv1beta1.KeptnTaskDefinition{ ObjectMeta: metav1.ObjectMeta{ Name: taskDefinitionName, Namespace: namespace, }, - Spec: klcv1alpha3.KeptnTaskDefinitionSpec{ - Function: &klcv1alpha3.RuntimeSpec{ - ConfigMapReference: klcv1alpha3.ConfigMapReference{ + Spec: klcv1beta1.KeptnTaskDefinitionSpec{ + Function: &klcv1beta1.RuntimeSpec{ + ConfigMapReference: klcv1beta1.ConfigMapReference{ Name: configmap.Name, }, }, @@ -119,7 +119,7 @@ var _ = Describe("Taskdefinition", Ordered, func() { By("Check if TaskDefinition was updated") - taskDefinition2 := &klcv1alpha3.KeptnTaskDefinition{} + taskDefinition2 := &klcv1beta1.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 = &klcv1alpha3.KeptnTaskDefinition{ + taskDefinition = &klcv1beta1.KeptnTaskDefinition{ ObjectMeta: metav1.ObjectMeta{ Name: taskDefinitionName, Namespace: namespace, }, - Spec: klcv1alpha3.KeptnTaskDefinitionSpec{ - Python: &klcv1alpha3.RuntimeSpec{ - ConfigMapReference: klcv1alpha3.ConfigMapReference{ + Spec: klcv1beta1.KeptnTaskDefinitionSpec{ + Python: &klcv1beta1.RuntimeSpec{ + ConfigMapReference: klcv1beta1.ConfigMapReference{ Name: configmap.Name, }, }, @@ -170,7 +170,7 @@ var _ = Describe("Taskdefinition", Ordered, func() { By("Check if TaskDefinition was updated") - taskDefinition2 := &klcv1alpha3.KeptnTaskDefinition{} + taskDefinition2 := &klcv1beta1.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 = &klcv1alpha3.KeptnTaskDefinition{ + taskDefinition = &klcv1beta1.KeptnTaskDefinition{ ObjectMeta: metav1.ObjectMeta{ Name: taskDefinitionName, Namespace: namespace, }, - Spec: klcv1alpha3.KeptnTaskDefinitionSpec{ - Function: &klcv1alpha3.RuntimeSpec{ - ConfigMapReference: klcv1alpha3.ConfigMapReference{ + Spec: klcv1beta1.KeptnTaskDefinitionSpec{ + Function: &klcv1beta1.RuntimeSpec{ + ConfigMapReference: klcv1beta1.ConfigMapReference{ Name: "my-configmap-non-existing", }, }, @@ -217,7 +217,7 @@ var _ = Describe("Taskdefinition", Ordered, func() { By("Check that TaskDefinition Status was not updated") - taskDefinition2 := &klcv1alpha3.KeptnTaskDefinition{} + taskDefinition2 := &klcv1beta1.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 46b1bdbbf12..61260780b6e 100644 --- a/lifecycle-operator/test/component/workload/workload_test.go +++ b/lifecycle-operator/test/component/workload/workload_test.go @@ -4,8 +4,7 @@ import ( "context" "fmt" - klcv1alpha3 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3" - klcv1alpha4 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha4" + klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/test/component/common" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" @@ -31,8 +30,8 @@ var _ = Describe("Workload", Ordered, func() { }) Describe("Creation of WorkloadVersion from a new Workload", func() { var ( - workload *klcv1alpha3.KeptnWorkload - workloadVersion *klcv1alpha4.KeptnWorkloadVersion + workload *klcv1beta1.KeptnWorkload + workloadVersion *klcv1beta1.KeptnWorkloadVersion ) BeforeEach(func() { @@ -43,7 +42,7 @@ var _ = Describe("Workload", Ordered, func() { It("should create WorkloadVersion", func() { By("Check if WorkloadVersion was created") - workloadVersion = &klcv1alpha4.KeptnWorkloadVersion{} + workloadVersion = &klcv1beta1.KeptnWorkloadVersion{} Eventually(func(g Gomega) { err := k8sClient.Get(context.TODO(), types.NamespacedName{ Namespace: namespace, @@ -69,16 +68,16 @@ var _ = Describe("Workload", Ordered, func() { }) }) -func createWorkloadInCluster(name string, namespace string, version string, applicationName string) *klcv1alpha3.KeptnWorkload { - workload := &klcv1alpha3.KeptnWorkload{ +func createWorkloadInCluster(name string, namespace string, version string, applicationName string) *klcv1beta1.KeptnWorkload { + workload := &klcv1beta1.KeptnWorkload{ ObjectMeta: metav1.ObjectMeta{ Name: name, Namespace: namespace, }, - Spec: klcv1alpha3.KeptnWorkloadSpec{ + Spec: klcv1beta1.KeptnWorkloadSpec{ AppName: applicationName, Version: version, - ResourceReference: klcv1alpha3.ResourceReference{UID: types.UID("uid"), Kind: "Pod", Name: "pod1"}, + ResourceReference: klcv1beta1.ResourceReference{UID: types.UID("uid"), Kind: "Pod", Name: "pod1"}, }, } 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 b5e2e5032c7..c584229f1b6 100644 --- a/lifecycle-operator/test/component/workloadversion/workloadversion_test.go +++ b/lifecycle-operator/test/component/workloadversion/workloadversion_test.go @@ -5,9 +5,8 @@ import ( "strings" "time" - klcv1alpha3 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3/common" - klcv1alpha4 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha4" + klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/test/component/common" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" @@ -33,8 +32,8 @@ var _ = Describe("WorkloadVersion", Ordered, func() { }) Describe("Creation of WorkloadVersion", func() { var ( - appVersion *klcv1alpha3.KeptnAppVersion - wi *klcv1alpha4.KeptnWorkloadVersion + appVersion *klcv1beta1.KeptnAppVersion + wi *klcv1beta1.KeptnWorkloadVersion ) Context("with a new AppVersions CRD", func() { @@ -45,13 +44,13 @@ var _ = Describe("WorkloadVersion", Ordered, func() { It("should fail if Workload not found in AppVersion", func() { wiName := "not-found" - wi = &klcv1alpha4.KeptnWorkloadVersion{ + wi = &klcv1beta1.KeptnWorkloadVersion{ ObjectMeta: metav1.ObjectMeta{ Name: appName, Namespace: namespace, }, - Spec: klcv1alpha4.KeptnWorkloadVersionSpec{ - KeptnWorkloadSpec: klcv1alpha3.KeptnWorkloadSpec{}, + Spec: klcv1beta1.KeptnWorkloadVersionSpec{ + KeptnWorkloadSpec: klcv1beta1.KeptnWorkloadSpec{}, WorkloadName: appName + "-wname-" + wiName, TraceId: map[string]string{"traceparent": "00-0f89f15e562489e2e171eca1cf9ba958-d2fa6dbbcbf7e29a-01"}, }, @@ -66,7 +65,7 @@ var _ = Describe("WorkloadVersion", Ordered, func() { Name: wi.Name, } Consistently(func(g Gomega) { - wi := &klcv1alpha4.KeptnWorkloadVersion{} + wi := &klcv1beta1.KeptnWorkloadVersion{} err := k8sClient.Get(ctx, wiNameObj, wi) g.Expect(err).To(BeNil()) g.Expect(wi).To(Not(BeNil())) @@ -102,7 +101,7 @@ var _ = Describe("WorkloadVersion", Ordered, func() { By("Setting the App PreDeploymentEvaluation Status to 'Succeeded'") - av := &klcv1alpha3.KeptnAppVersion{} + av := &klcv1beta1.KeptnAppVersion{} err = k8sClient.Get(ctx, types.NamespacedName{ Namespace: namespace, Name: appName, @@ -128,14 +127,14 @@ var _ = Describe("WorkloadVersion", Ordered, func() { Expect(err).To(BeNil()) By("Creating a WorkloadVersion that references the StatefulSet") - wi = &klcv1alpha4.KeptnWorkloadVersion{ + wi = &klcv1beta1.KeptnWorkloadVersion{ ObjectMeta: metav1.ObjectMeta{ Name: appName, Namespace: namespace, }, - Spec: klcv1alpha4.KeptnWorkloadVersionSpec{ - KeptnWorkloadSpec: klcv1alpha3.KeptnWorkloadSpec{ - ResourceReference: klcv1alpha3.ResourceReference{ + Spec: klcv1beta1.KeptnWorkloadVersionSpec{ + KeptnWorkloadSpec: klcv1beta1.KeptnWorkloadSpec{ + ResourceReference: klcv1beta1.ResourceReference{ UID: statefulSet.UID, Kind: "StatefulSet", Name: "my-statefulset", @@ -156,7 +155,7 @@ var _ = Describe("WorkloadVersion", Ordered, func() { Name: wi.Name, } Eventually(func(g Gomega) { - wi := &klcv1alpha4.KeptnWorkloadVersion{} + wi := &klcv1beta1.KeptnWorkloadVersion{} err := k8sClient.Get(ctx, wiNameObj, wi) g.Expect(err).To(BeNil()) g.Expect(wi.Status.DeploymentStatus).To(Equal(apicommon.StateSucceeded)) @@ -188,7 +187,7 @@ var _ = Describe("WorkloadVersion", Ordered, func() { By("Setting the App PreDeploymentEvaluation Status to 'Succeeded'") - av := &klcv1alpha3.KeptnAppVersion{} + av := &klcv1beta1.KeptnAppVersion{} err = k8sClient.Get(ctx, types.NamespacedName{ Namespace: namespace, Name: appName, @@ -213,14 +212,14 @@ var _ = Describe("WorkloadVersion", Ordered, func() { Expect(err).To(BeNil()) By("Creating a WorkloadVersion that references the DaemonSet") - wi = &klcv1alpha4.KeptnWorkloadVersion{ + wi = &klcv1beta1.KeptnWorkloadVersion{ ObjectMeta: metav1.ObjectMeta{ Name: appName, Namespace: namespace, }, - Spec: klcv1alpha4.KeptnWorkloadVersionSpec{ - KeptnWorkloadSpec: klcv1alpha3.KeptnWorkloadSpec{ - ResourceReference: klcv1alpha3.ResourceReference{ + Spec: klcv1beta1.KeptnWorkloadVersionSpec{ + KeptnWorkloadSpec: klcv1beta1.KeptnWorkloadSpec{ + ResourceReference: klcv1beta1.ResourceReference{ UID: daemonSet.UID, Kind: "DaemonSet", Name: "my-daemonset", @@ -241,19 +240,19 @@ var _ = Describe("WorkloadVersion", Ordered, func() { Name: wi.Name, } Eventually(func(g Gomega) { - wi := &klcv1alpha4.KeptnWorkloadVersion{} + wi := &klcv1beta1.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 := &klcv1alpha3.KeptnEvaluation{ + evaluation := &klcv1beta1.KeptnEvaluation{ ObjectMeta: metav1.ObjectMeta{ Name: "pre-eval-eval-def", Namespace: namespace, }, - Spec: klcv1alpha3.KeptnEvaluationSpec{ + Spec: klcv1beta1.KeptnEvaluationSpec{ EvaluationDefinition: "eval-def", Workload: appName + "-wname", WorkloadVersion: "2.0", @@ -276,10 +275,10 @@ var _ = Describe("WorkloadVersion", Ordered, func() { }, evaluation) Expect(err).To(BeNil()) - evaluation.Status = klcv1alpha3.KeptnEvaluationStatus{ + evaluation.Status = klcv1beta1.KeptnEvaluationStatus{ OverallStatus: apicommon.StateFailed, RetryCount: 10, - EvaluationStatus: map[string]klcv1alpha3.EvaluationStatusItem{ + EvaluationStatus: map[string]klcv1beta1.EvaluationStatusItem{ "something": { Status: apicommon.StateFailed, Value: "10", @@ -292,13 +291,13 @@ var _ = Describe("WorkloadVersion", Ordered, func() { err = k8sClient.Status().Update(ctx, evaluation) Expect(err).To(BeNil()) - wi = &klcv1alpha4.KeptnWorkloadVersion{ + wi = &klcv1beta1.KeptnWorkloadVersion{ ObjectMeta: metav1.ObjectMeta{ Name: appName + "-wname-2.0", Namespace: namespace, }, - Spec: klcv1alpha4.KeptnWorkloadVersionSpec{ - KeptnWorkloadSpec: klcv1alpha3.KeptnWorkloadSpec{ + Spec: klcv1beta1.KeptnWorkloadVersionSpec{ + KeptnWorkloadSpec: klcv1beta1.KeptnWorkloadSpec{ Version: "2.0", AppName: appVersion.GetAppName(), PreDeploymentEvaluations: []string{"eval-def"}, @@ -312,12 +311,12 @@ var _ = Describe("WorkloadVersion", Ordered, func() { time.Sleep(5 * time.Second) - wi2 := &klcv1alpha4.KeptnWorkloadVersion{} + wi2 := &klcv1beta1.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 = klcv1alpha4.KeptnWorkloadVersionStatus{ + wi2.Status = klcv1beta1.KeptnWorkloadVersionStatus{ PreDeploymentStatus: apicommon.StateSucceeded, PreDeploymentEvaluationStatus: apicommon.StateProgressing, DeploymentStatus: apicommon.StatePending, @@ -325,7 +324,7 @@ var _ = Describe("WorkloadVersion", Ordered, func() { PostDeploymentEvaluationStatus: apicommon.StatePending, CurrentPhase: apicommon.PhaseWorkloadPreEvaluation.ShortName, Status: apicommon.StateProgressing, - PreDeploymentEvaluationTaskStatus: []klcv1alpha3.ItemStatus{ + PreDeploymentEvaluationTaskStatus: []klcv1beta1.ItemStatus{ { Name: "pre-eval-eval-def", Status: apicommon.StateProgressing, @@ -344,7 +343,7 @@ var _ = Describe("WorkloadVersion", Ordered, func() { } //nolint:dupl Eventually(func(g Gomega) { - wi := &klcv1alpha4.KeptnWorkloadVersion{} + wi := &klcv1beta1.KeptnWorkloadVersion{} err := k8sClient.Get(ctx, wiNameObj, wi) g.Expect(err).To(BeNil()) g.Expect(wi).To(Not(BeNil())) @@ -389,18 +388,18 @@ var _ = Describe("WorkloadVersion", Ordered, func() { }) }) -func createAppVersionInCluster(name string, namespace string, version string) *klcv1alpha3.KeptnAppVersion { - instance := &klcv1alpha3.KeptnAppVersion{ +func createAppVersionInCluster(name string, namespace string, version string) *klcv1beta1.KeptnAppVersion { + instance := &klcv1beta1.KeptnAppVersion{ ObjectMeta: metav1.ObjectMeta{ Name: name, Namespace: namespace, Generation: 1, }, - Spec: klcv1alpha3.KeptnAppVersionSpec{ + Spec: klcv1beta1.KeptnAppVersionSpec{ AppName: name, - KeptnAppSpec: klcv1alpha3.KeptnAppSpec{ + KeptnAppSpec: klcv1beta1.KeptnAppSpec{ Version: version, - Workloads: []klcv1alpha3.KeptnWorkloadRef{ + Workloads: []klcv1beta1.KeptnWorkloadRef{ { Name: "wname", Version: "2.0", @@ -413,7 +412,7 @@ func createAppVersionInCluster(name string, namespace string, version string) *k Expect(common.IgnoreAlreadyExists(k8sClient.Create(ctx, instance))).Should(Succeed()) - av := &klcv1alpha3.KeptnAppVersion{} + av := &klcv1beta1.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 833e25c6782..946ee33696d 100644 --- a/lifecycle-operator/test/e2e/suite_test.go +++ b/lifecycle-operator/test/e2e/suite_test.go @@ -24,7 +24,7 @@ import ( "testing" "time" - klcv1alpha3 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3" + klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" . "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 = klcv1alpha3.AddToScheme(scheme.Scheme) + err = klcv1beta1.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 0541b2e8a41..c31e8e7cc91 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" - klcv1alpha3 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3/common" + klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/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 := &klcv1alpha3.KeptnAppCreationRequest{} + appCreationRequest := &klcv1beta1.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 *klcv1alpha3.KeptnAppCreationRequest) error { +func (a *AppCreationRequestHandler) createResource(ctx context.Context, newAppCreationRequest *klcv1beta1.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) *klcv1alpha3.KeptnAppCreationRequest { +func generateResource(ctx context.Context, pod *corev1.Pod, namespace string) *klcv1beta1.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 := &klcv1alpha3.KeptnAppCreationRequest{ + kacr := &klcv1beta1.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 = klcv1alpha3.KeptnAppCreationRequestSpec{ + kacr.Spec = klcv1beta1.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 22be4260701..89c7a6a499b 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" - klcv1alpha3 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3/common" + klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/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 := &klcv1alpha3.KeptnAppCreationRequest{ + singleServiceCreationReq := &klcv1beta1.KeptnAppCreationRequest{ TypeMeta: metav1.TypeMeta{ Kind: "KeptnAppCreationRequest", - APIVersion: "lifecycle.keptn.sh/v1alpha3", + APIVersion: "lifecycle.keptn.sh/v1beta1", }, ObjectMeta: metav1.ObjectMeta{ Name: TestWorkload, @@ -55,7 +55,7 @@ func TestAppHandlerHandle(t *testing.T) { "keptn.sh/app-type": "single-service", }, }, - Spec: klcv1alpha3.KeptnAppCreationRequestSpec{AppName: TestWorkload}, + Spec: klcv1beta1.KeptnAppCreationRequestSpec{AppName: TestWorkload}, } tests := []struct { @@ -63,7 +63,7 @@ func TestAppHandlerHandle(t *testing.T) { client client.Client pod *corev1.Pod wanterr error - wantReq *klcv1alpha3.KeptnAppCreationRequest + wantReq *klcv1beta1.KeptnAppCreationRequest }{ { name: "Create AppCreationRequest inherit from workload", @@ -90,17 +90,17 @@ func TestAppHandlerHandle(t *testing.T) { }, }}, client: testcommon.NewTestClient(), - wantReq: &klcv1alpha3.KeptnAppCreationRequest{ + wantReq: &klcv1beta1.KeptnAppCreationRequest{ TypeMeta: metav1.TypeMeta{ Kind: "KeptnAppCreationRequest", - APIVersion: "lifecycle.keptn.sh/v1alpha3", + APIVersion: "lifecycle.keptn.sh/v1beta1", }, ObjectMeta: metav1.ObjectMeta{ Name: testApp, Namespace: namespace, ResourceVersion: "1", }, - Spec: klcv1alpha3.KeptnAppCreationRequestSpec{AppName: testApp}, + Spec: klcv1beta1.KeptnAppCreationRequestSpec{AppName: testApp}, }, }, { @@ -142,7 +142,7 @@ func TestAppHandlerHandle(t *testing.T) { } if tt.wantReq != nil { - creationReq := &klcv1alpha3.KeptnAppCreationRequest{} + creationReq := &klcv1beta1.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 := &klcv1alpha3.KeptnAppCreationRequest{ + newAppCreationRequest := &klcv1beta1.KeptnAppCreationRequest{ ObjectMeta: metav1.ObjectMeta{Name: name}, } err := appHandler.createResource(ctx, newAppCreationRequest) require.Nil(t, err) - creationReq := &klcv1alpha3.KeptnAppCreationRequest{} + creationReq := &klcv1beta1.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 := &klcv1alpha3.KeptnAppCreationRequest{ + newAppCreationRequest := &klcv1beta1.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 1157ef99f5b..15b30806374 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/v1alpha3/common" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/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 4cf9783538d..0c930bfab38 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/v1alpha3/common" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/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 9c6f20ecec6..88926aad78e 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/v1alpha3/common" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/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 645e3f121a0..7daedca8e6e 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/v1alpha3/common" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/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 b6f600a1fe4..7084312af24 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" - klcv1alpha3 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3/common" + klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/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 := &klcv1alpha3.KeptnWorkload{} + workload := &klcv1beta1.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 *klcv1alpha3.KeptnWorkload, newWorkload *klcv1alpha3.KeptnWorkload) error { +func (a *WorkloadHandler) updateWorkload(ctx context.Context, workload *klcv1beta1.KeptnWorkload, newWorkload *klcv1beta1.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 *klcv1alp return nil } -func (a *WorkloadHandler) createWorkload(ctx context.Context, newWorkload *klcv1alpha3.KeptnWorkload) error { +func (a *WorkloadHandler) createWorkload(ctx context.Context, newWorkload *klcv1beta1.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) *klcv1alpha3.KeptnWorkload { +func generateWorkload(ctx context.Context, pod *corev1.Pod, namespace string) *klcv1beta1.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 &klcv1alpha3.KeptnWorkload{ + return &klcv1beta1.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: klcv1alpha3.KeptnWorkloadSpec{ + Spec: klcv1beta1.KeptnWorkloadSpec{ AppName: applicationName, Version: version, - ResourceReference: klcv1alpha3.ResourceReference{UID: ownerRef.UID, Kind: ownerRef.Kind, Name: ownerRef.Name}, + ResourceReference: klcv1beta1.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 a50e862d5b4..b6aa729e402 100644 --- a/lifecycle-operator/webhooks/pod_mutator/handlers/workload_test.go +++ b/lifecycle-operator/webhooks/pod_mutator/handlers/workload_test.go @@ -5,8 +5,8 @@ import ( "testing" "github.com/go-logr/logr/testr" - klcv1alpha3 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3/common" + klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/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" @@ -31,15 +31,15 @@ func TestHandle(t *testing.T) { mockEventSender := eventsender.NewK8sSender(record.NewFakeRecorder(100)) log := testr.New(t) - workload := &klcv1alpha3.KeptnWorkload{ + workload := &klcv1beta1.KeptnWorkload{ ObjectMeta: metav1.ObjectMeta{ Name: "my-workload-my-workload", Namespace: namespace, }, } - wantWorkload := &klcv1alpha3.KeptnWorkload{ - TypeMeta: metav1.TypeMeta{Kind: "KeptnWorkload", APIVersion: "lifecycle.keptn.sh/v1alpha3"}, + wantWorkload := &klcv1beta1.KeptnWorkload{ + TypeMeta: metav1.TypeMeta{Kind: "KeptnWorkload", APIVersion: "lifecycle.keptn.sh/v1beta1"}, ObjectMeta: metav1.ObjectMeta{ Name: testAppWorkload, Namespace: namespace, @@ -48,7 +48,7 @@ func TestHandle(t *testing.T) { }, ResourceVersion: "1", }, - Spec: klcv1alpha3.KeptnWorkloadSpec{ + Spec: klcv1beta1.KeptnWorkloadSpec{ AppName: TestWorkload, Version: "0.1", }, @@ -69,7 +69,7 @@ func TestHandle(t *testing.T) { client client.Client pod *corev1.Pod wanterr error - wantWorkload *klcv1alpha3.KeptnWorkload + wantWorkload *klcv1beta1.KeptnWorkload }{ { name: "Create Workload", @@ -132,7 +132,7 @@ func TestHandle(t *testing.T) { } if tt.wantWorkload != nil { - actualWorkload := &klcv1alpha3.KeptnWorkload{} + actualWorkload := &klcv1beta1.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) @@ -146,7 +146,7 @@ func TestUpdateWorkloadNoSpecChanges(t *testing.T) { mockEventSender := eventsender.NewK8sSender(record.NewFakeRecorder(100)) log := testr.New(t) - workload := &klcv1alpha3.KeptnWorkload{ + workload := &klcv1beta1.KeptnWorkload{ ObjectMeta: metav1.ObjectMeta{ Name: testAppWorkload, Namespace: namespace, @@ -166,7 +166,7 @@ func TestGenerateWorkload(t *testing.T) { testCases := []struct { name string podAnnotations map[string]string - expected *klcv1alpha3.KeptnWorkload + expected *klcv1beta1.KeptnWorkload }{ { name: "Pod with annotations", @@ -178,7 +178,7 @@ func TestGenerateWorkload(t *testing.T) { apicommon.PostDeploymentEvaluationAnnotation: "eval3,eval4", apicommon.K8sRecommendedAppAnnotations: "my-app", }, - expected: &klcv1alpha3.KeptnWorkload{ + expected: &klcv1beta1.KeptnWorkload{ ObjectMeta: metav1.ObjectMeta{ Name: getWorkloadName(&metav1.ObjectMeta{}, "my-app"), Namespace: "my-namespace", @@ -192,10 +192,10 @@ func TestGenerateWorkload(t *testing.T) { }, }, }, - Spec: klcv1alpha3.KeptnWorkloadSpec{ + Spec: klcv1beta1.KeptnWorkloadSpec{ AppName: "my-app", Version: "v1", - ResourceReference: klcv1alpha3.ResourceReference{UID: "owner-uid", Kind: "Deployment", Name: "deployment-1"}, + ResourceReference: klcv1beta1.ResourceReference{UID: "owner-uid", Kind: "Deployment", Name: "deployment-1"}, PreDeploymentTasks: []string{"task1", "task2"}, PostDeploymentTasks: []string{"task3", "task4"}, PreDeploymentEvaluations: []string{"eval1", "eval2"}, @@ -206,7 +206,7 @@ func TestGenerateWorkload(t *testing.T) { { name: "Pod with no annotations", podAnnotations: nil, - expected: &klcv1alpha3.KeptnWorkload{ + expected: &klcv1beta1.KeptnWorkload{ ObjectMeta: metav1.ObjectMeta{ Name: "-", Namespace: "my-namespace", @@ -218,8 +218,8 @@ func TestGenerateWorkload(t *testing.T) { UID: "owner-uid", }, }}, - Spec: klcv1alpha3.KeptnWorkloadSpec{ - ResourceReference: klcv1alpha3.ResourceReference{ + Spec: klcv1beta1.KeptnWorkloadSpec{ + ResourceReference: klcv1beta1.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 ac68b367cef..50c4efb116b 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/v1alpha3/common" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/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 bf2877e8aa8..5e9291491c3 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" - klcv1alpha3 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3" - apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1alpha3/common" + klcv1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" + apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/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 := &klcv1alpha3.KeptnAppCreationRequest{} + kacr := &klcv1beta1.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 := &klcv1alpha3.KeptnWorkload{} + workload := &klcv1beta1.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 := &klcv1alpha3.KeptnAppCreationRequest{} + kacr := &klcv1beta1.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 := &klcv1alpha3.KeptnWorkload{} + workload := &klcv1beta1.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, klcv1alpha3.KeptnWorkloadSpec{ + require.Equal(t, klcv1beta1.KeptnWorkloadSpec{ AppName: kacr.Spec.AppName, Version: "0.1", - ResourceReference: klcv1alpha3.ResourceReference{ + ResourceReference: klcv1beta1.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 := &klcv1alpha3.KeptnAppCreationRequest{} + kacr := &klcv1beta1.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 := &klcv1alpha3.KeptnWorkload{} + workload := &klcv1beta1.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, klcv1alpha3.KeptnWorkloadSpec{ + require.Equal(t, klcv1beta1.KeptnWorkloadSpec{ AppName: kacr.Spec.AppName, Version: "0.1", - ResourceReference: klcv1alpha3.ResourceReference{ + ResourceReference: klcv1beta1.ResourceReference{ UID: "1234", Kind: "Deployment", Name: testDeployment, @@ -396,7 +396,7 @@ func TestPodMutatingWebhookHandleSingleServiceAppCreationRequestAlreadyPresent(t apicommon.NamespaceEnabledAnnotation: "enabled", }, }, - }, &klcv1alpha3.KeptnAppCreationRequest{ + }, &klcv1beta1.KeptnAppCreationRequest{ TypeMeta: metav1.TypeMeta{}, ObjectMeta: metav1.ObjectMeta{ Name: testWorkload, @@ -408,7 +408,7 @@ func TestPodMutatingWebhookHandleSingleServiceAppCreationRequestAlreadyPresent(t "donotchange": "true", }, }, - Spec: klcv1alpha3.KeptnAppCreationRequestSpec{ + Spec: klcv1beta1.KeptnAppCreationRequestSpec{ AppName: testWorkload, }, }) @@ -453,7 +453,7 @@ func TestPodMutatingWebhookHandleSingleServiceAppCreationRequestAlreadyPresent(t require.NotNil(t, resp) require.True(t, resp.Allowed) - kacr := &klcv1alpha3.KeptnAppCreationRequest{} + kacr := &klcv1beta1.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 := &klcv1alpha3.KeptnWorkload{} + workload := &klcv1beta1.KeptnWorkload{} err = fakeClient.Get(context.TODO(), types.NamespacedName{ Namespace: testNamespace, @@ -476,10 +476,10 @@ func TestPodMutatingWebhookHandleSingleServiceAppCreationRequestAlreadyPresent(t require.Nil(t, err) - require.Equal(t, klcv1alpha3.KeptnWorkloadSpec{ + require.Equal(t, klcv1beta1.KeptnWorkloadSpec{ AppName: kacr.Spec.AppName, Version: "0.1", - ResourceReference: klcv1alpha3.ResourceReference{ + ResourceReference: klcv1beta1.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 := &klcv1alpha3.KeptnAppCreationRequest{} + kacr := &klcv1beta1.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 := &klcv1alpha3.KeptnWorkload{} + workload := &klcv1beta1.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, klcv1alpha3.KeptnWorkloadSpec{ + require.Equal(t, klcv1beta1.KeptnWorkloadSpec{ AppName: kacr.Spec.AppName, Version: "v0.1", - ResourceReference: klcv1alpha3.ResourceReference{ + ResourceReference: klcv1beta1.ResourceReference{ UID: "1234", Kind: "Deployment", Name: testDeployment, diff --git a/test/allowed-namespaces/simple-deployment-allowed/00-install.yaml b/test/allowed-namespaces/simple-deployment-allowed/00-install.yaml index 0d798f2a1e4..53257e97689 100644 --- a/test/allowed-namespaces/simple-deployment-allowed/00-install.yaml +++ b/test/allowed-namespaces/simple-deployment-allowed/00-install.yaml @@ -1,5 +1,5 @@ --- -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnTaskDefinition metadata: name: pre-deployment-hello diff --git a/test/allowed-namespaces/simple-deployment-allowed/01-assert.yaml b/test/allowed-namespaces/simple-deployment-allowed/01-assert.yaml index b0778a26dd4..b78729cd1f7 100644 --- a/test/allowed-namespaces/simple-deployment-allowed/01-assert.yaml +++ b/test/allowed-namespaces/simple-deployment-allowed/01-assert.yaml @@ -1,11 +1,11 @@ -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnWorkload metadata: name: waiter-waiter namespace: allowed-ns-test --- -apiVersion: lifecycle.keptn.sh/v1alpha4 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnWorkloadVersion metadata: name: waiter-waiter-0.4 diff --git a/test/allowed-namespaces/simple-deployment-not-allowed/00-install.yaml b/test/allowed-namespaces/simple-deployment-not-allowed/00-install.yaml index 3a42f164736..9ed8735ff47 100644 --- a/test/allowed-namespaces/simple-deployment-not-allowed/00-install.yaml +++ b/test/allowed-namespaces/simple-deployment-not-allowed/00-install.yaml @@ -1,5 +1,5 @@ --- -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnTaskDefinition metadata: name: pre-deployment-hello diff --git a/test/integration/TTLSecondsAfterFinished-in-jobs/00-install.yaml b/test/integration/TTLSecondsAfterFinished-in-jobs/00-install.yaml index f62e61056fe..eec46d4b7da 100644 --- a/test/integration/TTLSecondsAfterFinished-in-jobs/00-install.yaml +++ b/test/integration/TTLSecondsAfterFinished-in-jobs/00-install.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnTaskDefinition metadata: name: ttlsecondsafterfinished-task @@ -13,7 +13,7 @@ spec: args: - 'hello world' --- -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnTask metadata: name: ttlsecondstask-job diff --git a/test/integration/api-conversion/00-assert.yaml b/test/integration/api-conversion/00-assert.yaml index 83e5f89855e..1d0bcfb5290 100644 --- a/test/integration/api-conversion/00-assert.yaml +++ b/test/integration/api-conversion/00-assert.yaml @@ -26,39 +26,6 @@ spec: - name: podtato-head-left-arm version: 0.2.7 --- -apiVersion: lifecycle.keptn.sh/v1alpha1 -kind: KeptnWorkloadInstance -metadata: - annotations: - traceparent: my-trace-parent - name: some-keptn-workload-instance-2 -spec: - app: podtato-head - resourceReference: - kind: ReplicaSet - name: my-replica-set - uid: 957f825e-4025-4ea8-ad22-9292877ff7eb - traceId: - traceparent: my-trace-parent - version: 0.2.7 - preDeploymentTasks: - - pre-deployment-task - preDeploymentEvaluations: - - pre-deployment-evaluation - postDeploymentTasks: - - post-deployment-task - postDeploymentEvaluations: - - post-deployment-evaluation - workloadName: some-keptn-workload-instance-2 ---- -apiVersion: lifecycle.keptn.sh/v1alpha1 -kind: KeptnEvaluationProvider -metadata: - name: some-evaluation-provider-2 -spec: - targetServer: http://my-server-url - secretName: my-secret-name ---- apiVersion: metrics.keptn.sh/v1beta1 kind: KeptnMetric metadata: diff --git a/test/integration/api-conversion/00-install.yaml b/test/integration/api-conversion/00-install.yaml index ae8b4b0a12d..05dfd9fab48 100644 --- a/test/integration/api-conversion/00-install.yaml +++ b/test/integration/api-conversion/00-install.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnApp metadata: name: "some-keptn-app2" @@ -6,7 +6,7 @@ spec: version: "1.2.3" revision: 123 --- -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnAppVersion metadata: name: "some-keptn-app-version-2" @@ -28,41 +28,6 @@ spec: - name: podtato-head-left-arm version: 0.2.7 --- -apiVersion: lifecycle.keptn.sh/v1alpha3 -kind: KeptnWorkloadInstance -metadata: - annotations: - traceparent: my-trace-parent - name: some-keptn-workload-instance-2 -spec: - app: podtato-head - resourceReference: - kind: ReplicaSet - name: my-replica-set - uid: 957f825e-4025-4ea8-ad22-9292877ff7eb - traceId: - traceparent: my-trace-parent - version: 0.2.7 - preDeploymentTasks: - - pre-deployment-task - preDeploymentEvaluations: - - pre-deployment-evaluation - postDeploymentTasks: - - post-deployment-task - postDeploymentEvaluations: - - post-deployment-evaluation - workloadName: some-keptn-workload-instance-2 ---- -apiVersion: lifecycle.keptn.sh/v1alpha3 -kind: KeptnEvaluationProvider -metadata: - name: some-evaluation-provider-2 -spec: - targetServer: http://my-server-url - secretKeyRef: - name: "my-secret-name" - key: "apiToken" ---- apiVersion: metrics.keptn.sh/v1beta1 kind: KeptnMetric metadata: diff --git a/test/integration/api-conversion/01-assert.yaml b/test/integration/api-conversion/01-assert.yaml index ff34e355186..e4852be3060 100644 --- a/test/integration/api-conversion/01-assert.yaml +++ b/test/integration/api-conversion/01-assert.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnApp metadata: name: "some-keptn-app1" @@ -6,7 +6,7 @@ spec: version: "1.2.3" revision: 1 --- -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnAppVersion metadata: name: "some-keptn-app-version-1" @@ -28,41 +28,6 @@ spec: - name: podtato-head-left-arm version: 0.2.7 --- -apiVersion: lifecycle.keptn.sh/v1alpha3 -kind: KeptnWorkloadInstance -metadata: - annotations: - traceparent: my-trace-parent - name: some-keptn-workload-instance-1 -spec: - app: podtato-head - resourceReference: - kind: ReplicaSet - name: my-replica-set - uid: 957f825e-4025-4ea8-ad22-9292877ff7eb - traceId: - traceparent: my-trace-parent - version: 0.2.7 - preDeploymentTasks: - - pre-deployment-task - preDeploymentEvaluations: - - pre-deployment-evaluation - postDeploymentTasks: - - post-deployment-task - postDeploymentEvaluations: - - post-deployment-evaluation - workloadName: some-keptn-workload-instance-1 ---- -apiVersion: lifecycle.keptn.sh/v1alpha3 -kind: KeptnEvaluationProvider -metadata: - name: some-evaluation-provider-1 -spec: - targetServer: http://my-server-url - secretKeyRef: - name: "my-secret-name" - key: "apiToken" ---- apiVersion: metrics.keptn.sh/v1beta1 kind: KeptnMetric metadata: @@ -73,7 +38,7 @@ spec: name: prometheus query: "sum(kube_pod_container_resource_limits{resource='cpu'})" --- -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnTask metadata: name: slack-deployment-notification diff --git a/test/integration/api-conversion/01-install.yaml b/test/integration/api-conversion/01-install.yaml index 8dc53949dc4..d6160e3575f 100644 --- a/test/integration/api-conversion/01-install.yaml +++ b/test/integration/api-conversion/01-install.yaml @@ -26,39 +26,6 @@ spec: - name: podtato-head-left-arm version: 0.2.7 --- -apiVersion: lifecycle.keptn.sh/v1alpha1 -kind: KeptnWorkloadInstance -metadata: - annotations: - traceparent: my-trace-parent - name: some-keptn-workload-instance-1 -spec: - app: podtato-head - resourceReference: - kind: ReplicaSet - name: my-replica-set - uid: 957f825e-4025-4ea8-ad22-9292877ff7eb - traceId: - traceparent: my-trace-parent - version: 0.2.7 - preDeploymentTasks: - - pre-deployment-task - preDeploymentEvaluations: - - pre-deployment-evaluation - postDeploymentTasks: - - post-deployment-task - postDeploymentEvaluations: - - post-deployment-evaluation - workloadName: some-keptn-workload-instance-1 ---- -apiVersion: lifecycle.keptn.sh/v1alpha1 -kind: KeptnEvaluationProvider -metadata: - name: some-evaluation-provider-1 -spec: - targetServer: http://my-server-url - secretName: my-secret-name ---- apiVersion: metrics.keptn.sh/v1beta1 kind: KeptnMetric metadata: diff --git a/test/integration/app-creation-request/00-assert.yaml b/test/integration/app-creation-request/00-assert.yaml index dc4ed63f296..2b8382e8222 100644 --- a/test/integration/app-creation-request/00-assert.yaml +++ b/test/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/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnApp metadata: name: my-app diff --git a/test/integration/app-creation-request/00-install.yaml b/test/integration/app-creation-request/00-install.yaml index f3efc8f0b32..c9d18a32e71 100644 --- a/test/integration/app-creation-request/00-install.yaml +++ b/test/integration/app-creation-request/00-install.yaml @@ -1,11 +1,11 @@ -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnAppCreationRequest metadata: name: my-kacr spec: appName: my-app --- -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnWorkload metadata: name: my-app-my-workload diff --git a/test/integration/app-creation-request/01-assert.yaml b/test/integration/app-creation-request/01-assert.yaml index 19526b60c4e..3e208d184d7 100644 --- a/test/integration/app-creation-request/01-assert.yaml +++ b/test/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/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnApp metadata: name: my-app diff --git a/test/integration/app-creation-request/01-install.yaml b/test/integration/app-creation-request/01-install.yaml index 967f80cb80a..e48e8fb7f4a 100644 --- a/test/integration/app-creation-request/01-install.yaml +++ b/test/integration/app-creation-request/01-install.yaml @@ -1,11 +1,11 @@ -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnAppCreationRequest metadata: name: my-kacr spec: appName: my-app --- -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 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/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnWorkload metadata: name: my-app-my-workload-2 diff --git a/test/integration/app-failing-post-evaluation/00-assert.yaml b/test/integration/app-failing-post-evaluation/00-assert.yaml index c7edff3a9a2..3dca4164ae8 100644 --- a/test/integration/app-failing-post-evaluation/00-assert.yaml +++ b/test/integration/app-failing-post-evaluation/00-assert.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnAppVersion metadata: name: podtato-head-1.3-6b86b273 diff --git a/test/integration/app-failing-post-evaluation/00-install.yaml b/test/integration/app-failing-post-evaluation/00-install.yaml index 0814d5a2538..6872cb2be89 100644 --- a/test/integration/app-failing-post-evaluation/00-install.yaml +++ b/test/integration/app-failing-post-evaluation/00-install.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnApp metadata: name: podtato-head @@ -40,7 +40,7 @@ spec: - name: PODTATO_PORT value: "9000" --- -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnEvaluationDefinition metadata: name: available-cpus diff --git a/test/integration/app-failing-post-task/00-assert.yaml b/test/integration/app-failing-post-task/00-assert.yaml index 1e2e3df53c7..91c25cf4683 100644 --- a/test/integration/app-failing-post-task/00-assert.yaml +++ b/test/integration/app-failing-post-task/00-assert.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnAppVersion metadata: name: podtato-head-1.3-6b86b273 diff --git a/test/integration/app-failing-post-task/00-install.yaml b/test/integration/app-failing-post-task/00-install.yaml index 34a1411f390..c9248723837 100644 --- a/test/integration/app-failing-post-task/00-install.yaml +++ b/test/integration/app-failing-post-task/00-install.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnApp metadata: name: podtato-head @@ -40,7 +40,7 @@ spec: - name: PODTATO_PORT value: "9000" --- -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnTaskDefinition metadata: name: failing-task diff --git a/test/integration/app-failing-pre-evaluation/00-assert.yaml b/test/integration/app-failing-pre-evaluation/00-assert.yaml index 43ff8ad7793..196c5fd7c34 100644 --- a/test/integration/app-failing-pre-evaluation/00-assert.yaml +++ b/test/integration/app-failing-pre-evaluation/00-assert.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnAppVersion metadata: name: podtato-head-1.3-6b86b273 diff --git a/test/integration/app-failing-pre-evaluation/00-install.yaml b/test/integration/app-failing-pre-evaluation/00-install.yaml index 0ec306f78cd..b79a79aba89 100644 --- a/test/integration/app-failing-pre-evaluation/00-install.yaml +++ b/test/integration/app-failing-pre-evaluation/00-install.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnApp metadata: name: podtato-head @@ -56,7 +56,7 @@ spec: targetPort: 9000 type: LoadBalancer --- -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnEvaluationDefinition metadata: name: available-cpus diff --git a/test/integration/app-failing-pre-task-retry/00-assert.yaml b/test/integration/app-failing-pre-task-retry/00-assert.yaml index 0e97da75cab..07b079fcbef 100644 --- a/test/integration/app-failing-pre-task-retry/00-assert.yaml +++ b/test/integration/app-failing-pre-task-retry/00-assert.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnAppVersion metadata: name: podtato-head-1.3-6b86b273 @@ -11,7 +11,7 @@ status: status: Failed workloadOverallStatus: Deprecated --- -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnTask spec: context: diff --git a/test/integration/app-failing-pre-task-retry/00-install.yaml b/test/integration/app-failing-pre-task-retry/00-install.yaml index 707de22c76e..7f6dd4a96c1 100644 --- a/test/integration/app-failing-pre-task-retry/00-install.yaml +++ b/test/integration/app-failing-pre-task-retry/00-install.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnApp metadata: name: podtato-head @@ -40,7 +40,7 @@ spec: - name: PODTATO_PORT value: "9000" --- -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnTaskDefinition metadata: name: pre-task-retries diff --git a/test/integration/app-failing-pre-task-timeout/00-assert.yaml b/test/integration/app-failing-pre-task-timeout/00-assert.yaml index cef4d70d072..598c08e2d19 100644 --- a/test/integration/app-failing-pre-task-timeout/00-assert.yaml +++ b/test/integration/app-failing-pre-task-timeout/00-assert.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnAppVersion metadata: name: podtato-head-1.3-6b86b273 @@ -11,7 +11,7 @@ status: status: Failed workloadOverallStatus: Deprecated --- -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnTask spec: context: diff --git a/test/integration/app-failing-pre-task-timeout/00-install.yaml b/test/integration/app-failing-pre-task-timeout/00-install.yaml index 9eaeb54279e..ca02231bce8 100644 --- a/test/integration/app-failing-pre-task-timeout/00-install.yaml +++ b/test/integration/app-failing-pre-task-timeout/00-install.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnApp metadata: name: podtato-head @@ -40,7 +40,7 @@ spec: - name: PODTATO_PORT value: "9000" --- -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnTaskDefinition metadata: name: pre-task-timeout diff --git a/test/integration/app-failing-pre-task/00-assert.yaml b/test/integration/app-failing-pre-task/00-assert.yaml index 32a36d1d969..67862e97758 100644 --- a/test/integration/app-failing-pre-task/00-assert.yaml +++ b/test/integration/app-failing-pre-task/00-assert.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnAppVersion metadata: name: podtato-head-1.3-6b86b273 diff --git a/test/integration/app-failing-pre-task/00-install.yaml b/test/integration/app-failing-pre-task/00-install.yaml index c6789f72a7e..08d633ff527 100644 --- a/test/integration/app-failing-pre-task/00-install.yaml +++ b/test/integration/app-failing-pre-task/00-install.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnApp metadata: name: podtato-head @@ -40,7 +40,7 @@ spec: - name: PODTATO_PORT value: "9000" --- -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnTaskDefinition metadata: name: check-entry-service diff --git a/test/integration/app-one-taskdefinition-not-found/00-assert.yaml b/test/integration/app-one-taskdefinition-not-found/00-assert.yaml index f9521c017d5..2bce287db08 100644 --- a/test/integration/app-one-taskdefinition-not-found/00-assert.yaml +++ b/test/integration/app-one-taskdefinition-not-found/00-assert.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnAppVersion metadata: name: podtato-head-1.3-6b86b273 @@ -11,7 +11,7 @@ status: status: Progressing workloadOverallStatus: Pending --- -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnTask spec: context: diff --git a/test/integration/app-one-taskdefinition-not-found/00-install.yaml b/test/integration/app-one-taskdefinition-not-found/00-install.yaml index 7cc21c5093a..ed3a9f32f6e 100644 --- a/test/integration/app-one-taskdefinition-not-found/00-install.yaml +++ b/test/integration/app-one-taskdefinition-not-found/00-install.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnApp metadata: name: podtato-head @@ -41,7 +41,7 @@ spec: - name: PODTATO_PORT value: "9000" --- -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnTaskDefinition metadata: name: pre-task-timeout diff --git a/test/integration/container-runtime/00-assert.yaml b/test/integration/container-runtime/00-assert.yaml index 9f21dc0091a..68b68255160 100644 --- a/test/integration/container-runtime/00-assert.yaml +++ b/test/integration/container-runtime/00-assert.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1alpha4 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnWorkloadVersion metadata: name: waiter-waiter-0.4 @@ -14,7 +14,7 @@ status: status: Succeeded status: Succeeded --- -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnTask metadata: annotations: diff --git a/test/integration/container-runtime/00-install.yaml b/test/integration/container-runtime/00-install.yaml index 9519eded72a..eecf740d64e 100644 --- a/test/integration/container-runtime/00-install.yaml +++ b/test/integration/container-runtime/00-install.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnTaskDefinition metadata: name: pre-deployment-sleep diff --git a/test/integration/imagepullsecret/00-assert.yaml b/test/integration/imagepullsecret/00-assert.yaml index 21f9cca9cac..e7389664436 100644 --- a/test/integration/imagepullsecret/00-assert.yaml +++ b/test/integration/imagepullsecret/00-assert.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1alpha4 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnWorkloadVersion metadata: name: waiter-waiter-0.4 @@ -14,7 +14,7 @@ status: status: Succeeded status: Succeeded --- -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnTask metadata: annotations: diff --git a/test/integration/imagepullsecret/00-install.yaml b/test/integration/imagepullsecret/00-install.yaml index 5f7db740046..d21b7677efa 100644 --- a/test/integration/imagepullsecret/00-install.yaml +++ b/test/integration/imagepullsecret/00-install.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnTaskDefinition metadata: name: pre-deployment-sleep diff --git a/test/integration/podtato-head-application-auto-app-discovery/00-assert.yaml b/test/integration/podtato-head-application-auto-app-discovery/00-assert.yaml index 29367967185..04761132e72 100644 --- a/test/integration/podtato-head-application-auto-app-discovery/00-assert.yaml +++ b/test/integration/podtato-head-application-auto-app-discovery/00-assert.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnApp metadata: name: podtato-head diff --git a/test/integration/podtato-head-application/00-assert.yaml b/test/integration/podtato-head-application/00-assert.yaml index 09ca6569368..fee18de8eb0 100644 --- a/test/integration/podtato-head-application/00-assert.yaml +++ b/test/integration/podtato-head-application/00-assert.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnAppVersion metadata: name: podtato-head-1.3-6b86b273 @@ -11,7 +11,7 @@ status: status: Succeeded workloadOverallStatus: Succeeded --- -apiVersion: lifecycle.keptn.sh/v1alpha4 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnWorkloadVersion metadata: name: podtato-head-podtato-head-entry-0.1.0 @@ -27,7 +27,7 @@ status: preDeploymentStatus: Succeeded status: Succeeded --- -apiVersion: lifecycle.keptn.sh/v1alpha4 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnWorkloadVersion metadata: name: podtato-head-podtato-head-hat-0.1.0 @@ -43,7 +43,7 @@ status: definitionName: check-entry-service status: Succeeded --- -apiVersion: lifecycle.keptn.sh/v1alpha4 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnWorkloadVersion metadata: name: podtato-head-podtato-head-left-arm-0.1.0 @@ -59,7 +59,7 @@ status: definitionName: check-entry-service status: Succeeded --- -apiVersion: lifecycle.keptn.sh/v1alpha4 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnWorkloadVersion metadata: name: podtato-head-podtato-head-left-leg-0.1.0 @@ -75,7 +75,7 @@ status: definitionName: check-entry-service status: Succeeded --- -apiVersion: lifecycle.keptn.sh/v1alpha4 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnWorkloadVersion metadata: name: podtato-head-podtato-head-right-arm-0.1.0 @@ -91,7 +91,7 @@ status: definitionName: check-entry-service status: Succeeded --- -apiVersion: lifecycle.keptn.sh/v1alpha4 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnWorkloadVersion metadata: name: podtato-head-podtato-head-right-leg-0.1.0 diff --git a/test/integration/podtato-head-application/00-install.yaml b/test/integration/podtato-head-application/00-install.yaml index eff55be2556..6a12eb37e2a 100644 --- a/test/integration/podtato-head-application/00-install.yaml +++ b/test/integration/podtato-head-application/00-install.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnApp metadata: name: podtato-head @@ -317,7 +317,7 @@ spec: targetPort: 9000 type: ClusterIP --- -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnTaskDefinition metadata: name: post-deployment-hello @@ -327,7 +327,7 @@ spec: code: | console.log("Post-Deployment Task has been executed"); --- -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnTaskDefinition metadata: name: pre-deployment-hello @@ -337,7 +337,7 @@ spec: code: | console.log("Pre-Deployment Task has been executed"); --- -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnTaskDefinition metadata: name: check-entry-service @@ -349,7 +349,7 @@ spec: map: url: http://podtato-head-entry:9000 --- -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnEvaluationDefinition metadata: name: available-cpus diff --git a/test/integration/restartable-app/00-assert.yaml b/test/integration/restartable-app/00-assert.yaml index f4163fec4f1..84e3dfae2c4 100644 --- a/test/integration/restartable-app/00-assert.yaml +++ b/test/integration/restartable-app/00-assert.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnAppVersion metadata: name: podtato-head-1.3-6b86b273 diff --git a/test/integration/restartable-app/00-install.yaml b/test/integration/restartable-app/00-install.yaml index a12319607ac..323aef6d426 100644 --- a/test/integration/restartable-app/00-install.yaml +++ b/test/integration/restartable-app/00-install.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnApp metadata: name: podtato-head @@ -310,7 +310,7 @@ spec: targetPort: 9000 type: ClusterIP --- -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnTaskDefinition metadata: name: post-deployment-hello @@ -320,7 +320,7 @@ spec: code: | console.log("Post-Deployment Task has been executed"); --- -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnTaskDefinition metadata: name: check-entry-service diff --git a/test/integration/restartable-app/01-assert.yaml b/test/integration/restartable-app/01-assert.yaml index 2816a72d3e8..b15c7d1a97f 100644 --- a/test/integration/restartable-app/01-assert.yaml +++ b/test/integration/restartable-app/01-assert.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnAppVersion metadata: name: podtato-head-1.3-d4735e3a @@ -11,7 +11,7 @@ status: status: Succeeded workloadOverallStatus: Succeeded --- -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnAppVersion metadata: name: podtato-head-1.3-6b86b273 @@ -24,7 +24,7 @@ status: status: Deprecated workloadOverallStatus: Deprecated --- -apiVersion: lifecycle.keptn.sh/v1alpha4 +apiVersion: lifecycle.keptn.sh/v1beta1 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/v1alpha4 +apiVersion: lifecycle.keptn.sh/v1beta1 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/v1alpha4 +apiVersion: lifecycle.keptn.sh/v1beta1 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/v1alpha4 +apiVersion: lifecycle.keptn.sh/v1beta1 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/v1alpha4 +apiVersion: lifecycle.keptn.sh/v1beta1 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/v1alpha4 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnWorkloadVersion metadata: name: podtato-head-podtato-head-right-leg-0.1.0 diff --git a/test/integration/restartable-app/01-install.yaml b/test/integration/restartable-app/01-install.yaml index 9c0f5216634..0046c16eb9c 100644 --- a/test/integration/restartable-app/01-install.yaml +++ b/test/integration/restartable-app/01-install.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnApp metadata: name: podtato-head diff --git a/test/integration/restartable-app/02-assert.yaml b/test/integration/restartable-app/02-assert.yaml index c78daac6736..fe7dc04199b 100644 --- a/test/integration/restartable-app/02-assert.yaml +++ b/test/integration/restartable-app/02-assert.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnAppVersion metadata: name: podtato-head-1.3-4e074085 @@ -11,7 +11,7 @@ status: status: Succeeded workloadOverallStatus: Succeeded --- -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnAppVersion metadata: name: podtato-head-1.3-d4735e3a @@ -24,7 +24,7 @@ status: status: Deprecated workloadOverallStatus: Deprecated --- -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnAppVersion metadata: name: podtato-head-1.3-6b86b273 @@ -37,7 +37,7 @@ status: status: Deprecated workloadOverallStatus: Deprecated --- -apiVersion: lifecycle.keptn.sh/v1alpha4 +apiVersion: lifecycle.keptn.sh/v1beta1 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/v1alpha4 +apiVersion: lifecycle.keptn.sh/v1beta1 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/v1alpha4 +apiVersion: lifecycle.keptn.sh/v1beta1 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/v1alpha4 +apiVersion: lifecycle.keptn.sh/v1beta1 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/v1alpha4 +apiVersion: lifecycle.keptn.sh/v1beta1 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/v1alpha4 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnWorkloadVersion metadata: name: podtato-head-podtato-head-right-leg-0.1.0 diff --git a/test/integration/restartable-app/02-install.yaml b/test/integration/restartable-app/02-install.yaml index e22f7cca9a3..c18806b05d0 100644 --- a/test/integration/restartable-app/02-install.yaml +++ b/test/integration/restartable-app/02-install.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnApp metadata: name: podtato-head diff --git a/test/integration/serviceaccount-in-jobs/00-install.yaml b/test/integration/serviceaccount-in-jobs/00-install.yaml index 1a1246962bc..36c15e69faf 100644 --- a/test/integration/serviceaccount-in-jobs/00-install.yaml +++ b/test/integration/serviceaccount-in-jobs/00-install.yaml @@ -4,7 +4,7 @@ metadata: name: keptn-serviceaccount automountServiceAccountToken: false --- -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnTaskDefinition metadata: name: task-serviceaccount @@ -21,7 +21,7 @@ spec: args: - 'hello world' --- -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnTask metadata: name: sendserviceaccount diff --git a/test/integration/simple-daemonset-annotated/00-install.yaml b/test/integration/simple-daemonset-annotated/00-install.yaml index 1a05bc950c2..c464a5106e7 100644 --- a/test/integration/simple-daemonset-annotated/00-install.yaml +++ b/test/integration/simple-daemonset-annotated/00-install.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnTaskDefinition metadata: name: pre-deployment-hello diff --git a/test/integration/simple-daemonset-annotated/01-assert.yaml b/test/integration/simple-daemonset-annotated/01-assert.yaml index 5fe5cde9c5c..330a72eb760 100644 --- a/test/integration/simple-daemonset-annotated/01-assert.yaml +++ b/test/integration/simple-daemonset-annotated/01-assert.yaml @@ -1,11 +1,11 @@ -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnWorkload metadata: name: work-work --- -apiVersion: lifecycle.keptn.sh/v1alpha4 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnWorkloadVersion metadata: name: work-work-0.4 diff --git a/test/integration/simple-daemonset-annotated/02-assert.yaml b/test/integration/simple-daemonset-annotated/02-assert.yaml index 186d406563b..6b729154eaa 100644 --- a/test/integration/simple-daemonset-annotated/02-assert.yaml +++ b/test/integration/simple-daemonset-annotated/02-assert.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1alpha4 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnWorkloadVersion metadata: name: work-work-0.5 diff --git a/test/integration/simple-deployment-annotated/00-install.yaml b/test/integration/simple-deployment-annotated/00-install.yaml index 76231e3a645..cde632aefe2 100644 --- a/test/integration/simple-deployment-annotated/00-install.yaml +++ b/test/integration/simple-deployment-annotated/00-install.yaml @@ -1,5 +1,5 @@ --- -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnTaskDefinition metadata: name: pre-deployment-hello diff --git a/test/integration/simple-deployment-annotated/01-assert.yaml b/test/integration/simple-deployment-annotated/01-assert.yaml index dee26a8df92..77aeb5deeb8 100644 --- a/test/integration/simple-deployment-annotated/01-assert.yaml +++ b/test/integration/simple-deployment-annotated/01-assert.yaml @@ -1,10 +1,10 @@ -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnWorkload metadata: name: waiter-waiter --- -apiVersion: lifecycle.keptn.sh/v1alpha4 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnWorkloadVersion metadata: name: waiter-waiter-0.4 diff --git a/test/integration/simple-deployment-container-annotation/00-assert.yaml b/test/integration/simple-deployment-container-annotation/00-assert.yaml index ac166f0c2e8..53c27ce37b9 100644 --- a/test/integration/simple-deployment-container-annotation/00-assert.yaml +++ b/test/integration/simple-deployment-container-annotation/00-assert.yaml @@ -1,9 +1,9 @@ -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnWorkload metadata: name: waiter-waiter --- -apiVersion: lifecycle.keptn.sh/v1alpha4 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnWorkloadVersion metadata: name: waiter-waiter-1.35 @@ -15,12 +15,12 @@ status: preDeploymentEvaluationStatus: Succeeded preDeploymentStatus: Succeeded --- -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnApp metadata: name: waiter --- -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnAppVersion metadata: name: waiter-1.35-6b86b273 diff --git a/test/integration/simple-deployment-container-annotation/01-assert.yaml b/test/integration/simple-deployment-container-annotation/01-assert.yaml index 79ce6c1b089..b2e539b6f2b 100644 --- a/test/integration/simple-deployment-container-annotation/01-assert.yaml +++ b/test/integration/simple-deployment-container-annotation/01-assert.yaml @@ -1,9 +1,9 @@ -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnWorkload metadata: name: waiter-waiter --- -apiVersion: lifecycle.keptn.sh/v1alpha4 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnWorkloadVersion metadata: name: waiter-waiter-1.36 @@ -15,12 +15,12 @@ status: preDeploymentEvaluationStatus: Succeeded preDeploymentStatus: Succeeded --- -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnApp metadata: name: waiter --- -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnAppVersion metadata: name: waiter-1.36-d4735e3a diff --git a/test/integration/simple-deployment-evaluation/00-install.yaml b/test/integration/simple-deployment-evaluation/00-install.yaml index 2f4836c23ea..7d067edff15 100644 --- a/test/integration/simple-deployment-evaluation/00-install.yaml +++ b/test/integration/simple-deployment-evaluation/00-install.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnEvaluationDefinition metadata: name: pre-deployment-hello diff --git a/test/integration/simple-deployment-evaluation/01-assert.yaml b/test/integration/simple-deployment-evaluation/01-assert.yaml index 96b416a134d..7eafbd2d833 100644 --- a/test/integration/simple-deployment-evaluation/01-assert.yaml +++ b/test/integration/simple-deployment-evaluation/01-assert.yaml @@ -1,11 +1,11 @@ -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnWorkload metadata: name: waiter-waiter --- -apiVersion: lifecycle.keptn.sh/v1alpha4 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnWorkloadVersion metadata: name: waiter-waiter-0.4 diff --git a/test/integration/simple-deployment-k8s-recommended-label/01-assert.yaml b/test/integration/simple-deployment-k8s-recommended-label/01-assert.yaml index e08b075053b..cf26786a9a8 100644 --- a/test/integration/simple-deployment-k8s-recommended-label/01-assert.yaml +++ b/test/integration/simple-deployment-k8s-recommended-label/01-assert.yaml @@ -1,9 +1,9 @@ -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnWorkload metadata: name: waiter-waiter --- -apiVersion: lifecycle.keptn.sh/v1alpha4 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnWorkloadVersion metadata: name: waiter-waiter-0.4 @@ -15,12 +15,12 @@ status: preDeploymentEvaluationStatus: Succeeded preDeploymentStatus: Succeeded --- -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnApp metadata: name: waiter --- -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnAppVersion metadata: name: waiter-0.4-6b86b273 diff --git a/test/integration/simple-deployment-python-runtime/00-assert.yaml b/test/integration/simple-deployment-python-runtime/00-assert.yaml index 1a76c5f665c..a4f8062c658 100644 --- a/test/integration/simple-deployment-python-runtime/00-assert.yaml +++ b/test/integration/simple-deployment-python-runtime/00-assert.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1alpha4 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnWorkloadVersion metadata: name: waiter-waiter-0.4 @@ -14,7 +14,7 @@ status: status: Succeeded status: Succeeded --- -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnTask metadata: annotations: diff --git a/test/integration/simple-deployment-python-runtime/00-install.yaml b/test/integration/simple-deployment-python-runtime/00-install.yaml index 8c481b48364..47e3eca9f05 100644 --- a/test/integration/simple-deployment-python-runtime/00-install.yaml +++ b/test/integration/simple-deployment-python-runtime/00-install.yaml @@ -6,7 +6,7 @@ type: Opaque data: SECURE_DATA: dG9rZW46IG15dG9rZW4= --- -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnTaskDefinition metadata: name: pre-deployment-hello diff --git a/test/integration/simple-deployment-recursive-task/00-install.yaml b/test/integration/simple-deployment-recursive-task/00-install.yaml index f08baa5dd69..e986138133a 100644 --- a/test/integration/simple-deployment-recursive-task/00-install.yaml +++ b/test/integration/simple-deployment-recursive-task/00-install.yaml @@ -6,7 +6,7 @@ type: Opaque data: SECURE_DATA: dG9rZW46IG15dG9rZW4= --- -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnTaskDefinition metadata: name: pre-deployment-hello @@ -21,7 +21,7 @@ spec: user: "myuser" data: "mydata" --- -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnTaskDefinition metadata: name: pre-deployment-parent diff --git a/test/integration/simple-deployment-recursive-task/01-assert.yaml b/test/integration/simple-deployment-recursive-task/01-assert.yaml index b64aaceec7b..12c869f3351 100644 --- a/test/integration/simple-deployment-recursive-task/01-assert.yaml +++ b/test/integration/simple-deployment-recursive-task/01-assert.yaml @@ -37,7 +37,7 @@ metadata: keptn.sh/version: "0.4" keptn.sh/workload: waiter-waiter ownerReferences: - - apiVersion: lifecycle.keptn.sh/v1alpha3 + - apiVersion: lifecycle.keptn.sh/v1beta1 blockOwnerDeletion: true controller: true kind: KeptnTask diff --git a/test/integration/simple-deployment-sanitize-version-number/00-install.yaml b/test/integration/simple-deployment-sanitize-version-number/00-install.yaml index b9a606d748a..316f7a6e4b7 100644 --- a/test/integration/simple-deployment-sanitize-version-number/00-install.yaml +++ b/test/integration/simple-deployment-sanitize-version-number/00-install.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnTaskDefinition metadata: name: pre-deployment-hello diff --git a/test/integration/simple-deployment-sanitize-version-number/01-assert.yaml b/test/integration/simple-deployment-sanitize-version-number/01-assert.yaml index 04ee546511c..b3cdef592e7 100644 --- a/test/integration/simple-deployment-sanitize-version-number/01-assert.yaml +++ b/test/integration/simple-deployment-sanitize-version-number/01-assert.yaml @@ -1,9 +1,9 @@ -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnWorkload metadata: name: waiter-waiter --- -apiVersion: lifecycle.keptn.sh/v1alpha4 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnWorkloadVersion metadata: name: waiter-waiter-0.4.0-1 @@ -21,12 +21,12 @@ status: - status: Succeeded definitionName: pre-deployment-hello --- -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnApp metadata: name: waiter --- -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnAppVersion metadata: name: waiter-0.4.0-1-6b86b273 diff --git a/test/integration/simple-deployment/00-install.yaml b/test/integration/simple-deployment/00-install.yaml index c96eff8c869..980242fc820 100644 --- a/test/integration/simple-deployment/00-install.yaml +++ b/test/integration/simple-deployment/00-install.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnTaskDefinition metadata: name: pre-deployment-hello diff --git a/test/integration/simple-deployment/01-assert.yaml b/test/integration/simple-deployment/01-assert.yaml index 8bd13063962..527d58401c5 100644 --- a/test/integration/simple-deployment/01-assert.yaml +++ b/test/integration/simple-deployment/01-assert.yaml @@ -1,9 +1,9 @@ -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnWorkload metadata: name: waiter-waiter --- -apiVersion: lifecycle.keptn.sh/v1alpha4 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnWorkloadVersion metadata: name: waiter-waiter-0.4 @@ -21,12 +21,12 @@ status: - status: Succeeded definitionName: pre-deployment-hello --- -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnApp metadata: name: waiter --- -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnAppVersion metadata: name: waiter-0.4-6b86b273 diff --git a/test/integration/simple-statefulset-annotated/00-install.yaml b/test/integration/simple-statefulset-annotated/00-install.yaml index 66e8cc0b1ff..389cc88f6a2 100644 --- a/test/integration/simple-statefulset-annotated/00-install.yaml +++ b/test/integration/simple-statefulset-annotated/00-install.yaml @@ -1,6 +1,6 @@ --- -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnTaskDefinition metadata: name: pre-deployment-hello diff --git a/test/integration/simple-statefulset-annotated/01-assert.yaml b/test/integration/simple-statefulset-annotated/01-assert.yaml index 5fe5cde9c5c..330a72eb760 100644 --- a/test/integration/simple-statefulset-annotated/01-assert.yaml +++ b/test/integration/simple-statefulset-annotated/01-assert.yaml @@ -1,11 +1,11 @@ -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnWorkload metadata: name: work-work --- -apiVersion: lifecycle.keptn.sh/v1alpha4 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnWorkloadVersion metadata: name: work-work-0.4 diff --git a/test/integration/simple-statefulset-annotated/02-assert.yaml b/test/integration/simple-statefulset-annotated/02-assert.yaml index 186d406563b..6b729154eaa 100644 --- a/test/integration/simple-statefulset-annotated/02-assert.yaml +++ b/test/integration/simple-statefulset-annotated/02-assert.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1alpha4 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnWorkloadVersion metadata: name: work-work-0.5 diff --git a/test/integration/simple-task/00-install.yaml b/test/integration/simple-task/00-install.yaml index e80694bf5b3..01ee26904c3 100644 --- a/test/integration/simple-task/00-install.yaml +++ b/test/integration/simple-task/00-install.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnTaskDefinition metadata: name: pre-deployment-hello @@ -8,7 +8,7 @@ spec: code: | console.log("Pre-Deployment Task has been executed"); --- -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnTask metadata: name: pre-deployment-hello-1234 diff --git a/test/integration/validate-taskdefinition/td_bad_container_deno.yaml b/test/integration/validate-taskdefinition/td_bad_container_deno.yaml index c2b7fe49624..59463793da4 100644 --- a/test/integration/validate-taskdefinition/td_bad_container_deno.yaml +++ b/test/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/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnTaskDefinition metadata: name: badtaskdefinition4 diff --git a/test/integration/validate-taskdefinition/td_bad_container_function.yaml b/test/integration/validate-taskdefinition/td_bad_container_function.yaml index b311e9c9fd9..1086bfe1073 100644 --- a/test/integration/validate-taskdefinition/td_bad_container_function.yaml +++ b/test/integration/validate-taskdefinition/td_bad_container_function.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/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnTaskDefinition metadata: name: badtaskdefinition1 diff --git a/test/integration/validate-taskdefinition/td_bad_container_python.yaml b/test/integration/validate-taskdefinition/td_bad_container_python.yaml index 7d3c4496a7a..fcab3d35c5c 100644 --- a/test/integration/validate-taskdefinition/td_bad_container_python.yaml +++ b/test/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/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnTaskDefinition metadata: name: badtaskdefinition3 diff --git a/test/integration/validate-taskdefinition/td_bad_empty.yaml b/test/integration/validate-taskdefinition/td_bad_empty.yaml index 825f609a306..817a573d538 100644 --- a/test/integration/validate-taskdefinition/td_bad_empty.yaml +++ b/test/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/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnTaskDefinition metadata: name: badtaskdefinition2 diff --git a/test/integration/validate-taskdefinition/td_bad_function_deno.yaml b/test/integration/validate-taskdefinition/td_bad_function_deno.yaml index faeb29eadb9..73efb0a6f10 100644 --- a/test/integration/validate-taskdefinition/td_bad_function_deno.yaml +++ b/test/integration/validate-taskdefinition/td_bad_function_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/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnTaskDefinition metadata: name: badtaskdefinition6 diff --git a/test/integration/validate-taskdefinition/td_bad_function_python.yaml b/test/integration/validate-taskdefinition/td_bad_function_python.yaml index 5fe710a2203..e7f2b696c2d 100644 --- a/test/integration/validate-taskdefinition/td_bad_function_python.yaml +++ b/test/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/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnTaskDefinition metadata: name: badtaskdefinition5 diff --git a/test/integration/validate-taskdefinition/td_bad_python_deno.yaml b/test/integration/validate-taskdefinition/td_bad_python_deno.yaml index 91bbda04285..94d4b89442a 100644 --- a/test/integration/validate-taskdefinition/td_bad_python_deno.yaml +++ b/test/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/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnTaskDefinition metadata: name: badtaskdefinition7 diff --git a/test/integration/validate-taskdefinition/td_good_container.yaml b/test/integration/validate-taskdefinition/td_good_container.yaml index 3c711f95596..dfdc597e22f 100644 --- a/test/integration/validate-taskdefinition/td_good_container.yaml +++ b/test/integration/validate-taskdefinition/td_good_container.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnTaskDefinition metadata: name: goodtaskdefinition1 diff --git a/test/integration/validate-taskdefinition/td_good_deno.yaml b/test/integration/validate-taskdefinition/td_good_deno.yaml index 1d9e592869e..1e88f735287 100644 --- a/test/integration/validate-taskdefinition/td_good_deno.yaml +++ b/test/integration/validate-taskdefinition/td_good_deno.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnTaskDefinition metadata: name: goodtaskdefinition4 diff --git a/test/integration/validate-taskdefinition/td_good_function.yaml b/test/integration/validate-taskdefinition/td_good_function.yaml index 1482887faa3..97f47e220d2 100644 --- a/test/integration/validate-taskdefinition/td_good_function.yaml +++ b/test/integration/validate-taskdefinition/td_good_function.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnTaskDefinition metadata: name: goodtaskdefinition2 diff --git a/test/integration/validate-taskdefinition/td_good_python.yaml b/test/integration/validate-taskdefinition/td_good_python.yaml index 19383bec890..5f5f88e178d 100644 --- a/test/integration/validate-taskdefinition/td_good_python.yaml +++ b/test/integration/validate-taskdefinition/td_good_python.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnTaskDefinition metadata: name: goodtaskdefinition3 diff --git a/test/integration/workload-instance-failing-pre-task/00-assert.yaml b/test/integration/workload-instance-failing-pre-task/00-assert.yaml index 35021722b91..889a3d4bdda 100644 --- a/test/integration/workload-instance-failing-pre-task/00-assert.yaml +++ b/test/integration/workload-instance-failing-pre-task/00-assert.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnAppVersion metadata: name: podtato-head-1.3-6b86b273 @@ -11,7 +11,7 @@ status: status: Progressing workloadOverallStatus: Progressing --- -apiVersion: lifecycle.keptn.sh/v1alpha4 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnWorkloadVersion metadata: name: podtato-head-podtato-head-entry-0.1.0 diff --git a/test/integration/workload-instance-failing-pre-task/00-install.yaml b/test/integration/workload-instance-failing-pre-task/00-install.yaml index 0a0fbcf724f..ae16c418324 100644 --- a/test/integration/workload-instance-failing-pre-task/00-install.yaml +++ b/test/integration/workload-instance-failing-pre-task/00-install.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnApp metadata: name: podtato-head @@ -10,7 +10,7 @@ spec: postDeploymentTasks: - post-deployment-hello --- -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnTaskDefinition metadata: name: check-entry-service diff --git a/test/integration/workload-instance-missing-evaluation/00-assert.yaml b/test/integration/workload-instance-missing-evaluation/00-assert.yaml index fc9abd3dda0..3420a52cb62 100644 --- a/test/integration/workload-instance-missing-evaluation/00-assert.yaml +++ b/test/integration/workload-instance-missing-evaluation/00-assert.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnAppVersion metadata: name: podtato-head-1.3-6b86b273 @@ -11,7 +11,7 @@ status: status: Progressing workloadOverallStatus: Progressing --- -apiVersion: lifecycle.keptn.sh/v1alpha4 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnWorkloadVersion metadata: name: podtato-head-podtato-head-entry-0.1.0 diff --git a/test/integration/workload-instance-missing-evaluation/00-install.yaml b/test/integration/workload-instance-missing-evaluation/00-install.yaml index 815e00ba67c..caf620bede7 100644 --- a/test/integration/workload-instance-missing-evaluation/00-install.yaml +++ b/test/integration/workload-instance-missing-evaluation/00-install.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnApp metadata: name: podtato-head diff --git a/test/scheduling-gates/simple-deployment/00-install.yaml b/test/scheduling-gates/simple-deployment/00-install.yaml index c96eff8c869..980242fc820 100644 --- a/test/scheduling-gates/simple-deployment/00-install.yaml +++ b/test/scheduling-gates/simple-deployment/00-install.yaml @@ -1,4 +1,4 @@ -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnTaskDefinition metadata: name: pre-deployment-hello diff --git a/test/scheduling-gates/simple-deployment/01-assert.yaml b/test/scheduling-gates/simple-deployment/01-assert.yaml index 8bd13063962..527d58401c5 100644 --- a/test/scheduling-gates/simple-deployment/01-assert.yaml +++ b/test/scheduling-gates/simple-deployment/01-assert.yaml @@ -1,9 +1,9 @@ -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnWorkload metadata: name: waiter-waiter --- -apiVersion: lifecycle.keptn.sh/v1alpha4 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnWorkloadVersion metadata: name: waiter-waiter-0.4 @@ -21,12 +21,12 @@ status: - status: Succeeded definitionName: pre-deployment-hello --- -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnApp metadata: name: waiter --- -apiVersion: lifecycle.keptn.sh/v1alpha3 +apiVersion: lifecycle.keptn.sh/v1beta1 kind: KeptnAppVersion metadata: name: waiter-0.4-6b86b273