Skip to content

Commit e442581

Browse files
committed
Merge branch 'main' into test-acm-policies
2 parents d06ac16 + d03c0ff commit e442581

File tree

90 files changed

+552
-83307
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+552
-83307
lines changed

.ansible-lint

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# Vim filetype=yaml
22
---
33
offline: false
4-
#requirements: ansible/execution_environment/requirements.yml
54

65
exclude_paths:
76
- .cache/

.github/workflows/ansible-lint.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,4 @@ jobs:
1111
- uses: actions/checkout@v4
1212

1313
- name: Lint Ansible Playbook
14-
uses: ansible/ansible-lint-action@v6
15-
# Let's point it to the path
16-
with:
17-
path: "ansible/"
14+
uses: ansible/ansible-lint@06f616d6e86e9ce4c74393318d1cbb2d016af413

.github/workflows/jsonschema.yaml

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,19 @@
11
---
22
name: Verify json schema
33

4-
#
5-
# Documentation:
6-
# https://help.github.com/en/articles/workflow-syntax-for-github-actions
7-
#
8-
9-
#############################
10-
# Start the job on all push #
11-
#############################
124
on: [push, pull_request]
135

14-
###############
15-
# Set the Job #
16-
###############
176
jobs:
187
jsonschema_tests:
19-
# Name the Job
208
name: Json Schema tests
219
strategy:
2210
matrix:
2311
python-version: [3.11]
24-
# Set the agent to run on
2512
runs-on: ubuntu-latest
2613

27-
##################
28-
# Load all steps #
29-
##################
3014
steps:
31-
##########################
32-
# Checkout the code base #
33-
##########################
3415
- name: Checkout Code
3516
uses: actions/checkout@v4
36-
with:
37-
# Full git history is needed to get a proper list of changed files within `super-linter`
38-
fetch-depth: 0
3917

4018
- name: Set up Python ${{ matrix.python-version }}
4119
uses: actions/setup-python@v5
@@ -54,19 +32,20 @@ jobs:
5432

