mirror of https://github.com/databricks/cli.git
slice for tags
This commit is contained in:
parent
1dd399f3fe
commit
75a571a56d
|
@ -10,17 +10,19 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Fields tagged "readonly" should not be emitted in the schema as they are
|
var skipTags = []string{
|
||||||
// computed at runtime, and should not be assigned a value by the bundle author.
|
// Fields tagged "readonly" should not be emitted in the schema as they are
|
||||||
const readonlyTag = "readonly"
|
// computed at runtime, and should not be assigned a value by the bundle author.
|
||||||
|
"readonly",
|
||||||
|
|
||||||
// Annotation for internal bundle fields that should not be exposed to customers.
|
// Annotation for internal bundle fields that should not be exposed to customers.
|
||||||
// Fields can be tagged as "internal" to remove them from the generated schema.
|
// Fields can be tagged as "internal" to remove them from the generated schema.
|
||||||
const internalTag = "internal"
|
"internal",
|
||||||
|
|
||||||
// Annotation for bundle fields that have been deprecated.
|
// Annotation for bundle fields that have been deprecated.
|
||||||
// Fields tagged as "deprecated" are omitted from the generated schema.
|
// Fields tagged as "deprecated" are omitted from the generated schema.
|
||||||
const deprecatedTag = "deprecated"
|
"deprecated",
|
||||||
|
}
|
||||||
|
|
||||||
type constructor struct {
|
type constructor struct {
|
||||||
// Map of typ.PkgPath() + "." + typ.Name() to the schema for that type.
|
// Map of typ.PkgPath() + "." + typ.Name() to the schema for that type.
|
||||||
|
@ -251,10 +253,10 @@ func (c *constructor) fromTypeStruct(typ reflect.Type) (Schema, error) {
|
||||||
bundleTags := strings.Split(structField.Tag.Get("bundle"), ",")
|
bundleTags := strings.Split(structField.Tag.Get("bundle"), ",")
|
||||||
// Fields marked as "readonly", "internal" or "deprecated" are skipped
|
// Fields marked as "readonly", "internal" or "deprecated" are skipped
|
||||||
// while generating the schema
|
// while generating the schema
|
||||||
if slices.Contains(bundleTags, readonlyTag) ||
|
for _, tag := range skipTags {
|
||||||
slices.Contains(bundleTags, internalTag) ||
|
if slices.Contains(bundleTags, tag) {
|
||||||
slices.Contains(bundleTags, deprecatedTag) {
|
continue
|
||||||
continue
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
jsonTags := strings.Split(structField.Tag.Get("json"), ",")
|
jsonTags := strings.Split(structField.Tag.Get("json"), ",")
|
||||||
|
|
Loading…
Reference in New Issue