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
3 changes: 2 additions & 1 deletion chartvalidator/checker/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ helm_output
*.bin
manifests
imageLists
test_output
test_output
checker
2 changes: 1 addition & 1 deletion chartvalidator/checker/go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/interledger/interledger-app-deploy/ci
module github.com/builderslab/chartvalidator/checker

go 1.24.5

Expand Down
89 changes: 88 additions & 1 deletion chartvalidator/checker/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"flag"
"fmt"
"os"
"sync"
)

var srcPrefix string = "../"
Expand All @@ -22,6 +23,8 @@ func main() {
switch command {
case "run-checks":
runChartChecksCommand(args)
case "render-only":
runRenderOnlyCommand(args)
case "help", "-h", "--help":
printUsage()
default:
Expand All @@ -32,10 +35,11 @@ func main() {
}

func printUsage() {
fmt.Println("Usage: run-manifest-checks <command> [flags]")
fmt.Println("Usage: chart-checker <command> [flags]")
fmt.Println("")
fmt.Println("Commands:")
fmt.Println(" run-checks Runs all available checks on the charts for given environment.")
fmt.Println(" render-only Renders the charts for the given environment without performing validations.")
fmt.Println(" help Displays this help message.")
fmt.Println("")
fmt.Println("Use 'run-manifest-checks <command> -h' to see command-specific flags.")
Expand Down Expand Up @@ -82,6 +86,89 @@ func runChartChecksCommand(args []string) {

}

func runRenderOnlyCommand(args []string) {
fs := flag.NewFlagSet("render-only", flag.ExitOnError)

var (
singleEnv = fs.String("env", "", "Only process this environment (folder name under -envdir).")
envDir = fs.String("envdir", "../env", "Base directory containing environment folders.")
outputDir = fs.String("output", "manifests", "Output directory for rendered charts.")
verbose = fs.Bool("v", false, "Enable verbose logging.")
)

fs.Usage = func() {
fmt.Println("Usage: run-manifest-checks render-only [flags]")
fmt.Println("")
fmt.Println("Renders all charts found in the ApplicationSets in the specified environment and outputs the manifests to the specified output directory.")
fmt.Println("")
fs.PrintDefaults()
}

if err := fs.Parse(args); err != nil {
os.Exit(1)
}

verboseLogging = *verbose

if err := runAllChartRenders(*singleEnv, *envDir, *outputDir); err != nil {
fmt.Fprintf(os.Stderr, "Error running chart renders: %v\n", err)
os.Exit(1)
}

}


func runAllChartRenders(singleEnv, envDir, outputDir string) error {
fmt.Println("Starting chart renders...")
params, err := findChartsInAppsets(envDir, singleEnv)
if err != nil {
return fmt.Errorf("failed to find charts in ApplicationSets: %w", err)
}

fmt.Printf("Found %d charts to process.\n", len(params))

context := context.Background()

// Delete output dir if it exists
if err := os.RemoveAll(outputDir); err != nil {
return fmt.Errorf("failed to clear output directory: %w", err)
}

renderer := ChartRenderingEngine{
context: context,
executor: &RealCommandExecutor{},
outputDir: outputDir,
inputChan: make(chan ChartRenderParams),
resultChan: make(chan RenderResult),
name: "ChartRenderer",
errorChan: make(chan ErrorResult),
workerWaitGroup: sync.WaitGroup{},
}
renderer.Start(10)

go func() {
for _, p := range params {
renderer.inputChan <- p
}
close(renderer.inputChan)
}()

busy := true
for busy {
select {
case renderResult, ok := <-renderer.resultChan:
if !ok {
fmt.Println("No more render results.")
busy = false
}
fmt.Printf(">>> chart %s %s from env %s: ✓ Rendered successfully to %s\n", renderResult.Chart.ChartName, renderResult.Chart.ChartVersion, renderResult.Chart.Env, renderResult.ManifestPath)
case renderErr := <-renderer.errorChan:
fmt.Printf(">>> chart %s %s from env %s: ✗ Error: %v\n", renderErr.Chart.ChartName, renderErr.Chart.ChartVersion, renderErr.Chart.Env, renderErr.Error)
}
}
fmt.Printf("Done")
return nil
}

func runAllChartChecks(singleEnv, envDir, outputDir string) error {
fmt.Println("Starting chart checks...")
Expand Down