5533
- name: Verify secrets json schema against templates
5634
run: |
57-
# check-jsonschema needs .yaml as an extension
5835
cp ./values-secret.yaml.template ./values-secret.yaml
59-
check-jsonschema --schemafile https://raw.githubusercontent.com/validatedpatterns/rhvp.cluster_utils/refs/heads/main/roles/vault_utils/values-secrets.v2.schema.json values-secret.yaml
36+
check-jsonschema --fill-defaults --schemafile https://raw.githubusercontent.com/validatedpatterns/rhvp.cluster_utils/refs/heads/main/roles/vault_utils/values-secrets.v2.schema.json values-secret.yaml
6037
rm -f ./values-secret.yaml
6138
6239
- name: Verify ClusterGroup values.schema.json against values-*yaml files
6340
run: |
64-
set -e; for i in values-hub.yaml values-group-one.yaml; do
41+
set -e
42+
find . -maxdepth 1 -type f -name "values-*.yaml" ! -name "values-global.yaml" -print0 | while IFS= read -r -d '' i;
43+
do
6544
echo "$i"
6645
# disable shellcheck of single quotes in yq
6746
# shellcheck disable=2016
6847
yq eval-all '. as $item ireduce ({}; . * $item )' values-global.yaml "$i" > tmp.yaml
69-
check-jsonschema --schemafile https://raw.githubusercontent.com/validatedpatterns/clustergroup-chart/refs/heads/main/values.schema.json tmp.yaml
48+
check-jsonschema --fill-defaults --schemafile https://raw.githubusercontent.com/validatedpatterns/clustergroup-chart/refs/heads/main/values.schema.json tmp.yaml
7049
rm -f tmp.yaml
7150
done
7251
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# This is a job to be run in the validatedpatterns organization only.
2+
# It tries to keep the rhdp-deploy branch uptodate by creating a PR from main
3+
---
4+
name: Sync main to rhdp-deploy
5+
on:
6+
push:
7+
branches:
8+
- main
9+
10+
jobs:
11+
sync-branches:
12+
if: |
13+
github.repository_owner == 'validatedpatterns'
14+
runs-on: ubuntu-latest
15+
name: Git Sync branch
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v4
19+
- name: Set up Node
20+
uses: actions/setup-node@v4
21+
with:
22+
node-version: 20
23+
- name: Opening pull request
24+
id: pull
25+
uses: mbaldessari/git-sync-branch@v0.2.0
26+
with:
27+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
28+
FROM_BRANCH: "main"
29+
TO_BRANCH: "rhdp-deploy"
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# This job requires a secret called DOCS_TOKEN which should be a PAT token
2+
# that has the permissions described in:
3+
# validatedpatterns/docs/.github/workflows/metadata-docs.yml@main
4+
---
5+
name: Update docs pattern metadata
6+
on:
7+
push:
8+
paths:
9+
- "pattern-metadata.yaml"
10+
- ".github/workflows/update-metadata.yml"
11+
branches:
12+
- main
13+
14+
jobs:
15+
update-metadata:
16+
uses: validatedpatterns/docs/.github/workflows/metadata-docs.yml@main
17+
permissions: # Workflow-level permissions
18+
contents: read # Required for "read-all"
19+
packages: write # Allows writing to packages
20+
id-token: write # Allows creating OpenID Connect (OIDC) tokens
21+
secrets: inherit
22+
# For testing you can point to a different branch in the docs repository
23+
# with:
24+
# DOCS_BRANCH: "main"
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Run Bash Script on Multiple Distributions
2+
3+
on:
4+
push:
5+
paths:
6+
- "scripts/**"
7+
- "Makefile"
8+
branches:
9+
- main
10+
pull_request:
11+
paths:
12+
- "scripts/**"
13+
- "Makefile"
14+
15+
jobs:
16+
run-script:
17+
name: Run Bash Script
18+
strategy:
19+
matrix:
20+
# Fedora is not an option yet
21+
os: [ubuntu-latest, ubuntu-22.04]
22+
runs-on: ${{ matrix.os }}
23+
24+
steps:
25+
- name: Checkout Repository
26+
uses: actions/checkout@v4
27+
28+
- name: Install Podman on Ubuntu
29+
if: contains(matrix.os, 'ubuntu')
30+
run: |
31+
sudo apt-get update
32+
sudo apt-get install -y podman
33+
34+
# Currently we do not do MacOSX as it is not free, maybe in the future
35+
# - name: Install Podman on macOS
36+
# if: contains(matrix.os, 'macos')
37+
# run: |
38+
# brew install podman
39+
# podman machine init
40+
# podman machine start
41+
42+
- name: Verify Podman Installation
43+
run: podman --version
44+
45+
- name: Run pattern.sh script
46+
run: |
47+
export TARGET_BRANCH=main
48+
./scripts/pattern-util.sh make validate-origin

common/Makefile

Lines changed: 47 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,36 @@ ifneq ($(origin TARGET_SITE), undefined)
44
TARGET_SITE_OPT=--set main.clusterGroupName=$(TARGET_SITE)
55
endif
66

7+
# Set this to true if you want to skip any origin validation
8+
DISABLE_VALIDATE_ORIGIN ?= false
9+
ifeq ($(DISABLE_VALIDATE_ORIGIN),true)
10+
VALIDATE_ORIGIN :=
11+
else
12+
VALIDATE_ORIGIN := validate-origin
13+
endif
14+
715
# This variable can be set in order to pass additional helm arguments from the
816
# the command line. I.e. we can set things without having to tweak values files
917
EXTRA_HELM_OPTS ?=
1018

19+
# This variable can be set in order to pass additional ansible-playbook arguments from the
20+
# the command line. I.e. we can set -vvv for more verbose logging
21+
EXTRA_PLAYBOOK_OPTS ?=
22+
1123
# INDEX_IMAGES=registry-proxy.engineering.redhat.com/rh-osbs/iib:394248
1224
# or
1325
# INDEX_IMAGES=registry-proxy.engineering.redhat.com/rh-osbs/iib:394248,registry-proxy.engineering.redhat.com/rh-osbs/iib:394249
1426
INDEX_IMAGES ?=
1527

