Skip to content
This repository was archived by the owner on Feb 28, 2023. It is now read-only.

Commit 94460c9

Browse files
committed
Add prefix to generated names for cluster-scoped configurations
Previously, resource names generated by the component library for cluster-scoped configurations only used the target object name. This can easily lead to name collisions. For example, OpenShift 4 has many CRs named `cluster`. This commit adds code to use `<target.kind>-<target.apigroup>` as the prefix when generating names for cluster-scoped configurations to reduce the potential for collisions.
1 parent 04af716 commit 94460c9

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

lib/resource-locker.libjsonnet

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,20 @@ local rl_obj_name(objdata) =
168168
if objdata.namespace != null then
169169
'%s-%s' % [ objdata.namespace, name ]
170170
else
171-
name;
171+
// Reduce potential for name collisions when generating names for
172+
// cluster-scoped ResourceLocker configurations.
173+
local prefix =
174+
if objdata.apigroup != '' then
175+
'%s-%s' % [
176+
std.asciiLower(objdata.kind),
177+
std.strReplace(objdata.apigroup, '.', '-'),
178+
]
179+
else
180+
std.asciiLower(objdata.kind);
181+
'%s-%s' % [
182+
prefix,
183+
name,
184+
];
172185

173186
/**
174187
* \brief Create a managed resource (similar to Espejo, but for single NS)

0 commit comments

Comments
 (0)