update kind names

This commit is contained in:
Dafydd
2025-12-02 13:44:31 +00:00
parent 8a5b6804dd
commit fcf1a47222
19 changed files with 445 additions and 303 deletions
+10 -10
View File
@@ -1,35 +1,35 @@
package preferences
datasourcestacksV1alpha1: {
kind: "Datasources"
pluralName: "Datasource"
kind: "DataSourceStack"
pluralName: "DataSourceStacks"
scope: "Namespaced"
schema: {
spec: {
template: TemplateSpec
modes: [...Mode]
modes: [...ModeSpec]
}
}
}
TemplateSpec: {
[string]: DataSourceTemplateSpec
[string]: DataSourceStackTemplateItem
}
DataSourceTemplateSpec: {
DataSourceStackTemplateItem: {
group: string // type
name: string // variable name / display name
}
Mode: {
ModeSpec: {
name: string
uid: string
definition: ModeSpec
definition: Mode
}
ModeSpec: [string]: DataSourceRef
Mode: [string]: ModeItem
DataSourceRef: {
name: string // grafana data source uid
ModeItem: {
dataSourceRef: string // grafana data source uid
}
@@ -1,80 +0,0 @@
package v1alpha1
import (
"context"
"github.com/grafana/grafana-app-sdk/resource"
)
type DatasourcesClient struct {
client *resource.TypedClient[*Datasources, *DatasourcesList]
}
func NewDatasourcesClient(client resource.Client) *DatasourcesClient {
return &DatasourcesClient{
client: resource.NewTypedClient[*Datasources, *DatasourcesList](client, DatasourcesKind()),
}
}
func NewDatasourcesClientFromGenerator(generator resource.ClientGenerator) (*DatasourcesClient, error) {
c, err := generator.ClientFor(DatasourcesKind())
if err != nil {
return nil, err
}
return NewDatasourcesClient(c), nil
}
func (c *DatasourcesClient) Get(ctx context.Context, identifier resource.Identifier) (*Datasources, error) {
return c.client.Get(ctx, identifier)
}
func (c *DatasourcesClient) List(ctx context.Context, namespace string, opts resource.ListOptions) (*DatasourcesList, error) {
return c.client.List(ctx, namespace, opts)
}
func (c *DatasourcesClient) ListAll(ctx context.Context, namespace string, opts resource.ListOptions) (*DatasourcesList, error) {
resp, err := c.client.List(ctx, namespace, resource.ListOptions{
ResourceVersion: opts.ResourceVersion,
Limit: opts.Limit,
LabelFilters: opts.LabelFilters,
FieldSelectors: opts.FieldSelectors,
})
if err != nil {
return nil, err
}
for resp.GetContinue() != "" {
page, err := c.client.List(ctx, namespace, resource.ListOptions{
Continue: resp.GetContinue(),
ResourceVersion: opts.ResourceVersion,
Limit: opts.Limit,
LabelFilters: opts.LabelFilters,
FieldSelectors: opts.FieldSelectors,
})
if err != nil {
return nil, err
}
resp.SetContinue(page.GetContinue())
resp.SetResourceVersion(page.GetResourceVersion())
resp.SetItems(append(resp.GetItems(), page.GetItems()...))
}
return resp, nil
}
func (c *DatasourcesClient) Create(ctx context.Context, obj *Datasources, opts resource.CreateOptions) (*Datasources, error) {
// Make sure apiVersion and kind are set
obj.APIVersion = GroupVersion.Identifier()
obj.Kind = DatasourcesKind().Kind()
return c.client.Create(ctx, obj, opts)
}
func (c *DatasourcesClient) Update(ctx context.Context, obj *Datasources, opts resource.UpdateOptions) (*Datasources, error) {
return c.client.Update(ctx, obj, opts)
}
func (c *DatasourcesClient) Patch(ctx context.Context, identifier resource.Identifier, req resource.PatchRequest, opts resource.PatchOptions) (*Datasources, error) {
return c.client.Patch(ctx, identifier, req, opts)
}
func (c *DatasourcesClient) Delete(ctx context.Context, identifier resource.Identifier, opts resource.DeleteOptions) error {
return c.client.Delete(ctx, identifier, opts)
}
@@ -1,34 +0,0 @@
//
// Code generated by grafana-app-sdk. DO NOT EDIT.
//
package v1alpha1
import (
"github.com/grafana/grafana-app-sdk/resource"
)
// schema is unexported to prevent accidental overwrites
var (
schemaDatasources = resource.NewSimpleSchema("collections.grafana.app", "v1alpha1", &Datasources{}, &DatasourcesList{}, resource.WithKind("Datasources"),
resource.WithPlural("datasource"), resource.WithScope(resource.NamespacedScope))
kindDatasources = resource.Kind{
Schema: schemaDatasources,
Codecs: map[resource.KindEncoding]resource.Codec{
resource.KindEncodingJSON: &DatasourcesJSONCodec{},
},
}
)
// Kind returns a resource.Kind for this Schema with a JSON codec
func DatasourcesKind() resource.Kind {
return kindDatasources
}
// Schema returns a resource.SimpleSchema representation of Datasources
func DatasourcesSchema() *resource.SimpleSchema {
return schemaDatasources
}
// Interface compliance checks
var _ resource.Schema = kindDatasources
@@ -1,58 +0,0 @@
// Code generated - EDITING IS FUTILE. DO NOT EDIT.
package v1alpha1
// +k8s:openapi-gen=true
type DatasourcesTemplateSpec map[string]DatasourcesDataSourceTemplateSpec
// +k8s:openapi-gen=true
type DatasourcesDataSourceTemplateSpec struct {
// type
Group string `json:"group"`
// variable name / display name
Name string `json:"name"`
}
// NewDatasourcesDataSourceTemplateSpec creates a new DatasourcesDataSourceTemplateSpec object.
func NewDatasourcesDataSourceTemplateSpec() *DatasourcesDataSourceTemplateSpec {
return &DatasourcesDataSourceTemplateSpec{}
}
// +k8s:openapi-gen=true
type DatasourcesMode struct {
Name string `json:"name"`
Uid string `json:"uid"`
Definition DatasourcesModeSpec `json:"definition"`
}
// NewDatasourcesMode creates a new DatasourcesMode object.
func NewDatasourcesMode() *DatasourcesMode {
return &DatasourcesMode{}
}
// +k8s:openapi-gen=true
type DatasourcesModeSpec map[string]DatasourcesDataSourceRef
// +k8s:openapi-gen=true
type DatasourcesDataSourceRef struct {
// grafana data source uid
Name string `json:"name"`
}
// NewDatasourcesDataSourceRef creates a new DatasourcesDataSourceRef object.
func NewDatasourcesDataSourceRef() *DatasourcesDataSourceRef {
return &DatasourcesDataSourceRef{}
}
// +k8s:openapi-gen=true
type DatasourcesSpec struct {
Template DatasourcesTemplateSpec `json:"template"`
Modes []DatasourcesMode `json:"modes"`
}
// NewDatasourcesSpec creates a new DatasourcesSpec object.
func NewDatasourcesSpec() *DatasourcesSpec {
return &DatasourcesSpec{
Modes: []DatasourcesMode{},
}
}
@@ -0,0 +1,80 @@
package v1alpha1
import (
"context"
"github.com/grafana/grafana-app-sdk/resource"
)
type DataSourceStackClient struct {
client *resource.TypedClient[*DataSourceStack, *DataSourceStackList]
}
func NewDataSourceStackClient(client resource.Client) *DataSourceStackClient {
return &DataSourceStackClient{
client: resource.NewTypedClient[*DataSourceStack, *DataSourceStackList](client, DataSourceStackKind()),
}
}
func NewDataSourceStackClientFromGenerator(generator resource.ClientGenerator) (*DataSourceStackClient, error) {
c, err := generator.ClientFor(DataSourceStackKind())
if err != nil {
return nil, err
}
return NewDataSourceStackClient(c), nil
}
func (c *DataSourceStackClient) Get(ctx context.Context, identifier resource.Identifier) (*DataSourceStack, error) {
return c.client.Get(ctx, identifier)
}
func (c *DataSourceStackClient) List(ctx context.Context, namespace string, opts resource.ListOptions) (*DataSourceStackList, error) {
return c.client.List(ctx, namespace, opts)
}
func (c *DataSourceStackClient) ListAll(ctx context.Context, namespace string, opts resource.ListOptions) (*DataSourceStackList, error) {
resp, err := c.client.List(ctx, namespace, resource.ListOptions{
ResourceVersion: opts.ResourceVersion,
Limit: opts.Limit,
LabelFilters: opts.LabelFilters,
FieldSelectors: opts.FieldSelectors,
})
if err != nil {
return nil, err
}
for resp.GetContinue() != "" {
page, err := c.client.List(ctx, namespace, resource.ListOptions{
Continue: resp.GetContinue(),
ResourceVersion: opts.ResourceVersion,
Limit: opts.Limit,
LabelFilters: opts.LabelFilters,
FieldSelectors: opts.FieldSelectors,
})
if err != nil {
return nil, err
}
resp.SetContinue(page.GetContinue())
resp.SetResourceVersion(page.GetResourceVersion())
resp.SetItems(append(resp.GetItems(), page.GetItems()...))
}
return resp, nil
}
func (c *DataSourceStackClient) Create(ctx context.Context, obj *DataSourceStack, opts resource.CreateOptions) (*DataSourceStack, error) {
// Make sure apiVersion and kind are set
obj.APIVersion = GroupVersion.Identifier()
obj.Kind = DataSourceStackKind().Kind()
return c.client.Create(ctx, obj, opts)
}
func (c *DataSourceStackClient) Update(ctx context.Context, obj *DataSourceStack, opts resource.UpdateOptions) (*DataSourceStack, error) {
return c.client.Update(ctx, obj, opts)
}
func (c *DataSourceStackClient) Patch(ctx context.Context, identifier resource.Identifier, req resource.PatchRequest, opts resource.PatchOptions) (*DataSourceStack, error) {
return c.client.Patch(ctx, identifier, req, opts)
}
func (c *DataSourceStackClient) Delete(ctx context.Context, identifier resource.Identifier, opts resource.DeleteOptions) error {
return c.client.Delete(ctx, identifier, opts)
}
@@ -11,18 +11,18 @@ import (
"github.com/grafana/grafana-app-sdk/resource"
)
// DatasourcesJSONCodec is an implementation of resource.Codec for kubernetes JSON encoding
type DatasourcesJSONCodec struct{}
// DataSourceStackJSONCodec is an implementation of resource.Codec for kubernetes JSON encoding
type DataSourceStackJSONCodec struct{}
// Read reads JSON-encoded bytes from `reader` and unmarshals them into `into`
func (*DatasourcesJSONCodec) Read(reader io.Reader, into resource.Object) error {
func (*DataSourceStackJSONCodec) Read(reader io.Reader, into resource.Object) error {
return json.NewDecoder(reader).Decode(into)
}
// Write writes JSON-encoded bytes into `writer` marshaled from `from`
func (*DatasourcesJSONCodec) Write(writer io.Writer, from resource.Object) error {
func (*DataSourceStackJSONCodec) Write(writer io.Writer, from resource.Object) error {
return json.NewEncoder(writer).Encode(from)
}
// Interface compliance checks
var _ resource.Codec = &DatasourcesJSONCodec{}
var _ resource.Codec = &DataSourceStackJSONCodec{}
@@ -9,7 +9,7 @@ import (
// metadata contains embedded CommonMetadata and can be extended with custom string fields
// TODO: use CommonMetadata instead of redefining here; currently needs to be defined here
// without external reference as using the CommonMetadata reference breaks thema codegen.
type DatasourcesMetadata struct {
type DataSourceStackMetadata struct {
UpdateTimestamp time.Time `json:"updateTimestamp"`
CreatedBy string `json:"createdBy"`
Uid string `json:"uid"`
@@ -22,9 +22,9 @@ type DatasourcesMetadata struct {
Labels map[string]string `json:"labels"`
}
// NewDatasourcesMetadata creates a new DatasourcesMetadata object.
func NewDatasourcesMetadata() *DatasourcesMetadata {
return &DatasourcesMetadata{
// NewDataSourceStackMetadata creates a new DataSourceStackMetadata object.
func NewDataSourceStackMetadata() *DataSourceStackMetadata {
return &DataSourceStackMetadata{
Finalizers: []string{},
Labels: map[string]string{},
}
@@ -15,20 +15,20 @@ import (
)
// +k8s:openapi-gen=true
type Datasources struct {
type DataSourceStack struct {
metav1.TypeMeta `json:",inline" yaml:",inline"`
metav1.ObjectMeta `json:"metadata" yaml:"metadata"`
// Spec is the spec of the Datasources
Spec DatasourcesSpec `json:"spec" yaml:"spec"`
// Spec is the spec of the DataSourceStack
Spec DataSourceStackSpec `json:"spec" yaml:"spec"`
}
func (o *Datasources) GetSpec() any {
func (o *DataSourceStack) GetSpec() any {
return o.Spec
}
func (o *Datasources) SetSpec(spec any) error {
cast, ok := spec.(DatasourcesSpec)
func (o *DataSourceStack) SetSpec(spec any) error {
cast, ok := spec.(DataSourceStackSpec)
if !ok {
return fmt.Errorf("cannot set spec type %#v, not of type Spec", spec)
}
@@ -36,25 +36,25 @@ func (o *Datasources) SetSpec(spec any) error {
return nil
}
func (o *Datasources) GetSubresources() map[string]any {
func (o *DataSourceStack) GetSubresources() map[string]any {
return map[string]any{}
}
func (o *Datasources) GetSubresource(name string) (any, bool) {
func (o *DataSourceStack) GetSubresource(name string) (any, bool) {
switch name {
default:
return nil, false
}
}
func (o *Datasources) SetSubresource(name string, value any) error {
func (o *DataSourceStack) SetSubresource(name string, value any) error {
switch name {
default:
return fmt.Errorf("subresource '%s' does not exist", name)
}
}
func (o *Datasources) GetStaticMetadata() resource.StaticMetadata {
func (o *DataSourceStack) GetStaticMetadata() resource.StaticMetadata {
gvk := o.GroupVersionKind()
return resource.StaticMetadata{
Name: o.ObjectMeta.Name,
@@ -65,7 +65,7 @@ func (o *Datasources) GetStaticMetadata() resource.StaticMetadata {
}
}
func (o *Datasources) SetStaticMetadata(metadata resource.StaticMetadata) {
func (o *DataSourceStack) SetStaticMetadata(metadata resource.StaticMetadata) {
o.Name = metadata.Name
o.Namespace = metadata.Namespace
o.SetGroupVersionKind(schema.GroupVersionKind{
@@ -75,7 +75,7 @@ func (o *Datasources) SetStaticMetadata(metadata resource.StaticMetadata) {
})
}
func (o *Datasources) GetCommonMetadata() resource.CommonMetadata {
func (o *DataSourceStack) GetCommonMetadata() resource.CommonMetadata {
dt := o.DeletionTimestamp
var deletionTimestamp *time.Time
if dt != nil {
@@ -107,7 +107,7 @@ func (o *Datasources) GetCommonMetadata() resource.CommonMetadata {
}
}
func (o *Datasources) SetCommonMetadata(metadata resource.CommonMetadata) {
func (o *DataSourceStack) SetCommonMetadata(metadata resource.CommonMetadata) {
o.UID = types.UID(metadata.UID)
o.ResourceVersion = metadata.ResourceVersion
o.Generation = metadata.Generation
@@ -152,7 +152,7 @@ func (o *Datasources) SetCommonMetadata(metadata resource.CommonMetadata) {
}
}
func (o *Datasources) GetCreatedBy() string {
func (o *DataSourceStack) GetCreatedBy() string {
if o.ObjectMeta.Annotations == nil {
o.ObjectMeta.Annotations = make(map[string]string)
}
@@ -160,7 +160,7 @@ func (o *Datasources) GetCreatedBy() string {
return o.ObjectMeta.Annotations["grafana.com/createdBy"]
}
func (o *Datasources) SetCreatedBy(createdBy string) {
func (o *DataSourceStack) SetCreatedBy(createdBy string) {
if o.ObjectMeta.Annotations == nil {
o.ObjectMeta.Annotations = make(map[string]string)
}
@@ -168,7 +168,7 @@ func (o *Datasources) SetCreatedBy(createdBy string) {
o.ObjectMeta.Annotations["grafana.com/createdBy"] = createdBy
}
func (o *Datasources) GetUpdateTimestamp() time.Time {
func (o *DataSourceStack) GetUpdateTimestamp() time.Time {
if o.ObjectMeta.Annotations == nil {
o.ObjectMeta.Annotations = make(map[string]string)
}
@@ -177,7 +177,7 @@ func (o *Datasources) GetUpdateTimestamp() time.Time {
return parsed
}
func (o *Datasources) SetUpdateTimestamp(updateTimestamp time.Time) {
func (o *DataSourceStack) SetUpdateTimestamp(updateTimestamp time.Time) {
if o.ObjectMeta.Annotations == nil {
o.ObjectMeta.Annotations = make(map[string]string)
}
@@ -185,7 +185,7 @@ func (o *Datasources) SetUpdateTimestamp(updateTimestamp time.Time) {
o.ObjectMeta.Annotations["grafana.com/updateTimestamp"] = updateTimestamp.Format(time.RFC3339)
}
func (o *Datasources) GetUpdatedBy() string {
func (o *DataSourceStack) GetUpdatedBy() string {
if o.ObjectMeta.Annotations == nil {
o.ObjectMeta.Annotations = make(map[string]string)
}
@@ -193,7 +193,7 @@ func (o *Datasources) GetUpdatedBy() string {
return o.ObjectMeta.Annotations["grafana.com/updatedBy"]
}
func (o *Datasources) SetUpdatedBy(updatedBy string) {
func (o *DataSourceStack) SetUpdatedBy(updatedBy string) {
if o.ObjectMeta.Annotations == nil {
o.ObjectMeta.Annotations = make(map[string]string)
}
@@ -201,21 +201,21 @@ func (o *Datasources) SetUpdatedBy(updatedBy string) {
o.ObjectMeta.Annotations["grafana.com/updatedBy"] = updatedBy
}
func (o *Datasources) Copy() resource.Object {
func (o *DataSourceStack) Copy() resource.Object {
return resource.CopyObject(o)
}
func (o *Datasources) DeepCopyObject() runtime.Object {
func (o *DataSourceStack) DeepCopyObject() runtime.Object {
return o.Copy()
}
func (o *Datasources) DeepCopy() *Datasources {
cpy := &Datasources{}
func (o *DataSourceStack) DeepCopy() *DataSourceStack {
cpy := &DataSourceStack{}
o.DeepCopyInto(cpy)
return cpy
}
func (o *Datasources) DeepCopyInto(dst *Datasources) {
func (o *DataSourceStack) DeepCopyInto(dst *DataSourceStack) {
dst.TypeMeta.APIVersion = o.TypeMeta.APIVersion
dst.TypeMeta.Kind = o.TypeMeta.Kind
o.ObjectMeta.DeepCopyInto(&dst.ObjectMeta)
@@ -223,34 +223,34 @@ func (o *Datasources) DeepCopyInto(dst *Datasources) {
}
// Interface compliance compile-time check
var _ resource.Object = &Datasources{}
var _ resource.Object = &DataSourceStack{}
// +k8s:openapi-gen=true
type DatasourcesList struct {
type DataSourceStackList struct {
metav1.TypeMeta `json:",inline" yaml:",inline"`
metav1.ListMeta `json:"metadata" yaml:"metadata"`
Items []Datasources `json:"items" yaml:"items"`
Items []DataSourceStack `json:"items" yaml:"items"`
}
func (o *DatasourcesList) DeepCopyObject() runtime.Object {
func (o *DataSourceStackList) DeepCopyObject() runtime.Object {
return o.Copy()
}
func (o *DatasourcesList) Copy() resource.ListObject {
cpy := &DatasourcesList{
func (o *DataSourceStackList) Copy() resource.ListObject {
cpy := &DataSourceStackList{
TypeMeta: o.TypeMeta,
Items: make([]Datasources, len(o.Items)),
Items: make([]DataSourceStack, len(o.Items)),
}
o.ListMeta.DeepCopyInto(&cpy.ListMeta)
for i := 0; i < len(o.Items); i++ {
if item, ok := o.Items[i].Copy().(*Datasources); ok {
if item, ok := o.Items[i].Copy().(*DataSourceStack); ok {
cpy.Items[i] = *item
}
}
return cpy
}
func (o *DatasourcesList) GetItems() []resource.Object {
func (o *DataSourceStackList) GetItems() []resource.Object {
items := make([]resource.Object, len(o.Items))
for i := 0; i < len(o.Items); i++ {
items[i] = &o.Items[i]
@@ -258,36 +258,36 @@ func (o *DatasourcesList) GetItems() []resource.Object {
return items
}
func (o *DatasourcesList) SetItems(items []resource.Object) {
o.Items = make([]Datasources, len(items))
func (o *DataSourceStackList) SetItems(items []resource.Object) {
o.Items = make([]DataSourceStack, len(items))
for i := 0; i < len(items); i++ {
o.Items[i] = *items[i].(*Datasources)
o.Items[i] = *items[i].(*DataSourceStack)
}
}
func (o *DatasourcesList) DeepCopy() *DatasourcesList {
cpy := &DatasourcesList{}
func (o *DataSourceStackList) DeepCopy() *DataSourceStackList {
cpy := &DataSourceStackList{}
o.DeepCopyInto(cpy)
return cpy
}
func (o *DatasourcesList) DeepCopyInto(dst *DatasourcesList) {
func (o *DataSourceStackList) DeepCopyInto(dst *DataSourceStackList) {
resource.CopyObjectInto(dst, o)
}
// Interface compliance compile-time check
var _ resource.ListObject = &DatasourcesList{}
var _ resource.ListObject = &DataSourceStackList{}
// Copy methods for all subresource types
// DeepCopy creates a full deep copy of Spec
func (s *DatasourcesSpec) DeepCopy() *DatasourcesSpec {
cpy := &DatasourcesSpec{}
func (s *DataSourceStackSpec) DeepCopy() *DataSourceStackSpec {
cpy := &DataSourceStackSpec{}
s.DeepCopyInto(cpy)
return cpy
}
// DeepCopyInto deep copies Spec into another Spec object
func (s *DatasourcesSpec) DeepCopyInto(dst *DatasourcesSpec) {
func (s *DataSourceStackSpec) DeepCopyInto(dst *DataSourceStackSpec) {
resource.CopyObjectInto(dst, s)
}
@@ -0,0 +1,34 @@
//
// Code generated by grafana-app-sdk. DO NOT EDIT.
//
package v1alpha1
import (
"github.com/grafana/grafana-app-sdk/resource"
)
// schema is unexported to prevent accidental overwrites
var (
schemaDataSourceStack = resource.NewSimpleSchema("collections.grafana.app", "v1alpha1", &DataSourceStack{}, &DataSourceStackList{}, resource.WithKind("DataSourceStack"),
resource.WithPlural("datasourcestacks"), resource.WithScope(resource.NamespacedScope))
kindDataSourceStack = resource.Kind{
Schema: schemaDataSourceStack,
Codecs: map[resource.KindEncoding]resource.Codec{
resource.KindEncodingJSON: &DataSourceStackJSONCodec{},
},
}
)
// Kind returns a resource.Kind for this Schema with a JSON codec
func DataSourceStackKind() resource.Kind {
return kindDataSourceStack
}
// Schema returns a resource.SimpleSchema representation of DataSourceStack
func DataSourceStackSchema() *resource.SimpleSchema {
return schemaDataSourceStack
}
// Interface compliance checks
var _ resource.Schema = kindDataSourceStack
@@ -0,0 +1,58 @@
// Code generated - EDITING IS FUTILE. DO NOT EDIT.
package v1alpha1
// +k8s:openapi-gen=true
type DataSourceStackTemplateSpec map[string]DataSourceStackDataSourceStackTemplateItem
// +k8s:openapi-gen=true
type DataSourceStackDataSourceStackTemplateItem struct {
// type
Group string `json:"group"`
// variable name / display name
Name string `json:"name"`
}
// NewDataSourceStackDataSourceStackTemplateItem creates a new DataSourceStackDataSourceStackTemplateItem object.
func NewDataSourceStackDataSourceStackTemplateItem() *DataSourceStackDataSourceStackTemplateItem {
return &DataSourceStackDataSourceStackTemplateItem{}
}
// +k8s:openapi-gen=true
type DataSourceStackModeSpec struct {
Name string `json:"name"`
Uid string `json:"uid"`
Definition DataSourceStackMode `json:"definition"`
}
// NewDataSourceStackModeSpec creates a new DataSourceStackModeSpec object.
func NewDataSourceStackModeSpec() *DataSourceStackModeSpec {
return &DataSourceStackModeSpec{}
}
// +k8s:openapi-gen=true
type DataSourceStackMode map[string]DataSourceStackModeItem
// +k8s:openapi-gen=true
type DataSourceStackModeItem struct {
// grafana data source uid
DataSourceRef string `json:"dataSourceRef"`
}
// NewDataSourceStackModeItem creates a new DataSourceStackModeItem object.
func NewDataSourceStackModeItem() *DataSourceStackModeItem {
return &DataSourceStackModeItem{}
}
// +k8s:openapi-gen=true
type DataSourceStackSpec struct {
Template DataSourceStackTemplateSpec `json:"template"`
Modes []DataSourceStackModeSpec `json:"modes"`
}
// NewDataSourceStackSpec creates a new DataSourceStackSpec object.
func NewDataSourceStackSpec() *DataSourceStackSpec {
return &DataSourceStackSpec{
Modes: []DataSourceStackModeSpec{},
}
}
@@ -32,10 +32,10 @@ var StarsResourceInfo = utils.NewResourceInfo(APIGroup, APIVersion,
},
)
var DatasourcesResourceInfo = utils.NewResourceInfo(APIGroup, APIVersion,
"datasources", "datasource", "Datasources",
func() runtime.Object { return &Datasources{} },
func() runtime.Object { return &DatasourcesList{} },
var DatasourceStacksResourceInfo = utils.NewResourceInfo(APIGroup, APIVersion,
"datasourcestacks", "datasourcestack", "DataSourceStacks",
func() runtime.Object { return &DataSourceStack{} },
func() runtime.Object { return &DataSourceStackList{} },
utils.TableColumns{
Definition: []metav1.TableColumnDefinition{
{Name: "Name", Type: "string", Format: "name"},
@@ -61,8 +61,8 @@ func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(schemeGroupVersion,
&Stars{},
&StarsList{},
&Datasources{},
&DatasourcesList{},
&DataSourceStack{},
&DataSourceStackList{},
)
metav1.AddToGroupVersion(scheme, schemeGroupVersion)
return nil
@@ -14,20 +14,20 @@ import (
func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenAPIDefinition {
return map[string]common.OpenAPIDefinition{
"github.com/grafana/grafana/apps/collections/pkg/apis/collections/v1alpha1.Datasources": schema_pkg_apis_collections_v1alpha1_Datasources(ref),
"github.com/grafana/grafana/apps/collections/pkg/apis/collections/v1alpha1.DatasourcesDataSourceRef": schema_pkg_apis_collections_v1alpha1_DatasourcesDataSourceRef(ref),
"github.com/grafana/grafana/apps/collections/pkg/apis/collections/v1alpha1.DatasourcesDataSourceTemplateSpec": schema_pkg_apis_collections_v1alpha1_DatasourcesDataSourceTemplateSpec(ref),
"github.com/grafana/grafana/apps/collections/pkg/apis/collections/v1alpha1.DatasourcesList": schema_pkg_apis_collections_v1alpha1_DatasourcesList(ref),
"github.com/grafana/grafana/apps/collections/pkg/apis/collections/v1alpha1.DatasourcesMode": schema_pkg_apis_collections_v1alpha1_DatasourcesMode(ref),
"github.com/grafana/grafana/apps/collections/pkg/apis/collections/v1alpha1.DatasourcesSpec": schema_pkg_apis_collections_v1alpha1_DatasourcesSpec(ref),
"github.com/grafana/grafana/apps/collections/pkg/apis/collections/v1alpha1.Stars": schema_pkg_apis_collections_v1alpha1_Stars(ref),
"github.com/grafana/grafana/apps/collections/pkg/apis/collections/v1alpha1.StarsList": schema_pkg_apis_collections_v1alpha1_StarsList(ref),
"github.com/grafana/grafana/apps/collections/pkg/apis/collections/v1alpha1.StarsResource": schema_pkg_apis_collections_v1alpha1_StarsResource(ref),
"github.com/grafana/grafana/apps/collections/pkg/apis/collections/v1alpha1.StarsSpec": schema_pkg_apis_collections_v1alpha1_StarsSpec(ref),
"github.com/grafana/grafana/apps/collections/pkg/apis/collections/v1alpha1.DataSourceStack": schema_pkg_apis_collections_v1alpha1_DataSourceStack(ref),
"github.com/grafana/grafana/apps/collections/pkg/apis/collections/v1alpha1.DataSourceStackDataSourceStackTemplateItem": schema_pkg_apis_collections_v1alpha1_DataSourceStackDataSourceStackTemplateItem(ref),
"github.com/grafana/grafana/apps/collections/pkg/apis/collections/v1alpha1.DataSourceStackList": schema_pkg_apis_collections_v1alpha1_DataSourceStackList(ref),
"github.com/grafana/grafana/apps/collections/pkg/apis/collections/v1alpha1.DataSourceStackModeItem": schema_pkg_apis_collections_v1alpha1_DataSourceStackModeItem(ref),
"github.com/grafana/grafana/apps/collections/pkg/apis/collections/v1alpha1.DataSourceStackModeSpec": schema_pkg_apis_collections_v1alpha1_DataSourceStackModeSpec(ref),
"github.com/grafana/grafana/apps/collections/pkg/apis/collections/v1alpha1.DataSourceStackSpec": schema_pkg_apis_collections_v1alpha1_DataSourceStackSpec(ref),
"github.com/grafana/grafana/apps/collections/pkg/apis/collections/v1alpha1.Stars": schema_pkg_apis_collections_v1alpha1_Stars(ref),
"github.com/grafana/grafana/apps/collections/pkg/apis/collections/v1alpha1.StarsList": schema_pkg_apis_collections_v1alpha1_StarsList(ref),
"github.com/grafana/grafana/apps/collections/pkg/apis/collections/v1alpha1.StarsResource": schema_pkg_apis_collections_v1alpha1_StarsResource(ref),
"github.com/grafana/grafana/apps/collections/pkg/apis/collections/v1alpha1.StarsSpec": schema_pkg_apis_collections_v1alpha1_StarsSpec(ref),
}
}
func schema_pkg_apis_collections_v1alpha1_Datasources(ref common.ReferenceCallback) common.OpenAPIDefinition {
func schema_pkg_apis_collections_v1alpha1_DataSourceStack(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
@@ -55,9 +55,9 @@ func schema_pkg_apis_collections_v1alpha1_Datasources(ref common.ReferenceCallba
},
"spec": {
SchemaProps: spec.SchemaProps{
Description: "Spec is the spec of the Datasources",
Description: "Spec is the spec of the DataSourceStack",
Default: map[string]interface{}{},
Ref: ref("github.com/grafana/grafana/apps/collections/pkg/apis/collections/v1alpha1.DatasourcesSpec"),
Ref: ref("github.com/grafana/grafana/apps/collections/pkg/apis/collections/v1alpha1.DataSourceStackSpec"),
},
},
},
@@ -65,32 +65,11 @@ func schema_pkg_apis_collections_v1alpha1_Datasources(ref common.ReferenceCallba
},
},
Dependencies: []string{
"github.com/grafana/grafana/apps/collections/pkg/apis/collections/v1alpha1.DatasourcesSpec", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"},
"github.com/grafana/grafana/apps/collections/pkg/apis/collections/v1alpha1.DataSourceStackSpec", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"},
}
}
func schema_pkg_apis_collections_v1alpha1_DatasourcesDataSourceRef(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
Type: []string{"object"},
Properties: map[string]spec.Schema{
"name": {
SchemaProps: spec.SchemaProps{
Description: "grafana data source uid",
Default: "",
Type: []string{"string"},
Format: "",
},
},
},
Required: []string{"name"},
},
},
}
}
func schema_pkg_apis_collections_v1alpha1_DatasourcesDataSourceTemplateSpec(ref common.ReferenceCallback) common.OpenAPIDefinition {
func schema_pkg_apis_collections_v1alpha1_DataSourceStackDataSourceStackTemplateItem(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
@@ -119,7 +98,7 @@ func schema_pkg_apis_collections_v1alpha1_DatasourcesDataSourceTemplateSpec(ref
}
}
func schema_pkg_apis_collections_v1alpha1_DatasourcesList(ref common.ReferenceCallback) common.OpenAPIDefinition {
func schema_pkg_apis_collections_v1alpha1_DataSourceStackList(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
@@ -152,7 +131,7 @@ func schema_pkg_apis_collections_v1alpha1_DatasourcesList(ref common.ReferenceCa
Schema: &spec.Schema{
SchemaProps: spec.SchemaProps{
Default: map[string]interface{}{},
Ref: ref("github.com/grafana/grafana/apps/collections/pkg/apis/collections/v1alpha1.Datasources"),
Ref: ref("github.com/grafana/grafana/apps/collections/pkg/apis/collections/v1alpha1.DataSourceStack"),
},
},
},
@@ -163,11 +142,32 @@ func schema_pkg_apis_collections_v1alpha1_DatasourcesList(ref common.ReferenceCa
},
},
Dependencies: []string{
"github.com/grafana/grafana/apps/collections/pkg/apis/collections/v1alpha1.Datasources", "k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"},
"github.com/grafana/grafana/apps/collections/pkg/apis/collections/v1alpha1.DataSourceStack", "k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"},
}
}
func schema_pkg_apis_collections_v1alpha1_DatasourcesMode(ref common.ReferenceCallback) common.OpenAPIDefinition {
func schema_pkg_apis_collections_v1alpha1_DataSourceStackModeItem(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
Type: []string{"object"},
Properties: map[string]spec.Schema{
"dataSourceRef": {
SchemaProps: spec.SchemaProps{
Description: "grafana data source uid",
Default: "",
Type: []string{"string"},
Format: "",
},
},
},
Required: []string{"dataSourceRef"},
},
},
}
}
func schema_pkg_apis_collections_v1alpha1_DataSourceStackModeSpec(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
@@ -195,7 +195,7 @@ func schema_pkg_apis_collections_v1alpha1_DatasourcesMode(ref common.ReferenceCa
Schema: &spec.Schema{
SchemaProps: spec.SchemaProps{
Default: map[string]interface{}{},
Ref: ref("github.com/grafana/grafana/apps/collections/pkg/apis/collections/v1alpha1.DatasourcesDataSourceRef"),
Ref: ref("github.com/grafana/grafana/apps/collections/pkg/apis/collections/v1alpha1.DataSourceStackModeItem"),
},
},
},
@@ -206,11 +206,11 @@ func schema_pkg_apis_collections_v1alpha1_DatasourcesMode(ref common.ReferenceCa
},
},
Dependencies: []string{
"github.com/grafana/grafana/apps/collections/pkg/apis/collections/v1alpha1.DatasourcesDataSourceRef"},
"github.com/grafana/grafana/apps/collections/pkg/apis/collections/v1alpha1.DataSourceStackModeItem"},
}
}
func schema_pkg_apis_collections_v1alpha1_DatasourcesSpec(ref common.ReferenceCallback) common.OpenAPIDefinition {
func schema_pkg_apis_collections_v1alpha1_DataSourceStackSpec(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
@@ -224,7 +224,7 @@ func schema_pkg_apis_collections_v1alpha1_DatasourcesSpec(ref common.ReferenceCa
Schema: &spec.Schema{
SchemaProps: spec.SchemaProps{
Default: map[string]interface{}{},
Ref: ref("github.com/grafana/grafana/apps/collections/pkg/apis/collections/v1alpha1.DatasourcesDataSourceTemplateSpec"),
Ref: ref("github.com/grafana/grafana/apps/collections/pkg/apis/collections/v1alpha1.DataSourceStackDataSourceStackTemplateItem"),
},
},
},
@@ -237,7 +237,7 @@ func schema_pkg_apis_collections_v1alpha1_DatasourcesSpec(ref common.ReferenceCa
Schema: &spec.Schema{
SchemaProps: spec.SchemaProps{
Default: map[string]interface{}{},
Ref: ref("github.com/grafana/grafana/apps/collections/pkg/apis/collections/v1alpha1.DatasourcesMode"),
Ref: ref("github.com/grafana/grafana/apps/collections/pkg/apis/collections/v1alpha1.DataSourceStackModeSpec"),
},
},
},
@@ -248,7 +248,7 @@ func schema_pkg_apis_collections_v1alpha1_DatasourcesSpec(ref common.ReferenceCa
},
},
Dependencies: []string{
"github.com/grafana/grafana/apps/collections/pkg/apis/collections/v1alpha1.DatasourcesDataSourceTemplateSpec", "github.com/grafana/grafana/apps/collections/pkg/apis/collections/v1alpha1.DatasourcesMode"},
"github.com/grafana/grafana/apps/collections/pkg/apis/collections/v1alpha1.DataSourceStackDataSourceStackTemplateItem", "github.com/grafana/grafana/apps/collections/pkg/apis/collections/v1alpha1.DataSourceStackModeSpec"},
}
}
@@ -1,4 +1,4 @@
API rule violation: list_type_missing,github.com/grafana/grafana/apps/collections/pkg/apis/collections/v1alpha1,DatasourcesSpec,Modes
API rule violation: list_type_missing,github.com/grafana/grafana/apps/collections/pkg/apis/collections/v1alpha1,DataSourceStackSpec,Modes
API rule violation: list_type_missing,github.com/grafana/grafana/apps/collections/pkg/apis/collections/v1alpha1,StarsSpec,Resource
API rule violation: streaming_list_type_json_tags,github.com/grafana/grafana/apps/collections/pkg/apis/collections/v1alpha1,DatasourcesList,ListMeta
API rule violation: streaming_list_type_json_tags,github.com/grafana/grafana/apps/collections/pkg/apis/collections/v1alpha1,DataSourceStackList,ListMeta
API rule violation: streaming_list_type_json_tags,github.com/grafana/grafana/apps/collections/pkg/apis/collections/v1alpha1,StarsList,ListMeta
+11 -11
View File
@@ -20,12 +20,12 @@ import (
)
var (
rawSchemaStarsv1alpha1 = []byte(`{"Resource":{"additionalProperties":false,"properties":{"group":{"type":"string"},"kind":{"type":"string"},"names":{"description":"The set of resources\n+listType=set","items":{"type":"string"},"type":"array"}},"required":["group","kind","names"],"type":"object"},"Stars":{"properties":{"spec":{"$ref":"#/components/schemas/spec"}},"required":["spec"]},"spec":{"additionalProperties":false,"properties":{"resource":{"items":{"$ref":"#/components/schemas/Resource"},"type":"array"}},"required":["resource"],"type":"object"}}`)
versionSchemaStarsv1alpha1 app.VersionSchema
_ = json.Unmarshal(rawSchemaStarsv1alpha1, &versionSchemaStarsv1alpha1)
rawSchemaDatasourcesv1alpha1 = []byte(`{"DataSourceRef":{"additionalProperties":false,"properties":{"name":{"description":"grafana data source uid","type":"string"}},"required":["name"],"type":"object"},"DataSourceTemplateSpec":{"additionalProperties":false,"properties":{"group":{"description":"type","type":"string"},"name":{"description":"variable name / display name","type":"string"}},"required":["group","name"],"type":"object"},"Datasources":{"properties":{"spec":{"$ref":"#/components/schemas/spec"}},"required":["spec"]},"Mode":{"additionalProperties":false,"properties":{"definition":{"$ref":"#/components/schemas/ModeSpec"},"name":{"type":"string"},"uid":{"type":"string"}},"required":["name","uid","definition"],"type":"object"},"ModeSpec":{"additionalProperties":{"$ref":"#/components/schemas/DataSourceRef"},"type":"object"},"TemplateSpec":{"additionalProperties":{"$ref":"#/components/schemas/DataSourceTemplateSpec"},"type":"object"},"spec":{"additionalProperties":false,"properties":{"modes":{"items":{"$ref":"#/components/schemas/Mode"},"type":"array"},"template":{"$ref":"#/components/schemas/TemplateSpec"}},"required":["template","modes"],"type":"object"}}`)
versionSchemaDatasourcesv1alpha1 app.VersionSchema
_ = json.Unmarshal(rawSchemaDatasourcesv1alpha1, &versionSchemaDatasourcesv1alpha1)
rawSchemaStarsv1alpha1 = []byte(`{"Resource":{"additionalProperties":false,"properties":{"group":{"type":"string"},"kind":{"type":"string"},"names":{"description":"The set of resources\n+listType=set","items":{"type":"string"},"type":"array"}},"required":["group","kind","names"],"type":"object"},"Stars":{"properties":{"spec":{"$ref":"#/components/schemas/spec"}},"required":["spec"]},"spec":{"additionalProperties":false,"properties":{"resource":{"items":{"$ref":"#/components/schemas/Resource"},"type":"array"}},"required":["resource"],"type":"object"}}`)
versionSchemaStarsv1alpha1 app.VersionSchema
_ = json.Unmarshal(rawSchemaStarsv1alpha1, &versionSchemaStarsv1alpha1)
rawSchemaDataSourceStackv1alpha1 = []byte(`{"DataSourceStack":{"properties":{"spec":{"$ref":"#/components/schemas/spec"}},"required":["spec"]},"DataSourceStackTemplateItem":{"additionalProperties":false,"properties":{"group":{"description":"type","type":"string"},"name":{"description":"variable name / display name","type":"string"}},"required":["group","name"],"type":"object"},"Mode":{"additionalProperties":{"$ref":"#/components/schemas/ModeItem"},"type":"object"},"ModeItem":{"additionalProperties":false,"properties":{"dataSourceRef":{"description":"grafana data source uid","type":"string"}},"required":["dataSourceRef"],"type":"object"},"ModeSpec":{"additionalProperties":false,"properties":{"definition":{"$ref":"#/components/schemas/Mode"},"name":{"type":"string"},"uid":{"type":"string"}},"required":["name","uid","definition"],"type":"object"},"TemplateSpec":{"additionalProperties":{"$ref":"#/components/schemas/DataSourceStackTemplateItem"},"type":"object"},"spec":{"additionalProperties":false,"properties":{"modes":{"items":{"$ref":"#/components/schemas/ModeSpec"},"type":"array"},"template":{"$ref":"#/components/schemas/TemplateSpec"}},"required":["template","modes"],"type":"object"}}`)
versionSchemaDataSourceStackv1alpha1 app.VersionSchema
_ = json.Unmarshal(rawSchemaDataSourceStackv1alpha1, &versionSchemaDataSourceStackv1alpha1)
)
var appManifestData = app.ManifestData{
@@ -54,11 +54,11 @@ var appManifestData = app.ManifestData{
},
{
Kind: "Datasources",
Plural: "Datasource",
Kind: "DataSourceStack",
Plural: "DataSourceStacks",
Scope: "Namespaced",
Conversion: false,
Schema: &versionSchemaDatasourcesv1alpha1,
Schema: &versionSchemaDataSourceStackv1alpha1,
},
},
Routes: app.ManifestVersionRoutes{
@@ -79,8 +79,8 @@ func RemoteManifest() app.Manifest {
}
var kindVersionToGoType = map[string]resource.Kind{
"Stars/v1alpha1": v1alpha1.StarsKind(),
"Datasources/v1alpha1": v1alpha1.DatasourcesKind(),
"Stars/v1alpha1": v1alpha1.StarsKind(),
"DataSourceStack/v1alpha1": v1alpha1.DataSourceStackKind(),
}
// ManifestGoTypeAssociator returns the associated resource.Kind instance for a given Kind and Version, if one exists.
@@ -0,0 +1,47 @@
/*
* This file was generated by grafana-app-sdk. DO NOT EDIT.
*/
import { Spec } from './types.spec.gen';
export interface Metadata {
name: string;
namespace: string;
generateName?: string;
selfLink?: string;
uid?: string;
resourceVersion?: string;
generation?: number;
creationTimestamp?: string;
deletionTimestamp?: string;
deletionGracePeriodSeconds?: number;
labels?: Record<string, string>;
annotations?: Record<string, string>;
ownerReferences?: OwnerReference[];
finalizers?: string[];
managedFields?: ManagedFieldsEntry[];
}
export interface OwnerReference {
apiVersion: string;
kind: string;
name: string;
uid: string;
controller?: boolean;
blockOwnerDeletion?: boolean;
}
export interface ManagedFieldsEntry {
manager?: string;
operation?: string;
apiVersion?: string;
time?: string;
fieldsType?: string;
subresource?: string;
}
export interface DataSourceStack {
kind: string;
apiVersion: string;
metadata: Metadata;
spec: Spec;
}
@@ -0,0 +1,30 @@
// Code generated - EDITING IS FUTILE. DO NOT EDIT.
// metadata contains embedded CommonMetadata and can be extended with custom string fields
// TODO: use CommonMetadata instead of redefining here; currently needs to be defined here
// without external reference as using the CommonMetadata reference breaks thema codegen.
export interface Metadata {
updateTimestamp: string;
createdBy: string;
uid: string;
creationTimestamp: string;
deletionTimestamp?: string;
finalizers: string[];
resourceVersion: string;
generation: number;
updatedBy: string;
labels: Record<string, string>;
}
export const defaultMetadata = (): Metadata => ({
updateTimestamp: "",
createdBy: "",
uid: "",
creationTimestamp: "",
finalizers: [],
resourceVersion: "",
generation: 0,
updatedBy: "",
labels: {},
});
@@ -0,0 +1,53 @@
// Code generated - EDITING IS FUTILE. DO NOT EDIT.
export type TemplateSpec = Record<string, DataSourceStackTemplateItem>;
export const defaultTemplateSpec = (): TemplateSpec => ({});
export interface DataSourceStackTemplateItem {
// type
group: string;
// variable name / display name
name: string;
}
export const defaultDataSourceStackTemplateItem = (): DataSourceStackTemplateItem => ({
group: "",
name: "",
});
export interface ModeSpec {
name: string;
uid: string;
definition: Mode;
}
export const defaultModeSpec = (): ModeSpec => ({
name: "",
uid: "",
definition: defaultMode(),
});
export type Mode = Record<string, ModeItem>;
export const defaultMode = (): Mode => ({});
export interface ModeItem {
// grafana data source uid
dataSourceRef: string;
}
export const defaultModeItem = (): ModeItem => ({
dataSourceRef: "",
});
export interface Spec {
template: TemplateSpec;
modes: ModeSpec[];
}
export const defaultSpec = (): Spec => ({
template: defaultTemplateSpec(),
modes: [],
});
+3 -3
View File
@@ -31,12 +31,12 @@ func (s *datasourceStorage) List(ctx context.Context, options *internalversion.L
// Get the single user stars
case authlib.TypeUser:
datasources := &collections.DatasourcesList{}
datasources := &collections.DataSourceStackList{}
obj, _ := s.Get(ctx, "user-"+user.GetIdentifier(), &v1.GetOptions{})
if obj != nil {
d, ok := obj.(*collections.Datasources)
d, ok := obj.(*collections.DataSourceStack)
if ok {
datasources.Items = []collections.Datasources{*d}
datasources.Items = []collections.DataSourceStack{*d}
}
}
return datasources, nil
+13 -1
View File
@@ -15,6 +15,7 @@ import (
"k8s.io/kube-openapi/pkg/validation/spec"
collections "github.com/grafana/grafana/apps/collections/pkg/apis/collections/v1alpha1"
"github.com/grafana/grafana/pkg/apimachinery/identity"
grafanaregistry "github.com/grafana/grafana/pkg/apiserver/registry/generic"
grafanarest "github.com/grafana/grafana/pkg/apiserver/rest"
"github.com/grafana/grafana/pkg/infra/db"
@@ -113,7 +114,7 @@ func (b *APIBuilder) UpdateAPIGroupInfo(apiGroupInfo *genericapiserver.APIGroupI
storage[starsResource.StoragePath("update")] = &starsREST{store: stars}
// no need for dual writer for a kind that does not exist in the legacy database
resourceInfo := collections.DatasourcesResourceInfo
resourceInfo := collections.DatasourceStacksResourceInfo
datasourcesStorage, err := grafanaregistry.NewRegistryStore(opts.Scheme, resourceInfo, opts.OptsGetter)
if err != nil {
return err
@@ -132,6 +133,17 @@ func (b *APIBuilder) GetAuthorizer() authorizer.Authorizer {
return b.authorizer.Authorize(ctx, attr)
}
// datasources auth branch starts
if !attr.IsResourceRequest() {
return authorizer.DecisionNoOpinion, "", nil
}
// require a user
_, err = identity.GetRequester(ctx)
if err != nil {
return authorizer.DecisionDeny, "valid user is required", err
}
// TODO make the auth more restrictive
return authorizer.DecisionAllow, "", nil
})