Skip to content

Commit

Permalink
fix(orchestrator): remove dependency on devmode in the entity provider (
Browse files Browse the repository at this point in the history
  • Loading branch information
caponetto authored Jan 12, 2024
1 parent 4d3da07 commit ee9535d
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ export class OrchestratorEntityProvider
private readonly owner: string;
private readonly environment: string;

private readonly sonataFlowServiceUrl: string;
private readonly orchestratorPluginUrl: string;

static async fromConfig(args: {
Expand All @@ -47,12 +46,6 @@ export class OrchestratorEntityProvider
scheduler: PluginTaskScheduler;
discovery: DiscoveryApi;
}): Promise<OrchestratorEntityProvider> {
const sonataFlowBaseUrl = args.config.getString(
'orchestrator.sonataFlowService.baseUrl',
);
const sonataFlowPort = args.config.getOptionalNumber(
'orchestrator.sonataFlowService.port',
);
const owner =
args.config.getOptionalString('orchestrator.catalog.owner') ??
DEFAULT_CATALOG_OWNER;
Expand All @@ -63,12 +56,7 @@ export class OrchestratorEntityProvider
const orchestratorPluginUrl =
await args.discovery.getBaseUrl('orchestrator');

const sonataFlowServiceUrl = sonataFlowPort
? `${sonataFlowBaseUrl}:${sonataFlowPort}`
: sonataFlowBaseUrl;

return new OrchestratorEntityProvider({
sonataFlowServiceUrl,
orchestratorPluginUrl,
scheduler: args.scheduler,
logger: args.logger,
Expand All @@ -78,14 +66,12 @@ export class OrchestratorEntityProvider
}

constructor(args: {
sonataFlowServiceUrl: string;
orchestratorPluginUrl: string;
scheduler: PluginTaskScheduler;
logger: Logger;
owner: string;
environment: string;
}) {
this.sonataFlowServiceUrl = args.sonataFlowServiceUrl;
this.orchestratorPluginUrl = args.orchestratorPluginUrl;
this.scheduler = args.scheduler;
this.owner = args.owner;
Expand Down Expand Up @@ -154,31 +140,33 @@ export class OrchestratorEntityProvider
private workflowToTemplateEntities(
items: WorkflowItem[],
): TemplateEntityV1beta3[] {
return items.map(i => {
const sanitizedId = i.definition.id.replace(/ /g, '_');
const category: WorkflowCategory = getWorkflowCategory(i.definition);

return {
apiVersion: 'scaffolder.backstage.io/v1beta3',
kind: 'Template',
metadata: {
name: sanitizedId,
title: i.definition.name,
description: i.definition.description,
tags: [category],
annotations: {
[ANNOTATION_LOCATION]: `url:${this.sonataFlowServiceUrl}`,
[ANNOTATION_ORIGIN_LOCATION]: `url:${this.sonataFlowServiceUrl}`,
[ANNOTATION_SOURCE_LOCATION]: `url:${this.sonataFlowServiceUrl}/management/processes/${sanitizedId}/source`,
[ANNOTATION_VIEW_URL]: `${this.sonataFlowServiceUrl}/management/processes/${sanitizedId}/source`,
return items
.filter(i => i.serviceUrl)
.map(i => {
const sanitizedId = i.definition.id.replace(/ /g, '_');
const category: WorkflowCategory = getWorkflowCategory(i.definition);

return {
apiVersion: 'scaffolder.backstage.io/v1beta3',
kind: 'Template',
metadata: {
name: sanitizedId,
title: i.definition.name,
description: i.definition.description,
tags: [category],
annotations: {
[ANNOTATION_LOCATION]: `url:${i.serviceUrl}`,
[ANNOTATION_ORIGIN_LOCATION]: `url:${i.serviceUrl}`,
[ANNOTATION_SOURCE_LOCATION]: `url:${i.serviceUrl}/management/processes/${sanitizedId}/source`,
[ANNOTATION_VIEW_URL]: `${i.serviceUrl}/management/processes/${sanitizedId}/source`,
},
},
},
spec: {
owner: this.owner,
type: WORKFLOW_TYPE,
steps: [],
},
};
});
spec: {
owner: this.owner,
type: WORKFLOW_TYPE,
steps: [],
},
};
});
}
}
3 changes: 2 additions & 1 deletion plugins/orchestrator-backend/src/service/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ function setupInternalRoutes(
}
const item: WorkflowItem = {
definition: info as WorkflowDefinition,
uri: uri,
serviceUrl: info.serviceUrl,
uri,
};
return item;
}),
Expand Down
1 change: 1 addition & 0 deletions plugins/orchestrator-common/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export type WorkflowDefinition = OmitRecursively<
>;

export interface WorkflowItem {
serviceUrl?: string;
uri: string;
definition: WorkflowDefinition;
}
Expand Down

0 comments on commit ee9535d

Please sign in to comment.