Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add map as another reference type to check to show warnings #414

Merged
merged 3 commits into from
Sep 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,12 @@ func ValidateVisualizationsUsedByValue(fsys fspath.FS) ve.ValidationErrors {
for _, ref := range references[1:] {
s = fmt.Sprintf("%s, %s (%s)", s, ref.ID, ref.Type)
}

message := fmt.Sprintf("Warning: references found in dashboard %s: %s", filePath, s)
if warningsAsErrors {
errs = append(errs, errors.Errorf("Warning: references found in dashboard %s: %s", filePath, s))
errs = append(errs, errors.New(message))
} else {
log.Printf("Warning: references found in dashboard %s: %s", filePath, s)
log.Printf(message)
}

}
Expand All @@ -82,7 +84,7 @@ func anyReference(val interface{}) ([]reference, error) {
var references []reference
for _, reference := range allReferences {
switch reference.Type {
case "lens", "visualization":
case "lens", "visualization", "map":
references = append(references, reference)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,18 +77,34 @@ func TestAnyReference(t *testing.T) {
},
map[string]interface{}{
"id": "4",
"name": "panel_1",
"name": "panel_2",
"type": "map",
},
map[string]interface{}{
"id": "42",
"name": "panel_1",
"name": "panel_3",
"type": "index-pattern",
},
map[string]interface{}{
"id": "44",
"name": "panel_4",
"type": "search",
},
map[string]interface{}{
"id": "45",
"name": "panel_5",
"type": "tag",
},
map[string]interface{}{
"id": "50",
"name": "panel_6",
"type": "dashboard",
},
},
[]reference{
{"12345", "panel_0", "visualization"},
{"9000", "panel_1", "lens"},
{"4", "panel_2", "map"},
},
},
{
Expand Down
4 changes: 2 additions & 2 deletions spec/changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
link: https://github.com/elastic/package-spec/issues/331
- version: 1.18.1-next
changes:
- description: Prepare for next patch release
- description: Add map as another reference type to check to show warnings
type: enhancement
link: https://github.com/elastic/package-spec/pull/411
link: https://github.com/elastic/package-spec/pull/414
- version: 1.18.0
changes:
- description: Update Go runtime to 1.19.1.
Expand Down