Skip to content

Commit

Permalink
Rename ConversionConvertable as ConversionSpoke
Browse files Browse the repository at this point in the history
Signed-off-by: Alper Rifat Ulucinar <ulucinar@users.noreply.github.com>
  • Loading branch information
ulucinar committed Jan 5, 2024
1 parent e36f36c commit 8a75419
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ var (
regexTypeFile = regexp.MustCompile(`zz_(.+)_types.go`)
)

// NewConversionConvertibleGenerator returns a new ConversionConvertibleGenerator.
func NewConversionConvertibleGenerator(pkg *types.Package, rootDir, group, version string) *ConversionConvertibleGenerator {
return &ConversionConvertibleGenerator{
// NewConversionSpokeGenerator returns a new ConversionSpokeGenerator.
func NewConversionSpokeGenerator(pkg *types.Package, rootDir, group, version string) *ConversionSpokeGenerator {
return &ConversionSpokeGenerator{
LocalDirectoryPath: filepath.Join(rootDir, "apis", strings.ToLower(strings.Split(group, ".")[0])),
LicenseHeaderPath: filepath.Join(rootDir, "hack", "boilerplate.go.txt"),
SpokeVersionsMap: make(map[string][]string),
Expand All @@ -33,9 +33,9 @@ func NewConversionConvertibleGenerator(pkg *types.Package, rootDir, group, versi
}
}

// ConversionConvertibleGenerator generates conversion methods implementing the
// ConversionSpokeGenerator generates conversion methods implementing the
// conversion.Convertible interface on the CRD structs.
type ConversionConvertibleGenerator struct {
type ConversionSpokeGenerator struct {
LocalDirectoryPath string
LicenseHeaderPath string
SpokeVersionsMap map[string][]string
Expand All @@ -45,7 +45,7 @@ type ConversionConvertibleGenerator struct {
}

// Generate writes generated conversion.Convertible interface functions
func (cg *ConversionConvertibleGenerator) Generate(cfgs []*terraformedInput) error {
func (cg *ConversionSpokeGenerator) Generate(cfgs []*terraformedInput) error {
entries, err := os.ReadDir(cg.LocalDirectoryPath)
if err != nil {
return errors.Wrapf(err, "cannot list the directory entries for the source folder %s while generating the conversion.Convertible interface functions", cg.LocalDirectoryPath)
Expand All @@ -57,7 +57,7 @@ func (cg *ConversionConvertibleGenerator) Generate(cfgs []*terraformedInput) err
// the current CRD version is the hub version.
continue
}
trFile := wrapper.NewFile(cg.pkg.Path(), cg.pkg.Name(), templates.ConversionConvertibleTemplate,
trFile := wrapper.NewFile(cg.pkg.Path(), cg.pkg.Name(), templates.ConversionSpokeTemplate,
wrapper.WithGenStatement(GenStatement),
wrapper.WithHeaderPath(cg.LicenseHeaderPath),
)
Expand Down
6 changes: 3 additions & 3 deletions pkg/pipeline/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func Run(pc *config.Provider, rootDir string) { //nolint:gocyclo
crdGen := NewCRDGenerator(versionGen.Package(), rootDir, pc.ShortName, group, version)
tfGen := NewTerraformedGenerator(versionGen.Package(), rootDir, group, version)
conversionHubGen := NewConversionHubGenerator(versionGen.Package(), rootDir, group, version)
conversionConvertibleGen := NewConversionConvertibleGenerator(versionGen.Package(), rootDir, group, version)
conversionSpokeGen := NewConversionSpokeGenerator(versionGen.Package(), rootDir, group, version)
ctrlGen := NewControllerGenerator(rootDir, pc.ModulePath, group)

for _, name := range sortedResources(resources) {
Expand Down Expand Up @@ -133,7 +133,7 @@ func Run(pc *config.Provider, rootDir string) { //nolint:gocyclo
panic(errors.Wrapf(err, "cannot generate the conversion.Hub function for the resource group %q", group))
}

if err := conversionConvertibleGen.Generate(tfResources); err != nil {
if err := conversionSpokeGen.Generate(tfResources); err != nil {
panic(errors.Wrapf(err, "cannot generate the conversion.Convertible functions for the resource group %q", group))
}

Expand All @@ -144,7 +144,7 @@ func Run(pc *config.Provider, rootDir string) { //nolint:gocyclo
apiVersionPkgList = append(apiVersionPkgList, p)
for _, r := range resources {
// if there are spoke versions for the given group.Kind
if spokeVersions := conversionConvertibleGen.SpokeVersionsMap[fmt.Sprintf("%s.%s", r.ShortGroup, r.Kind)]; spokeVersions != nil {
if spokeVersions := conversionSpokeGen.SpokeVersionsMap[fmt.Sprintf("%s.%s", r.ShortGroup, r.Kind)]; spokeVersions != nil {
base := filepath.Dir(p)
for _, sv := range spokeVersions {
apiVersionPkgList = append(apiVersionPkgList, filepath.Join(base, sv))
Expand Down
6 changes: 3 additions & 3 deletions pkg/pipeline/templates/embed.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ var SetupTemplate string
//go:embed conversion_hub.go.tmpl
var ConversionHubTemplate string

// ConversionConvertibleTemplate is populated with the CRD API versions
// ConversionSpokeTemplate is populated with the CRD API versions
// conversion.Convertible implementation template string.
//
//go:embed conversion_convertible.go.tmpl
var ConversionConvertibleTemplate string
//go:embed conversion_spoke.go.tmpl
var ConversionSpokeTemplate string

0 comments on commit 8a75419

Please sign in to comment.