Skip to content
This repository has been archived by the owner on May 31, 2024. It is now read-only.

Commit

Permalink
Add -p flag to skip updating ns.yaml file with placement bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
edcdavid committed Mar 8, 2024
1 parent e653ef7 commit c1e67bc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 4 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ func main() {
var generateACMPolicies = flag.Bool("g", false, "optionally generates ACM policies for PGT and ACM Gen templates")
// Defines ns.yaml file for templates
var NSYAML = flag.String("n", fileutils.NamespaceFileName, "the optional ns.yaml file path")
// optionally disables generating default placement in ns.yaml
var skipDefaultPlacementBindings = flag.Bool("p", false, "optionally disable generating default placement bindings in ns.yaml")
// Defines source-crs directory location
var sourceCRs = flag.String("c", "", "the optional comma delimited list of reference source CRs templates")
// Optionally generate placement API template containing toleration for
Expand Down Expand Up @@ -80,8 +82,8 @@ func main() {
os.Exit(1)
}

if NSYAML != nil && *NSYAML != "" {
err = fileutils.CopyAndProcessNSAndKustomizationYAML(*NSYAML, *inputFile, *outputDir)
if NSYAML != nil && *NSYAML != "" && skipDefaultPlacementBindings != nil {
err = fileutils.CopyAndProcessNSAndKustomizationYAML(*NSYAML, *inputFile, *outputDir, *skipDefaultPlacementBindings)
if err != nil {
fmt.Printf("Could not post-process %s and %s files, err: %s", *NSYAML, fileutils.KustomizationFileName, err)
}
Expand Down
6 changes: 5 additions & 1 deletion packages/fileutils/fileutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,15 @@ func RenameACMGenTemplatesInKustomization(inputFile, outputDir string) (err erro
return nil
}

func CopyAndProcessNSAndKustomizationYAML(nsFilePath, inputFile, outputDir string) (err error) {
func CopyAndProcessNSAndKustomizationYAML(nsFilePath, inputFile, outputDir string, skipUpdateNs bool) (err error) {
err = RenameACMGenTemplatesInKustomization(inputFile, outputDir)
if err != nil {
return fmt.Errorf("could not rename generators in kustomization file, err: %s", err)
}
// No need to update ns.yaml, exiting early
if skipUpdateNs {
return nil
}
err = AddDefaultPlacementBindingsToNSFile(nsFilePath, outputDir)
if err != nil {
return fmt.Errorf("could not add placement bindings in NS file file, err: %s", err)
Expand Down

0 comments on commit c1e67bc

Please sign in to comment.