Skip to content

Commit a22803d

Browse files
authored
Allow GET and LIST requests for custom resources (#145)
Include "group" in the request URL to allow querying custom resources. Before: /apis/v2/ciliumendpoints After: /apis/cilium.io/v2/ciliumendpoints Signed-off-by: Will Daly <widaly@microsoft.com>
1 parent b839e02 commit a22803d

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

request/random.go

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -156,15 +156,11 @@ func newRequestGetBuilder(src *types.RequestGet, resourceVersion string, maxRetr
156156
// Build implements RequestBuilder.Build.
157157
func (b *requestGetBuilder) Build(cli rest.Interface) (string, *rest.Request) {
158158
// https://kubernetes.io/docs/reference/using-api/#api-groups
159-
apiPath := "apis"
159+
comps := make([]string, 0, 5)
160160
if b.version.Group == "" {
161-
apiPath = "api"
162-
}
163-
164-
comps := make([]string, 2, 5)
165-
comps[0], comps[1] = apiPath, b.version.Version
166-
if b.namespace != "" {
167-
comps = append(comps, "namespaces", b.namespace)
161+
comps = append(comps, "api", b.version.Version)
162+
} else {
163+
comps = append(comps, "apis", b.version.Group, b.version.Version)
168164
}
169165
comps = append(comps, b.resource, b.name)
170166

@@ -206,13 +202,12 @@ func newRequestListBuilder(src *types.RequestList, resourceVersion string, maxRe
206202
// Build implements RequestBuilder.Build.
207203
func (b *requestListBuilder) Build(cli rest.Interface) (string, *rest.Request) {
208204
// https://kubernetes.io/docs/reference/using-api/#api-groups
209-
apiPath := "apis"
205+
comps := make([]string, 0, 5)
210206
if b.version.Group == "" {
211-
apiPath = "api"
207+
comps = append(comps, "api", b.version.Version)
208+
} else {
209+
comps = append(comps, "apis", b.version.Group, b.version.Version)
212210
}
213-
214-
comps := make([]string, 2, 5)
215-
comps[0], comps[1] = apiPath, b.version.Version
216211
if b.namespace != "" {
217212
comps = append(comps, "namespaces", b.namespace)
218213
}

0 commit comments

Comments
 (0)