Skip to content

Commit 6ffaddc

Browse files
committed
feat: add ability to specify Git repos and Homebrew packages
1 parent 41d5852 commit 6ffaddc

File tree

4 files changed

+47
-4
lines changed

4 files changed

+47
-4
lines changed

.github/workflows/release.yml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
- name: Set up Go
2020
uses: actions/setup-go@v5
2121
with:
22-
go-version: "1.24"
22+
go-version: "1.25"
2323

2424
- name: Run tests
2525
run: go test -v ./...
@@ -35,7 +35,7 @@ jobs:
3535
- name: Set up Go
3636
uses: actions/setup-go@v5
3737
with:
38-
go-version: "1.24"
38+
go-version: "1.25"
3939

4040
- name: Build binaries for all platforms
4141
run: |
@@ -57,6 +57,10 @@ jobs:
5757
echo "Building Linux amd64..."
5858
GOOS=linux GOARCH=amd64 go build -ldflags="${LDFLAGS}" -o dist/devenv-linux-amd64 ./cmd/devenv
5959
60+
# Linux arm64
61+
echo "Building Linux arm64..."
62+
GOOS=linux GOARCH=arm64 go build -ldflags="${LDFLAGS}" -o dist/devenv-linux-arm64 ./cmd/devenv
63+
6064
# macOS amd64 (Intel)
6165
echo "Building macOS amd64..."
6266
GOOS=darwin GOARCH=amd64 go build -ldflags="${LDFLAGS}" -o dist/devenv-darwin-amd64 ./cmd/devenv
@@ -72,14 +76,21 @@ jobs:
7276
echo "✅ All binaries built successfully"
7377
ls -lh dist/
7478
79+
- name: Generate checksums
80+
run: |
81+
cd dist
82+
sha256sum * > checksums.txt
83+
7584
- name: Create Release
7685
uses: softprops/action-gh-release@v2
7786
with:
7887
files: |
7988
dist/devenv-linux-amd64
89+
dist/devenv-linux-arm64
8090
dist/devenv-darwin-amd64
8191
dist/devenv-darwin-arm64
8292
dist/devenv-windows-amd64.exe
93+
dist/checksums.txt
8394
generate_release_notes: true
8495
draft: false
8596
prerelease: false

internal/config/types.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ type BaseConfig struct {
1717
// Package management
1818
Packages PackageConfig `yaml:"packages,omitempty"`
1919

20+
// Git repos to be cloned
21+
GitRepos []GitRepo `yaml:"gitRepos,omitempty" validate:"dive"`
22+
2023
// Storage configuration
2124
Volumes []VolumeMount `yaml:"volumes,omitempty" validate:"dive"`
2225

@@ -68,9 +71,17 @@ type GitConfig struct {
6871
type PackageConfig struct {
6972
Python []string `yaml:"python,omitempty" validate:"dive,min=1"`
7073
APT []string `yaml:"apt,omitempty" validate:"dive,min=1"`
74+
Brew []string `yaml:"brew,omitempty" validate:"dive,min=1"`
7175
// Consider adding other package managers such as NPM, Yarn, etc.
7276
}
7377

78+
type GitRepo struct {
79+
URL string `yaml:"url" validate:"required,min=1,url"`
80+
Branch string `yaml:"branch,omitempty" validate:"omitempty,min=1"`
81+
CommitHash string `yaml:"commitHash,omitempty" validate:"omitempty,min=1"`
82+
Directory string `yaml:"directory,omitempty" validate:"omitempty,min=1,filepath"`
83+
}
84+
7485
// ResourceConfig represents resource allocation
7586
type ResourceConfig struct {
7687
CPU any `yaml:"cpu,omitempty" validate:"omitempty,k8s_cpu"`
@@ -112,7 +123,9 @@ func NewBaseConfigWithDefaults() BaseConfig {
112123
Packages: PackageConfig{
113124
Python: []string{}, // Empty slice - no default packages
114125
APT: []string{}, // Empty slice - no default packages
126+
Brew: []string{}, // Empty slice - no default packages
115127
},
128+
GitRepos: []GitRepo{}, // Empty slice - no default git repositories
116129
Volumes: []VolumeMount{}, // Empty slice - no default volumes
117130
Namespace: "devenv", // Default namespace
118131
EnvironmentName: "development", // Default environment name

internal/config/validation.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ func init() {
5656
if err := validate.RegisterValidation("k8s_memory", validateKubernetesMemory); err != nil {
5757
panic(fmt.Errorf("register validator k8s_memory: %w", err))
5858
}
59+
validate.RegisterStructValidation(validateGitRepo, GitRepo{})
5960
}
6061

6162
// validateSSHKeys implements the "ssh_keys" tag.
@@ -79,6 +80,17 @@ func validateSSHKeys(fl validator.FieldLevel) bool {
7980
return true
8081
}
8182

83+
// validateGitRepo implements the "git_repo" tag.
84+
// Ensures that if both Branch and CommitHash are specified, an error is raised.
85+
func validateGitRepo(sl validator.StructLevel) {
86+
repo := sl.Current().Interface().(GitRepo)
87+
// Both Branch and CommitHash cannot be specified simultaneously.
88+
if repo.Branch != "" && repo.CommitHash != "" {
89+
sl.ReportError(repo.Branch, "branch", "Branch", "branch_commit_conflict", "")
90+
sl.ReportError(repo.CommitHash, "commitHash", "CommitHash", "branch_commit_conflict", "")
91+
}
92+
}
93+
8294
// validateKubernetesCPU implements the "k8s_cpu" tag for *raw* CPU fields.
8395
// Accepts:
8496
// - Strings: "", "unlimited", plain number ("2", "2.5"), or millicores ("500m")
@@ -182,6 +194,13 @@ func ValidateDevEnvConfig(config *DevEnvConfig) error {
182194
return err // "memory must be >= 0"
183195
}
184196

197+
// If GitRepos are specified, ensure that hash & branch are not both specified.
198+
for i, repo := range config.GitRepos {
199+
if repo.CommitHash != "" && repo.Branch != "" {
200+
return fmt.Errorf("gitRepos[%d]: commitHash and branch cannot both be specified", i)
201+
}
202+
}
203+
185204
if config.Resources.GPU < 0 {
186205
return fmt.Errorf("gpu must be >= 0")
187206
}

internal/templates/template_files/system/manifests/namespace.tmpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ apiVersion: v1
22
kind: Namespace
33
metadata:
44
name: {{.Namespace}}
5-
environment: {{.EnvironmentName}}
65
annotations:
7-
description: "Namespace for DevENV resources"
6+
description: "Namespace for DevENV resources"
7+
environment: {{.EnvironmentName}}

0 commit comments

Comments
 (0)