mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
K8s: use +enum tag in playlist and unstructured dummy (#82022)
This commit is contained in:
@@ -21,7 +21,6 @@ type DataSourceConnection struct {
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
type DataSourceConnectionList struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
// +optional
|
||||
metav1.ListMeta `json:"metadata,omitempty"`
|
||||
|
||||
Items []DataSourceConnection `json:"items,omitempty"`
|
||||
|
||||
@@ -2,6 +2,8 @@ package v0alpha1
|
||||
|
||||
import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
common "github.com/grafana/grafana/pkg/apis/common/v0alpha1"
|
||||
)
|
||||
|
||||
// Mirrors the info exposed in "github.com/grafana/grafana/pkg/setting"
|
||||
@@ -26,13 +28,12 @@ type DummyResource struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
|
||||
Spec string `json:"spec,omitempty"`
|
||||
Spec common.Unstructured `json:"spec,omitempty"`
|
||||
}
|
||||
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
type DummyResourceList struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
// +optional
|
||||
metav1.ListMeta `json:"metadata,omitempty"`
|
||||
|
||||
Items []DummyResource `json:"items,omitempty"`
|
||||
|
||||
@@ -16,6 +16,7 @@ func (in *DummyResource) DeepCopyInto(out *DummyResource) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
|
||||
in.Spec.DeepCopyInto(&out.Spec)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -51,15 +51,14 @@ func schema_pkg_apis_example_v0alpha1_DummyResource(ref common.ReferenceCallback
|
||||
},
|
||||
"spec": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Type: []string{"string"},
|
||||
Format: "",
|
||||
Ref: ref("github.com/grafana/grafana/pkg/apis/common/v0alpha1.Unstructured"),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
Dependencies: []string{
|
||||
"k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"},
|
||||
"github.com/grafana/grafana/pkg/apis/common/v0alpha1.Unstructured", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -407,7 +407,7 @@ func schema_pkg_apis_peakq_v0alpha1_VariableReplacement(ref common.ReferenceCall
|
||||
Properties: map[string]spec.Schema{
|
||||
"path": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Description: "Path is the location of the property within the the target properties. The format for this is not figured out yet (Maybe JSONPath?). Idea: [\"string\", int, \"string\"] where int indicates array offset",
|
||||
Description: "Path is the location of the property within a target. The format for this is not figured out yet (Maybe JSONPath?). Idea: [\"string\", int, \"string\"] where int indicates array offset",
|
||||
Default: "",
|
||||
Type: []string{"string"},
|
||||
Format: "",
|
||||
|
||||
@@ -36,12 +36,16 @@ type Spec struct {
|
||||
Items []Item `json:"items,omitempty"`
|
||||
}
|
||||
|
||||
// Type of the item.
|
||||
// +enum
|
||||
type ItemType string
|
||||
|
||||
// Defines values for ItemType.
|
||||
const (
|
||||
ItemTypeDashboardByTag ItemType = "dashboard_by_tag"
|
||||
ItemTypeDashboardByUid ItemType = "dashboard_by_uid"
|
||||
|
||||
// deprecated -- should use UID
|
||||
// Deprecated -- should use UID
|
||||
ItemTypeDashboardById ItemType = "dashboard_by_id"
|
||||
)
|
||||
|
||||
@@ -60,6 +64,3 @@ type Item struct {
|
||||
// - dashboard_by_uid: The value is the dashboard UID
|
||||
Value string `json:"value"`
|
||||
}
|
||||
|
||||
// Type of the item.
|
||||
type ItemType string
|
||||
|
||||
@@ -32,10 +32,11 @@ func schema_pkg_apis_playlist_v0alpha1_Item(ref common.ReferenceCallback) common
|
||||
Properties: map[string]spec.Schema{
|
||||
"type": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Description: "Type of the item.",
|
||||
Description: "Type of the item.\n\nPossible enum values:\n - `\"dashboard_by_id\"` Deprecated -- should use UID\n - `\"dashboard_by_tag\"`\n - `\"dashboard_by_uid\"`",
|
||||
Default: "",
|
||||
Type: []string{"string"},
|
||||
Format: "",
|
||||
Enum: []interface{}{"dashboard_by_id", "dashboard_by_tag", "dashboard_by_uid"},
|
||||
},
|
||||
},
|
||||
"value": {
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
// +k8s:defaulter-gen=TypeMeta
|
||||
// +groupName=query.grafana.app
|
||||
|
||||
package v0alpha1
|
||||
package v0alpha1 // import "github.com/grafana/grafana/pkg/apis/query/v0alpha1"
|
||||
|
||||
@@ -28,7 +28,7 @@ func newCommandStartExampleAPIServer(o *APIServerOptions, stopCh <-chan struct{}
|
||||
Short: "Run the grafana apiserver",
|
||||
Long: "Run a standalone kubernetes based apiserver that can be aggregated by a root apiserver. " +
|
||||
devAcknowledgementNotice,
|
||||
Example: "grafana apiserver example.grafana.app",
|
||||
Example: "grafana apiserver --runtime-config=example.grafana.app/v0alpha1=true",
|
||||
RunE: func(c *cobra.Command, args []string) error {
|
||||
runtime, err := standalone.ReadRuntimeConfig(runtimeConfig)
|
||||
if err != nil {
|
||||
|
||||
@@ -12,6 +12,7 @@ import (
|
||||
genericregistry "k8s.io/apiserver/pkg/registry/generic/registry"
|
||||
"k8s.io/apiserver/pkg/registry/rest"
|
||||
|
||||
common "github.com/grafana/grafana/pkg/apis/common/v0alpha1"
|
||||
example "github.com/grafana/grafana/pkg/apis/example/v0alpha1"
|
||||
grafanarequest "github.com/grafana/grafana/pkg/services/apiserver/endpoints/request"
|
||||
grafanaregistry "github.com/grafana/grafana/pkg/services/apiserver/registry/generic"
|
||||
@@ -93,7 +94,11 @@ func (s *dummyStorage) Get(ctx context.Context, name string, options *metav1.Get
|
||||
CreationTimestamp: s.creationTimestamp,
|
||||
ResourceVersion: "1",
|
||||
},
|
||||
Spec: fmt.Sprintf("dummy: %s", name),
|
||||
Spec: common.Unstructured{
|
||||
Object: map[string]any{
|
||||
"Dummy": name,
|
||||
},
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -112,7 +117,11 @@ func (s *dummyStorage) List(ctx context.Context, options *internalversion.ListOp
|
||||
CreationTimestamp: s.creationTimestamp,
|
||||
ResourceVersion: "1",
|
||||
},
|
||||
Spec: fmt.Sprintf("dummy: %s", name),
|
||||
Spec: common.Unstructured{
|
||||
Object: map[string]any{
|
||||
"Dummy": name,
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
return res, nil
|
||||
|
||||
Reference in New Issue
Block a user