Skip to content
Merged
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
14 changes: 14 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: 2
updates:
- package-ecosystem: gomod
directory: /
schedule:
interval: weekly
groups:
go-dependencies:
patterns:
- "*"
- package-ecosystem: github-actions
directory: /
schedule:
interval: weekly
43 changes: 43 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: ci
on:
push:
branches:
- main
pull_request:
permissions:
contents: read
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: setup-go
uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6.5.0
with:
go-version-file: go.mod
- name: build
run: go build ./...
- name: vet
run: go vet ./...
- name: test
run: go test ./...
- name: check go.mod is tidy
run: |
go mod tidy
git diff --exit-code go.mod go.sum
- name: check generated schema is up to date
run: |
go run schema/main.go
git diff --exit-code pkg/config/v1alpha1/schema.json
lint:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: setup-go
uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6.5.0
with:
go-version-file: go.mod
- name: golangci-lint
uses: golangci/golangci-lint-action@d583c34f0599d37dbac4a198b9c83201be380893 # v9.3.0
40 changes: 18 additions & 22 deletions .github/workflows/go_releaser_branches.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,28 @@
name: go_releaser_branches
on:
- push
- workflow_dispatch
push:
branches:
- '**'
workflow_dispatch:
permissions:
contents: read
jobs:
go-releaser-branches:
runs-on: ubuntu-latest
steps:
- name: checkout=self
uses: actions/checkout@v4
- name: task=3.35.1
uses: pnorton5432/setup-task@v1
- name: checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
task-version: 3.35.1
- name: checkout=taskfiles
uses: actions/checkout@v4
fetch-depth: 0
- name: setup-go
uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6.5.0
with:
path: taskfiles
repository: bradfordwagner/taskfiles
- name: go=1.22
uses: actions/setup-go@v5
go-version-file: go.mod
- name: goreleaser snapshot
uses: goreleaser/goreleaser-action@f06c13b6b1a9625abc9e6e439d9c05a8f2190e94 # v7.2.3
with:
go-version: 1.22
- name: goreleaser=1.24.0
uses: goreleaser/goreleaser-action@v5
with:
version: 1.24.0
install-only: true
- name: task=branches
run: task -t ./taskfiles/tasks/go_releaser.yml is_tag=false
version: '~> v2'
args: release --snapshot --clean
env:
GITHUB_TOKEN: ${{ github.token }}
GITHUB_TOKEN: ${{ github.token }}

34 changes: 14 additions & 20 deletions .github/workflows/go_releaser_tags.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,25 @@ on:
push:
tags:
- '*'
permissions:
contents: write
jobs:
go-releaser-tags:
runs-on: ubuntu-latest
steps:
- name: checkout=self
uses: actions/checkout@v4
- name: task=3.35.1
uses: pnorton5432/setup-task@v1
- name: checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
task-version: 3.35.1
- name: checkout=taskfiles
uses: actions/checkout@v4
fetch-depth: 0
- name: setup-go
uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6.5.0
with:
path: taskfiles
repository: bradfordwagner/taskfiles
- name: go=1.22
uses: actions/setup-go@v5
go-version-file: go.mod
- name: goreleaser release
uses: goreleaser/goreleaser-action@f06c13b6b1a9625abc9e6e439d9c05a8f2190e94 # v7.2.3
with:
go-version: 1.22
- name: goreleaser=1.24.0
uses: goreleaser/goreleaser-action@v5
with:
version: 1.24.0
install-only: true
- name: task=tags
run: task -t ./taskfiles/tasks/go_releaser.yml is_tag=true
version: '~> v2'
args: release --clean
env:
GITHUB_TOKEN: ${{ github.token }}
GITHUB_TOKEN: ${{ github.token }}

3 changes: 2 additions & 1 deletion .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
version: 2
builds:
- main: ./main.go
binary: gitops-toolkit
Expand All @@ -19,7 +20,7 @@ archives:
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ incpatch .Version }}-next"
version_template: "{{ incpatch .Version }}-next"
changelog:
sort: asc
filters:
Expand Down
19 changes: 10 additions & 9 deletions cmd/clusters/clusters.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ package clusters

import (
"context"
"fmt"
"os"
"os/exec"
"path/filepath"
"time"

"github.com/ghodss/yaml"
Expand Down Expand Up @@ -74,8 +74,12 @@ func NewClustersCmd() *cobra.Command {
if err != nil {
return err
}
workdir := fmt.Sprintf("%s/gitops-toolkit/", outputDir)
defer os.RemoveAll(workdir)
workdir := filepath.Join(outputDir, "gitops-toolkit")
defer func() {
if err := os.RemoveAll(workdir); err != nil {
logging.Log().Warnf("unable to clean up workdir %s: %v", workdir, err)
}
}()
// create the clusters
clusterDistro := k3d.NewK3dDistro(workdir)
k8sClusters, err := clusterDistro.CreateClusters(timeoutCtx, &requestedClusters)
Expand All @@ -93,16 +97,13 @@ func NewClustersCmd() *cobra.Command {

// deploy the gitops engine to any enabled clusters
gitOpsEngine := argocd.NewGitOpsEngine(binaries)
if err != nil {
return err
}

for _, ops := range gitopsClusters {
if err = gitOpsEngine.Deploy(ctx, ops); err != nil {
if err = gitOpsEngine.Deploy(timeoutCtx, ops); err != nil {
logging.Log().Fatalf("error deploying gitops: %v", err)
}

if err = gitOpsEngine.AddClusters(ctx, ops, k8sClusters); err != nil {
if err = gitOpsEngine.AddClusters(timeoutCtx, ops, k8sClusters); err != nil {
logging.Log().Fatalf("error adding cluster to gitops engine: %v", err)
}
}
Expand All @@ -117,7 +118,7 @@ func NewClustersCmd() *cobra.Command {

func getDefaultClusterConfig() (filePath string) {
homeDir, _ := os.UserHomeDir()
filePath = fmt.Sprintf("%s/.gitops-toolkit-clusters.yaml", homeDir)
filePath = filepath.Join(homeDir, ".gitops-toolkit-clusters.yaml")
return
}

Expand Down
Loading