Skip to content

Commit 00f8659

Browse files
datho7561rgrunber
authored andcommitted
Simplify regex to check devfile location
Fixes #2909 Signed-off-by: David Thompson <davthomp@redhat.com>
1 parent 06865f4 commit 00f8659

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

src/openshift/openshiftItem.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*-----------------------------------------------------------------------------------------------*/
55
/* eslint-disable @typescript-eslint/ban-types */
66

7+
import * as path from 'path';
78
import validator from 'validator';
89
import { QuickPickItem, commands, window } from 'vscode';
910
import { OpenShiftExplorer } from '../explorer';
@@ -94,8 +95,8 @@ export default class OpenShiftItem {
9495
}
9596

9697
static validateFilePath(message: string, value: string): string | null {
97-
const regx = new RegExp(/(^[a-z]:((\/|\\)[a-zA-Z0-9_ \\-]+)+|(devfile))\.(yaml|yml)$/,'gi');
98-
return regx.test(value) ? null : message;
98+
const proposedPath = path.parse(value);
99+
return /^devfile\.ya?ml$/i.test(proposedPath.base) ? null : message;
99100
}
100101

101102
static validateRFC1123DNSLabel(message: string, value: string): string | null {

src/webview/git-import/gitImportLoader.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,25 @@
22
* Copyright (c) Red Hat, Inc. All rights reserved.
33
* Licensed under the MIT License. See LICENSE file in the project root for license information.
44
*-----------------------------------------------------------------------------------------------*/
5-
import * as vscode from 'vscode';
6-
import * as path from 'path';
75
import * as fs from 'fs';
6+
import * as path from 'path';
7+
import * as vscode from 'vscode';
88
import * as YAML from 'yaml';
9-
import { ExtensionID } from '../../util/constants';
10-
import { ComponentTypesView } from '../../registriesView';
9+
import { OdoImpl } from '../../odo';
1110
import { AnalyzeResponse, ComponentTypeDescription } from '../../odo/componentType';
11+
import { ComponentDescription, Endpoint } from '../../odo/componentTypeDescription';
12+
import { ComponentWorkspaceFolder } from '../../odo/workspace';
13+
import * as odo3 from '../../odo3';
1214
import { Component } from '../../openshift/component';
1315
import OpenShiftItem from '../../openshift/openshiftItem';
16+
import { ComponentTypesView } from '../../registriesView';
17+
import { ExtensionID } from '../../util/constants';
1418
import { selectWorkspaceFolder } from '../../util/workspace';
19+
import { vsCommand } from '../../vscommand';
20+
import { DevfileConverter } from './devfileConverter';
1521
import GitUrlParse = require('git-url-parse');
1622
import treeKill = require('tree-kill')
1723
import cp = require('child_process');
18-
import { vsCommand } from '../../vscommand';
19-
import * as odo3 from '../../odo3';
20-
import { ComponentDescription, Endpoint } from '../../odo/componentTypeDescription';
21-
import { ComponentWorkspaceFolder } from '../../odo/workspace';
22-
import { OdoImpl } from '../../odo';
23-
import { DevfileConverter } from './devfileConverter';
2424
let panel: vscode.WebviewPanel;
2525
let childProcess: cp.ChildProcess;
2626
let forceCancel = false;
@@ -354,7 +354,7 @@ function validateComponentName(event: any) {
354354

355355
function validateDevFilePath(event: any) {
356356
let validationMessage = OpenShiftItem.emptyName(`Required ${event.param}`, event.param.trim());
357-
if (!validationMessage) validationMessage = OpenShiftItem.validateFilePath(`Not matches ^[a-z]:((\/|\\\\)[a-zA-Z0-9_ \\-]+)+\\.yaml$`, event.param);
357+
if (!validationMessage) validationMessage = OpenShiftItem.validateFilePath(`Devfile must be called devfile.yaml (or devfile.yml) for the tooling to recognize it`, event.param);
358358
if (!validationMessage && event.param !== 'devfile.yaml' && event.param !== 'devfile.yml') {
359359
const uri = vscode.Uri.parse(event.param);
360360
const devFileLocation = path.join(uri.fsPath);

0 commit comments

Comments
 (0)