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

Commit 9594909

Browse files
committed
Move rl_obj_name before rbac_objs
1 parent 94460c9 commit 9594909

1 file changed

Lines changed: 21 additions & 21 deletions

File tree

lib/resource-locker.libjsonnet

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,27 @@ local clusterRoleName(name) =
9595
local replaceColon(str) =
9696
std.strReplace(str, ':', '-');
9797

98+
local rl_obj_name(objdata) =
99+
// Some objects like ClusterRoleBinding can contain colons.
100+
local name = replaceColon(objdata.name);
101+
if objdata.namespace != null then
102+
'%s-%s' % [ objdata.namespace, name ]
103+
else
104+
// Reduce potential for name collisions when generating names for
105+
// cluster-scoped ResourceLocker configurations.
106+
local prefix =
107+
if objdata.apigroup != '' then
108+
'%s-%s' % [
109+
std.asciiLower(objdata.kind),
110+
std.strReplace(objdata.apigroup, '.', '-'),
111+
]
112+
else
113+
std.asciiLower(objdata.kind);
114+
'%s-%s' % [
115+
prefix,
116+
name,
117+
];
118+
98119
local rbac_objs(objdata, verbs=[ 'create', 'get', 'update', 'patch' ]) =
99120
local dest_ns = objdata.namespace;
100121
// Some objects like ClusterRoleBinding can contain colons.
@@ -162,27 +183,6 @@ local obj_data(obj) =
162183
namespace: if std.objectHas(obj.metadata, 'namespace') then obj.metadata.namespace,
163184
};
164185

165-
local rl_obj_name(objdata) =
166-
// Some objects like ClusterRoleBinding can contain colons.
167-
local name = replaceColon(objdata.name);
168-
if objdata.namespace != null then
169-
'%s-%s' % [ objdata.namespace, name ]
170-
else
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-
];
185-
186186
/**
187187
* \brief Create a managed resource (similar to Espejo, but for single NS)
188188
*

0 commit comments

Comments
 (0)