Skip to content

Commit 4aa7aa7

Browse files
committed
Always use --registry option when creating component
This PR fixes #2141. Signed-off-by: Denis Golovin dgolovin@redhat.com
1 parent f87cdd7 commit 4aa7aa7

File tree

6 files changed

+31
-7
lines changed

6 files changed

+31
-7
lines changed

src/odo.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ export interface Odo {
358358
createApplication(application: OpenShiftObject): Promise<OpenShiftObject>;
359359
deleteApplication(application: OpenShiftObject): Promise<OpenShiftObject>;
360360
createComponentFromGit(application: OpenShiftObject, type: string, version: string, name: string, repoUri: string, context: Uri, ref: string): Promise<OpenShiftObject>;
361-
createComponentFromFolder(application: OpenShiftObject, type: string, version: string, name: string, path: Uri, starterName?: string, useExistingDevfile?: boolean): Promise<OpenShiftObject>;
361+
createComponentFromFolder(application: OpenShiftObject, type: string, version: string, registryName: string, name: string, path: Uri, starterName?: string, useExistingDevfile?: boolean): Promise<OpenShiftObject>;
362362
createComponentFromBinary(application: OpenShiftObject, type: string, version: string, name: string, path: Uri, context: Uri): Promise<OpenShiftObject>;
363363
deleteComponent(component: OpenShiftObject): Promise<OpenShiftObject>;
364364
undeployComponent(component: OpenShiftObject): Promise<OpenShiftObject>;
@@ -889,8 +889,8 @@ export class OdoImpl implements Odo {
889889
return application;
890890
}
891891

892-
public async createComponentFromFolder(application: OpenShiftObject, type: string, version: string, name: string, location: Uri, starter: string = undefined, useExistingDevfile = false): Promise<OpenShiftObject> {
893-
await this.execute(Command.createLocalComponent(application.getParent().getName(), application.getName(), type, version, name, location.fsPath, starter, useExistingDevfile), location.fsPath);
892+
public async createComponentFromFolder(application: OpenShiftObject, type: string, version: string, registryName: string, name: string, location: Uri, starter: string = undefined, useExistingDevfile = false): Promise<OpenShiftObject> {
893+
await this.execute(Command.createLocalComponent(application.getParent().getName(), application.getName(), type, version, registryName, name, location.fsPath, starter, useExistingDevfile), location.fsPath);
894894
if (workspace.workspaceFolders && application.getParent().getParent()) { // if there are workspace folders and cluster is accessible
895895
const targetApplication = (await this.getApplications(application.getParent())).find((value) => value === application);
896896
if (!targetApplication) {

src/odo/catalog.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,18 @@
33
* Licensed under the MIT License. See LICENSE file in the project root for license information.
44
*-----------------------------------------------------------------------------------------------*/
55

6+
export interface Registry {
7+
Name: string;
8+
URL: string;
9+
Secure: boolean;
10+
}
11+
12+
export const DefaultRegistry: Registry = {
13+
Name: 'DefaultDevfileRegistry',
14+
URL: 'https://github.com/odo-devfiles/registry',
15+
Secure: false
16+
};
17+
618
export interface ComponentDescription {
719
schemaVersion: string;
820
metadata: {

src/odo/command.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,7 @@ export class Command {
391391
app: string,
392392
type = '', // will use empty string in case of undefined type passed in
393393
version: string,
394+
registryName: string,
394395
name: string,
395396
folder: string,
396397
starter: string = undefined,
@@ -400,6 +401,9 @@ export class Command {
400401
if (version) {
401402
cTxt.addOption(new CommandOption('--s2i'));
402403
}
404+
if (registryName) {
405+
cTxt.addOption(new CommandOption('--registry', registryName));
406+
}
403407
cTxt.addOption(new CommandOption('--context', folder))
404408
.addOption(new CommandOption('--app', app))
405409
.addOption(new CommandOption('--project', project));

src/openshift/component.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -698,8 +698,9 @@ export class Component extends OpenShiftItem {
698698
`Creating new Component '${componentName}'`,
699699
() => Component.odo.createComponentFromFolder(
700700
application,
701-
componentType? componentType.name : undefined, // in case of using existing devfile
702-
componentType? componentType.version : undefined,
701+
componentType?.name, // in case of using existing devfile
702+
componentType?.version,
703+
componentType?.registryName,
703704
componentName,
704705
folder,
705706
createStarter,
@@ -1034,7 +1035,13 @@ export class Component extends OpenShiftItem {
10341035
const gitRef = bcJson.spec.source.git.ref || 'master';
10351036
await Component.odo.execute(Command.createGitComponent(prjName, appName, compTypeName, compTypeVersion, compName, gitUrl, gitRef), workspaceFolder.fsPath);
10361037
} else { // componentType === ComponentType.Local
1037-
await Component.odo.execute(Command.createLocalComponent(prjName, appName, componentJson.metadata.labels['app.kubernetes.io/name'], componentJson.metadata.labels['app.openshift.io/runtime-version'], compName, workspaceFolder.fsPath));
1038+
await Component.odo.execute(Command.createLocalComponent(
1039+
prjName,
1040+
appName,
1041+
componentJson.metadata.labels['app.kubernetes.io/name'],
1042+
componentJson.metadata.labels['app.openshift.io/runtime-version'],
1043+
undefined,
1044+
compName, workspaceFolder.fsPath));
10381045
}
10391046
// import storage if present
10401047
if (componentJson.spec.template.spec.containers[0].volumeMounts) {

test/integration/command.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ suite('odo commands integration', () => {
183183
newAppName,
184184
'nodejs',
185185
'latest',
186+
undefined,
186187
newNodeJsComponent,
187188
componentLocation
188189
)

test/unit/openshift/component.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ suite('OpenShift/Component', () => {
148148
expect(result.toString()).equals(`Component '${componentItem.getName()}' successfully created. To deploy it on cluster, perform 'Push' action.`);
149149
expect(progressFunctionStub).calledOnceWith(
150150
`Creating new Component '${componentItem.getName()}'`);
151-
expect(execStub).calledWith(Command.createLocalComponent(appItem.getParent().getName(), appItem.getName(), componentType.name, version, componentItem.getName(), folder.uri.fsPath));
151+
expect(execStub).calledWith(Command.createLocalComponent(appItem.getParent().getName(), appItem.getName(), componentType.name, version, undefined, componentItem.getName(), folder.uri.fsPath));
152152
});
153153

154154
test('returns null when no option is selected from quick pick', async () => {

0 commit comments

Comments
 (0)