Skip to content

Commit

Permalink
Support display metadata AlternateDefault validate
Browse files Browse the repository at this point in the history
  • Loading branch information
q2w committed Oct 18, 2024
1 parent 70fdd57 commit c8d97a8
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 3 deletions.
4 changes: 1 addition & 3 deletions cli/bpmetadata/schema/gcp-blueprint-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -856,9 +856,7 @@
}
]
},
"value": {
"$ref": "#/$defs/Value"
}
"value": true
},
"additionalProperties": false,
"type": "object"
Expand Down
4 changes: 4 additions & 0 deletions cli/bpmetadata/schema/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ func GenerateSchema() ([]byte, error) {
if defExists {
oDef.Properties.Set("type", jsonschema.TrueSchema)
}
altDefaultDef, defExists := s.Definitions["DisplayVariable_AlternateDefault"]
if defExists {
altDefaultDef.Properties.Set("value", jsonschema.TrueSchema)
}

sData, err := json.MarshalIndent(s, "", " ")
if err != nil {
Expand Down
5 changes: 5 additions & 0 deletions cli/bpmetadata/validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ func TestValidateMetadata(t *testing.T) {
path: "valid-metadata-connections.yaml",
wantErr: false,
},
{
name: "valid display metadata with alternate defaults",
path: "valid-display-metadata-alternate-defaults.yaml",
wantErr: false,
},
{
name: "invalid metadata - title missing",
path: "invalid-metadata.yaml",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
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
ui:
input:
variables:
string_type:
name: string_type
title: String type
altDefaults:
- type: ALTERNATE_TYPE_DC
value: REGIONAL
bool_type:
name: bool_type
title: Bool type
altDefaults:
- type: ALTERNATE_TYPE_DC
value: true
number_type:
name: number_type
title: Number type
altDefaults:
- type: ALTERNATE_TYPE_DC
value: 1
object_type:
name: object_type
title: Object type
altDefaults:
- type: ALTERNATE_TYPE_DC
value:
key: value
list_type:
name: list_type
title: List type
altDefaults:
- type: ALTERNATE_TYPE_DC
value:
- item1
- item2
runtime:
outputs:
output1:
visibility: VISIBILITY_ROOT

0 comments on commit c8d97a8

Please sign in to comment.