Skip to content

Commit

Permalink
cleanup: remove unused usage of IsLegacyLayout
Browse files Browse the repository at this point in the history
  • Loading branch information
camilamacedo86 committed May 20, 2024
1 parent 076fded commit 74dce48
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,30 +36,15 @@ type Types struct {

// Port if informed we will create the scaffold with this spec
Port string

IsLegacyLayout bool
}

// SetTemplateDefaults implements file.Template
func (f *Types) SetTemplateDefaults() error {
if f.Path == "" {

if f.IsLegacyLayout {
if f.MultiGroup {
if f.Resource.Group != "" {
f.Path = filepath.Join("apis", "%[group]", "%[version]", "%[kind]_types.go")
} else {
f.Path = filepath.Join("apis", "%[version]", "%[kind]_types.go")
}
} else {
f.Path = filepath.Join("api", "%[version]", "%[kind]_types.go")
}
if f.MultiGroup && f.Resource.Group != "" {
f.Path = filepath.Join("api", "%[group]", "%[version]", "%[kind]_types.go")
} else {
if f.MultiGroup && f.Resource.Group != "" {
f.Path = filepath.Join("api", "%[group]", "%[version]", "%[kind]_types.go")
} else {
f.Path = filepath.Join("api", "%[version]", "%[kind]_types.go")
}
f.Path = filepath.Join("api", "%[version]", "%[kind]_types.go")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,36 +34,23 @@ type ControllerTest struct {
machinery.BoilerplateMixin
machinery.ResourceMixin

Port string
IsLegacyLayout bool
PackageName string
Port string
PackageName string
}

// SetTemplateDefaults implements file.Template
func (f *ControllerTest) SetTemplateDefaults() error {
if f.Path == "" {
if f.MultiGroup && f.Resource.Group != "" {
if f.IsLegacyLayout {
f.Path = filepath.Join("controllers", "%[group]", "%[kind]_controller_test.go")
} else {
f.Path = filepath.Join("internal", "controller", "%[group]", "%[kind]_controller_test.go")
}
f.Path = filepath.Join("internal", "controller", "%[group]", "%[kind]_controller_test.go")
} else {
if f.IsLegacyLayout {
f.Path = filepath.Join("controllers", "%[kind]_controller_test.go")
} else {
f.Path = filepath.Join("internal", "controller", "%[kind]_controller_test.go")
}
f.Path = filepath.Join("internal", "controller", "%[kind]_controller_test.go")
}
}
f.Path = f.Resource.Replacer().Replace(f.Path)
log.Println(f.Path)

f.PackageName = "controller"
if f.IsLegacyLayout {
f.PackageName = "controllers"
}

f.IfExistsAction = machinery.OverwriteFile

log.Println("creating import for %", f.Resource.Path)
Expand Down

0 comments on commit 74dce48

Please sign in to comment.