diff --git a/cli/Makefile b/cli/Makefile index 59a19819e35..c6916162cde 100644 --- a/cli/Makefile +++ b/cli/Makefile @@ -1,7 +1,7 @@ SHELL := /bin/bash # Changing this value will trigger a new release -VERSION=v1.3.6 +VERSION=v1.4.0 BINARY=bin/cft GITHUB_REPO=github.com/GoogleCloudPlatform/cloud-foundation-toolkit PLATFORMS := linux windows darwin diff --git a/cli/bpmetadata/schema/gcp-blueprint-metadata.json b/cli/bpmetadata/schema/gcp-blueprint-metadata.json index 2c9ea851b1e..96cf07fba92 100644 --- a/cli/bpmetadata/schema/gcp-blueprint-metadata.json +++ b/cli/bpmetadata/schema/gcp-blueprint-metadata.json @@ -73,6 +73,18 @@ "pageUrl" ] }, + "BlueprintConnection": { + "properties": { + "source": { + "$ref": "#/$defs/ConnectionSource" + }, + "spec": { + "$ref": "#/$defs/ConnectionSpec" + } + }, + "additionalProperties": false, + "type": "object" + }, "BlueprintContent": { "properties": { "architecture": { @@ -357,7 +369,8 @@ }, "description": { "type": "string" - } + }, + "type": true }, "additionalProperties": false, "type": "object", @@ -426,6 +439,12 @@ "type": "string" }, "type": "array" + }, + "versions": { + "items": { + "$ref": "#/$defs/ProviderVersion" + }, + "type": "array" } }, "additionalProperties": false, @@ -597,6 +616,12 @@ "defaultValue": true, "required": { "type": "boolean" + }, + "connections": { + "items": { + "$ref": "#/$defs/BlueprintConnection" + }, + "type": "array" } }, "additionalProperties": false, @@ -645,6 +670,30 @@ "title" ] }, + "ConnectionSource": { + "properties": { + "source": { + "type": "string" + }, + "version": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object" + }, + "ConnectionSpec": { + "properties": { + "outputExpr": { + "type": "string" + }, + "inputPath": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object" + }, "DisplayOutput": { "properties": { "openInNewTab": { @@ -655,6 +704,16 @@ }, "label": { "type": "string" + }, + "visibility": { + "oneOf": [ + { + "type": "string" + }, + { + "type": "integer" + } + ] } }, "additionalProperties": false, @@ -745,6 +804,12 @@ }, "booleanGroup": { "type": "string" + }, + "altDefaults": { + "items": { + "$ref": "#/$defs/DisplayVariable_AlternateDefault" + }, + "type": "array" } }, "additionalProperties": false, @@ -754,6 +819,25 @@ "title" ] }, + "DisplayVariable_AlternateDefault": { + "properties": { + "type": { + "oneOf": [ + { + "type": "string" + }, + { + "type": "integer" + } + ] + }, + "value": { + "$ref": "#/$defs/Value" + } + }, + "additionalProperties": false, + "type": "object" + }, "GCEDiskSizeExtension": { "properties": { "diskTypeVariable": { @@ -1060,6 +1144,18 @@ "roles" ] }, + "ProviderVersion": { + "properties": { + "source": { + "type": "string" + }, + "version": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object" + }, "ResourceTypeMeta": { "properties": { "name": { diff --git a/cli/bpmetadata/schema/generate.go b/cli/bpmetadata/schema/generate.go index 1f72bc357cb..3d350dbe570 100644 --- a/cli/bpmetadata/schema/generate.go +++ b/cli/bpmetadata/schema/generate.go @@ -51,6 +51,12 @@ func GenerateSchema() ([]byte, error) { if defExists { vDef.Properties.Set("defaultValue", jsonschema.TrueSchema) } + // JSON schema seems to infer google.protobuf.Value as object type + // so we use the same workaround as above. + oDef, defExists := s.Definitions["BlueprintOutput"] + if defExists { + oDef.Properties.Set("type", jsonschema.TrueSchema) + } sData, err := json.MarshalIndent(s, "", " ") if err != nil { diff --git a/cli/bpmetadata/validate_test.go b/cli/bpmetadata/validate_test.go index 785b85ef0e0..f75b6ac77a4 100644 --- a/cli/bpmetadata/validate_test.go +++ b/cli/bpmetadata/validate_test.go @@ -27,6 +27,11 @@ func TestValidateMetadata(t *testing.T) { path: "valid-metadata.yaml", wantErr: false, }, + { + name: "valid metadata with connections", + path: "valid-metadata-connections.yaml", + wantErr: false, + }, { name: "invalid metadata - title missing", path: "invalid-metadata.yaml", diff --git a/cli/testdata/bpmetadata/schema/valid-metadata-connections.yaml b/cli/testdata/bpmetadata/schema/valid-metadata-connections.yaml new file mode 100644 index 00000000000..a3cd295fae9 --- /dev/null +++ b/cli/testdata/bpmetadata/schema/valid-metadata-connections.yaml @@ -0,0 +1,45 @@ +apiVersion: blueprints.cloud.google.com/v1alpha1 +kind: BlueprintMetadata +metadata: + name: terraform-google-module +spec: + info: + title: Terraform Google Module + source: + repo: https://github.com/GoogleCloudPlatform/terraform-google-module.git + sourceType: git + interfaces: + variables: + - name: foo + connections: + - source: + source: "GoogleCloudPlatform/terraform-google-module1" + version: "~> v1" + spec: + outputExpr: "field1" + inputPath: "nested.field" + - name: bar + connections: + - source: + source: "GoogleCloudPlatform/terraform-google-module1" + version: "~> v1" + spec: + outputExpr: "field1" + - source: + source: "GoogleCloudPlatform/terraform-google-module1" + version: "~> v2" + spec: + outputExpr: "field2" + - name: baz + outputs: + - name: qux + type: [ + "object", + { + "VAR1": "string", + "VAR2": "number" + } + ] + + +