Skip to content

Commit

Permalink
update JSON schema
Browse files Browse the repository at this point in the history
  • Loading branch information
shreyas-goenka committed Dec 4, 2024
1 parent 2b61d73 commit 455a11b
Show file tree
Hide file tree
Showing 5 changed files with 111 additions and 0 deletions.
19 changes: 19 additions & 0 deletions bundle/internal/schema/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,24 @@ func removeJobsFields(typ reflect.Type, s jsonschema.Schema) jsonschema.Schema {
return s
}

// While volume_type is required in the volume create API, DABs automatically sets
// it's value to "MANAGED" if it's not provided. Thus, we make it optional
// in the bundle schema.
func makeVolumeTypeOptional(typ reflect.Type, s jsonschema.Schema) jsonschema.Schema {
if typ != reflect.TypeOf(resources.Volume{}) {
return s
}

res := []string{}
for _, r := range s.Required {
if r != "volume_type" {
res = append(res, r)
}
}
s.Required = res
return s
}

func main() {
if len(os.Args) != 2 {
fmt.Println("Usage: go run main.go <output-file>")
Expand All @@ -118,6 +136,7 @@ func main() {
p.addDescriptions,
p.addEnums,
removeJobsFields,
makeVolumeTypeOptional,
addInterpolationPatterns,
})
if err != nil {
Expand Down
10 changes: 10 additions & 0 deletions bundle/internal/schema/testdata/fail/incorrect_volume_type.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
bundle:
name: volume with incorrect type

resources:
volumes:
foo:
catalog_name: main
name: my_volume
schema_name: myschema
volume_type: incorrect_type
9 changes: 9 additions & 0 deletions bundle/internal/schema/testdata/pass/volume.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
bundle:
name: a volume

resources:
volumes:
foo:
catalog_name: main
name: my_volume
schema_name: myschema
1 change: 1 addition & 0 deletions bundle/phases/initialize.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ func Initialize() bundle.Mutator {
mutator.SetRunAs(),
mutator.OverrideCompute(),
mutator.ConfigureDashboardDefaults(),
mutator.ConfigureVolumeDefaults(),
mutator.ProcessTargetMode(),
mutator.ApplyPresets(),
mutator.DefaultQueueing(),
Expand Down
72 changes: 72 additions & 0 deletions bundle/schema/jsonschema.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 455a11b

Please sign in to comment.