feat(catalog): add an ldap processor
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
|
||||
import { ENTITY_DEFAULT_NAMESPACE } from './constants';
|
||||
import { Entity } from './Entity';
|
||||
import { parseEntityName, parseEntityRef, serializeEntityRef } from './ref';
|
||||
|
||||
describe('ref', () => {
|
||||
@@ -333,6 +334,26 @@ describe('ref', () => {
|
||||
expect(serializeEntityRef({ name: 'c' })).toEqual('c');
|
||||
});
|
||||
|
||||
it('handles entities', () => {
|
||||
const entityWithNamespace: Entity = {
|
||||
apiVersion: 'a',
|
||||
kind: 'b',
|
||||
metadata: {
|
||||
name: 'c',
|
||||
namespace: 'd',
|
||||
},
|
||||
};
|
||||
const entityWithoutNamespace: Entity = {
|
||||
apiVersion: 'a',
|
||||
kind: 'b',
|
||||
metadata: {
|
||||
name: 'c',
|
||||
},
|
||||
};
|
||||
expect(serializeEntityRef(entityWithNamespace)).toEqual('b:d/c');
|
||||
expect(serializeEntityRef(entityWithoutNamespace)).toEqual('b:c');
|
||||
});
|
||||
|
||||
it('picks the least complex form', () => {
|
||||
expect(
|
||||
serializeEntityRef({ kind: 'a', namespace: 'b', name: 'c' }),
|
||||
|
||||
@@ -160,12 +160,29 @@ export function parseEntityRef(
|
||||
* @param ref The reference to serialize
|
||||
* @returns The same reference on either string or compound form
|
||||
*/
|
||||
export function serializeEntityRef(ref: {
|
||||
kind?: string;
|
||||
namespace?: string;
|
||||
name: string;
|
||||
}): EntityRef {
|
||||
const { kind, namespace, name } = ref;
|
||||
export function serializeEntityRef(
|
||||
ref:
|
||||
| Entity
|
||||
| {
|
||||
kind?: string;
|
||||
namespace?: string;
|
||||
name: string;
|
||||
},
|
||||
): EntityRef {
|
||||
let kind;
|
||||
let namespace;
|
||||
let name;
|
||||
|
||||
if ('apiVersion' in ref) {
|
||||
kind = ref.kind;
|
||||
namespace = ref.metadata.namespace;
|
||||
name = ref.metadata.name;
|
||||
} else {
|
||||
kind = ref.kind;
|
||||
namespace = ref.namespace;
|
||||
name = ref.name;
|
||||
}
|
||||
|
||||
if (
|
||||
kind?.includes(':') ||
|
||||
kind?.includes('/') ||
|
||||
|
||||
Reference in New Issue
Block a user