This is an automated email from the ASF dual-hosted git repository. astefanutti pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel-k.git
commit e32d557334bc2e103cd00ce69774e12d56c59c3c Author: phantomjinx <[email protected]> AuthorDate: Mon Dec 6 19:35:58 2021 +0000 Remove any credential leakage in the log output * Discontinue using json-to-variables and converted secret to simple key-value list * Converts all environment variables into inputs and outputs as these are not logged * Creates bash scripts that are called from run: calls as these scripts do not get logged and set-output and set-mask can be used without leakage --- .github/actions/e2e-builder/action.yml | 34 ++-- .github/actions/e2e-knative-yaks/action.yml | 34 ++-- .github/actions/e2e-knative/action.yml | 34 ++-- .github/actions/e2e-kubernetes/action.yml | 34 ++-- .github/actions/e2e-upgrade/action.yml | 35 +++-- .github/actions/json-to-variables | 1 - .github/actions/kamel-build-binary/action.yml | 14 +- .github/actions/kamel-build-bundle/action.yaml | 28 +++- .github/actions/kamel-build/action.yml | 21 ++- .github/actions/kamel-cleanup/action.yaml | 11 +- .../actions/kamel-config-cluster-custom/action.yml | 175 ++++----------------- .../kamel-config-cluster-custom/connect-cluster.sh | 142 +++++++++++++++++ .../actions/kamel-config-cluster-kind/action.yml | 49 +++--- .../kamel-config-cluster-kind/extract-config.sh | 51 ++++++ .../actions/kamel-config-cluster-ocp3/action.yml | 57 +++++-- .github/actions/kamel-config-cluster/action.yaml | 84 ++++++++-- .../actions/kamel-config-cluster/output-config.sh | 81 ++++++++++ .github/actions/kamel-prepare-env/action.yml | 3 - .github/workflows/builder.yml | 1 + .github/workflows/knative.yml | 2 + .github/workflows/kubernetes.yml | 1 + .github/workflows/openshift.yml | 24 +-- .github/workflows/upgrade.yml | 1 + .gitmodules | 4 - config/rbac/operator-role.yaml | 21 --- 25 files changed, 631 insertions(+), 311 deletions(-) diff --git a/.github/actions/e2e-builder/action.yml b/.github/actions/e2e-builder/action.yml index caeff37..a4e814b 100644 --- a/.github/actions/e2e-builder/action.yml +++ b/.github/actions/e2e-builder/action.yml @@ -22,6 +22,9 @@ inputs: cluster-config-data: description: 'The configuration of the underlying cluster (if cluster-type is custom)' required: false + cluster-kube-config-data: + description: 'Base16 encoded kube config - required for custom cluster type only' + required: false publisher: description: 'The publishing strategy to be used' required: true @@ -34,30 +37,31 @@ runs: name: Prepare Test Environment uses: ./.github/actions/kamel-prepare-env - - id: configure-cluster + - id: config-cluster name: Configure Platform uses: ./.github/actions/kamel-config-cluster with: cluster-type: ${{ env.TEST_CLUSTER }} cluster-config-data: ${{ inputs.cluster-config-data }} + cluster-kube-config-data: ${{ inputs.cluster-kube-config-data }} - id: build-kamel name: Build Kamel uses: ./.github/actions/kamel-build with: - image-registry-push-host: ${{ env.CLUSTER_IMAGE_REGISTRY_PUSH_HOST }} - image-registry-pull-host: ${{ env.CLUSTER_IMAGE_REGISTRY_PULL_HOST }} - image-namespace: ${{ env.CLUSTER_IMAGE_NAMESPACE }} + image-registry-push-host: ${{ steps.config-cluster.outputs.cluster-image-registry-push-host }} + image-registry-pull-host: ${{ steps.config-cluster.outputs.cluster-image-registry-pull-host }} + image-namespace: ${{ steps.config-cluster.outputs.cluster-image-namespace }} # Builds the bundle if an OLM is available - depends on cluster being tested - build-bundle: ${{ env.CLUSTER_HAS_OLM }} + build-bundle: ${{ steps.config-cluster.outputs.cluster-has-olm }} # Can be empty and so catalog source will not be created - catalog-source-namespace: ${{ env.CLUSTER_CATALOG_SOURCE_NAMESPACE }} + catalog-source-namespace: ${{ steps.config-cluster.outputs.cluster-catalog-source-namespace }} - id: install-kamel-cluster-setup name: Install Kamel Cluster Setup uses: ./.github/actions/kamel-install-cluster-setup with: - kube-admin-user-ctx: ${{ env.CLUSTER_KUBE_ADMIN_USER_CTX }} + kube-admin-user-ctx: ${{ steps.config-cluster.outputs.cluster-kube-admin-user-ctx }} - id: run-it name: Run IT @@ -66,19 +70,19 @@ runs: KAMEL_INSTALL_BUILD_PUBLISH_STRATEGY: ${{ inputs.publisher }} run: | # Cluster environment - export CUSTOM_IMAGE=${{ env.BUILD_BINARY_LOCAL_IMAGE_NAME }} - export CUSTOM_VERSION=${{ env.BUILD_BINARY_LOCAL_IMAGE_VERSION }} + export CUSTOM_IMAGE=${{ steps.build-kamel.outputs.build-binary-local-image-name }} + export CUSTOM_VERSION=${{ steps.build-kamel.outputs.build-binary-local-image-version }} # # If bundle has been built and installed then use it # - if [ -n "${{ env.BUILD_BUNDLE_CATALOG_SOURCE }}" ]; then - export KAMEL_INSTALL_OLM_SOURCE_NAMESPACE=${{ env.CLUSTER_IMAGE_NAMESPACE }} - export KAMEL_INSTALL_OLM_SOURCE=${{ env.BUILD_BUNDLE_CATALOG_SOURCE }} + if [ -n "${{ steps.build-kamel.outputs.build-bundle-catalog-source-name }}" ]; then + export KAMEL_INSTALL_OLM_SOURCE_NAMESPACE=${{ steps.config-cluster.outputs.cluster-image-namespace }} + export KAMEL_INSTALL_OLM_SOURCE=${{ steps.build-kamel.outputs.build-bundle-catalog-source-name }} fi - export KAMEL_INSTALL_REGISTRY=${{ env.CLUSTER_IMAGE_REGISTRY_PULL_HOST }} - export KAMEL_INSTALL_REGISTRY_INSECURE=${{ env.CLUSTER_IMAGE_REGISTRY_INSECURE }} + export KAMEL_INSTALL_REGISTRY=${{ steps.config-cluster.outputs.cluster-image-registry-pull-host }} + export KAMEL_INSTALL_REGISTRY_INSECURE=${{steps.config-cluster.outputs.cluster-image-registry-insecure }} export KAMEL_INSTALL_OPERATOR_IMAGE=${CUSTOM_IMAGE}:${CUSTOM_VERSION} export CAMEL_K_TEST_IMAGE_NAME=${CUSTOM_IMAGE} export CAMEL_K_TEST_IMAGE_VERSION=${CUSTOM_VERSION} @@ -90,3 +94,5 @@ runs: - name: Cleanup uses: ./.github/actions/kamel-cleanup if: ${{ always() }} + with: + build-bundle-catalog-source: ${{ steps.build-kamel.outputs.build-bundle-catalog-source-name }} diff --git a/.github/actions/e2e-knative-yaks/action.yml b/.github/actions/e2e-knative-yaks/action.yml index fc95dad..df367ae 100644 --- a/.github/actions/e2e-knative-yaks/action.yml +++ b/.github/actions/e2e-knative-yaks/action.yml @@ -22,6 +22,9 @@ inputs: cluster-config-data: description: 'The configuration of the underlying cluster (if cluster-type is custom)' required: false + cluster-kube-config-data: + description: 'Base16 encoded kube config - required for custom cluster type only' + required: false runs: using: "composite" @@ -31,12 +34,13 @@ runs: name: Prepare Test Environment uses: ./.github/actions/kamel-prepare-env - - id: configure-cluster + - id: config-cluster name: Configure Platform uses: ./.github/actions/kamel-config-cluster with: cluster-type: ${{ env.TEST_CLUSTER }} cluster-config-data: ${{ inputs.cluster-config-data }} + cluster-kube-config-data: ${{ inputs.cluster-kube-config-data }} - name: Install YAKS uses: ./.github/actions/kamel-install-yaks @@ -48,38 +52,38 @@ runs: name: Build Kamel uses: ./.github/actions/kamel-build with: - image-registry-push-host: ${{ env.CLUSTER_IMAGE_REGISTRY_PUSH_HOST }} - image-registry-pull-host: ${{ env.CLUSTER_IMAGE_REGISTRY_PULL_HOST }} - image-namespace: ${{ env.CLUSTER_IMAGE_NAMESPACE }} + image-registry-push-host: ${{ steps.config-cluster.outputs.cluster-image-registry-push-host }} + image-registry-pull-host: ${{ steps.config-cluster.outputs.cluster-image-registry-pull-host }} + image-namespace: ${{ steps.config-cluster.outputs.cluster-image-namespace }} # Builds the bundle if an OLM is available - depends on cluster being tested - build-bundle: ${{ env.CLUSTER_HAS_OLM }} + build-bundle: ${{ steps.config-cluster.outputs.cluster-has-olm }} # Can be empty and so catalog source will not be created - catalog-source-namespace: ${{ env.CLUSTER_CATALOG_SOURCE_NAMESPACE }} + catalog-source-namespace: ${{ steps.config-cluster.outputs.cluster-catalog-source-namespace }} - id: install-kamel-cluster-setup name: Install Kamel Cluster Setup uses: ./.github/actions/kamel-install-cluster-setup with: - kube-admin-user-ctx: ${{ env.CLUSTER_KUBE_ADMIN_USER_CTX }} + kube-admin-user-ctx: ${{ steps.config-cluster.outputs.cluster-kube-admin-user-ctx }} - id: run-it name: Run IT shell: bash run: | # Cluster environment - export CUSTOM_IMAGE=${{ env.BUILD_BINARY_LOCAL_IMAGE_NAME }} - export CUSTOM_VERSION=${{ env.BUILD_BINARY_LOCAL_IMAGE_VERSION }} + export CUSTOM_IMAGE=${{ steps.build-kamel.outputs.build-binary-local-image-name }} + export CUSTOM_VERSION=${{ steps.build-kamel.outputs.build-binary-local-image-version }} # # If bundle has been built and installed then use it # - if [ -n "${{ env.BUILD_BUNDLE_CATALOG_SOURCE }}" ]; then - export KAMEL_INSTALL_OLM_SOURCE_NAMESPACE=${{ env.CLUSTER_IMAGE_NAMESPACE }} - export KAMEL_INSTALL_OLM_SOURCE=${{ env.BUILD_BUNDLE_CATALOG_SOURCE }} + if [ -n "${{ steps.build-kamel.outputs.build-bundle-catalog-source-name }}" ]; then + export KAMEL_INSTALL_OLM_SOURCE_NAMESPACE=${{ steps.config-cluster.outputs.cluster-image-namespace }} + export KAMEL_INSTALL_OLM_SOURCE=${{ steps.build-kamel.outputs.build-bundle-catalog-source-name }} fi - export KAMEL_INSTALL_REGISTRY=${{ env.CLUSTER_IMAGE_REGISTRY_PULL_HOST }} - export KAMEL_INSTALL_REGISTRY_INSECURE=${{ env.CLUSTER_IMAGE_REGISTRY_INSECURE }} + export KAMEL_INSTALL_REGISTRY=${{ steps.config-cluster.outputs.cluster-image-registry-pull-host }} + export KAMEL_INSTALL_REGISTRY_INSECURE=${{steps.config-cluster.outputs.cluster-image-registry-insecure }} export KAMEL_INSTALL_OPERATOR_IMAGE=${CUSTOM_IMAGE}:${CUSTOM_VERSION} export CAMEL_K_TEST_IMAGE_NAME=${CUSTOM_IMAGE} export CAMEL_K_TEST_IMAGE_VERSION=${CUSTOM_VERSION} @@ -98,3 +102,5 @@ runs: - name: Cleanup uses: ./.github/actions/kamel-cleanup if: ${{ always() }} + with: + build-bundle-catalog-source: ${{ steps.build-kamel.outputs.build-bundle-catalog-source-name }} diff --git a/.github/actions/e2e-knative/action.yml b/.github/actions/e2e-knative/action.yml index a1af033..ce3658a 100644 --- a/.github/actions/e2e-knative/action.yml +++ b/.github/actions/e2e-knative/action.yml @@ -22,6 +22,9 @@ inputs: cluster-config-data: description: 'The configuration of the underlying cluster (if cluster-type is custom)' required: false + cluster-kube-config-data: + description: 'Base16 encoded kube config - required for custom cluster type only' + required: false runs: using: "composite" @@ -31,12 +34,13 @@ runs: name: Prepare Test Environment uses: ./.github/actions/kamel-prepare-env - - id: configure-cluster + - id: config-cluster name: Configure Platform uses: ./.github/actions/kamel-config-cluster with: cluster-type: ${{ env.TEST_CLUSTER }} cluster-config-data: ${{ inputs.cluster-config-data }} + cluster-kube-config-data: ${{ inputs.cluster-kube-config-data }} - name: Install Knative uses: ./.github/actions/kamel-install-knative @@ -45,38 +49,38 @@ runs: name: Build Kamel uses: ./.github/actions/kamel-build with: - image-registry-push-host: ${{ env.CLUSTER_IMAGE_REGISTRY_PUSH_HOST }} - image-registry-pull-host: ${{ env.CLUSTER_IMAGE_REGISTRY_PULL_HOST }} - image-namespace: ${{ env.CLUSTER_IMAGE_NAMESPACE }} + image-registry-push-host: ${{ steps.config-cluster.outputs.cluster-image-registry-push-host }} + image-registry-pull-host: ${{ steps.config-cluster.outputs.cluster-image-registry-pull-host }} + image-namespace: ${{ steps.config-cluster.outputs.cluster-image-namespace }} # Builds the bundle if an OLM is available - depends on cluster being tested - build-bundle: ${{ env.CLUSTER_HAS_OLM }} + build-bundle: ${{ steps.config-cluster.outputs.cluster-has-olm }} # Can be empty and so catalog source will not be created - catalog-source-namespace: ${{ env.CLUSTER_CATALOG_SOURCE_NAMESPACE }} + catalog-source-namespace: ${{ steps.config-cluster.outputs.cluster-catalog-source-namespace }} - id: install-kamel-cluster-setup name: Install Kamel Cluster Setup uses: ./.github/actions/kamel-install-cluster-setup with: - kube-admin-user-ctx: ${{ env.CLUSTER_KUBE_ADMIN_USER_CTX }} + kube-admin-user-ctx: ${{ steps.config-cluster.outputs.cluster-kube-admin-user-ctx }} - id: run-it name: Run IT shell: bash run: | # Cluster environment - export CUSTOM_IMAGE=${{ env.BUILD_BINARY_LOCAL_IMAGE_NAME }} - export CUSTOM_VERSION=${{ env.BUILD_BINARY_LOCAL_IMAGE_VERSION }} + export CUSTOM_IMAGE=${{ steps.build-kamel.outputs.build-binary-local-image-name }} + export CUSTOM_VERSION=${{ steps.build-kamel.outputs.build-binary-local-image-version }} # # If bundle has been built and installed then use it # - if [ -n "${{ env.BUILD_BUNDLE_CATALOG_SOURCE }}" ]; then - export KAMEL_INSTALL_OLM_SOURCE_NAMESPACE=${{ env.CLUSTER_IMAGE_NAMESPACE }} - export KAMEL_INSTALL_OLM_SOURCE=${{ env.BUILD_BUNDLE_CATALOG_SOURCE }} + if [ -n "${{ steps.build-kamel.outputs.build-bundle-catalog-source-name }}" ]; then + export KAMEL_INSTALL_OLM_SOURCE_NAMESPACE=${{ steps.config-cluster.outputs.cluster-image-namespace }} + export KAMEL_INSTALL_OLM_SOURCE=${{ steps.build-kamel.outputs.build-bundle-catalog-source-name }} fi - export KAMEL_INSTALL_REGISTRY=${{ env.CLUSTER_IMAGE_REGISTRY_PULL_HOST }} - export KAMEL_INSTALL_REGISTRY_INSECURE=${{ env.CLUSTER_IMAGE_REGISTRY_INSECURE }} + export KAMEL_INSTALL_REGISTRY=${{ steps.config-cluster.outputs.cluster-image-registry-pull-host }} + export KAMEL_INSTALL_REGISTRY_INSECURE=${{steps.config-cluster.outputs.cluster-image-registry-insecure }} export KAMEL_INSTALL_OPERATOR_IMAGE=${CUSTOM_IMAGE}:${CUSTOM_VERSION} export CAMEL_K_TEST_IMAGE_NAME=${CUSTOM_IMAGE} export CAMEL_K_TEST_IMAGE_VERSION=${CUSTOM_VERSION} @@ -92,3 +96,5 @@ runs: - name: Cleanup uses: ./.github/actions/kamel-cleanup if: ${{ always() }} + with: + build-bundle-catalog-source: ${{ steps.build-kamel.outputs.build-bundle-catalog-source-name }} diff --git a/.github/actions/e2e-kubernetes/action.yml b/.github/actions/e2e-kubernetes/action.yml index c3ee22f..6dfde05 100644 --- a/.github/actions/e2e-kubernetes/action.yml +++ b/.github/actions/e2e-kubernetes/action.yml @@ -22,6 +22,9 @@ inputs: cluster-config-data: description: 'The configuration of the underlying cluster (if cluster-type is custom)' required: false + cluster-kube-config-data: + description: 'Base16 encoded kube config - required for custom cluster type only' + required: false runs: using: "composite" @@ -31,50 +34,51 @@ runs: name: Prepare Test Environment uses: ./.github/actions/kamel-prepare-env - - id: configure-cluster + - id: config-cluster name: Configure Platform uses: ./.github/actions/kamel-config-cluster with: cluster-type: ${{ env.TEST_CLUSTER }} cluster-config-data: ${{ inputs.cluster-config-data }} + cluster-kube-config-data: ${{ inputs.cluster-kube-config-data }} - id: build-kamel name: Build Kamel uses: ./.github/actions/kamel-build with: - image-registry-push-host: ${{ env.CLUSTER_IMAGE_REGISTRY_PUSH_HOST }} - image-registry-pull-host: ${{ env.CLUSTER_IMAGE_REGISTRY_PULL_HOST }} - image-namespace: ${{ env.CLUSTER_IMAGE_NAMESPACE }} + image-registry-push-host: ${{ steps.config-cluster.outputs.cluster-image-registry-push-host }} + image-registry-pull-host: ${{ steps.config-cluster.outputs.cluster-image-registry-pull-host }} + image-namespace: ${{ steps.config-cluster.outputs.cluster-image-namespace }} # Builds the bundle if an OLM is available - depends on cluster being tested - build-bundle: ${{ env.CLUSTER_HAS_OLM }} + build-bundle: ${{ steps.config-cluster.outputs.cluster-has-olm }} # Can be empty and so catalog source will not be created - catalog-source-namespace: ${{ env.CLUSTER_CATALOG_SOURCE_NAMESPACE }} + catalog-source-namespace: ${{ steps.config-cluster.outputs.cluster-catalog-source-namespace }} - id: install-kamel-cluster-setup name: Install Kamel Cluster Setup uses: ./.github/actions/kamel-install-cluster-setup with: - kube-admin-user-ctx: ${{ env.CLUSTER_KUBE_ADMIN_USER_CTX }} + kube-admin-user-ctx: ${{ steps.config-cluster.outputs.cluster-kube-admin-user-ctx }} - id: run-it name: Run IT shell: bash run: | # Cluster environment - export CUSTOM_IMAGE=${{ env.BUILD_BINARY_LOCAL_IMAGE_NAME }} - export CUSTOM_VERSION=${{ env.BUILD_BINARY_LOCAL_IMAGE_VERSION }} + export CUSTOM_IMAGE=${{ steps.build-kamel.outputs.build-binary-local-image-name }} + export CUSTOM_VERSION=${{ steps.build-kamel.outputs.build-binary-local-image-version }} # # If bundle has been built and installed then use it # - if [ -n "${{ env.BUILD_BUNDLE_CATALOG_SOURCE }}" ]; then - export KAMEL_INSTALL_OLM_SOURCE_NAMESPACE=${{ env.CLUSTER_IMAGE_NAMESPACE }} - export KAMEL_INSTALL_OLM_SOURCE=${{ env.BUILD_BUNDLE_CATALOG_SOURCE }} + if [ -n "${{ steps.build-kamel.outputs.build-bundle-catalog-source-name }}" ]; then + export KAMEL_INSTALL_OLM_SOURCE_NAMESPACE=${{ steps.config-cluster.outputs.cluster-image-namespace }} + export KAMEL_INSTALL_OLM_SOURCE=${{ steps.build-kamel.outputs.build-bundle-catalog-source-name }} fi export KAMEL_INSTALL_MAVEN_REPOSITORIES=$(make get-staging-repo) - export KAMEL_INSTALL_REGISTRY=${{ env.CLUSTER_IMAGE_REGISTRY_PULL_HOST }} - export KAMEL_INSTALL_REGISTRY_INSECURE=${{ env.CLUSTER_IMAGE_REGISTRY_INSECURE }} + export KAMEL_INSTALL_REGISTRY=${{ steps.config-cluster.outputs.cluster-image-registry-pull-host }} + export KAMEL_INSTALL_REGISTRY_INSECURE=${{steps.config-cluster.outputs.cluster-image-registry-insecure }} export KAMEL_INSTALL_OPERATOR_IMAGE=${CUSTOM_IMAGE}:${CUSTOM_VERSION} export CAMEL_K_TEST_IMAGE_NAME=${CUSTOM_IMAGE} @@ -90,3 +94,5 @@ runs: - name: Cleanup uses: ./.github/actions/kamel-cleanup if: ${{ always() }} + with: + build-bundle-catalog-source: ${{ steps.build-kamel.outputs.build-bundle-catalog-source-name }} diff --git a/.github/actions/e2e-upgrade/action.yml b/.github/actions/e2e-upgrade/action.yml index 1da7253..b968392 100644 --- a/.github/actions/e2e-upgrade/action.yml +++ b/.github/actions/e2e-upgrade/action.yml @@ -22,6 +22,9 @@ inputs: cluster-config-data: description: 'The configuration of the underlying cluster (if cluster-type is custom)' required: false + cluster-kube-config-data: + description: 'Base16 encoded kube config - required for custom cluster type only' + required: false runs: using: "composite" @@ -31,15 +34,17 @@ runs: name: Prepare Test Environment uses: ./.github/actions/kamel-prepare-env - - id: configure-cluster + - id: config-cluster name: Configure Cluster uses: ./.github/actions/kamel-config-cluster with: cluster-type: ${{ env.TEST_CLUSTER }} cluster-config-data: ${{ inputs.cluster-config-data }} + cluster-kube-config-data: ${{ inputs.cluster-kube-config-data }} require-olm: true - - name: Get Released Kamel CLI + - id: released-kamel-cli + name: Get Released Kamel CLI shell: bash run: | export KAMEL_VERSION=$(make get-last-released-version) @@ -57,7 +62,7 @@ runs: mv /tmp/kamel ${RELEASED_KAMEL_BINARY} if [ $? == 0 ]; then echo "Info: Kamel version installed: $(${RELEASED_KAMEL_BINARY} version)" - echo "E2E_UPGRADE_RELEASED_KAMEL_BINARY=${RELEASED_KAMEL_BINARY}" >> $GITHUB_ENV + echo "::set-output name=released-kamel-binary::${RELEASED_KAMEL_BINARY}" else echo "Error: Failed to install kamel binary ${KAMEL_VERSION}" exit 1 @@ -67,35 +72,35 @@ runs: name: Build Kamel uses: ./.github/actions/kamel-build with: - image-registry-push-host: ${{ env.CLUSTER_IMAGE_REGISTRY_PUSH_HOST }} - image-registry-pull-host: ${{ env.CLUSTER_IMAGE_REGISTRY_PULL_HOST }} - image-namespace: ${{ env.CLUSTER_IMAGE_NAMESPACE }} + image-registry-push-host: ${{ steps.config-cluster.outputs.cluster-image-registry-push-host }} + image-registry-pull-host: ${{ steps.config-cluster.outputs.cluster-image-registry-pull-host }} + image-namespace: ${{ steps.config-cluster.outputs.cluster-image-namespace }} # Builds the bundle if an OLM is available. # Since configure-cluster requires OLM then this should be true - build-bundle: ${{ env.CLUSTER_HAS_OLM }} + build-bundle: ${{ steps.config-cluster.outputs.cluster-has-olm }} # Can be empty and so catalog source will not be created - catalog-source-namespace: ${{ env.CLUSTER_CATALOG_SOURCE_NAMESPACE }} + catalog-source-namespace: ${{ steps.config-cluster.outputs.cluster-catalog-source-namespace }} - name: Run IT shell: bash run: | # Use the last released Kamel CLI - export RELEASED_KAMEL_BIN=${{ env.E2E_UPGRADE_RELEASED_KAMEL_BINARY }} + export RELEASED_KAMEL_BIN=${{ steps.released-kamel-cli.outputs.released-kamel-binary }} echo "Kamel version: $(${RELEASED_KAMEL_BIN} version)" # Configure install options - export CUSTOM_IMAGE=${{ env.BUILD_BINARY_LOCAL_IMAGE_NAME }} - export CUSTOM_VERSION=${{ env.BUILD_BINARY_LOCAL_IMAGE_VERSION }} + export CUSTOM_IMAGE=${{ steps.build-kamel.outputs.build-binary-local-image-name }} + export CUSTOM_VERSION=${{ steps.build-kamel.outputs.build-binary-local-image-version }} export KAMEL_INSTALL_MAVEN_REPOSITORIES=$(make get-staging-repo) - export KAMEL_INSTALL_REGISTRY=${{ env.CLUSTER_IMAGE_REGISTRY_PULL_HOST }} - export KAMEL_INSTALL_REGISTRY_INSECURE=${{ env.CLUSTER_IMAGE_REGISTRY_INSECURE }} + export KAMEL_INSTALL_REGISTRY=${{ steps.config-cluster.outputs.cluster-image-registry-pull-host }} + export KAMEL_INSTALL_REGISTRY_INSECURE=${{steps.config-cluster.outputs.cluster-image-registry-insecure }} # Despite building a bundle we don't want it installed immediately so no OLM_INDEX_BUNDLE var # Configure test options export CAMEL_K_PREV_IIB=quay.io/operatorhubio/catalog:latest - export CAMEL_K_NEW_IIB=${{ env.BUILD_BUNDLE_LOCAL_IMAGE_BUNDLE_INDEX }} + export CAMEL_K_NEW_IIB=${{ steps.build-kamel.outputs.build-bundle-image-bundle-index }} export KAMEL_K_TEST_RELEASE_VERSION=$(make get-last-released-version) export KAMEL_K_TEST_OPERATOR_CURRENT_IMAGE=${CUSTOM_IMAGE}:${CUSTOM_VERSION} export CAMEL_K_TEST_SAVE_FAILED_TEST_NAMESPACE=${{ env.CAMEL_K_TEST_SAVE_FAILED_TEST_NAMESPACE }} @@ -106,3 +111,5 @@ runs: - name: Cleanup uses: ./.github/actions/kamel-cleanup if: ${{ always() }} + with: + build-bundle-catalog-source: ${{ steps.build-kamel.outputs.build-bundle-catalog-source-name }} diff --git a/.github/actions/json-to-variables b/.github/actions/json-to-variables deleted file mode 160000 index cc8c639..0000000 --- a/.github/actions/json-to-variables +++ /dev/null @@ -1 +0,0 @@ -Subproject commit cc8c6394031e145c90f7f9ec909d83df92431fb8 diff --git a/.github/actions/kamel-build-binary/action.yml b/.github/actions/kamel-build-binary/action.yml index 1355bf2..8b87dd6 100644 --- a/.github/actions/kamel-build-binary/action.yml +++ b/.github/actions/kamel-build-binary/action.yml @@ -81,5 +81,15 @@ runs: # Use the PULL host to ensure the correct image:tag # is passed into the tests for the deployment to pull from # - echo "BUILD_BINARY_LOCAL_IMAGE_NAME=${{ inputs.image-registry-pull-host }}/${{ inputs.image-namespace }}/camel-k" >> $GITHUB_ENV - echo "BUILD_BINARY_LOCAL_IMAGE_VERSION=$(make get-version)" >> $GITHUB_ENV + BUILD_BINARY_LOCAL_IMAGE_NAME="${{ inputs.image-registry-pull-host }}/${{ inputs.image-namespace }}/camel-k" + BUILD_BINARY_LOCAL_IMAGE_VERSION="$(make get-version)" + echo "::set-output name=build-binary-local-image-name::${BUILD_BINARY_LOCAL_IMAGE_NAME}" + echo "::set-output name=build-binary-local-image-version::${BUILD_BINARY_LOCAL_IMAGE_VERSION}" + +outputs: + build-binary-local-image-name: + description: "Full name of the binary operator image" + value: ${{ steps.build-operator.outputs.build-binary-local-image-name }} + build-binary-local-image-version: + description: "Version & tag of the binary operator image" + value: ${{ steps.build-operator.outputs.build-binary-local-image-version }} diff --git a/.github/actions/kamel-build-bundle/action.yaml b/.github/actions/kamel-build-bundle/action.yaml index 2191680..2a6f65f 100644 --- a/.github/actions/kamel-build-bundle/action.yaml +++ b/.github/actions/kamel-build-bundle/action.yaml @@ -97,7 +97,9 @@ runs: # Use the PULL host to ensure the correct image:tag # is passed into the tests for the deployment to pull from # - echo "BUILD_BUNDLE_LOCAL_IMAGE=${{ inputs.image-registry-pull-host }}/${{ inputs.image-namespace }}/camel-k-bundle:${{ inputs.local-image-version }}" >> $GITHUB_ENV + BUILD_BUNDLE_LOCAL_IMAGE="${{ inputs.image-registry-pull-host }}/${{ inputs.image-namespace }}/camel-k-bundle:${{ inputs.local-image-version }}" + echo "::set-output name=build-bundle-local-image::${BUILD_BUNDLE_LOCAL_IMAGE}" + - id: install-opm name: Install opm if required @@ -170,11 +172,11 @@ runs: # docker tag \ ${PUSH_REGISTRY}/${{ inputs.image-namespace }}/camel-k-bundle:${{ inputs.local-image-version }} \ - ${{ env.BUILD_BUNDLE_LOCAL_IMAGE }} + ${{ steps.build-bundle-image.outputs.build-bundle-local-image }} # Push the bundle image to the registry # - docker push ${{ env.BUILD_BUNDLE_LOCAL_IMAGE }} + docker push ${{ steps.build-bundle-image.outputs.build-bundle-local-image }} fi # @@ -187,12 +189,13 @@ runs: # sudo opm index add \ -c docker --skip-tls \ - --bundles ${{ env.BUILD_BUNDLE_LOCAL_IMAGE }} \ + --bundles ${{ steps.build-bundle-image.outputs.build-bundle-local-image }} \ --from-index quay.io/operatorhubio/catalog:latest \ --tag ${LOCAL_IIB} docker push ${LOCAL_IIB} - echo "BUILD_BUNDLE_LOCAL_IMAGE_BUNDLE_INDEX=${{ inputs.image-registry-pull-host }}/${{ inputs.image-namespace }}/camel-k-iib:${{ inputs.local-image-version }}" >> $GITHUB_ENV + BUILD_BUNDLE_LOCAL_IMAGE_BUNDLE_INDEX="${{ inputs.image-registry-pull-host }}/${{ inputs.image-namespace }}/camel-k-iib:${{ inputs.local-image-version }}" + echo "::set-output name=build-bundle-image-bundle-index::${BUILD_BUNDLE_LOCAL_IMAGE_BUNDLE_INDEX}" - id: build-image-catalog name: Create a new catalog to host the index image @@ -211,7 +214,7 @@ runs: fi export BUILD_CATALOG_SOURCE="camel-k-test-source" - echo "BUILD_BUNDLE_CATALOG_SOURCE=${BUILD_CATALOG_SOURCE}" >> $GITHUB_ENV + echo "::set-output name=build-bundle-catalog-source-name::${BUILD_CATALOG_SOURCE}" cat <<EOF | kubectl apply -f - apiVersion: operators.coreos.com/v1alpha1 @@ -221,10 +224,21 @@ runs: namespace: ${{ inputs.image-namespace }} spec: displayName: OLM upgrade test Catalog - image: ${{ env.BUILD_BUNDLE_LOCAL_IMAGE_BUNDLE_INDEX }} + image: ${{ steps.build-index-image.outputs.build-bundle-image-bundle-index }} sourceType: grpc publisher: grpc updateStrategy: registryPoll: interval: 1m0s EOF + +outputs: + build-bundle-local-image: + description: "Full name of the bundle image" + value: ${{ steps.build-bundle-image.outputs.build-bundle-local-image }} + build-bundle-image-bundle-index: + description: "Full name of the bundle index image" + value: ${{ steps.build-index-image.outputs.build-bundle-image-bundle-index }} + build-bundle-catalog-source-name: + description: "Name of the catalog source for the build bundle image" + value: ${{ steps.build-image-catalog.outputs.build-bundle-catalog-source-name }} diff --git a/.github/actions/kamel-build/action.yml b/.github/actions/kamel-build/action.yml index ba84c06..09de53d 100644 --- a/.github/actions/kamel-build/action.yml +++ b/.github/actions/kamel-build/action.yml @@ -63,6 +63,23 @@ runs: image-registry-push-host: ${{ inputs.image-registry-push-host }} image-registry-pull-host: ${{ inputs.image-registry-pull-host }} image-namespace: ${{ inputs.image-namespace }} - local-image-name: ${{ env.BUILD_BINARY_LOCAL_IMAGE_NAME }} - local-image-version: ${{ env.BUILD_BINARY_LOCAL_IMAGE_VERSION }} + local-image-name: ${{ steps.build-kamel-binary.outputs.build-binary-local-image-name }} + local-image-version: ${{ steps.build-kamel-binary.outputs.build-binary-local-image-version }} catalog-source-namespace: ${{ inputs.catalog-source-namespace }} + +outputs: + build-binary-local-image-name: + description: "Full name of the binary operator image" + value: ${{ steps.build-kamel-binary.outputs.build-binary-local-image-name }} + build-binary-local-image-version: + description: "Version & tag of the binary operator image" + value: ${{ steps.build-kamel-binary.outputs.build-binary-local-image-version }} + build-bundle-local-image: + description: "Full name of the bundle image" + value: ${{ steps.build-kamel-bundle.outputs.build-bundle-local-image }} + build-bundle-image-bundle-index: + description: "Full name of the bundle index image" + value: ${{ steps.build-kamel-bundle.outputs.build-bundle-image-bundle-index }} + build-bundle-catalog-source-name: + description: "Name of the catalog source for the build bundle image" + value: ${{ steps.build-kamel-bundle.outputs.build-bundle-catalog-source-name }} diff --git a/.github/actions/kamel-cleanup/action.yaml b/.github/actions/kamel-cleanup/action.yaml index 338ad37..aadc8a4 100644 --- a/.github/actions/kamel-cleanup/action.yaml +++ b/.github/actions/kamel-cleanup/action.yaml @@ -18,6 +18,11 @@ name: kamel-cleanup description: 'Cleans up the target cluster, removing any e2e test resources' +inputs: + build-bundle-catalog-source: + description: "Name of the catalog source for the build bundle image" + required: true + runs: using: "composite" steps: @@ -41,15 +46,15 @@ runs: shell: bash if: ${{ always() }} run: | - if [ -z "${{ env.BUILD_BUNDLE_CATALOG_SOURCE }}" ]; then + if [ -z "${{ inputs.build-bundle-catalog-source-name }}" ]; then # Catalog source never defined so nothing to do exit 0 fi set +e - CATALOG_NS=$(kubectl get catalogsource --all-namespaces | grep ${{ env.BUILD_BUNDLE_CATALOG_SOURCE }} | awk {'print $1'}) + CATALOG_NS=$(kubectl get catalogsource --all-namespaces | grep ${{ inputs.build-bundle-catalog-source-name }} | awk {'print $1'}) for ns in ${CATALOG_NS} do - kubectl delete CatalogSource ${{ env.BUILD_BUNDLE_CATALOG_SOURCE }} -n ${ns} + kubectl delete CatalogSource ${{ inputs.build-bundle-catalog-source-name }} -n ${ns} done set -e diff --git a/.github/actions/kamel-config-cluster-custom/action.yml b/.github/actions/kamel-config-cluster-custom/action.yml index e5986e1..7cb64f4 100644 --- a/.github/actions/kamel-config-cluster-custom/action.yml +++ b/.github/actions/kamel-config-cluster-custom/action.yml @@ -20,127 +20,26 @@ description: 'Provides configuration for acessing a custom kubernetes cluster' inputs: cluster-config-data: - description: 'The JSON configuration of the cluster' + description: 'Non-Secure Variables for the cluster configuration' + required: true + cluster-kube-config-data: + description: 'Base16 encoded kube config' required: true runs: using: "composite" steps: - - name: Read cluster-config-data variable to temporary file & override CLUSTER_TYPE if cluster config defined - shell: bash - if: ${{ env.CLUSTER_CUSTOM_CONFIGURED != 'true' }} - run: | - export CLUSTER_CONFIG_FILE=/tmp/cluster-config.json - - if [ -f ${CLUSTER_CONFIG_FILE} ]; then - rm -f ${CLUSTER_CONFIG_FILE} - fi - - touch "${CLUSTER_CONFIG_FILE}" - if [ -z "${{ inputs.cluster-config-data }}" ]; then - echo "Error: No cluster-config-data parameter has been defined" - exit 1 - fi - - cat << EOF > "${CLUSTER_CONFIG_FILE}" - ${{ inputs.cluster-config-data }} - EOF - - if [ ! -f "${CLUSTER_CONFIG_FILE}" ]; then - echo "Error: No file ${CLUSTER_CONFIG_FILE} has been created" - exit 1 - fi - - if [ -s "${CLUSTER_CONFIG_FILE}" ]; then - echo "Info: Cluster configuration defined" - echo "CLUSTER_CONFIG_FILE=${CLUSTER_CONFIG_FILE}" >> $GITHUB_ENV - else - echo "Error: No cluster configuration defined" - exit 1 - fi - - - name: Cluster config JSON to variables - uses: ./.github/actions/json-to-variables - if: ${{ env.CLUSTER_CUSTOM_CONFIGURED != 'true' }} - with: - filename: ${{ env.CLUSTER_CONFIG_FILE }} - prefix: 'e2e' - - id: connect-cluster name: Connect to cluster shell: bash - if: ${{ env.CLUSTER_CUSTOM_CONFIGURED != 'true' }} run: | - echo "::add-mask::${{ env.e2e_kube-config-data }}" - echo "::add-mask::${{ env.e2e_kube-admin-user-ctx }}" - echo "::add-mask::${{ env.e2e_kube-user-ctx }}" - echo "::add-mask::${{ env.e2e_image-registry-pull-host }}" - echo "::add-mask::${{ env.e2e_image-registry-push-host }}" - echo "::add-mask::${{ env.e2e_image-registry-user }}" - echo "::add-mask::${{ env.e2e_image-registry-token }}" - echo "::add-mask::${{ env.e2e_image-namespace }}" - echo "::add-mask::${{ env.e2e_catalog-source-namespace }}" - - if [ -z "${{ env.e2e_kube-config-data }}" ]; then - echo "Error: kube config data property cannot be found" - exit 1 - fi - - if [ -z "${{ env.e2e_kube-admin-user-ctx }}" ]; then - echo "Error: kube admin context property cannot be found" - exit 1 - fi - - if [ -z "${{ env.e2e_kube-user-ctx }}" ]; then - echo "Error: kube user context property cannot be found" - exit 1 - fi - - if [ -z "${{ env.e2e_image-registry-pull-host }}" ]; then - echo "Error: image registry pull host property cannot be found" - exit 1 - fi - - if [ -z "${{ env.e2e_image-registry-push-host }}" ]; then - echo "Error: image registry build host property cannot be found" - exit 1 - fi - - if [ -n "${{ env.e2e_image-registry-user }}" ] && [ -n "${{ env.e2e_image-registry-token }}" ]; then - echo "Secured registry in use so login with docker" - docker login \ - -u "${{ env.e2e_image-registry-user }}" \ - -p "${{ env.e2e_image-registry-token }}" \ - "${{ env.e2e_image-registry-push-host }}" - fi - - # Copy the kube config to the correct location for kubectl - mkdir -p $HOME/.kube - echo -n "${{ env.e2e_kube-config-data }}" | base64 -d > ${HOME}/.kube/config - if [ ! -f ${HOME}/.kube/config ]; then - echo "Error: kube config file not created correctly" - exit 1 - fi - - set -e - kubectl config use-context "${{ env.e2e_kube-admin-user-ctx }}" - if [ $? != 0 ]; then - echo "Error: Failed to select kube admin context. Is the config and context correct?" - exit 1 - fi - set +e - - - id: info - name: Info - shell: bash - if: ${{ env.CLUSTER_CUSTOM_CONFIGURED != 'true' }} - run: | - kubectl describe nodes + ./.github/actions/kamel-config-cluster-custom/connect-cluster.sh \ + -c "${{ inputs.cluster-config-data }}" \ + -k "${{ inputs.cluster-kube-config-data }}" - id: configure-developer-user name: Configure Developer User shell: bash - if: ${{ env.CLUSTER_CUSTOM_CONFIGURED != 'true' }} run: | # Aggregate pod eviction permission to the default admin role cat <<EOF | kubectl apply -f - @@ -197,36 +96,30 @@ runs: EOF # Set the context to the user - kubectl config use-context "${{ env.e2e_kube-user-ctx }}" - - - id: extract-config - shell: bash - if: ${{ env.CLUSTER_CUSTOM_CONFIGURED != 'true' }} - run: | - echo "CLUSTER_IMAGE_REGISTRY_PUSH_HOST=${{ env.e2e_image-registry-push-host }}" >> $GITHUB_ENV - echo "CLUSTER_IMAGE_REGISTRY_PULL_HOST=${{ env.e2e_image-registry-pull-host }}" >> $GITHUB_ENV - echo "CLUSTER_IMAGE_REGISTRY_INSECURE=${{ env.e2e_image-registry-insecure }}" >> $GITHUB_ENV - echo "CLUSTER_CATALOG_SOURCE_NAMESPACE=${{ env.e2e_catalog-source-namespace }}" >> $GITHUB_ENV - - # - # Export the image namespace if defined in the cluster config - # - if [ -n "${{ env.e2e_image-namespace }}" ]; then - echo "CLUSTER_IMAGE_NAMESPACE=${{ env.e2e_image-namespace }}" >> $GITHUB_ENV - fi - - # - # Export the context used for admin and user - # - echo "CLUSTER_KUBE_ADMIN_USER_CTX=${{ env.e2e_kube-admin-user-ctx }}" >> $GITHUB_ENV - echo "CLUSTER_KUBE_USER_CTX=${{ env.e2e_kube-user-ctx }}" >> $GITHUB_ENV - - # - # Export the flag for olm capability - # - echo "CLUSTER_HAS_OLM=${{ env.e2e_has-olm }}" >> $GITHUB_ENV - - # - # Avoid configuring the cluster repeatedly - # - echo "CLUSTER_CUSTOM_CONFIGURED=true" >> $GITHUB_ENV + kubectl config use-context ${{ steps.connect-cluster.outputs.cluster-kube-user-ctx }} + +outputs: + cluster-image-registry-push-host: + description: "The image registry to which to push images" + value: ${{ steps.connect-cluster.outputs.cluster-image-registry-push-host }} + cluster-image-registry-pull-host: + description: "The image registry from which to pull images" + value: ${{ steps.connect-cluster.outputs.cluster-image-registry-pull-host }} + cluster-image-registry-insecure: + description: "Whether the pull registry is insecure" + value: ${{ steps.connect-cluster.outputs.cluster-image-registry-insecure }} + cluster-catalog-source-namespace: + description: "The namespace in which to install the OLM catalog source" + value: ${{ steps.connect-cluster.outputs.cluster-catalog-source-namespace }} + cluster-image-namespace: + description: "The namespace to install the camel-k images" + value: ${{ steps.connect-cluster.outputs.cluster-image-namespace }} + cluster-kube-admin-user-ctx: + description: "The context of the kube admin user" + value: ${{ steps.connect-cluster.outputs.cluster-kube-admin-user-ctx }} + cluster-kube-user-ctx: + description: "The context of the kube user" + value: ${{ steps.connect-cluster.outputs.cluster-kube-user-ctx }} + cluster-has-olm: + description: "Does the cluster have OLM" + value: ${{ steps.connect-cluster.outputs.cluster-has-olm }} diff --git a/.github/actions/kamel-config-cluster-custom/connect-cluster.sh b/.github/actions/kamel-config-cluster-custom/connect-cluster.sh new file mode 100755 index 0000000..8f6b087 --- /dev/null +++ b/.github/actions/kamel-config-cluster-custom/connect-cluster.sh @@ -0,0 +1,142 @@ +#!/bin/bash + +# --------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# --------------------------------------------------------------------------- + +#### +# +# Configures access to the cluster +# +#### + +set -e + +while getopts ":c:k:" opt; do + case "${opt}" in + c) + CLUSTER_CONFIG_DATA=${OPTARG} + ;; + k) + KUBE_CONFIG_DATA=${OPTARG} + ;; + :) + echo "ERROR: Option -$OPTARG requires an argument" + exit 1 + ;; + \?) + echo "ERROR: Invalid option -$OPTARG" + exit 1 + ;; + esac +done +shift $((OPTIND-1)) + +has_property() { + if echo "${CLUSTER_CONFIG_DATA}" | grep ${1} &> /dev/null; then + echo 0 + else + echo 1 + fi +} + +get_property() { + VAR=$(echo "${CLUSTER_CONFIG_DATA}" | grep ${1}) + echo ${VAR#*=} +} + +if [ -z "${KUBE_CONFIG_DATA}" ]; then + echo "Error: kube config data property cannot be found" + exit 1 +fi + +if [ ! $(has_property kube-admin-user-ctx) ]; then + echo "Error: kube admin context property cannot be found" + exit 1 +fi + +if [ ! $(has_property kube-user-ctx) ]; then + echo "Error: kube user context property cannot be found" + exit 1 +fi + +if [ ! $(has_property image-registry-pull-host) ]; then + echo "Error: image registry pull host property cannot be found" + exit 1 +fi + +if [ ! $(has_property image-registry-push-host) ]; then + echo "Error: image registry build host property cannot be found" + exit 1 +fi + +echo "::set-output name=cluster-image-registry-push-host::$(get_property image-registry-push-host)" +echo "::set-output name=cluster-image-registry-pull-host::$(get_property image-registry-pull-host)" +echo "::set-output name=cluster-image-registry-insecure::$(get_property image-registry-insecure)" +echo "::set-output name=cluster-catalog-source-namespace::$(get_property catalog-source-namespace)" + +# +# Export the image namespace if defined in the cluster config +# +if [ $(has_property image-namespace) ]; then + echo "::set-output name=cluster-image-namespace::$(get_property image-namespace)" +fi + +# +# Export the context used for admin and user +# +echo "::set-output name=cluster-kube-admin-user-ctx::$(get_property kube-admin-user-ctx)" +echo "::set-output name=cluster-kube-user-ctx::$(get_property kube-user-ctx)" + +# +# Keep values private in the log +# +echo "::add-mask::$(get_property image-registry-push-host)" +echo "::add-mask::$(get_property image-registry-pull-host)" +echo "::add-mask::$(get_property kube-admin-user-ctx)" +echo "::add-mask::$(get_property kube-user-ctx)" + +# +# Export the flag for olm capability +# +echo "::set-output name=cluster-has-olm::$(get_property has-olm)" + +# +# Login to docker if registry is externally secured +# +if [ $(has_property image-registry-user) ] && [ $(has_property image-registry-token) ]; then + echo "Secured registry in use so login with docker" + docker login \ + -u $(get_property image-registry-user) \ + -p $(get_property image-registry-token) \ + $(get_property image-registry-push-host) +fi + +# Copy the kube config to the correct location for kubectl +mkdir -p $HOME/.kube +echo -n "${KUBE_CONFIG_DATA}" | base64 -d > ${HOME}/.kube/config +if [ ! -f ${HOME}/.kube/config ]; then + echo "Error: kube config file not created correctly" + exit 1 +fi + +set -e +kubectl config use-context $(get_property kube-admin-user-ctx) +if [ $? != 0 ]; then + echo "Error: Failed to select kube admin context. Is the config and context correct?" + exit 1 +fi +set +e diff --git a/.github/actions/kamel-config-cluster-kind/action.yml b/.github/actions/kamel-config-cluster-kind/action.yml index e680394..3034ee8 100644 --- a/.github/actions/kamel-config-cluster-kind/action.yml +++ b/.github/actions/kamel-config-cluster-kind/action.yml @@ -37,28 +37,35 @@ runs: kubectl cluster-info kubectl describe nodes - - id: extract-config - shell: bash - if: ${{ env.CLUSTER_KIND_CONFIGURED != 'true' }} - run: | - # Kind has the same interface for both pushing and pulling images in its registry - echo "CLUSTER_IMAGE_REGISTRY_PUSH_HOST=${{ env.KIND_REGISTRY }}" >> $GITHUB_ENV - echo "CLUSTER_IMAGE_REGISTRY_PULL_HOST=${{ env.KIND_REGISTRY }}" >> $GITHUB_ENV - echo "CLUSTER_IMAGE_REGISTRY_INSECURE=true" >> $GITHUB_ENV - # - # Export the context used for admin and user - # Since kind has no rbac switched on then these can be the same + # Avoid bringing up the cluster repeatedly # - echo "CLUSTER_KUBE_ADMIN_USER_CTX=$(kubectl config current-context)" >> $GITHUB_ENV - echo "CLUSTER_KUBE_USER_CTX=$(kubectl config current-context)" >> $GITHUB_ENV + echo "CLUSTER_KIND_CONFIGURED=true" >> $GITHUB_ENV - # - # Export the flag for olm capability - # - echo "CLUSTER_HAS_OLM=false" >> $GITHUB_ENV + - id: extract-config + name: Output the config + shell: bash + run: ./.github/actions/kamel-config-cluster-kind/extract-config.sh - # - # Avoid configuring the cluster repeatedly - # - echo "CLUSTER_KIND_CONFIGURED=true" >> $GITHUB_ENV +outputs: + cluster-image-registry-push-host: + description: "The image registry to which to push images" + value: ${{ steps.extract-config.outputs.cluster-image-registry-push-host }} + cluster-image-registry-pull-host: + description: "The image registry from which to pull images" + value: ${{ steps.extract-config.outputs.cluster-image-registry-pull-host }} + cluster-image-registry-insecure: + description: "Whether the pull registry is insecure" + value: ${{ steps.extract-config.outputs.cluster-image-registry-insecure }} + cluster-image-namespace: + description: "The namespace to install the camel-k images" + value: ${{ steps.extract-config.outputs.cluster-image-namespace }} + cluster-kube-admin-user-ctx: + description: "The context of the kube admin user" + value: ${{ steps.extract-config.outputs.cluster-kube-admin-user-ctx }} + cluster-kube-user-ctx: + description: "The context of the kube user" + value: ${{ steps.extract-config.outputs.cluster-kube-user-ctx }} + cluster-has-olm: + description: "Does the cluster have OLM" + value: ${{ steps.extract-config.outputs.cluster-has-olm }} diff --git a/.github/actions/kamel-config-cluster-kind/extract-config.sh b/.github/actions/kamel-config-cluster-kind/extract-config.sh new file mode 100755 index 0000000..69b4924 --- /dev/null +++ b/.github/actions/kamel-config-cluster-kind/extract-config.sh @@ -0,0 +1,51 @@ +#!/bin/bash + +# --------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# --------------------------------------------------------------------------- + +#### +# +# Outputs the kind config to output variables +# +#### + +set -e + +# Kind has the same interface for both pushing and pulling images in its registry +echo "::set-output name=cluster-image-registry-push-host::${KIND_REGISTRY}" +echo "::set-output name=cluster-image-registry-pull-host::${KIND_REGISTRY}" +echo "::set-output name=cluster-image-registry-insecure::$(echo true)" + +# +# Export the context used for admin and user +# Since kind has no rbac switched on then these can be the same +# +echo "::set-output name=cluster-kube-admin-user-ctx::$(kubectl config current-context)" +echo "::set-output name=cluster-kube-user-ctx::$(kubectl config current-context)" + +# Set the image namespace +echo "::set-output name=cluster-image-namespace::$(echo apache)" + +# +# cluster-catalog-source-namespace intentionally blank as OLM not routinely installed +# upgrade tests will install their own catalog-source +# + +# +# Export the flag for olm capability +# +echo "::set-output name=cluster-has-olm::$(echo false)" diff --git a/.github/actions/kamel-config-cluster-ocp3/action.yml b/.github/actions/kamel-config-cluster-ocp3/action.yml index 2be4ca9..c6bdf96 100644 --- a/.github/actions/kamel-config-cluster-ocp3/action.yml +++ b/.github/actions/kamel-config-cluster-ocp3/action.yml @@ -67,9 +67,6 @@ runs: oc cluster up --public-hostname=$IP_ADDR --enable=persistent-volumes,registry,router oc login -u system:admin - # Export the context used for admin login - echo "CLUSTER_KUBE_ADMIN_USER_CTX=$(oc config current-context)" >> $GITHUB_ENV - # Wait until we have a ready node in openshift TIMEOUT=0 TIMEOUT_COUNT=60 @@ -89,6 +86,11 @@ runs: echo "openshift is deployed and reachable" + # + # Avoid configuring the cluster repeatedly + # + echo "CLUSTER_OCP3_CONFIGURED=true" >> $GITHUB_ENV + - id: info name: Info shell: bash @@ -99,8 +101,12 @@ runs: - id: configure-developer-user name: Configure Developer User shell: bash - if: ${{ env.CLUSTER_OCP3_CONFIGURED != 'true' }} run: | + oc login -u system:admin + + # Export the context used for admin login + echo "::set-output name=cluster-kube-admin-user-ctx::$(oc config current-context)" + # Aggregate pod eviction permission to the default admin role cat <<EOF | oc apply -f - kind: ClusterRole @@ -186,19 +192,38 @@ runs: oc login -u developer # Export the context used for developer login - echo "CLUSTER_KUBE_USER_CTX=$(oc config current-context)" >> $GITHUB_ENV + echo "::set-output name=cluster-kube-user-ctx::$(oc config current-context)" - - - id: extract-kube-config + - id: extract-config shell: bash if: ${{ env.CLUSTER_OCP3_CONFIGURED != 'true' }} run: | - echo "CLUSTER_IMAGE_REGISTRY_PUSH_HOST=" >> $GITHUB_ENV - echo "CLUSTER_IMAGE_REGISTRY_PULL_HOST=" >> $GITHUB_ENV - echo "CLUSTER_IMAGE_REGISTRY_INSECURE=false" >> $GITHUB_ENV - echo "CLUSTER_HAS_OLM=true" >> $GITHUB_ENV - - # - # Avoid configuring the cluster repeatedly - # - echo "CLUSTER_OCP3_CONFIGURED=true" >> $GITHUB_ENV + echo "::set-output name=cluster-image-registry-pull-host::" + echo "::set-output name=cluster-image-registry-pull-host::" + echo "::set-output name=cluster-image-registry-insecure::$(echo true)" + echo "::set-output name=cluster-has-olm::$(echo false)" + echo "::set-output name=cluster-image-namespace::$(echo apache)" + /* cluster-catalog-source-namespace intentionally blank due to using straight docker */ + +outputs: + cluster-image-registry-push-host: + description: "The image registry to which to push images" + value: ${{ steps.extract-config.outputs.cluster-image-registry-push-host }} + cluster-image-registry-pull-host: + description: "The image registry from which to pull images" + value: ${{ steps.extract-config.outputs.cluster-image-registry-pull-host }} + cluster-image-registry-insecure: + description: "Whether the pull registry is insecure" + value: ${{ steps.extract-config.outputs.cluster-image-registry-insecure }} + cluster-image-namespace: + description: "The namespace to install the camel-k images" + value: ${{ steps.extract-config.outputs.cluster-image-namespace }} + cluster-kube-admin-user-ctx: + description: "The context of the kube admin user" + value: ${{ steps.configure-developer-user.outputs.cluster-kube-admin-user-ctx }} + cluster-kube-user-ctx: + description: "The context of the kube user" + value: ${{ steps.configure-developer-user.outputs.cluster-kube-user-ctx }} + cluster-has-olm: + description: "Does the cluster have OLM" + value: ${{ steps.extract-config.outputs.cluster-has-olm }} diff --git a/.github/actions/kamel-config-cluster/action.yaml b/.github/actions/kamel-config-cluster/action.yaml index 7e87850..90a5ae7 100644 --- a/.github/actions/kamel-config-cluster/action.yaml +++ b/.github/actions/kamel-config-cluster/action.yaml @@ -24,7 +24,10 @@ inputs: required: true default: 'kind' cluster-config-data: - description: 'The JSON configuration of the cluster - required for custom cluster type only' + description: 'Variables for the cluster configuration - required for custom cluster type only' + required: false + cluster-kube-config-data: + description: 'Base16 encoded kube config - required for custom cluster type only' required: false require-olm: description: 'If OLM is not available by default ensure that it is installed' @@ -62,6 +65,7 @@ runs: if: ${{ env.CLUSTER_TYPE == 'custom' }} with: cluster-config-data: ${{ inputs.cluster-config-data }} + cluster-kube-config-data: ${{ inputs.cluster-kube-config-data }} - id: execute-invalid name: Execute Invalid Cluster @@ -71,14 +75,45 @@ runs: echo "Error: Unrecognised cluster request for type of cluster. Should be kind, ocp3 or custom." exit 1 - - id: image-namespace + - id: cluster-config + name: Extract the config from the cluster shell: bash - env: - DEFAULT_IMAGE_NAMESPACE: 'apache' run: | - if [ -z "${{ env.CLUSTER_IMAGE_NAMESPACE }}" ]; then - echo "CLUSTER_IMAGE_NAMESPACE=apache" >> $GITHUB_ENV - fi + case ${{ env.CLUSTER_TYPE }} in + kind) + # Does not require cluster-catalog-source-namespace + ./.github/actions/kamel-config-cluster/output-config.sh \ + -a "${{ steps.execute-kind.outputs.cluster-kube-admin-user-ctx }}" \ + -n "${{ steps.execute-kind.outputs.cluster-image-namespace }}" \ + -o "${{ steps.execute-kind.outputs.cluster-has-olm }}" \ + -p "${{ steps.execute-kind.outputs.cluster-image-registry-push-host }}" \ + -q "${{ steps.execute-kind.outputs.cluster-image-registry-pull-host }}" \ + -s "${{ steps.execute-kind.outputs.cluster-image-registry-insecure }}" \ + -u "${{ steps.execute-kind.outputs.cluster-kube-user-ctx }}" + ;; + custom) + ./.github/actions/kamel-config-cluster/output-config.sh \ + -a "${{ steps.execute-custom.outputs.cluster-kube-admin-user-ctx }}" \ + -c "${{ steps.execute-custom.outputs.cluster-catalog-source-namespace }}" \ + -n "${{ steps.execute-custom.outputs.cluster-image-namespace }}" \ + -o "${{ steps.execute-custom.outputs.cluster-has-olm }}" \ + -p "${{ steps.execute-custom.outputs.cluster-image-registry-push-host }}" \ + -q "${{ steps.execute-custom.outputs.cluster-image-registry-pull-host }}" \ + -s "${{ steps.execute-custom.outputs.cluster-image-registry-insecure }}" \ + -u "${{ steps.execute-custom.outputs.cluster-kube-user-ctx }}" + ;; + ocp3) + # Does not require cluster-catalog-source-namespace + ./.github/actions/kamel-config-cluster/output-config.sh \ + -a "${{ steps.execute-ocp3.outputs.cluster-kube-admin-user-ctx }}" \ + -n "${{ steps.execute-ocp3.outputs.cluster-image-namespace }}" \ + -o "${{ steps.execute-ocp3.outputs.cluster-has-olm }}" \ + -p "${{ steps.execute-ocp3.outputs.cluster-image-registry-push-host }}" \ + -q "${{ steps.execute-ocp3.outputs.cluster-image-registry-pull-host }}" \ + -s "${{ steps.execute-ocp3.outputs.cluster-image-registry-insecure }}" \ + -u "${{ steps.execute-ocp3.outputs.cluster-kube-user-ctx }}" + ;; + esac # # Install opm if required @@ -100,16 +135,17 @@ runs: name: Install OLM shell: bash run: | - if [ "${{ env.CLUSTER_HAS_OLM }}" == "true" ]; then + if [ "${{ steps.cluster-config.outputs.cluster-has-olm }}" == "true" ]; then # OLM already installed by default echo "OLM already available in cluster" + echo "::set-output name=cluster-has-olm::${{ steps.cluster-config.outputs.cluster-has-olm }}" exit 0 fi if [ "${{ inputs.require-olm }}" != "true" ]; then # OLM not explicitly requested echo "OLM not explicity required for testing" - echo "CLUSTER_HAS_OLM=false" >> $GITHUB_ENV + echo "::set-output name=cluster-has-olm::$(echo false)" exit 0 fi @@ -123,7 +159,7 @@ runs: # Need to be admin so switch to the admin context # echo "Change to kube admin context" - kubectl config use-context "${{ env.CLUSTER_KUBE_ADMIN_USER_CTX }}" + kubectl config use-context "${{ steps.cluster-config.outputs.cluster-kube-admin-user-ctx }}" set +e echo "Check if OLM is already installed" @@ -144,5 +180,31 @@ runs: echo "Return to original kube context" kubectl config use-context "${ctx}" + echo "::set-output name=cluster-has-olm::$(echo true)" echo "Complete" - echo "CLUSTER_HAS_OLM=true" >> $GITHUB_ENV + +outputs: + cluster-image-registry-push-host: + description: "The image registry to which to push images" + value: ${{ steps.cluster-config.outputs.cluster-image-registry-push-host }} + cluster-image-registry-pull-host: + description: "The image registry from which to pull images" + value: ${{ steps.cluster-config.outputs.cluster-image-registry-pull-host }} + cluster-image-registry-insecure: + description: "Whether the pull registry is insecure" + value: ${{ steps.cluster-config.outputs.cluster-image-registry-insecure }} + cluster-catalog-source-namespace: + description: "The namespace in which to install the OLM catalog source" + value: ${{ steps.cluster-config.outputs.cluster-catalog-source-namespace }} + cluster-image-namespace: + description: "The namespace to install the camel-k images" + value: ${{ steps.cluster-config.outputs.cluster-image-namespace }} + cluster-kube-admin-user-ctx: + description: "The context of the kube admin user" + value: ${{ steps.cluster-config.outputs.cluster-kube-admin-user-ctx }} + cluster-kube-user-ctx: + description: "The context of the kube user" + value: ${{ steps.cluster-config.outputs.cluster-kube-user-ctx }} + cluster-has-olm: + description: "Does the cluster have OLM" + value: ${{ steps.install-olm.outputs.cluster-has-olm }} diff --git a/.github/actions/kamel-config-cluster/output-config.sh b/.github/actions/kamel-config-cluster/output-config.sh new file mode 100755 index 0000000..99e9d86 --- /dev/null +++ b/.github/actions/kamel-config-cluster/output-config.sh @@ -0,0 +1,81 @@ +#!/bin/bash + +# --------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# --------------------------------------------------------------------------- + +#### +# +# Outputs the config to cluster output variables +# +#### + +set -e + +while getopts ":a:c:n:o:p:q:s:u:" opt; do + case "${opt}" in + a) + ADMIN_USER_CTX=${OPTARG} + ;; + c) + CATALOG_SOURCE_NAMESPACE=${OPTARG} + ;; + n) + IMAGE_NAMESPACE=${OPTARG} + ;; + o) + HAS_OLM=${OPTARG} + ;; + p) + PUSH_HOST=${OPTARG} + ;; + q) + PULL_HOST=${OPTARG} + ;; + s) + INSECURE=${OPTARG} + ;; + u) + USER_CTX=${OPTARG} + ;; + :) + echo "ERROR: Option -$OPTARG requires an argument" + exit 1 + ;; + \?) + echo "ERROR: Invalid option -$OPTARG" + exit 1 + ;; + esac +done +shift $((OPTIND-1)) + +echo "::set-output name=cluster-image-registry-push-host::${PUSH_HOST}" +echo "::set-output name=cluster-image-registry-pull-host::${PULL_HOST}" +echo "::set-output name=cluster-image-registry-insecure::${INSECURE}" +echo "::set-output name=cluster-kube-admin-user-ctx::${ADMIN_USER_CTX}" +echo "::set-output name=cluster-kube-user-ctx::${USER_CTX}" + +# Set the image namespace +echo "::set-output name=cluster-image-namespace::${IMAGE_NAMESPACE}" + +# Set the catalog source namespace +echo "::set-output name=cluster-catalog-source-namespace::${CATALOG_SOURCE_NAMESPACE}" + +# +# Export the flag for olm capability +# +echo "::set-output name=cluster-has-olm::${HAS_OLM}" diff --git a/.github/actions/kamel-prepare-env/action.yml b/.github/actions/kamel-prepare-env/action.yml index 666ae87..45871e1 100644 --- a/.github/actions/kamel-prepare-env/action.yml +++ b/.github/actions/kamel-prepare-env/action.yml @@ -103,9 +103,6 @@ runs: shell: bash if: ${{ env.KAMEL_PREPARE_ENV != 'true' }} run : | - - echo "::add-mask::${{ env.DEBUG_USE_EXISTING_IMAGE }}" - # # Avoid preparing the environment repeatedly # diff --git a/.github/workflows/builder.yml b/.github/workflows/builder.yml index bd77998..fd11628 100644 --- a/.github/workflows/builder.yml +++ b/.github/workflows/builder.yml @@ -66,4 +66,5 @@ jobs: uses: ./.github/actions/e2e-builder with: cluster-config-data: ${{ secrets.E2E_CLUSTER_CONFIG }} + cluster-kube-config-data: ${{ secrets.E2E_KUBE_CONFIG }} publisher: ${{ matrix.publisher }} diff --git a/.github/workflows/knative.yml b/.github/workflows/knative.yml index d3cdfd7..6092fd4 100644 --- a/.github/workflows/knative.yml +++ b/.github/workflows/knative.yml @@ -62,6 +62,7 @@ jobs: uses: ./.github/actions/e2e-knative with: cluster-config-data: ${{ secrets.E2E_CLUSTER_CONFIG }} + cluster-kube-config-data: ${{ secrets.E2E_KUBE_CONFIG }} yaks: runs-on: ubuntu-20.04 @@ -76,3 +77,4 @@ jobs: uses: ./.github/actions/e2e-knative-yaks with: cluster-config-data: ${{ secrets.E2E_CLUSTER_CONFIG }} + cluster-kube-config-data: ${{ secrets.E2E_KUBE_CONFIG }} diff --git a/.github/workflows/kubernetes.yml b/.github/workflows/kubernetes.yml index 55ce811..bcb0650 100644 --- a/.github/workflows/kubernetes.yml +++ b/.github/workflows/kubernetes.yml @@ -63,3 +63,4 @@ jobs: uses: ./.github/actions/e2e-kubernetes with: cluster-config-data: ${{ secrets.E2E_CLUSTER_CONFIG }} + cluster-kube-config-data: ${{ secrets.E2E_KUBE_CONFIG }} diff --git a/.github/workflows/openshift.yml b/.github/workflows/openshift.yml index 0470dbb..dff8a72 100644 --- a/.github/workflows/openshift.yml +++ b/.github/workflows/openshift.yml @@ -63,26 +63,32 @@ jobs: name: Prepare Test Environment uses: ./.github/actions/kamel-prepare-env - - id: configure-platform + - id: config-cluster name: Configure Platform uses: ./.github/actions/kamel-config-cluster with: cluster-type: 'ocp3' - - id: build-kamel-binary - name: Build Kamel Binary - uses: ./.github/actions/kamel-build-binary + - id: build-kamel + name: Build Kamel + uses: ./.github/actions/kamel-build + with: + image-registry-push-host: ${{ steps.config-cluster.outputs.cluster-image-registry-push-host }} + image-registry-pull-host: ${{ steps.config-cluster.outputs.cluster-image-registry-pull-host }} + image-namespace: ${{ steps.config-cluster.outputs.cluster-image-namespace }} + # Builds the bundle if an OLM is available - depends on cluster being tested + build-bundle: ${{ steps.config-cluster.outputs.cluster-has-olm }} + # Can be empty and so catalog source will not be created + catalog-source-namespace: ${{ steps.config-cluster.outputs.cluster-catalog-source-namespace }} - - name: Install Kamel Cluster Setup + - id: install-kamel-cluster-setup + name: Install Kamel Cluster Setup uses: ./.github/actions/kamel-install-cluster-setup with: - kube-admin-user-ctx: ${{ steps.configure-platform.outputs.kube-admin-user-ctx }} + kube-admin-user-ctx: ${{ steps.config-cluster.outputs.cluster-kube-admin-user-ctx }} - name: Run IT run: | - # Make the Apache Snapshots or Apache Staging repository enabled by default - export KAMEL_INSTALL_MAVEN_REPOSITORIES=$(make get-staging-repo) - # Then run integration tests make test-integration make test-builder diff --git a/.github/workflows/upgrade.yml b/.github/workflows/upgrade.yml index 7967dc0..fceb860 100644 --- a/.github/workflows/upgrade.yml +++ b/.github/workflows/upgrade.yml @@ -62,3 +62,4 @@ jobs: uses: ./.github/actions/e2e-upgrade with: cluster-config-data: ${{ secrets.E2E_CLUSTER_CONFIG }} + cluster-kube-config-data: ${{ secrets.E2E_KUBE_CONFIG }} diff --git a/.gitmodules b/.gitmodules index 237f21a..4643631 100644 --- a/.gitmodules +++ b/.gitmodules @@ -8,7 +8,3 @@ path = .github/actions/action-dotenv-to-setenv url = https://github.com/c-py/action-dotenv-to-setenv.git branch = tags/v3 -[submodule ".github/actions/json-to-variables"] - path = .github/actions/json-to-variables - url = https://github.com/antifree/json-to-variables.git - branch = tags/v1.0.1 diff --git a/config/rbac/operator-role.yaml b/config/rbac/operator-role.yaml index e505081..0941d6e 100644 --- a/config/rbac/operator-role.yaml +++ b/config/rbac/operator-role.yaml @@ -165,24 +165,3 @@ rules: - patch - update - watch -- apiGroups: - - operators.coreos.com - resources: - - operatorgroups - - subscriptions - - installplans - verbs: - - create - - delete - - update - - get - - list - - watch -- apiGroups: - - operators.coreos.com - resources: - - clusterserviceversions - verbs: - - get - - list - - watch
