fix: builder and sdk changes (#81)
## Description
<!-- **Please link some issue here describing what you are trying to achieve.**
In case there is no issue present for your PR, please consider creating one.
At least please give us some description what you are trying to achieve and why your change is needed. -->
relates to #1234
## Checklist
- [ ] Issue was linked above
- [ ] Code format was applied: `make fmt`
- [ ] Examples were added / adjusted (see `examples/` directory)
- [x] Docs are up-to-date: `make generate-docs` (will be checked by CI)
- [ ] Unit tests got implemented or updated
- [ ] Acceptance tests got implemented or updated (see e.g. [here](f5f99d1709/stackit/internal/services/dns/dns_acc_test.go))
- [x] Unit tests are passing: `make test` (will be checked by CI)
- [x] No linter issues: `make lint` (will be checked by CI)
Co-authored-by: Marcel S. Henselin <marcel.henselin@stackit.cloud>
Co-authored-by: marcel.henselin <marcel.henselin@stackit.cloud>
Reviewed-on: #81
This commit is contained in:
parent
635a9abf20
commit
1033d7e034
145 changed files with 5944 additions and 5298 deletions
220
.github/actions/acc_test/action.yaml
vendored
220
.github/actions/acc_test/action.yaml
vendored
|
|
@ -2,6 +2,11 @@ name: Acceptance Testing
|
|||
description: "Acceptance Testing pipeline"
|
||||
|
||||
inputs:
|
||||
test_timeout_string:
|
||||
description: "string that determines the timeout (default: 45m)"
|
||||
default: '45m'
|
||||
required: true
|
||||
|
||||
go-version:
|
||||
description: "go version to install"
|
||||
default: '1.25'
|
||||
|
|
@ -11,38 +16,78 @@ inputs:
|
|||
description: "STACKIT project ID for tests"
|
||||
required: true
|
||||
|
||||
project_user_email:
|
||||
required: true
|
||||
description: "project user email for acc testing"
|
||||
|
||||
tf_acc_kek_key_id:
|
||||
description: "KEK key ID"
|
||||
required: true
|
||||
|
||||
tf_acc_kek_key_ring_id:
|
||||
description: "KEK key ring ID"
|
||||
required: true
|
||||
|
||||
tf_acc_kek_key_version:
|
||||
description: "KEK key version"
|
||||
required: true
|
||||
|
||||
tf_acc_kek_service_account:
|
||||
description: "KEK service account email"
|
||||
required: true
|
||||
|
||||
region:
|
||||
description: "STACKIT region for tests"
|
||||
default: 'eu01'
|
||||
required: true
|
||||
|
||||
service_account_json:
|
||||
service_account_json_content:
|
||||
description: "STACKIT service account JSON file contents"
|
||||
required: true
|
||||
default: ""
|
||||
|
||||
service_account_json_content_b64:
|
||||
description: "STACKIT service account JSON file contents"
|
||||
required: true
|
||||
default: ""
|
||||
|
||||
service_account_json_file_path:
|
||||
description: "STACKIT service account JSON file contents"
|
||||
required: true
|
||||
default: 'service_account.json'
|
||||
|
||||
test_file:
|
||||
description: "testfile to run"
|
||||
default: ''
|
||||
|
||||
outputs:
|
||||
random-number:
|
||||
description: "Random number"
|
||||
value: ${{ steps.random-number-generator.outputs.random-number }}
|
||||
|
||||
#outputs:
|
||||
# random-number:
|
||||
# description: "Random number"
|
||||
# value: ${{ steps.random-number-generator.outputs.random-number }}
|
||||
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: Random Number Generator
|
||||
id: random-number-generator
|
||||
run: echo "random-number=$(echo $RANDOM)" >> $GITHUB_OUTPUT
|
||||
shell: bash
|
||||
# - name: Random Number Generator
|
||||
# id: random-number-generator
|
||||
# run: echo "random-number=$(echo $RANDOM)" >> $GITHUB_OUTPUT
|
||||
# shell: bash
|
||||
|
||||
- name: Install needed tools
|
||||
shell: bash
|
||||
run: |
|
||||
echo "::group::apt install"
|
||||
set -e
|
||||
apt-get -y -qq update
|
||||
apt-get -y -qq install jq python3 python3-pip python-is-python3 s3cmd git make wget
|
||||
apt-get -y -qq update >apt_update.log 2>apt_update_err.log
|
||||
if [ $? -ne 0 ]; then
|
||||
cat apt_update.log apt_update_err.log
|
||||
fi
|
||||
apt-get -y -qq install jq python3 python3-pip python-is-python3 s3cmd git make wget >apt_get.log 2>apt_get_err.log
|
||||
if [ $? -ne 0 ]; then
|
||||
cat apt_get.log apt_get_err.log
|
||||
fi
|
||||
echo "::endgroup::"
|
||||
|
||||
- name: Setup JAVA
|
||||
uses: actions/setup-java@v5
|
||||
|
|
@ -53,62 +98,165 @@ runs:
|
|||
- name: Install Go ${{ inputs.go-version }}
|
||||
uses: actions/setup-go@v6
|
||||
with:
|
||||
go-version: ${{ inputs.go-version }}
|
||||
# go-version: ${{ inputs.go-version }}
|
||||
check-latest: true
|
||||
go-version-file: 'go.mod'
|
||||
|
||||
- name: Determine GOMODCACHE
|
||||
shell: bash
|
||||
id: goenv
|
||||
run: |
|
||||
set -e
|
||||
echo "gomodcache=$(go env GOMODCACHE)" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Restore cached GO pkg
|
||||
id: cache-gopkg
|
||||
uses: actions/cache/restore@v5
|
||||
with:
|
||||
path: "${{ steps.goenv.outputs.gomodcache }}"
|
||||
key: ${{ runner.os }}-gopkg
|
||||
|
||||
- name: Install go tools
|
||||
if: steps.cache-gopkg.outputs.cache-hit != 'true'
|
||||
shell: bash
|
||||
run: |
|
||||
echo "::group::go install"
|
||||
set -e
|
||||
go mod download
|
||||
go install golang.org/x/tools/cmd/goimports@latest
|
||||
go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.7.2
|
||||
go install github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs@v0.24.0
|
||||
go install github.com/hashicorp/terraform-plugin-codegen-framework/cmd/tfplugingen-framework@latest
|
||||
go install github.com/hashicorp/terraform-plugin-codegen-openapi/cmd/tfplugingen-openapi@latest
|
||||
go install github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs@latest
|
||||
go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest
|
||||
echo "::endgroup::"
|
||||
- name: Run go mod tidy
|
||||
shell: bash
|
||||
run: go mod tidy
|
||||
|
||||
- name: Prepare pkg_gen directory
|
||||
- name: Save GO package Cache
|
||||
id: cache-gopkg-save
|
||||
uses: actions/cache/save@v5
|
||||
with:
|
||||
path: |
|
||||
${{ steps.goenv.outputs.gomodcache }}
|
||||
key: ${{ runner.os }}-gopkg
|
||||
|
||||
- name: Creating service_account file from json input
|
||||
if: inputs.service_account_json_content != ''
|
||||
shell: bash
|
||||
run: |
|
||||
go run cmd/main.go build -p
|
||||
echo "::group::create service account file"
|
||||
set -e
|
||||
set -o pipefail
|
||||
|
||||
jsonFile="${{ inputs.service_account_json_file_path }}"
|
||||
jsonFile="${jsonFile:-x}"
|
||||
if [ "${jsonFile}" == "x" ]; then
|
||||
echo "no service account file path provided"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -f "${jsonFile}" ]; then
|
||||
echo "creating service account file '${{ inputs.service_account_json_file_path }}'"
|
||||
echo "${{ inputs.service_account_json_content }}" > stackit/"${{ inputs.service_account_json_file_path }}"
|
||||
fi
|
||||
ls -l stackit/"${{ inputs.service_account_json_file_path }}"
|
||||
echo "::endgroup::"
|
||||
|
||||
- name: Creating service_account file from base64 json input
|
||||
if: inputs.service_account_json_content_b64 != ''
|
||||
shell: bash
|
||||
run: |
|
||||
echo "::group::create service account file"
|
||||
set -e
|
||||
set -o pipefail
|
||||
|
||||
jsonFile="${{ inputs.service_account_json_file_path }}"
|
||||
jsonFile="${jsonFile:-x}"
|
||||
if [ "${jsonFile}" == "x" ]; then
|
||||
echo "no service account file path provided"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -f "${jsonFile}" ]; then
|
||||
echo "creating service account file '${{ inputs.service_account_json_file_path }}'"
|
||||
echo "${{ inputs.service_account_json_content_b64 }}" | base64 -d > stackit/"${{ inputs.service_account_json_file_path }}"
|
||||
fi
|
||||
ls -l stackit/"${{ inputs.service_account_json_file_path }}"
|
||||
echo "::endgroup::"
|
||||
|
||||
- name: Run acceptance test file
|
||||
if: ${{ inputs.test_file != '' }}
|
||||
shell: bash
|
||||
run: |
|
||||
echo "::group::go test file"
|
||||
set -e
|
||||
set -o pipefail
|
||||
|
||||
echo "Running acceptance tests for the terraform provider"
|
||||
echo "${STACKIT_SERVICE_ACCOUNT_JSON}" > ~/.service_account.json
|
||||
cd stackit
|
||||
cd stackit || exit 1
|
||||
TF_ACC=1 \
|
||||
TF_ACC_PROJECT_ID=${TF_ACC_PROJECT_ID} \
|
||||
TF_ACC_REGION=${TF_ACC_REGION} \
|
||||
go test ${{ inputs.test_file }} -count=1 -timeout=30m
|
||||
TF_ACC_TEST_PROJECT_USER_EMAIL=${TF_ACC_TEST_PROJECT_USER_EMAIL} \
|
||||
TF_ACC_SERVICE_ACCOUNT_FILE="${PWD}/${{ inputs.service_account_json_file_path }}" \
|
||||
TF_ACC_KEK_KEY_ID=${TF_ACC_KEK_KEY_ID} \
|
||||
TF_ACC_KEK_KEY_RING_ID=${TF_ACC_KEK_KEY_RING_ID} \
|
||||
TF_ACC_KEK_KEY_VERSION=${TF_ACC_KEK_KEY_VERSION} \
|
||||
TF_ACC_KEK_SERVICE_ACCOUNT=${TF_ACC_KEK_SERVICE_ACCOUNT} \
|
||||
go test ${{ inputs.test_file }} -count=1 -timeout=${{ inputs.test_timeout_string }}
|
||||
echo "::endgroup::"
|
||||
env:
|
||||
STACKIT_SERVICE_ACCOUNT_JSON: ${{ inputs.service_account_json }}
|
||||
TF_PROJECT_ID: ${{ inputs.project_id }}
|
||||
TF_ACC_PROJECT_ID: ${{ inputs.project_id }}
|
||||
TF_ACC_REGION: ${{ inputs.region }}
|
||||
# TF_ACC_TEST_PROJECT_SERVICE_ACCOUNT_EMAIL: ${{ secrets.TF_ACC_TEST_PROJECT_SERVICE_ACCOUNT_EMAIL }}
|
||||
# TF_ACC_TEST_PROJECT_SERVICE_ACCOUNT_TOKEN: ${{ secrets.TF_ACC_TEST_PROJECT_SERVICE_ACCOUNT_TOKEN }}
|
||||
# TF_ACC_TEST_PROJECT_PARENT_CONTAINER_ID: ${{ secrets.TF_ACC_TEST_PROJECT_PARENT_CONTAINER_ID }}
|
||||
# TF_ACC_TEST_PROJECT_PARENT_UUID: ${{ secrets.TF_ACC_TEST_PROJECT_PARENT_UUID }}
|
||||
# TF_ACC_TEST_PROJECT_USER_EMAIL: ${{ secrets.TF_ACC_TEST_PROJECT_USER_EMAIL }}
|
||||
TF_ACC_TEST_PROJECT_USER_EMAIL: ${{ inputs.project_user_email }}
|
||||
TF_ACC_KEK_KEY_ID: ${{ inputs.tf_acc_kek_key_id }}
|
||||
TF_ACC_KEK_KEY_RING_ID: ${{ inputs.tf_acc_kek_key_ring_id }}
|
||||
TF_ACC_KEK_KEY_VERSION: ${{ inputs.tf_acc_kek_key_version }}
|
||||
TF_ACC_KEK_SERVICE_ACCOUNT: ${{ inputs.tf_acc_kek_service_account }}
|
||||
|
||||
# - name: Run test action
|
||||
# if: ${{ inputs.test_file == '' }}
|
||||
# env:
|
||||
# TF_ACC: 1
|
||||
# TF_ACC_PROJECT_ID: ${{ inputs.project_id }}
|
||||
# TF_ACC_REGION: ${{ inputs.region }}
|
||||
# TF_ACC_TEST_PROJECT_USER_EMAIL: ${{ inputs.project_user_email }}
|
||||
# TF_ACC_KEK_KEY_ID: ${{ inputs.tf_acc_kek_key_id }}
|
||||
# TF_ACC_KEK_KEY_RING_ID: ${{ inputs.tf_acc_kek_key_ring_id }}
|
||||
# TF_ACC_KEK_KEY_VERSION: ${{ inputs.tf_acc_kek_key_version }}
|
||||
# TF_ACC_KEK_SERVICE_ACCOUNT: ${{ inputs.tf_acc_kek_service_account }}
|
||||
# TF_ACC_SERVICE_ACCOUNT_FILE: "${PWD}/${{ inputs.service_account_json_file_path }}"
|
||||
# uses: robherley/go-test-action@v0.1.0
|
||||
# with:
|
||||
# testArguments: "./... -timeout 45m"
|
||||
|
||||
- name: Run acceptance tests
|
||||
if: ${{ inputs.test_file == '' }}
|
||||
shell: bash
|
||||
run: |
|
||||
echo "::group::go test all"
|
||||
set -e
|
||||
set -o pipefail
|
||||
|
||||
echo "Running acceptance tests for the terraform provider"
|
||||
echo "${STACKIT_SERVICE_ACCOUNT_JSON}" > ~/.service_account.json
|
||||
cd stackit
|
||||
cd stackit || exit 1
|
||||
TF_ACC=1 \
|
||||
TF_ACC_PROJECT_ID=${TF_ACC_PROJECT_ID} \
|
||||
TF_ACC_REGION=${TF_ACC_REGION} \
|
||||
go test ./... -count=1 -timeout=30m
|
||||
TF_ACC_TEST_PROJECT_USER_EMAIL=${TF_ACC_TEST_PROJECT_USER_EMAIL} \
|
||||
TF_ACC_SERVICE_ACCOUNT_FILE="${PWD}/${{ inputs.service_account_json_file_path }}" \
|
||||
TF_ACC_KEK_KEY_ID=${TF_ACC_KEK_KEY_ID} \
|
||||
TF_ACC_KEK_KEY_RING_ID=${TF_ACC_KEK_KEY_RING_ID} \
|
||||
TF_ACC_KEK_KEY_VERSION=${TF_ACC_KEK_KEY_VERSION} \
|
||||
TF_ACC_KEK_SERVICE_ACCOUNT=${TF_ACC_KEK_SERVICE_ACCOUNT} \
|
||||
go test ./... -count=1 -timeout=${{ inputs.test_timeout_string }}
|
||||
echo "::endgroup::"
|
||||
env:
|
||||
STACKIT_SERVICE_ACCOUNT_JSON: ${{ inputs.service_account_json }}
|
||||
TF_PROJECT_ID: ${{ inputs.project_id }}
|
||||
TF_ACC_PROJECT_ID: ${{ inputs.project_id }}
|
||||
TF_ACC_REGION: ${{ inputs.region }}
|
||||
# TF_ACC_TEST_PROJECT_SERVICE_ACCOUNT_EMAIL: ${{ secrets.TF_ACC_TEST_PROJECT_SERVICE_ACCOUNT_EMAIL }}
|
||||
# TF_ACC_TEST_PROJECT_SERVICE_ACCOUNT_TOKEN: ${{ secrets.TF_ACC_TEST_PROJECT_SERVICE_ACCOUNT_TOKEN }}
|
||||
# TF_ACC_TEST_PROJECT_PARENT_CONTAINER_ID: ${{ secrets.TF_ACC_TEST_PROJECT_PARENT_CONTAINER_ID }}
|
||||
# TF_ACC_TEST_PROJECT_PARENT_UUID: ${{ secrets.TF_ACC_TEST_PROJECT_PARENT_UUID }}
|
||||
# TF_ACC_TEST_PROJECT_USER_EMAIL: ${{ secrets.TF_ACC_TEST_PROJECT_USER_EMAIL }}
|
||||
TF_ACC_TEST_PROJECT_USER_EMAIL: ${{ inputs.project_user_email }}
|
||||
TF_ACC_KEK_KEY_ID: ${{ inputs.tf_acc_kek_key_id }}
|
||||
TF_ACC_KEK_KEY_RING_ID: ${{ inputs.tf_acc_kek_key_ring_id }}
|
||||
TF_ACC_KEK_KEY_VERSION: ${{ inputs.tf_acc_kek_key_version }}
|
||||
TF_ACC_KEK_SERVICE_ACCOUNT: ${{ inputs.tf_acc_kek_service_account }}
|
||||
|
|
|
|||
54
.github/actions/build/action.yaml
vendored
54
.github/actions/build/action.yaml
vendored
|
|
@ -20,25 +20,63 @@ runs:
|
|||
run: |
|
||||
set -e
|
||||
apt-get -y -qq update
|
||||
apt-get -y -qq install jq python3 python3-pip python-is-python3 s3cmd git make wget
|
||||
apt-get -y -qq install jq python3 python3-pip python-is-python3 s3cmd git make wget unzip bc
|
||||
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: Install Go ${{ inputs.go-version }}
|
||||
uses: actions/setup-go@v6
|
||||
with:
|
||||
go-version: ${{ inputs.go-version }}
|
||||
# go-version: ${{ inputs.go-version }}
|
||||
check-latest: true
|
||||
go-version-file: 'go.mod'
|
||||
|
||||
- name: Determine GOMODCACHE
|
||||
shell: bash
|
||||
id: goenv
|
||||
run: |
|
||||
set -e
|
||||
# echo "::set-output name=gomodcache::$(go env GOMODCACHE)"
|
||||
echo "gomodcache=$(go env GOMODCACHE)" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Restore cached GO pkg
|
||||
id: cache-gopkg
|
||||
uses: actions/cache/restore@v5
|
||||
with:
|
||||
path: "${{ steps.goenv.outputs.gomodcache }}"
|
||||
key: ${{ runner.os }}-gopkg
|
||||
|
||||
- name: Install go tools
|
||||
if: steps.cache-gopkg.outputs.cache-hit != 'true'
|
||||
shell: bash
|
||||
run: |
|
||||
set -e
|
||||
go install golang.org/x/tools/cmd/goimports@latest
|
||||
go install github.com/hashicorp/terraform-plugin-codegen-framework/cmd/tfplugingen-framework@latest
|
||||
go install github.com/hashicorp/terraform-plugin-codegen-openapi/cmd/tfplugingen-openapi@latest
|
||||
go install github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs@v0.24.0
|
||||
go install github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs@latest
|
||||
|
||||
# - name: Run build pkg directory
|
||||
# shell: bash
|
||||
# run: |
|
||||
# set -e
|
||||
# go run generator/main.go build
|
||||
|
||||
- name: Get all go packages
|
||||
if: steps.cache-gopkg.outputs.cache-hit != 'true'
|
||||
shell: bash
|
||||
run: |
|
||||
set -e
|
||||
go get ./...
|
||||
|
||||
- name: Save Cache
|
||||
id: cache-gopkg-save
|
||||
uses: actions/cache/save@v5
|
||||
with:
|
||||
path: |
|
||||
${{ steps.goenv.outputs.gomodcache }}
|
||||
key: ${{ runner.os }}-gopkg
|
||||
|
||||
- name: Setup JAVA ${{ inputs.java-distribution }} ${{ inputs.go-version }}
|
||||
uses: actions/setup-java@v5
|
||||
|
|
@ -46,16 +84,6 @@ runs:
|
|||
distribution: ${{ inputs.java-distribution }} # See 'Supported distributions' for available options
|
||||
java-version: ${{ inputs.java-version }}
|
||||
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: Run build pkg directory
|
||||
shell: bash
|
||||
run: |
|
||||
set -e
|
||||
go run cmd/main.go build
|
||||
|
||||
|
||||
- name: Run make to build app
|
||||
shell: bash
|
||||
run: |
|
||||
|
|
|
|||
4
.github/actions/setup-cache-go/action.yaml
vendored
4
.github/actions/setup-cache-go/action.yaml
vendored
|
|
@ -26,9 +26,9 @@ runs:
|
|||
uses: https://code.forgejo.org/actions/setup-go@v6
|
||||
id: go-version
|
||||
with:
|
||||
go-version: ${{ inputs.go-version }}
|
||||
# go-version: ${{ inputs.go-version }}
|
||||
check-latest: true # Always check for the latest patch release
|
||||
# go-version-file: "go.mod"
|
||||
go-version-file: "go.mod"
|
||||
# do not cache dependencies, we do this manually
|
||||
cache: false
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue