Skip to content

Commit

Permalink
Merge pull request #12 from 1debit/skip-kustomize-files
Browse files Browse the repository at this point in the history
Skip customize files + set workdir
  • Loading branch information
msanterre authored Feb 27, 2024
2 parents 00544e1 + b7e06ba commit 0db0789
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"errors"
"flag"
"fmt"
"log"
Expand All @@ -18,6 +19,8 @@ import (

const InfiniteDepth = -1

var ErrKustomizeNotSupported = errors.New("kustomize not supported")

// Renderer is a function that can render an Argo application.
type Renderer func(*v1alpha1.Application, string) error

Expand Down Expand Up @@ -136,6 +139,9 @@ func (w *Walker) walk(inputPath, outputPath string, depth, maxDepth int, visited
if hashGenerated != hash || emptyManifest {
log.Printf("No match detected. Render: %s\n", crd.ObjectMeta.Name)
if err := w.Render(crd, path); err != nil {
if errors.Is(err, ErrKustomizeNotSupported) {
continue
}
return err
}

Expand All @@ -157,10 +163,14 @@ func (w *Walker) Render(application *v1alpha1.Application, output string) error

var render Renderer

// Figure out what renderer to use
if application.Spec.Source.Helm != nil {
// Figure out which renderer to use
switch {
case application.Spec.Source.Helm != nil:
render = w.HelmTemplate
} else {
case application.Spec.Source.Kustomize != nil:
log.Println("WARNING: kustomize not supported")
return ErrKustomizeNotSupported
default:
render = w.CopySource
}

Expand Down Expand Up @@ -203,6 +213,7 @@ func PostRender(command string) PostRenderer {

func main() {
root := flag.String("root", "bootstrap", "Directory to initially look for k8s manifests containing Argo applications. The root of the tree.")
workdir := flag.String("workdir", ".", "Directory to run the command in.")
renderDir := flag.String("output", ".zz.auto-generated", "Path to store the compiled Argo applications.")
maxDepth := flag.Int("max-depth", InfiniteDepth, "Maximum depth for the depth first walk.")
hashStore := flag.String("hash-store", "sumfile", "The hashing backend to use. Can be `sumfile` or `json`.")
Expand All @@ -213,6 +224,12 @@ func main() {
postRenderer := flag.String("post-renderer", "", "When provided, binary will be called after an application is rendered.")
flag.Parse()

// Runs the command in the specified directory
err := os.Chdir(*workdir)
if err != nil {
log.Fatal("Could not set workdir: ", err)
}

start := time.Now()
if err := helm.VerifyRenderDir(*renderDir); err != nil {
log.Fatal(err)
Expand Down

0 comments on commit 0db0789

Please sign in to comment.