Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Support display metadata AlternateDefault validate #2661

Merged
merged 1 commit into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading