Skip to content

Commit

Permalink
name external resources if no explicit name is set
Browse files Browse the repository at this point in the history
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
  • Loading branch information
ndeloof committed Nov 27, 2023
1 parent eb68bbf commit 5614cf9
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions transform/external.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,21 @@ func transformMaybeExternal(data any, p tree.Path) (any, error) {
if !ok {
return resource, nil
}
name := resource["name"]
if ename, ok := external["name"]; ok {
name, named := resource["name"]
extname, extNamed := external["name"]
if extNamed {
logrus.Warnf("%s: external.name is deprecated. Please set name and external: true", p)
if name != nil && ename != name {
if named && extname != name {
return nil, fmt.Errorf("%s: name and external.name conflict; only use name", p)
}
if name == nil {
resource["name"] = ename
}
if !named {
if extNamed {
// adopt (deprecated) external.name if set
resource["name"] = extname
} else {
// otherwise, just replicate the mapping key for convenience
resource["name"] = p
}
}
resource["external"] = true
Expand Down

0 comments on commit 5614cf9

Please sign in to comment.