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"
|
||||
)
|
||||
|
||||
// Fields tagged "readonly" should not be emitted in the schema as they are
|
||||
// computed at runtime, and should not be assigned a value by the bundle author.
|
||||
const readonlyTag = "readonly"
|
||||
var skipTags = []string{
|
||||
// Fields tagged "readonly" should not be emitted in the schema as they are
|
||||
// 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.
|
||||
// Fields can be tagged as "internal" to remove them from the generated schema.
|
||||
const internalTag = "internal"
|
||||
// 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.
|
||||
"internal",
|
||||
|
||||
// Annotation for bundle fields that have been deprecated.
|
||||
// Fields tagged as "deprecated" are omitted from the generated schema.
|
||||
const deprecatedTag = "deprecated"
|
||||
// Annotation for bundle fields that have been deprecated.
|
||||
// Fields tagged as "deprecated" are omitted from the generated schema.
|
||||
"deprecated",
|
||||
}
|
||||
|
||||
type constructor struct {
|
||||
// Map of typ.PkgPath() + "." + typ.Name() to the schema for that type.
|
||||
|
@ -251,11 +253,11 @@ func (c *constructor) fromTypeStruct(typ reflect.Type) (Schema, error) {
|
|||
bundleTags := strings.Split(structField.Tag.Get("bundle"), ",")
|
||||
// Fields marked as "readonly", "internal" or "deprecated" are skipped
|
||||
// while generating the schema
|
||||
if slices.Contains(bundleTags, readonlyTag) ||
|
||||
slices.Contains(bundleTags, internalTag) ||
|
||||
slices.Contains(bundleTags, deprecatedTag) {
|
||||
for _, tag := range skipTags {
|
||||
if slices.Contains(bundleTags, tag) {
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
jsonTags := strings.Split(structField.Tag.Get("json"), ",")
|
||||
fieldName := jsonTags[0]
|
||||
|
|
Loading…
Reference in New Issue