Skip to content

Commit

Permalink
Use lowered resource kind as file name
Browse files Browse the repository at this point in the history
  • Loading branch information
south37 committed Dec 29, 2020
1 parent ea7e28e commit aaba479
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion pkg/model/file/mixins.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ limitations under the License.
package file

import (
"strings"

"sigs.k8s.io/kubebuilder/v2/pkg/model/resource"
)

Expand Down Expand Up @@ -130,13 +132,15 @@ func (m *BoilerplateMixin) InjectBoilerplate(boilerplate string) {

// ResourceMixin provides templates with a injectable resource field
type ResourceMixin struct {
Resource *resource.Resource
Resource *resource.Resource
LoweredResourceKind string
}

// InjectResource implements HasResource
func (m *ResourceMixin) InjectResource(res *resource.Resource) {
if m.Resource == nil {
m.Resource = res
m.LoweredResourceKind = strings.ToLower(res.Kind)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ type {{ .Resource.Kind }}Spec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "make" to regenerate code after modifying this file
// Foo is an example field of {{ .Resource.Kind }}. Edit {{ .Resource.Kind }}_types.go to remove/update
// Foo is an example field of {{ .Resource.Kind }}. Edit {{ .LoweredResourceKind }}_types.go to remove/update
Foo string ` + "`" + `json:"foo,omitempty"` + "`" + `
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ type {{ .Resource.Kind }}Spec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "make" to regenerate code after modifying this file
// Foo is an example field of {{ .Resource.Kind }}. Edit {{ .Resource.Kind }}_types.go to remove/update
// Foo is an example field of {{ .Resource.Kind }}. Edit {{ .LoweredResourceKind }}_types.go to remove/update
Foo string ` + "`" + `json:"foo,omitempty"` + "`" + `
}
Expand Down

0 comments on commit aaba479

Please sign in to comment.