Alerting: Use Unstructured type for settings of K8s model Integration + code owners (#91430)

* remove nonnamespaced paths
* use common.Unstructed for Intergration.Settings
* update codeowners to include alerting
* fix json name of secure fields to start with lower case
This commit is contained in:
Yuri Tseretyan
2024-08-02 20:02:58 +03:00
committed by GitHub
parent 1747cd1747
commit 96f7f0f486
7 changed files with 57 additions and 40 deletions
@@ -1,17 +1,18 @@
package v0alpha1
import "encoding/json"
import (
common "github.com/grafana/grafana/pkg/apimachinery/apis/common/v0alpha1"
)
// Integration defines model for Integration.
// +k8s:openapi-gen=true
type Integration struct {
DisableResolveMessage *bool `json:"disableResolveMessage,omitempty"`
// +mapType=atomic
SecureFields map[string]bool `json:"SecureFields,omitempty"`
// +listType=atomic
Settings json.RawMessage `json:"settings"`
Type string `json:"type"`
Uid *string `json:"uid,omitempty"`
SecureFields map[string]bool `json:"secureFields,omitempty"`
Settings common.Unstructured `json:"settings"`
Type string `json:"type"`
Uid *string `json:"uid,omitempty"`
}
// ReceiverSpec defines model for Spec.
@@ -8,8 +8,6 @@
package v0alpha1
import (
json "encoding/json"
runtime "k8s.io/apimachinery/pkg/runtime"
)
@@ -28,11 +26,7 @@ func (in *Integration) DeepCopyInto(out *Integration) {
(*out)[key] = val
}
}
if in.Settings != nil {
in, out := &in.Settings, &out.Settings
*out = make(json.RawMessage, len(*in))
copy(*out, *in)
}
in.Settings.DeepCopyInto(&out.Settings)
if in.Uid != nil {
in, out := &in.Uid, &out.Uid
*out = new(string)
@@ -48,28 +48,12 @@ func schema_pkg_apis_alerting_notifications_v0alpha1_Integration(ref common.Refe
},
},
SchemaProps: spec.SchemaProps{
Type: []string{"object"},
AdditionalProperties: &spec.SchemaOrBool{
Allows: true,
Schema: &spec.Schema{
SchemaProps: spec.SchemaProps{
Default: false,
Type: []string{"boolean"},
Format: "",
},
},
},
Ref: ref("github.com/grafana/grafana/pkg/apimachinery/apis/common/v0alpha1.Unstructured"),
},
},
"settings": {
VendorExtensible: spec.VendorExtensible{
Extensions: spec.Extensions{
"x-kubernetes-list-type": "atomic",
},
},
SchemaProps: spec.SchemaProps{
Type: []string{"string"},
Format: "byte",
Ref: ref("github.com/grafana/grafana/pkg/apimachinery/apis/common/v0alpha1.Unstructured"),
},
},
"type": {
@@ -89,6 +73,8 @@ func schema_pkg_apis_alerting_notifications_v0alpha1_Integration(ref common.Refe
Required: []string{"settings", "type"},
},
},
Dependencies: []string{
"github.com/grafana/grafana/pkg/apimachinery/apis/common/v0alpha1.Unstructured"},
}
}