Skip to content

Commit

Permalink
Merge remote-tracking branch 'common-upstream/main' into common-autom…
Browse files Browse the repository at this point in the history
…atic-update
  • Loading branch information
mbaldessari committed Aug 6, 2024
2 parents 592e286 + 414a252 commit ac05b4a
Show file tree
Hide file tree
Showing 104 changed files with 29,362 additions and 5,555 deletions.
1 change: 1 addition & 0 deletions common/.ansible-lint
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ exclude_paths:
- ./ansible/playbooks/iib-ci/iib-ci.yaml
- ./ansible/playbooks/k8s_secrets/k8s_secrets.yml
- ./ansible/playbooks/process_secrets/process_secrets.yml
- ./ansible/playbooks/write-token-kubeconfig/write-token-kubeconfig.yml
- ./ansible/playbooks/process_secrets/display_secrets_info.yml
- ./ansible/roles/vault_utils/tests/test.yml
20 changes: 5 additions & 15 deletions common/.github/workflows/chart-branches.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,7 @@ jobs:
acm:
needs: changes
if: |
${{ needs.changes.outputs.acm == 'true' }} &&
github.repository == 'validatedpatterns/common'
if: ${{ (needs.changes.outputs.acm == 'true') && (github.repository == 'validatedpatterns/common') }}
uses: validatedpatterns/common/.github/workflows/chart-split.yml@main
permissions:
actions: write
Expand All @@ -63,9 +61,7 @@ jobs:

golang-external-secrets:
needs: changes
if: |
${{ needs.changes.outputs.golang-external-secrets == 'true' }} &&
github.repository == 'validatedpatterns/common'
if: ${{ (needs.changes.outputs.golang-external-secrets == 'true') && (github.repository == 'validatedpatterns/common') }}
uses: validatedpatterns/common/.github/workflows/chart-split.yml@main
permissions:
actions: write
Expand All @@ -77,9 +73,7 @@ jobs:

hashicorp-vault:
needs: changes
if: |
${{ needs.changes.outputs.hashicorp-vault == 'true' }} &&
github.repository == 'validatedpatterns/common'
if: ${{ (needs.changes.outputs.hashicorp-vault == 'true') && (github.repository == 'validatedpatterns/common') }}
uses: validatedpatterns/common/.github/workflows/chart-split.yml@main
permissions:
actions: write
Expand All @@ -91,9 +85,7 @@ jobs:

letsencrypt:
needs: changes
if: |
${{ needs.changes.outputs.letsencrypt == 'true' }} &&
github.repository == 'validatedpatterns/common'
if: ${{ (needs.changes.outputs.letsencrypt == 'true') && (github.repository == 'validatedpatterns/common') }}
uses: validatedpatterns/common/.github/workflows/chart-split.yml@main
permissions:
actions: write
Expand All @@ -105,9 +97,7 @@ jobs:

clustergroup:
needs: changes
if: |
${{ needs.changes.outputs.clustergroup == 'true' }} &&
github.repository == 'validatedpatterns/common'
if: ${{ (needs.changes.outputs.clustergroup == 'true') && (github.repository == 'validatedpatterns/common') }}
uses: validatedpatterns/common/.github/workflows/chart-split.yml@main
permissions:
actions: write
Expand Down
8 changes: 6 additions & 2 deletions common/.github/workflows/chart-split.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,12 @@ jobs:
set -e
N="${{ inputs.chart_name }}"
B="${N}-main-single-chart"
GITIMG="quay.io/hybridcloudpatterns/gitsubtree-container:2.40.1"
sudo apt-get update -y && sudo apt-get install -y podman
echo "Running subtree split for ${B}"
podman pull "${GITIMG}"
git push origin -d "${B}" || /bin/true
git subtree split -P "${N}" -b "${B}"
git push -f -u origin "${B}"
# Git subtree got broken on recent versions of git hence this container
podman run --net=host --rm -t -v .:/git "${GITIMG}" subtree split -P "${N}" -b "${B}"
#git clone https://validatedpatterns:${GITHUB_TOKEN}@github.com/validatedpatterns/common.git -b "acm-main-single-chart" --single-branch
git push --force https://validatedpatterns:"${GITHUB_TOKEN}"@github.com/${{ inputs.target_repository }}.git "${B}:main"
4 changes: 2 additions & 2 deletions common/.github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ jobs:
# Full git history is needed to get a proper list of changed files within `super-linter`
fetch-depth: 0
- name: Setup helm
uses: azure/setup-helm@v3
uses: azure/setup-helm@v4
with:
version: 'v3.13.2'
version: 'v3.14.0'


