Skip to content

Commit

Permalink
Differentiate the names of the generated conversion hub and spoke files
Browse files Browse the repository at this point in the history
- Do not generate empty conversion hub or spoke files.

Signed-off-by: Alper Rifat Ulucinar <ulucinar@users.noreply.github.com>
  • Loading branch information
ulucinar committed Jan 9, 2024
1 parent 1906bf1 commit 3902c69
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion pkg/pipeline/conversion_hub.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand All @@ -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,
Expand Down
5 changes: 4 additions & 1 deletion pkg/pipeline/conversion_spoke.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
}
Expand Down Expand Up @@ -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)
}
Expand Down

0 comments on commit 3902c69

Please sign in to comment.