allow exceptions to be specified to handle conflicting group and resourc enames

pull/6/head
deads2k 2017-07-19 15:01:24 -04:00 committed by Marek Grabowski
parent 9d1e082105
commit 2a724dfc9c
1 changed files with 30 additions and 4 deletions

View File

@ -47,7 +47,7 @@ func NameSystems() namer.NameSystems {
// these exceptions are used to deconflict the generated code
// you can put your fully qualified package like
// to generate a name that doesn't conflict with your group.
// "k8s.io/apis/events/v1alpha1.Event": "EventResource"
// "k8s.io/apis/events/v1beta1.Event": "EventResource"
},
KeyFunc: func(t *types.Type) string {
return t.Name.Package + "." + t.Name.Name
@ -59,21 +59,47 @@ func NameSystems() namer.NameSystems {
// these exceptions are used to deconflict the generated code
// you can put your fully qualified package like
// to generate a name that doesn't conflict with your group.
// "k8s.io/apis/events/v1alpha1.Event": "eventResource"
// "k8s.io/apis/events/v1beta1.Event": "eventResource"
},
KeyFunc: func(t *types.Type) string {
return t.Name.Package + "." + t.Name.Name
},
Delegate: namer.NewPrivateNamer(0),
}
publicPluralNamer := &ExceptionNamer{
Exceptions: map[string]string{
// these exceptions are used to deconflict the generated code
// you can put your fully qualified package like
// to generate a name that doesn't conflict with your group.
// "k8s.io/apis/events/v1beta1.Event": "EventResource"
},
KeyFunc: func(t *types.Type) string {
return t.Name.Package + "." + t.Name.Name
},
Delegate: namer.NewPublicPluralNamer(pluralExceptions),
}
privatePluralNamer := &ExceptionNamer{
Exceptions: map[string]string{
// you can put your fully qualified package like
// to generate a name that doesn't conflict with your group.
// "k8s.io/apis/events/v1beta1.Event": "eventResource"
// these exceptions are used to deconflict the generated code
"k8s.io/apis/events/v1beta1.Event": "eventResources",
"k8s.io/kubernetes/pkg/apis/events.Event": "eventResources",
},
KeyFunc: func(t *types.Type) string {
return t.Name.Package + "." + t.Name.Name
},
Delegate: namer.NewPrivatePluralNamer(pluralExceptions),
}
return namer.NameSystems{
"singularKind": namer.NewPublicNamer(0),
"public": publicNamer,
"private": privateNamer,
"raw": namer.NewRawNamer("", nil),
"publicPlural": namer.NewPublicPluralNamer(pluralExceptions),
"privatePlural": namer.NewPrivatePluralNamer(pluralExceptions),
"publicPlural": publicPluralNamer,
"privatePlural": privatePluralNamer,
"allLowercasePlural": lowercaseNamer,
"resource": NewTagOverrideNamer("resourceName", lowercaseNamer),
}