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
|
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||||
type DataSourceConnectionList struct {
|
type DataSourceConnectionList struct {
|
||||||
metav1.TypeMeta `json:",inline"`
|
metav1.TypeMeta `json:",inline"`
|
||||||
// +optional
|
|
||||||
metav1.ListMeta `json:"metadata,omitempty"`
|
metav1.ListMeta `json:"metadata,omitempty"`
|
||||||
|
|
||||||
Items []DataSourceConnection `json:"items,omitempty"`
|
Items []DataSourceConnection `json:"items,omitempty"`
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ package v0alpha1
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
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"
|
// Mirrors the info exposed in "github.com/grafana/grafana/pkg/setting"
|
||||||
@@ -26,13 +28,12 @@ type DummyResource struct {
|
|||||||
metav1.TypeMeta `json:",inline"`
|
metav1.TypeMeta `json:",inline"`
|
||||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
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
|
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||||
type DummyResourceList struct {
|
type DummyResourceList struct {
|
||||||
metav1.TypeMeta `json:",inline"`
|
metav1.TypeMeta `json:",inline"`
|
||||||
// +optional
|
|
||||||
metav1.ListMeta `json:"metadata,omitempty"`
|
metav1.ListMeta `json:"metadata,omitempty"`
|
||||||
|
|
||||||
Items []DummyResource `json:"items,omitempty"`
|
Items []DummyResource `json:"items,omitempty"`
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ func (in *DummyResource) DeepCopyInto(out *DummyResource) {
|
|||||||
*out = *in
|
*out = *in
|
||||||
out.TypeMeta = in.TypeMeta
|
out.TypeMeta = in.TypeMeta
|
||||||
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
|
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
|
||||||
|
in.Spec.DeepCopyInto(&out.Spec)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -51,15 +51,14 @@ func schema_pkg_apis_example_v0alpha1_DummyResource(ref common.ReferenceCallback
|
|||||||
},
|
},
|
||||||
"spec": {
|
"spec": {
|
||||||
SchemaProps: spec.SchemaProps{
|
SchemaProps: spec.SchemaProps{
|
||||||
Type: []string{"string"},
|
Ref: ref("github.com/grafana/grafana/pkg/apis/common/v0alpha1.Unstructured"),
|
||||||
Format: "",
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Dependencies: []string{
|
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{
|
Properties: map[string]spec.Schema{
|
||||||
"path": {
|
"path": {
|
||||||
SchemaProps: spec.SchemaProps{
|
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: "",
|
Default: "",
|
||||||
Type: []string{"string"},
|
Type: []string{"string"},
|
||||||
Format: "",
|
Format: "",
|
||||||
|
|||||||
@@ -36,12 +36,16 @@ type Spec struct {
|
|||||||
Items []Item `json:"items,omitempty"`
|
Items []Item `json:"items,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Type of the item.
|
||||||
|
// +enum
|
||||||
|
type ItemType string
|
||||||
|
|
||||||
// Defines values for ItemType.
|
// Defines values for ItemType.
|
||||||
const (
|
const (
|
||||||
ItemTypeDashboardByTag ItemType = "dashboard_by_tag"
|
ItemTypeDashboardByTag ItemType = "dashboard_by_tag"
|
||||||
ItemTypeDashboardByUid ItemType = "dashboard_by_uid"
|
ItemTypeDashboardByUid ItemType = "dashboard_by_uid"
|
||||||
|
|
||||||
// deprecated -- should use UID
|
// Deprecated -- should use UID
|
||||||
ItemTypeDashboardById ItemType = "dashboard_by_id"
|
ItemTypeDashboardById ItemType = "dashboard_by_id"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -60,6 +64,3 @@ type Item struct {
|
|||||||
// - dashboard_by_uid: The value is the dashboard UID
|
// - dashboard_by_uid: The value is the dashboard UID
|
||||||
Value string `json:"value"`
|
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{
|
Properties: map[string]spec.Schema{
|
||||||
"type": {
|
"type": {
|
||||||
SchemaProps: spec.SchemaProps{
|
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: "",
|
Default: "",
|
||||||
Type: []string{"string"},
|
Type: []string{"string"},
|
||||||
Format: "",
|
Format: "",
|
||||||
|
Enum: []interface{}{"dashboard_by_id", "dashboard_by_tag", "dashboard_by_uid"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"value": {
|
"value": {
|
||||||
|
|||||||
@@ -3,4 +3,4 @@
|
|||||||
// +k8s:defaulter-gen=TypeMeta
|
// +k8s:defaulter-gen=TypeMeta
|
||||||
// +groupName=query.grafana.app
|
// +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",
|
Short: "Run the grafana apiserver",
|
||||||
Long: "Run a standalone kubernetes based apiserver that can be aggregated by a root apiserver. " +
|
Long: "Run a standalone kubernetes based apiserver that can be aggregated by a root apiserver. " +
|
||||||
devAcknowledgementNotice,
|
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 {
|
RunE: func(c *cobra.Command, args []string) error {
|
||||||
runtime, err := standalone.ReadRuntimeConfig(runtimeConfig)
|
runtime, err := standalone.ReadRuntimeConfig(runtimeConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import (
|
|||||||
genericregistry "k8s.io/apiserver/pkg/registry/generic/registry"
|
genericregistry "k8s.io/apiserver/pkg/registry/generic/registry"
|
||||||
"k8s.io/apiserver/pkg/registry/rest"
|
"k8s.io/apiserver/pkg/registry/rest"
|
||||||
|
|
||||||
|
common "github.com/grafana/grafana/pkg/apis/common/v0alpha1"
|
||||||
example "github.com/grafana/grafana/pkg/apis/example/v0alpha1"
|
example "github.com/grafana/grafana/pkg/apis/example/v0alpha1"
|
||||||
grafanarequest "github.com/grafana/grafana/pkg/services/apiserver/endpoints/request"
|
grafanarequest "github.com/grafana/grafana/pkg/services/apiserver/endpoints/request"
|
||||||
grafanaregistry "github.com/grafana/grafana/pkg/services/apiserver/registry/generic"
|
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,
|
CreationTimestamp: s.creationTimestamp,
|
||||||
ResourceVersion: "1",
|
ResourceVersion: "1",
|
||||||
},
|
},
|
||||||
Spec: fmt.Sprintf("dummy: %s", name),
|
Spec: common.Unstructured{
|
||||||
|
Object: map[string]any{
|
||||||
|
"Dummy": name,
|
||||||
|
},
|
||||||
|
},
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,7 +117,11 @@ func (s *dummyStorage) List(ctx context.Context, options *internalversion.ListOp
|
|||||||
CreationTimestamp: s.creationTimestamp,
|
CreationTimestamp: s.creationTimestamp,
|
||||||
ResourceVersion: "1",
|
ResourceVersion: "1",
|
||||||
},
|
},
|
||||||
Spec: fmt.Sprintf("dummy: %s", name),
|
Spec: common.Unstructured{
|
||||||
|
Object: map[string]any{
|
||||||
|
"Dummy": name,
|
||||||
|
},
|
||||||
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return res, nil
|
return res, nil
|
||||||
|
|||||||
Reference in New Issue
Block a user