################################
Expand Down
5 changes: 4 additions & 1 deletion common/.github/workflows/superlinter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,19 @@ jobs:
# Run Linter against code base #
################################
- name: Lint Code Base
uses: github/super-linter/slim@v5
uses: github/super-linter/slim@v6
env:
VALIDATE_ALL_CODEBASE: true
DEFAULT_BRANCH: main
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# These are the validation we disable atm
VALIDATE_ANSIBLE: false
VALIDATE_BASH: false
VALIDATE_CHECKOV: false
VALIDATE_JSCPD: false
VALIDATE_KUBERNETES_KUBECONFORM: false
VALIDATE_PYTHON_PYLINT: false
VALIDATE_SHELL_SHFMT: false
VALIDATE_YAML: false
# VALIDATE_DOCKERFILE_HADOLINT: false
# VALIDATE_MARKDOWN: false
Expand Down
24 changes: 15 additions & 9 deletions common/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
NAME ?= $(shell basename "`pwd`")

ifneq ($(origin TARGET_SITE), undefined)
TARGET_SITE_OPT=--set main.clusterGroupName=$(TARGET_SITE)
endif
Expand Down Expand Up @@ -55,11 +56,12 @@ help: ## This help message
show: ## show the starting template without installing it
helm template common/operator-install/ --name-template $(NAME) $(HELM_OPTS)

preview-all:
preview-all: ## (EXPERIMENTAL) Previews all applications on hub and managed clusters
@echo "NOTE: This is just a tentative approximation of rendering all hub and managed clusters templates"
@common/scripts/preview-all.sh $(TARGET_REPO) $(TARGET_BRANCH)

preview-%:
CLUSTERGROUP?=$(shell yq ".main.clusterGroupName" values-global.yaml)
$(eval CLUSTERGROUP ?= $(shell yq ".main.clusterGroupName" values-global.yaml))
@common/scripts/preview.sh $(CLUSTERGROUP) $* $(TARGET_REPO) $(TARGET_BRANCH)

.PHONY: operator-deploy
Expand Down Expand Up @@ -111,14 +113,15 @@ secrets-backend-none: ## Edits values files to remove secrets manager + ESO
.PHONY: load-iib
load-iib: ## CI target to install Index Image Bundles
@set -e; if [ x$(INDEX_IMAGES) != x ]; then \
for IIB in $(shell echo $(INDEX_IMAGES) | tr ',' '\n'); do \
INDEX_IMAGE="$${IIB}" ansible-playbook common/ansible/playbooks/iib-ci/iib-ci.yaml; \
done; \
ansible-playbook common/ansible/playbooks/iib-ci/iib-ci.yaml; \
else \
echo "No INDEX_IMAGES defined. Bailing out"; \
exit 1; \
fi

.PHONY: token-kubeconfig
token-kubeconfig: ## Create a local ~/.kube/config with password (not usually needed)
common/scripts/write-token-kubeconfig.sh

##@ Validation Tasks

