mirror of
https://github.com/morten-olsen/homelab-operator.git
synced 2026-02-08 01:36:28 +01:00
14 lines
364 B
TypeScript
14 lines
364 B
TypeScript
const getWithNamespace = (input: string, defaultNamespace?: string) => {
|
|
const result = input.split('/');
|
|
const first = result.pop();
|
|
if (!first) {
|
|
throw new Error(`${input} could not be parsed as a namespace`);
|
|
}
|
|
return {
|
|
name: first,
|
|
namespace: result.length > 0 ? result.join('/') : defaultNamespace,
|
|
};
|
|
};
|
|
|
|
export { getWithNamespace };
|