Implement shared tags functionality to remove tags when dashboard export#3163
Conversation
|
|
||
| func isSharedTag(aId string, sharedTags []string) bool { | ||
| for _, tag := range sharedTags { | ||
| id := fmt.Sprintf("tag-ref-%s-default", strings.ReplaceAll(strings.ToLower(tag), " ", "-")) |
There was a problem hiding this comment.
does the shared tag have more formatting than this?
There was a problem hiding this comment.
Is this format set by Fleet? Not sure if we can rely on it, it could be changed without previous notice.
Though we should not care a lot if we check by names instead of ids.
There was a problem hiding this comment.
fleet is actually parsing a specific id for shared tags https://github.com/elastic/kibana/blob/5385f96a132114362b2542e6a44c96a697b66c28/x-pack/platform/plugins/shared/fleet/server/services/epm/kibana/assets/tag_assets.ts#L67
i've reviewed the pr and have taken into account this format to identify the shared tags when exporting a dashboard.
jsoriano
left a comment
There was a problem hiding this comment.
Approach looks mostly good to me. I only wonder if we are relying on ids, when we are interested on the names, that is what users see.
Tried to re-export all Crowdstrike dashboards and the changes make sense to me 👍
|
|
||
| func isSharedTag(aId string, sharedTags []string) bool { | ||
| for _, tag := range sharedTags { | ||
| id := fmt.Sprintf("tag-ref-%s-default", strings.ReplaceAll(strings.ToLower(tag), " ", "-")) |
There was a problem hiding this comment.
Is this format set by Fleet? Not sure if we can rely on it, it could be changed without previous notice.
Though we should not care a lot if we check by names instead of ids.
There was a problem hiding this comment.
Nit. It is usually discouraged to use underscores in go files or package names, as some of them have special meanings (_test, _linux...).
Maybe this file could be called just removesharedtags.go, or we could merge all these files into a single tags.go.
Though I see there are already other files here with underscores.
There was a problem hiding this comment.
i followed the naming i saw.. but agree, i think we can merge into a single one 👍🏻
There was a problem hiding this comment.
consolidated tag functions into new ´tag.go´ file
…oid-tag-duplicates
💛 Build succeeded, but was flaky
Failed CI StepsHistory
|
tags.ymlfile)When exporting a dashboard, tags that are shared (defined at kibana/tags.yml) where being also exported into
kibana/tagfolder.Shared tags are managed by fleet when reading the
tags.ymlso exporting them asjsonis duplicating this tags in the UI.This PR adds a filter layer when exporting a dashboard, removing shared tag objects and dashboard references to them.
Identification of tags is done based on fleet criteria on creating the json objects when reading the ´tags.yml´ file.
Updated unit tests to include shared tags object and check the filter is working as expected