16-
TARGET_ORIGIN ?= origin
28+
# git branch --show-current is also available as of git 2.22, but we will use this for compatibility
29+
TARGET_BRANCH ?= $(shell git rev-parse --abbrev-ref HEAD)
30+
31+
#default to the branch remote
32+
TARGET_ORIGIN ?= $(shell git config branch.$(TARGET_BRANCH).remote)
33+
1734
# This is to ensure that whether we start with a git@ or https:// URL, we end up with an https:// URL
1835
# This is because we expect to use tokens for repo authentication as opposed to SSH keys
1936
TARGET_REPO=$(shell git ls-remote --get-url --symref $(TARGET_ORIGIN) | sed -e 's/.*URL:[[:space:]]*//' -e 's%^git@%%' -e 's%^https://%%' -e 's%:%/%' -e 's%^%https://%')
20-
# git branch --show-current is also available as of git 2.22, but we will use this for compatibility
21-
TARGET_BRANCH=$(shell git rev-parse --abbrev-ref HEAD)
2237

2338
UUID_FILE ?= ~/.config/validated-patterns/pattern-uuid
2439
UUID_HELM_OPTS ?=
@@ -67,12 +82,8 @@ preview-%:
6782
@common/scripts/preview.sh $(CLUSTERGROUP) $* $(TARGET_REPO) $(TARGET_BRANCH)
6883

6984
.PHONY: operator-deploy
70-
operator-deploy operator-upgrade: validate-prereq validate-origin validate-cluster ## runs helm install
71-
@set -e -o pipefail
72-
# Retry five times because the CRD might not be fully installed yet
73-
for i in {1..5}; do \
74-
helm template --include-crds --name-template $(NAME) $(PATTERN_INSTALL_CHART) $(HELM_OPTS) | oc apply -f- && break || sleep 10; \
75-
done
85+
operator-deploy operator-upgrade: validate-prereq $(VALIDATE_ORIGIN) validate-cluster ## runs helm install
86+
@common/scripts/deploy-pattern.sh $(NAME) $(PATTERN_INSTALL_CHART) $(HELM_OPTS)
7687

7788
.PHONY: uninstall
7889
uninstall: ## runs helm uninstall
@@ -115,7 +126,7 @@ secrets-backend-none: ## Edits values files to remove secrets manager + ESO
115126
.PHONY: load-iib
116127
load-iib: ## CI target to install Index Image Bundles
117128
@set -e; if [ x$(INDEX_IMAGES) != x ]; then \
118-
ansible-playbook rhvp.cluster_utils.iib-ci; \
129+
ansible-playbook $(EXTRA_PLAYBOOK_OPTS) rhvp.cluster_utils.iib_ci; \
119130
else \
120131
echo "No INDEX_IMAGES defined. Bailing out"; \
121132
exit 1; \
@@ -129,12 +140,22 @@ token-kubeconfig: ## Create a local ~/.kube/config with password (not usually ne
129140

130141
# We only check the remote ssh git branch's existance if we're not running inside a container
131142
# as getting ssh auth working inside a container seems a bit brittle
143+
# If the main repoUpstreamURL field is set, then we need to check against
144+
# that and not target_repo
132145
.PHONY: validate-origin
133146
validate-origin: ## verify the git origin is available
134147
@echo "Checking repository:"
135-
@echo -n " $(TARGET_REPO) - branch '$(TARGET_BRANCH)': "
136-
@git ls-remote --exit-code --heads $(TARGET_REPO) $(TARGET_BRANCH) >/dev/null &&\
137-
echo "OK" || (echo "NOT FOUND"; exit 1)
148+
$(eval UPSTREAMURL := $(shell yq -r '.main.git.repoUpstreamURL // (.main.git.repoUpstreamURL = "")' values-global.yaml))
149+
@if [ -z "$(UPSTREAMURL)" ]; then\
150+
echo -n " $(TARGET_REPO) - branch '$(TARGET_BRANCH)': ";\
151+
git ls-remote --exit-code --heads $(TARGET_REPO) $(TARGET_BRANCH) >/dev/null &&\
152+
echo "OK" || (echo "NOT FOUND"; exit 1);\
153+
else\
154+
echo "Upstream URL set to: $(UPSTREAMURL)";\
155+
echo -n " $(UPSTREAMURL) - branch '$(TARGET_BRANCH)': ";\
156+
git ls-remote --exit-code --heads $(UPSTREAMURL) $(TARGET_BRANCH) >/dev/null &&\
157+
echo "OK" || (echo "NOT FOUND"; exit 1);\
158+
fi
138159

