feat: replace config kind with noop kind

This commit is contained in:
Mariell Hoversholm committed 2024-11-13 08:39:26 +01:00
1 parent f2fb4673df
commit 77e9a61fe7
11 files changed
+145 -140

No files matched your search

+2 -2
View File
@@ -1,8 +1,8 @@
package core
externalName: {
kind: "Config"
pluralName: "Configs"
kind: "NoOp"
pluralName: "NoOps"
group: "gituisync"
apiResource: {
groupOverride: "gituisync.grafana.app"
@@ -1,34 +0,0 @@
//
// Code generated by grafana-app-sdk. DO NOT EDIT.
//
package v0alpha1
import (
"github.com/grafana/grafana-app-sdk/resource"
)
// schema is unexported to prevent accidental overwrites
var (
schemaConfig = resource.NewSimpleSchema("gituisync.grafana.app", "v0alpha1", &Config{}, &ConfigList{}, resource.WithKind("Config"),
resource.WithPlural("configs"), resource.WithScope(resource.NamespacedScope))
kindConfig = resource.Kind{
Schema: schemaConfig,
Codecs: map[resource.KindEncoding]resource.Codec{
resource.KindEncodingJSON: &ConfigJSONCodec{},
},
}
)
// Kind returns a resource.Kind for this Schema with a JSON codec
func ConfigKind() resource.Kind {
return kindConfig
}
// Schema returns a resource.SimpleSchema representation of Config
func ConfigSchema() *resource.SimpleSchema {
return schemaConfig
}
// Interface compliance checks
var _ resource.Schema = kindConfig
@@ -11,18 +11,18 @@ import (
"github.com/grafana/grafana-app-sdk/resource"
)
// ConfigJSONCodec is an implementation of resource.Codec for kubernetes JSON encoding
type ConfigJSONCodec struct{}
// NoOpJSONCodec is an implementation of resource.Codec for kubernetes JSON encoding
type NoOpJSONCodec struct{}
// Read reads JSON-encoded bytes from `reader` and unmarshals them into `into`
func (*ConfigJSONCodec) Read(reader io.Reader, into resource.Object) error {
func (*NoOpJSONCodec) 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 (*ConfigJSONCodec) Write(writer io.Writer, from resource.Object) error {
func (*NoOpJSONCodec) Write(writer io.Writer, from resource.Object) error {
return json.NewEncoder(writer).Encode(from)
}
// Interface compliance checks
var _ resource.Codec = &ConfigJSONCodec{}
var _ resource.Codec = &NoOpJSONCodec{}
@@ -4,8 +4,8 @@ import (
"time"
)
// ConfigMetadata defines model for ConfigMetadata.
type ConfigMetadata struct {
// NoOpMetadata defines model for NoOpMetadata.
type NoOpMetadata struct {
CreatedBy string `json:"createdBy"`
CreationTimestamp time.Time `json:"creationTimestamp"`
DeletionTimestamp *time.Time `json:"deletionTimestamp,omitempty"`
@@ -21,7 +21,7 @@ type ConfigMetadata struct {
// _kubeObjectMetadata is metadata found in a kubernetes object's metadata field.
// It is not exhaustive and only includes fields which may be relevant to a kind's implementation,
// As it is also intended to be generic enough to function with any API Server.
type ConfigKubeObjectMetadata struct {
type NoOpKubeObjectMetadata struct {
CreationTimestamp time.Time `json:"creationTimestamp"`
DeletionTimestamp *time.Time `json:"deletionTimestamp,omitempty"`
Finalizers []string `json:"finalizers"`
@@ -15,19 +15,19 @@ import (
)
// +k8s:openapi-gen=true
type Config struct {
type NoOp struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata"`
Spec ConfigSpec `json:"spec"`
ConfigStatus ConfigStatus `json:"status"`
Spec NoOpSpec `json:"spec"`
NoOpStatus NoOpStatus `json:"status"`
}
func (o *Config) GetSpec() any {
func (o *NoOp) GetSpec() any {
return o.Spec
}
func (o *Config) SetSpec(spec any) error {
cast, ok := spec.(ConfigSpec)
func (o *NoOp) SetSpec(spec any) error {
cast, ok := spec.(NoOpSpec)
if !ok {
return fmt.Errorf("cannot set spec type %#v, not of type Spec", spec)
}
@@ -35,36 +35,36 @@ func (o *Config) SetSpec(spec any) error {
return nil
}
func (o *Config) GetSubresources() map[string]any {
func (o *NoOp) GetSubresources() map[string]any {
return map[string]any{
"status": o.ConfigStatus,
"status": o.NoOpStatus,
}
}
func (o *Config) GetSubresource(name string) (any, bool) {
func (o *NoOp) GetSubresource(name string) (any, bool) {
switch name {
case "status":
return o.ConfigStatus, true
return o.NoOpStatus, true
default:
return nil, false
}
}
func (o *Config) SetSubresource(name string, value any) error {
func (o *NoOp) SetSubresource(name string, value any) error {
switch name {
case "status":
cast, ok := value.(ConfigStatus)
cast, ok := value.(NoOpStatus)
if !ok {
return fmt.Errorf("cannot set status type %#v, not of type ConfigStatus", value)
return fmt.Errorf("cannot set status type %#v, not of type NoOpStatus", value)
}
o.ConfigStatus = cast
o.NoOpStatus = cast
return nil
default:
return fmt.Errorf("subresource '%s' does not exist", name)
}
}
func (o *Config) GetStaticMetadata() resource.StaticMetadata {
func (o *NoOp) GetStaticMetadata() resource.StaticMetadata {
gvk := o.GroupVersionKind()
return resource.StaticMetadata{
Name: o.ObjectMeta.Name,
@@ -75,7 +75,7 @@ func (o *Config) GetStaticMetadata() resource.StaticMetadata {
}
}
func (o *Config) SetStaticMetadata(metadata resource.StaticMetadata) {
func (o *NoOp) SetStaticMetadata(metadata resource.StaticMetadata) {
o.Name = metadata.Name
o.Namespace = metadata.Namespace
o.SetGroupVersionKind(schema.GroupVersionKind{
@@ -85,7 +85,7 @@ func (o *Config) SetStaticMetadata(metadata resource.StaticMetadata) {
})
}
func (o *Config) GetCommonMetadata() resource.CommonMetadata {
func (o *NoOp) GetCommonMetadata() resource.CommonMetadata {
dt := o.DeletionTimestamp
var deletionTimestamp *time.Time
if dt != nil {
@@ -117,7 +117,7 @@ func (o *Config) GetCommonMetadata() resource.CommonMetadata {
}
}
func (o *Config) SetCommonMetadata(metadata resource.CommonMetadata) {
func (o *NoOp) SetCommonMetadata(metadata resource.CommonMetadata) {
o.UID = types.UID(metadata.UID)
o.ResourceVersion = metadata.ResourceVersion
o.Generation = metadata.Generation
@@ -162,7 +162,7 @@ func (o *Config) SetCommonMetadata(metadata resource.CommonMetadata) {
}
}
func (o *Config) GetCreatedBy() string {
func (o *NoOp) GetCreatedBy() string {
if o.ObjectMeta.Annotations == nil {
o.ObjectMeta.Annotations = make(map[string]string)
}
@@ -170,7 +170,7 @@ func (o *Config) GetCreatedBy() string {
return o.ObjectMeta.Annotations["grafana.com/createdBy"]
}
func (o *Config) SetCreatedBy(createdBy string) {
func (o *NoOp) SetCreatedBy(createdBy string) {
if o.ObjectMeta.Annotations == nil {
o.ObjectMeta.Annotations = make(map[string]string)
}
@@ -178,7 +178,7 @@ func (o *Config) SetCreatedBy(createdBy string) {
o.ObjectMeta.Annotations["grafana.com/createdBy"] = createdBy
}
func (o *Config) GetUpdateTimestamp() time.Time {
func (o *NoOp) GetUpdateTimestamp() time.Time {
if o.ObjectMeta.Annotations == nil {
o.ObjectMeta.Annotations = make(map[string]string)
}
@@ -187,7 +187,7 @@ func (o *Config) GetUpdateTimestamp() time.Time {
return parsed
}
func (o *Config) SetUpdateTimestamp(updateTimestamp time.Time) {
func (o *NoOp) SetUpdateTimestamp(updateTimestamp time.Time) {
if o.ObjectMeta.Annotations == nil {
o.ObjectMeta.Annotations = make(map[string]string)
}
@@ -195,7 +195,7 @@ func (o *Config) SetUpdateTimestamp(updateTimestamp time.Time) {
o.ObjectMeta.Annotations["grafana.com/updateTimestamp"] = updateTimestamp.Format(time.RFC3339)
}
func (o *Config) GetUpdatedBy() string {
func (o *NoOp) GetUpdatedBy() string {
if o.ObjectMeta.Annotations == nil {
o.ObjectMeta.Annotations = make(map[string]string)
}
@@ -203,7 +203,7 @@ func (o *Config) GetUpdatedBy() string {
return o.ObjectMeta.Annotations["grafana.com/updatedBy"]
}
func (o *Config) SetUpdatedBy(updatedBy string) {
func (o *NoOp) SetUpdatedBy(updatedBy string) {
if o.ObjectMeta.Annotations == nil {
o.ObjectMeta.Annotations = make(map[string]string)
}
@@ -211,43 +211,43 @@ func (o *Config) SetUpdatedBy(updatedBy string) {
o.ObjectMeta.Annotations["grafana.com/updatedBy"] = updatedBy
}
func (o *Config) Copy() resource.Object {
func (o *NoOp) Copy() resource.Object {
return resource.CopyObject(o)
}
func (o *Config) DeepCopyObject() runtime.Object {
func (o *NoOp) DeepCopyObject() runtime.Object {
return o.Copy()
}
// Interface compliance compile-time check
var _ resource.Object = &Config{}
var _ resource.Object = &NoOp{}
// +k8s:openapi-gen=true
type ConfigList struct {
type NoOpList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata"`
Items []Config `json:"items"`
Items []NoOp `json:"items"`
}
func (o *ConfigList) DeepCopyObject() runtime.Object {
func (o *NoOpList) DeepCopyObject() runtime.Object {
return o.Copy()
}
func (o *ConfigList) Copy() resource.ListObject {
cpy := &ConfigList{
func (o *NoOpList) Copy() resource.ListObject {
cpy := &NoOpList{
TypeMeta: o.TypeMeta,
Items: make([]Config, len(o.Items)),
Items: make([]NoOp, len(o.Items)),
}
o.ListMeta.DeepCopyInto(&cpy.ListMeta)
for i := 0; i < len(o.Items); i++ {
if item, ok := o.Items[i].Copy().(*Config); ok {
if item, ok := o.Items[i].Copy().(*NoOp); ok {
cpy.Items[i] = *item
}
}
return cpy
}
func (o *ConfigList) GetItems() []resource.Object {
func (o *NoOpList) GetItems() []resource.Object {
items := make([]resource.Object, len(o.Items))
for i := 0; i < len(o.Items); i++ {
items[i] = &o.Items[i]
@@ -255,12 +255,12 @@ func (o *ConfigList) GetItems() []resource.Object {
return items
}
func (o *ConfigList) SetItems(items []resource.Object) {
o.Items = make([]Config, len(items))
func (o *NoOpList) SetItems(items []resource.Object) {
o.Items = make([]NoOp, len(items))
for i := 0; i < len(items); i++ {
o.Items[i] = *items[i].(*Config)
o.Items[i] = *items[i].(*NoOp)
}
}
// Interface compliance compile-time check
var _ resource.ListObject = &ConfigList{}
var _ resource.ListObject = &NoOpList{}
@@ -0,0 +1,34 @@
//
// Code generated by grafana-app-sdk. DO NOT EDIT.
//
package v0alpha1
import (
"github.com/grafana/grafana-app-sdk/resource"
)
// schema is unexported to prevent accidental overwrites
var (
schemaNoOp = resource.NewSimpleSchema("gituisync.grafana.app", "v0alpha1", &NoOp{}, &NoOpList{}, resource.WithKind("NoOp"),
resource.WithPlural("noops"), resource.WithScope(resource.NamespacedScope))
kindNoOp = resource.Kind{
Schema: schemaNoOp,
Codecs: map[resource.KindEncoding]resource.Codec{
resource.KindEncodingJSON: &NoOpJSONCodec{},
},
}
)
// Kind returns a resource.Kind for this Schema with a JSON codec
func NoOpKind() resource.Kind {
return kindNoOp
}
// Schema returns a resource.SimpleSchema representation of NoOp
func NoOpSchema() *resource.SimpleSchema {
return schemaNoOp
}
// Interface compliance checks
var _ resource.Schema = kindNoOp
@@ -1,7 +1,7 @@
package v0alpha1
// ConfigSpec defines model for ConfigSpec.
// NoOpSpec defines model for NoOpSpec.
// +k8s:openapi-gen=true
type ConfigSpec struct {
type NoOpSpec struct {
NoopValueHere bool `json:"noop_value_here"`
}
@@ -1,22 +1,22 @@
package v0alpha1
// Defines values for ConfigOperatorStateState.
// Defines values for NoOpOperatorStateState.
const (
ConfigOperatorStateStateFailed ConfigOperatorStateState = "failed"
ConfigOperatorStateStateInProgress ConfigOperatorStateState = "in_progress"
ConfigOperatorStateStateSuccess ConfigOperatorStateState = "success"
NoOpOperatorStateStateFailed NoOpOperatorStateState = "failed"
NoOpOperatorStateStateInProgress NoOpOperatorStateState = "in_progress"
NoOpOperatorStateStateSuccess NoOpOperatorStateState = "success"
)
// Defines values for ConfigstatusOperatorStateState.
// Defines values for NoOpstatusOperatorStateState.
const (
ConfigstatusOperatorStateStateFailed ConfigstatusOperatorStateState = "failed"
ConfigstatusOperatorStateStateInProgress ConfigstatusOperatorStateState = "in_progress"
ConfigstatusOperatorStateStateSuccess ConfigstatusOperatorStateState = "success"
NoOpstatusOperatorStateStateFailed NoOpstatusOperatorStateState = "failed"
NoOpstatusOperatorStateStateInProgress NoOpstatusOperatorStateState = "in_progress"
NoOpstatusOperatorStateStateSuccess NoOpstatusOperatorStateState = "success"
)
// ConfigOperatorState defines model for ConfigOperatorState.
// NoOpOperatorState defines model for NoOpOperatorState.
// +k8s:openapi-gen=true
type ConfigOperatorState struct {
type NoOpOperatorState struct {
// descriptiveState is an optional more descriptive state field which has no requirements on format
DescriptiveState *string `json:"descriptiveState,omitempty"`
@@ -28,28 +28,28 @@ type ConfigOperatorState struct {
// state describes the state of the lastEvaluation.
// It is limited to three possible states for machine evaluation.
State ConfigOperatorStateState `json:"state"`
State NoOpOperatorStateState `json:"state"`
}
// ConfigOperatorStateState state describes the state of the lastEvaluation.
// NoOpOperatorStateState state describes the state of the lastEvaluation.
// It is limited to three possible states for machine evaluation.
// +k8s:openapi-gen=true
type ConfigOperatorStateState string
type NoOpOperatorStateState string
// ConfigStatus defines model for ConfigStatus.
// NoOpStatus defines model for NoOpStatus.
// +k8s:openapi-gen=true
type ConfigStatus struct {
type NoOpStatus struct {
// additionalFields is reserved for future use
AdditionalFields map[string]interface{} `json:"additionalFields,omitempty"`
// operatorStates is a map of operator ID to operator state evaluations.
// Any operator which consumes this kind SHOULD add its state evaluation information to this field.
OperatorStates map[string]ConfigstatusOperatorState `json:"operatorStates,omitempty"`
OperatorStates map[string]NoOpstatusOperatorState `json:"operatorStates,omitempty"`
}
// ConfigstatusOperatorState defines model for Configstatus.#OperatorState.
// NoOpstatusOperatorState defines model for NoOpstatus.#OperatorState.
// +k8s:openapi-gen=true
type ConfigstatusOperatorState struct {
type NoOpstatusOperatorState struct {
// descriptiveState is an optional more descriptive state field which has no requirements on format
DescriptiveState *string `json:"descriptiveState,omitempty"`
@@ -61,10 +61,10 @@ type ConfigstatusOperatorState struct {
// state describes the state of the lastEvaluation.
// It is limited to three possible states for machine evaluation.
State ConfigstatusOperatorStateState `json:"state"`
State NoOpstatusOperatorStateState `json:"state"`
}
// ConfigstatusOperatorStateState state describes the state of the lastEvaluation.
// NoOpstatusOperatorStateState state describes the state of the lastEvaluation.
// It is limited to three possible states for machine evaluation.
// +k8s:openapi-gen=true
type ConfigstatusOperatorStateState string
type NoOpstatusOperatorStateState string
@@ -12,16 +12,16 @@ import (
func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenAPIDefinition {
return map[string]common.OpenAPIDefinition{
"github.com/grafana/grafana/apps/gituisync/pkg/apis/gituisync/v0alpha1.Config": schema_pkg_apis_gituisync_v0alpha1_Config(ref),
"github.com/grafana/grafana/apps/gituisync/pkg/apis/gituisync/v0alpha1.ConfigList": schema_pkg_apis_gituisync_v0alpha1_ConfigList(ref),
"github.com/grafana/grafana/apps/gituisync/pkg/apis/gituisync/v0alpha1.ConfigOperatorState": schema_pkg_apis_gituisync_v0alpha1_ConfigOperatorState(ref),
"github.com/grafana/grafana/apps/gituisync/pkg/apis/gituisync/v0alpha1.ConfigSpec": schema_pkg_apis_gituisync_v0alpha1_ConfigSpec(ref),
"github.com/grafana/grafana/apps/gituisync/pkg/apis/gituisync/v0alpha1.ConfigStatus": schema_pkg_apis_gituisync_v0alpha1_ConfigStatus(ref),
"github.com/grafana/grafana/apps/gituisync/pkg/apis/gituisync/v0alpha1.ConfigstatusOperatorState": schema_pkg_apis_gituisync_v0alpha1_ConfigstatusOperatorState(ref),
"github.com/grafana/grafana/apps/gituisync/pkg/apis/gituisync/v0alpha1.NoOp": schema_pkg_apis_gituisync_v0alpha1_NoOp(ref),
"github.com/grafana/grafana/apps/gituisync/pkg/apis/gituisync/v0alpha1.NoOpList": schema_pkg_apis_gituisync_v0alpha1_NoOpList(ref),
"github.com/grafana/grafana/apps/gituisync/pkg/apis/gituisync/v0alpha1.NoOpOperatorState": schema_pkg_apis_gituisync_v0alpha1_NoOpOperatorState(ref),
"github.com/grafana/grafana/apps/gituisync/pkg/apis/gituisync/v0alpha1.NoOpSpec": schema_pkg_apis_gituisync_v0alpha1_NoOpSpec(ref),
"github.com/grafana/grafana/apps/gituisync/pkg/apis/gituisync/v0alpha1.NoOpStatus": schema_pkg_apis_gituisync_v0alpha1_NoOpStatus(ref),
"github.com/grafana/grafana/apps/gituisync/pkg/apis/gituisync/v0alpha1.NoOpstatusOperatorState": schema_pkg_apis_gituisync_v0alpha1_NoOpstatusOperatorState(ref),
}
}
func schema_pkg_apis_gituisync_v0alpha1_Config(ref common.ReferenceCallback) common.OpenAPIDefinition {
func schema_pkg_apis_gituisync_v0alpha1_NoOp(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
@@ -50,13 +50,13 @@ func schema_pkg_apis_gituisync_v0alpha1_Config(ref common.ReferenceCallback) com
"spec": {
SchemaProps: spec.SchemaProps{
Default: map[string]interface{}{},
Ref: ref("github.com/grafana/grafana/apps/gituisync/pkg/apis/gituisync/v0alpha1.ConfigSpec"),
Ref: ref("github.com/grafana/grafana/apps/gituisync/pkg/apis/gituisync/v0alpha1.NoOpSpec"),
},
},
"status": {
SchemaProps: spec.SchemaProps{
Default: map[string]interface{}{},
Ref: ref("github.com/grafana/grafana/apps/gituisync/pkg/apis/gituisync/v0alpha1.ConfigStatus"),
Ref: ref("github.com/grafana/grafana/apps/gituisync/pkg/apis/gituisync/v0alpha1.NoOpStatus"),
},
},
},
@@ -64,11 +64,11 @@ func schema_pkg_apis_gituisync_v0alpha1_Config(ref common.ReferenceCallback) com
},
},
Dependencies: []string{
"github.com/grafana/grafana/apps/gituisync/pkg/apis/gituisync/v0alpha1.ConfigSpec", "github.com/grafana/grafana/apps/gituisync/pkg/apis/gituisync/v0alpha1.ConfigStatus", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"},
"github.com/grafana/grafana/apps/gituisync/pkg/apis/gituisync/v0alpha1.NoOpSpec", "github.com/grafana/grafana/apps/gituisync/pkg/apis/gituisync/v0alpha1.NoOpStatus", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"},
}
}
func schema_pkg_apis_gituisync_v0alpha1_ConfigList(ref common.ReferenceCallback) common.OpenAPIDefinition {
func schema_pkg_apis_gituisync_v0alpha1_NoOpList(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
@@ -101,7 +101,7 @@ func schema_pkg_apis_gituisync_v0alpha1_ConfigList(ref common.ReferenceCallback)
Schema: &spec.Schema{
SchemaProps: spec.SchemaProps{
Default: map[string]interface{}{},
Ref: ref("github.com/grafana/grafana/apps/gituisync/pkg/apis/gituisync/v0alpha1.Config"),
Ref: ref("github.com/grafana/grafana/apps/gituisync/pkg/apis/gituisync/v0alpha1.NoOp"),
},
},
},
@@ -112,15 +112,15 @@ func schema_pkg_apis_gituisync_v0alpha1_ConfigList(ref common.ReferenceCallback)
},
},
Dependencies: []string{
"github.com/grafana/grafana/apps/gituisync/pkg/apis/gituisync/v0alpha1.Config", "k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"},
"github.com/grafana/grafana/apps/gituisync/pkg/apis/gituisync/v0alpha1.NoOp", "k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"},
}
}
func schema_pkg_apis_gituisync_v0alpha1_ConfigOperatorState(ref common.ReferenceCallback) common.OpenAPIDefinition {
func schema_pkg_apis_gituisync_v0alpha1_NoOpOperatorState(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
Description: "ConfigOperatorState defines model for ConfigOperatorState.",
Description: "NoOpOperatorState defines model for NoOpOperatorState.",
Type: []string{"object"},
Properties: map[string]spec.Schema{
"descriptiveState": {
@@ -168,11 +168,11 @@ func schema_pkg_apis_gituisync_v0alpha1_ConfigOperatorState(ref common.Reference
}
}
func schema_pkg_apis_gituisync_v0alpha1_ConfigSpec(ref common.ReferenceCallback) common.OpenAPIDefinition {
func schema_pkg_apis_gituisync_v0alpha1_NoOpSpec(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
Description: "ConfigSpec defines model for ConfigSpec.",
Description: "NoOpSpec defines model for NoOpSpec.",
Type: []string{"object"},
Properties: map[string]spec.Schema{
"noop_value_here": {
@@ -189,11 +189,11 @@ func schema_pkg_apis_gituisync_v0alpha1_ConfigSpec(ref common.ReferenceCallback)
}
}
func schema_pkg_apis_gituisync_v0alpha1_ConfigStatus(ref common.ReferenceCallback) common.OpenAPIDefinition {
func schema_pkg_apis_gituisync_v0alpha1_NoOpStatus(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
Description: "ConfigStatus defines model for ConfigStatus.",
Description: "NoOpStatus defines model for NoOpStatus.",
Type: []string{"object"},
Properties: map[string]spec.Schema{
"additionalFields": {
@@ -220,7 +220,7 @@ func schema_pkg_apis_gituisync_v0alpha1_ConfigStatus(ref common.ReferenceCallbac
Schema: &spec.Schema{
SchemaProps: spec.SchemaProps{
Default: map[string]interface{}{},
Ref: ref("github.com/grafana/grafana/apps/gituisync/pkg/apis/gituisync/v0alpha1.ConfigstatusOperatorState"),
Ref: ref("github.com/grafana/grafana/apps/gituisync/pkg/apis/gituisync/v0alpha1.NoOpstatusOperatorState"),
},
},
},
@@ -230,15 +230,15 @@ func schema_pkg_apis_gituisync_v0alpha1_ConfigStatus(ref common.ReferenceCallbac
},
},
Dependencies: []string{
"github.com/grafana/grafana/apps/gituisync/pkg/apis/gituisync/v0alpha1.ConfigstatusOperatorState"},
"github.com/grafana/grafana/apps/gituisync/pkg/apis/gituisync/v0alpha1.NoOpstatusOperatorState"},
}
}
func schema_pkg_apis_gituisync_v0alpha1_ConfigstatusOperatorState(ref common.ReferenceCallback) common.OpenAPIDefinition {
func schema_pkg_apis_gituisync_v0alpha1_NoOpstatusOperatorState(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
Description: "ConfigstatusOperatorState defines model for Configstatus.#OperatorState.",
Description: "NoOpstatusOperatorState defines model for NoOpstatus.#OperatorState.",
Type: []string{"object"},
Properties: map[string]spec.Schema{
"descriptiveState": {
+5 -5
View File
@@ -12,9 +12,9 @@ import (
)
var (
rawSchemaConfigv0alpha1 = []byte(`{"spec":{"properties":{"noop_value_here":{"type":"boolean"}},"required":["noop_value_here"],"type":"object"},"status":{"properties":{"additionalFields":{"description":"additionalFields is reserved for future use","type":"object","x-kubernetes-preserve-unknown-fields":true},"operatorStates":{"additionalProperties":{"properties":{"descriptiveState":{"description":"descriptiveState is an optional more descriptive state field which has no requirements on format","type":"string"},"details":{"description":"details contains any extra information that is operator-specific","type":"object","x-kubernetes-preserve-unknown-fields":true},"lastEvaluation":{"description":"lastEvaluation is the ResourceVersion last evaluated","type":"string"},"state":{"description":"state describes the state of the lastEvaluation.\nIt is limited to three possible states for machine evaluation.","enum":["success","in_progress","failed"],"type":"string"}},"required":["lastEvaluation","state"],"type":"object"},"description":"operatorStates is a map of operator ID to operator state evaluations.\nAny operator which consumes this kind SHOULD add its state evaluation information to this field.","type":"object"}},"type":"object","x-kubernetes-preserve-unknown-fields":true}}`)
versionSchemaConfigv0alpha1 app.VersionSchema
_ = json.Unmarshal(rawSchemaConfigv0alpha1, &versionSchemaConfigv0alpha1)
rawSchemaNoOpv0alpha1 = []byte(`{"spec":{"properties":{"noop_value_here":{"type":"boolean"}},"required":["noop_value_here"],"type":"object"},"status":{"properties":{"additionalFields":{"description":"additionalFields is reserved for future use","type":"object","x-kubernetes-preserve-unknown-fields":true},"operatorStates":{"additionalProperties":{"properties":{"descriptiveState":{"description":"descriptiveState is an optional more descriptive state field which has no requirements on format","type":"string"},"details":{"description":"details contains any extra information that is operator-specific","type":"object","x-kubernetes-preserve-unknown-fields":true},"lastEvaluation":{"description":"lastEvaluation is the ResourceVersion last evaluated","type":"string"},"state":{"description":"state describes the state of the lastEvaluation.\nIt is limited to three possible states for machine evaluation.","enum":["success","in_progress","failed"],"type":"string"}},"required":["lastEvaluation","state"],"type":"object"},"description":"operatorStates is a map of operator ID to operator state evaluations.\nAny operator which consumes this kind SHOULD add its state evaluation information to this field.","type":"object"}},"type":"object","x-kubernetes-preserve-unknown-fields":true}}`)
versionSchemaNoOpv0alpha1 app.VersionSchema
_ = json.Unmarshal(rawSchemaNoOpv0alpha1, &versionSchemaNoOpv0alpha1)
)
var appManifestData = app.ManifestData{
@@ -22,7 +22,7 @@ var appManifestData = app.ManifestData{
Group: "gituisync.grafana.app",
Kinds: []app.ManifestKind{
{
Kind: "Config",
Kind: "NoOp",
Scope: "Namespaced",
Conversion: false,
Versions: []app.ManifestKindVersion{
@@ -42,7 +42,7 @@ var appManifestData = app.ManifestData{
},
},
},
Schema: &versionSchemaConfigv0alpha1,
Schema: &versionSchemaNoOpv0alpha1,
},
},
},
+11 -6
View File
@@ -22,7 +22,7 @@ func New(cfg app.Config) (app.App, error) {
},
ManagedKinds: []simple.AppManagedKind{
{
Kind: v0alpha1.ConfigKind(),
Kind: v0alpha1.NoOpKind(),
Watcher: &simple.Watcher{},
Mutator: &simple.Mutator{
MutateFunc: func(ctx context.Context, ar *app.AdmissionRequest) (*app.MutatingResponse, error) {
@@ -52,11 +52,16 @@ func New(cfg app.Config) (app.App, error) {
}
func GetKinds() map[schema.GroupVersion]resource.Kind {
gv := schema.GroupVersion{
Group: v0alpha1.ConfigKind().Group(),
Version: v0alpha1.ConfigKind().Version(),
kinds := []resource.Kind{
v0alpha1.NoOpKind(),
}
return map[schema.GroupVersion]resource.Kind{
gv: v0alpha1.ConfigKind(),
kindMap := make(map[schema.GroupVersion]resource.Kind, len(kinds))
for _, kind := range kinds {
gv := schema.GroupVersion{
Group: kind.Group(),
Version: kind.Version(),
}
kindMap[gv] = kind
}
return kindMap
}