Expand Down Expand Up @@ -230,17 +233,20 @@ kubeconform: ## run helm kubeconform
super-linter: ## Runs super linter locally
rm -rf .mypy_cache
podman run -e RUN_LOCAL=true -e USE_FIND_ALGORITHM=true \
-e VALIDATE_ANSIBLE=false \
-e VALIDATE_BASH=false \
-e VALIDATE_CHECKOV=false \
-e VALIDATE_DOCKERFILE_HADOLINT=false \
-e VALIDATE_JSCPD=false \
-e VALIDATE_KUBERNETES_KUBECONFORM=false \
-e VALIDATE_YAML=false \
-e VALIDATE_ANSIBLE=false \
-e VALIDATE_DOCKERFILE_HADOLINT=false \
-e VALIDATE_PYTHON_PYLINT=false \
-e VALIDATE_SHELL_SHFMT=false \
-e VALIDATE_TEKTON=false \
-e VALIDATE_YAML=false \
$(DISABLE_LINTERS) \
-v $(PWD):/tmp/lint:rw,z \
-w /tmp/lint \
docker.io/github/super-linter:slim-v5
ghcr.io/super-linter/super-linter:slim-v6

.PHONY: ansible-lint
ansible-lint: ## run ansible lint on ansible/ folder
Expand Down
2 changes: 1 addition & 1 deletion common/acm/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ description: A Helm chart to configure Advanced Cluster Manager for OpenShift.
keywords:
- pattern
name: acm
version: 0.0.1
version: 0.1.0
5 changes: 5 additions & 0 deletions common/acm/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Validated Patterns ACM chart

