Skip to content

Commit

Permalink
Allow GET and LIST requests for custom resources (#145)
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
wedaly authored Jan 27, 2025
1 parent b839e02 commit a22803d
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions request/random.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,15 +156,11 @@ func newRequestGetBuilder(src *types.RequestGet, resourceVersion string, maxRetr
// Build implements RequestBuilder.Build.
func (b *requestGetBuilder) Build(cli rest.Interface) (string, *rest.Request) {
// https://kubernetes.io/docs/reference/using-api/#api-groups
apiPath := "apis"
comps := make([]string, 0, 5)
if b.version.Group == "" {
apiPath = "api"
}

comps := make([]string, 2, 5)
comps[0], comps[1] = apiPath, b.version.Version
if b.namespace != "" {
comps = append(comps, "namespaces", b.namespace)
comps = append(comps, "api", b.version.Version)
} else {
comps = append(comps, "apis", b.version.Group, b.version.Version)
}
comps = append(comps, b.resource, b.name)

Expand Down Expand Up @@ -206,13 +202,12 @@ func newRequestListBuilder(src *types.RequestList, resourceVersion string, maxRe
// Build implements RequestBuilder.Build.
func (b *requestListBuilder) Build(cli rest.Interface) (string, *rest.Request) {
// https://kubernetes.io/docs/reference/using-api/#api-groups
apiPath := "apis"
comps := make([]string, 0, 5)
if b.version.Group == "" {
apiPath = "api"
comps = append(comps, "api", b.version.Version)
} else {
comps = append(comps, "apis", b.version.Group, b.version.Version)
}

comps := make([]string, 2, 5)
comps[0], comps[1] = apiPath, b.version.Version
if b.namespace != "" {
comps = append(comps, "namespaces", b.namespace)
}
Expand Down

0 comments on commit a22803d

Please sign in to comment.