139160
.PHONY: validate-cluster
140161
validate-cluster: ## Do some cluster validations before installing
@@ -143,7 +164,7 @@ validate-cluster: ## Do some cluster validations before installing
143164
@oc cluster-info >/dev/null && echo "OK" || (echo "Error"; exit 1)
144165
@echo -n " storageclass: "
145166
@if [ `oc get storageclass -o go-template='{{printf "%d\n" (len .items)}}'` -eq 0 ]; then\
146-
echo "None Found"; exit 1;\
167+
echo "WARNING: No storageclass found";\
147168
else\
148169
echo "OK";\
149170
fi
@@ -153,15 +174,20 @@ validate-cluster: ## Do some cluster validations before installing
153174
validate-schema: ## validates values files against schema in common/clustergroup
154175
$(eval VAL_PARAMS := $(shell for i in ./values-*.yaml; do echo -n "$${i} "; done))
155176
@echo -n "Validating clustergroup schema of: "
156-
@set -e; for i in $(VAL_PARAMS); do echo -n " $$i"; helm template common/clustergroup $(HELM_OPTS) -f "$${i}" >/dev/null; done
177+
@set -e; for i in $(VAL_PARAMS); do echo -n " $$i"; helm template oci://quay.io/hybridcloudpatterns/clustergroup $(HELM_OPTS) -f "$${i}" >/dev/null; done
157178
@echo
158179

159180
.PHONY: validate-prereq
160181
validate-prereq: ## verify pre-requisites
182+
$(eval GLOBAL_PATTERN := $(shell yq -r .global.pattern values-global.yaml))
183+
@if [ $(NAME) != $(GLOBAL_PATTERN) ]; then\
184+
echo "";\
185+
echo "WARNING: folder directory is \"$(NAME)\" and global.pattern is set to \"$(GLOBAL_PATTERN)\"";\
186+
echo "this can create problems. Please make sure they are the same!";\
187+
echo "";\
188+
fi
161189
@if [ ! -f /run/.containerenv ]; then\
162190
echo "Checking prerequisites:";\
163-
for t in $(EXECUTABLES); do if ! which $$t > /dev/null 2>&1; then echo "No $$t in PATH"; exit 1; fi; done;\
164-
echo " Check for '$(EXECUTABLES)': OK";\
165191
echo -n " Check for python-kubernetes: ";\
166192
if ! ansible -m ansible.builtin.command -a "{{ ansible_python_interpreter }} -c 'import kubernetes'" localhost > /dev/null 2>&1; then echo "Not found"; exit 1; fi;\
167193
echo "OK";\
@@ -182,16 +208,16 @@ validate-prereq: ## verify pre-requisites
182208
.PHONY: argo-healthcheck
183209
argo-healthcheck: ## Checks if all argo applications are synced
184210
@echo "Checking argo applications"
185-
$(eval APPS := $(shell oc get applications -A -o jsonpath='{range .items[*]}{@.metadata.namespace}{","}{@.metadata.name}{"\n"}{end}'))
211+
$(eval APPS := $(shell oc get applications.argoproj.io -A -o jsonpath='{range .items[*]}{@.metadata.namespace}{","}{@.metadata.name}{"\n"}{end}'))
186212
@NOTOK=0; \
187213
for i in $(APPS); do\
188214
n=`echo "$${i}" | cut -f1 -d,`;\
189215
a=`echo "$${i}" | cut -f2 -d,`;\
190-
STATUS=`oc get -n "$${n}" application/"$${a}" -o jsonpath='{.status.sync.status}'`;\
216+
STATUS=`oc get -n "$${n}" applications.argoproj.io/"$${a}" -o jsonpath='{.status.sync.status}'`;\
191217
if [[ $$STATUS != "Synced" ]]; then\
192218
NOTOK=$$(( $${NOTOK} + 1));\
193219
fi;\
194-
HEALTH=`oc get -n "$${n}" application/"$${a}" -o jsonpath='{.status.health.status}'`;\
220+
HEALTH=`oc get -n "$${n}" applications.argoproj.io/"$${a}" -o jsonpath='{.status.health.status}'`;\
195221
if [[ $$HEALTH != "Healthy" ]]; then\
196222
NOTOK=$$(( $${NOTOK} + 1));\
197223
fi;\
@@ -208,7 +234,7 @@ argo-healthcheck: ## Checks if all argo applications are synced
208234
.PHONY: qe-tests
209235
qe-tests: ## Runs the tests that QE runs
210236
@set -e; if [ -f ./tests/interop/run_tests.sh ]; then \
211-
./tests/interop/run_tests.sh; \
237+
pushd ./tests/interop; ./run_tests.sh; popd; \
212238
else \
213239
echo "No ./tests/interop/run_tests.sh found skipping"; \
214240
fi

