Skip to content

Commit

Permalink
feat: Add dynamic pipeline name for CodebaseBranch (#112)
Browse files Browse the repository at this point in the history
  • Loading branch information
zmotso committed Aug 13, 2024
1 parent 11da5e9 commit 0874477
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 2 deletions.
8 changes: 6 additions & 2 deletions api/v1/codebasebranch_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ const (
CodebaseBranchGitStatusBranchCreated = "branch-created"
)

// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.

// CodebaseBranchSpec defines the desired state of CodebaseBranch.
type CodebaseBranchSpec struct {
// Name of Codebase associated with.
Expand All @@ -31,6 +29,12 @@ type CodebaseBranchSpec struct {
// +nullable
// +optional
ReleaseJobParams map[string]string `json:"releaseJobParams,omitempty"`

// Pipelines is a map of pipelines related to the branch.
// +nullable
// +optional
// +kubebuilder:example:={"review": "review-pipeline", "build": "build-pipeline"}
Pipelines map[string]string `json:"pipelines,omitempty"`
}

// CodebaseBranchStatus defines the observed state of CodebaseBranch.
Expand Down
7 changes: 7 additions & 0 deletions api/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions config/crd/bases/v2.edp.epam.com_codebasebranches.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,15 @@ spec:
description: The new branch will be created starting from the selected
commit hash.
type: string
pipelines:
additionalProperties:
type: string
description: Pipelines is a map of pipelines related to the branch.
example:
build: build-pipeline
review: review-pipeline
nullable: true
type: object
release:
description: Flag if branch is used as "release" branch.
type: boolean
Expand Down
13 changes: 13 additions & 0 deletions controllers/codebasebranch/codebasebranch_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,19 @@ func (r *ReconcileCodebaseBranch) setOwnerRef(cb *codebaseApi.CodebaseBranch, c
return nil
}

func (r *ReconcileCodebaseBranch) setDefaultValues(cb *codebaseApi.CodebaseBranch) (error, bool) {
//changed := false
//if cb.Spec.Pipelines == nil {
// cb.Spec.Pipelines = make(map[string]string, 2)
//}
//
//if _, ok := cb.Spec.Pipelines["review"]; !ok {
//
//}

return nil, false
}

func setErrorStatus(metadata *codebaseApi.CodebaseBranch, msg string) {
metadata.Status.Status = errorStatus
metadata.Status.DetailedMessage = msg
Expand Down
9 changes: 9 additions & 0 deletions deploy-templates/crds/v2.edp.epam.com_codebasebranches.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,15 @@ spec:
description: The new branch will be created starting from the selected
commit hash.
type: string
pipelines:
additionalProperties:
type: string
description: Pipelines is a map of pipelines related to the branch.
example:
build: build-pipeline
review: review-pipeline
nullable: true
type: object
release:
description: Flag if branch is used as "release" branch.
type: boolean
Expand Down

0 comments on commit 0874477

Please sign in to comment.