Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions projects/lib/portal-options/models/luigi-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ export interface PortalNodeContext extends NodeContext {
kcpPath?: string;
translationTable?: any;
namespaceId?: string;
accountPath?: string;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where is the difference between kcpPath and accountPath?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will make and approach to tackle this duality

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done, and left only the kcpPath

entity?: Resource;
entityName?: string;
entityId?: string;
entityContext?: PortalEntityContext;
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ describe('LuigiExtendedGlobalContextConfigServiceImpl', () => {
organizationId: 'originClusterId/test-org',
kcpCA: 'dW5kZWZpbmVk',
organization: 'test-org',
accountPath: 'root:orgs:test-org',
entityId: 'originClusterId/test-org',
entityName: 'test-org',
});

expect(mockResourceService.readAccountInfo).toHaveBeenCalledWith({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ export class LuigiExtendedGlobalContextConfigServiceImpl
organization: entityId,
organizationId: `${organizationOriginClusterId}/${entityId}`,
kcpCA: btoa(accountInfo?.spec?.clusterInfo?.ca),
accountPath: `root:orgs:${entityId}`,
entityId: `${organizationOriginClusterId}/${entityId}`, // if no entity selected the entityId is the same as the organizationId
entityName: entityId,
};
} catch (e) {
console.error(`Failed to read entity ${entityId} from ${operation}`, e);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import { PortalNodeContext } from '../models/luigi-context';
import { PortalLuigiNode } from '../models/luigi-node';
import { CrdGatewayKcpPatchResolver } from './crd-gateway-kcp-patch-resolver.service';
import { Injectable, inject } from '@angular/core';
import {
NodeContextProcessingService,
} from '@openmfp/portal-ui-lib';
import { NodeContextProcessingService } from '@openmfp/portal-ui-lib';
import { ResourceService } from '@platform-mesh/portal-ui-lib/services';
import { replaceDotsAndHyphensWithUnderscores } from '@platform-mesh/portal-ui-lib/utils';
import { firstValueFrom } from 'rxjs';
import { PortalNodeContext } from '../models/luigi-context';
import { PortalLuigiNode } from '../models/luigi-node';
import { CrdGatewayKcpPatchResolver } from './crd-gateway-kcp-patch-resolver.service';

@Injectable({
providedIn: 'root',
Expand Down Expand Up @@ -67,11 +65,18 @@ export class NodeContextProcessingServiceImpl
);

// update the current already calculated by Luigi context for a node
ctx.accountPath =
ctx.resourceDefinition?.kind === 'Account'
? `${ctx.accountPath}:${entityId}`
: ctx.accountPath;
ctx.entity = entity;
ctx.entityName = entityId;
ctx.entityId = `${entity.metadata?.annotations?.['kcp.io/cluster']}/${entityId}`;
// update the node context of sa node to contain the entity for future context calculations
entityNode.context.entity = entity;
entityNode.context.entityName = ctx.entityName;
entityNode.context.entityId = ctx.entityId;
entityNode.context.accountPath = ctx.accountPath;
} catch (e) {
console.error(`Not able to read entity ${entityId} from ${operation}`);
}
Expand Down