From 3902c697fb44e8920054cdd8bbc05679064de81d Mon Sep 17 00:00:00 2001 From: Alper Rifat Ulucinar Date: Tue, 9 Jan 2024 23:56:10 +0300 Subject: [PATCH] Differentiate the names of the generated conversion hub and spoke files - Do not generate empty conversion hub or spoke files. Signed-off-by: Alper Rifat Ulucinar --- pkg/pipeline/conversion_hub.go | 5 ++++- pkg/pipeline/conversion_spoke.go | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/pkg/pipeline/conversion_hub.go b/pkg/pipeline/conversion_hub.go index 1097bf73..f04372b8 100644 --- a/pkg/pipeline/conversion_hub.go +++ b/pkg/pipeline/conversion_hub.go @@ -40,7 +40,7 @@ func (cg *ConversionHubGenerator) Generate(cfgs []*terraformedInput, apiVersion wrapper.WithGenStatement(GenStatement), wrapper.WithHeaderPath(cg.LicenseHeaderPath), ) - filePath := filepath.Join(cg.LocalDirectoryPath, "zz_generated.conversion.go") + filePath := filepath.Join(cg.LocalDirectoryPath, "zz_generated.conversion_hubs.go") vars := map[string]any{ "APIVersion": apiVersion, } @@ -55,6 +55,9 @@ func (cg *ConversionHubGenerator) Generate(cfgs []*terraformedInput, apiVersion index++ } vars["Resources"] = resources + if len(resources) == 0 { + return nil + } return errors.Wrapf( trFile.Write(filePath, vars, os.ModePerm), "cannot write the generated conversion Hub functions file %s", filePath, diff --git a/pkg/pipeline/conversion_spoke.go b/pkg/pipeline/conversion_spoke.go index 8bb9dc38..1811b111 100644 --- a/pkg/pipeline/conversion_spoke.go +++ b/pkg/pipeline/conversion_spoke.go @@ -61,7 +61,7 @@ func (cg *ConversionSpokeGenerator) Generate(cfgs []*terraformedInput) error { / wrapper.WithGenStatement(GenStatement), wrapper.WithHeaderPath(cg.LicenseHeaderPath), ) - filePath := filepath.Join(cg.LocalDirectoryPath, e.Name(), "zz_generated.conversion.go") + filePath := filepath.Join(cg.LocalDirectoryPath, e.Name(), "zz_generated.conversion_spokes.go") vars := map[string]any{ "APIVersion": e.Name(), } @@ -96,6 +96,9 @@ func (cg *ConversionSpokeGenerator) Generate(cfgs []*terraformedInput) error { / } vars["Resources"] = resources + if len(resources) == 0 { + continue + } if err := trFile.Write(filePath, vars, os.ModePerm); err != nil { return errors.Wrapf(err, "cannot write the generated conversion Hub functions file %s", filePath) }