Skip to content

Commit

Permalink
Merge branch 'main' into multiple-yaml-documents
Browse files Browse the repository at this point in the history
  • Loading branch information
devtribe authored Dec 11, 2024
2 parents 49f0427 + 5417267 commit 723e84e
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/proud-tomatoes-fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@roadiehq/catalog-backend-module-aws': patch
---

Add support from namespaced group tagging
18 changes: 18 additions & 0 deletions plugins/backend/catalog-backend-module-aws/src/utils/tags.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,24 @@ describe('labelsFromTags and ownerFromTags', () => {
const result = ownerFromTags(tags, 'tagOwner', groups);
expect(result).toBe('group:test/owner1');
});

it('should return owner from an object of tags with different ownerTagKey when tag contains namespace', () => {
const tags = { tagOwner: 'test/owner1', 'tag:two': 'value2' };
const groupsWithMultipleNamespaces = [
...groups,
{
kind: 'Group',
metadata: { name: 'owner1', namespace: 'default' },
} as Entity,
];
const result = ownerFromTags(
tags,
'tagOwner',
groupsWithMultipleNamespaces,
);
expect(result).toBe('group:test/owner1');
});

it('should handle complex owner keys and values in an array of tags', () => {
const tags = [{ Key: 'owner:one', Value: 'owner1' }];
const result = ownerFromTags(tags, 'owner:one', groups);
Expand Down
5 changes: 4 additions & 1 deletion plugins/backend/catalog-backend-module-aws/src/utils/tags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,10 @@ export const ownerFromTags = (

if (ownerString && groups && groups.length > 0) {
const exactMatch = groups.find(
g => g.metadata.name.toLowerCase() === ownerString?.toLowerCase(),
g =>
g.metadata.name.toLowerCase() === ownerString?.toLowerCase() ||
`${g.metadata.namespace}/${g.metadata.name}`.toLowerCase() ===
ownerString?.toLowerCase(),
);
if (exactMatch) {
return stringifyEntityRef(exactMatch);
Expand Down

0 comments on commit 723e84e

Please sign in to comment.