From 98defa9191f3d94999c9fba9def37a105a9fe9eb Mon Sep 17 00:00:00 2001 From: Fraser Waters Date: Wed, 14 Dec 2022 22:31:56 +0000 Subject: [PATCH] Add test for lists as blocks --- .../convert/testdata/list_as_blocks/main.tf | 17 +++ .../testdata/list_as_blocks/pcl/main.pp | 18 +++ .../convert/testdata/mappings/blocks.json | 55 ++++++++ .../convert/testdata/schemas/blocks.json | 130 ++++++++++++++++++ 4 files changed, 220 insertions(+) create mode 100644 pkg/tf2pulumi/convert/testdata/list_as_blocks/main.tf create mode 100644 pkg/tf2pulumi/convert/testdata/list_as_blocks/pcl/main.pp create mode 100644 pkg/tf2pulumi/convert/testdata/mappings/blocks.json create mode 100644 pkg/tf2pulumi/convert/testdata/schemas/blocks.json diff --git a/pkg/tf2pulumi/convert/testdata/list_as_blocks/main.tf b/pkg/tf2pulumi/convert/testdata/list_as_blocks/main.tf new file mode 100644 index 000000000..de6f32fef --- /dev/null +++ b/pkg/tf2pulumi/convert/testdata/list_as_blocks/main.tf @@ -0,0 +1,17 @@ +data "blocks_data_source" "a_data_source" { + a_list_of_resources { + inner_string = "hi" + } + a_list_of_resources { + inner_string = "bye" + } +} + +resource "blocks_resource" "a_resource" { + a_list_of_resources { + inner_string = "hi" + } + a_list_of_resources { + inner_string = "bye" + } +} \ No newline at end of file diff --git a/pkg/tf2pulumi/convert/testdata/list_as_blocks/pcl/main.pp b/pkg/tf2pulumi/convert/testdata/list_as_blocks/pcl/main.pp new file mode 100644 index 000000000..2090afa24 --- /dev/null +++ b/pkg/tf2pulumi/convert/testdata/list_as_blocks/pcl/main.pp @@ -0,0 +1,18 @@ +aDataSource = invoke("blocks:index/index:data_source", { + aListOfResources = [ + { + innerString = "hi" + }, + { + innerString = "bye" + } ] +}) +resource aResource "blocks:index/index:resource" { + aListOfResources = [ + { + innerString = "hi" + }, + { + innerString = "bye" + } ] +} diff --git a/pkg/tf2pulumi/convert/testdata/mappings/blocks.json b/pkg/tf2pulumi/convert/testdata/mappings/blocks.json new file mode 100644 index 000000000..151982ab5 --- /dev/null +++ b/pkg/tf2pulumi/convert/testdata/mappings/blocks.json @@ -0,0 +1,55 @@ +{ + "name": "blocks", + "provider": { + "dataSources": { + "blocks_data_source": { + "a_list_of_resources": { + "type": 5, + "optional": true, + "element": { + "resource": { + "inner_string": { + "type": 4, + "optional": true + } + } + } + }, + "result": { + "type": 4, + "computed": true + } + } + }, + "resources": { + "blocks_resource": { + "a_list_of_resources": { + "type": 5, + "optional": true, + "element": { + "resource": { + "inner_string": { + "type": 4, + "optional": true + } + } + } + }, + "result": { + "type": 4, + "computed": true + } + } + } + }, + "dataSources": { + "blocks_data_source": { + "tok": "blocks:index/index:data_source" + } + }, + "resources": { + "blocks_resource": { + "tok": "blocks:index/index:resource" + } + } +} \ No newline at end of file diff --git a/pkg/tf2pulumi/convert/testdata/schemas/blocks.json b/pkg/tf2pulumi/convert/testdata/schemas/blocks.json new file mode 100644 index 000000000..fc266dd4b --- /dev/null +++ b/pkg/tf2pulumi/convert/testdata/schemas/blocks.json @@ -0,0 +1,130 @@ +{ + "name": "blocks", + "attribution": "This Pulumi package is based on the [`blocks` Terraform Provider](https://github.com/terraform-providers/terraform-provider-blocks).", + "meta": { + "moduleFormat": "(.*)(?:/[^/]*)" + }, + "language": { + "nodejs": { + "compatibility": "tfbridge20", + "disableUnionOutputTypes": true, + "readme": "\u003e This provider is a derived work of the [Terraform Provider](https://github.com/terraform-providers/terraform-provider-blocks)\n\u003e distributed under [MPL 2.0](https://www.mozilla.org/en-US/MPL/2.0/). If you encounter a bug or missing feature,\n\u003e first check the [`pulumi-blocks` repo](/issues); however, if that doesn't turn up anything,\n\u003e please consult the source [`terraform-provider-blocks` repo](https://github.com/terraform-providers/terraform-provider-blocks/issues)." + }, + "python": { + "compatibility": "tfbridge20", + "readme": "\u003e This provider is a derived work of the [Terraform Provider](https://github.com/terraform-providers/terraform-provider-blocks)\n\u003e distributed under [MPL 2.0](https://www.mozilla.org/en-US/MPL/2.0/). If you encounter a bug or missing feature,\n\u003e first check the [`pulumi-blocks` repo](/issues); however, if that doesn't turn up anything,\n\u003e please consult the source [`terraform-provider-blocks` repo](https://github.com/terraform-providers/terraform-provider-blocks/issues)." + } + }, + "config": {}, + "types": { + "blocks:index/data_sourceAListOfResource:data_sourceAListOfResource": { + "properties": { + "innerString": { + "type": "string", + "language": { + "python": { + "mapCase": false + } + } + } + }, + "type": "object" + }, + "blocks:index/resourceAListOfResource:resourceAListOfResource": { + "properties": { + "innerString": { + "type": "string", + "language": { + "python": { + "mapCase": false + } + } + } + }, + "type": "object" + } + }, + "provider": { + "description": "The provider type for the blocks package. By default, resources use package-wide configuration\nsettings, however an explicit `Provider` instance may be created and passed during resource\nconstruction to achieve fine-grained programmatic control over provider settings. See the\n[documentation](https://www.pulumi.com/docs/reference/programming-model/#providers) for more information.\n" + }, + "resources": { + "blocks:index/index:resource": { + "properties": { + "aListOfResources": { + "type": "array", + "items": { + "$ref": "#/types/blocks:index/resourceAListOfResource:resourceAListOfResource" + } + }, + "result": { + "type": "string" + } + }, + "required": [ + "result" + ], + "inputProperties": { + "aListOfResources": { + "type": "array", + "items": { + "$ref": "#/types/blocks:index/resourceAListOfResource:resourceAListOfResource" + } + } + }, + "stateInputs": { + "description": "Input properties used for looking up and filtering resource resources.\n", + "properties": { + "aListOfResources": { + "type": "array", + "items": { + "$ref": "#/types/blocks:index/resourceAListOfResource:resourceAListOfResource" + } + }, + "result": { + "type": "string" + } + }, + "type": "object" + } + } + }, + "functions": { + "blocks:index/index:data_source": { + "inputs": { + "description": "A collection of arguments for invoking data_source.\n", + "properties": { + "aListOfResources": { + "type": "array", + "items": { + "$ref": "#/types/blocks:index/data_sourceAListOfResource:data_sourceAListOfResource" + } + } + }, + "type": "object" + }, + "outputs": { + "description": "A collection of values returned by data_source.\n", + "properties": { + "aListOfResources": { + "type": "array", + "items": { + "$ref": "#/types/blocks:index/data_sourceAListOfResource:data_sourceAListOfResource" + } + }, + "id": { + "type": "string", + "description": "The provider-assigned unique ID for this managed resource.\n" + }, + "result": { + "type": "string" + } + }, + "type": "object", + "required": [ + "result", + "id" + ] + } + } + } +}