Skip to content

Commit

Permalink
Add SingularNameProvider for Storage (#277)
Browse files Browse the repository at this point in the history
Signed-off-by: Rokibul Hasan <[email protected]>
  • Loading branch information
RokibulHasan7 authored Jan 4, 2024
1 parent f18d13f commit a9c8898
Show file tree
Hide file tree
Showing 28 changed files with 166 additions and 1 deletion.
6 changes: 6 additions & 0 deletions pkg/registry/auditor/siteinfo/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package SiteInfo

import (
"context"
"strings"
"time"

"github.com/google/uuid"
Expand Down Expand Up @@ -45,6 +46,7 @@ var (
_ rest.Scoper = &Storage{}
_ rest.Storage = &Storage{}
_ rest.Creater = &Storage{}
_ rest.SingularNameProvider = &Storage{}
)

func NewStorage(cfg *restclient.Config, c client.Client) (*Storage, error) {
Expand Down Expand Up @@ -77,6 +79,10 @@ func (r *Storage) NamespaceScoped() bool {
return false
}

func (r *Storage) GetSingularName() string {
return strings.ToLower(auditorv1alpha1.ResourceKindSiteInfo)
}

func (r *Storage) New() runtime.Object {
return &auditorv1alpha1.SiteInfo{}
}
Expand Down
6 changes: 6 additions & 0 deletions pkg/registry/core/genericresource/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package genericresource
import (
"context"
"sort"
"strings"

"kubeops.dev/ui-server/pkg/shared"

Expand Down Expand Up @@ -54,6 +55,7 @@ var (
_ rest.Storage = &Storage{}
_ rest.Getter = &Storage{}
_ rest.Lister = &Storage{}
_ rest.SingularNameProvider = &Storage{}
)

func NewStorage(kc client.Client, clusterID string, a authorizer.Authorizer) *Storage {
Expand All @@ -76,6 +78,10 @@ func (r *Storage) NamespaceScoped() bool {
return true
}

func (r *Storage) GetSingularName() string {
return strings.ToLower(rscoreapi.ResourceKindGenericResource)
}

func (r *Storage) New() runtime.Object {
return &rscoreapi.GenericResource{}
}
Expand Down
6 changes: 6 additions & 0 deletions pkg/registry/core/podview/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package podview
import (
"context"
"errors"
"strings"

core "k8s.io/api/core/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
Expand Down Expand Up @@ -52,6 +53,7 @@ var (
_ rest.Storage = &Storage{}
_ rest.Lister = &Storage{}
_ rest.Getter = &Storage{}
_ rest.SingularNameProvider = &Storage{}
)

func NewStorage(kc client.Client, a authorizer.Authorizer, builder *promclient.ClientBuilder) *Storage {
Expand Down Expand Up @@ -79,6 +81,10 @@ func (r *Storage) NamespaceScoped() bool {
return true
}

func (r *Storage) GetSingularName() string {
return strings.ToLower(rscoreapi.ResourceKindPodView)
}

func (r *Storage) New() runtime.Object {
return &rscoreapi.PodView{}
}
Expand Down
5 changes: 5 additions & 0 deletions pkg/registry/core/project/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ var (
_ rest.Storage = &Storage{}
_ rest.Lister = &Storage{}
_ rest.Getter = &Storage{}
_ rest.SingularNameProvider = &Storage{}

gr = schema.GroupResource{
Group: rscoreapi.SchemeGroupVersion.Group,
Expand All @@ -77,6 +78,10 @@ func (r *Storage) NamespaceScoped() bool {
return false
}

func (r *Storage) GetSingularName() string {
return strings.ToLower(rscoreapi.ResourceKindProject)
}

func (r *Storage) New() runtime.Object {
return &rscoreapi.Project{}
}
Expand Down
5 changes: 5 additions & 0 deletions pkg/registry/core/resourceservice/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ var (
_ rest.Storage = &Storage{}
_ rest.Getter = &Storage{}
_ rest.Lister = &Storage{}
_ rest.SingularNameProvider = &Storage{}
)

func NewStorage(kc client.Client, clusterID string, a authorizer.Authorizer) *Storage {
Expand All @@ -88,6 +89,10 @@ func (r *Storage) NamespaceScoped() bool {
return true
}

func (r *Storage) GetSingularName() string {
return strings.ToLower(rscoreapi.ResourceKindGenericResourceService)
}

func (r *Storage) New() runtime.Object {
return &rscoreapi.GenericResourceService{}
}
Expand Down
6 changes: 6 additions & 0 deletions pkg/registry/core/resourcesummary/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package ResourceSummary
import (
"context"
"sort"
"strings"
"time"

"kubeops.dev/ui-server/pkg/shared"
Expand Down Expand Up @@ -55,6 +56,7 @@ var (
_ rest.Scoper = &Storage{}
_ rest.Storage = &Storage{}
_ rest.Lister = &Storage{}
_ rest.SingularNameProvider = &Storage{}
)

func NewStorage(kc client.Client, clusterID string, a authorizer.Authorizer) *Storage {
Expand All @@ -77,6 +79,10 @@ func (r *Storage) NamespaceScoped() bool {
return true
}

func (r *Storage) GetSingularName() string {
return strings.ToLower(rscoreapi.ResourceKindResourceSummary)
}

func (r *Storage) New() runtime.Object {
return &rscoreapi.ResourceSummary{}
}
Expand Down
6 changes: 6 additions & 0 deletions pkg/registry/cost/reports/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"io"
"net/http"
"net/url"
"strings"

costapi "kubeops.dev/ui-server/apis/cost/v1alpha1"

Expand Down Expand Up @@ -51,6 +52,7 @@ var (
_ rest.Scoper = &Storage{}
_ rest.Storage = &Storage{}
_ rest.Creater = &Storage{}
_ rest.SingularNameProvider = &Storage{}
)

func NewStorage(kc client.Client) *Storage {
Expand All @@ -67,6 +69,10 @@ func (r *Storage) NamespaceScoped() bool {
return false
}

func (r *Storage) GetSingularName() string {
return strings.ToLower(costapi.ResourceKindCostReport)
}

func (r *Storage) New() runtime.Object {
return &costapi.CostReport{}
}
Expand Down
6 changes: 6 additions & 0 deletions pkg/registry/identity/whoami/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package whoami

import (
"context"
"strings"

identityv1alpha1 "kubeops.dev/ui-server/apis/identity/v1alpha1"

Expand All @@ -36,6 +37,7 @@ var (
_ rest.Scoper = &Storage{}
_ rest.Storage = &Storage{}
_ rest.Creater = &Storage{}
_ rest.SingularNameProvider = &Storage{}
)

func NewStorage() *Storage {
Expand All @@ -50,6 +52,10 @@ func (r *Storage) NamespaceScoped() bool {
return false
}

func (r *Storage) GetSingularName() string {
return strings.ToLower(identityv1alpha1.ResourceKindWhoAmI)
}

func (r *Storage) New() runtime.Object {
return &identityv1alpha1.WhoAmI{}
}
Expand Down
6 changes: 6 additions & 0 deletions pkg/registry/meta/chartpresetquery/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package chartpresetquery

import (
"context"
"strings"

apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand All @@ -39,6 +40,7 @@ var (
_ rest.Scoper = &Storage{}
_ rest.Storage = &Storage{}
_ rest.Creater = &Storage{}
_ rest.SingularNameProvider = &Storage{}
)

func NewStorage(kc client.Client) *Storage {
Expand All @@ -55,6 +57,10 @@ func (r *Storage) NamespaceScoped() bool {
return false
}

func (r *Storage) GetSingularName() string {
return strings.ToLower(rsapi.ResourceKindChartPresetQuery)
}

func (r *Storage) New() runtime.Object {
return &rsapi.ChartPresetQuery{}
}
Expand Down
6 changes: 6 additions & 0 deletions pkg/registry/meta/clusterstatus/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package clusterstatus

import (
"context"
"strings"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
Expand All @@ -37,6 +38,7 @@ var (
_ rest.Scoper = &Storage{}
_ rest.Storage = &Storage{}
_ rest.Creater = &Storage{}
_ rest.SingularNameProvider = &Storage{}
)

func NewStorage(kc client.Client) *Storage {
Expand All @@ -57,6 +59,10 @@ func (r *Storage) NamespaceScoped() bool {
return false
}

func (r *Storage) GetSingularName() string {
return strings.ToLower(rsapi.ResourceKindClusterStatus)
}

func (r *Storage) New() runtime.Object {
return &rsapi.ClusterStatus{}
}
Expand Down
6 changes: 6 additions & 0 deletions pkg/registry/meta/render/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package render

import (
"context"
"strings"

"kubeops.dev/ui-server/pkg/graph"

Expand Down Expand Up @@ -47,6 +48,7 @@ var (
_ rest.Scoper = &Storage{}
_ rest.Storage = &Storage{}
_ rest.Creater = &Storage{}
_ rest.SingularNameProvider = &Storage{}
)

func NewStorage(kc client.Client, oc openvizcs.Interface, a authorizer.Authorizer) *Storage {
Expand All @@ -65,6 +67,10 @@ func (r *Storage) NamespaceScoped() bool {
return false
}

func (r *Storage) GetSingularName() string {
return strings.ToLower(rsapi.ResourceKindRender)
}

func (r *Storage) New() runtime.Object {
return &rsapi.Render{}
}
Expand Down
6 changes: 6 additions & 0 deletions pkg/registry/meta/renderdashboard/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package renderdashboard
import (
"context"
"fmt"
"strings"

"kubeops.dev/ui-server/pkg/graph"

Expand Down Expand Up @@ -46,6 +47,7 @@ var (
_ rest.Scoper = &Storage{}
_ rest.Storage = &Storage{}
_ rest.Creater = &Storage{}
_ rest.SingularNameProvider = &Storage{}
)

func NewStorage(kc client.Client, oc openvizcs.Interface) *Storage {
Expand All @@ -63,6 +65,10 @@ func (r *Storage) NamespaceScoped() bool {
return false
}

func (r *Storage) GetSingularName() string {
return strings.ToLower(rsapi.ResourceKindRenderDashboard)
}

func (r *Storage) New() runtime.Object {
return &rsapi.RenderDashboard{}
}
Expand Down
6 changes: 6 additions & 0 deletions pkg/registry/meta/rendermenu/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package rendermenu

import (
"context"
"strings"

"kubeops.dev/ui-server/pkg/menu"

Expand All @@ -43,6 +44,7 @@ var (
_ rest.Scoper = &Storage{}
_ rest.Storage = &Storage{}
_ rest.Creater = &Storage{}
_ rest.SingularNameProvider = &Storage{}
)

func NewStorage(kc client.Client, disco discovery.ServerResourcesInterface, ns string) *Storage {
Expand All @@ -61,6 +63,10 @@ func (r *Storage) NamespaceScoped() bool {
return false
}

func (r *Storage) GetSingularName() string {
return strings.ToLower(rsapi.ResourceKindRenderMenu)
}

func (r *Storage) New() runtime.Object {
return &rsapi.RenderMenu{}
}
Expand Down
6 changes: 6 additions & 0 deletions pkg/registry/meta/renderrawgraph/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package renderrawgraph

import (
"context"
"strings"

"kubeops.dev/ui-server/pkg/graph"

Expand All @@ -40,6 +41,7 @@ var (
_ rest.Scoper = &Storage{}
_ rest.Storage = &Storage{}
_ rest.Creater = &Storage{}
_ rest.SingularNameProvider = &Storage{}
)

func NewStorage(kc client.Client) *Storage {
Expand All @@ -56,6 +58,10 @@ func (r *Storage) NamespaceScoped() bool {
return false
}

func (r *Storage) GetSingularName() string {
return strings.ToLower(rsapi.ResourceKindRenderRawGraph)
}

func (r *Storage) New() runtime.Object {
return &rsapi.RenderRawGraph{}
}
Expand Down
6 changes: 6 additions & 0 deletions pkg/registry/meta/resourceblockdefinition/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"context"
"fmt"
"strconv"
"strings"

kerr "k8s.io/apimachinery/pkg/api/errors"
metainternalversion "k8s.io/apimachinery/pkg/apis/meta/internalversion"
Expand All @@ -43,6 +44,7 @@ var (
_ rest.Storage = &Storage{}
_ rest.Getter = &Storage{}
_ rest.Lister = &Storage{}
_ rest.SingularNameProvider = &Storage{}
)

func NewStorage() *Storage {
Expand All @@ -62,6 +64,10 @@ func (r *Storage) NamespaceScoped() bool {
return false
}

func (r *Storage) GetSingularName() string {
return strings.ToLower(rsapi.ResourceKindResourceBlockDefinition)
}

// Getter
func (r *Storage) New() runtime.Object {
return &rsapi.ResourceBlockDefinition{}
Expand Down
Loading

0 comments on commit a9c8898

Please sign in to comment.