From 6f843e3d18e5fe8774c10438368cfc6a0355984a Mon Sep 17 00:00:00 2001 From: samitab Date: Wed, 24 Apr 2024 12:14:13 +1000 Subject: [PATCH 1/7] [ignore] Added Terraform CI for build and integration tests --- .github/workflows/checks.yml | 62 ++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 .github/workflows/checks.yml diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml new file mode 100644 index 000000000..abfba7ec2 --- /dev/null +++ b/.github/workflows/checks.yml @@ -0,0 +1,62 @@ +name: CI + +on: + push: + branches: [master] + pull_request: + +permissions: + # Permission for checking out code + contents: read + +jobs: + build: + name: Check & Build Provider + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + go-version-file: 'go.mod' + - run: chmod +x ./scripts/gofmtcheck.sh + - name: gofmt Check + run: ./scripts/gofmtcheck.sh + # - name: Generate provider code + # run: go generate + # - name: Check generated code for diffs + # run: git diff --exit-code + - name: Build + run: go build -v + acceptance: + name: Acceptance Tests + needs: build + runs-on: ubuntu-latest + concurrency: + group: tf-aci-ci-test-${{ matrix.apic_host.name }} + cancel-in-progress: false + strategy: + fail-fast: false + matrix: + apic_host: + - name: v5.2 + url: 'https://173.36.219.83/' + - name: v6.0 + url: 'https://173.36.219.84/' + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + go-version-file: 'go.mod' + - uses: hashicorp/setup-terraform@v2 + with: + terraform_version: '1.7.*' + terraform_wrapper: false + - name: Terraform Acceptance Test (APIC ${{ matrix.apic_host.name }}) + run: go test github.com/CiscoDevNet/terraform-provider-aci/v2/internal/provider -v -cover -timeout 120m + env: + TF_ACC: '1' + TF_ACC_STATE_LINEAGE: '1' + ACI_VAL_REL_DN: false + ACI_USERNAME: ${{ secrets.TF_ACC_ACI_USERNAME }} + ACI_PASSWORD: ${{ secrets.TF_ACC_ACI_PASSWORD }} + ACI_URL: ${{ matrix.apic_host.url }} \ No newline at end of file From e393f0e7f2ffe5ea54074f5beb63df969d4f679e Mon Sep 17 00:00:00 2001 From: samitab Date: Wed, 24 Apr 2024 15:08:19 +1000 Subject: [PATCH 2/7] [ignore] Added testing pipeline APIC hosts --- .github/workflows/checks.yml | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index abfba7ec2..c02384f21 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -27,10 +27,14 @@ jobs: # run: git diff --exit-code - name: Build run: go build -v + acceptance: name: Acceptance Tests needs: build runs-on: ubuntu-latest + env: + ACI_USERNAME: 'ansible_github_ci' + ACI_PASSWORD: 'sJ94G92#8dq2hx*K4qh' concurrency: group: tf-aci-ci-test-${{ matrix.apic_host.name }} cancel-in-progress: false @@ -38,10 +42,16 @@ jobs: fail-fast: false matrix: apic_host: + - name: v4.2 + url: 'https://173.36.219.68/' - name: v5.2 - url: 'https://173.36.219.83/' + url: 'https://173.36.219.69/' - name: v6.0 - url: 'https://173.36.219.84/' + url: 'https://173.36.219.70/' + - name: aws_cloud + url: 'https://52.52.20.121/' + - name: azure_cloud + url: 'https://20.245.236.136/' steps: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 @@ -57,6 +67,4 @@ jobs: TF_ACC: '1' TF_ACC_STATE_LINEAGE: '1' ACI_VAL_REL_DN: false - ACI_USERNAME: ${{ secrets.TF_ACC_ACI_USERNAME }} - ACI_PASSWORD: ${{ secrets.TF_ACC_ACI_PASSWORD }} ACI_URL: ${{ matrix.apic_host.url }} \ No newline at end of file From 98e276f50728979166d17522a95086e0671fbf80 Mon Sep 17 00:00:00 2001 From: samitab Date: Mon, 29 Apr 2024 06:45:51 +1000 Subject: [PATCH 3/7] [ignore] Generate codecov report --- .github/workflows/checks.yml | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index c02384f21..0bcece87f 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -21,16 +21,25 @@ jobs: - run: chmod +x ./scripts/gofmtcheck.sh - name: gofmt Check run: ./scripts/gofmtcheck.sh - # - name: Generate provider code - # run: go generate - # - name: Check generated code for diffs - # run: git diff --exit-code - name: Build run: go build -v + # diff: + # name: Check Generated Code Difference + # runs-on: ubuntu-latest + # steps: + # - uses: actions/checkout@v4 + # - uses: actions/setup-go@v5 + # with: + # go-version-file: 'go.mod' + # - name: Generate provider code + # run: go generate + # - name: Check generated code for diffs + # run: git diff --exit-code + acceptance: name: Acceptance Tests - needs: build + needs: [build] runs-on: ubuntu-latest env: ACI_USERNAME: 'ansible_github_ci' @@ -48,10 +57,10 @@ jobs: url: 'https://173.36.219.69/' - name: v6.0 url: 'https://173.36.219.70/' - - name: aws_cloud - url: 'https://52.52.20.121/' - - name: azure_cloud - url: 'https://20.245.236.136/' + # - name: aws_cloud + # url: 'https://52.52.20.121/' + # - name: azure_cloud + # url: 'https://20.245.236.136/' steps: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 @@ -62,9 +71,13 @@ jobs: terraform_version: '1.7.*' terraform_wrapper: false - name: Terraform Acceptance Test (APIC ${{ matrix.apic_host.name }}) - run: go test github.com/CiscoDevNet/terraform-provider-aci/v2/internal/provider -v -cover -timeout 120m + run: go test github.com/CiscoDevNet/terraform-provider-aci/v2/internal/provider -v -timeout 300m -race -coverprofile=coverage.out -covermode=atomic env: TF_ACC: '1' TF_ACC_STATE_LINEAGE: '1' ACI_VAL_REL_DN: false - ACI_URL: ${{ matrix.apic_host.url }} \ No newline at end of file + ACI_URL: ${{ matrix.apic_host.url }} + - name: Upload coverage to Codecov + # Upload Coverage on latest only + if: ${{ matrix.apic_host.name == 'v6.0'}} + uses: codecov/codecov-action@v3 \ No newline at end of file From 5048fd7ea0181d120c2dbdcc79490c822ee27dc8 Mon Sep 17 00:00:00 2001 From: samitab Date: Mon, 29 Apr 2024 06:57:25 +1000 Subject: [PATCH 4/7] [ignore] Add check for missed vendor changes --- .github/workflows/checks.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 0bcece87f..53b19fe0f 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -21,6 +21,10 @@ jobs: - run: chmod +x ./scripts/gofmtcheck.sh - name: gofmt Check run: ./scripts/gofmtcheck.sh + - run: go mod tidy + - run: go mod vendor + - name: Check vendor for changes + run: git diff --exit-code - name: Build run: go build -v From 55ce1face358f0c46cae696d00b967d789ea45da Mon Sep 17 00:00:00 2001 From: samitab Date: Mon, 29 Apr 2024 09:17:45 +1000 Subject: [PATCH 5/7] [ignore] Remove race check for test --- .github/workflows/checks.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 53b19fe0f..51bc92fc3 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -75,7 +75,7 @@ jobs: terraform_version: '1.7.*' terraform_wrapper: false - name: Terraform Acceptance Test (APIC ${{ matrix.apic_host.name }}) - run: go test github.com/CiscoDevNet/terraform-provider-aci/v2/internal/provider -v -timeout 300m -race -coverprofile=coverage.out -covermode=atomic + run: go test github.com/CiscoDevNet/terraform-provider-aci/v2/internal/provider -v -timeout 300m -coverprofile=coverage.out -covermode=atomic env: TF_ACC: '1' TF_ACC_STATE_LINEAGE: '1' From 88d69f37f622341fb94f7b0c5264a81587284807 Mon Sep 17 00:00:00 2001 From: samitab Date: Mon, 29 Apr 2024 09:43:12 +1000 Subject: [PATCH 6/7] [ignore] Update terraform action version --- .github/workflows/checks.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 51bc92fc3..bafed17c4 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -55,8 +55,8 @@ jobs: fail-fast: false matrix: apic_host: - - name: v4.2 - url: 'https://173.36.219.68/' + # - name: v4.2 + # url: 'https://173.36.219.68/' - name: v5.2 url: 'https://173.36.219.69/' - name: v6.0 @@ -70,7 +70,7 @@ jobs: - uses: actions/setup-go@v5 with: go-version-file: 'go.mod' - - uses: hashicorp/setup-terraform@v2 + - uses: hashicorp/setup-terraform@v3 with: terraform_version: '1.7.*' terraform_wrapper: false From 8224f652622ee552f080882324b5c5473e8909f7 Mon Sep 17 00:00:00 2001 From: samitab Date: Mon, 29 Apr 2024 06:58:55 +1000 Subject: [PATCH 7/7] [ignore] Add missing booldefault module and fix rest managed data source. --- .../provider/data_source_aci_rest_managed.go | 14 ++++++- .../resource/schema/booldefault/doc.go | 5 +++ .../schema/booldefault/static_value.go | 42 +++++++++++++++++++ vendor/modules.txt | 1 + 4 files changed, 60 insertions(+), 2 deletions(-) create mode 100644 vendor/github.com/hashicorp/terraform-plugin-framework/resource/schema/booldefault/doc.go create mode 100644 vendor/github.com/hashicorp/terraform-plugin-framework/resource/schema/booldefault/static_value.go diff --git a/internal/provider/data_source_aci_rest_managed.go b/internal/provider/data_source_aci_rest_managed.go index 8ccf1ccea..32e32732e 100644 --- a/internal/provider/data_source_aci_rest_managed.go +++ b/internal/provider/data_source_aci_rest_managed.go @@ -27,6 +27,16 @@ type AciRestManagedDataSource struct { client *client.Client } +// AciRestManagedDataSourceModel describes the data source model. +type AciRestManagedDataSourceModel struct { + Id types.String `tfsdk:"id"` + Dn types.String `tfsdk:"dn"` + ClassName types.String `tfsdk:"class_name"` + Content types.Map `tfsdk:"content"` + Child types.Set `tfsdk:"child"` + Annotation types.String `tfsdk:"annotation"` +} + func (d *AciRestManagedDataSource) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { tflog.Debug(ctx, "Start schema of datasource: aci_rest_managed") resp.TypeName = req.ProviderTypeName + "_rest_managed" @@ -110,7 +120,7 @@ func (d *AciRestManagedDataSource) Configure(ctx context.Context, req datasource func (d *AciRestManagedDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { tflog.Debug(ctx, "Start read of datasource: aci_rest_managed") - var data *AciRestManagedResourceModel + var data *AciRestManagedDataSourceModel // Read Terraform configuration data into the model resp.Diagnostics.Append(req.Config.Get(ctx, &data)...) @@ -202,7 +212,7 @@ func (d *AciRestManagedDataSource) Read(ctx context.Context, req datasource.Read } -func dataSourceRestManagedNotFoundError(diags *diag.Diagnostics, data *AciRestManagedResourceModel) { +func dataSourceRestManagedNotFoundError(diags *diag.Diagnostics, data *AciRestManagedDataSourceModel) { diags.AddError( "Failed to read aci_rest_managed data source", fmt.Sprintf("The aci_rest_managed data source with dn '%s' has not been found", data.Dn), diff --git a/vendor/github.com/hashicorp/terraform-plugin-framework/resource/schema/booldefault/doc.go b/vendor/github.com/hashicorp/terraform-plugin-framework/resource/schema/booldefault/doc.go new file mode 100644 index 000000000..fe6b0f76d --- /dev/null +++ b/vendor/github.com/hashicorp/terraform-plugin-framework/resource/schema/booldefault/doc.go @@ -0,0 +1,5 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +// Package booldefault provides default values for types.Bool attributes. +package booldefault diff --git a/vendor/github.com/hashicorp/terraform-plugin-framework/resource/schema/booldefault/static_value.go b/vendor/github.com/hashicorp/terraform-plugin-framework/resource/schema/booldefault/static_value.go new file mode 100644 index 000000000..797f81d09 --- /dev/null +++ b/vendor/github.com/hashicorp/terraform-plugin-framework/resource/schema/booldefault/static_value.go @@ -0,0 +1,42 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +package booldefault + +import ( + "context" + "fmt" + + "github.com/hashicorp/terraform-plugin-framework/resource/schema/defaults" + "github.com/hashicorp/terraform-plugin-framework/types" +) + +// StaticBool returns a static boolean value default handler. +// +// Use StaticBool if a static default value for a boolean should be set. +func StaticBool(defaultVal bool) defaults.Bool { + return staticBoolDefault{ + defaultVal: defaultVal, + } +} + +// staticBoolDefault is static value default handler that +// sets a value on a boolean attribute. +type staticBoolDefault struct { + defaultVal bool +} + +// Description returns a human-readable description of the default value handler. +func (d staticBoolDefault) Description(_ context.Context) string { + return fmt.Sprintf("value defaults to %t", d.defaultVal) +} + +// MarkdownDescription returns a markdown description of the default value handler. +func (d staticBoolDefault) MarkdownDescription(_ context.Context) string { + return fmt.Sprintf("value defaults to `%t`", d.defaultVal) +} + +// DefaultBool implements the static default value logic. +func (d staticBoolDefault) DefaultBool(_ context.Context, req defaults.BoolRequest, resp *defaults.BoolResponse) { + resp.PlanValue = types.BoolValue(d.defaultVal) +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 84d288adc..616c39caa 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -164,6 +164,7 @@ github.com/hashicorp/terraform-plugin-framework/provider/schema github.com/hashicorp/terraform-plugin-framework/providerserver github.com/hashicorp/terraform-plugin-framework/resource github.com/hashicorp/terraform-plugin-framework/resource/schema +github.com/hashicorp/terraform-plugin-framework/resource/schema/booldefault github.com/hashicorp/terraform-plugin-framework/resource/schema/defaults github.com/hashicorp/terraform-plugin-framework/resource/schema/mapplanmodifier github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier