Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip customize files + set workdir #12

Merged
merged 6 commits into from
Feb 27, 2024
Merged
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
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")
d1egoaz marked this conversation as resolved.
Show resolved Hide resolved
return ErrKustomizeNotSupported
default:
msanterre marked this conversation as resolved.
Show resolved Hide resolved
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.")
d1egoaz marked this conversation as resolved.
Show resolved Hide resolved
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
msanterre marked this conversation as resolved.
Show resolved Hide resolved
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
Loading