Skip to content

Commit

Permalink
SONAR-23559 Improves editions and versions setting for sonarqube chart
Browse files Browse the repository at this point in the history
  • Loading branch information
davividal committed Jan 2, 2025
1 parent 552f8af commit c0667c1
Show file tree
Hide file tree
Showing 100 changed files with 1,649 additions and 258 deletions.
17 changes: 9 additions & 8 deletions .cirrus/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ARG CIRRUS_AWS_ACCOUNT
FROM ${CIRRUS_AWS_ACCOUNT:-275878209202}.dkr.ecr.eu-central-1.amazonaws.com/base:j11-latest as tools
FROM ${CIRRUS_AWS_ACCOUNT:-275878209202}.dkr.ecr.eu-central-1.amazonaws.com/base:j11-latest AS tools

FROM docker:20.10
FROM docker:27.4

USER root

Expand All @@ -27,24 +27,25 @@ ENV PATH=/usr/bin/google-cloud-sdk/bin:${PATH}

RUN apk add --update --no-cache \
aws-cli \
ca-certificates \
bash \
jq \
moreutils \
ca-certificates \
curl \
gcompat \
git \
gnupg \
go \
jq \
libc6-compat \
libstdc++ \
moreutils \
openssh-client \
py3-pip \
py3-wheel \
python3 && \
pip install --upgrade pip==24.2
pip install --break-system-packages --upgrade pip==24.2

RUN pip install "yamllint==${YAMLLINT_VERSION}" && \
pip install "yamale==${YAMALE_VERSION}"
RUN pip install --break-system-packages "yamllint==${YAMLLINT_VERSION}" && \
pip install --break-system-packages "yamale==${YAMALE_VERSION}"

RUN set -eux; \
curl -sL ${HELM_BASE_URL}/${HELM_TAR_FILE} -o ${HELM_TAR_FILE} ; \
Expand Down
7 changes: 7 additions & 0 deletions .cirrus/schema_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

set -euo pipefail

cd "$(dirname "$0")/../tests/unit-test"

go test -timeout=0 -v schema_test.go
11 changes: 11 additions & 0 deletions .cirrus/tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,17 @@ chart_static_compatibility_test_task:
- ./.cirrus/build_chart_dependencies.sh charts/sonarqube-dce
- ./.cirrus/unit_helm_compatibility_test.sh sonarqube-dce

chart_schema_test_task:
eks_container:
<<: *CONTAINER_TEMPLATE
cpu: 1
memory: 2Gb
<<: *CLONE_SCRIPT_TEMPLATE
script:
- ./.cirrus/build_chart_dependencies.sh charts/sonarqube
- ./.cirrus/build_chart_dependencies.sh charts/sonarqube-dce
- ./.cirrus/schema_test.sh

chart_fixture_test_task:
<<: *ONLY_ON_NON_RELEASE_DRAFT_TEMPLATE
timeout_in: 30m
Expand Down
1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
gcloud 470.0.0
helm-ct 3.10.1
kubeconform 0.6.3
golang 1.22.0
1 change: 1 addition & 0 deletions charts/sonarqube/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ All changes to this chart will be documented in this file.
* Update ingress-nginx subchart to 4.11.3
* Support Kubernetes v1.32
* Remove the default passcode provided with `monitoringPasscode`
* Improves editions and versions setting for sonarqube chart

## [10.8.1]
* Update Chart's version to 10.8.1
Expand Down
2 changes: 2 additions & 0 deletions charts/sonarqube/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ annotations:
description: "Support Kubernetes v1.32"
- kind: changed
description: "Remove the default passcode provided with 'monitoringPasscode'"
- kind: changed
description: "Improves editions and versions setting for sonarqube chart"
artifacthub.io/containsSecurityUpdates: "false"
artifacthub.io/images: |
- name: sonarqube
Expand Down
3 changes: 3 additions & 0 deletions charts/sonarqube/ci/cirrus-values.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
community:
enabled: true

image:
pullSecrets:
- name: pullsecret
Expand Down
3 changes: 3 additions & 0 deletions charts/sonarqube/openshift-verifier/values.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
community:
enabled: true

OpenShift:
enabled: true
route:
Expand Down
42 changes: 32 additions & 10 deletions charts/sonarqube/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,39 @@ Expand the Application Image name.

