This repository has been archived by the owner on Apr 4, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use component for task configuration instead of container name
Signed-off-by: Roman Nikitenko <[email protected]>
- Loading branch information
1 parent
0b5cdb1
commit 9341d4f
Showing
12 changed files
with
157 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/********************************************************************* | ||
* Copyright (c) 2019 Red Hat, Inc. | ||
* | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
**********************************************************************/ | ||
|
||
import { injectable, inject } from 'inversify'; | ||
import * as che from '@eclipse-che/plugin'; | ||
import { CHE_TASK_TYPE, COMPONENT_ATTRIBUTE } from './task-protocol'; | ||
import { CheWorkspaceClient } from '../che-workspace-client'; | ||
import { getAttribute } from '../utils'; | ||
|
||
/** Contains logic to provide backward compatibility. */ | ||
@injectable() | ||
export class BackwardCompatibilityResolver { | ||
|
||
@inject(CheWorkspaceClient) | ||
protected readonly cheWorkspaceClient!: CheWorkspaceClient; | ||
|
||
async resolveComponent(configs: che.TaskConfiguration[]): Promise<che.TaskConfiguration[]> { | ||
if (configs.length === 0) { | ||
return configs; | ||
} | ||
|
||
const containers = await this.cheWorkspaceClient.getMachines(); | ||
for (const config of configs) { | ||
if (config.type !== CHE_TASK_TYPE) { | ||
continue; | ||
} | ||
|
||
const target = config.target; | ||
if (!target || !target.containerName) { | ||
continue; | ||
} | ||
|
||
const containerName = target.containerName; | ||
target.containerName = undefined; | ||
target.component = ''; | ||
|
||
if (!containers.hasOwnProperty(containerName)) { | ||
continue; | ||
} | ||
|
||
const container = containers[containerName]; | ||
const component = getAttribute(COMPONENT_ATTRIBUTE, container.attributes); | ||
if (component) { | ||
target.component = component; | ||
} | ||
} | ||
return configs; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters