@@ -168,9 +168,11 @@ func (opts *Options) safeImport(unsafe string) string {
168
168
func (opts * Options ) NewV1Resource (c * config.Config , doResource bool ) * Resource {
169
169
res := opts .newResource ()
170
170
171
+ replacer := res .Replacer ()
172
+
171
173
// NOTE: while directories can have "-" and ".", v1 needs that directory to be a Go package
172
174
// and that is the reason why we remove them for the directory
173
- pkg := path .Join (c .Repo , "pkg" , "apis" , res . GroupPackageName , opts . Version )
175
+ pkg := replacer . Replace ( path .Join (c .Repo , "pkg" , "apis" , "%[group-package-name]" , "%[version]" ) )
174
176
domain := c .Domain
175
177
176
178
// pkg and domain may need to be changed in case we are referring to a builtin core resource:
@@ -180,11 +182,11 @@ func (opts *Options) NewV1Resource(c *config.Config, doResource bool) *Resource
180
182
// - In any other case, default to => project resource
181
183
// TODO: need to support '--resource-pkg-path' flag for specifying resourcePath
182
184
if ! doResource {
183
- file := filepath .Join ("pkg" , "apis" , res . GroupPackageName , opts . Version ,
184
- fmt . Sprintf ( "%s_types.go " , strings . ToLower ( opts . Kind ) ))
185
+ file := replacer . Replace ( filepath .Join (
186
+ "pkg" , "apis" , "%[group-package-name] " , "%[version]" , "%[kind]_types.go" ))
185
187
if _ , err := os .Stat (file ); os .IsNotExist (err ) {
186
188
if coreDomain , found := coreGroups [opts .Group ]; found {
187
- pkg = path .Join ("k8s.io" , "api" , opts . Group , opts . Version )
189
+ pkg = replacer . Replace ( path .Join ("k8s.io" , "api" , "%[group]" , "%[version]" ) )
188
190
domain = coreDomain
189
191
}
190
192
}
@@ -205,9 +207,11 @@ func (opts *Options) NewV1Resource(c *config.Config, doResource bool) *Resource
205
207
func (opts * Options ) NewResource (c * config.Config , doResource bool ) * Resource {
206
208
res := opts .newResource ()
207
209
208
- pkg := path .Join (c .Repo , "api" , opts .Version )
210
+ replacer := res .Replacer ()
211
+
212
+ pkg := replacer .Replace (path .Join (c .Repo , "api" , "%[version]" ))
209
213
if c .MultiGroup {
210
- pkg = path .Join (c .Repo , "apis" , res . Group , opts . Version )
214
+ pkg = replacer . Replace ( path .Join (c .Repo , "apis" , "%[group]" , "%[version]" ) )
211
215
}
212
216
domain := c .Domain
213
217
@@ -220,7 +224,7 @@ func (opts *Options) NewResource(c *config.Config, doResource bool) *Resource {
220
224
if ! doResource {
221
225
if ! c .HasResource (opts .GVK ()) {
222
226
if coreDomain , found := coreGroups [opts .Group ]; found {
223
- pkg = path .Join ("k8s.io" , "api" , opts . Group , opts . Version )
227
+ pkg = replacer . Replace ( path .Join ("k8s.io" , "api" , "%[group]" , "%[version]" ) )
224
228
domain = coreDomain
225
229
}
226
230
}
0 commit comments