mirror of https://github.com/databricks/cli.git
fix: More explicit names for annotation data structures
This commit is contained in:
parent
3231cffc54
commit
c619a73232
|
@ -27,8 +27,10 @@ type annotation struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type annotationHandler struct {
|
type annotationHandler struct {
|
||||||
ref annotationFile
|
// Annotations read from all annotation files including all overrides
|
||||||
empty annotationFile
|
parsedAnnotations annotationFile
|
||||||
|
// Missing annotations for fields that are found in config that need to be added to the annotation file
|
||||||
|
missingAnnotations annotationFile
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -68,8 +70,8 @@ func newAnnotationHandler(sources []string) (*annotationHandler, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
d := &annotationHandler{}
|
d := &annotationHandler{}
|
||||||
d.ref = data
|
d.parsedAnnotations = data
|
||||||
d.empty = annotationFile{}
|
d.missingAnnotations = annotationFile{}
|
||||||
return d, nil
|
return d, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,7 +82,7 @@ func (d *annotationHandler) addAnnotations(typ reflect.Type, s jsonschema.Schema
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
annotations := d.ref[refPath]
|
annotations := d.parsedAnnotations[refPath]
|
||||||
if annotations == nil {
|
if annotations == nil {
|
||||||
annotations = map[string]annotation{}
|
annotations = map[string]annotation{}
|
||||||
}
|
}
|
||||||
|
@ -95,10 +97,10 @@ func (d *annotationHandler) addAnnotations(typ reflect.Type, s jsonschema.Schema
|
||||||
if item.Description == "" {
|
if item.Description == "" {
|
||||||
item.Description = Placeholder
|
item.Description = Placeholder
|
||||||
|
|
||||||
emptyAnnotations := d.empty[refPath]
|
emptyAnnotations := d.missingAnnotations[refPath]
|
||||||
if emptyAnnotations == nil {
|
if emptyAnnotations == nil {
|
||||||
emptyAnnotations = map[string]annotation{}
|
emptyAnnotations = map[string]annotation{}
|
||||||
d.empty[refPath] = emptyAnnotations
|
d.missingAnnotations[refPath] = emptyAnnotations
|
||||||
}
|
}
|
||||||
emptyAnnotations[k] = item
|
emptyAnnotations[k] = item
|
||||||
}
|
}
|
||||||
|
@ -117,7 +119,7 @@ func (d *annotationHandler) sync(outputPath string) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
missingAnnotations, err := convert.FromTyped(&d.empty, dyn.NilValue)
|
missingAnnotations, err := convert.FromTyped(&d.missingAnnotations, dyn.NilValue)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue