Skip to content

Commit

Permalink
fix appsets from directory
Browse files Browse the repository at this point in the history
  • Loading branch information
schlapzz committed Jun 28, 2023
1 parent 9d4426d commit 4134fd4
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 5 deletions.
8 changes: 8 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@
"request": "launch",
"mode": "test",
"program": "${relativeFileDirname}",
},
{
"name": "Run argocd tests",
"type": "go",
"request": "launch",
"mode": "test",
"program": "argocd/",

}
]
}
14 changes: 11 additions & 3 deletions argocd/appSet.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,34 @@ package argocd

import (
"fmt"
"io/fs"
"os"
"path/filepath"

"github.com/argoproj/argo-cd/v2/applicationset/generators"
"github.com/argoproj/argo-cd/v2/applicationset/utils"
"github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1"
"github.com/ghodss/yaml"
"github.com/go-godo/godo/glob"
log "github.com/sirupsen/logrus"
)

func RenderApplicationSets(inputDir, outDir string) error {
files, _, err := glob.Glob([]string{inputDir})
inputDir, err := filepath.Abs(inputDir)
if err != nil {
return err
}

files := make([]string, 0)
filepath.WalkDir(inputDir, func(path string, d fs.DirEntry, err error) error {
if !d.IsDir() {
files = append(files, path)
}
return nil
})

var hasError bool
for i := range files {
file := files[i].Path
file := files[i]
err = RenderApplicationSet(file, outDir)
if err != nil {
log.Errorf("could not process application set '%s': %s", file, err.Error())
Expand Down
2 changes: 1 addition & 1 deletion argocd/appSet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
func TestRenderApplicationSet(t *testing.T) {

outPath := "../out/app-set/"
err := RenderApplicationSets("../testdata/appSet/", outPath)
err := RenderApplicationSets("../testdata/appSet/input", outPath)
if err != nil {
t.Error(err)
}
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ services:
image: "redis"
ports:
- "6379:6379"
repos:
reposerver:
image: "quay.io/argoproj/argocd:latest"
command:
- "--redis"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
name: exapp
namespace: nsa
spec:
generators:
- list:
Expand Down

0 comments on commit 4134fd4

Please sign in to comment.