From e62318653ef274765a58ba2af484f39cde606ed0 Mon Sep 17 00:00:00 2001 From: Richard Hagen Date: Tue, 23 Jan 2024 08:39:16 +0100 Subject: [PATCH] Set radix-tekton tag (#585) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * set radix-tekton tag * cleanup readme * Update api/jobs/start_job_handler.go Co-authored-by: Nils Gustav Stråbø <65334626+nilsgstrabo@users.noreply.github.com> --------- Co-authored-by: Richard Hagen Co-authored-by: Nils Gustav Stråbø <65334626+nilsgstrabo@users.noreply.github.com> --- .vscode/launch.json | 3 ++- README.md | 18 +++++-------- api/jobs/start_job_handler.go | 15 ++++++++++- charts/radix-api-dev/.helmignore | 21 ---------------- charts/radix-api-dev/Chart.yaml | 4 --- charts/radix-api-dev/templates/_helpers.tpl | 16 ------------ .../radix-api-dev/templates/deployment.yaml | 25 ------------------- charts/radix-api-dev/values.yaml | 12 --------- radixconfig.yaml | 2 ++ 9 files changed, 24 insertions(+), 92 deletions(-) delete mode 100644 charts/radix-api-dev/.helmignore delete mode 100644 charts/radix-api-dev/Chart.yaml delete mode 100644 charts/radix-api-dev/templates/_helpers.tpl delete mode 100644 charts/radix-api-dev/templates/deployment.yaml delete mode 100644 charts/radix-api-dev/values.yaml diff --git a/.vscode/launch.json b/.vscode/launch.json index ed088e52..55491114 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -13,6 +13,7 @@ "env": { "RADIX_CONTAINER_REGISTRY":"radixdev.azurecr.io", "PIPELINE_IMG_TAG": "master-latest", + "RADIX_TEKTON_TAG": "main-latest", "K8S_API_HOST": "https://weekly-14-clusters-16ede4-97pzjkre.hcp.northeurope.azmk8s.io", "RADIX_CLUSTER_TYPE": "development", "RADIX_DNS_ZONE": "dev.radix.equinor.com", @@ -28,4 +29,4 @@ ] } ] -} \ No newline at end of file +} diff --git a/README.md b/README.md index 622e1a93..1febdcc1 100644 --- a/README.md +++ b/README.md @@ -18,9 +18,9 @@ You need Go installed. Make sure `GOPATH` and `GOROOT` are properly set up. Also needed: -- [`go-swagger`](https://github.com/go-swagger/go-swagger) (install with `go install github.com/go-swagger/go-swagger/cmd/swagger@v0.30.5`.) -- [`statik`](https://github.com/rakyll/statik) (install with `go install github.com/rakyll/statik@v0.1.7`) -- [`gomock`](https://github.com/golang/mock) (install with `go install github.com/golang/mock/mockgen@v1.6.0`) +- [`go-swagger`](https://github.com/go-swagger/go-swagger) (install with `make bootstrap`.) +- [`golangci-lint`](https://golangci-lint.run/) (install with `make bootstrap`) +- [`gomock`](https://github.com/golang/mock) (install with `make bootstrap`) Clone the repo into your `GOPATH` and run `go mod download`. @@ -44,6 +44,7 @@ The following env vars are needed. Useful default values in brackets. - `RADIX_CONTAINER_REGISTRY` - (`radixdev.azurecr.io`) - `PIPELINE_IMG_TAG` - (`master-latest`) +- `RADIX_TEKTON_TAG` - (`release-latest`) You also probably want to start with the argument `--useOutClusterClient=false`. When `useOutClusterClient` is `false`, several debugging settings are enabled: * a service principal with superpowers is used to authorize the requests, and the client's `Authorization` bearer token is ignored. @@ -53,16 +54,9 @@ You also probably want to start with the argument `--useOutClusterClient=false`. If you are using VSCode, there is a convenient launch configuration in `.vscode`. -#### Common errors running locally - -- **Problem**: `panic: statik/fs: no zip data registered` - - **Solution**: `make swagger` - #### Validate code -- `go install honnef.co/go/tools/cmd/staticcheck@v0.3.3` -- run `make staticcheck` +- run `make lint` #### Update version We follow the [semantic version](https://semver.org/) as recommended by [go](https://blog.golang.org/publishing-go-modules). @@ -109,4 +103,4 @@ Read our [contributing guidelines](./CONTRIBUTING.md) ------------------ -[Security notification](./SECURITY.md) \ No newline at end of file +[Security notification](./SECURITY.md) diff --git a/api/jobs/start_job_handler.go b/api/jobs/start_job_handler.go index b3a4da9d..286aa72d 100644 --- a/api/jobs/start_job_handler.go +++ b/api/jobs/start_job_handler.go @@ -22,7 +22,8 @@ import ( ) const ( - pipelineTagEnvironmentVariable = "PIPELINE_IMG_TAG" + pipelineTagEnvironmentVariable = "PIPELINE_IMG_TAG" + radixTektonTagEnvironmentVariable = "RADIX_TEKTON_TAG" ) // HandleStartPipelineJob Handles the creation of a pipeline job for an application @@ -116,6 +117,7 @@ func (jh JobHandler) buildPipelineJob(appName, cloneURL, radixConfigFullName str CloneURL: cloneURL, PipeLineType: pipeline.Type, PipelineImage: getPipelineTag(), + TektonImage: getRadixTektonTag(), Build: buildSpec, Promote: promoteSpec, Deploy: deploySpec, @@ -149,6 +151,17 @@ func getPipelineTag() string { return pipelineTag } +func getRadixTektonTag() string { + tektonTag := os.Getenv(radixTektonTagEnvironmentVariable) + if tektonTag == "" { + log.Warning("No radix tekton image tag defined. Using release-latest") + tektonTag = "release-latest" + } else { + log.Infof("Using %s radix tekton image tag", tektonTag) + } + return tektonTag +} + func getUniqueJobName(image string) (string, string) { var jobName []string randomStr := strings.ToLower(radixutils.RandString(5)) diff --git a/charts/radix-api-dev/.helmignore b/charts/radix-api-dev/.helmignore deleted file mode 100644 index f0c13194..00000000 --- a/charts/radix-api-dev/.helmignore +++ /dev/null @@ -1,21 +0,0 @@ -# Patterns to ignore when building packages. -# This supports shell glob matching, relative path matching, and -# negation (prefixed with !). Only one pattern per line. -.DS_Store -# Common VCS dirs -.git/ -.gitignore -.bzr/ -.bzrignore -.hg/ -.hgignore -.svn/ -# Common backup files -*.swp -*.bak -*.tmp -*~ -# Various IDEs -.project -.idea/ -*.tmproj diff --git a/charts/radix-api-dev/Chart.yaml b/charts/radix-api-dev/Chart.yaml deleted file mode 100644 index 36af4473..00000000 --- a/charts/radix-api-dev/Chart.yaml +++ /dev/null @@ -1,4 +0,0 @@ -apiVersion: v1 -description: A Helm chart for Kubernetes -name: radix-api-dev -version: v0.1.1 diff --git a/charts/radix-api-dev/templates/_helpers.tpl b/charts/radix-api-dev/templates/_helpers.tpl deleted file mode 100644 index f0d83d2e..00000000 --- a/charts/radix-api-dev/templates/_helpers.tpl +++ /dev/null @@ -1,16 +0,0 @@ -{{/* vim: set filetype=mustache: */}} -{{/* -Expand the name of the chart. -*/}} -{{- define "name" -}} -{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} -{{- end -}} - -{{/* -Create a default fully qualified app name. -We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). -*/}} -{{- define "fullname" -}} -{{- $name := default .Chart.Name .Values.nameOverride -}} -{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} -{{- end -}} diff --git a/charts/radix-api-dev/templates/deployment.yaml b/charts/radix-api-dev/templates/deployment.yaml deleted file mode 100644 index 4cd13e8c..00000000 --- a/charts/radix-api-dev/templates/deployment.yaml +++ /dev/null @@ -1,25 +0,0 @@ -apiVersion: radix.equinor.com/v1 -kind: RadixDeployment -metadata: - labels: - radix-commit: {{ .Values.buildID }} - radix-env: {{ .Values.app.env }} - radix-app: {{ .Values.app.name }} - draft: {{ default "draft-app" .Values.draft }} - chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" - name: {{ .Values.app.name }} - namespace: {{ .Values.app.namespace }} -spec: - appname: {{ .Values.app.name }} - components: - - environmentVariables: - PIPELINE_IMG_TAG: {{ .Values.component.pipelineImage }} - image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" - monitoring: true - name: {{ .Values.component.name }} - ports: - - name: http - port: {{ .Values.component.port }} - public: true - replicas: 1 - environment: {{ .Values.app.env }} \ No newline at end of file diff --git a/charts/radix-api-dev/values.yaml b/charts/radix-api-dev/values.yaml deleted file mode 100644 index a06fc22e..00000000 --- a/charts/radix-api-dev/values.yaml +++ /dev/null @@ -1,12 +0,0 @@ -# Default values for golang. -# This is a YAML-formatted file. -# Declare variables to be passed into your templates. -app: - name: radix-api - namespace: radix-api-dev - env: dev - -component: - name: server - pipelineImage: release-latest - port: 3002 \ No newline at end of file diff --git a/radixconfig.yaml b/radixconfig.yaml index 120576ba..8a9542d8 100644 --- a/radixconfig.yaml +++ b/radixconfig.yaml @@ -38,6 +38,7 @@ spec: cpu: "2000m" variables: PIPELINE_IMG_TAG: "master-latest" + RADIX_TEKTON_TAG: "main-latest" GOMAXPROCS: "1" - environment: prod runAsNonRoot: true @@ -52,4 +53,5 @@ spec: cpu: "2000m" variables: PIPELINE_IMG_TAG: "release-latest" + RADIX_TEKTON_TAG: "release-latest" GOMAXPROCS: "2"