From f040b62b2f2d2649b3b5675c8011780632a7739c Mon Sep 17 00:00:00 2001 From: Zorian Motso Date: Tue, 14 Jan 2025 12:58:48 +0200 Subject: [PATCH] feat: Add Description property to CDPipeline (#104) --- api/v1/cdpipeline_types.go | 7 +++++-- config/crd/bases/v2.edp.epam.com_cdpipelines.yaml | 4 ++++ deploy-templates/crds/v2.edp.epam.com_cdpipelines.yaml | 4 ++++ docs/api.md | 7 +++++++ pkg/webhook/stage_webhook.go | 4 ++-- pkg/webhook/stage_webhook_test.go | 4 ++-- .../capsule-feature/03-assert-cdpipeline-and-stages.yaml | 1 + .../capsule-feature/03-create-cdpipeline-and-stages.yaml | 1 + 8 files changed, 26 insertions(+), 6 deletions(-) diff --git a/api/v1/cdpipeline_types.go b/api/v1/cdpipeline_types.go index f078d59..3a0124e 100644 --- a/api/v1/cdpipeline_types.go +++ b/api/v1/cdpipeline_types.go @@ -4,8 +4,6 @@ import ( metaV1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) -// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. - // CDPipelineSpec defines the desired state of CDPipeline. type CDPipelineSpec struct { // +kubebuilder:validation:MinLength=2 @@ -13,6 +11,11 @@ type CDPipelineSpec struct { // Name of CD pipeline Name string `json:"name"` + // Description of CD pipeline. + // +optional + // +kubebuilder:example="This is a CD pipeline for deploying applications" + Description string `json:"description,omitempty"` + // Type of workload to be deployed, e.g., container, custom. // +kubebuilder:default="container" DeploymentType string `json:"deploymentType"` diff --git a/config/crd/bases/v2.edp.epam.com_cdpipelines.yaml b/config/crd/bases/v2.edp.epam.com_cdpipelines.yaml index 1c48f54..2190c65 100644 --- a/config/crd/bases/v2.edp.epam.com_cdpipelines.yaml +++ b/config/crd/bases/v2.edp.epam.com_cdpipelines.yaml @@ -66,6 +66,10 @@ spec: default: container description: Type of workload to be deployed, e.g., container, custom. type: string + description: + description: Description of CD pipeline. + example: This is a CD pipeline for deploying applications + type: string inputDockerStreams: description: A list of docker streams items: diff --git a/deploy-templates/crds/v2.edp.epam.com_cdpipelines.yaml b/deploy-templates/crds/v2.edp.epam.com_cdpipelines.yaml index 1c48f54..2190c65 100644 --- a/deploy-templates/crds/v2.edp.epam.com_cdpipelines.yaml +++ b/deploy-templates/crds/v2.edp.epam.com_cdpipelines.yaml @@ -66,6 +66,10 @@ spec: default: container description: Type of workload to be deployed, e.g., container, custom. type: string + description: + description: Description of CD pipeline. + example: This is a CD pipeline for deploying applications + type: string inputDockerStreams: description: A list of docker streams items: diff --git a/docs/api.md b/docs/api.md index 4f9f199..b76183f 100644 --- a/docs/api.md +++ b/docs/api.md @@ -122,6 +122,13 @@ CDPipelineSpec defines the desired state of CDPipeline. A list of applications which will promote after successful release.
false + + description + string + + Description of CD pipeline.
+ + false diff --git a/pkg/webhook/stage_webhook.go b/pkg/webhook/stage_webhook.go index b6691e3..24df0f3 100644 --- a/pkg/webhook/stage_webhook.go +++ b/pkg/webhook/stage_webhook.go @@ -4,15 +4,15 @@ import ( "context" "errors" "fmt" - "github.com/epam/edp-cd-pipeline-operator/v2/controllers/stage/chain/util" - corev1 "k8s.io/api/core/v1" + corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/runtime" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/webhook" pipelineApi "github.com/epam/edp-cd-pipeline-operator/v2/api/v1" + "github.com/epam/edp-cd-pipeline-operator/v2/controllers/stage/chain/util" ) const listLimit = 1000 diff --git a/pkg/webhook/stage_webhook_test.go b/pkg/webhook/stage_webhook_test.go index 6f43286..fbdb9c8 100644 --- a/pkg/webhook/stage_webhook_test.go +++ b/pkg/webhook/stage_webhook_test.go @@ -2,18 +2,18 @@ package webhook import ( "context" - "github.com/epam/edp-cd-pipeline-operator/v2/controllers/stage/chain/util" - corev1 "k8s.io/api/core/v1" "testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + corev1 "k8s.io/api/core/v1" metaV1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" pipelineApi "github.com/epam/edp-cd-pipeline-operator/v2/api/v1" + "github.com/epam/edp-cd-pipeline-operator/v2/controllers/stage/chain/util" codebaseApi "github.com/epam/edp-codebase-operator/v2/api/v1" ) diff --git a/tests/e2e/capsule-feature/03-assert-cdpipeline-and-stages.yaml b/tests/e2e/capsule-feature/03-assert-cdpipeline-and-stages.yaml index f6f558f..24f33cb 100644 --- a/tests/e2e/capsule-feature/03-assert-cdpipeline-and-stages.yaml +++ b/tests/e2e/capsule-feature/03-assert-cdpipeline-and-stages.yaml @@ -16,6 +16,7 @@ spec: inputDockerStreams: - test-main name: mypipeline + description: mypipeline description --- apiVersion: v2.edp.epam.com/v1 diff --git a/tests/e2e/capsule-feature/03-create-cdpipeline-and-stages.yaml b/tests/e2e/capsule-feature/03-create-cdpipeline-and-stages.yaml index e0b1ca0..58726e3 100644 --- a/tests/e2e/capsule-feature/03-create-cdpipeline-and-stages.yaml +++ b/tests/e2e/capsule-feature/03-create-cdpipeline-and-stages.yaml @@ -11,6 +11,7 @@ spec: inputDockerStreams: - test-main name: mypipeline + description: mypipeline description --- apiVersion: v2.edp.epam.com/v1