Skip to content

Commit

Permalink
feat: Enable configuration to disable pipeline by codebses (#365)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mykola Serdiuk authored and MykolaMarusenko committed Nov 21, 2024
1 parent 9f639fa commit b20963c
Show file tree
Hide file tree
Showing 421 changed files with 2,408 additions and 1,891 deletions.
4 changes: 4 additions & 0 deletions charts/pipelines-library/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ Follows [Tekton Interceptor](https://tekton.dev/vault/triggers-main/clusterinter
| kaniko.image.tag | string | `"v1.12.1"` | |
| kaniko.roleArn | string | `""` | AWS IAM role to be used for kaniko pod service account (IRSA). Format: arn:aws:iam::<AWS_ACCOUNT_ID>:role/<AWS_IAM_ROLE_NAME> |
| nameOverride | string | `""` | |
| pipelines.deployableResources | object | `{"c":{"cmake":true,"make":true},"cs":{"dotnet3.1":false,"dotnet6.0":false},"deploy":true,"docker":true,"go":{"beego":true,"gin":true,"operatorsdk":true},"groovy":true,"helm":true,"helm-pipeline":true,"infrastructure":true,"java":{"java11":true,"java17":true,"java8":false},"js":{"angular":true,"antora":true,"express":true,"next":true,"react":true,"vue":true},"opa":false,"python":{"ansible":true,"fastapi":true,"flask":true,"python3.8":false},"tasks":true,"terraform":true}` | This section contains the list of pipelines and tasks that will be installed. |
| pipelines.deployableResources.c | object | `{"cmake":true,"make":true}` | This section control the installation of the review and build pipelines. |
| pipelines.deployableResources.deploy | bool | `true` | This flag control the installation of the Deploy pipelines. |
| pipelines.deployableResources.tasks | bool | `true` | This flag control the installation of the tasks. |
| pipelines.image.registry | string | `"docker.io"` | Registry for tekton pipelines images. Default: docker.io |
| tekton-cache.enabled | bool | `true` | Enables the Tekton-cache subchart. |
| tekton-cache.url | string | `"http://tekton-cache:8080"` | Defines the URL to the tekton-cache. Default: http://tekton-cache:8080 |
Expand Down
141 changes: 141 additions & 0 deletions charts/pipelines-library/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,144 @@ Define registry for pipelines images
{{- define "edp-tekton.registry" -}}
{{- .Values.pipelines.image.registry -}}
{{- end -}}

# Mapping for Java Maven (application and library) pipeliens
{{- define "edp-tekton.resourceMapping.maven" -}}
{{- $registry := .Values.pipelines.image.registry -}}
{{- $mavenVersions := dict -}}
{{- with .Values.pipelines.deployableResources.java -}}
{{- if .java8 }}
{{- $mavenVersions = set $mavenVersions "java8" (printf "%s/maven:3.9.0-eclipse-temurin-8" $registry) }}
{{- end }}
{{- if .java11 }}
{{- $mavenVersions = set $mavenVersions "java11" (printf "%s/maven:3.9.0-eclipse-temurin-11" $registry) }}
{{- end }}
{{- if .java17 }}
{{- $mavenVersions = set $mavenVersions "java17" (printf "%s/maven:3.9.0-eclipse-temurin-17" $registry) }}
{{- end }}
{{- end }}
{{- $mavenVersions | toYaml -}}
{{- end }}

{{- define "edp-tekton.resourceMapping.mavenSonar" -}}
{{- $registry := .Values.pipelines.image.registry -}}
{{- $sonarVersions := dict -}}
{{- with .Values.pipelines.deployableResources.java -}}
{{- if .java8 }}
{{- $sonarVersions = set $sonarVersions "java8" (printf "%s/maven:3.9.0-eclipse-temurin-11" $registry) }}
{{- end }}
{{- if .java11 }}
{{- $sonarVersions = set $sonarVersions "java11" (printf "%s/maven:3.9.0-eclipse-temurin-11" $registry) }}
{{- end }}
{{- if .java17 }}
{{- $sonarVersions = set $sonarVersions "java17" (printf "%s/maven:3.9.0-eclipse-temurin-17" $registry) }}
{{- end }}
{{- end }}
{{- $sonarVersions | toYaml -}}
{{- end }}

# Mapping for Java Gradle (application and library) pipeliens
{{- define "edp-tekton.resourceMapping.gradle" -}}
{{- $registry := .Values.pipelines.image.registry -}}
{{- $gradleVersions := dict -}}
{{- with .Values.pipelines.deployableResources.java -}}
{{- if .java8 }}
{{- $gradleVersions = set $gradleVersions "java8" (printf "%s/gradle:7.5.1-jdk8" $registry) }}
{{- end }}
{{- if .java11 }}
{{- $gradleVersions = set $gradleVersions "java11" (printf "%s/gradle:7.5.1-jdk11" $registry) }}
{{- end }}
{{- if .java17 }}
{{- $gradleVersions = set $gradleVersions "java17" (printf "%s/gradle:7.5.1-jdk17" $registry) }}
{{- end }}
{{- end }}
{{- $gradleVersions | toYaml -}}
{{- end }}

{{- define "edp-tekton.resourceMapping.gradleSonar" -}}
{{- $registry := .Values.pipelines.image.registry -}}
{{- $sonarVersions := dict -}}
{{- with .Values.pipelines.deployableResources.java -}}
{{- if .java8 }}
{{- $sonarVersions = set $sonarVersions "java8" (printf "%s/gradle:7.5.1-jdk11" $registry) }}
{{- end }}
{{- if .java11 }}
{{- $sonarVersions = set $sonarVersions "java11" (printf "%sgradle:7.5.1-jdk11" $registry) }}
{{- end }}
{{- if .java17 }}
{{- $sonarVersions = set $sonarVersions "java17" (printf "%s/gradle:7.5.1-jdk17" $registry) }}
{{- end }}
{{- end }}
{{- $sonarVersions | toYaml -}}
{{- end }}


# Mapping for Go pipelines
{{- define "edp-tekton.resourceMapping.go" -}}
{{- $go := list -}}
{{- with .Values.pipelines.deployableResources.go -}}
{{- if .beego }}
{{- $go = append $go "beego" }}
{{- end }}
{{- if .gin }}
{{- $go = append $go "gin" }}
{{- end }}
{{- if .operatorsdk }}
{{- $go = append $go "operator-sdk" }}
{{- end }}
{{- end }}
{{- $go -}}
{{- end }}

# Mapping for JS pipelines
{{- define "edp-tekton.resourceMapping.js" -}}
{{- $js := list -}}
{{- with .Values.pipelines.deployableResources.js -}}
{{- if .vue }}
{{- $js = append $js "vue" }}
{{- end }}
{{- if .angular }}
{{- $js = append $js "angular" }}
{{- end }}
{{- if .express }}
{{- $js = append $js "express" }}
{{- end }}
{{- if .next }}
{{- $js = append $js "next" }}
{{- end }}
{{- if .react }}
{{- $js = append $js "react" }}
{{- end }}
{{- end }}
{{- $js -}}
{{- end }}

# Mapping for Pyhton pipelines
{{- define "edp-tekton.resourceMapping.python" -}}
{{- $python := list -}}
{{- with .Values.pipelines.deployableResources.python -}}
{{- if .fastapi }}
{{- $python = append $python "fastapi" }}
{{- end }}
{{- if .flask }}
{{- $python = append $python "flask" }}
{{- end }}
{{- end }}
{{- $python -}}
{{- end }}


# Mapping for Csharp pipeliens
{{- define "edp-tekton.resourceMapping.cs" -}}
{{- $registry := .Values.pipelines.image.registry -}}
{{- $csVersions := dict -}}
{{- with .Values.pipelines.deployableResources.cs -}}
{{- if (index . "dotnet3.1" )}}
{{- $csVersions = set $csVersions "dotnet-3.1" "mcr.microsoft.com/dotnet/sdk:3.1.423-alpine3.16" }}
{{- end }}
{{- if (index . "dotnet6.0" ) }}
{{- $csVersions = set $csVersions "dotnet-6.0" "mcr.microsoft.com/dotnet/sdk:6.0.407-alpine3.17" }}
{{- end }}
{{- end }}
{{- $csVersions | toYaml -}}
{{- end }}
Original file line number Diff line number Diff line change
@@ -1,26 +1,18 @@
{{ if has "bitbucket" .Values.global.gitProviders }}
{{- $registry := include "edp-tekton.registry" . -}}
{{- $resourceMapping := dict
"java8" (printf "%s/gradle:7.5.1-jdk8" $registry)
"java11" (printf "%s/gradle:7.5.1-jdk11" $registry)
"java17" (printf "%s/gradle:7.5.1-jdk17" $registry)
-}}
{{- $altResourceMapping := dict
"java8" (printf "%s/gradle:7.5.1-jdk11" $registry)
"java11" (printf "%s/gradle:7.5.1-jdk11" $registry)
"java17" (printf "%s/gradle:7.5.1-jdk17" $registry)
-}}
{{- range $k, $v := $resourceMapping }}
{{- $valueFromAlt := pluck $k $altResourceMapping | first -}}
{{ if or ( .Values.pipelines.deployableResources.java.java8 ) ( .Values.pipelines.deployableResources.java.java11 ) ( .Values.pipelines.deployableResources.java.java17 )}}
{{- $raw := include "edp-tekton.resourceMapping.maven" . | fromYaml -}}
{{- $rawSonar := include "edp-tekton.resourceMapping.mavenSonar" . | fromYaml -}}
{{- range $framework, $image := $raw }}
{{- $sonarImage := pluck $framework $rawSonar | first -}}
apiVersion: tekton.dev/v1
kind: Pipeline
metadata:
name: bitbucket-gradle-{{ $k }}-aut-build-default
name: bitbucket-gradle-{{ $framework }}-aut-build-default
labels:
app.edp.epam.com/pipelinetype: build
{{- include "edp-tekton.labels" $ | nindent 4 }}
spec:
description: "The Build pipeline for building {{ $k }} automation tests with Gradle (default version)"
description: "The Build pipeline for building {{ $framework }} automation tests with Gradle (default version)"
workspaces:
- name: shared-workspace
- name: ssh-creds
Expand All @@ -34,19 +26,19 @@ spec:
default: "edp"
type: string
- name: CODEBASE_NAME
default: '{{ $k }}-gradle'
default: '{{ $framework }}-gradle'
description: "Project name"
type: string
- name: changeNumber
description: Change number from Merge Request
default: ""
type: string
- name: image
default: '{{ $v }}'
default: '{{ $image }}'
description: "gradle image version"
type: string
- name: sonar_image
default: '{{ $valueFromAlt }}'
default: '{{ $sonarImage }}'
description: "sonar image version"
type: string

Expand Down Expand Up @@ -135,3 +127,4 @@ spec:
---
{{ end }}
{{ end }}
{{ end }}
Original file line number Diff line number Diff line change
@@ -1,26 +1,18 @@
{{ if has "bitbucket" .Values.global.gitProviders }}
{{- $registry := include "edp-tekton.registry" . -}}
{{- $resourceMapping := dict
"java8" (printf "%s/gradle:7.5.1-jdk8" $registry)
"java11" (printf "%s/gradle:7.5.1-jdk11" $registry)
"java17" (printf "%s/gradle:7.5.1-jdk17" $registry)
-}}
{{- $altResourceMapping := dict
"java8" (printf "%s/gradle:7.5.1-jdk11" $registry)
"java11" (printf "%s/gradle:7.5.1-jdk11" $registry)
"java17" (printf "%s/gradle:7.5.1-jdk17" $registry)
-}}
{{- range $k, $v := $resourceMapping }}
{{- $valueFromAlt := pluck $k $altResourceMapping | first -}}
{{ if or ( .Values.pipelines.deployableResources.java.java8 ) ( .Values.pipelines.deployableResources.java.java11 ) ( .Values.pipelines.deployableResources.java.java17 )}}
{{- $raw := include "edp-tekton.resourceMapping.maven" . | fromYaml -}}
{{- $rawSonar := include "edp-tekton.resourceMapping.mavenSonar" . | fromYaml -}}
{{- range $framework, $image := $raw }}
{{- $sonarImage := pluck $framework $rawSonar | first -}}
apiVersion: tekton.dev/v1
kind: Pipeline
metadata:
name: bitbucket-gradle-{{ $k }}-aut-build-edp
name: bitbucket-gradle-{{ $framework }}-aut-build-edp
labels:
app.edp.epam.com/pipelinetype: build
{{- include "edp-tekton.labels" $ | nindent 4 }}
spec:
description: "The Build pipeline for building {{ $k }} automation tests with Gradle (EDP version)"
description: "The Build pipeline for building {{ $framework }} automation tests with Gradle (EDP version)"
workspaces:
- name: shared-workspace
- name: ssh-creds
Expand All @@ -34,7 +26,7 @@ spec:
default: "edp"
type: string
- name: CODEBASE_NAME
default: '{{ $k }}-gradle'
default: '{{ $framework }}-gradle'
description: "Project name"
type: string
- name: CODEBASEBRANCH_NAME
Expand All @@ -45,7 +37,7 @@ spec:
default: ""
type: string
- name: sonar_image
default: '{{ $valueFromAlt }}'
default: '{{ $sonarImage }}'
description: "sonar image version"
type: string

Expand Down Expand Up @@ -116,3 +108,4 @@ spec:
---
{{ end }}
{{ end }}
{{ end }}
Original file line number Diff line number Diff line change
@@ -1,26 +1,18 @@
{{ if has "bitbucket" .Values.global.gitProviders }}
{{- $registry := include "edp-tekton.registry" . -}}
{{- $resourceMapping := dict
"java8" (printf "%s/gradle:7.5.1-jdk8" $registry)
"java11" (printf "%s/gradle:7.5.1-jdk11" $registry)
"java17" (printf "%s/gradle:7.5.1-jdk17" $registry)
-}}
{{- $altResourceMapping := dict
"java8" (printf "%s/gradle:7.5.1-jdk11" $registry)
"java11" (printf "%s/gradle:7.5.1-jdk11" $registry)
"java17" (printf "%s/gradle:7.5.1-jdk17" $registry)
-}}
{{- range $k, $v := $resourceMapping }}
{{- $valueFromAlt := pluck $k $altResourceMapping | first -}}
{{ if or ( .Values.pipelines.deployableResources.java.java8 ) ( .Values.pipelines.deployableResources.java.java11 ) ( .Values.pipelines.deployableResources.java.java17 )}}
{{- $raw := include "edp-tekton.resourceMapping.maven" . | fromYaml -}}
{{- $rawSonar := include "edp-tekton.resourceMapping.mavenSonar" . | fromYaml -}}
{{- range $framework, $image := $raw }}
{{- $sonarImage := pluck $framework $rawSonar | first -}}
apiVersion: tekton.dev/v1
kind: Pipeline
metadata:
name: bitbucket-gradle-{{ $k }}-aut-review
name: bitbucket-gradle-{{ $framework }}-aut-review
labels:
app.edp.epam.com/pipelinetype: review
{{- include "edp-tekton.labels" $ | nindent 4 }}
spec:
description: "The Review pipeline for building {{ $k }} automation tests with Gradle"
description: "The Review pipeline for building {{ $framework }} automation tests with Gradle"
workspaces:
- name: shared-workspace
- name: ssh-creds
Expand All @@ -45,18 +37,18 @@ spec:
- name: changeNumber
description: Change number from Merge Request
- name: CODEBASE_NAME
default: '{{ $k }}-gradle'
default: '{{ $framework }}-gradle'
description: "Project name"
type: string
- name: CODEBASEBRANCH_NAME
description: "Codebasebranch name"
type: string
- name: image
default: '{{ $v }}'
default: '{{ $image }}'
description: "gradle image version"
type: string
- name: sonar_image
default: '{{ $valueFromAlt }}'
default: '{{ $sonarImage }}'
description: "sonar image version"
type: string
- name: gitfullrepositoryname
Expand Down Expand Up @@ -99,3 +91,4 @@ spec:
---
{{ end }}
{{ end }}
{{ end }}
Original file line number Diff line number Diff line change
@@ -1,26 +1,18 @@
{{ if has "gerrit" .Values.global.gitProviders }}
{{- $registry := include "edp-tekton.registry" . -}}
{{- $resourceMapping := dict
"java8" (printf "%s/gradle:7.5.1-jdk8" $registry)
"java11" (printf "%s/gradle:7.5.1-jdk11" $registry)
"java17" (printf "%s/gradle:7.5.1-jdk17" $registry)
-}}
{{- $altResourceMapping := dict
"java8" (printf "%s/gradle:7.5.1-jdk11" $registry)
"java11" (printf "%s/gradle:7.5.1-jdk11" $registry)
"java17" (printf "%s/gradle:7.5.1-jdk17" $registry)
-}}
{{- range $k, $v := $resourceMapping }}
{{- $valueFromAlt := pluck $k $altResourceMapping | first -}}
{{ if or ( .Values.pipelines.deployableResources.java.java8 ) ( .Values.pipelines.deployableResources.java.java11 ) ( .Values.pipelines.deployableResources.java.java17 )}}
{{- $raw := include "edp-tekton.resourceMapping.maven" . | fromYaml -}}
{{- $rawSonar := include "edp-tekton.resourceMapping.mavenSonar" . | fromYaml -}}
{{- range $framework, $image := $raw }}
{{- $sonarImage := pluck $framework $rawSonar | first -}}
apiVersion: tekton.dev/v1
kind: Pipeline
metadata:
name: gerrit-gradle-{{ $k }}-aut-build-default
name: gerrit-gradle-{{ $framework }}-aut-build-default
labels:
app.edp.epam.com/pipelinetype: build
{{- include "edp-tekton.labels" $ | nindent 4 }}
spec:
description: "The Build pipeline for building {{ $k }} automation tests with Gradle (default versioning)"
description: "The Build pipeline for building {{ $framework }} automation tests with Gradle (default versioning)"

workspaces:
- name: shared-workspace
Expand All @@ -39,15 +31,15 @@ spec:
default: "edp"
type: string
- name: CODEBASE_NAME
default: '{{ $k }}-gradle'
default: '{{ $framework }}-gradle'
description: "Project name"
type: string
- name: image
default: '{{ $v }}'
default: '{{ $image }}'
description: "gradle image version"
type: string
- name: sonar_image
default: '{{ $valueFromAlt }}'
default: '{{ $sonarImage }}'
description: "sonar image version"
type: string
- name: changeNumber
Expand Down Expand Up @@ -140,3 +132,4 @@ spec:
---
{{ end }}
{{ end }}
{{ end }}
Loading

0 comments on commit b20963c

Please sign in to comment.