Skip to content

Commit 625ae6a

Browse files
CopilotRoemer
andauthored
feat: add Waza devcontainer feature (#69)
* Initial plan * feat: add waza feature installer Co-authored-by: Roemer <393641+Roemer@users.noreply.github.com> * fix: register defer before error return for proper cleanup in waza installer Co-authored-by: Roemer <393641+Roemer@users.noreply.github.com> * fix: remove binary, add to CI, add WAZA_NO_UPDATE_CHECK env var Co-authored-by: Roemer <393641+Roemer@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Roemer <393641+Roemer@users.noreply.github.com>
1 parent 95f51bb commit 625ae6a

9 files changed

Lines changed: 158 additions & 0 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ jobs:
116116
"terraform",
117117
"timezone",
118118
"vault-cli",
119+
"waza",
119120
"zig"
120121
]
121122
runs-on: ubuntu-latest

‎build/build.go‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,10 @@ func init() {
222222
gotaskr.Task("Feature:vault-cli:Package", func() error { return packageFeature("vault-cli") })
223223
gotaskr.Task("Feature:vault-cli:Test", func() error { return testFeature("vault-cli") })
224224

225+
////////// waza
226+
gotaskr.Task("Feature:waza:Package", func() error { return packageFeature("waza") })
227+
gotaskr.Task("Feature:waza:Test", func() error { return testFeature("waza") })
228+
225229
////////// zig
226230
gotaskr.Task("Feature:zig:Package", func() error { return packageFeature("zig") })
227231
gotaskr.Task("Feature:zig:Test", func() error { return testFeature("zig") })
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"id": "waza",
3+
"version": "1.0.0",
4+
"name": "Waza",
5+
"description": "Installs Waza, the AI-powered development agent from Microsoft.",
6+
"options": {
7+
"version": {
8+
"type": "string",
9+
"proposals": [
10+
"latest",
11+
"0.38.5"
12+
],
13+
"default": "latest",
14+
"description": "The version of Waza to install."
15+
},
16+
"downloadUrl": {
17+
"type": "string",
18+
"default": "",
19+
"proposals": [
20+
"https://mycompany.com/artifactory/github-releases-remote"
21+
],
22+
"description": "The download URL to use for Waza binaries."
23+
}
24+
},
25+
"containerEnv": {
26+
"WAZA_NO_UPDATE_CHECK": "1"
27+
}
28+
}

‎features/src/waza/install.sh‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
. ./functions.sh
2+
3+
"./installer_$(detect_arch)" \
4+
-version="${VERSION:-"latest"}" \
5+
-downloadUrl="${DOWNLOADURL:-""}"

‎features/src/waza/installer.go‎

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
package main
2+
3+
import (
4+
"builder/installer"
5+
"flag"
6+
"fmt"
7+
"os"
8+
"regexp"
9+
10+
"github.com/roemer/gover"
11+
)
12+
13+
//////////
14+
// Configuration
15+
//////////
16+
17+
var versionRegex *regexp.Regexp = regexp.MustCompile(`(?m)^v(?P<raw>(\d+)\.(\d+)\.(\d+))$`)
18+
19+
//////////
20+
// Main
21+
//////////
22+
23+
func main() {
24+
if err := runMain(); err != nil {
25+
fmt.Printf("Error: %v\n", err)
26+
os.Exit(1)
27+
}
28+
}
29+
30+
func runMain() error {
31+
// Handle the flags
32+
version := flag.String("version", "latest", "")
33+
downloadUrl := flag.String("downloadUrl", "", "")
34+
flag.Parse()
35+
36+
// Load settings from an external file
37+
if err := installer.LoadOverrides(); err != nil {
38+
return err
39+
}
40+
41+
// Apply override logic for URLs
42+
installer.HandleGitHubOverride(downloadUrl, "microsoft/waza", "waza-download-url")
43+
44+
// Create and process the feature
45+
feature := installer.NewFeature("Waza", false,
46+
&wazaComponent{
47+
ComponentBase: installer.NewComponentBase("Waza", *version),
48+
DownloadUrl: *downloadUrl,
49+
})
50+
return feature.Process()
51+
}
52+
53+
//////////
54+
// Implementation
55+
//////////
56+
57+
type wazaComponent struct {
58+
*installer.ComponentBase
59+
DownloadUrl string
60+
}
61+
62+
func (c *wazaComponent) GetAllVersions() ([]*gover.Version, error) {
63+
tags, err := installer.Tools.GitHub.GetTags("microsoft", "waza")
64+
if err != nil {
65+
return nil, err
66+
}
67+
return installer.Tools.Versioning.ParseVersionsFromList(tags, versionRegex, true)
68+
}
69+
70+
func (c *wazaComponent) InstallVersion(version *gover.Version) error {
71+
archPart, err := installer.Tools.System.MapArchitecture(map[string]string{
72+
installer.AMD64: "amd64",
73+
installer.ARM64: "arm64",
74+
})
75+
if err != nil {
76+
return err
77+
}
78+
// Download the binary directly (no archive)
79+
fileName := fmt.Sprintf("waza-linux-%s", archPart)
80+
downloadUrl, err := installer.Tools.Http.BuildUrl(c.DownloadUrl, "v"+version.Raw, fileName)
81+
if err != nil {
82+
return err
83+
}
84+
downloadErr := installer.Tools.Download.ToFile(downloadUrl, fileName, "waza")
85+
defer os.Remove(fileName)
86+
if downloadErr != nil {
87+
return downloadErr
88+
}
89+
// Install the binary
90+
return installer.Tools.System.InstallBinaryToUsrLocalBin(fileName, "waza")
91+
}

‎features/test/waza/install.sh‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
set -e
3+
4+
[[ -f "$(dirname "$0")/../functions.sh" ]] && source "$(dirname "$0")/../functions.sh"
5+
[[ -f "$(dirname "$0")/functions.sh" ]] && source "$(dirname "$0")/functions.sh"
6+
7+
check_file_exists "/usr/local/bin/waza"
8+
check_version "$(waza --version 2>&1)" "0.38.5"

‎features/test/waza/scenarios.json‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"install": {
3+
"build": {
4+
"dockerfile": "Dockerfile"
5+
},
6+
"features": {
7+
"./waza": {
8+
"version": "0.38.5"
9+
}
10+
}
11+
}
12+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[
2+
"mcr.microsoft.com/devcontainers/base:debian12",
3+
"mcr.microsoft.com/devcontainers/base:debian13",
4+
"mcr.microsoft.com/devcontainers/base:ubuntu24.04",
5+
"mcr.microsoft.com/devcontainers/base:ubuntu26.04"
6+
]

‎override-all.env‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@ TERRAFORM_VERSIONS_URL=""
102102
VAULT_CLI_DOWNLOAD_URL=""
103103
VAULT_CLI_VERSIONS_URL=""
104104

105+
# waza
106+
WAZA_DOWNLOAD_URL=""
107+
105108
# zig
106109
ZIG_DOWNLOAD_URL=""
107110
ZIG_VERSIONS_URL=""

0 commit comments

Comments
 (0)