mirror of https://github.com/grafana/grafana
K8s: Move shared apis to a common folder with shared openapi spec (#80484)
parent
81c45bfe44
commit
bb05a6f58f
@ -0,0 +1,4 @@ |
||||
// +k8s:openapi-gen=true
|
||||
// +groupName=common.grafana.app
|
||||
|
||||
package v0alpha1 // import "github.com/grafana/grafana/pkg/apis/common/v0alpha1"
|
@ -0,0 +1,19 @@ |
||||
//go:build !ignore_autogenerated
|
||||
// +build !ignore_autogenerated
|
||||
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
// Code generated by defaulter-gen. DO NOT EDIT.
|
||||
|
||||
package v0alpha1 |
||||
|
||||
import ( |
||||
runtime "k8s.io/apimachinery/pkg/runtime" |
||||
) |
||||
|
||||
// RegisterDefaults adds defaulters functions to the given scheme.
|
||||
// Public to allow building arbitrary schemes.
|
||||
// All generated defaulters are covering - they call all nested defaulters.
|
||||
func RegisterDefaults(scheme *runtime.Scheme) error { |
||||
return nil |
||||
} |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,31 @@ |
||||
package v0alpha1 |
||||
|
||||
import ( |
||||
"k8s.io/apimachinery/pkg/runtime" |
||||
"k8s.io/apimachinery/pkg/runtime/schema" |
||||
|
||||
common "github.com/grafana/grafana/pkg/apis/common/v0alpha1" |
||||
) |
||||
|
||||
const ( |
||||
GROUP = "dashboard.grafana.app" |
||||
VERSION = "v0alpha1" |
||||
APIVERSION = GROUP + "/" + VERSION |
||||
) |
||||
|
||||
var DashboardResourceInfo = common.NewResourceInfo(GROUP, VERSION, |
||||
"dashboards", "dashboard", "Dashboard", |
||||
func() runtime.Object { return &Dashboard{} }, |
||||
func() runtime.Object { return &DashboardList{} }, |
||||
) |
||||
|
||||
var DashboardSummaryResourceInfo = common.NewResourceInfo(GROUP, VERSION, |
||||
"summary", "summary", "DashboardSummary", |
||||
func() runtime.Object { return &DashboardSummary{} }, |
||||
func() runtime.Object { return &DashboardSummaryList{} }, |
||||
) |
||||
|
||||
var ( |
||||
// SchemeGroupVersion is group version used to register these objects
|
||||
SchemeGroupVersion = schema.GroupVersion{Group: GROUP, Version: VERSION} |
||||
) |
@ -0,0 +1,18 @@ |
||||
package v0alpha1 |
||||
|
||||
import ( |
||||
"k8s.io/apimachinery/pkg/runtime" |
||||
|
||||
common "github.com/grafana/grafana/pkg/apis/common/v0alpha1" |
||||
) |
||||
|
||||
const ( |
||||
GROUP = "*.datasource.grafana.app" |
||||
VERSION = "v0alpha1" |
||||
) |
||||
|
||||
var GenericConnectionResourceInfo = common.NewResourceInfo(GROUP, VERSION, |
||||
"connections", "connection", "DataSourceConnection", |
||||
func() runtime.Object { return &DataSourceConnection{} }, |
||||
func() runtime.Object { return &DataSourceConnectionList{} }, |
||||
) |
@ -1,100 +0,0 @@ |
||||
package v0alpha1 |
||||
|
||||
import ( |
||||
"encoding/json" |
||||
|
||||
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" |
||||
runtime "k8s.io/apimachinery/pkg/runtime" |
||||
) |
||||
|
||||
// Unstructured allows objects that do not have Golang structs registered to be manipulated
|
||||
// generically.
|
||||
type Unstructured struct { |
||||
// Object is a JSON compatible map with string, float, int, bool, []interface{}, or
|
||||
// map[string]interface{}
|
||||
// children.
|
||||
Object map[string]interface{} |
||||
} |
||||
|
||||
func (u *Unstructured) UnstructuredContent() map[string]interface{} { |
||||
if u.Object == nil { |
||||
return make(map[string]interface{}) |
||||
} |
||||
return u.Object |
||||
} |
||||
|
||||
func (u *Unstructured) SetUnstructuredContent(content map[string]interface{}) { |
||||
u.Object = content |
||||
} |
||||
|
||||
// MarshalJSON ensures that the unstructured object produces proper
|
||||
// JSON when passed to Go's standard JSON library.
|
||||
func (u *Unstructured) MarshalJSON() ([]byte, error) { |
||||
return json.Marshal(u.Object) |
||||
} |
||||
|
||||
// UnmarshalJSON ensures that the unstructured object properly decodes
|
||||
// JSON when passed to Go's standard JSON library.
|
||||
func (u *Unstructured) UnmarshalJSON(b []byte) error { |
||||
return json.Unmarshal(b, &u.Object) |
||||
} |
||||
|
||||
func (u *Unstructured) DeepCopy() *Unstructured { |
||||
if u == nil { |
||||
return nil |
||||
} |
||||
out := new(Unstructured) |
||||
*out = *u |
||||
out.Object = runtime.DeepCopyJSON(u.Object) |
||||
return out |
||||
} |
||||
|
||||
func (u *Unstructured) DeepCopyInto(out *Unstructured) { |
||||
clone := u.DeepCopy() |
||||
*out = *clone |
||||
} |
||||
|
||||
func (u *Unstructured) Set(field string, value interface{}) { |
||||
if u.Object == nil { |
||||
u.Object = make(map[string]interface{}) |
||||
} |
||||
_ = unstructured.SetNestedField(u.Object, value, field) |
||||
} |
||||
|
||||
func (u *Unstructured) Remove(fields ...string) { |
||||
if u.Object == nil { |
||||
u.Object = make(map[string]interface{}) |
||||
} |
||||
unstructured.RemoveNestedField(u.Object, fields...) |
||||
} |
||||
|
||||
func (u *Unstructured) SetNestedField(value interface{}, fields ...string) { |
||||
if u.Object == nil { |
||||
u.Object = make(map[string]interface{}) |
||||
} |
||||
_ = unstructured.SetNestedField(u.Object, value, fields...) |
||||
} |
||||
|
||||
func (u *Unstructured) GetNestedString(fields ...string) string { |
||||
val, found, err := unstructured.NestedString(u.Object, fields...) |
||||
if !found || err != nil { |
||||
return "" |
||||
} |
||||
return val |
||||
} |
||||
|
||||
func (u *Unstructured) GetNestedStringSlice(fields ...string) []string { |
||||
val, found, err := unstructured.NestedStringSlice(u.Object, fields...) |
||||
if !found || err != nil { |
||||
return nil |
||||
} |
||||
return val |
||||
} |
||||
|
||||
func (u *Unstructured) GetNestedInt64(fields ...string) int64 { |
||||
val, found, err := unstructured.NestedInt64(u.Object, fields...) |
||||
if !found || err != nil { |
||||
return 0 |
||||
} |
||||
return val |
||||
} |
@ -0,0 +1,30 @@ |
||||
package v0alpha1 |
||||
|
||||
import ( |
||||
"k8s.io/apimachinery/pkg/runtime" |
||||
"k8s.io/apimachinery/pkg/runtime/schema" |
||||
|
||||
common "github.com/grafana/grafana/pkg/apis/common/v0alpha1" |
||||
) |
||||
|
||||
const ( |
||||
GROUP = "example.grafana.app" |
||||
VERSION = "v0alpha1" |
||||
APIVERSION = GROUP + "/" + VERSION |
||||
) |
||||
|
||||
var RuntimeResourceInfo = common.NewResourceInfo(GROUP, VERSION, |
||||
"runtime", "runtime", "RuntimeInfo", |
||||
func() runtime.Object { return &RuntimeInfo{} }, |
||||
func() runtime.Object { return &RuntimeInfo{} }, |
||||
) |
||||
var DummyResourceInfo = common.NewResourceInfo(GROUP, VERSION, |
||||
"dummy", "dummy", "DummyResource", |
||||
func() runtime.Object { return &DummyResource{} }, |
||||
func() runtime.Object { return &DummyResourceList{} }, |
||||
) |
||||
|
||||
var ( |
||||
// SchemeGroupVersion is group version used to register these objects
|
||||
SchemeGroupVersion = schema.GroupVersion{Group: GROUP, Version: VERSION} |
||||
) |
@ -0,0 +1,26 @@ |
||||
package v0alpha1 |
||||
|
||||
import ( |
||||
"k8s.io/apimachinery/pkg/runtime" |
||||
"k8s.io/apimachinery/pkg/runtime/schema" |
||||
|
||||
common "github.com/grafana/grafana/pkg/apis/common/v0alpha1" |
||||
) |
||||
|
||||
const ( |
||||
GROUP = "folders.grafana.app" |
||||
VERSION = "v0alpha1" |
||||
RESOURCE = "folders" |
||||
APIVERSION = GROUP + "/" + VERSION |
||||
) |
||||
|
||||
var FolderResourceInfo = common.NewResourceInfo(GROUP, VERSION, |
||||
RESOURCE, "folder", "Folder", |
||||
func() runtime.Object { return &Folder{} }, |
||||
func() runtime.Object { return &FolderList{} }, |
||||
) |
||||
|
||||
var ( |
||||
// SchemeGroupVersion is group version used to register these objects
|
||||
SchemeGroupVersion = schema.GroupVersion{Group: GROUP, Version: VERSION} |
||||
) |
@ -0,0 +1,25 @@ |
||||
package v0alpha1 |
||||
|
||||
import ( |
||||
"k8s.io/apimachinery/pkg/runtime" |
||||
"k8s.io/apimachinery/pkg/runtime/schema" |
||||
|
||||
common "github.com/grafana/grafana/pkg/apis/common/v0alpha1" |
||||
) |
||||
|
||||
const ( |
||||
GROUP = "playlist.grafana.app" |
||||
VERSION = "v0alpha1" |
||||
APIVERSION = GROUP + "/" + VERSION |
||||
) |
||||
|
||||
var PlaylistResourceInfo = common.NewResourceInfo(GROUP, VERSION, |
||||
"playlists", "playlist", "Playlist", |
||||
func() runtime.Object { return &Playlist{} }, |
||||
func() runtime.Object { return &PlaylistList{} }, |
||||
) |
||||
|
||||
var ( |
||||
// SchemeGroupVersion is group version used to register these objects
|
||||
SchemeGroupVersion = schema.GroupVersion{Group: GROUP, Version: VERSION} |
||||
) |
Loading…
Reference in new issue