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

add windows support for container tasks #5

Closed
wants to merge 3 commits into from
Closed
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
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -356,4 +356,7 @@ azurecontainerapps/Tests/
*.js

# Ignore .vsix files generated via tfx-cli
*.vsix
*.vsix

# Ignore file history
.history/
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"jira-plugin.workingProject": "",
"sarif-viewer.connectToGithubCodeScanning": "off"
}
29 changes: 29 additions & 0 deletions azurecontainerapps/src/CommandHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,33 @@ export class CommandHelper {
throw err;
}
}

public async execPwshCommandAsync(command: string, cwd?: string): Promise<string> {
try {
if (!cwd) {
cwd = tl.getPathInput('cwd', true, false);
}

const pwshPath: string = tl.which('pwsh.exe', true);
const pwshCmd = tl.tool(pwshPath)
.arg('-command')
.arg(command);
const pwshOptions = <tr.IExecOptions> {
cwd: cwd,
failOnStdErr: true,
errStream: process.stderr,
outStream: process.stdout,
ignoreReturnCode: false
};
let pwshOutput = '';
pwshCmd.on('stdout', (data) => {
pwshOutput += data.toString();
});
await pwshCmd.exec(pwshOptions);
return pwshOutput.trim();
} catch (err) {
tl.error(tl.loc('PwshCommandFailed', command));
throw err;
}
}
}
21 changes: 18 additions & 3 deletions azurecontainerapps/src/ContainerAppHelper.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as tl from 'azure-pipelines-task-lib/task';
import os from 'os';
import { CommandHelper } from './CommandHelper';

const ORYX_CLI_IMAGE: string = 'cormtestacr.azurecr.io/oryx/cli:latest';
Expand Down Expand Up @@ -118,9 +119,23 @@ export class ContainerAppHelper {
public async installPackCliAsync() {
tl.debug('Attempting to install the pack CLI');
try {
const command: string = '(curl -sSL \"https://github.com/buildpacks/pack/releases/download/v0.27.0/pack-v0.27.0-linux.tgz\" | ' +
'tar -C /usr/local/bin/ --no-same-owner -xzv pack)';
await new CommandHelper().execBashCommandAsync(command);
if (os.platform() == 'win32') {
let packUri = 'https://github.com/buildpacks/pack/releases/download/v0.27.0/pack-v0.27.0-win32.zip';
let downloadFile = 'C:\\Temp\\pack-v0.27.0-win32.zip';

const command: string = `(Invoke-WebRequest -Uri ${packUri} -OutFile ${downloadFile}; ` +
`$ExtractPath = "C:\\Temp\\pack\\; ` +
`$ExtractShell = New-Object -ComObject Shell.Application; ` +
`$ExtractFiles = $ExtractShell.Namespace(${downloadFile}).Items(); ` +
`$ExtractShell.NameSpace($ExtractPath).CopyHere($ExtractFiles); ` +
`Start-Process $ExtractPath`;

await new CommandHelper().execPwshCommandAsync(command);
} else {
const command: string = '(curl -sSL \"https://github.com/buildpacks/pack/releases/download/v0.27.0/pack-v0.27.0-linux.tgz\" | ' +
'tar -C /usr/local/bin/ --no-same-owner -xzv pack)';
await new CommandHelper().execBashCommandAsync(command);
}
} catch (err) {
tl.error(tl.loc('PackCliInstallFailed'));
throw err;
Expand Down
2 changes: 1 addition & 1 deletion vss-extension.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifestVersion": 1,
"id": "AzureContainerAppsRC",
"name": "Azure Container Apps Deploy (Release Candidate)",
"version": "0.1.7",
"version": "0.1.8",
"publisher": "microsoft-oryx",
"public": true,
"targets": [
Expand Down