Skip to content

Commit c8d97a8

Browse files
committed
Support display metadata AlternateDefault validate
1 parent 70fdd57 commit c8d97a8

File tree

4 files changed

+60
-3
lines changed

4 files changed

+60
-3
lines changed

cli/bpmetadata/schema/gcp-blueprint-metadata.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -856,9 +856,7 @@
856856
}
857857
]
858858
},
859-
"value": {
860-
"$ref": "#/$defs/Value"
861-
}
859+
"value": true
862860
},
863861
"additionalProperties": false,
864862
"type": "object"

cli/bpmetadata/schema/generate.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ func GenerateSchema() ([]byte, error) {
5757
if defExists {
5858
oDef.Properties.Set("type", jsonschema.TrueSchema)
5959
}
60+
altDefaultDef, defExists := s.Definitions["DisplayVariable_AlternateDefault"]
61+
if defExists {
62+
altDefaultDef.Properties.Set("value", jsonschema.TrueSchema)
63+
}
6064

6165
sData, err := json.MarshalIndent(s, "", " ")
6266
if err != nil {

cli/bpmetadata/validate_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ func TestValidateMetadata(t *testing.T) {
3232
path: "valid-metadata-connections.yaml",
3333
wantErr: false,
3434
},
35+
{
36+
name: "valid display metadata with alternate defaults",
37+
path: "valid-display-metadata-alternate-defaults.yaml",
38+
wantErr: false,
39+
},
3540
{
3641
name: "invalid metadata - title missing",
3742
path: "invalid-metadata.yaml",
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
apiVersion: blueprints.cloud.google.com/v1alpha1
2+
kind: BlueprintMetadata
3+
metadata:
4+
name: terraform-google-module
5+
spec:
6+
info:
7+
title: Terraform Google Module
8+
source:
9+
repo: https://github.com/GoogleCloudPlatform/terraform-google-module.git
10+
sourceType: git
11+
ui:
12+
input:
13+
variables:
14+
string_type:
15+
name: string_type
16+
title: String type
17+
altDefaults:
18+
- type: ALTERNATE_TYPE_DC
19+
value: REGIONAL
20+
bool_type:
21+
name: bool_type
22+
title: Bool type
23+
altDefaults:
24+
- type: ALTERNATE_TYPE_DC
25+
value: true
26+
number_type:
27+
name: number_type
28+
title: Number type
29+
altDefaults:
30+
- type: ALTERNATE_TYPE_DC
31+
value: 1
32+
object_type:
33+
name: object_type
34+
title: Object type
35+
altDefaults:
36+
- type: ALTERNATE_TYPE_DC
37+
value:
38+
key: value
39+
list_type:
40+
name: list_type
41+
title: List type
42+
altDefaults:
43+
- type: ALTERNATE_TYPE_DC
44+
value:
45+
- item1
46+
- item2
47+
runtime:
48+
outputs:
49+
output1:
50+
visibility: VISIBILITY_ROOT

0 commit comments

Comments
 (0)