common/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,16 @@ main:
3434
## Start Here
3535
3636
This repository is never used as standalone. It is usually imported in each pattern as a subtree.
37-
In order to import the common/ the very first time you can use
38-
`https://github.com/validatedpatterns/multicloud-gitops/blob/main/common/scripts/make_common_subtree.sh`
37+
In order to import the common subtree the very first time you can use the script
38+
[make_common_subtree.sh](scripts/make-common-subtree.sh).
3939
4040
In order to update your common subtree inside your pattern repository you can either use
4141
`https://github.com/validatedpatterns/utilities/blob/main/scripts/update-common-everywhere.sh` or
42-
do it manually by doing the following:
42+
do it manually with the following commands:
4343

4444
```sh
45-
git remote add -f upstream-common https://github.com/validatedpatterns/common.git
46-
git merge -s subtree -Xtheirs -Xsubtree=common upstream-common/main
45+
git remote add -f common-upstream https://github.com/validatedpatterns/common.git
46+
git merge -s subtree -Xtheirs -Xsubtree=common common-upstream/main
4747
```
4848

4949
## Secrets

common/scripts/argocd-login.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/usr/bin/env bash
2+
3+
## Login to validated patterns argocd instances
4+
5+
# Detect Argo CD namespaces
6+
ARGOCD_NAMESPACES=$(oc get argoCD -A -o jsonpath='{.items[*].metadata.namespace}')
7+
if [ -z "$ARGOCD_NAMESPACES" ]; then
8+
echo "Error: No Argo CD instances found in the cluster."
9+
exit 1
10+
fi
11+
12+
# Split the namespaces into an array
13+
NAMESPACES=($ARGOCD_NAMESPACES)
14+
15+
# Check if there are at least two Argo CD instances
16+
if [ ${#NAMESPACES[@]} -lt 2 ]; then
17+
echo "Error: Less than two Argo CD instances found. Found instances in namespaces: $ARGOCD_NAMESPACES"
18+
exit 1
19+
fi
20+
21+
22+
for NAMESPACE in ${NAMESPACES[@]}; do
23+
# get the instance name
24+
ARGOCD_INSTANCE=$(oc get argocd -n "$NAMESPACE" -o jsonpath='{.items[0].metadata.name}') # assume only one per NS
25+
SERVER_URL=$(oc get route "$ARGOCD_INSTANCE"-server -n "$NAMESPACE" -o jsonpath='{.status.ingress[0].host}')
26+
PASSWORD=$(oc get secret "$ARGOCD_INSTANCE"-cluster -n "$NAMESPACE" -o jsonpath='{.data.admin\.password}' | base64 -d)
27+
echo $PASSWORD
28+
argocd login --skip-test-tls --insecure --grpc-web "$SERVER_URL" --username "admin" --password "$PASSWORD"
29+
if [ "$?" -ne 0 ]; then
30+
echo "Login to Argo CD ${SERVER_URL} failed. Exiting."
31+
exit 1
32+
fi
33+
34+
done

0 commit comments

Comments
 (0)