merge main
This commit is contained in:
@@ -8,12 +8,12 @@ import (
|
||||
)
|
||||
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
type GenericDataSource struct {
|
||||
type DataSource struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata"`
|
||||
|
||||
// generic config
|
||||
Spec GenericDataSourceSpec `json:"spec"`
|
||||
Spec DataSourceSpec `json:"spec"`
|
||||
|
||||
// Secure values placeholder (true for fields that exist)
|
||||
Secure secret.InlineSecureValues `json:"secure,omitempty"`
|
||||
@@ -36,7 +36,7 @@ func (dsa DsAccess) String() string {
|
||||
return string(dsa)
|
||||
}
|
||||
|
||||
type GenericDataSourceSpec struct {
|
||||
type DataSourceSpec struct {
|
||||
// The diplay name (previously saved as the "name" property)
|
||||
Title string `json:"title"`
|
||||
|
||||
@@ -58,9 +58,9 @@ type GenericDataSourceSpec struct {
|
||||
}
|
||||
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
type GenericDataSourceList struct {
|
||||
type DataSourceList struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ListMeta `json:"metadata"`
|
||||
|
||||
Items []GenericDataSource `json:"items"`
|
||||
Items []DataSource `json:"items"`
|
||||
}
|
||||
|
||||
@@ -15,22 +15,22 @@ const (
|
||||
VERSION = "v0alpha1"
|
||||
)
|
||||
|
||||
var GenericDataSourceResourceInfo = utils.NewResourceInfo(GROUP, VERSION,
|
||||
var DataSourceResourceInfo = utils.NewResourceInfo(GROUP, VERSION,
|
||||
"datasources", "datasource", "DataSource",
|
||||
func() runtime.Object { return &GenericDataSource{} },
|
||||
func() runtime.Object { return &GenericDataSourceList{} },
|
||||
func() runtime.Object { return &DataSource{} },
|
||||
func() runtime.Object { return &DataSourceList{} },
|
||||
utils.TableColumns{
|
||||
Definition: []metav1.TableColumnDefinition{
|
||||
{Name: "Name", Type: "string", Format: "name"},
|
||||
{Name: "Title", Type: "string", Format: "string", Description: "Title"},
|
||||
{Name: "Created At", Type: "date"},
|
||||
},
|
||||
Reader: func(obj any) ([]interface{}, error) {
|
||||
m, ok := obj.(*GenericDataSource)
|
||||
Reader: func(obj any) ([]any, error) {
|
||||
m, ok := obj.(*DataSource)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("expected connection")
|
||||
}
|
||||
return []interface{}{
|
||||
return []any{
|
||||
m.Name,
|
||||
m.Spec.Title,
|
||||
m.CreationTimestamp.UTC().Format(time.RFC3339),
|
||||
@@ -39,7 +39,7 @@ var GenericDataSourceResourceInfo = utils.NewResourceInfo(GROUP, VERSION,
|
||||
},
|
||||
)
|
||||
|
||||
var GenericConnectionResourceInfo = utils.NewResourceInfo(GROUP, VERSION,
|
||||
var ConnectionResourceInfo = utils.NewResourceInfo(GROUP, VERSION,
|
||||
"connections", "connection", "DataSourceConnection",
|
||||
func() runtime.Object { return &DataSourceConnection{} },
|
||||
func() runtime.Object { return &DataSourceConnectionList{} },
|
||||
|
||||
@@ -12,6 +12,40 @@ import (
|
||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *DataSource) DeepCopyInto(out *DataSource) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
|
||||
in.Spec.DeepCopyInto(&out.Spec)
|
||||
if in.Secure != nil {
|
||||
in, out := &in.Secure, &out.Secure
|
||||
*out = make(map[string]secretv0alpha1.InlineSecureValue, len(*in))
|
||||
for key, val := range *in {
|
||||
(*out)[key] = val
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DataSource.
|
||||
func (in *DataSource) DeepCopy() *DataSource {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(DataSource)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *DataSource) DeepCopyObject() runtime.Object {
|
||||
if c := in.DeepCopy(); c != nil {
|
||||
return c
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *DataSourceConnection) DeepCopyInto(out *DataSourceConnection) {
|
||||
*out = *in
|
||||
@@ -72,47 +106,13 @@ func (in *DataSourceConnectionList) DeepCopyObject() runtime.Object {
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *GenericDataSource) DeepCopyInto(out *GenericDataSource) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
|
||||
in.Spec.DeepCopyInto(&out.Spec)
|
||||
if in.Secure != nil {
|
||||
in, out := &in.Secure, &out.Secure
|
||||
*out = make(map[string]secretv0alpha1.InlineSecureValue, len(*in))
|
||||
for key, val := range *in {
|
||||
(*out)[key] = val
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GenericDataSource.
|
||||
func (in *GenericDataSource) DeepCopy() *GenericDataSource {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(GenericDataSource)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *GenericDataSource) DeepCopyObject() runtime.Object {
|
||||
if c := in.DeepCopy(); c != nil {
|
||||
return c
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *GenericDataSourceList) DeepCopyInto(out *GenericDataSourceList) {
|
||||
func (in *DataSourceList) DeepCopyInto(out *DataSourceList) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ListMeta.DeepCopyInto(&out.ListMeta)
|
||||
if in.Items != nil {
|
||||
in, out := &in.Items, &out.Items
|
||||
*out = make([]GenericDataSource, len(*in))
|
||||
*out = make([]DataSource, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
@@ -120,18 +120,18 @@ func (in *GenericDataSourceList) DeepCopyInto(out *GenericDataSourceList) {
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GenericDataSourceList.
|
||||
func (in *GenericDataSourceList) DeepCopy() *GenericDataSourceList {
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DataSourceList.
|
||||
func (in *DataSourceList) DeepCopy() *DataSourceList {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(GenericDataSourceList)
|
||||
out := new(DataSourceList)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *GenericDataSourceList) DeepCopyObject() runtime.Object {
|
||||
func (in *DataSourceList) DeepCopyObject() runtime.Object {
|
||||
if c := in.DeepCopy(); c != nil {
|
||||
return c
|
||||
}
|
||||
@@ -139,18 +139,18 @@ func (in *GenericDataSourceList) DeepCopyObject() runtime.Object {
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *GenericDataSourceSpec) DeepCopyInto(out *GenericDataSourceSpec) {
|
||||
func (in *DataSourceSpec) DeepCopyInto(out *DataSourceSpec) {
|
||||
*out = *in
|
||||
in.JsonData.DeepCopyInto(&out.JsonData)
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GenericDataSourceSpec.
|
||||
func (in *GenericDataSourceSpec) DeepCopy() *GenericDataSourceSpec {
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DataSourceSpec.
|
||||
func (in *DataSourceSpec) DeepCopy() *DataSourceSpec {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(GenericDataSourceSpec)
|
||||
out := new(DataSourceSpec)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
@@ -14,15 +14,72 @@ import (
|
||||
|
||||
func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenAPIDefinition {
|
||||
return map[string]common.OpenAPIDefinition{
|
||||
"github.com/grafana/grafana/pkg/apis/datasource/v0alpha1.DataSource": schema_pkg_apis_datasource_v0alpha1_DataSource(ref),
|
||||
"github.com/grafana/grafana/pkg/apis/datasource/v0alpha1.DataSourceConnection": schema_pkg_apis_datasource_v0alpha1_DataSourceConnection(ref),
|
||||
"github.com/grafana/grafana/pkg/apis/datasource/v0alpha1.DataSourceConnectionList": schema_pkg_apis_datasource_v0alpha1_DataSourceConnectionList(ref),
|
||||
"github.com/grafana/grafana/pkg/apis/datasource/v0alpha1.GenericDataSource": schema_pkg_apis_datasource_v0alpha1_GenericDataSource(ref),
|
||||
"github.com/grafana/grafana/pkg/apis/datasource/v0alpha1.GenericDataSourceList": schema_pkg_apis_datasource_v0alpha1_GenericDataSourceList(ref),
|
||||
"github.com/grafana/grafana/pkg/apis/datasource/v0alpha1.GenericDataSourceSpec": schema_pkg_apis_datasource_v0alpha1_GenericDataSourceSpec(ref),
|
||||
"github.com/grafana/grafana/pkg/apis/datasource/v0alpha1.DataSourceList": schema_pkg_apis_datasource_v0alpha1_DataSourceList(ref),
|
||||
"github.com/grafana/grafana/pkg/apis/datasource/v0alpha1.DataSourceSpec": schema_pkg_apis_datasource_v0alpha1_DataSourceSpec(ref),
|
||||
"github.com/grafana/grafana/pkg/apis/datasource/v0alpha1.HealthCheckResult": schema_pkg_apis_datasource_v0alpha1_HealthCheckResult(ref),
|
||||
}
|
||||
}
|
||||
|
||||
func schema_pkg_apis_datasource_v0alpha1_DataSource(ref common.ReferenceCallback) common.OpenAPIDefinition {
|
||||
return common.OpenAPIDefinition{
|
||||
Schema: spec.Schema{
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Type: []string{"object"},
|
||||
Properties: map[string]spec.Schema{
|
||||
"kind": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds",
|
||||
Type: []string{"string"},
|
||||
Format: "",
|
||||
},
|
||||
},
|
||||
"apiVersion": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources",
|
||||
Type: []string{"string"},
|
||||
Format: "",
|
||||
},
|
||||
},
|
||||
"metadata": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Default: map[string]interface{}{},
|
||||
Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"),
|
||||
},
|
||||
},
|
||||
"spec": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Description: "generic config",
|
||||
Default: map[string]interface{}{},
|
||||
Ref: ref("github.com/grafana/grafana/pkg/apis/datasource/v0alpha1.DataSourceSpec"),
|
||||
},
|
||||
},
|
||||
"secure": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Description: "Secure values placeholder (true for fields that exist)",
|
||||
Type: []string{"object"},
|
||||
AdditionalProperties: &spec.SchemaOrBool{
|
||||
Allows: true,
|
||||
Schema: &spec.Schema{
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Default: map[string]interface{}{},
|
||||
Ref: ref("github.com/grafana/grafana/pkg/apis/secret/v0alpha1.InlineSecureValue"),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
Required: []string{"metadata", "spec"},
|
||||
},
|
||||
},
|
||||
Dependencies: []string{
|
||||
"github.com/grafana/grafana/pkg/apis/datasource/v0alpha1.DataSourceSpec", "github.com/grafana/grafana/pkg/apis/secret/v0alpha1.InlineSecureValue", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"},
|
||||
}
|
||||
}
|
||||
|
||||
func schema_pkg_apis_datasource_v0alpha1_DataSourceConnection(ref common.ReferenceCallback) common.OpenAPIDefinition {
|
||||
return common.OpenAPIDefinition{
|
||||
Schema: spec.Schema{
|
||||
@@ -121,64 +178,7 @@ func schema_pkg_apis_datasource_v0alpha1_DataSourceConnectionList(ref common.Ref
|
||||
}
|
||||
}
|
||||
|
||||
func schema_pkg_apis_datasource_v0alpha1_GenericDataSource(ref common.ReferenceCallback) common.OpenAPIDefinition {
|
||||
return common.OpenAPIDefinition{
|
||||
Schema: spec.Schema{
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Type: []string{"object"},
|
||||
Properties: map[string]spec.Schema{
|
||||
"kind": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds",
|
||||
Type: []string{"string"},
|
||||
Format: "",
|
||||
},
|
||||
},
|
||||
"apiVersion": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources",
|
||||
Type: []string{"string"},
|
||||
Format: "",
|
||||
},
|
||||
},
|
||||
"metadata": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Default: map[string]interface{}{},
|
||||
Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"),
|
||||
},
|
||||
},
|
||||
"spec": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Description: "generic config",
|
||||
Default: map[string]interface{}{},
|
||||
Ref: ref("github.com/grafana/grafana/pkg/apis/datasource/v0alpha1.GenericDataSourceSpec"),
|
||||
},
|
||||
},
|
||||
"secure": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Description: "Secure values placeholder (true for fields that exist)",
|
||||
Type: []string{"object"},
|
||||
AdditionalProperties: &spec.SchemaOrBool{
|
||||
Allows: true,
|
||||
Schema: &spec.Schema{
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Default: map[string]interface{}{},
|
||||
Ref: ref("github.com/grafana/grafana/pkg/apis/secret/v0alpha1.InlineSecureValue"),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
Required: []string{"metadata", "spec"},
|
||||
},
|
||||
},
|
||||
Dependencies: []string{
|
||||
"github.com/grafana/grafana/pkg/apis/datasource/v0alpha1.GenericDataSourceSpec", "github.com/grafana/grafana/pkg/apis/secret/v0alpha1.InlineSecureValue", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"},
|
||||
}
|
||||
}
|
||||
|
||||
func schema_pkg_apis_datasource_v0alpha1_GenericDataSourceList(ref common.ReferenceCallback) common.OpenAPIDefinition {
|
||||
func schema_pkg_apis_datasource_v0alpha1_DataSourceList(ref common.ReferenceCallback) common.OpenAPIDefinition {
|
||||
return common.OpenAPIDefinition{
|
||||
Schema: spec.Schema{
|
||||
SchemaProps: spec.SchemaProps{
|
||||
@@ -211,7 +211,7 @@ func schema_pkg_apis_datasource_v0alpha1_GenericDataSourceList(ref common.Refere
|
||||
Schema: &spec.Schema{
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Default: map[string]interface{}{},
|
||||
Ref: ref("github.com/grafana/grafana/pkg/apis/datasource/v0alpha1.GenericDataSource"),
|
||||
Ref: ref("github.com/grafana/grafana/pkg/apis/datasource/v0alpha1.DataSource"),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -222,11 +222,11 @@ func schema_pkg_apis_datasource_v0alpha1_GenericDataSourceList(ref common.Refere
|
||||
},
|
||||
},
|
||||
Dependencies: []string{
|
||||
"github.com/grafana/grafana/pkg/apis/datasource/v0alpha1.GenericDataSource", "k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"},
|
||||
"github.com/grafana/grafana/pkg/apis/datasource/v0alpha1.DataSource", "k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"},
|
||||
}
|
||||
}
|
||||
|
||||
func schema_pkg_apis_datasource_v0alpha1_GenericDataSourceSpec(ref common.ReferenceCallback) common.OpenAPIDefinition {
|
||||
func schema_pkg_apis_datasource_v0alpha1_DataSourceSpec(ref common.ReferenceCallback) common.OpenAPIDefinition {
|
||||
return common.OpenAPIDefinition{
|
||||
Schema: spec.Schema{
|
||||
SchemaProps: spec.SchemaProps{
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
API rule violation: names_match,github.com/grafana/grafana/pkg/apis/datasource/v0alpha1,GenericDataSourceSpec,User
|
||||
API rule violation: streaming_list_type_json_tags,github.com/grafana/grafana/pkg/apis/datasource/v0alpha1,GenericDataSourceList,ListMeta
|
||||
API rule violation: names_match,github.com/grafana/grafana/pkg/apis/datasource/v0alpha1,DataSourceSpec,User
|
||||
API rule violation: streaming_list_type_json_tags,github.com/grafana/grafana/pkg/apis/datasource/v0alpha1,DataSourceList,ListMeta
|
||||
|
||||
@@ -46,8 +46,8 @@ func (r *converter) asConnection(ds *datasources.DataSource) (*v0alpha1.DataSour
|
||||
return asConnection(ds, r.mapper(ds.OrgID))
|
||||
}
|
||||
|
||||
func (r *converter) asGenericDataSource(ds *datasources.DataSource) (*v0alpha1.GenericDataSource, error) {
|
||||
cfg := &v0alpha1.GenericDataSource{
|
||||
func (r *converter) asDataSource(ds *datasources.DataSource) (*v0alpha1.DataSource, error) {
|
||||
cfg := &v0alpha1.DataSource{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: ds.UID,
|
||||
Namespace: r.mapper(ds.OrgID),
|
||||
@@ -55,7 +55,7 @@ func (r *converter) asGenericDataSource(ds *datasources.DataSource) (*v0alpha1.G
|
||||
ResourceVersion: fmt.Sprintf("%d", ds.Updated.UnixMilli()),
|
||||
Generation: int64(ds.Version),
|
||||
},
|
||||
Spec: v0alpha1.GenericDataSourceSpec{
|
||||
Spec: v0alpha1.DataSourceSpec{
|
||||
Title: ds.Name,
|
||||
Access: v0alpha1.DsAccess(ds.Access),
|
||||
URL: ds.URL,
|
||||
@@ -96,7 +96,7 @@ func (r *converter) asGenericDataSource(ds *datasources.DataSource) (*v0alpha1.G
|
||||
return cfg, nil
|
||||
}
|
||||
|
||||
func (r *converter) toAddCommand(ds *v0alpha1.GenericDataSource) (*datasources.AddDataSourceCommand, error) {
|
||||
func (r *converter) toAddCommand(ds *v0alpha1.DataSource) (*datasources.AddDataSourceCommand, error) {
|
||||
if r.group != "" && !strings.HasPrefix(ds.APIVersion, r.group) {
|
||||
return nil, fmt.Errorf("expecting APIGroup: %s", r.group)
|
||||
}
|
||||
@@ -131,7 +131,7 @@ func (r *converter) toAddCommand(ds *v0alpha1.GenericDataSource) (*datasources.A
|
||||
return cmd, nil
|
||||
}
|
||||
|
||||
func (r *converter) toUpdateCommand(ds *v0alpha1.GenericDataSource) (*datasources.UpdateDataSourceCommand, error) {
|
||||
func (r *converter) toUpdateCommand(ds *v0alpha1.DataSource) (*datasources.UpdateDataSourceCommand, error) {
|
||||
if r.group != "" && !strings.HasPrefix(ds.APIVersion, r.group) {
|
||||
return nil, fmt.Errorf("expecting APIGroup: %s", r.group)
|
||||
}
|
||||
@@ -167,7 +167,7 @@ func (r *converter) toUpdateCommand(ds *v0alpha1.GenericDataSource) (*datasource
|
||||
return cmd, nil
|
||||
}
|
||||
|
||||
func toSecureJsonData(ds *v0alpha1.GenericDataSource) map[string]string {
|
||||
func toSecureJsonData(ds *v0alpha1.DataSource) map[string]string {
|
||||
if ds == nil || len(ds.Secure) < 1 {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ import (
|
||||
|
||||
func TestConverter(t *testing.T) {
|
||||
t.Run("resource to command", func(t *testing.T) {
|
||||
obj := &v0alpha1.GenericDataSource{}
|
||||
obj := &v0alpha1.DataSource{}
|
||||
converter := converter{
|
||||
mapper: types.OrgNamespaceFormatter,
|
||||
dstype: "test-datasource",
|
||||
|
||||
@@ -62,7 +62,7 @@ func (s *legacyStorage) Get(ctx context.Context, name string, options *metav1.Ge
|
||||
|
||||
// Create implements rest.Creater.
|
||||
func (s *legacyStorage) Create(ctx context.Context, obj runtime.Object, createValidation rest.ValidateObjectFunc, options *metav1.CreateOptions) (runtime.Object, error) {
|
||||
ds, ok := obj.(*v0alpha1.GenericDataSource)
|
||||
ds, ok := obj.(*v0alpha1.DataSource)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("expected a datasource object")
|
||||
}
|
||||
@@ -81,12 +81,12 @@ func (s *legacyStorage) Update(ctx context.Context, name string, objInfo rest.Up
|
||||
return nil, false, err
|
||||
}
|
||||
|
||||
ds, ok := obj.(*v0alpha1.GenericDataSource)
|
||||
ds, ok := obj.(*v0alpha1.DataSource)
|
||||
if !ok {
|
||||
return nil, false, fmt.Errorf("expected a datasource object")
|
||||
}
|
||||
|
||||
oldDS, ok := obj.(*v0alpha1.GenericDataSource)
|
||||
oldDS, ok := obj.(*v0alpha1.DataSource)
|
||||
if !ok {
|
||||
return nil, false, fmt.Errorf("expected a datasource object (old)")
|
||||
}
|
||||
|
||||
@@ -25,16 +25,16 @@ type PluginDatasourceProvider interface {
|
||||
ListConnections(ctx context.Context) (*v0alpha1.DataSourceConnectionList, error)
|
||||
|
||||
// Get a single datasurce
|
||||
GetDataSource(ctx context.Context, uid string) (*v0alpha1.GenericDataSource, error)
|
||||
GetDataSource(ctx context.Context, uid string) (*v0alpha1.DataSource, error)
|
||||
|
||||
// List all datasources
|
||||
ListDataSource(ctx context.Context) (*v0alpha1.GenericDataSourceList, error)
|
||||
ListDataSource(ctx context.Context) (*v0alpha1.DataSourceList, error)
|
||||
|
||||
// Create a data source
|
||||
CreateDataSource(ctx context.Context, ds *v0alpha1.GenericDataSource) (*v0alpha1.GenericDataSource, error)
|
||||
CreateDataSource(ctx context.Context, ds *v0alpha1.DataSource) (*v0alpha1.DataSource, error)
|
||||
|
||||
// Update a data source
|
||||
UpdateDataSource(ctx context.Context, ds *v0alpha1.GenericDataSource) (*v0alpha1.GenericDataSource, error)
|
||||
UpdateDataSource(ctx context.Context, ds *v0alpha1.DataSource) (*v0alpha1.DataSource, error)
|
||||
|
||||
// Delete datasurce
|
||||
Delete(ctx context.Context, uid string) error
|
||||
@@ -146,7 +146,7 @@ func (q *scopedDatasourceProvider) GetInstanceSettings(ctx context.Context, uid
|
||||
}
|
||||
|
||||
// CreateDataSource implements PluginDatasourceProvider.
|
||||
func (q *scopedDatasourceProvider) CreateDataSource(ctx context.Context, ds *v0alpha1.GenericDataSource) (*v0alpha1.GenericDataSource, error) {
|
||||
func (q *scopedDatasourceProvider) CreateDataSource(ctx context.Context, ds *v0alpha1.DataSource) (*v0alpha1.DataSource, error) {
|
||||
cmd, err := q.converter.toAddCommand(ds)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -155,11 +155,11 @@ func (q *scopedDatasourceProvider) CreateDataSource(ctx context.Context, ds *v0a
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return q.converter.asGenericDataSource(out)
|
||||
return q.converter.asDataSource(out)
|
||||
}
|
||||
|
||||
// UpdateDataSource implements PluginDatasourceProvider.
|
||||
func (q *scopedDatasourceProvider) UpdateDataSource(ctx context.Context, ds *v0alpha1.GenericDataSource) (*v0alpha1.GenericDataSource, error) {
|
||||
func (q *scopedDatasourceProvider) UpdateDataSource(ctx context.Context, ds *v0alpha1.DataSource) (*v0alpha1.DataSource, error) {
|
||||
cmd, err := q.converter.toUpdateCommand(ds)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -168,7 +168,7 @@ func (q *scopedDatasourceProvider) UpdateDataSource(ctx context.Context, ds *v0a
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return q.converter.asGenericDataSource(out)
|
||||
return q.converter.asDataSource(out)
|
||||
}
|
||||
|
||||
// Delete implements PluginDatasourceProvider.
|
||||
@@ -193,7 +193,7 @@ func (q *scopedDatasourceProvider) Delete(ctx context.Context, uid string) error
|
||||
}
|
||||
|
||||
// GetDataSource implements PluginDatasourceProvider.
|
||||
func (q *scopedDatasourceProvider) GetDataSource(ctx context.Context, uid string) (*v0alpha1.GenericDataSource, error) {
|
||||
func (q *scopedDatasourceProvider) GetDataSource(ctx context.Context, uid string) (*v0alpha1.DataSource, error) {
|
||||
user, err := identity.GetRequester(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -202,11 +202,11 @@ func (q *scopedDatasourceProvider) GetDataSource(ctx context.Context, uid string
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return q.converter.asGenericDataSource(ds)
|
||||
return q.converter.asDataSource(ds)
|
||||
}
|
||||
|
||||
// ListDataSource implements PluginDatasourceProvider.
|
||||
func (q *scopedDatasourceProvider) ListDataSource(ctx context.Context) (*v0alpha1.GenericDataSourceList, error) {
|
||||
func (q *scopedDatasourceProvider) ListDataSource(ctx context.Context) (*v0alpha1.DataSourceList, error) {
|
||||
info, err := request.NamespaceInfoFrom(ctx, true)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -220,11 +220,11 @@ func (q *scopedDatasourceProvider) ListDataSource(ctx context.Context) (*v0alpha
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result := &v0alpha1.GenericDataSourceList{
|
||||
Items: []v0alpha1.GenericDataSource{},
|
||||
result := &v0alpha1.DataSourceList{
|
||||
Items: []v0alpha1.DataSource{},
|
||||
}
|
||||
for _, ds := range dss {
|
||||
v, _ := q.converter.asGenericDataSource(ds)
|
||||
v, _ := q.converter.asDataSource(ds)
|
||||
result.Items = append(result.Items, *v)
|
||||
}
|
||||
return result, nil
|
||||
|
||||
@@ -122,8 +122,8 @@ func NewDataSourceAPIBuilder(
|
||||
}
|
||||
|
||||
builder := &DataSourceAPIBuilder{
|
||||
connectionResourceInfo: datasource.GenericConnectionResourceInfo.WithGroupAndShortName(group, plugin.ID+"-connection"),
|
||||
datasourceResourceInfo: datasource.GenericDataSourceResourceInfo.WithGroupAndShortName(group, plugin.ID),
|
||||
connectionResourceInfo: datasource.ConnectionResourceInfo.WithGroupAndShortName(group, plugin.ID+"-connection"),
|
||||
datasourceResourceInfo: datasource.DataSourceResourceInfo.WithGroupAndShortName(group, plugin.ID),
|
||||
pluginJSON: plugin,
|
||||
client: client,
|
||||
datasources: datasources,
|
||||
@@ -167,8 +167,8 @@ func addKnownTypes(scheme *runtime.Scheme, gv schema.GroupVersion) {
|
||||
scheme.AddKnownTypes(gv,
|
||||
&datasource.DataSourceConnection{},
|
||||
&datasource.DataSourceConnectionList{},
|
||||
&datasource.GenericDataSource{},
|
||||
&datasource.GenericDataSourceList{},
|
||||
&datasource.DataSource{},
|
||||
&datasource.DataSourceList{},
|
||||
&datasource.HealthCheckResult{},
|
||||
&unstructured.Unstructured{},
|
||||
|
||||
|
||||
@@ -122,12 +122,12 @@ type mockDatasources struct {
|
||||
}
|
||||
|
||||
// CreateDataSource implements PluginDatasourceProvider.
|
||||
func (m mockDatasources) CreateDataSource(ctx context.Context, ds *v0alpha1.GenericDataSource) (*v0alpha1.GenericDataSource, error) {
|
||||
func (m mockDatasources) CreateDataSource(ctx context.Context, ds *v0alpha1.DataSource) (*v0alpha1.DataSource, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// UpdateDataSource implements PluginDatasourceProvider.
|
||||
func (m mockDatasources) UpdateDataSource(ctx context.Context, ds *v0alpha1.GenericDataSource) (*v0alpha1.GenericDataSource, error) {
|
||||
func (m mockDatasources) UpdateDataSource(ctx context.Context, ds *v0alpha1.DataSource) (*v0alpha1.DataSource, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
@@ -137,12 +137,12 @@ func (m mockDatasources) Delete(ctx context.Context, uid string) error {
|
||||
}
|
||||
|
||||
// GetDataSource implements PluginDatasourceProvider.
|
||||
func (m mockDatasources) GetDataSource(ctx context.Context, uid string) (*v0alpha1.GenericDataSource, error) {
|
||||
func (m mockDatasources) GetDataSource(ctx context.Context, uid string) (*v0alpha1.DataSource, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// ListDataSource implements PluginDatasourceProvider.
|
||||
func (m mockDatasources) ListDataSource(ctx context.Context) (*v0alpha1.GenericDataSourceList, error) {
|
||||
func (m mockDatasources) ListDataSource(ctx context.Context) (*v0alpha1.DataSourceList, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user