{{/*
Define the image.tag value that computes the right tag to be used as `sonarqube.image`
The tag is derived from the following parameters:
- .Values.image.tag
- .Values.community.enabled
- .Values.community.buildNumber
- .Values.edition
- .Chart.AppVersion
The logic to generate the tag is as follows:
There should not be a default edition, with users that specify it.
The edition must be one of these values: developer/enterprise.
When “edition“ is used and “image.tag” is not, we use “appVersion” for paid editions and the latest release of SQ-CB for the community.
The CI supports the release of the Server edition.
*/}}
{{- define "image.tag" -}}
{{- if empty .Values.image.tag -}}
{{- if and (not (empty .Values.edition)) (or (eq .Values.edition "developer") (eq .Values.edition "enterprise")) -}}
{{- printf "%s-%s" .Chart.AppVersion .Values.edition -}}
{{- else if or (.Values.community.enabled) (and (not (empty .Values.edition)) (eq .Values.edition "community")) -}}
{{- printf "%s-%s" .Values.community.buildNumber "community" -}}
{{- end -}}
{{- else -}}
{{- .Values.image.tag -}}
{{- end -}}
{{- $imageTag := "" -}}
{{- if not (empty .Values.edition) -}}
{{- if or (empty .Values.image) (empty .Values.image.tag) -}}
{{- $imageTag = printf "%s-%s" .Chart.AppVersion .Values.edition -}}
{{- else -}}
{{- $imageTag = printf "%s" .Values.image.tag -}}
{{- end -}}
{{- else if (and (.Values.community) .Values.community.enabled) -}}
{{- if or (empty .Values.image) (empty .Values.image.tag) -}}
{{- if not (empty .Values.community.buildNumber) -}}
{{- $imageTag = printf "%s-%s" .Values.community.buildNumber "community" -}}
{{- else -}}
{{- $imageTag = printf "community" -}}
{{- end -}}
{{- else -}}
{{- $imageTag = printf "%s" .Values.image.tag -}}
{{- end -}}
{{- end -}}
{{- printf "%s" $imageTag -}}
{{- end -}}

{{/*
Expand Down Expand Up @@ -431,4 +453,4 @@ Remove incompatible user/group values that do not work in Openshift out of the b

{{- $accountDeprecation := (include "deepMerge" (dict "map1" $map1 "map2" $map2)) -}}
{{- $accountDeprecation }}
{{- end -}}
{{- end -}}
93 changes: 74 additions & 19 deletions charts/sonarqube/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,10 @@
"properties": {
"edition": {
"type": "string",
"enum": ["community", "developer", "enterprise"],
"properties": {
"community": {
"type": "string",
"deprecated": true,
"$comment": "(DEPRECATED) Please use `community.enabled` instead"
}
}
"enum": [
"developer",
"enterprise"
]
},
"persistence": {
"type": "object",
Expand All @@ -40,8 +36,7 @@
}
}
},
"OpenShift":
{
"OpenShift": {
"type": "object",
"properties": {
"createSCC": {
Expand Down Expand Up @@ -98,7 +93,10 @@
},
"replicaCount": {
"type": "integer",
"enum": [0, 1]
"enum": [
0,
1
]
},
"jvmOpts": {
"type": "string",
Expand Down Expand Up @@ -172,20 +170,17 @@
"deprecated": true,
"$comment": "(DEPRECATED) this option will be removed in the next major release"
},
"curlContainerImage":
{
"curlContainerImage": {
"type": "string",
"deprecated": true,
"$comment": "(DEPRECATED) please use `setAdminPassword.image` at the value top level"
},
"adminJobAnnotations":
{
"adminJobAnnotations": {
"type": "object",
"deprecated": true,
"$comment": "(DEPRECATED) please use `setAdminPassword.annotations` at the value top level"
},
"sonarqubeFolder":
{
"sonarqubeFolder": {
"type": "string",
"deprecated": true,
"$comment": "(DEPRECATED) This value will is no longer required and will be dropped in future releases"
Expand All @@ -205,5 +200,65 @@
}
}
}
}
}
},
"allOf": [
{
"if": {
"properties": {
"community": {
"properties": {
"enabled": {
"const": true
}
}
}
}
},
"then": {
"properties": {
"edition": {
"maxLength": 0
}
}
}
},
{
"if": {
"properties": {
"community": {
"properties": {
"enabled": {
"const": false
}
}
}
}
},
"then": {
"required": [
"edition"
]
}
},
{
"if": {
"not": {
"properties": {
"community": {
"properties": {
"enabled": {
"type": "boolean"
}
}
}
}
}
},
"then": {
"required": [
"edition"
]
}
}
]
}
10 changes: 4 additions & 6 deletions charts/sonarqube/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,17 @@ OpenShift:
# labels:
# external: 'true'

# (DEPRECATED) The "community" value as the default of "edition" is deprecated and will be removed in the next release (in favor of an empty value). Please set "community" to "true", if you want to use SonarQube Community Build.
edition: "community"
# Configure the edition of SonarQube Server to deploy: developer or enterprise
# edition: ""

# Set the chart to use the latest released SonarQube Community Build
community:
enabled: true
enabled: false
buildNumber: "24.12.0.100206"

image:
repository: sonarqube
# (DEPRECATED) The "image.tag" parameter is set to be empty as default.
# image.tag is set according to the edition and community fields, user-defined have precedance.
# tag: 10.8.1-{{ .Values.edition }}
# tag: ""
pullPolicy: IfNotPresent
# If using a private repository, the imagePullSecrets to use
# pullSecrets:
Expand Down
18 changes: 13 additions & 5 deletions tests/dynamic-compatibility-test/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
## Execute tests
# Execute tests

In order to execute the dynamic compability test locally, you need to have a k8s cluster running (configurations stored in the default folder), go (at least version 1.13).
## Dynamic compatibility tests

When the pre-requisites are fullfilled, just run:
In order to execute the dynamic compatibility test locally, you need to have a k8s cluster running (configurations stored in the default folder), go (at least version 1.22).

```
When the pre-requisites are fulfilled, just run:

```bash
go test -timeout=0 -v sonarqube_standard_dynamic_test.go pod_utils.go
```
```

## Schema validation tests

```bash
go test -v schema_test.go
```
Loading

0 comments on commit c0667c1

Please sign in to comment.