From b30427d772d15f20f022056994ba2fe8765fd787 Mon Sep 17 00:00:00 2001 From: Juan Jose Medina Godoy Date: Fri, 23 Feb 2024 15:24:14 +0000 Subject: [PATCH] Move from CircleCI to GithubActions --- .circleci/config.yml | 89 --------------- .github/workflows/ci.yaml | 129 +++++++++++++++++++++ README.md | 2 - test/harbor/.env | 1 + test/harbor/config/core/app.conf | 6 + test/harbor/config/jobservice/config.yml | 41 +++++++ test/harbor/config/proxy/nginx.conf | 130 ++++++++++++++++++++++ test/harbor/config/registry/config.yml | 36 ++++++ test/harbor/config/registry/passwd | 1 + test/harbor/config/registryctl/config.yml | 9 ++ test/harbor/docker-compose.yml | 117 +++++++++++++++++++ test/install-ghost.sh | 10 +- test/kind-create-cluster.sh | 24 ++++ test/run-charts-syncer.sh | 2 +- test/run-verifications.sh | 7 +- test/test-config.yaml | 12 +- test/wait-for-ghost-deployment.sh | 6 +- 17 files changed, 514 insertions(+), 108 deletions(-) delete mode 100644 .circleci/config.yml create mode 100644 .github/workflows/ci.yaml create mode 100644 test/harbor/.env create mode 100644 test/harbor/config/core/app.conf create mode 100644 test/harbor/config/jobservice/config.yml create mode 100644 test/harbor/config/proxy/nginx.conf create mode 100644 test/harbor/config/registry/config.yml create mode 100644 test/harbor/config/registry/passwd create mode 100644 test/harbor/config/registryctl/config.yml create mode 100644 test/harbor/docker-compose.yml create mode 100644 test/kind-create-cluster.sh diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index c55847e2..00000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,89 +0,0 @@ -version: 2 - -## Definitions -install_helm_cli: &install_helm_cli - run: | - wget https://get.helm.sh/helm-v${HELM_VERSION}-linux-amd64.tar.gz - tar zxf helm-v${HELM_VERSION}-linux-amd64.tar.gz - sudo mv linux-amd64/helm /usr/local/bin/ -install_kubectl: &install_kubectl - run: | - curl -LO https://storage.googleapis.com/kubernetes-release/release/v${KUBECTL_VERSION}/bin/linux/amd64/kubectl - chmod +x kubectl - sudo mv kubectl /usr/local/bin/ -install_kind: &install_kind - run: | - curl -LO https://github.com/kubernetes-sigs/kind/releases/download/v${KIND_VERSION}/kind-Linux-amd64 - chmod +x kind-Linux-amd64 - sudo mv kind-Linux-amd64 /usr/local/bin/kind -install_chartmuseum: &install_chartmuseum - run: | - curl -LO https://get.helm.sh/chartmuseum-v${CHARTMUSEUM_VERSION}-linux-amd64.tar.gz - tar xzf chartmuseum-v${CHARTMUSEUM_VERSION}-linux-amd64.tar.gz - chmod a+x ./linux-amd64/chartmuseum - sudo mv ./linux-amd64/chartmuseum /usr/local/bin/ -install_wait_for_port: &install_wait_for_port - run: | - curl -LO https://github.com/bitnami/wait-for-port/releases/download/v1.0/wait-for-port.zip - unzip wait-for-port.zip - chmod +x wait-for-port - sudo mv wait-for-port /usr/local/bin/ -add_bitnami_helm: &add_bitnami_helm - run: | - helm repo add bitnami https://charts.bitnami.com/bitnami - helm repo update - -# Main workflow -workflows: - version: 2 - build_and_test: - jobs: - - build - - test: - requires: - - build - -# Jobs -jobs: - build: - docker: - - image: cimg/go:1.21 - steps: - - checkout - - run: make build - - run: go test ./... - # Persist compiled tool - - persist_to_workspace: - root: dist - paths: - - "*" - test: - machine: - image: ubuntu-2004:202201-02 - environment: - KIND_VERSION: "0.12.0" - KUBECTL_VERSION: "1.22.0" - HELM_VERSION: "3.8.1" - CHARTMUSEUM_VERSION: "0.16.0" - DEBUG_MODE: "true" - steps: - - checkout - - <<: *install_kind - - run: kind create cluster - - run: echo "export KUBECONFIG=$(kind get kubeconfig-path --name=kind)" >> $BASH_ENV - - <<: *install_chartmuseum - - <<: *install_kubectl - - <<: *install_wait_for_port - - <<: *install_helm_cli - - <<: *add_bitnami_helm - - run: - background: true - command: | - chartmuseum --basic-auth-user admin --basic-auth-pass dummypassword --storage local --storage-local-rootdir /tmp/chartstorage - # Attach workspace with compiled tool - - attach_workspace: - at: /tmp/dist - - run: ./test/run-charts-syncer.sh - - run: ./test/install-ghost.sh - - run: ./test/wait-for-ghost-deployment.sh - - run: ./test/run-verifications.sh diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 00000000..5adc9b66 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,129 @@ +name: CI +on: + workflow_dispatch: + push: + branches: + - v2 + pull_request: + branches: + - v2 + types: + - assigned + - opened + - synchronize + - reopened + +env: + KIND_VERSION: "0.12.0" + KUBECTL_VERSION: "1.22.0" + +jobs: + Validate: + runs-on: ubuntu-20.04 + steps: + - name: Checkout Code + uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3 + with: + fetch-depth: 0 + - name: Set Golang + uses: actions/setup-go@v4 + with: + go-version: 1.21 + + - name: Set Golangci-lint + run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.55.2 + + - name: Set Shellcheck + run: sudo apt-get -qq update && sudo apt-get install -y shellcheck + + - name: Verify scripts + run: | + shellcheck test/*.sh + + - name: Build + run: make build + - name: Lint + run: make test-style + + - name: Test + run: make test + + Build: + runs-on: ubuntu-20.04 + steps: + - name: Checkout Code + uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3 + with: + fetch-depth: 0 + - name: Set Golang + uses: actions/setup-go@v4 + with: + go-version: 1.21 + + - name: Build + run: make build + - uses: actions/upload-artifact@v4 + with: + name: charts-syncer-binary + path: dist/charts-syncer + + Integration: + needs: Build + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3 + with: + fetch-depth: 0 + - name: Get Harbor Local IP + run: | + echo "HARBOR_IP=$(hostname -I | cut -d" " -f1)" >> $GITHUB_ENV + - uses: actions/download-artifact@v4 + with: + name: charts-syncer-binary + path: /tmp/dist + - name: Install Kind + run: | + curl -LO https://github.com/kubernetes-sigs/kind/releases/download/v${KIND_VERSION}/kind-Linux-amd64 + chmod +x kind-Linux-amd64 + sudo mv kind-Linux-amd64 /usr/local/bin/kind + - name: Create kind cluster + run: | + ./test/kind-create-cluster.sh + echo "KUBECONFIG=$HOME/.kube/config" >> $GITHUB_ENV + - name: Set Helm + uses: azure/setup-helm@5119fcb9089d432beecbf79bb2c7915207344b78 # v3.5 + with: + version: v3.12.1 + - name: Run Registry + run: | + cd test/harbor + openssl genrsa -traditional -out private_key.pem 4096 + openssl req -new -x509 -key private_key.pem -out root.crt -days 3650 -subj "/C=CN/ST=State/L=CN/O=organization/OU=organizational unit/CN=example.com/emailAddress=example@example.com" + cp private_key.pem config/core/private_key.pem + cp root.crt config/registry/root.crt + echo "HARBOR_IP=$HARBOR_IP" >> .env.github + docker-compose --env-file .env.github config + docker-compose --env-file .env.github up -d + - name: Install Kubectl + run: | + curl -LO https://storage.googleapis.com/kubernetes-release/release/v${KUBECTL_VERSION}/bin/linux/amd64/kubectl + chmod +x kubectl + sudo mv kubectl /usr/local/bin + - name: Install wait-for-port + run: | + curl -LO https://github.com/bitnami/wait-for-port/releases/download/v1.0/wait-for-port.zip + unzip wait-for-port.zip + chmod +x wait-for-port + sudo mv wait-for-port /usr/local/bin/ + + - name: Add bitnami Helm + run: | + helm repo add bitnami https://charts.bitnami.com/bitnami + helm repo update + - run: | + chmod +x /tmp/dist/charts-syncer + ./test/run-charts-syncer.sh + - run: ./test/install-ghost.sh + - run: ./test/wait-for-ghost-deployment.sh + - run: ./test/run-verifications.sh diff --git a/README.md b/README.md index 8d5d64db..49892af3 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,3 @@ -[![CircleCI](https://circleci.com/gh/bitnami/charts-syncer.svg?style=svg&circle-token=91105ed254723ef1e3af739f6d31dc845136828c)](https://circleci.com/gh/bitnami/charts-syncer/tree/master) - # charts-syncer Sync chart packages and associated container images between chart repositories diff --git a/test/harbor/.env b/test/harbor/.env new file mode 100644 index 00000000..a84bfe08 --- /dev/null +++ b/test/harbor/.env @@ -0,0 +1 @@ +HARBOR_IP=localhost diff --git a/test/harbor/config/core/app.conf b/test/harbor/config/core/app.conf new file mode 100644 index 00000000..6110364c --- /dev/null +++ b/test/harbor/config/core/app.conf @@ -0,0 +1,6 @@ +appname = Harbor +runmode = dev +enablegzip = true + +[dev] +httpport = 8080 diff --git a/test/harbor/config/jobservice/config.yml b/test/harbor/config/jobservice/config.yml new file mode 100644 index 00000000..a575ce71 --- /dev/null +++ b/test/harbor/config/jobservice/config.yml @@ -0,0 +1,41 @@ +--- +#Protocol used to serve +protocol: "http" + +#Config certification if use 'https' protocol +#https_config: +# cert: "server.crt" +# key: "server.key" + +#Server listening port +port: 8080 + +#Worker pool +worker_pool: + #Worker concurrency + workers: 10 + backend: "redis" + #Additional config if use 'redis' backend + redis_pool: + #redis://[arbitrary_username:password@]ipaddress:port/database_index + redis_url: redis://redis:6379/2 + namespace: "harbor_job_service_namespace" +#Loggers for the running job +job_loggers: + - name: "STD_OUTPUT" # logger backend name, only support "FILE" and "STD_OUTPUT" + level: "INFO" # INFO/DEBUG/WARNING/ERROR/FATAL + - name: "FILE" + level: "INFO" + settings: # Customized settings of logger + base_dir: "/var/log/jobs" + sweeper: + duration: 1 #days + settings: # Customized settings of sweeper + work_dir: "/var/log/jobs" + +#Loggers for the job service +loggers: + - name: "STD_OUTPUT" # Same with above + level: "INFO" +#Admin server endpoint +admin_server: "http://adminserver:8080/" diff --git a/test/harbor/config/proxy/nginx.conf b/test/harbor/config/proxy/nginx.conf new file mode 100644 index 00000000..833c54cf --- /dev/null +++ b/test/harbor/config/proxy/nginx.conf @@ -0,0 +1,130 @@ +worker_processes auto; +error_log "/opt/bitnami/nginx/logs/error.log"; +pid "/opt/bitnami/nginx/tmp/nginx.pid"; + +events { + worker_connections 1024; + use epoll; + multi_accept on; +} + +http { + tcp_nodelay on; + + # this is necessary for us to be able to disable request buffering in all cases + proxy_http_version 1.1; + + upstream core { + server core:8080; + } + + upstream portal { + server portal:8080; + } + + log_format timed_combined '$remote_addr - ' + '"$request" $status $body_bytes_sent ' + '"$http_referer" "$http_user_agent" ' + '$request_time $upstream_response_time $pipe'; + + client_body_temp_path "/opt/bitnami/nginx/tmp/client_body" 1 2; + proxy_temp_path "/opt/bitnami/nginx/tmp/proxy" 1 2; + fastcgi_temp_path "/opt/bitnami/nginx/tmp/fastcgi" 1 2; + scgi_temp_path "/opt/bitnami/nginx/tmp/scgi" 1 2; + uwsgi_temp_path "/opt/bitnami/nginx/tmp/uwsgi" 1 2; + + server { + listen 8080; + server_tokens off; + # disable any limits to avoid HTTP 413 for large image uploads + client_max_body_size 0; + + # costumized location config file can place to /opt/bitnami/nginx/conf with prefix harbor.http. and suffix .conf + include /opt/bitnami/conf/nginx/conf.d/harbor.http.*.conf; + + location / { + proxy_pass http://portal/; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + + # When setting up Harbor behind other proxy, such as an Nginx instance, remove the below line if the proxy already has similar settings. + proxy_set_header X-Forwarded-Proto $scheme; + + proxy_buffering off; + proxy_request_buffering off; + } + + location /c/ { + proxy_pass http://core/c/; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + + # When setting up Harbor behind other proxy, such as an Nginx instance, remove the below line if the proxy already has similar settings. + proxy_set_header X-Forwarded-Proto $scheme; + + proxy_buffering off; + proxy_request_buffering off; + } + + location /api/ { + proxy_pass http://core/api/; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + + # When setting up Harbor behind other proxy, such as an Nginx instance, remove the below line if the proxy already has similar settings. + proxy_set_header X-Forwarded-Proto $scheme; + + proxy_buffering off; + proxy_request_buffering off; + } + + location /chartrepo/ { + proxy_pass http://core/chartrepo/; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + + # When setting up Harbor behind other proxy, such as an Nginx instance, remove the below line if the proxy already has similar settings. + proxy_set_header X-Forwarded-Proto $scheme; + + proxy_buffering off; + proxy_request_buffering off; + } + + location /v1/ { + return 404; + } + + location /v2/ { + proxy_pass http://core/v2/; + proxy_set_header Host $http_host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + + # When setting up Harbor behind other proxy, such as an Nginx instance, remove the below line if the proxy already has similar settings. + proxy_set_header X-Forwarded-Proto $scheme; + proxy_buffering off; + proxy_request_buffering off; + } + + location /service/ { + proxy_pass http://core/service/; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + + # When setting up Harbor behind other proxy, such as an Nginx instance, remove the below line if the proxy already has similar settings. + proxy_set_header X-Forwarded-Proto $scheme; + + proxy_buffering off; + proxy_request_buffering off; + } + + location /service/notifications { + return 404; + } + } +} diff --git a/test/harbor/config/registry/config.yml b/test/harbor/config/registry/config.yml new file mode 100644 index 00000000..e4e99a79 --- /dev/null +++ b/test/harbor/config/registry/config.yml @@ -0,0 +1,36 @@ +version: 0.1 +log: + level: info + fields: + service: registry +storage: + cache: + layerinfo: redis + filesystem: + rootdirectory: /storage + maintenance: + uploadpurging: + enabled: false + delete: + enabled: true +redis: + addr: redis:6379 + password: + db: 1 +http: + addr: :5000 + secret: placeholder + debug: + addr: localhost:5001 +auth: + htpasswd: + realm: harbor-registry-basic-realm + path: /etc/registry/passwd +notifications: + endpoints: + - name: harbor + disabled: false + url: http://core:8080/service/notifications + timeout: 3000ms + threshold: 5 + backoff: 1s diff --git a/test/harbor/config/registry/passwd b/test/harbor/config/registry/passwd new file mode 100644 index 00000000..bec5ef97 --- /dev/null +++ b/test/harbor/config/registry/passwd @@ -0,0 +1 @@ +harbor_registry_user:$2y$10$9L4Tc0DJbFFMB6RdSCunrOpTHdwhid4ktBJmLD00bYgqkkGOvll3m \ No newline at end of file diff --git a/test/harbor/config/registryctl/config.yml b/test/harbor/config/registryctl/config.yml new file mode 100644 index 00000000..636f674b --- /dev/null +++ b/test/harbor/config/registryctl/config.yml @@ -0,0 +1,9 @@ +--- +protocol: "http" +port: 8080 +log_level: "INFO" +registry_config: "/etc/registry/config.yml" + +#https_config: +# cert: "server.crt" +# key: "server.key" diff --git a/test/harbor/docker-compose.yml b/test/harbor/docker-compose.yml new file mode 100644 index 00000000..da73019c --- /dev/null +++ b/test/harbor/docker-compose.yml @@ -0,0 +1,117 @@ +# Copyright VMware, Inc. +# SPDX-License-Identifier: APACHE-2.0 + +version: '2' + +services: + registry: + image: docker.io/bitnami/harbor-registry:2 + environment: + - REGISTRY_HTTP_SECRET=CHANGEME + volumes: + - registry_data:/storage + - ./config/registry/:/etc/registry/:ro + registryctl: + image: docker.io/bitnami/harbor-registryctl:2 + environment: + - CORE_SECRET=CHANGEME + - JOBSERVICE_SECRET=CHANGEME + - REGISTRY_HTTP_SECRET=CHANGEME + volumes: + - registry_data:/storage + - ./config/registry/:/etc/registry/:ro + - ./config/registryctl/config.yml:/etc/registryctl/config.yml:ro + postgresql: + image: docker.io/bitnami/postgresql:13 + container_name: harbor-db + environment: + - POSTGRESQL_PASSWORD=dummypassword + - POSTGRESQL_DATABASE=registry + volumes: + - postgresql_data:/bitnami/postgresql + core: + image: docker.io/bitnami/harbor-core:2 + container_name: harbor-core + depends_on: + - registry + environment: + - CORE_KEY=change-this-key + - _REDIS_URL_CORE=redis://redis:6379/0 + - SYNC_REGISTRY=false + - CHART_CACHE_DRIVER=redis + - _REDIS_URL_REG=redis://redis:6379/1 + - PORT=8080 + - LOG_LEVEL=info + - EXT_ENDPOINT=http://${HARBOR_IP}:8080 + - DATABASE_TYPE=postgresql + - REGISTRY_CONTROLLER_URL=http://registryctl:8080 + - POSTGRESQL_HOST=postgresql + - POSTGRESQL_PORT=5432 + - POSTGRESQL_DATABASE=registry + - POSTGRESQL_USERNAME=postgres + - POSTGRESQL_PASSWORD=dummypassword + - POSTGRESQL_SSLMODE=disable + - REGISTRY_URL=http://registry:5000 + - TOKEN_SERVICE_URL=http://core:8080/service/token + - HARBOR_ADMIN_PASSWORD=dummypassword + - CORE_SECRET=CHANGEME + - JOBSERVICE_SECRET=CHANGEME + - ADMIRAL_URL= + - CORE_URL=http://core:8080 + - JOBSERVICE_URL=http://jobservice:8080 + - REGISTRY_STORAGE_PROVIDER_NAME=filesystem + - REGISTRY_CREDENTIAL_USERNAME=harbor_registry_user + - REGISTRY_CREDENTIAL_PASSWORD=harbor_registry_password + - READ_ONLY=false + - RELOAD_KEY= + volumes: + - core_data:/data + - ./config/core/app.conf:/etc/core/app.conf:ro + - ./config/core/private_key.pem:/etc/core/private_key.pem:ro + portal: + image: docker.io/bitnami/harbor-portal:2 + container_name: harbor-portal + depends_on: + - core + jobservice: + image: docker.io/bitnami/harbor-jobservice:2 + container_name: harbor-jobservice + depends_on: + - redis + - core + environment: + - CORE_SECRET=CHANGEME + - JOBSERVICE_SECRET=CHANGEME + - CORE_URL=http://core:8080 + - REGISTRY_CONTROLLER_URL=http://registryctl:8080 + - REGISTRY_CREDENTIAL_USERNAME=harbor_registry_user + - REGISTRY_CREDENTIAL_PASSWORD=harbor_registry_password + volumes: + - jobservice_data:/var/log/jobs + - ./config/jobservice/config.yml:/etc/jobservice/config.yml:ro + redis: + image: docker.io/bitnami/redis:7.0 + environment: + # ALLOW_EMPTY_PASSWORD is recommended only for development. + - ALLOW_EMPTY_PASSWORD=yes + harbor-nginx: + image: docker.io/bitnami/nginx:1.25 + container_name: nginx + volumes: + - ./config/proxy/nginx.conf:/opt/bitnami/nginx/conf/nginx.conf:ro + ports: + - '8080:8080' + depends_on: + - postgresql + - registry + - core + - portal +volumes: + registry_data: + driver: local + core_data: + driver: local + jobservice_data: + driver: local + postgresql_data: + driver: local diff --git a/test/install-ghost.sh b/test/install-ghost.sh index 942f49da..bdd434fd 100755 --- a/test/install-ghost.sh +++ b/test/install-ghost.sh @@ -1,10 +1,10 @@ #!/usr/bin/env bash +set -x set -o nounset set -o pipefail -helm repo remove target || true -helm repo add target http://127.0.0.1:8080 --username admin --password dummypassword -helm repo update -helm search repo target/ghost -helm install --wait ghost-test target/ghost --set ghostHost=127.0.0.1 --set service.type=ClusterIP +helm install --username admin --password dummypassword --wait ghost-test oci://127.0.0.1:8080/library/ghost --set ghostHost=127.0.0.1 --set service.type=ClusterIP + + + diff --git a/test/kind-create-cluster.sh b/test/kind-create-cluster.sh new file mode 100644 index 00000000..373c3339 --- /dev/null +++ b/test/kind-create-cluster.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +set -o nounset +set -o pipefail + +reg_port=8080 +reg_name=${HARBOR_IP:-${1:?Missing harbor ip}} + +cat </dev/null && pwd)" ## Wait for chartmuseum service (Timeout in 30s) wait-for-port --state=inuse 8080 -/tmp/dist/charts-syncer --config ${ROOT_DIR}/test/test-config.yaml sync --latest-version-only +/tmp/dist/charts-syncer --config "${ROOT_DIR}/test/test-config.yaml" sync --latest-version-only --insecure --use-plain-http diff --git a/test/run-verifications.sh b/test/run-verifications.sh index f77fa57c..054cff64 100755 --- a/test/run-verifications.sh +++ b/test/run-verifications.sh @@ -5,13 +5,12 @@ set -o nounset set -o pipefail # Constants -ROOT_DIR="$(cd "$( dirname "${BASH_SOURCE[0]}" )/.." >/dev/null && pwd)" FAILED_TEST=0 -EXPECTED_REGISTRY='docker.io/bitnami' +EXPECTED_REGISTRY='localhost:8080/library/bitnami' ## Check that Ghost deployment is using the expected registry ghostImage=$(kubectl get pods --selector=app.kubernetes.io/name=ghost -ojsonpath='{.items[0].spec.containers[0].image}') -if [[ "${ghostImage}" =~ "${EXPECTED_REGISTRY}" ]]; then +if [[ "${ghostImage}" =~ ${EXPECTED_REGISTRY} ]]; then echo "[PASS] Ghost is using the expected registry: ${EXPECTED_REGISTRY}" else echo "[FAILED] Ghost is not using the expected registry. Got: \"${ghostImage}\", expected: \"${EXPECTED_REGISTRY}\"" @@ -20,7 +19,7 @@ fi ## Check that MySQL deployment is using the expected registry mysqlImage=$(kubectl get pods --selector=statefulset.kubernetes.io/pod-name=ghost-test-mysql-0 -ojsonpath='{.items[0].spec.containers[0].image}') -if [[ "${mysqlImage}" =~ "${EXPECTED_REGISTRY}" ]]; then +if [[ "${mysqlImage}" =~ ${EXPECTED_REGISTRY} ]]; then echo "[PASS] MySQL is using the expected registry: ${EXPECTED_REGISTRY}" else echo "[FAILED] MySQL is not using the expected registry. Got: \"${mysqlImage}\", expected: \"${EXPECTED_REGISTRY}\"" diff --git a/test/test-config.yaml b/test/test-config.yaml index f71dfb41..be2d7516 100644 --- a/test/test-config.yaml +++ b/test/test-config.yaml @@ -6,13 +6,17 @@ source: kind: "HELM" url: "https://charts.bitnami.com/bitnami" target: - containerRegistry: "docker.io" - containerRepository: "bitnami" + containers: + auth: + username: admin + password: dummypassword + repo: - kind: "CHARTMUSEUM" - url: "http://127.0.0.1:8080" + kind: "OCI" + url: "http://localhost:8080/library" auth: username: "admin" password: "dummypassword" + charts: - ghost diff --git a/test/wait-for-ghost-deployment.sh b/test/wait-for-ghost-deployment.sh index f14c89de..286d5b20 100755 --- a/test/wait-for-ghost-deployment.sh +++ b/test/wait-for-ghost-deployment.sh @@ -20,8 +20,8 @@ wait_for_string_in_pod() { local -r sleep_time="${5:-5}" for ((i = 1 ; i <= retries ; i+=1 )); do - matches=$(kubectl logs ${pod} | grep "${string}" | wc -l) - if [ ${matches} -ge ${repetitions} ]; then + matches=$(kubectl logs "${pod}" | grep -c "${string}") + if [ "${matches}" -ge "${repetitions}" ]; then break fi sleep "$sleep_time" @@ -30,6 +30,6 @@ wait_for_string_in_pod() { ## Wait until Ghost is up and running ghostPod=$(kubectl get pods --selector=app.kubernetes.io/name=ghost -ojsonpath='{.items[0].metadata.name}') -wait_for_string_in_pod ${ghostPod} "Your site is now available on" 2 +wait_for_string_in_pod "${ghostPod}" "Your site is now available on" 2 # Even after printing that message in the log, the service is not available yet sleep 5