@@ -100,6 +100,9 @@ type apiDefinition struct {
100
100
// MainPackage is an override for API definitions that involves more
101
101
// than one package.
102
102
MainPackage string `json:"mainPackage"`
103
+
104
+ // Resource types manually specified
105
+ Resources []string `json:"resources"`
103
106
}
104
107
105
108
// Global vars
@@ -138,7 +141,7 @@ func init() {
138
141
}
139
142
140
143
// processAPIPath processes a path for package enumeration and processing.
141
- func processAPIPath (path string , includes []string , title string , mainPkg string ) ([]* apiPackage , error ) {
144
+ func processAPIPath (path string , includes []string , title string , mainPkg string , resources [] string ) ([]* apiPackage , error ) {
142
145
klog .V (0 ).Infof ("Parsing go packages in %s" , path )
143
146
gopkgs , err := parseAPIPackages (path )
144
147
if err != nil {
@@ -156,7 +159,7 @@ func processAPIPath(path string, includes []string, title string, mainPkg string
156
159
gopkgs = append (gopkgs , extra ... )
157
160
}
158
161
159
- pkgs , err := combineAPIPackages (gopkgs , title , mainPkg )
162
+ pkgs , err := combineAPIPackages (gopkgs , title , mainPkg , resources )
160
163
if err != nil {
161
164
return nil , err
162
165
}
@@ -217,7 +220,7 @@ func parseAPIPackages(dir string) ([]*types.Package, error) {
217
220
218
221
// combineAPIPackages groups the Go packages by the <apiGroup+apiVersion> they
219
222
// offer, and combines the types in them.
220
- func combineAPIPackages (pkgs []* types.Package , title string , mainPkg string ) ([]* apiPackage , error ) {
223
+ func combineAPIPackages (pkgs []* types.Package , title string , mainPkg string , resources [] string ) ([]* apiPackage , error ) {
221
224
pkgMap := make (map [string ]* apiPackage )
222
225
re := `^v\d+((alpha|beta)\d+)?$`
223
226
@@ -242,13 +245,15 @@ func combineAPIPackages(pkgs []*types.Package, title string, mainPkg string) ([]
242
245
if len (mainPkg ) > 0 && group != mainPkg {
243
246
isMain = false
244
247
}
248
+
245
249
pkgMap [id ] = & apiPackage {
246
250
apiGroup : group ,
247
251
apiVersion : version ,
248
252
Types : typeList ,
249
253
GoPackages : []* types.Package {gopkg },
250
254
Title : title ,
251
255
IsMain : isMain ,
256
+ Resources : resources ,
252
257
}
253
258
} else {
254
259
v .Types = append (v .Types , typeList ... )
@@ -359,7 +364,7 @@ func main() {
359
364
if len (pkgInclude ) > 0 && ! containsString (pkgInclude , item .Name ) {
360
365
continue
361
366
}
362
- pkgs , err := processAPIPath (apiDir , item .Includes , item .Title , item .MainPackage )
367
+ pkgs , err := processAPIPath (apiDir , item .Includes , item .Title , item .MainPackage , item . Resources )
363
368
if err != nil {
364
369
klog .ErrorS (err , "cannot process API path" )
365
370
continue
0 commit comments