update JSON schema

This commit is contained in:
Shreyas Goenka 2024-12-04 10:46:32 +01:00
parent 2b61d73ede
commit 455a11b470
No known key found for this signature in database
GPG Key ID: 92A07DF49CCB0622
5 changed files with 111 additions and 0 deletions

View File

@ -93,6 +93,24 @@ func removeJobsFields(typ reflect.Type, s jsonschema.Schema) jsonschema.Schema {
return s 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() { func main() {
if len(os.Args) != 2 { if len(os.Args) != 2 {
fmt.Println("Usage: go run main.go <output-file>") fmt.Println("Usage: go run main.go <output-file>")
@ -118,6 +136,7 @@ func main() {
p.addDescriptions, p.addDescriptions,
p.addEnums, p.addEnums,
removeJobsFields, removeJobsFields,
makeVolumeTypeOptional,
addInterpolationPatterns, addInterpolationPatterns,
}) })
if err != nil { if err != nil {

View File

@ -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

View File

@ -0,0 +1,9 @@
bundle:
name: a volume
resources:
volumes:
foo:
catalog_name: main
name: my_volume
schema_name: myschema

View File

@ -68,6 +68,7 @@ func Initialize() bundle.Mutator {
mutator.SetRunAs(), mutator.SetRunAs(),
mutator.OverrideCompute(), mutator.OverrideCompute(),
mutator.ConfigureDashboardDefaults(), mutator.ConfigureDashboardDefaults(),
mutator.ConfigureVolumeDefaults(),
mutator.ProcessTargetMode(), mutator.ProcessTargetMode(),
mutator.ApplyPresets(), mutator.ApplyPresets(),
mutator.DefaultQueueing(), mutator.DefaultQueueing(),

View File

@ -791,6 +791,51 @@
} }
] ]
}, },
"resources.Volume": {
"anyOf": [
{
"type": "object",
"properties": {
"catalog_name": {
"description": "The name of the catalog where the schema and the volume are",
"$ref": "#/$defs/string"
},
"comment": {
"description": "The comment attached to the volume",
"$ref": "#/$defs/string"
},
"grants": {
"$ref": "#/$defs/slice/github.com/databricks/cli/bundle/config/resources.Grant"
},
"name": {
"description": "The name of the volume",
"$ref": "#/$defs/string"
},
"schema_name": {
"description": "The name of the schema where the volume is",
"$ref": "#/$defs/string"
},
"storage_location": {
"description": "The storage location on the cloud",
"$ref": "#/$defs/string"
},
"volume_type": {
"$ref": "#/$defs/github.com/databricks/databricks-sdk-go/service/catalog.VolumeType"
}
},
"additionalProperties": false,
"required": [
"catalog_name",
"name",
"schema_name"
]
},
{
"type": "string",
"pattern": "\\$\\{(var(\\.[a-zA-Z]+([-_]?[a-zA-Z0-9]+)*(\\[[0-9]+\\])*)+)\\}"
}
]
},
"variable.Lookup": { "variable.Lookup": {
"anyOf": [ "anyOf": [
{ {
@ -963,6 +1008,9 @@
}, },
"name": { "name": {
"$ref": "#/$defs/string" "$ref": "#/$defs/string"
},
"uuid": {
"$ref": "#/$defs/string"
} }
}, },
"additionalProperties": false, "additionalProperties": false,
@ -1157,6 +1205,9 @@
}, },
"schemas": { "schemas": {
"$ref": "#/$defs/map/github.com/databricks/cli/bundle/config/resources.Schema" "$ref": "#/$defs/map/github.com/databricks/cli/bundle/config/resources.Schema"
},
"volumes": {
"$ref": "#/$defs/map/github.com/databricks/cli/bundle/config/resources.Volume"
} }
}, },
"additionalProperties": false "additionalProperties": false
@ -1558,6 +1609,13 @@
} }
] ]
}, },
"catalog.VolumeType": {
"type": "string",
"enum": [
"EXTERNAL",
"MANAGED"
]
},
"compute.Adlsgen2Info": { "compute.Adlsgen2Info": {
"anyOf": [ "anyOf": [
{ {
@ -5565,6 +5623,20 @@
} }
] ]
}, },
"resources.Volume": {
"anyOf": [
{
"type": "object",
"additionalProperties": {
"$ref": "#/$defs/github.com/databricks/cli/bundle/config/resources.Volume"
}
},
{
"type": "string",
"pattern": "\\$\\{(var(\\.[a-zA-Z]+([-_]?[a-zA-Z0-9]+)*(\\[[0-9]+\\])*)+)\\}"
}
]
},
"variable.TargetVariable": { "variable.TargetVariable": {
"anyOf": [ "anyOf": [
{ {