This chart is used to set up ACM in [Validated Patterns](https://validatedpatterns.io)

Please send PRs [here](https://github.com/validatedpatterns/common)
48 changes: 46 additions & 2 deletions common/acm/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,53 @@ Default always defined valueFiles to be included when pushing the cluster wide a
- "/values-global.yaml"
- "/values-{{ .name }}.yaml"
- '/values-{{ `{{ (lookup "config.openshift.io/v1" "Infrastructure" "" "cluster").spec.platformSpec.type }}` }}.yaml'
- '/values-{{ `{{ (lookup "config.openshift.io/v1" "Infrastructure" "" "cluster").spec.platformSpec.type }}` }}-{{ `{{ printf "%d.%d" ((semver (lookup "operator.openshift.io/v1" "OpenShiftControllerManager" "" "cluster").status.version).Major) ((semver (lookup "operator.openshift.io/v1" "OpenShiftControllerManager" "" "cluster").status.version).Minor) }}` }}.yaml'
- '/values-{{ `{{ (lookup "config.openshift.io/v1" "Infrastructure" "" "cluster").spec.platformSpec.type }}` }}-{{ `{{ printf "%d.%d" ((semver (index (lookup "config.openshift.io/v1" "ClusterVersion" "" "version").status.history 0).version).Major) ((semver (index (lookup "config.openshift.io/v1" "ClusterVersion" "" "version").status.history 0).version).Minor) }}` }}.yaml'
- '/values-{{ `{{ (lookup "config.openshift.io/v1" "Infrastructure" "" "cluster").spec.platformSpec.type }}` }}-{{ .name }}.yaml'
# We cannot use $.Values.global.clusterVersion because that gets resolved to the
# hub's cluster version, whereas we want to include the spoke cluster version
- '/values-{{ `{{ printf "%d.%d" ((semver (lookup "operator.openshift.io/v1" "OpenShiftControllerManager" "" "cluster").status.version).Major) ((semver (lookup "operator.openshift.io/v1" "OpenShiftControllerManager" "" "cluster").status.version).Minor) }}` }}-{{ .name }}.yaml'
- '/values-{{ `{{ printf "%d.%d" ((semver (index (lookup "config.openshift.io/v1" "ClusterVersion" "" "version").status.history 0).version).Major) ((semver (index (lookup "config.openshift.io/v1" "ClusterVersion" "" "version").status.history 0).version).Minor) }}` }}.yaml'
{{- end }} {{- /*acm.app.policies.valuefiles */}}

{{- define "acm.app.policies.multisourcevaluefiles" -}}
- "$patternref/values-global.yaml"
- "$patternref/values-{{ .name }}.yaml"
- '$patternref/values-{{ `{{ (lookup "config.openshift.io/v1" "Infrastructure" "" "cluster").spec.platformSpec.type }}` }}.yaml'
- '$patternref/values-{{ `{{ (lookup "config.openshift.io/v1" "Infrastructure" "" "cluster").spec.platformSpec.type }}` }}-{{ `{{ printf "%d.%d" ((semver (index (lookup "config.openshift.io/v1" "ClusterVersion" "" "version").status.history 0).version).Major) ((semver (index (lookup "config.openshift.io/v1" "ClusterVersion" "" "version").status.history 0).version).Minor) }}` }}.yaml'
- '$patternref/values-{{ `{{ (lookup "config.openshift.io/v1" "Infrastructure" "" "cluster").spec.platformSpec.type }}` }}-{{ .name }}.yaml'
# We cannot use $.Values.global.clusterVersion because that gets resolved to the
# hub's cluster version, whereas we want to include the spoke cluster version
- '$patternref/values-{{ `{{ printf "%d.%d" ((semver (index (lookup "config.openshift.io/v1" "ClusterVersion" "" "version").status.history 0).version).Major) ((semver (index (lookup "config.openshift.io/v1" "ClusterVersion" "" "version").status.history 0).version).Minor) }}` }}.yaml'
{{- end }} {{- /*acm.app.policies.multisourcevaluefiles */}}

{{- define "acm.app.policies.helmparameters" -}}
- name: global.repoURL
value: {{ $.Values.global.repoURL }}
- name: global.targetRevision
value: {{ $.Values.global.targetRevision }}
- name: global.namespace
value: $ARGOCD_APP_NAMESPACE
- name: global.pattern
value: {{ $.Values.global.pattern }}
- name: global.hubClusterDomain
value: {{ $.Values.global.hubClusterDomain }}
- name: global.localClusterDomain
value: '{{ `{{ (lookup "config.openshift.io/v1" "Ingress" "" "cluster").spec.domain }}` }}'
- name: global.clusterDomain
value: '{{ `{{ (lookup "config.openshift.io/v1" "Ingress" "" "cluster").spec.domain | replace "apps." "" }}` }}'
- name: global.clusterVersion
value: '{{ `{{ printf "%d.%d" ((semver (index (lookup "config.openshift.io/v1" "ClusterVersion" "" "version").status.history 0).version).Major) ((semver (index (lookup "config.openshift.io/v1" "ClusterVersion" "" "version").status.history 0).version).Minor) }}` }}'
- name: global.localClusterName
value: '{{ `{{ (split "." (lookup "config.openshift.io/v1" "Ingress" "" "cluster").spec.domain)._1 }}` }}'
- name: global.clusterPlatform
value: {{ $.Values.global.clusterPlatform }}
- name: global.multiSourceSupport
value: {{ $.Values.global.multiSourceSupport | quote }}
- name: global.multiSourceRepoUrl
value: {{ $.Values.global.multiSourceRepoUrl }}
- name: global.multiSourceTargetRevision
value: {{ $.Values.global.multiSourceTargetRevision }}
- name: global.privateRepo
value: {{ $.Values.global.privateRepo | quote }}
- name: global.experimentalCapabilities
value: {{ $.Values.global.experimentalCapabilities }}
{{- end }} {{- /*acm.app.policies.helmparameters */}}
8 changes: 5 additions & 3 deletions common/acm/templates/multiclusterhub.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
{{- $channel := "" }}
{{- if .Values.acm.mce_operator.channel }}
{{- $channel = printf ",\"channel\": \"%s\"" .Values.acm.mce_operator.channel }}
{{- end }}
apiVersion: operator.open-cluster-management.io/v1
kind: MultiClusterHub
metadata:
name: multiclusterhub
namespace: open-cluster-management
annotations:
argocd.argoproj.io/sync-wave: "-1"
{{- if kindIs "map" .Values.clusterGroup.subscriptions }}
installer.open-cluster-management.io/mce-subscription-spec: '{"source": "{{ default "redhat-operators" .Values.clusterGroup.subscriptions.acm.source }}" }'
{{- end }}
installer.open-cluster-management.io/mce-subscription-spec: '{"source": "{{ default "redhat-operators" .Values.acm.mce_operator.source }}" {{- $channel }} }'
spec: {}
Loading

0 comments on commit ac05b4a

Please sign in to comment.