diff --git a/.github/workflows/trivy.yml b/.github/workflows/trivy.yml index 03323479..b1b02a08 100644 --- a/.github/workflows/trivy.yml +++ b/.github/workflows/trivy.yml @@ -53,7 +53,7 @@ jobs: uses: aquasecurity/trivy-action@0.20.0 with: scan-type: 'image' - format: 'spdx' + format: 'spdx-json' output: 'dependency-results.sbom.json' image-ref: 'trivy/charmed-spark:test' github-pat: ${{ secrets.GITHUB_TOKEN }} diff --git a/tests/integration/setup-aws-cli.sh b/tests/integration/setup-aws-cli.sh index a6386697..5f513d35 100755 --- a/tests/integration/setup-aws-cli.sh +++ b/tests/integration/setup-aws-cli.sh @@ -4,11 +4,8 @@ sudo snap install aws-cli --classic -get_s3_endpoint(){ - # Get S3 endpoint from MinIO - kubectl get service minio -n minio-operator -o jsonpath='{.spec.clusterIP}' -} +source ./utils/s3-utils.sh wait_and_retry(){ # Retry a command for a number of times by waiting a few seconds. @@ -37,8 +34,8 @@ wait_and_retry get_s3_endpoint S3_ENDPOINT=$(get_s3_endpoint) DEFAULT_REGION="us-east-2" -ACCESS_KEY=$(kubectl get secret -n minio-operator microk8s-user-1 -o jsonpath='{.data.CONSOLE_ACCESS_KEY}' | base64 -d) -SECRET_KEY=$(kubectl get secret -n minio-operator microk8s-user-1 -o jsonpath='{.data.CONSOLE_SECRET_KEY}' | base64 -d) +ACCESS_KEY=$(get_s3_access_key) +SECRET_KEY=$(get_s3_secret_key) # Configure AWS CLI credentials aws configure set aws_access_key_id $ACCESS_KEY diff --git a/tests/integration/utils/s3-utils.sh b/tests/integration/utils/s3-utils.sh index 9008f0e8..c297e83d 100644 --- a/tests/integration/utils/s3-utils.sh +++ b/tests/integration/utils/s3-utils.sh @@ -20,14 +20,30 @@ get_s3_endpoint(){ get_s3_access_key(){ - # Print the S3 Access Key by reading it from K8s secret - kubectl get secret -n minio-operator microk8s-user-1 -o jsonpath='{.data.CONSOLE_ACCESS_KEY}' | base64 -d + # Print the S3 Access Key by reading it from K8s secret or by outputting the default value + kubectl get secret -n minio-operator microk8s-user-1 + if [ $? -eq 0 ]; then + echo "Use access-key from secret" + access_key=$(kubectl get secret -n minio-operator microk8s-user-1 -o jsonpath='{.data.CONSOLE_ACCESS_KEY}' | base64 -d) + else + echo "use default access-key" + access_key="minio" + fi + echo "$access_key" } get_s3_secret_key(){ - # Print the S3 Secret Key by reading it from K8s secret - kubectl get secret -n minio-operator microk8s-user-1 -o jsonpath='{.data.CONSOLE_SECRET_KEY}' | base64 -d + # Print the S3 Secret Key by reading it from K8s secret or by outputting the default value + kubectl get secret -n minio-operator microk8s-user-1 + if [ $? -eq 0 ]; then + echo "Use access-key from secret" + secret_key=$(kubectl get secret -n minio-operator microk8s-user-1 -o jsonpath='{.data.CONSOLE_SECRET_KEY}' | base64 -d) + else + echo "use default access-key" + secret_key="minio123" + fi + echo "$secret_key" }