Skip to content

Commit 68c11e4

Browse files
committed
Return correct plural type for collections
Rancher Desktop and other projects were relying on the collection type to be plural: k3s-io/k3s#11447 Ref: * 4e582e2 * rancher/apiserver@1045731 Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
1 parent 12fab56 commit 68c11e4

4 files changed

Lines changed: 13 additions & 10 deletions

File tree

pkg/server/server.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ import (
1414
"github.com/rancher/apiserver/pkg/types"
1515
"github.com/rancher/channelserver/pkg/config"
1616
"github.com/rancher/channelserver/pkg/model"
17-
"github.com/rancher/channelserver/pkg/server/store"
1817
"github.com/rancher/channelserver/pkg/server/store/appdefault"
18+
"github.com/rancher/channelserver/pkg/server/store/channel"
1919
"github.com/rancher/channelserver/pkg/server/store/release"
2020
)
2121

@@ -39,7 +39,7 @@ func NewHandler(configs map[string]*config.Config) http.Handler {
3939
for prefix, config := range configs {
4040
server := server.DefaultAPIServer()
4141
server.Schemas.MustImportAndCustomize(model.Channel{}, func(schema *types.APISchema) {
42-
schema.Store = store.New(config)
42+
schema.Store = channel.New(config)
4343
schema.CollectionMethods = []string{http.MethodGet}
4444
schema.ResourceMethods = []string{http.MethodGet}
4545
})

pkg/server/store/appdefault/store.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ func New(config *config.Config) *Store {
1717
}
1818
}
1919

20-
func (c *Store) List(_ *types.APIRequest, _ *types.APISchema) (types.APIObjectList, error) {
20+
func (c *Store) List(req *types.APIRequest, _ *types.APISchema) (types.APIObjectList, error) {
21+
req.Type = "appdefaults"
2122
resp := types.APIObjectList{}
2223
for _, appDefault := range c.config.AppDefaultsConfig().AppDefaults {
2324
resp.Objects = append(resp.Objects, types.APIObject{
Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package store
1+
package channel
22

33
import (
44
"net/http"
@@ -9,18 +9,19 @@ import (
99
"github.com/rancher/wrangler/v3/pkg/schemas/validation"
1010
)
1111

12-
type ChannelStore struct {
12+
type Channel struct {
1313
empty.Store
1414
config *config.Config
1515
}
1616

17-
func New(config *config.Config) *ChannelStore {
18-
return &ChannelStore{
17+
func New(config *config.Config) *Channel {
18+
return &Channel{
1919
config: config,
2020
}
2121
}
2222

23-
func (c *ChannelStore) List(_ *types.APIRequest, _ *types.APISchema) (types.APIObjectList, error) {
23+
func (c *Channel) List(req *types.APIRequest, _ *types.APISchema) (types.APIObjectList, error) {
24+
req.Type = "channels"
2425
resp := types.APIObjectList{}
2526
for _, channel := range c.config.ChannelsConfig().Channels {
2627
resp.Objects = append(resp.Objects, types.APIObject{
@@ -32,7 +33,7 @@ func (c *ChannelStore) List(_ *types.APIRequest, _ *types.APISchema) (types.APIO
3233
return resp, nil
3334
}
3435

35-
func (c *ChannelStore) ByID(apiOp *types.APIRequest, schema *types.APISchema, id string) (types.APIObject, error) {
36+
func (c *Channel) ByID(apiOp *types.APIRequest, schema *types.APISchema, id string) (types.APIObject, error) {
3637
redirect, err := c.config.Redirect(id)
3738
if err != nil {
3839
return types.APIObject{}, nil

pkg/server/store/release/store.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ func New(config *config.Config) *Store {
1717
}
1818
}
1919

20-
func (c *Store) List(_ *types.APIRequest, _ *types.APISchema) (types.APIObjectList, error) {
20+
func (c *Store) List(req *types.APIRequest, _ *types.APISchema) (types.APIObjectList, error) {
21+
req.Type = "releases"
2122
resp := types.APIObjectList{}
2223
for _, release := range c.config.ReleasesConfig().Releases {
2324
resp.Objects = append(resp.Objects, types.APIObject{

0 commit comments

Comments
 (0)