Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix collection resources order #203

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions pkg/storage/internalstorage/collectionresource.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ const (
CollectionResourceKubeResources = "kuberesources"
)

var collectionResources = map[string]internal.CollectionResource{
CollectionResourceWorkloads: {
var collectionResources = []internal.CollectionResource{
{
ObjectMeta: metav1.ObjectMeta{
Name: CollectionResourceWorkloads,
},
Expand All @@ -33,8 +33,7 @@ var collectionResources = map[string]internal.CollectionResource{
},
},
},

CollectionResourceKubeResources: {
{
ObjectMeta: metav1.ObjectMeta{
Name: CollectionResourceKubeResources,
},
Expand All @@ -54,10 +53,9 @@ func init() {
})
}

collectionResources[CollectionResourceKubeResources] = internal.CollectionResource{
ObjectMeta: metav1.ObjectMeta{
Name: CollectionResourceKubeResources,
},
ResourceTypes: types,
for i := range collectionResources {
if collectionResources[i].Name == CollectionResourceKubeResources {
collectionResources[i].ResourceTypes = types
}
}
}
8 changes: 5 additions & 3 deletions pkg/storage/internalstorage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@ func (s *StorageFactory) NewResourceStorage(config *storage.ResourceStorageConfi
}

func (s *StorageFactory) NewCollectionResourceStorage(cr *internal.CollectionResource) (storage.CollectionResourceStorage, error) {
if _, ok := collectionResources[cr.Name]; !ok {
return nil, fmt.Errorf("not support collection resource: %s", cr.Name)
for i := range collectionResources {
if collectionResources[i].Name == cr.Name {
return NewCollectionResourceStorage(s.db, cr), nil
}
}
return NewCollectionResourceStorage(s.db, cr), nil
return nil, fmt.Errorf("not support collection resource: %s", cr.Name)
}

func (f *StorageFactory) GetResourceVersions(ctx context.Context, cluster string) (map[schema.GroupVersionResource]map[string]interface{}, error) {
Expand Down