Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dont pass the default manifest to up and down if it's the default value #256

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
21 changes: 16 additions & 5 deletions src/okteto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,22 +186,33 @@ export function up(manifest: vscode.Uri, namespace: string, name: string, port:
}

isActive.set(`${terminalName}-${namespace}-${name}`, true);
let cmd = `${binary} up ${name} -f '${finalManifest}' --remote ${port}`;

let cmd = [binary, 'up', name];
if (!paths.isDefaultManifestPath(finalManifest)) {
cmd.push('-f', finalManifest);
}
cmd.push('--remote', port.toString());

const config = vscode.workspace.getConfiguration('okteto');
if (config) {
const params = config.get<boolean>('upArgs') || '';
cmd = `${cmd} ${params}`;
const params = config.get<string>('upArgs') || '';
if (params) {
cmd.push(...params.split(' ').filter(p => p));
}
}

term.sendText(cmd, true);
term.sendText(cmd.join(' '), true);
}

export async function down(manifest: vscode.Uri, namespace: string, name: string) {
isActive.set(`${terminalName}-${namespace}-${name}`, false);
disposeTerminal(`${terminalName}-${namespace}-${name}`);

const r = execa(getBinary(), ['down', name, '--file', `${manifest.fsPath}`, '--namespace', `${namespace}`], {
const args = ['down', name, '--namespace', `${namespace}`];
if (!paths.isDefaultManifestPath(manifest.fsPath)) {
args.push('--file', manifest.fsPath);
}
const r = execa(getBinary(), args, {
env: {
"OKTETO_ORIGIN":"vscode"
},
Expand Down
4 changes: 4 additions & 0 deletions src/paths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@ export function toGitBash(p: string): string {
const newDrive = '/' + drive[0];
return newDrive + joined.slice(2);
}

export function isDefaultManifestPath(path: string): boolean {
return path.endsWith('okteto.yaml') || path.endsWith('okteto.yml');
}
24 changes: 24 additions & 0 deletions src/test/suite/paths.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,28 @@ describe('toGitBash', () => {
expect(result).to.equal('okteto');
});

});

describe('isDefaultManifestPath', () => {
it('should return true for okteto.yaml', () => {
expect(paths.isDefaultManifestPath('/path/to/okteto.yaml')).equal(true);
expect(paths.isDefaultManifestPath('okteto.yaml')).equal(true);
});

it('should return true for okteto.yml', () => {
expect(paths.isDefaultManifestPath('/path/to/okteto.yml')).equal(true);
expect(paths.isDefaultManifestPath('okteto.yml')).equal(true);
});

it('should return false for non-default manifest paths', () => {
expect(paths.isDefaultManifestPath('/path/to/custom.yaml')).equal(false);
expect(paths.isDefaultManifestPath('manifest.yml')).equal(false);
expect(paths.isDefaultManifestPath('okteto.json')).equal(false);
expect(paths.isDefaultManifestPath('')).equal(false);
});

it('should handle case sensitivity correctly', () => {
expect(paths.isDefaultManifestPath('OKTETO.YAML')).equal(false);
expect(paths.isDefaultManifestPath('Okteto.yml')).equal(false);
});
});