From 105761d00ae8c0167e1267199cb6c5959f9bdf99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1ximo=20Cuadros?= Date: Tue, 6 Apr 2021 15:58:07 +0200 Subject: [PATCH] ci: fix github action --- .github/workflows/test.yml | 4 +- starlark/types/backend.go | 11 +- .../types/fixtures/state/terraform.tfstate | 32 ---- starlark/types/resource.go | 4 + .../testdata/examples/provider_resource.star | 2 +- .../types/testdata/examples/terraform.tfstate | 138 ------------------ 6 files changed, 16 insertions(+), 175 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6ca40ae..ef856ac 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,7 +11,7 @@ jobs: strategy: fail-fast: false matrix: - go-version: [1.13.x, 1.14.x] + go-version: [1.15.x, 1.16.x] platform: [ubuntu-latest, macos-latest, windows-latest] runs-on: ${{ matrix.platform }} steps: @@ -25,7 +25,7 @@ jobs: uses: actions/checkout@v2 - name: Allow skip provisioner tests - uses: allenevans/set-env@v1.0.0 + uses: allenevans/set-env@v2.0.0 if: matrix.os != 'ubuntu-latest' with: ALLOW_PROVISIONER_SKIP: 1 diff --git a/starlark/types/backend.go b/starlark/types/backend.go index b4716e5..6be7e5a 100644 --- a/starlark/types/backend.go +++ b/starlark/types/backend.go @@ -286,11 +286,18 @@ func (s *State) initializeResource(p *Provider, r *states.Resource) error { mode := addrsResourceModeString(r.Addr.Mode) var schema providers.Schema + var ok bool switch r.Addr.Mode { case addrs.DataResourceMode: - schema = p.dataSources.schemas[typ] + schema, ok = p.dataSources.schemas[typ] + if !ok { + return fmt.Errorf("unknown data resource %s", typ) + } case addrs.ManagedResourceMode: - schema = p.resources.schemas[typ] + schema, ok = p.resources.schemas[typ] + if !ok { + return fmt.Errorf("unknown resource %s", typ) + } default: return fmt.Errorf("invalid resource type") } diff --git a/starlark/types/fixtures/state/terraform.tfstate b/starlark/types/fixtures/state/terraform.tfstate index f3c51b4..cb21620 100644 --- a/starlark/types/fixtures/state/terraform.tfstate +++ b/starlark/types/fixtures/state/terraform.tfstate @@ -23,33 +23,6 @@ } ] }, - { - "mode": "data", - "type": "helm_repository", - "name": "stable", - "provider": "provider.helm.default", - "instances": [ - { - "schema_version": 0, - "attributes": { - "ca_file": null, - "cert_file": null, - "id": "stable", - "key_file": null, - "metadata": [ - { - "name": "stable", - "url": "https://kubernetes-charts.storage.googleapis.com" - } - ], - "name": "stable", - "password": null, - "url": "https://kubernetes-charts.storage.googleapis.com", - "username": null - } - } - ] - }, { "mode": "managed", "type": "google_container_cluster", @@ -352,7 +325,6 @@ "reuse_values": false, "set": [], "set_sensitive": [], - "set_string": [], "skip_crds": false, "status": "deployed", "timeout": 300, @@ -424,7 +396,6 @@ } ], "set_sensitive": [], - "set_string": [], "skip_crds": false, "status": "deployed", "timeout": 300, @@ -498,7 +469,6 @@ } ], "set_sensitive": [], - "set_string": [], "skip_crds": false, "status": "deployed", "timeout": 300, @@ -565,7 +535,6 @@ } ], "set_sensitive": [], - "set_string": [], "skip_crds": false, "status": "deployed", "timeout": 300, @@ -626,7 +595,6 @@ "reuse_values": false, "set": [], "set_sensitive": [], - "set_string": [], "skip_crds": false, "status": "deployed", "timeout": 300, diff --git a/starlark/types/resource.go b/starlark/types/resource.go index 56a70e3..9cb1daf 100644 --- a/starlark/types/resource.go +++ b/starlark/types/resource.go @@ -224,6 +224,10 @@ func NewResource( b *configschema.Block, provider *Provider, parent *Resource, cs starlark.CallStack, ) *Resource { + + if b == nil { + b.Attributes["fpoo"] = nil + } return &Resource{ name: name, typ: typ, diff --git a/starlark/types/testdata/examples/provider_resource.star b/starlark/types/testdata/examples/provider_resource.star index 6e96b66..ecd0587 100644 --- a/starlark/types/testdata/examples/provider_resource.star +++ b/starlark/types/testdata/examples/provider_resource.star @@ -1,4 +1,4 @@ -helm = tf.provider("helm") +helm = tf.provider("helm", "1.0.0") podinfo = helm.resource.release("podinfo") podinfo.chart = "podinfo" diff --git a/starlark/types/testdata/examples/terraform.tfstate b/starlark/types/testdata/examples/terraform.tfstate index f3c51b4..12a4df3 100644 --- a/starlark/types/testdata/examples/terraform.tfstate +++ b/starlark/types/testdata/examples/terraform.tfstate @@ -23,33 +23,6 @@ } ] }, - { - "mode": "data", - "type": "helm_repository", - "name": "stable", - "provider": "provider.helm.default", - "instances": [ - { - "schema_version": 0, - "attributes": { - "ca_file": null, - "cert_file": null, - "id": "stable", - "key_file": null, - "metadata": [ - { - "name": "stable", - "url": "https://kubernetes-charts.storage.googleapis.com" - } - ], - "name": "stable", - "password": null, - "url": "https://kubernetes-charts.storage.googleapis.com", - "username": null - } - } - ] - }, { "mode": "managed", "type": "google_container_cluster", @@ -59,19 +32,6 @@ { "schema_version": 1, "attributes": { - "additional_zones": [], - "addons_config": [ - { - "horizontal_pod_autoscaling": [], - "http_load_balancing": [], - "kubernetes_dashboard": [], - "network_policy_config": [ - { - "disabled": true - } - ] - } - ], "authenticator_groups_config": [], "cluster_autoscaling": [ { @@ -127,37 +87,6 @@ "provider": "PROVIDER_UNSPECIFIED" } ], - "node_config": [ - { - "disk_size_gb": 100, - "disk_type": "pd-standard", - "guest_accelerator": [], - "image_type": "COS", - "labels": {}, - "local_ssd_count": 0, - "machine_type": "n1-standard-2", - "metadata": { - "disable-legacy-endpoints": "true" - }, - "min_cpu_platform": "", - "oauth_scopes": [ - "https://www.googleapis.com/auth/logging.write", - "https://www.googleapis.com/auth/monitoring" - ], - "preemptible": true, - "sandbox_config": [], - "service_account": "default", - "shielded_instance_config": [ - { - "enable_integrity_monitoring": true, - "enable_secure_boot": false - } - ], - "tags": [], - "taint": [], - "workload_metadata_config": [] - } - ], "node_locations": [ "us-central1-a", "us-central1-b", @@ -181,37 +110,6 @@ "max_pods_per_node": 0, "name": "primary-node-pool", "name_prefix": "", - "node_config": [ - { - "disk_size_gb": 100, - "disk_type": "pd-standard", - "guest_accelerator": [], - "image_type": "COS", - "labels": {}, - "local_ssd_count": 0, - "machine_type": "n1-standard-2", - "metadata": { - "disable-legacy-endpoints": "true" - }, - "min_cpu_platform": "", - "oauth_scopes": [ - "https://www.googleapis.com/auth/logging.write", - "https://www.googleapis.com/auth/monitoring" - ], - "preemptible": true, - "sandbox_config": [], - "service_account": "default", - "shielded_instance_config": [ - { - "enable_integrity_monitoring": true, - "enable_secure_boot": false - } - ], - "tags": [], - "taint": [], - "workload_metadata_config": [] - } - ], "node_count": 1, "version": "1.14.10-gke.17" } @@ -262,37 +160,6 @@ "max_pods_per_node": null, "name": "primary-node-pool", "name_prefix": "", - "node_config": [ - { - "disk_size_gb": 100, - "disk_type": "pd-standard", - "guest_accelerator": [], - "image_type": "COS", - "labels": {}, - "local_ssd_count": 0, - "machine_type": "n1-standard-2", - "metadata": { - "disable-legacy-endpoints": "true" - }, - "min_cpu_platform": "", - "oauth_scopes": [ - "https://www.googleapis.com/auth/logging.write", - "https://www.googleapis.com/auth/monitoring" - ], - "preemptible": true, - "sandbox_config": [], - "service_account": "default", - "shielded_instance_config": [ - { - "enable_integrity_monitoring": true, - "enable_secure_boot": false - } - ], - "tags": [], - "taint": [], - "workload_metadata_config": [] - } - ], "node_count": 1, "project": "project-foo", "region": null, @@ -352,7 +219,6 @@ "reuse_values": false, "set": [], "set_sensitive": [], - "set_string": [], "skip_crds": false, "status": "deployed", "timeout": 300, @@ -424,7 +290,6 @@ } ], "set_sensitive": [], - "set_string": [], "skip_crds": false, "status": "deployed", "timeout": 300, @@ -498,7 +363,6 @@ } ], "set_sensitive": [], - "set_string": [], "skip_crds": false, "status": "deployed", "timeout": 300, @@ -565,7 +429,6 @@ } ], "set_sensitive": [], - "set_string": [], "skip_crds": false, "status": "deployed", "timeout": 300, @@ -626,7 +489,6 @@ "reuse_values": false, "set": [], "set_sensitive": [], - "set_string": [], "skip_crds": false, "status": "deployed", "timeout": 300,