Alerting: Move alerting codegen to --grouping=group (#105068)

This commit is contained in:
Gilles De Mey 2025-05-08 14:59:33 +02:00 committed by GitHub
parent 9156149960
commit c78ae5cb76
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
67 changed files with 2262 additions and 2451 deletions

View file

@ -24,5 +24,4 @@ generate: do-generate ## Run Grafana App SDK code generation
.PHONY: do-generate
do-generate: install-app-sdk update-app-sdk
## --defencoding=none and noschemasinmanifest are needed to avoid infinite loop while generating recursive models (see routingtree.cue)
@$(APP_SDK_BIN) generate --gogenpath=./pkg/apis --defencoding=none --noschemasinmanifest
@$(APP_SDK_BIN) generate --grouping=group --gogenpath=./pkg/apis --defencoding=none --postprocess --noschemasinmanifest

View file

@ -7,13 +7,13 @@ import (
"strings"
"time"
"github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/timeinterval/v0alpha1"
"github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/alerting/v0alpha1"
)
var UTCLocation = "UTC"
// +k8s:openapi-gen=false
type IntervalMutator func(spec *v0alpha1.Interval)
type IntervalMutator func(spec *v0alpha1.TimeIntervalInterval)
// +k8s:openapi-gen=false
type IntervalGenerator struct {
@ -36,10 +36,10 @@ func (t IntervalGenerator) generateDaysOfMonth() string {
return fmt.Sprintf("%d:%d", from, to)
}
func (t IntervalGenerator) generateTimeRange() v0alpha1.TimeRange {
func (t IntervalGenerator) generateTimeRange() v0alpha1.TimeIntervalTimeRange {
from := rand.Int63n(1440 / 2) // [0, 719]
to := from + rand.Int63n(1440/2) + 1 // from < ([0,719] + [1,720]) < 1440
return v0alpha1.TimeRange{
return v0alpha1.TimeIntervalTimeRange{
StartTime: time.Unix(from*60, 0).UTC().Format("15:04"),
EndTime: time.Unix(to*60, 0).UTC().Format("15:04"),
}
@ -70,16 +70,16 @@ func (t IntervalGenerator) generateMonth() string {
return fmt.Sprintf("%d", rand.Intn(12)+1)
}
func (t IntervalGenerator) GenerateMany(count int) []v0alpha1.Interval {
result := make([]v0alpha1.Interval, 0, count)
func (t IntervalGenerator) GenerateMany(count int) []v0alpha1.TimeIntervalInterval {
result := make([]v0alpha1.TimeIntervalInterval, 0, count)
for i := 0; i < count; i++ {
result = append(result, t.Generate())
}
return result
}
func (t IntervalGenerator) Generate() v0alpha1.Interval {
i := v0alpha1.Interval{
func (t IntervalGenerator) Generate() v0alpha1.TimeIntervalInterval {
i := v0alpha1.TimeIntervalInterval{
DaysOfMonth: generateMany(rand.Intn(6), true, t.generateDaysOfMonth),
Location: t.generateLocation(),
Months: generateMany(rand.Intn(3), true, t.generateMonth),

View file

@ -11,18 +11,18 @@ import (
"github.com/grafana/grafana-app-sdk/resource"
)
// JSONCodec is an implementation of resource.Codec for kubernetes JSON encoding
type JSONCodec struct{}
// ReceiverJSONCodec is an implementation of resource.Codec for kubernetes JSON encoding
type ReceiverJSONCodec struct{}
// Read reads JSON-encoded bytes from `reader` and unmarshals them into `into`
func (*JSONCodec) Read(reader io.Reader, into resource.Object) error {
func (*ReceiverJSONCodec) 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 (*JSONCodec) Write(writer io.Writer, from resource.Object) error {
func (*ReceiverJSONCodec) Write(writer io.Writer, from resource.Object) error {
return json.NewEncoder(writer).Encode(from)
}
// Interface compliance checks
var _ resource.Codec = &JSONCodec{}
var _ resource.Codec = &ReceiverJSONCodec{}

View file

@ -5,17 +5,15 @@ import (
"k8s.io/apimachinery/pkg/fields"
"k8s.io/apiserver/pkg/registry/generic"
"github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/alerting/v0alpha1"
)
func (o *Receiver) GetProvenanceStatus() string {
if o == nil || o.Annotations == nil {
return ""
}
s, ok := o.Annotations[v0alpha1.ProvenanceStatusAnnotationKey]
s, ok := o.Annotations[ProvenanceStatusAnnotationKey]
if !ok || s == "" {
return v0alpha1.ProvenanceStatusNone
return ProvenanceStatusNone
}
return s
}
@ -25,9 +23,9 @@ func (o *Receiver) SetProvenanceStatus(status string) {
o.Annotations = make(map[string]string, 1)
}
if status == "" {
status = v0alpha1.ProvenanceStatusNone
status = ProvenanceStatusNone
}
o.Annotations[v0alpha1.ProvenanceStatusAnnotationKey] = status
o.Annotations[ProvenanceStatusAnnotationKey] = status
}
func (o *Receiver) SetAccessControl(action string) {
@ -40,7 +38,7 @@ func (o *Receiver) SetAccessControl(action string) {
// AccessControlAnnotation returns the key for the access control annotation for the given action.
// Ex. grafana.com/access/canDelete.
func AccessControlAnnotation(action string) string {
return fmt.Sprintf("%s%s/%s", v0alpha1.InternalPrefix, "access", action)
return fmt.Sprintf("%s%s/%s", InternalPrefix, "access", action)
}
func (o *Receiver) SetInUse(routesCnt int, rules []string) {
@ -54,14 +52,14 @@ func (o *Receiver) SetInUse(routesCnt int, rules []string) {
// InUseAnnotation returns the key for the in-use annotation for the given resource.
// Ex. grafana.com/inUse/routes, grafana.com/inUse/rules.
func InUseAnnotation(resource string) string {
return fmt.Sprintf("%s%s/%s", v0alpha1.InternalPrefix, "inUse", resource)
return fmt.Sprintf("%s%s/%s", InternalPrefix, "inUse", resource)
}
func SelectableFields(obj *Receiver) fields.Set {
func ReceiverSelectableFields(obj *Receiver) fields.Set {
if obj == nil {
return nil
}
selectable := Schema().SelectableFields()
selectable := ReceiverSchema().SelectableFields()
set := make(fields.Set, len(selectable))
for _, field := range selectable {
f, err := field.FieldValueFunc(obj)

View file

@ -9,7 +9,7 @@ import (
// metadata contains embedded CommonMetadata and can be extended with custom string fields
// TODO: use CommonMetadata instead of redefining here; currently needs to be defined here
// without external reference as using the CommonMetadata reference breaks thema codegen.
type Metadata struct {
type ReceiverMetadata struct {
UpdateTimestamp time.Time `json:"updateTimestamp"`
CreatedBy string `json:"createdBy"`
Uid string `json:"uid"`
@ -22,7 +22,7 @@ type Metadata struct {
Labels map[string]string `json:"labels"`
}
// NewMetadata creates a new Metadata object.
func NewMetadata() *Metadata {
return &Metadata{}
// NewReceiverMetadata creates a new ReceiverMetadata object.
func NewReceiverMetadata() *ReceiverMetadata {
return &ReceiverMetadata{}
}

View file

@ -20,9 +20,9 @@ type Receiver struct {
metav1.ObjectMeta `json:"metadata" yaml:"metadata"`
// Spec is the spec of the Receiver
Spec Spec `json:"spec" yaml:"spec"`
Spec ReceiverSpec `json:"spec" yaml:"spec"`
Status Status `json:"status" yaml:"status"`
Status ReceiverStatus `json:"status" yaml:"status"`
}
func (o *Receiver) GetSpec() any {
@ -30,7 +30,7 @@ func (o *Receiver) GetSpec() any {
}
func (o *Receiver) SetSpec(spec any) error {
cast, ok := spec.(Spec)
cast, ok := spec.(ReceiverSpec)
if !ok {
return fmt.Errorf("cannot set spec type %#v, not of type Spec", spec)
}
@ -56,9 +56,9 @@ func (o *Receiver) GetSubresource(name string) (any, bool) {
func (o *Receiver) SetSubresource(name string, value any) error {
switch name {
case "status":
cast, ok := value.(Status)
cast, ok := value.(ReceiverStatus)
if !ok {
return fmt.Errorf("cannot set status type %#v, not of type Status", value)
return fmt.Errorf("cannot set status type %#v, not of type ReceiverStatus", value)
}
o.Status = cast
return nil
@ -295,25 +295,25 @@ var _ resource.ListObject = &ReceiverList{}
// Copy methods for all subresource types
// DeepCopy creates a full deep copy of Spec
func (s *Spec) DeepCopy() *Spec {
cpy := &Spec{}
func (s *ReceiverSpec) DeepCopy() *ReceiverSpec {
cpy := &ReceiverSpec{}
s.DeepCopyInto(cpy)
return cpy
}
// DeepCopyInto deep copies Spec into another Spec object
func (s *Spec) DeepCopyInto(dst *Spec) {
func (s *ReceiverSpec) DeepCopyInto(dst *ReceiverSpec) {
resource.CopyObjectInto(dst, s)
}
// DeepCopy creates a full deep copy of Status
func (s *Status) DeepCopy() *Status {
cpy := &Status{}
// DeepCopy creates a full deep copy of ReceiverStatus
func (s *ReceiverStatus) DeepCopy() *ReceiverStatus {
cpy := &ReceiverStatus{}
s.DeepCopyInto(cpy)
return cpy
}
// DeepCopyInto deep copies Status into another Status object
func (s *Status) DeepCopyInto(dst *Status) {
// DeepCopyInto deep copies ReceiverStatus into another ReceiverStatus object
func (s *ReceiverStatus) DeepCopyInto(dst *ReceiverStatus) {
resource.CopyObjectInto(dst, s)
}

View file

@ -13,7 +13,7 @@ import (
// schema is unexported to prevent accidental overwrites
var (
schemaReceiver = resource.NewSimpleSchema("notifications.alerting.grafana.app", "v0alpha1", &Receiver{}, &ReceiverList{}, resource.WithKind("Receiver"),
resource.WithPlural("receivers"), resource.WithScope(resource.NamespacedScope), resource.WithSelectableFields([]resource.SelectableField{{
resource.WithPlural("receivers"), resource.WithScope(resource.NamespacedScope), resource.WithSelectableFields([]resource.SelectableField{resource.SelectableField{
FieldSelector: "spec.title",
FieldValueFunc: func(o resource.Object) (string, error) {
cast, ok := o.(*Receiver)
@ -27,18 +27,18 @@ var (
kindReceiver = resource.Kind{
Schema: schemaReceiver,
Codecs: map[resource.KindEncoding]resource.Codec{
resource.KindEncodingJSON: &JSONCodec{},
resource.KindEncodingJSON: &ReceiverJSONCodec{},
},
}
)
// Kind returns a resource.Kind for this Schema with a JSON codec
func Kind() resource.Kind {
func ReceiverKind() resource.Kind {
return kindReceiver
}
// Schema returns a resource.SimpleSchema representation of Receiver
func Schema() *resource.SimpleSchema {
func ReceiverSchema() *resource.SimpleSchema {
return schemaReceiver
}

View file

@ -3,7 +3,7 @@
package v0alpha1
// +k8s:openapi-gen=true
type Integration struct {
type ReceiverIntegration struct {
Uid *string `json:"uid,omitempty"`
Type string `json:"type"`
DisableResolveMessage *bool `json:"disableResolveMessage,omitempty"`
@ -11,18 +11,18 @@ type Integration struct {
SecureFields map[string]bool `json:"secureFields,omitempty"`
}
// NewIntegration creates a new Integration object.
func NewIntegration() *Integration {
return &Integration{}
// NewReceiverIntegration creates a new ReceiverIntegration object.
func NewReceiverIntegration() *ReceiverIntegration {
return &ReceiverIntegration{}
}
// +k8s:openapi-gen=true
type Spec struct {
Title string `json:"title"`
Integrations []Integration `json:"integrations"`
type ReceiverSpec struct {
Title string `json:"title"`
Integrations []ReceiverIntegration `json:"integrations"`
}
// NewSpec creates a new Spec object.
func NewSpec() *Spec {
return &Spec{}
// NewReceiverSpec creates a new ReceiverSpec object.
func NewReceiverSpec() *ReceiverSpec {
return &ReceiverSpec{}
}

View file

@ -3,42 +3,42 @@
package v0alpha1
// +k8s:openapi-gen=true
type StatusOperatorState struct {
type ReceiverstatusOperatorState struct {
// lastEvaluation is the ResourceVersion last evaluated
LastEvaluation string `json:"lastEvaluation"`
// state describes the state of the lastEvaluation.
// It is limited to three possible states for machine evaluation.
State StatusOperatorStateState `json:"state"`
State ReceiverStatusOperatorStateState `json:"state"`
// descriptiveState is an optional more descriptive state field which has no requirements on format
DescriptiveState *string `json:"descriptiveState,omitempty"`
// details contains any extra information that is operator-specific
Details map[string]interface{} `json:"details,omitempty"`
}
// NewStatusOperatorState creates a new StatusOperatorState object.
func NewStatusOperatorState() *StatusOperatorState {
return &StatusOperatorState{}
// NewReceiverstatusOperatorState creates a new ReceiverstatusOperatorState object.
func NewReceiverstatusOperatorState() *ReceiverstatusOperatorState {
return &ReceiverstatusOperatorState{}
}
// +k8s:openapi-gen=true
type Status struct {
type ReceiverStatus struct {
// 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]StatusOperatorState `json:"operatorStates,omitempty"`
OperatorStates map[string]ReceiverstatusOperatorState `json:"operatorStates,omitempty"`
// additionalFields is reserved for future use
AdditionalFields map[string]interface{} `json:"additionalFields,omitempty"`
}
// NewStatus creates a new Status object.
func NewStatus() *Status {
return &Status{}
// NewReceiverStatus creates a new ReceiverStatus object.
func NewReceiverStatus() *ReceiverStatus {
return &ReceiverStatus{}
}
// +k8s:openapi-gen=true
type StatusOperatorStateState string
type ReceiverStatusOperatorStateState string
const (
StatusOperatorStateStateSuccess StatusOperatorStateState = "success"
StatusOperatorStateStateInProgress StatusOperatorStateState = "in_progress"
StatusOperatorStateStateFailed StatusOperatorStateState = "failed"
ReceiverStatusOperatorStateStateSuccess ReceiverStatusOperatorStateState = "success"
ReceiverStatusOperatorStateStateInProgress ReceiverStatusOperatorStateState = "in_progress"
ReceiverStatusOperatorStateStateFailed ReceiverStatusOperatorStateState = "failed"
)

View file

@ -11,18 +11,18 @@ import (
"github.com/grafana/grafana-app-sdk/resource"
)
// JSONCodec is an implementation of resource.Codec for kubernetes JSON encoding
type JSONCodec struct{}
// RoutingTreeJSONCodec is an implementation of resource.Codec for kubernetes JSON encoding
type RoutingTreeJSONCodec struct{}
// Read reads JSON-encoded bytes from `reader` and unmarshals them into `into`
func (*JSONCodec) Read(reader io.Reader, into resource.Object) error {
func (*RoutingTreeJSONCodec) 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 (*JSONCodec) Write(writer io.Writer, from resource.Object) error {
func (*RoutingTreeJSONCodec) Write(writer io.Writer, from resource.Object) error {
return json.NewEncoder(writer).Encode(from)
}
// Interface compliance checks
var _ resource.Codec = &JSONCodec{}
var _ resource.Codec = &RoutingTreeJSONCodec{}

View file

@ -1,18 +1,14 @@
package v0alpha1
import (
"github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/alerting/v0alpha1"
)
const UserDefinedRoutingTreeName = "user-defined"
func (o *RoutingTree) GetProvenanceStatus() string {
if o == nil || o.Annotations == nil {
return ""
}
s, ok := o.Annotations[v0alpha1.ProvenanceStatusAnnotationKey]
s, ok := o.Annotations[ProvenanceStatusAnnotationKey]
if !ok || s == "" {
return v0alpha1.ProvenanceStatusNone
return ProvenanceStatusNone
}
return s
}
@ -22,7 +18,7 @@ func (o *RoutingTree) SetProvenanceStatus(status string) {
o.Annotations = make(map[string]string, 1)
}
if status == "" {
status = v0alpha1.ProvenanceStatusNone
status = ProvenanceStatusNone
}
o.Annotations[v0alpha1.ProvenanceStatusAnnotationKey] = status
o.Annotations[ProvenanceStatusAnnotationKey] = status
}

View file

@ -9,7 +9,7 @@ import (
// metadata contains embedded CommonMetadata and can be extended with custom string fields
// TODO: use CommonMetadata instead of redefining here; currently needs to be defined here
// without external reference as using the CommonMetadata reference breaks thema codegen.
type Metadata struct {
type RoutingTreeMetadata struct {
UpdateTimestamp time.Time `json:"updateTimestamp"`
CreatedBy string `json:"createdBy"`
Uid string `json:"uid"`
@ -22,7 +22,7 @@ type Metadata struct {
Labels map[string]string `json:"labels"`
}
// NewMetadata creates a new Metadata object.
func NewMetadata() *Metadata {
return &Metadata{}
// NewRoutingTreeMetadata creates a new RoutingTreeMetadata object.
func NewRoutingTreeMetadata() *RoutingTreeMetadata {
return &RoutingTreeMetadata{}
}

View file

@ -20,9 +20,9 @@ type RoutingTree struct {
metav1.ObjectMeta `json:"metadata" yaml:"metadata"`
// Spec is the spec of the RoutingTree
Spec Spec `json:"spec" yaml:"spec"`
Spec RoutingTreeSpec `json:"spec" yaml:"spec"`
Status Status `json:"status" yaml:"status"`
Status RoutingTreeStatus `json:"status" yaml:"status"`
}
func (o *RoutingTree) GetSpec() any {
@ -30,7 +30,7 @@ func (o *RoutingTree) GetSpec() any {
}
func (o *RoutingTree) SetSpec(spec any) error {
cast, ok := spec.(Spec)
cast, ok := spec.(RoutingTreeSpec)
if !ok {
return fmt.Errorf("cannot set spec type %#v, not of type Spec", spec)
}
@ -56,9 +56,9 @@ func (o *RoutingTree) GetSubresource(name string) (any, bool) {
func (o *RoutingTree) SetSubresource(name string, value any) error {
switch name {
case "status":
cast, ok := value.(Status)
cast, ok := value.(RoutingTreeStatus)
if !ok {
return fmt.Errorf("cannot set status type %#v, not of type Status", value)
return fmt.Errorf("cannot set status type %#v, not of type RoutingTreeStatus", value)
}
o.Status = cast
return nil
@ -295,25 +295,25 @@ var _ resource.ListObject = &RoutingTreeList{}
// Copy methods for all subresource types
// DeepCopy creates a full deep copy of Spec
func (s *Spec) DeepCopy() *Spec {
cpy := &Spec{}
func (s *RoutingTreeSpec) DeepCopy() *RoutingTreeSpec {
cpy := &RoutingTreeSpec{}
s.DeepCopyInto(cpy)
return cpy
}
// DeepCopyInto deep copies Spec into another Spec object
func (s *Spec) DeepCopyInto(dst *Spec) {
func (s *RoutingTreeSpec) DeepCopyInto(dst *RoutingTreeSpec) {
resource.CopyObjectInto(dst, s)
}
// DeepCopy creates a full deep copy of Status
func (s *Status) DeepCopy() *Status {
cpy := &Status{}
// DeepCopy creates a full deep copy of RoutingTreeStatus
func (s *RoutingTreeStatus) DeepCopy() *RoutingTreeStatus {
cpy := &RoutingTreeStatus{}
s.DeepCopyInto(cpy)
return cpy
}
// DeepCopyInto deep copies Status into another Status object
func (s *Status) DeepCopyInto(dst *Status) {
// DeepCopyInto deep copies RoutingTreeStatus into another RoutingTreeStatus object
func (s *RoutingTreeStatus) DeepCopyInto(dst *RoutingTreeStatus) {
resource.CopyObjectInto(dst, s)
}

View file

@ -15,18 +15,18 @@ var (
kindRoutingTree = resource.Kind{
Schema: schemaRoutingTree,
Codecs: map[resource.KindEncoding]resource.Codec{
resource.KindEncodingJSON: &JSONCodec{},
resource.KindEncodingJSON: &RoutingTreeJSONCodec{},
},
}
)
// Kind returns a resource.Kind for this Schema with a JSON codec
func Kind() resource.Kind {
func RoutingTreeKind() resource.Kind {
return kindRoutingTree
}
// Schema returns a resource.SimpleSchema representation of RoutingTree
func Schema() *resource.SimpleSchema {
func RoutingTreeSchema() *resource.SimpleSchema {
return schemaRoutingTree
}

View file

@ -0,0 +1,71 @@
// Code generated - EDITING IS FUTILE. DO NOT EDIT.
package v0alpha1
// +k8s:openapi-gen=true
type RoutingTreeRouteDefaults struct {
Receiver string `json:"receiver"`
GroupBy []string `json:"group_by,omitempty"`
GroupWait *string `json:"group_wait,omitempty"`
GroupInterval *string `json:"group_interval,omitempty"`
RepeatInterval *string `json:"repeat_interval,omitempty"`
}
// NewRoutingTreeRouteDefaults creates a new RoutingTreeRouteDefaults object.
func NewRoutingTreeRouteDefaults() *RoutingTreeRouteDefaults {
return &RoutingTreeRouteDefaults{}
}
// +k8s:openapi-gen=true
type RoutingTreeRoute struct {
Receiver *string `json:"receiver,omitempty"`
Matchers []RoutingTreeMatcher `json:"matchers,omitempty"`
Continue bool `json:"continue"`
GroupBy []string `json:"group_by,omitempty"`
MuteTimeIntervals []string `json:"mute_time_intervals,omitempty"`
ActiveTimeIntervals []string `json:"active_time_intervals,omitempty"`
Routes []RoutingTreeRoute `json:"routes,omitempty"`
GroupWait *string `json:"group_wait,omitempty"`
GroupInterval *string `json:"group_interval,omitempty"`
RepeatInterval *string `json:"repeat_interval,omitempty"`
}
// NewRoutingTreeRoute creates a new RoutingTreeRoute object.
func NewRoutingTreeRoute() *RoutingTreeRoute {
return &RoutingTreeRoute{}
}
// +k8s:openapi-gen=true
type RoutingTreeMatcher struct {
Type RoutingTreeMatcherType `json:"type"`
Label string `json:"label"`
Value string `json:"value"`
}
// NewRoutingTreeMatcher creates a new RoutingTreeMatcher object.
func NewRoutingTreeMatcher() *RoutingTreeMatcher {
return &RoutingTreeMatcher{}
}
// +k8s:openapi-gen=true
type RoutingTreeSpec struct {
Defaults RoutingTreeRouteDefaults `json:"defaults"`
Routes []RoutingTreeRoute `json:"routes"`
}
// NewRoutingTreeSpec creates a new RoutingTreeSpec object.
func NewRoutingTreeSpec() *RoutingTreeSpec {
return &RoutingTreeSpec{
Defaults: *NewRoutingTreeRouteDefaults(),
}
}
// +k8s:openapi-gen=true
type RoutingTreeMatcherType string
const (
RoutingTreeMatcherTypeEqual RoutingTreeMatcherType = "="
RoutingTreeMatcherTypeNotEqual RoutingTreeMatcherType = "!="
RoutingTreeMatcherTypeEqualRegex RoutingTreeMatcherType = "=~"
RoutingTreeMatcherTypeNotEqualRegex RoutingTreeMatcherType = "!~"
)

View file

@ -3,42 +3,42 @@
package v0alpha1
// +k8s:openapi-gen=true
type StatusOperatorState struct {
type RoutingTreestatusOperatorState struct {
// lastEvaluation is the ResourceVersion last evaluated
LastEvaluation string `json:"lastEvaluation"`
// state describes the state of the lastEvaluation.
// It is limited to three possible states for machine evaluation.
State StatusOperatorStateState `json:"state"`
State RoutingTreeStatusOperatorStateState `json:"state"`
// descriptiveState is an optional more descriptive state field which has no requirements on format
DescriptiveState *string `json:"descriptiveState,omitempty"`
// details contains any extra information that is operator-specific
Details map[string]interface{} `json:"details,omitempty"`
}
// NewStatusOperatorState creates a new StatusOperatorState object.
func NewStatusOperatorState() *StatusOperatorState {
return &StatusOperatorState{}
// NewRoutingTreestatusOperatorState creates a new RoutingTreestatusOperatorState object.
func NewRoutingTreestatusOperatorState() *RoutingTreestatusOperatorState {
return &RoutingTreestatusOperatorState{}
}
// +k8s:openapi-gen=true
type Status struct {
type RoutingTreeStatus struct {
// 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]StatusOperatorState `json:"operatorStates,omitempty"`
OperatorStates map[string]RoutingTreestatusOperatorState `json:"operatorStates,omitempty"`
// additionalFields is reserved for future use
AdditionalFields map[string]interface{} `json:"additionalFields,omitempty"`
}
// NewStatus creates a new Status object.
func NewStatus() *Status {
return &Status{}
// NewRoutingTreeStatus creates a new RoutingTreeStatus object.
func NewRoutingTreeStatus() *RoutingTreeStatus {
return &RoutingTreeStatus{}
}
// +k8s:openapi-gen=true
type StatusOperatorStateState string
type RoutingTreeStatusOperatorStateState string
const (
StatusOperatorStateStateSuccess StatusOperatorStateState = "success"
StatusOperatorStateStateInProgress StatusOperatorStateState = "in_progress"
StatusOperatorStateStateFailed StatusOperatorStateState = "failed"
RoutingTreeStatusOperatorStateStateSuccess RoutingTreeStatusOperatorStateState = "success"
RoutingTreeStatusOperatorStateStateInProgress RoutingTreeStatusOperatorStateState = "in_progress"
RoutingTreeStatusOperatorStateStateFailed RoutingTreeStatusOperatorStateState = "failed"
)

View file

@ -11,18 +11,18 @@ import (
"github.com/grafana/grafana-app-sdk/resource"
)
// JSONCodec is an implementation of resource.Codec for kubernetes JSON encoding
type JSONCodec struct{}
// TemplateGroupJSONCodec is an implementation of resource.Codec for kubernetes JSON encoding
type TemplateGroupJSONCodec struct{}
// Read reads JSON-encoded bytes from `reader` and unmarshals them into `into`
func (*JSONCodec) Read(reader io.Reader, into resource.Object) error {
func (*TemplateGroupJSONCodec) 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 (*JSONCodec) Write(writer io.Writer, from resource.Object) error {
func (*TemplateGroupJSONCodec) Write(writer io.Writer, from resource.Object) error {
return json.NewEncoder(writer).Encode(from)
}
// Interface compliance checks
var _ resource.Codec = &JSONCodec{}
var _ resource.Codec = &TemplateGroupJSONCodec{}

View file

@ -3,8 +3,6 @@ package v0alpha1
import (
"k8s.io/apimachinery/pkg/fields"
"k8s.io/apiserver/pkg/registry/generic"
"github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/alerting/v0alpha1"
)
const DefaultTemplateTitle = "Built-in Templates"
@ -13,9 +11,9 @@ func (o *TemplateGroup) GetProvenanceStatus() string {
if o == nil || o.Annotations == nil {
return ""
}
s, ok := o.Annotations[v0alpha1.ProvenanceStatusAnnotationKey]
s, ok := o.Annotations[ProvenanceStatusAnnotationKey]
if !ok || s == "" {
return v0alpha1.ProvenanceStatusNone
return ProvenanceStatusNone
}
return s
}
@ -25,16 +23,16 @@ func (o *TemplateGroup) SetProvenanceStatus(status string) {
o.Annotations = make(map[string]string, 1)
}
if status == "" {
status = v0alpha1.ProvenanceStatusNone
status = ProvenanceStatusNone
}
o.Annotations[v0alpha1.ProvenanceStatusAnnotationKey] = status
o.Annotations[ProvenanceStatusAnnotationKey] = status
}
func SelectableFields(obj *TemplateGroup) fields.Set {
func TemplateGroupSelectableFields(obj *TemplateGroup) fields.Set {
if obj == nil {
return nil
}
selectable := Schema().SelectableFields()
selectable := TemplateGroupSchema().SelectableFields()
set := make(fields.Set, len(selectable))
for _, field := range selectable {
f, err := field.FieldValueFunc(obj)

View file

@ -9,7 +9,7 @@ import (
// metadata contains embedded CommonMetadata and can be extended with custom string fields
// TODO: use CommonMetadata instead of redefining here; currently needs to be defined here
// without external reference as using the CommonMetadata reference breaks thema codegen.
type Metadata struct {
type TemplateGroupMetadata struct {
UpdateTimestamp time.Time `json:"updateTimestamp"`
CreatedBy string `json:"createdBy"`
Uid string `json:"uid"`
@ -22,7 +22,7 @@ type Metadata struct {
Labels map[string]string `json:"labels"`
}
// NewMetadata creates a new Metadata object.
func NewMetadata() *Metadata {
return &Metadata{}
// NewTemplateGroupMetadata creates a new TemplateGroupMetadata object.
func NewTemplateGroupMetadata() *TemplateGroupMetadata {
return &TemplateGroupMetadata{}
}

View file

@ -20,9 +20,9 @@ type TemplateGroup struct {
metav1.ObjectMeta `json:"metadata" yaml:"metadata"`
// Spec is the spec of the TemplateGroup
Spec Spec `json:"spec" yaml:"spec"`
Spec TemplateGroupSpec `json:"spec" yaml:"spec"`
Status Status `json:"status" yaml:"status"`
Status TemplateGroupStatus `json:"status" yaml:"status"`
}
func (o *TemplateGroup) GetSpec() any {
@ -30,7 +30,7 @@ func (o *TemplateGroup) GetSpec() any {
}
func (o *TemplateGroup) SetSpec(spec any) error {
cast, ok := spec.(Spec)
cast, ok := spec.(TemplateGroupSpec)
if !ok {
return fmt.Errorf("cannot set spec type %#v, not of type Spec", spec)
}
@ -56,9 +56,9 @@ func (o *TemplateGroup) GetSubresource(name string) (any, bool) {
func (o *TemplateGroup) SetSubresource(name string, value any) error {
switch name {
case "status":
cast, ok := value.(Status)
cast, ok := value.(TemplateGroupStatus)
if !ok {
return fmt.Errorf("cannot set status type %#v, not of type Status", value)
return fmt.Errorf("cannot set status type %#v, not of type TemplateGroupStatus", value)
}
o.Status = cast
return nil
@ -295,25 +295,25 @@ var _ resource.ListObject = &TemplateGroupList{}
// Copy methods for all subresource types
// DeepCopy creates a full deep copy of Spec
func (s *Spec) DeepCopy() *Spec {
cpy := &Spec{}
func (s *TemplateGroupSpec) DeepCopy() *TemplateGroupSpec {
cpy := &TemplateGroupSpec{}
s.DeepCopyInto(cpy)
return cpy
}
// DeepCopyInto deep copies Spec into another Spec object
func (s *Spec) DeepCopyInto(dst *Spec) {
func (s *TemplateGroupSpec) DeepCopyInto(dst *TemplateGroupSpec) {
resource.CopyObjectInto(dst, s)
}
// DeepCopy creates a full deep copy of Status
func (s *Status) DeepCopy() *Status {
cpy := &Status{}
// DeepCopy creates a full deep copy of TemplateGroupStatus
func (s *TemplateGroupStatus) DeepCopy() *TemplateGroupStatus {
cpy := &TemplateGroupStatus{}
s.DeepCopyInto(cpy)
return cpy
}
// DeepCopyInto deep copies Status into another Status object
func (s *Status) DeepCopyInto(dst *Status) {
// DeepCopyInto deep copies TemplateGroupStatus into another TemplateGroupStatus object
func (s *TemplateGroupStatus) DeepCopyInto(dst *TemplateGroupStatus) {
resource.CopyObjectInto(dst, s)
}

View file

@ -13,7 +13,7 @@ import (
// schema is unexported to prevent accidental overwrites
var (
schemaTemplateGroup = resource.NewSimpleSchema("notifications.alerting.grafana.app", "v0alpha1", &TemplateGroup{}, &TemplateGroupList{}, resource.WithKind("TemplateGroup"),
resource.WithPlural("templategroups"), resource.WithScope(resource.NamespacedScope), resource.WithSelectableFields([]resource.SelectableField{{
resource.WithPlural("templategroups"), resource.WithScope(resource.NamespacedScope), resource.WithSelectableFields([]resource.SelectableField{resource.SelectableField{
FieldSelector: "spec.title",
FieldValueFunc: func(o resource.Object) (string, error) {
cast, ok := o.(*TemplateGroup)
@ -27,18 +27,18 @@ var (
kindTemplateGroup = resource.Kind{
Schema: schemaTemplateGroup,
Codecs: map[resource.KindEncoding]resource.Codec{
resource.KindEncodingJSON: &JSONCodec{},
resource.KindEncodingJSON: &TemplateGroupJSONCodec{},
},
}
)
// Kind returns a resource.Kind for this Schema with a JSON codec
func Kind() resource.Kind {
func TemplateGroupKind() resource.Kind {
return kindTemplateGroup
}
// Schema returns a resource.SimpleSchema representation of TemplateGroup
func Schema() *resource.SimpleSchema {
func TemplateGroupSchema() *resource.SimpleSchema {
return schemaTemplateGroup
}

View file

@ -0,0 +1,14 @@
// Code generated - EDITING IS FUTILE. DO NOT EDIT.
package v0alpha1
// +k8s:openapi-gen=true
type TemplateGroupSpec struct {
Title string `json:"title"`
Content string `json:"content"`
}
// NewTemplateGroupSpec creates a new TemplateGroupSpec object.
func NewTemplateGroupSpec() *TemplateGroupSpec {
return &TemplateGroupSpec{}
}

View file

@ -3,42 +3,42 @@
package v0alpha1
// +k8s:openapi-gen=true
type StatusOperatorState struct {
type TemplateGroupstatusOperatorState struct {
// lastEvaluation is the ResourceVersion last evaluated
LastEvaluation string `json:"lastEvaluation"`
// state describes the state of the lastEvaluation.
// It is limited to three possible states for machine evaluation.
State StatusOperatorStateState `json:"state"`
State TemplateGroupStatusOperatorStateState `json:"state"`
// descriptiveState is an optional more descriptive state field which has no requirements on format
DescriptiveState *string `json:"descriptiveState,omitempty"`
// details contains any extra information that is operator-specific
Details map[string]interface{} `json:"details,omitempty"`
}
// NewStatusOperatorState creates a new StatusOperatorState object.
func NewStatusOperatorState() *StatusOperatorState {
return &StatusOperatorState{}
// NewTemplateGroupstatusOperatorState creates a new TemplateGroupstatusOperatorState object.
func NewTemplateGroupstatusOperatorState() *TemplateGroupstatusOperatorState {
return &TemplateGroupstatusOperatorState{}
}
// +k8s:openapi-gen=true
type Status struct {
type TemplateGroupStatus struct {
// 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]StatusOperatorState `json:"operatorStates,omitempty"`
OperatorStates map[string]TemplateGroupstatusOperatorState `json:"operatorStates,omitempty"`
// additionalFields is reserved for future use
AdditionalFields map[string]interface{} `json:"additionalFields,omitempty"`
}
// NewStatus creates a new Status object.
func NewStatus() *Status {
return &Status{}
// NewTemplateGroupStatus creates a new TemplateGroupStatus object.
func NewTemplateGroupStatus() *TemplateGroupStatus {
return &TemplateGroupStatus{}
}
// +k8s:openapi-gen=true
type StatusOperatorStateState string
type TemplateGroupStatusOperatorStateState string
const (
StatusOperatorStateStateSuccess StatusOperatorStateState = "success"
StatusOperatorStateStateInProgress StatusOperatorStateState = "in_progress"
StatusOperatorStateStateFailed StatusOperatorStateState = "failed"
TemplateGroupStatusOperatorStateStateSuccess TemplateGroupStatusOperatorStateState = "success"
TemplateGroupStatusOperatorStateStateInProgress TemplateGroupStatusOperatorStateState = "in_progress"
TemplateGroupStatusOperatorStateStateFailed TemplateGroupStatusOperatorStateState = "failed"
)

View file

@ -11,18 +11,18 @@ import (
"github.com/grafana/grafana-app-sdk/resource"
)
// JSONCodec is an implementation of resource.Codec for kubernetes JSON encoding
type JSONCodec struct{}
// TimeIntervalJSONCodec is an implementation of resource.Codec for kubernetes JSON encoding
type TimeIntervalJSONCodec struct{}
// Read reads JSON-encoded bytes from `reader` and unmarshals them into `into`
func (*JSONCodec) Read(reader io.Reader, into resource.Object) error {
func (*TimeIntervalJSONCodec) 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 (*JSONCodec) Write(writer io.Writer, from resource.Object) error {
func (*TimeIntervalJSONCodec) Write(writer io.Writer, from resource.Object) error {
return json.NewEncoder(writer).Encode(from)
}
// Interface compliance checks
var _ resource.Codec = &JSONCodec{}
var _ resource.Codec = &TimeIntervalJSONCodec{}

View file

@ -3,17 +3,15 @@ package v0alpha1
import (
"k8s.io/apimachinery/pkg/fields"
"k8s.io/apiserver/pkg/registry/generic"
"github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/alerting/v0alpha1"
)
func (o *TimeInterval) GetProvenanceStatus() string {
if o == nil || o.Annotations == nil {
return ""
}
s, ok := o.Annotations[v0alpha1.ProvenanceStatusAnnotationKey]
s, ok := o.Annotations[ProvenanceStatusAnnotationKey]
if !ok || s == "" {
return v0alpha1.ProvenanceStatusNone
return ProvenanceStatusNone
}
return s
}
@ -23,16 +21,16 @@ func (o *TimeInterval) SetProvenanceStatus(status string) {
o.Annotations = make(map[string]string, 1)
}
if status == "" {
status = v0alpha1.ProvenanceStatusNone
status = ProvenanceStatusNone
}
o.Annotations[v0alpha1.ProvenanceStatusAnnotationKey] = status
o.Annotations[ProvenanceStatusAnnotationKey] = status
}
func SelectableFields(obj *TimeInterval) fields.Set {
func TimeIntervalSelectableFields(obj *TimeInterval) fields.Set {
if obj == nil {
return nil
}
selectable := Schema().SelectableFields()
selectable := TimeIntervalSchema().SelectableFields()
set := make(fields.Set, len(selectable))
for _, field := range selectable {
f, err := field.FieldValueFunc(obj)

View file

@ -9,7 +9,7 @@ import (
// metadata contains embedded CommonMetadata and can be extended with custom string fields
// TODO: use CommonMetadata instead of redefining here; currently needs to be defined here
// without external reference as using the CommonMetadata reference breaks thema codegen.
type Metadata struct {
type TimeIntervalMetadata struct {
UpdateTimestamp time.Time `json:"updateTimestamp"`
CreatedBy string `json:"createdBy"`
Uid string `json:"uid"`
@ -22,7 +22,7 @@ type Metadata struct {
Labels map[string]string `json:"labels"`
}
// NewMetadata creates a new Metadata object.
func NewMetadata() *Metadata {
return &Metadata{}
// NewTimeIntervalMetadata creates a new TimeIntervalMetadata object.
func NewTimeIntervalMetadata() *TimeIntervalMetadata {
return &TimeIntervalMetadata{}
}

View file

@ -20,9 +20,9 @@ type TimeInterval struct {
metav1.ObjectMeta `json:"metadata" yaml:"metadata"`
// Spec is the spec of the TimeInterval
Spec Spec `json:"spec" yaml:"spec"`
Spec TimeIntervalSpec `json:"spec" yaml:"spec"`
Status Status `json:"status" yaml:"status"`
Status TimeIntervalStatus `json:"status" yaml:"status"`
}
func (o *TimeInterval) GetSpec() any {
@ -30,7 +30,7 @@ func (o *TimeInterval) GetSpec() any {
}
func (o *TimeInterval) SetSpec(spec any) error {
cast, ok := spec.(Spec)
cast, ok := spec.(TimeIntervalSpec)
if !ok {
return fmt.Errorf("cannot set spec type %#v, not of type Spec", spec)
}
@ -56,9 +56,9 @@ func (o *TimeInterval) GetSubresource(name string) (any, bool) {
func (o *TimeInterval) SetSubresource(name string, value any) error {
switch name {
case "status":
cast, ok := value.(Status)
cast, ok := value.(TimeIntervalStatus)
if !ok {
return fmt.Errorf("cannot set status type %#v, not of type Status", value)
return fmt.Errorf("cannot set status type %#v, not of type TimeIntervalStatus", value)
}
o.Status = cast
return nil
@ -295,25 +295,25 @@ var _ resource.ListObject = &TimeIntervalList{}
// Copy methods for all subresource types
// DeepCopy creates a full deep copy of Spec
func (s *Spec) DeepCopy() *Spec {
cpy := &Spec{}
func (s *TimeIntervalSpec) DeepCopy() *TimeIntervalSpec {
cpy := &TimeIntervalSpec{}
s.DeepCopyInto(cpy)
return cpy
}
// DeepCopyInto deep copies Spec into another Spec object
func (s *Spec) DeepCopyInto(dst *Spec) {
func (s *TimeIntervalSpec) DeepCopyInto(dst *TimeIntervalSpec) {
resource.CopyObjectInto(dst, s)
}
// DeepCopy creates a full deep copy of Status
func (s *Status) DeepCopy() *Status {
cpy := &Status{}
// DeepCopy creates a full deep copy of TimeIntervalStatus
func (s *TimeIntervalStatus) DeepCopy() *TimeIntervalStatus {
cpy := &TimeIntervalStatus{}
s.DeepCopyInto(cpy)
return cpy
}
// DeepCopyInto deep copies Status into another Status object
func (s *Status) DeepCopyInto(dst *Status) {
// DeepCopyInto deep copies TimeIntervalStatus into another TimeIntervalStatus object
func (s *TimeIntervalStatus) DeepCopyInto(dst *TimeIntervalStatus) {
resource.CopyObjectInto(dst, s)
}

View file

@ -13,7 +13,7 @@ import (
// schema is unexported to prevent accidental overwrites
var (
schemaTimeInterval = resource.NewSimpleSchema("notifications.alerting.grafana.app", "v0alpha1", &TimeInterval{}, &TimeIntervalList{}, resource.WithKind("TimeInterval"),
resource.WithPlural("timeintervals"), resource.WithScope(resource.NamespacedScope), resource.WithSelectableFields([]resource.SelectableField{{
resource.WithPlural("timeintervals"), resource.WithScope(resource.NamespacedScope), resource.WithSelectableFields([]resource.SelectableField{resource.SelectableField{
FieldSelector: "spec.name",
FieldValueFunc: func(o resource.Object) (string, error) {
cast, ok := o.(*TimeInterval)
@ -27,18 +27,18 @@ var (
kindTimeInterval = resource.Kind{
Schema: schemaTimeInterval,
Codecs: map[resource.KindEncoding]resource.Codec{
resource.KindEncodingJSON: &JSONCodec{},
resource.KindEncodingJSON: &TimeIntervalJSONCodec{},
},
}
)
// Kind returns a resource.Kind for this Schema with a JSON codec
func Kind() resource.Kind {
func TimeIntervalKind() resource.Kind {
return kindTimeInterval
}
// Schema returns a resource.SimpleSchema representation of TimeInterval
func Schema() *resource.SimpleSchema {
func TimeIntervalSchema() *resource.SimpleSchema {
return schemaTimeInterval
}

View file

@ -0,0 +1,40 @@
// Code generated - EDITING IS FUTILE. DO NOT EDIT.
package v0alpha1
// +k8s:openapi-gen=true
type TimeIntervalInterval struct {
Times []TimeIntervalTimeRange `json:"times,omitempty"`
Weekdays []string `json:"weekdays,omitempty"`
DaysOfMonth []string `json:"days_of_month,omitempty"`
Months []string `json:"months,omitempty"`
Years []string `json:"years,omitempty"`
Location *string `json:"location,omitempty"`
}
// NewTimeIntervalInterval creates a new TimeIntervalInterval object.
func NewTimeIntervalInterval() *TimeIntervalInterval {
return &TimeIntervalInterval{}
}
// +k8s:openapi-gen=true
type TimeIntervalTimeRange struct {
StartTime string `json:"start_time"`
EndTime string `json:"end_time"`
}
// NewTimeIntervalTimeRange creates a new TimeIntervalTimeRange object.
func NewTimeIntervalTimeRange() *TimeIntervalTimeRange {
return &TimeIntervalTimeRange{}
}
// +k8s:openapi-gen=true
type TimeIntervalSpec struct {
Name string `json:"name"`
TimeIntervals []TimeIntervalInterval `json:"time_intervals"`
}
// NewTimeIntervalSpec creates a new TimeIntervalSpec object.
func NewTimeIntervalSpec() *TimeIntervalSpec {
return &TimeIntervalSpec{}
}

View file

@ -3,42 +3,42 @@
package v0alpha1
// +k8s:openapi-gen=true
type StatusOperatorState struct {
type TimeIntervalstatusOperatorState struct {
// lastEvaluation is the ResourceVersion last evaluated
LastEvaluation string `json:"lastEvaluation"`
// state describes the state of the lastEvaluation.
// It is limited to three possible states for machine evaluation.
State StatusOperatorStateState `json:"state"`
State TimeIntervalStatusOperatorStateState `json:"state"`
// descriptiveState is an optional more descriptive state field which has no requirements on format
DescriptiveState *string `json:"descriptiveState,omitempty"`
// details contains any extra information that is operator-specific
Details map[string]interface{} `json:"details,omitempty"`
}
// NewStatusOperatorState creates a new StatusOperatorState object.
func NewStatusOperatorState() *StatusOperatorState {
return &StatusOperatorState{}
// NewTimeIntervalstatusOperatorState creates a new TimeIntervalstatusOperatorState object.
func NewTimeIntervalstatusOperatorState() *TimeIntervalstatusOperatorState {
return &TimeIntervalstatusOperatorState{}
}
// +k8s:openapi-gen=true
type Status struct {
type TimeIntervalStatus struct {
// 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]StatusOperatorState `json:"operatorStates,omitempty"`
OperatorStates map[string]TimeIntervalstatusOperatorState `json:"operatorStates,omitempty"`
// additionalFields is reserved for future use
AdditionalFields map[string]interface{} `json:"additionalFields,omitempty"`
}
// NewStatus creates a new Status object.
func NewStatus() *Status {
return &Status{}
// NewTimeIntervalStatus creates a new TimeIntervalStatus object.
func NewTimeIntervalStatus() *TimeIntervalStatus {
return &TimeIntervalStatus{}
}
// +k8s:openapi-gen=true
type StatusOperatorStateState string
type TimeIntervalStatusOperatorStateState string
const (
StatusOperatorStateStateSuccess StatusOperatorStateState = "success"
StatusOperatorStateStateInProgress StatusOperatorStateState = "in_progress"
StatusOperatorStateStateFailed StatusOperatorStateState = "failed"
TimeIntervalStatusOperatorStateStateSuccess TimeIntervalStatusOperatorStateState = "success"
TimeIntervalStatusOperatorStateStateInProgress TimeIntervalStatusOperatorStateState = "in_progress"
TimeIntervalStatusOperatorStateStateFailed TimeIntervalStatusOperatorStateState = "failed"
)

File diff suppressed because it is too large Load diff

View file

@ -11,6 +11,8 @@ import (
"github.com/grafana/grafana-app-sdk/app"
)
var ()
var appManifestData = app.ManifestData{
AppName: "alerting",
Group: "notifications.alerting.grafana.app",

View file

@ -1,18 +0,0 @@
package v0alpha1
import "k8s.io/apimachinery/pkg/runtime/schema"
const (
// Group is the API group used by all kinds in this package
Group = "notifications.alerting.grafana.app"
// Version is the API version used by all kinds in this package
Version = "v0alpha1"
)
var (
// GroupVersion is a schema.GroupVersion consisting of the Group and Version constants for this package
GroupVersion = schema.GroupVersion{
Group: Group,
Version: Version,
}
)

View file

@ -1,311 +0,0 @@
//go:build !ignore_autogenerated
// +build !ignore_autogenerated
// SPDX-License-Identifier: AGPL-3.0-only
// Code generated by openapi-gen. DO NOT EDIT.
package v0alpha1
import (
common "k8s.io/kube-openapi/pkg/common"
spec "k8s.io/kube-openapi/pkg/validation/spec"
)
func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenAPIDefinition {
return map[string]common.OpenAPIDefinition{
"github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/receiver/v0alpha1.Integration": schema_pkg_apis_receiver_v0alpha1_Integration(ref),
"github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/receiver/v0alpha1.Receiver": schema_pkg_apis_receiver_v0alpha1_Receiver(ref),
"github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/receiver/v0alpha1.ReceiverList": schema_pkg_apis_receiver_v0alpha1_ReceiverList(ref),
"github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/receiver/v0alpha1.Spec": schema_pkg_apis_receiver_v0alpha1_Spec(ref),
"github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/receiver/v0alpha1.Status": schema_pkg_apis_receiver_v0alpha1_Status(ref),
"github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/receiver/v0alpha1.StatusOperatorState": schema_pkg_apis_receiver_v0alpha1_StatusOperatorState(ref),
}
}
func schema_pkg_apis_receiver_v0alpha1_Integration(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
Type: []string{"object"},
Properties: map[string]spec.Schema{
"uid": {
SchemaProps: spec.SchemaProps{
Type: []string{"string"},
Format: "",
},
},
"type": {
SchemaProps: spec.SchemaProps{
Default: "",
Type: []string{"string"},
Format: "",
},
},
"disableResolveMessage": {
SchemaProps: spec.SchemaProps{
Type: []string{"boolean"},
Format: "",
},
},
"settings": {
SchemaProps: spec.SchemaProps{
Type: []string{"object"},
AdditionalProperties: &spec.SchemaOrBool{
Allows: true,
Schema: &spec.Schema{
SchemaProps: spec.SchemaProps{
Type: []string{"object"},
Format: "",
},
},
},
},
},
"secureFields": {
SchemaProps: spec.SchemaProps{
Type: []string{"object"},
AdditionalProperties: &spec.SchemaOrBool{
Allows: true,
Schema: &spec.Schema{
SchemaProps: spec.SchemaProps{
Default: false,
Type: []string{"boolean"},
Format: "",
},
},
},
},
},
},
Required: []string{"type", "settings"},
},
},
}
}
func schema_pkg_apis_receiver_v0alpha1_Receiver(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
Type: []string{"object"},
Properties: map[string]spec.Schema{
"kind": {
SchemaProps: spec.SchemaProps{
Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds",
Type: []string{"string"},
Format: "",
},
},
"apiVersion": {
SchemaProps: spec.SchemaProps{
Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources",
Type: []string{"string"},
Format: "",
},
},
"metadata": {
SchemaProps: spec.SchemaProps{
Default: map[string]interface{}{},
Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"),
},
},
"spec": {
SchemaProps: spec.SchemaProps{
Description: "Spec is the spec of the Receiver",
Default: map[string]interface{}{},
Ref: ref("github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/receiver/v0alpha1.Spec"),
},
},
"status": {
SchemaProps: spec.SchemaProps{
Default: map[string]interface{}{},
Ref: ref("github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/receiver/v0alpha1.Status"),
},
},
},
Required: []string{"metadata", "spec", "status"},
},
},
Dependencies: []string{
"github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/receiver/v0alpha1.Spec", "github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/receiver/v0alpha1.Status", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"},
}
}
func schema_pkg_apis_receiver_v0alpha1_ReceiverList(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
Type: []string{"object"},
Properties: map[string]spec.Schema{
"kind": {
SchemaProps: spec.SchemaProps{
Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds",
Type: []string{"string"},
Format: "",
},
},
"apiVersion": {
SchemaProps: spec.SchemaProps{
Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources",
Type: []string{"string"},
Format: "",
},
},
"metadata": {
SchemaProps: spec.SchemaProps{
Default: map[string]interface{}{},
Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"),
},
},
"items": {
SchemaProps: spec.SchemaProps{
Type: []string{"array"},
Items: &spec.SchemaOrArray{
Schema: &spec.Schema{
SchemaProps: spec.SchemaProps{
Default: map[string]interface{}{},
Ref: ref("github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/receiver/v0alpha1.Receiver"),
},
},
},
},
},
},
Required: []string{"metadata", "items"},
},
},
Dependencies: []string{
"github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/receiver/v0alpha1.Receiver", "k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"},
}
}
func schema_pkg_apis_receiver_v0alpha1_Spec(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
Type: []string{"object"},
Properties: map[string]spec.Schema{
"title": {
SchemaProps: spec.SchemaProps{
Default: "",
Type: []string{"string"},
Format: "",
},
},
"integrations": {
SchemaProps: spec.SchemaProps{
Type: []string{"array"},
Items: &spec.SchemaOrArray{
Schema: &spec.Schema{
SchemaProps: spec.SchemaProps{
Default: map[string]interface{}{},
Ref: ref("github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/receiver/v0alpha1.Integration"),
},
},
},
},
},
},
Required: []string{"title", "integrations"},
},
},
Dependencies: []string{
"github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/receiver/v0alpha1.Integration"},
}
}
func schema_pkg_apis_receiver_v0alpha1_Status(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
Type: []string{"object"},
Properties: map[string]spec.Schema{
"operatorStates": {
SchemaProps: spec.SchemaProps{
Description: "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.",
Type: []string{"object"},
AdditionalProperties: &spec.SchemaOrBool{
Allows: true,
Schema: &spec.Schema{
SchemaProps: spec.SchemaProps{
Default: map[string]interface{}{},
Ref: ref("github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/receiver/v0alpha1.StatusOperatorState"),
},
},
},
},
},
"additionalFields": {
SchemaProps: spec.SchemaProps{
Description: "additionalFields is reserved for future use",
Type: []string{"object"},
AdditionalProperties: &spec.SchemaOrBool{
Allows: true,
Schema: &spec.Schema{
SchemaProps: spec.SchemaProps{
Type: []string{"object"},
Format: "",
},
},
},
},
},
},
},
},
Dependencies: []string{
"github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/receiver/v0alpha1.StatusOperatorState"},
}
}
func schema_pkg_apis_receiver_v0alpha1_StatusOperatorState(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
Type: []string{"object"},
Properties: map[string]spec.Schema{
"lastEvaluation": {
SchemaProps: spec.SchemaProps{
Description: "lastEvaluation is the ResourceVersion last evaluated",
Default: "",
Type: []string{"string"},
Format: "",
},
},
"state": {
SchemaProps: spec.SchemaProps{
Description: "state describes the state of the lastEvaluation. It is limited to three possible states for machine evaluation.",
Default: "",
Type: []string{"string"},
Format: "",
},
},
"descriptiveState": {
SchemaProps: spec.SchemaProps{
Description: "descriptiveState is an optional more descriptive state field which has no requirements on format",
Type: []string{"string"},
Format: "",
},
},
"details": {
SchemaProps: spec.SchemaProps{
Description: "details contains any extra information that is operator-specific",
Type: []string{"object"},
AdditionalProperties: &spec.SchemaOrBool{
Allows: true,
Schema: &spec.Schema{
SchemaProps: spec.SchemaProps{
Type: []string{"object"},
Format: "",
},
},
},
},
},
},
Required: []string{"lastEvaluation", "state"},
},
},
}
}

View file

@ -1 +0,0 @@
API rule violation: list_type_missing,github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/receiver/v0alpha1,Spec,Integrations

View file

@ -1,18 +0,0 @@
package v0alpha1
import "k8s.io/apimachinery/pkg/runtime/schema"
const (
// Group is the API group used by all kinds in this package
Group = "notifications.alerting.grafana.app"
// Version is the API version used by all kinds in this package
Version = "v0alpha1"
)
var (
// GroupVersion is a schema.GroupVersion consisting of the Group and Version constants for this package
GroupVersion = schema.GroupVersion{
Group: Group,
Version: Version,
}
)

View file

@ -1,71 +0,0 @@
// Code generated - EDITING IS FUTILE. DO NOT EDIT.
package v0alpha1
// +k8s:openapi-gen=true
type RouteDefaults struct {
Receiver string `json:"receiver"`
GroupBy []string `json:"group_by,omitempty"`
GroupWait *string `json:"group_wait,omitempty"`
GroupInterval *string `json:"group_interval,omitempty"`
RepeatInterval *string `json:"repeat_interval,omitempty"`
}
// NewRouteDefaults creates a new RouteDefaults object.
func NewRouteDefaults() *RouteDefaults {
return &RouteDefaults{}
}
// +k8s:openapi-gen=true
type Route struct {
Receiver *string `json:"receiver,omitempty"`
Matchers []Matcher `json:"matchers,omitempty"`
Continue bool `json:"continue"`
GroupBy []string `json:"group_by,omitempty"`
MuteTimeIntervals []string `json:"mute_time_intervals,omitempty"`
ActiveTimeIntervals []string `json:"active_time_intervals,omitempty"`
Routes []Route `json:"routes,omitempty"`
GroupWait *string `json:"group_wait,omitempty"`
GroupInterval *string `json:"group_interval,omitempty"`
RepeatInterval *string `json:"repeat_interval,omitempty"`
}
// NewRoute creates a new Route object.
func NewRoute() *Route {
return &Route{}
}
// +k8s:openapi-gen=true
type Matcher struct {
Type MatcherType `json:"type"`
Label string `json:"label"`
Value string `json:"value"`
}
// NewMatcher creates a new Matcher object.
func NewMatcher() *Matcher {
return &Matcher{}
}
// +k8s:openapi-gen=true
type Spec struct {
Defaults RouteDefaults `json:"defaults"`
Routes []Route `json:"routes"`
}
// NewSpec creates a new Spec object.
func NewSpec() *Spec {
return &Spec{
Defaults: *NewRouteDefaults(),
}
}
// +k8s:openapi-gen=true
type MatcherType string
const (
MatcherTypeEqual MatcherType = "="
MatcherTypeNotEqual MatcherType = "!="
MatcherTypeEqualRegex MatcherType = "=~"
MatcherTypeNotEqualRegex MatcherType = "!~"
)

View file

@ -1,451 +0,0 @@
//go:build !ignore_autogenerated
// +build !ignore_autogenerated
// SPDX-License-Identifier: AGPL-3.0-only
// Code generated by openapi-gen. DO NOT EDIT.
package v0alpha1
import (
common "k8s.io/kube-openapi/pkg/common"
spec "k8s.io/kube-openapi/pkg/validation/spec"
)
func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenAPIDefinition {
return map[string]common.OpenAPIDefinition{
"github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/routingtree/v0alpha1.Matcher": schema_pkg_apis_routingtree_v0alpha1_Matcher(ref),
"github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/routingtree/v0alpha1.Route": schema_pkg_apis_routingtree_v0alpha1_Route(ref),
"github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/routingtree/v0alpha1.RouteDefaults": schema_pkg_apis_routingtree_v0alpha1_RouteDefaults(ref),
"github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/routingtree/v0alpha1.RoutingTree": schema_pkg_apis_routingtree_v0alpha1_RoutingTree(ref),
"github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/routingtree/v0alpha1.RoutingTreeList": schema_pkg_apis_routingtree_v0alpha1_RoutingTreeList(ref),
"github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/routingtree/v0alpha1.Spec": schema_pkg_apis_routingtree_v0alpha1_Spec(ref),
"github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/routingtree/v0alpha1.Status": schema_pkg_apis_routingtree_v0alpha1_Status(ref),
"github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/routingtree/v0alpha1.StatusOperatorState": schema_pkg_apis_routingtree_v0alpha1_StatusOperatorState(ref),
}
}
func schema_pkg_apis_routingtree_v0alpha1_Matcher(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
Type: []string{"object"},
Properties: map[string]spec.Schema{
"type": {
SchemaProps: spec.SchemaProps{
Default: "",
Type: []string{"string"},
Format: "",
},
},
"label": {
SchemaProps: spec.SchemaProps{
Default: "",
Type: []string{"string"},
Format: "",
},
},
"value": {
SchemaProps: spec.SchemaProps{
Default: "",
Type: []string{"string"},
Format: "",
},
},
},
Required: []string{"type", "label", "value"},
},
},
}
}
func schema_pkg_apis_routingtree_v0alpha1_Route(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
Type: []string{"object"},
Properties: map[string]spec.Schema{
"receiver": {
SchemaProps: spec.SchemaProps{
Type: []string{"string"},
Format: "",
},
},
"matchers": {
SchemaProps: spec.SchemaProps{
Type: []string{"array"},
Items: &spec.SchemaOrArray{
Schema: &spec.Schema{
SchemaProps: spec.SchemaProps{
Default: map[string]interface{}{},
Ref: ref("github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/routingtree/v0alpha1.Matcher"),
},
},
},
},
},
"continue": {
SchemaProps: spec.SchemaProps{
Default: false,
Type: []string{"boolean"},
Format: "",
},
},
"group_by": {
SchemaProps: spec.SchemaProps{
Type: []string{"array"},
Items: &spec.SchemaOrArray{
Schema: &spec.Schema{
SchemaProps: spec.SchemaProps{
Default: "",
Type: []string{"string"},
Format: "",
},
},
},
},
},
"mute_time_intervals": {
SchemaProps: spec.SchemaProps{
Type: []string{"array"},
Items: &spec.SchemaOrArray{
Schema: &spec.Schema{
SchemaProps: spec.SchemaProps{
Default: "",
Type: []string{"string"},
Format: "",
},
},
},
},
},
"active_time_intervals": {
SchemaProps: spec.SchemaProps{
Type: []string{"array"},
Items: &spec.SchemaOrArray{
Schema: &spec.Schema{
SchemaProps: spec.SchemaProps{
Default: "",
Type: []string{"string"},
Format: "",
},
},
},
},
},
"routes": {
SchemaProps: spec.SchemaProps{
Type: []string{"array"},
Items: &spec.SchemaOrArray{
Schema: &spec.Schema{
SchemaProps: spec.SchemaProps{
Default: map[string]interface{}{},
Ref: ref("github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/routingtree/v0alpha1.Route"),
},
},
},
},
},
"group_wait": {
SchemaProps: spec.SchemaProps{
Type: []string{"string"},
Format: "",
},
},
"group_interval": {
SchemaProps: spec.SchemaProps{
Type: []string{"string"},
Format: "",
},
},
"repeat_interval": {
SchemaProps: spec.SchemaProps{
Type: []string{"string"},
Format: "",
},
},
},
Required: []string{"continue"},
},
},
Dependencies: []string{
"github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/routingtree/v0alpha1.Matcher", "github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/routingtree/v0alpha1.Route"},
}
}
func schema_pkg_apis_routingtree_v0alpha1_RouteDefaults(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
Type: []string{"object"},
Properties: map[string]spec.Schema{
"receiver": {
SchemaProps: spec.SchemaProps{
Default: "",
Type: []string{"string"},
Format: "",
},
},
"group_by": {
SchemaProps: spec.SchemaProps{
Type: []string{"array"},
Items: &spec.SchemaOrArray{
Schema: &spec.Schema{
SchemaProps: spec.SchemaProps{
Default: "",
Type: []string{"string"},
Format: "",
},
},
},
},
},
"group_wait": {
SchemaProps: spec.SchemaProps{
Type: []string{"string"},
Format: "",
},
},
"group_interval": {
SchemaProps: spec.SchemaProps{
Type: []string{"string"},
Format: "",
},
},
"repeat_interval": {
SchemaProps: spec.SchemaProps{
Type: []string{"string"},
Format: "",
},
},
},
Required: []string{"receiver"},
},
},
}
}
func schema_pkg_apis_routingtree_v0alpha1_RoutingTree(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
Type: []string{"object"},
Properties: map[string]spec.Schema{
"kind": {
SchemaProps: spec.SchemaProps{
Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds",
Type: []string{"string"},
Format: "",
},
},
"apiVersion": {
SchemaProps: spec.SchemaProps{
Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources",
Type: []string{"string"},
Format: "",
},
},
"metadata": {
SchemaProps: spec.SchemaProps{
Default: map[string]interface{}{},
Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"),
},
},
"spec": {
SchemaProps: spec.SchemaProps{
Description: "Spec is the spec of the RoutingTree",
Default: map[string]interface{}{},
Ref: ref("github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/routingtree/v0alpha1.Spec"),
},
},
"status": {
SchemaProps: spec.SchemaProps{
Default: map[string]interface{}{},
Ref: ref("github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/routingtree/v0alpha1.Status"),
},
},
},
Required: []string{"metadata", "spec", "status"},
},
},
Dependencies: []string{
"github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/routingtree/v0alpha1.Spec", "github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/routingtree/v0alpha1.Status", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"},
}
}
func schema_pkg_apis_routingtree_v0alpha1_RoutingTreeList(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
Type: []string{"object"},
Properties: map[string]spec.Schema{
"kind": {
SchemaProps: spec.SchemaProps{
Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds",
Type: []string{"string"},
Format: "",
},
},
"apiVersion": {
SchemaProps: spec.SchemaProps{
Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources",
Type: []string{"string"},
Format: "",
},
},
"metadata": {
SchemaProps: spec.SchemaProps{
Default: map[string]interface{}{},
Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"),
},
},
"items": {
SchemaProps: spec.SchemaProps{
Type: []string{"array"},
Items: &spec.SchemaOrArray{
Schema: &spec.Schema{
SchemaProps: spec.SchemaProps{
Default: map[string]interface{}{},
Ref: ref("github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/routingtree/v0alpha1.RoutingTree"),
},
},
},
},
},
},
Required: []string{"metadata", "items"},
},
},
Dependencies: []string{
"github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/routingtree/v0alpha1.RoutingTree", "k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"},
}
}
func schema_pkg_apis_routingtree_v0alpha1_Spec(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
Type: []string{"object"},
Properties: map[string]spec.Schema{
"defaults": {
SchemaProps: spec.SchemaProps{
Default: map[string]interface{}{},
Ref: ref("github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/routingtree/v0alpha1.RouteDefaults"),
},
},
"routes": {
SchemaProps: spec.SchemaProps{
Type: []string{"array"},
Items: &spec.SchemaOrArray{
Schema: &spec.Schema{
SchemaProps: spec.SchemaProps{
Default: map[string]interface{}{},
Ref: ref("github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/routingtree/v0alpha1.Route"),
},
},
},
},
},
},
Required: []string{"defaults", "routes"},
},
},
Dependencies: []string{
"github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/routingtree/v0alpha1.Route", "github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/routingtree/v0alpha1.RouteDefaults"},
}
}
func schema_pkg_apis_routingtree_v0alpha1_Status(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
Type: []string{"object"},
Properties: map[string]spec.Schema{
"operatorStates": {
SchemaProps: spec.SchemaProps{
Description: "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.",
Type: []string{"object"},
AdditionalProperties: &spec.SchemaOrBool{
Allows: true,
Schema: &spec.Schema{
SchemaProps: spec.SchemaProps{
Default: map[string]interface{}{},
Ref: ref("github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/routingtree/v0alpha1.StatusOperatorState"),
},
},
},
},
},
"additionalFields": {
SchemaProps: spec.SchemaProps{
Description: "additionalFields is reserved for future use",
Type: []string{"object"},
AdditionalProperties: &spec.SchemaOrBool{
Allows: true,
Schema: &spec.Schema{
SchemaProps: spec.SchemaProps{
Type: []string{"object"},
Format: "",
},
},
},
},
},
},
},
},
Dependencies: []string{
"github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/routingtree/v0alpha1.StatusOperatorState"},
}
}
func schema_pkg_apis_routingtree_v0alpha1_StatusOperatorState(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
Type: []string{"object"},
Properties: map[string]spec.Schema{
"lastEvaluation": {
SchemaProps: spec.SchemaProps{
Description: "lastEvaluation is the ResourceVersion last evaluated",
Default: "",
Type: []string{"string"},
Format: "",
},
},
"state": {
SchemaProps: spec.SchemaProps{
Description: "state describes the state of the lastEvaluation. It is limited to three possible states for machine evaluation.",
Default: "",
Type: []string{"string"},
Format: "",
},
},
"descriptiveState": {
SchemaProps: spec.SchemaProps{
Description: "descriptiveState is an optional more descriptive state field which has no requirements on format",
Type: []string{"string"},
Format: "",
},
},
"details": {
SchemaProps: spec.SchemaProps{
Description: "details contains any extra information that is operator-specific",
Type: []string{"object"},
AdditionalProperties: &spec.SchemaOrBool{
Allows: true,
Schema: &spec.Schema{
SchemaProps: spec.SchemaProps{
Type: []string{"object"},
Format: "",
},
},
},
},
},
},
Required: []string{"lastEvaluation", "state"},
},
},
}
}

View file

@ -1,17 +0,0 @@
API rule violation: list_type_missing,github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/routingtree/v0alpha1,Route,ActiveTimeIntervals
API rule violation: list_type_missing,github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/routingtree/v0alpha1,Route,GroupBy
API rule violation: list_type_missing,github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/routingtree/v0alpha1,Route,Matchers
API rule violation: list_type_missing,github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/routingtree/v0alpha1,Route,MuteTimeIntervals
API rule violation: list_type_missing,github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/routingtree/v0alpha1,Route,Routes
API rule violation: list_type_missing,github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/routingtree/v0alpha1,RouteDefaults,GroupBy
API rule violation: list_type_missing,github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/routingtree/v0alpha1,Spec,Routes
API rule violation: names_match,github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/routingtree/v0alpha1,Route,ActiveTimeIntervals
API rule violation: names_match,github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/routingtree/v0alpha1,Route,GroupBy
API rule violation: names_match,github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/routingtree/v0alpha1,Route,GroupInterval
API rule violation: names_match,github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/routingtree/v0alpha1,Route,GroupWait
API rule violation: names_match,github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/routingtree/v0alpha1,Route,MuteTimeIntervals
API rule violation: names_match,github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/routingtree/v0alpha1,Route,RepeatInterval
API rule violation: names_match,github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/routingtree/v0alpha1,RouteDefaults,GroupBy
API rule violation: names_match,github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/routingtree/v0alpha1,RouteDefaults,GroupInterval
API rule violation: names_match,github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/routingtree/v0alpha1,RouteDefaults,GroupWait
API rule violation: names_match,github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/routingtree/v0alpha1,RouteDefaults,RepeatInterval

View file

@ -1,18 +0,0 @@
package v0alpha1
import "k8s.io/apimachinery/pkg/runtime/schema"
const (
// Group is the API group used by all kinds in this package
Group = "notifications.alerting.grafana.app"
// Version is the API version used by all kinds in this package
Version = "v0alpha1"
)
var (
// GroupVersion is a schema.GroupVersion consisting of the Group and Version constants for this package
GroupVersion = schema.GroupVersion{
Group: Group,
Version: Version,
}
)

View file

@ -1,14 +0,0 @@
// Code generated - EDITING IS FUTILE. DO NOT EDIT.
package v0alpha1
// +k8s:openapi-gen=true
type Spec struct {
Title string `json:"title"`
Content string `json:"content"`
}
// NewSpec creates a new Spec object.
func NewSpec() *Spec {
return &Spec{}
}

View file

@ -1,241 +0,0 @@
//go:build !ignore_autogenerated
// +build !ignore_autogenerated
// SPDX-License-Identifier: AGPL-3.0-only
// Code generated by openapi-gen. DO NOT EDIT.
package v0alpha1
import (
common "k8s.io/kube-openapi/pkg/common"
spec "k8s.io/kube-openapi/pkg/validation/spec"
)
func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenAPIDefinition {
return map[string]common.OpenAPIDefinition{
"github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/templategroup/v0alpha1.Spec": schema_pkg_apis_templategroup_v0alpha1_Spec(ref),
"github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/templategroup/v0alpha1.Status": schema_pkg_apis_templategroup_v0alpha1_Status(ref),
"github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/templategroup/v0alpha1.StatusOperatorState": schema_pkg_apis_templategroup_v0alpha1_StatusOperatorState(ref),
"github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/templategroup/v0alpha1.TemplateGroup": schema_pkg_apis_templategroup_v0alpha1_TemplateGroup(ref),
"github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/templategroup/v0alpha1.TemplateGroupList": schema_pkg_apis_templategroup_v0alpha1_TemplateGroupList(ref),
}
}
func schema_pkg_apis_templategroup_v0alpha1_Spec(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
Type: []string{"object"},
Properties: map[string]spec.Schema{
"title": {
SchemaProps: spec.SchemaProps{
Default: "",
Type: []string{"string"},
Format: "",
},
},
"content": {
SchemaProps: spec.SchemaProps{
Default: "",
Type: []string{"string"},
Format: "",
},
},
},
Required: []string{"title", "content"},
},
},
}
}
func schema_pkg_apis_templategroup_v0alpha1_Status(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
Type: []string{"object"},
Properties: map[string]spec.Schema{
"operatorStates": {
SchemaProps: spec.SchemaProps{
Description: "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.",
Type: []string{"object"},
AdditionalProperties: &spec.SchemaOrBool{
Allows: true,
Schema: &spec.Schema{
SchemaProps: spec.SchemaProps{
Default: map[string]interface{}{},
Ref: ref("github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/templategroup/v0alpha1.StatusOperatorState"),
},
},
},
},
},
"additionalFields": {
SchemaProps: spec.SchemaProps{
Description: "additionalFields is reserved for future use",
Type: []string{"object"},
AdditionalProperties: &spec.SchemaOrBool{
Allows: true,
Schema: &spec.Schema{
SchemaProps: spec.SchemaProps{
Type: []string{"object"},
Format: "",
},
},
},
},
},
},
},
},
Dependencies: []string{
"github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/templategroup/v0alpha1.StatusOperatorState"},
}
}
func schema_pkg_apis_templategroup_v0alpha1_StatusOperatorState(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
Type: []string{"object"},
Properties: map[string]spec.Schema{
"lastEvaluation": {
SchemaProps: spec.SchemaProps{
Description: "lastEvaluation is the ResourceVersion last evaluated",
Default: "",
Type: []string{"string"},
Format: "",
},
},
"state": {
SchemaProps: spec.SchemaProps{
Description: "state describes the state of the lastEvaluation. It is limited to three possible states for machine evaluation.",
Default: "",
Type: []string{"string"},
Format: "",
},
},
"descriptiveState": {
SchemaProps: spec.SchemaProps{
Description: "descriptiveState is an optional more descriptive state field which has no requirements on format",
Type: []string{"string"},
Format: "",
},
},
"details": {
SchemaProps: spec.SchemaProps{
Description: "details contains any extra information that is operator-specific",
Type: []string{"object"},
AdditionalProperties: &spec.SchemaOrBool{
Allows: true,
Schema: &spec.Schema{
SchemaProps: spec.SchemaProps{
Type: []string{"object"},
Format: "",
},
},
},
},
},
},
Required: []string{"lastEvaluation", "state"},
},
},
}
}
func schema_pkg_apis_templategroup_v0alpha1_TemplateGroup(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
Type: []string{"object"},
Properties: map[string]spec.Schema{
"kind": {
SchemaProps: spec.SchemaProps{
Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds",
Type: []string{"string"},
Format: "",
},
},
"apiVersion": {
SchemaProps: spec.SchemaProps{
Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources",
Type: []string{"string"},
Format: "",
},
},
"metadata": {
SchemaProps: spec.SchemaProps{
Default: map[string]interface{}{},
Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"),
},
},
"spec": {
SchemaProps: spec.SchemaProps{
Description: "Spec is the spec of the TemplateGroup",
Default: map[string]interface{}{},
Ref: ref("github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/templategroup/v0alpha1.Spec"),
},
},
"status": {
SchemaProps: spec.SchemaProps{
Default: map[string]interface{}{},
Ref: ref("github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/templategroup/v0alpha1.Status"),
},
},
},
Required: []string{"metadata", "spec", "status"},
},
},
Dependencies: []string{
"github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/templategroup/v0alpha1.Spec", "github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/templategroup/v0alpha1.Status", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"},
}
}
func schema_pkg_apis_templategroup_v0alpha1_TemplateGroupList(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
Type: []string{"object"},
Properties: map[string]spec.Schema{
"kind": {
SchemaProps: spec.SchemaProps{
Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds",
Type: []string{"string"},
Format: "",
},
},
"apiVersion": {
SchemaProps: spec.SchemaProps{
Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources",
Type: []string{"string"},
Format: "",
},
},
"metadata": {
SchemaProps: spec.SchemaProps{
Default: map[string]interface{}{},
Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"),
},
},
"items": {
SchemaProps: spec.SchemaProps{
Type: []string{"array"},
Items: &spec.SchemaOrArray{
Schema: &spec.Schema{
SchemaProps: spec.SchemaProps{
Default: map[string]interface{}{},
Ref: ref("github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/templategroup/v0alpha1.TemplateGroup"),
},
},
},
},
},
},
Required: []string{"metadata", "items"},
},
},
Dependencies: []string{
"github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/templategroup/v0alpha1.TemplateGroup", "k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"},
}
}

View file

@ -1,18 +0,0 @@
package v0alpha1
import "k8s.io/apimachinery/pkg/runtime/schema"
const (
// Group is the API group used by all kinds in this package
Group = "notifications.alerting.grafana.app"
// Version is the API version used by all kinds in this package
Version = "v0alpha1"
)
var (
// GroupVersion is a schema.GroupVersion consisting of the Group and Version constants for this package
GroupVersion = schema.GroupVersion{
Group: Group,
Version: Version,
}
)

View file

@ -1,40 +0,0 @@
// Code generated - EDITING IS FUTILE. DO NOT EDIT.
package v0alpha1
// +k8s:openapi-gen=true
type Interval struct {
Times []TimeRange `json:"times,omitempty"`
Weekdays []string `json:"weekdays,omitempty"`
DaysOfMonth []string `json:"days_of_month,omitempty"`
Months []string `json:"months,omitempty"`
Years []string `json:"years,omitempty"`
Location *string `json:"location,omitempty"`
}
// NewInterval creates a new Interval object.
func NewInterval() *Interval {
return &Interval{}
}
// +k8s:openapi-gen=true
type TimeRange struct {
StartTime string `json:"start_time"`
EndTime string `json:"end_time"`
}
// NewTimeRange creates a new TimeRange object.
func NewTimeRange() *TimeRange {
return &TimeRange{}
}
// +k8s:openapi-gen=true
type Spec struct {
Name string `json:"name"`
TimeIntervals []Interval `json:"time_intervals"`
}
// NewSpec creates a new Spec object.
func NewSpec() *Spec {
return &Spec{}
}

View file

@ -1,367 +0,0 @@
//go:build !ignore_autogenerated
// +build !ignore_autogenerated
// SPDX-License-Identifier: AGPL-3.0-only
// Code generated by openapi-gen. DO NOT EDIT.
package v0alpha1
import (
common "k8s.io/kube-openapi/pkg/common"
spec "k8s.io/kube-openapi/pkg/validation/spec"
)
func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenAPIDefinition {
return map[string]common.OpenAPIDefinition{
"github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/timeinterval/v0alpha1.Interval": schema_pkg_apis_timeinterval_v0alpha1_Interval(ref),
"github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/timeinterval/v0alpha1.Spec": schema_pkg_apis_timeinterval_v0alpha1_Spec(ref),
"github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/timeinterval/v0alpha1.Status": schema_pkg_apis_timeinterval_v0alpha1_Status(ref),
"github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/timeinterval/v0alpha1.StatusOperatorState": schema_pkg_apis_timeinterval_v0alpha1_StatusOperatorState(ref),
"github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/timeinterval/v0alpha1.TimeInterval": schema_pkg_apis_timeinterval_v0alpha1_TimeInterval(ref),
"github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/timeinterval/v0alpha1.TimeIntervalList": schema_pkg_apis_timeinterval_v0alpha1_TimeIntervalList(ref),
"github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/timeinterval/v0alpha1.TimeRange": schema_pkg_apis_timeinterval_v0alpha1_TimeRange(ref),
}
}
func schema_pkg_apis_timeinterval_v0alpha1_Interval(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
Type: []string{"object"},
Properties: map[string]spec.Schema{
"times": {
SchemaProps: spec.SchemaProps{
Type: []string{"array"},
Items: &spec.SchemaOrArray{
Schema: &spec.Schema{
SchemaProps: spec.SchemaProps{
Default: map[string]interface{}{},
Ref: ref("github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/timeinterval/v0alpha1.TimeRange"),
},
},
},
},
},
"weekdays": {
SchemaProps: spec.SchemaProps{
Type: []string{"array"},
Items: &spec.SchemaOrArray{
Schema: &spec.Schema{
SchemaProps: spec.SchemaProps{
Default: "",
Type: []string{"string"},
Format: "",
},
},
},
},
},
"days_of_month": {
SchemaProps: spec.SchemaProps{
Type: []string{"array"},
Items: &spec.SchemaOrArray{
Schema: &spec.Schema{
SchemaProps: spec.SchemaProps{
Default: "",
Type: []string{"string"},
Format: "",
},
},
},
},
},
"months": {
SchemaProps: spec.SchemaProps{
Type: []string{"array"},
Items: &spec.SchemaOrArray{
Schema: &spec.Schema{
SchemaProps: spec.SchemaProps{
Default: "",
Type: []string{"string"},
Format: "",
},
},
},
},
},
"years": {
SchemaProps: spec.SchemaProps{
Type: []string{"array"},
Items: &spec.SchemaOrArray{
Schema: &spec.Schema{
SchemaProps: spec.SchemaProps{
Default: "",
Type: []string{"string"},
Format: "",
},
},
},
},
},
"location": {
SchemaProps: spec.SchemaProps{
Type: []string{"string"},
Format: "",
},
},
},
},
},
Dependencies: []string{
"github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/timeinterval/v0alpha1.TimeRange"},
}
}
func schema_pkg_apis_timeinterval_v0alpha1_Spec(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
Type: []string{"object"},
Properties: map[string]spec.Schema{
"name": {
SchemaProps: spec.SchemaProps{
Default: "",
Type: []string{"string"},
Format: "",
},
},
"time_intervals": {
SchemaProps: spec.SchemaProps{
Type: []string{"array"},
Items: &spec.SchemaOrArray{
Schema: &spec.Schema{
SchemaProps: spec.SchemaProps{
Default: map[string]interface{}{},
Ref: ref("github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/timeinterval/v0alpha1.Interval"),
},
},
},
},
},
},
Required: []string{"name", "time_intervals"},
},
},
Dependencies: []string{
"github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/timeinterval/v0alpha1.Interval"},
}
}
func schema_pkg_apis_timeinterval_v0alpha1_Status(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
Type: []string{"object"},
Properties: map[string]spec.Schema{
"operatorStates": {
SchemaProps: spec.SchemaProps{
Description: "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.",
Type: []string{"object"},
AdditionalProperties: &spec.SchemaOrBool{
Allows: true,
Schema: &spec.Schema{
SchemaProps: spec.SchemaProps{
Default: map[string]interface{}{},
Ref: ref("github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/timeinterval/v0alpha1.StatusOperatorState"),
},
},
},
},
},
"additionalFields": {
SchemaProps: spec.SchemaProps{
Description: "additionalFields is reserved for future use",
Type: []string{"object"},
AdditionalProperties: &spec.SchemaOrBool{
Allows: true,
Schema: &spec.Schema{
SchemaProps: spec.SchemaProps{
Type: []string{"object"},
Format: "",
},
},
},
},
},
},
},
},
Dependencies: []string{
"github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/timeinterval/v0alpha1.StatusOperatorState"},
}
}
func schema_pkg_apis_timeinterval_v0alpha1_StatusOperatorState(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
Type: []string{"object"},
Properties: map[string]spec.Schema{
"lastEvaluation": {
SchemaProps: spec.SchemaProps{
Description: "lastEvaluation is the ResourceVersion last evaluated",
Default: "",
Type: []string{"string"},
Format: "",
},
},
"state": {
SchemaProps: spec.SchemaProps{
Description: "state describes the state of the lastEvaluation. It is limited to three possible states for machine evaluation.",
Default: "",
Type: []string{"string"},
Format: "",
},
},
"descriptiveState": {
SchemaProps: spec.SchemaProps{
Description: "descriptiveState is an optional more descriptive state field which has no requirements on format",
Type: []string{"string"},
Format: "",
},
},
"details": {
SchemaProps: spec.SchemaProps{
Description: "details contains any extra information that is operator-specific",
Type: []string{"object"},
AdditionalProperties: &spec.SchemaOrBool{
Allows: true,
Schema: &spec.Schema{
SchemaProps: spec.SchemaProps{
Type: []string{"object"},
Format: "",
},
},
},
},
},
},
Required: []string{"lastEvaluation", "state"},
},
},
}
}
func schema_pkg_apis_timeinterval_v0alpha1_TimeInterval(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
Type: []string{"object"},
Properties: map[string]spec.Schema{
"kind": {
SchemaProps: spec.SchemaProps{
Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds",
Type: []string{"string"},
Format: "",
},
},
"apiVersion": {
SchemaProps: spec.SchemaProps{
Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources",
Type: []string{"string"},
Format: "",
},
},
"metadata": {
SchemaProps: spec.SchemaProps{
Default: map[string]interface{}{},
Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"),
},
},
"spec": {
SchemaProps: spec.SchemaProps{
Description: "Spec is the spec of the TimeInterval",
Default: map[string]interface{}{},
Ref: ref("github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/timeinterval/v0alpha1.Spec"),
},
},
"status": {
SchemaProps: spec.SchemaProps{
Default: map[string]interface{}{},
Ref: ref("github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/timeinterval/v0alpha1.Status"),
},
},
},
Required: []string{"metadata", "spec", "status"},
},
},
Dependencies: []string{
"github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/timeinterval/v0alpha1.Spec", "github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/timeinterval/v0alpha1.Status", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"},
}
}
func schema_pkg_apis_timeinterval_v0alpha1_TimeIntervalList(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
Type: []string{"object"},
Properties: map[string]spec.Schema{
"kind": {
SchemaProps: spec.SchemaProps{
Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds",
Type: []string{"string"},
Format: "",
},
},
"apiVersion": {
SchemaProps: spec.SchemaProps{
Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources",
Type: []string{"string"},
Format: "",
},
},
"metadata": {
SchemaProps: spec.SchemaProps{
Default: map[string]interface{}{},
Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"),
},
},
"items": {
SchemaProps: spec.SchemaProps{
Type: []string{"array"},
Items: &spec.SchemaOrArray{
Schema: &spec.Schema{
SchemaProps: spec.SchemaProps{
Default: map[string]interface{}{},
Ref: ref("github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/timeinterval/v0alpha1.TimeInterval"),
},
},
},
},
},
},
Required: []string{"metadata", "items"},
},
},
Dependencies: []string{
"github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/timeinterval/v0alpha1.TimeInterval", "k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"},
}
}
func schema_pkg_apis_timeinterval_v0alpha1_TimeRange(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
Type: []string{"object"},
Properties: map[string]spec.Schema{
"start_time": {
SchemaProps: spec.SchemaProps{
Default: "",
Type: []string{"string"},
Format: "",
},
},
"end_time": {
SchemaProps: spec.SchemaProps{
Default: "",
Type: []string{"string"},
Format: "",
},
},
},
Required: []string{"start_time", "end_time"},
},
},
}
}

View file

@ -1,10 +0,0 @@
API rule violation: list_type_missing,github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/timeinterval/v0alpha1,Interval,DaysOfMonth
API rule violation: list_type_missing,github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/timeinterval/v0alpha1,Interval,Months
API rule violation: list_type_missing,github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/timeinterval/v0alpha1,Interval,Times
API rule violation: list_type_missing,github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/timeinterval/v0alpha1,Interval,Weekdays
API rule violation: list_type_missing,github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/timeinterval/v0alpha1,Interval,Years
API rule violation: list_type_missing,github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/timeinterval/v0alpha1,Spec,TimeIntervals
API rule violation: names_match,github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/timeinterval/v0alpha1,Interval,DaysOfMonth
API rule violation: names_match,github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/timeinterval/v0alpha1,Spec,TimeIntervals
API rule violation: names_match,github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/timeinterval/v0alpha1,TimeRange,EndTime
API rule violation: names_match,github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/timeinterval/v0alpha1,TimeRange,StartTime

View file

@ -1,39 +1,19 @@
package apis
import (
"maps"
sdkResource "github.com/grafana/grafana-app-sdk/resource"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/kube-openapi/pkg/common"
"github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/alerting/v0alpha1"
receiverv0alpha1 "github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/receiver/v0alpha1"
routingtreev0alpha1 "github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/routingtree/v0alpha1"
templategroupv0alpha1 "github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/templategroup/v0alpha1"
timeintervalv0alpha1 "github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/timeinterval/v0alpha1"
)
func GetOpenAPIDefinitions(c common.ReferenceCallback) map[string]common.OpenAPIDefinition {
tmpl := templategroupv0alpha1.GetOpenAPIDefinitions(c)
tin := timeintervalv0alpha1.GetOpenAPIDefinitions(c)
recv := receiverv0alpha1.GetOpenAPIDefinitions(c)
rest := routingtreev0alpha1.GetOpenAPIDefinitions(c)
result := make(map[string]common.OpenAPIDefinition, len(tmpl)+len(tin)+len(recv)+len(rest))
maps.Copy(result, tmpl)
maps.Copy(result, tin)
maps.Copy(result, recv)
maps.Copy(result, rest)
return result
}
func GetKinds() map[schema.GroupVersion][]sdkResource.Kind {
result := map[schema.GroupVersion][]sdkResource.Kind{
v0alpha1.GroupVersion: {
receiverv0alpha1.Kind(),
routingtreev0alpha1.Kind(),
templategroupv0alpha1.Kind(),
timeintervalv0alpha1.Kind(),
v0alpha1.ReceiverKind(),
v0alpha1.RoutingTreeKind(),
v0alpha1.TemplateGroupKind(),
v0alpha1.TimeIntervalKind(),
},
}
return result

View file

@ -88,7 +88,6 @@ grafana::codegen:run pkg/apimachinery
grafana::codegen:run pkg/aggregator
grafana::codegen:run apps/dashboard/pkg
grafana::codegen:run apps/folder/pkg
grafana::codegen:run apps/alerting/notifications/pkg
if [ -d "pkg/extensions/apis" ]; then
grafana::codegen:run pkg/extensions

View file

@ -8,7 +8,7 @@ import (
"k8s.io/apimachinery/pkg/fields"
"k8s.io/apimachinery/pkg/types"
model "github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/receiver/v0alpha1"
model "github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/alerting/v0alpha1"
"github.com/grafana/grafana/pkg/services/apiserver/endpoints/request"
gapiutil "github.com/grafana/grafana/pkg/services/apiserver/utils"
ngmodels "github.com/grafana/grafana/pkg/services/ngalert/models"
@ -42,7 +42,7 @@ func convertToK8sResources(
if err != nil {
return nil, err
}
if selector != nil && !selector.Empty() && !selector.Matches(model.SelectableFields(k8sResource)) {
if selector != nil && !selector.Empty() && !selector.Matches(model.ReceiverSelectableFields(k8sResource)) {
continue
}
result.Items = append(result.Items, *k8sResource)
@ -57,12 +57,12 @@ func convertToK8sResource(
metadata *ngmodels.ReceiverMetadata,
namespacer request.NamespaceMapper,
) (*model.Receiver, error) {
spec := model.Spec{
spec := model.ReceiverSpec{
Title: receiver.Name,
Integrations: make([]model.Integration, 0, len(receiver.Integrations)),
Integrations: make([]model.ReceiverIntegration, 0, len(receiver.Integrations)),
}
for _, integration := range receiver.Integrations {
spec.Integrations = append(spec.Integrations, model.Integration{
spec.Integrations = append(spec.Integrations, model.ReceiverIntegration{
Uid: &integration.UID,
Type: integration.Config.Type,
DisableResolveMessage: &integration.DisableResolveMessage,

View file

@ -11,7 +11,7 @@ import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apiserver/pkg/registry/rest"
model "github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/receiver/v0alpha1"
model "github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/alerting/v0alpha1"
"github.com/grafana/grafana/pkg/apimachinery/identity"
grafanarest "github.com/grafana/grafana/pkg/apiserver/rest"
"github.com/grafana/grafana/pkg/services/apiserver/endpoints/request"

View file

@ -7,11 +7,11 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
model "github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/receiver/v0alpha1"
model "github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/alerting/v0alpha1"
"github.com/grafana/grafana/pkg/apimachinery/utils"
)
var kind = model.Kind()
var kind = model.ReceiverKind()
var ResourceInfo = utils.NewResourceInfo(kind.Group(), kind.Version(),
kind.GroupVersionResource().Resource, strings.ToLower(kind.Kind()), kind.Kind(),
func() runtime.Object { return kind.ZeroValue() },

View file

@ -9,6 +9,7 @@ import (
"k8s.io/apiserver/pkg/authorization/authorizer"
notificationsResource "github.com/grafana/grafana/apps/alerting/notifications/pkg/apis"
"github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/alerting/v0alpha1"
notificationsApp "github.com/grafana/grafana/apps/alerting/notifications/pkg/app"
grafanarest "github.com/grafana/grafana/pkg/apiserver/rest"
"github.com/grafana/grafana/pkg/registry/apps/alerting/notifications/receiver"
@ -38,7 +39,7 @@ func RegisterApp(
appCfg := &runner.AppBuilderConfig{
Authorizer: getAuthorizer(ng.Api.AccessControl),
LegacyStorageGetter: getLegacyStorage(request.GetNamespaceMapper(cfg), ng),
OpenAPIDefGetter: notificationsResource.GetOpenAPIDefinitions,
OpenAPIDefGetter: v0alpha1.GetOpenAPIDefinitions,
ManagedKinds: notificationsResource.GetKinds(),
}

View file

@ -12,7 +12,7 @@ import (
promModel "github.com/prometheus/common/model"
model "github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/routingtree/v0alpha1"
model "github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/alerting/v0alpha1"
"github.com/grafana/grafana/pkg/services/apiserver/endpoints/request"
gapiutil "github.com/grafana/grafana/pkg/services/apiserver/utils"
"github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
@ -20,8 +20,8 @@ import (
)
func ConvertToK8sResource(orgID int64, r definitions.Route, version string, namespacer request.NamespaceMapper) (*model.RoutingTree, error) {
spec := model.Spec{
Defaults: model.RouteDefaults{
spec := model.RoutingTreeSpec{
Defaults: model.RoutingTreeRouteDefaults{
GroupBy: r.GroupByStr,
GroupWait: optionalPrometheusDurationToString(r.GroupWait),
GroupInterval: optionalPrometheusDurationToString(r.GroupInterval),
@ -49,8 +49,8 @@ func ConvertToK8sResource(orgID int64, r definitions.Route, version string, name
return result, nil
}
func convertRouteToK8sSubRoute(r *definitions.Route) model.Route {
result := model.Route{
func convertRouteToK8sSubRoute(r *definitions.Route) model.RoutingTreeRoute {
result := model.RoutingTreeRoute{
GroupBy: r.GroupByStr,
MuteTimeIntervals: r.MuteTimeIntervals,
ActiveTimeIntervals: r.ActiveTimeIntervals,
@ -58,7 +58,7 @@ func convertRouteToK8sSubRoute(r *definitions.Route) model.Route {
GroupWait: optionalPrometheusDurationToString(r.GroupWait),
GroupInterval: optionalPrometheusDurationToString(r.GroupInterval),
RepeatInterval: optionalPrometheusDurationToString(r.RepeatInterval),
Routes: make([]model.Route, 0, len(r.Routes)),
Routes: make([]model.RoutingTreeRoute, 0, len(r.Routes)),
}
if r.Receiver != "" {
result.Receiver = util.Pointer(r.Receiver)
@ -68,9 +68,9 @@ func convertRouteToK8sSubRoute(r *definitions.Route) model.Route {
keys := slices.Collect(maps.Keys(r.Match))
slices.Sort(keys)
for _, key := range keys {
result.Matchers = append(result.Matchers, model.Matcher{
result.Matchers = append(result.Matchers, model.RoutingTreeMatcher{
Label: key,
Type: model.MatcherTypeEqual,
Type: model.RoutingTreeMatcherTypeEqual,
Value: r.Match[key],
})
}
@ -80,9 +80,9 @@ func convertRouteToK8sSubRoute(r *definitions.Route) model.Route {
keys := slices.Collect(maps.Keys(r.MatchRE))
slices.Sort(keys)
for _, key := range keys {
m := model.Matcher{
m := model.RoutingTreeMatcher{
Label: key,
Type: model.MatcherTypeEqualRegex,
Type: model.RoutingTreeMatcherTypeEqualRegex,
}
value, _ := r.MatchRE[key].MarshalYAML()
if s, ok := value.(string); ok {
@ -93,16 +93,16 @@ func convertRouteToK8sSubRoute(r *definitions.Route) model.Route {
}
for _, m := range r.Matchers {
result.Matchers = append(result.Matchers, model.Matcher{
result.Matchers = append(result.Matchers, model.RoutingTreeMatcher{
Label: m.Name,
Type: model.MatcherType(m.Type.String()),
Type: model.RoutingTreeMatcherType(m.Type.String()),
Value: m.Value,
})
}
for _, m := range r.ObjectMatchers {
result.Matchers = append(result.Matchers, model.Matcher{
result.Matchers = append(result.Matchers, model.RoutingTreeMatcher{
Label: m.Name,
Type: model.MatcherType(m.Type.String()),
Type: model.RoutingTreeMatcherType(m.Type.String()),
Value: m.Value,
})
}
@ -151,7 +151,7 @@ func convertToDomainModel(obj *model.RoutingTree) (definitions.Route, string, er
return result, obj.ResourceVersion, nil
}
func convertK8sSubRouteToRoute(r model.Route, path string) (definitions.Route, []error) {
func convertK8sSubRouteToRoute(r model.RoutingTreeRoute, path string) (definitions.Route, []error) {
result := definitions.Route{
GroupByStr: r.GroupBy,
MuteTimeIntervals: r.MuteTimeIntervals,
@ -177,13 +177,13 @@ func convertK8sSubRouteToRoute(r model.Route, path string) (definitions.Route, [
for _, matcher := range r.Matchers {
var mt labels.MatchType
switch matcher.Type {
case model.MatcherTypeEqual:
case model.RoutingTreeMatcherTypeEqual:
mt = labels.MatchEqual
case model.MatcherTypeNotEqual:
case model.RoutingTreeMatcherTypeNotEqual:
mt = labels.MatchNotEqual
case model.MatcherTypeEqualRegex:
case model.RoutingTreeMatcherTypeEqualRegex:
mt = labels.MatchRegexp
case model.MatcherTypeNotEqualRegex:
case model.RoutingTreeMatcherTypeNotEqualRegex:
mt = labels.MatchNotRegexp
default:
errs = append(errs, fmt.Errorf("route '%s' has unsupported matcher type: %s", path, matcher.Type))

View file

@ -10,7 +10,7 @@ import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apiserver/pkg/registry/rest"
model "github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/routingtree/v0alpha1"
model "github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/alerting/v0alpha1"
grafanarest "github.com/grafana/grafana/pkg/apiserver/rest"
"github.com/grafana/grafana/pkg/services/apiserver/endpoints/request"
"github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"

View file

@ -5,11 +5,11 @@ import (
"k8s.io/apimachinery/pkg/runtime"
model "github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/routingtree/v0alpha1"
model "github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/alerting/v0alpha1"
"github.com/grafana/grafana/pkg/apimachinery/utils"
)
var kind = model.Kind()
var kind = model.RoutingTreeKind()
var ResourceInfo = utils.NewResourceInfo(kind.Group(), kind.Version(),
kind.GroupVersionResource().Resource, strings.ToLower(kind.Kind()), kind.Kind(),
func() runtime.Object { return kind.ZeroValue() },

View file

@ -5,7 +5,7 @@ import (
"k8s.io/apimachinery/pkg/fields"
"k8s.io/apimachinery/pkg/types"
model "github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/templategroup/v0alpha1"
model "github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/alerting/v0alpha1"
gapiutil "github.com/grafana/grafana/pkg/services/apiserver/utils"
"github.com/grafana/grafana/pkg/services/apiserver/endpoints/request"
@ -17,7 +17,7 @@ func convertToK8sResources(orgID int64, list []definitions.NotificationTemplate,
result := &model.TemplateGroupList{}
for _, t := range list {
item := convertToK8sResource(orgID, t, namespacer)
if selector != nil && !selector.Empty() && !selector.Matches(model.SelectableFields(item)) {
if selector != nil && !selector.Empty() && !selector.Matches(model.TemplateGroupSelectableFields(item)) {
continue
}
result.Items = append(result.Items, *item)
@ -33,7 +33,7 @@ func convertToK8sResource(orgID int64, template definitions.NotificationTemplate
Namespace: namespacer(orgID),
ResourceVersion: template.ResourceVersion,
},
Spec: model.Spec{
Spec: model.TemplateGroupSpec{
Title: template.Name,
Content: template.Template,
},

View file

@ -12,7 +12,7 @@ import (
"github.com/grafana/alerting/templates"
model "github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/templategroup/v0alpha1"
model "github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/alerting/v0alpha1"
grafanarest "github.com/grafana/grafana/pkg/apiserver/rest"
"github.com/grafana/grafana/pkg/services/apiserver/endpoints/request"
"github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"

View file

@ -7,11 +7,11 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
model "github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/templategroup/v0alpha1"
model "github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/alerting/v0alpha1"
"github.com/grafana/grafana/pkg/apimachinery/utils"
)
var kind = model.Kind()
var kind = model.TemplateGroupKind()
var ResourceInfo = utils.NewResourceInfo(kind.Group(), kind.Version(),
kind.GroupVersionResource().Resource, strings.ToLower(kind.Kind()), kind.Kind(),
func() runtime.Object { return kind.ZeroValue() },

View file

@ -7,7 +7,7 @@ import (
"k8s.io/apimachinery/pkg/fields"
"k8s.io/apimachinery/pkg/types"
model "github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/timeinterval/v0alpha1"
model "github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/alerting/v0alpha1"
"github.com/grafana/grafana/pkg/services/apiserver/endpoints/request"
gapiutil "github.com/grafana/grafana/pkg/services/apiserver/utils"
"github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
@ -20,7 +20,7 @@ func ConvertToK8sResources(orgID int64, intervals []definitions.MuteTimeInterval
if err != nil {
return nil, err
}
var specs []model.Spec
var specs []model.TimeIntervalSpec
err = json.Unmarshal(data, &specs)
if err != nil {
return nil, err
@ -31,7 +31,7 @@ func ConvertToK8sResources(orgID int64, intervals []definitions.MuteTimeInterval
interval := intervals[idx]
spec := specs[idx]
item := buildTimeInterval(orgID, interval, spec, namespacer)
if selector != nil && !selector.Empty() && !selector.Matches(model.SelectableFields(&item)) {
if selector != nil && !selector.Empty() && !selector.Matches(model.TimeIntervalSelectableFields(&item)) {
continue
}
result.Items = append(result.Items, item)
@ -44,7 +44,7 @@ func ConvertToK8sResource(orgID int64, interval definitions.MuteTimeInterval, na
if err != nil {
return nil, err
}
spec := model.Spec{}
spec := model.TimeIntervalSpec{}
err = json.Unmarshal(data, &spec)
if err != nil {
return nil, err
@ -54,7 +54,7 @@ func ConvertToK8sResource(orgID int64, interval definitions.MuteTimeInterval, na
return &result, nil
}
func buildTimeInterval(orgID int64, interval definitions.MuteTimeInterval, spec model.Spec, namespacer request.NamespaceMapper) model.TimeInterval {
func buildTimeInterval(orgID int64, interval definitions.MuteTimeInterval, spec model.TimeIntervalSpec, namespacer request.NamespaceMapper) model.TimeInterval {
i := model.TimeInterval{
ObjectMeta: metav1.ObjectMeta{
UID: types.UID(interval.UID), // TODO This is needed to make PATCH work

View file

@ -10,7 +10,7 @@ import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apiserver/pkg/registry/rest"
model "github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/timeinterval/v0alpha1"
model "github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/alerting/v0alpha1"
grafanarest "github.com/grafana/grafana/pkg/apiserver/rest"
"github.com/grafana/grafana/pkg/services/apiserver/endpoints/request"
"github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"

View file

@ -7,11 +7,11 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
model "github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/timeinterval/v0alpha1"
model "github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/alerting/v0alpha1"
"github.com/grafana/grafana/pkg/apimachinery/utils"
)
var kind = model.Kind()
var kind = model.TimeIntervalKind()
var ResourceInfo = utils.NewResourceInfo(kind.Group(), kind.Version(),
kind.GroupVersionResource().Resource, strings.ToLower(kind.Kind()), kind.Kind(),
func() runtime.Object { return kind.ZeroValue() },

View file

@ -8,72 +8,69 @@ import (
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/client-go/dynamic"
v0alpha1_receiver "github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/receiver/v0alpha1"
v0alpha1_routingtree "github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/routingtree/v0alpha1"
v0alpha1_templategroup "github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/templategroup/v0alpha1"
v0alpha1_timeinterval "github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/timeinterval/v0alpha1"
"github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/alerting/v0alpha1"
)
func NewReceiverClient(t *testing.T, user apis.User) *apis.TypedClient[v0alpha1_receiver.Receiver, v0alpha1_receiver.ReceiverList] {
func NewReceiverClient(t *testing.T, user apis.User) *apis.TypedClient[v0alpha1.Receiver, v0alpha1.ReceiverList] {
t.Helper()
client, err := dynamic.NewForConfig(user.NewRestConfig())
require.NoError(t, err)
return &apis.TypedClient[v0alpha1_receiver.Receiver, v0alpha1_receiver.ReceiverList]{
return &apis.TypedClient[v0alpha1.Receiver, v0alpha1.ReceiverList]{
Client: client.Resource(
schema.GroupVersionResource{
Group: v0alpha1_receiver.Kind().Group(),
Version: v0alpha1_receiver.Kind().Version(),
Resource: v0alpha1_receiver.Kind().Plural(),
Group: v0alpha1.ReceiverKind().Group(),
Version: v0alpha1.ReceiverKind().Version(),
Resource: v0alpha1.ReceiverKind().Plural(),
}).Namespace("default"),
}
}
func NewRoutingTreeClient(t *testing.T, user apis.User) *apis.TypedClient[v0alpha1_routingtree.RoutingTree, v0alpha1_routingtree.RoutingTreeList] {
func NewRoutingTreeClient(t *testing.T, user apis.User) *apis.TypedClient[v0alpha1.RoutingTree, v0alpha1.RoutingTreeList] {
t.Helper()
client, err := dynamic.NewForConfig(user.NewRestConfig())
require.NoError(t, err)
return &apis.TypedClient[v0alpha1_routingtree.RoutingTree, v0alpha1_routingtree.RoutingTreeList]{
return &apis.TypedClient[v0alpha1.RoutingTree, v0alpha1.RoutingTreeList]{
Client: client.Resource(
schema.GroupVersionResource{
Group: v0alpha1_routingtree.Kind().Group(),
Version: v0alpha1_routingtree.Kind().Version(),
Resource: v0alpha1_routingtree.Kind().Plural(),
Group: v0alpha1.RoutingTreeKind().Group(),
Version: v0alpha1.RoutingTreeKind().Version(),
Resource: v0alpha1.RoutingTreeKind().Plural(),
}).Namespace("default"),
}
}
func NewTemplateGroupClient(t *testing.T, user apis.User) *apis.TypedClient[v0alpha1_templategroup.TemplateGroup, v0alpha1_templategroup.TemplateGroupList] {
func NewTemplateGroupClient(t *testing.T, user apis.User) *apis.TypedClient[v0alpha1.TemplateGroup, v0alpha1.TemplateGroupList] {
t.Helper()
client, err := dynamic.NewForConfig(user.NewRestConfig())
require.NoError(t, err)
return &apis.TypedClient[v0alpha1_templategroup.TemplateGroup, v0alpha1_templategroup.TemplateGroupList]{
return &apis.TypedClient[v0alpha1.TemplateGroup, v0alpha1.TemplateGroupList]{
Client: client.Resource(
schema.GroupVersionResource{
Group: v0alpha1_templategroup.Kind().Group(),
Version: v0alpha1_templategroup.Kind().Version(),
Resource: v0alpha1_templategroup.Kind().Plural(),
Group: v0alpha1.TemplateGroupKind().Group(),
Version: v0alpha1.TemplateGroupKind().Version(),
Resource: v0alpha1.TemplateGroupKind().Plural(),
}).Namespace("default"),
}
}
func NewTimeIntervalClient(t *testing.T, user apis.User) *apis.TypedClient[v0alpha1_timeinterval.TimeInterval, v0alpha1_timeinterval.TimeIntervalList] {
func NewTimeIntervalClient(t *testing.T, user apis.User) *apis.TypedClient[v0alpha1.TimeInterval, v0alpha1.TimeIntervalList] {
t.Helper()
client, err := dynamic.NewForConfig(user.NewRestConfig())
require.NoError(t, err)
return &apis.TypedClient[v0alpha1_timeinterval.TimeInterval, v0alpha1_timeinterval.TimeIntervalList]{
return &apis.TypedClient[v0alpha1.TimeInterval, v0alpha1.TimeIntervalList]{
Client: client.Resource(
schema.GroupVersionResource{
Group: v0alpha1_timeinterval.Kind().Group(),
Version: v0alpha1_timeinterval.Kind().Version(),
Resource: v0alpha1_timeinterval.Kind().Plural(),
Group: v0alpha1.TimeIntervalKind().Group(),
Version: v0alpha1.TimeIntervalKind().Version(),
Resource: v0alpha1.TimeIntervalKind().Plural(),
}).Namespace("default"),
}
}

View file

@ -21,7 +21,7 @@ import (
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/types"
"github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/receiver/v0alpha1"
"github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/alerting/v0alpha1"
common "github.com/grafana/grafana/pkg/apimachinery/apis/common/v0alpha1"
"github.com/grafana/grafana/pkg/registry/apps/alerting/notifications/routingtree"
@ -73,9 +73,9 @@ func TestIntegrationResourceIdentifier(t *testing.T) {
ObjectMeta: v1.ObjectMeta{
Namespace: "default",
},
Spec: v0alpha1.Spec{
Spec: v0alpha1.ReceiverSpec{
Title: "Test-Receiver",
Integrations: []v0alpha1.Integration{},
Integrations: []v0alpha1.ReceiverIntegration{},
},
}
@ -305,9 +305,9 @@ func TestIntegrationResourcePermissions(t *testing.T) {
ObjectMeta: v1.ObjectMeta{
Namespace: "default",
},
Spec: v0alpha1.Spec{
Spec: v0alpha1.ReceiverSpec{
Title: "receiver-1",
Integrations: []v0alpha1.Integration{},
Integrations: []v0alpha1.ReceiverIntegration{},
},
}
d, err := json.Marshal(created)
@ -571,9 +571,9 @@ func TestIntegrationAccessControl(t *testing.T) {
ObjectMeta: v1.ObjectMeta{
Namespace: "default",
},
Spec: v0alpha1.Spec{
Spec: v0alpha1.ReceiverSpec{
Title: fmt.Sprintf("receiver-1-%s", tc.user.Identity.GetLogin()),
Integrations: []v0alpha1.Integration{},
Integrations: []v0alpha1.ReceiverIntegration{},
},
}
d, err := json.Marshal(expected)
@ -878,9 +878,9 @@ func TestIntegrationProvisioning(t *testing.T) {
ObjectMeta: v1.ObjectMeta{
Namespace: "default",
},
Spec: v0alpha1.Spec{
Spec: v0alpha1.ReceiverSpec{
Title: "test-receiver-1",
Integrations: []v0alpha1.Integration{
Integrations: []v0alpha1.ReceiverIntegration{
createIntegration(t, "email"),
},
},
@ -927,9 +927,9 @@ func TestIntegrationOptimisticConcurrency(t *testing.T) {
ObjectMeta: v1.ObjectMeta{
Namespace: "default",
},
Spec: v0alpha1.Spec{
Spec: v0alpha1.ReceiverSpec{
Title: "receiver-1",
Integrations: []v0alpha1.Integration{},
Integrations: []v0alpha1.ReceiverIntegration{},
},
}
@ -1010,9 +1010,9 @@ func TestIntegrationPatch(t *testing.T) {
ObjectMeta: v1.ObjectMeta{
Namespace: "default",
},
Spec: v0alpha1.Spec{
Spec: v0alpha1.ReceiverSpec{
Title: "receiver",
Integrations: []v0alpha1.Integration{
Integrations: []v0alpha1.ReceiverIntegration{
createIntegration(t, "email"),
createIntegration(t, "webhook"),
createIntegration(t, "sns"),
@ -1028,7 +1028,7 @@ func TestIntegrationPatch(t *testing.T) {
current, err := adminClient.Get(ctx, current.Name, v1.GetOptions{})
require.NoError(t, err)
index := slices.IndexFunc(current.Spec.Integrations, func(t v0alpha1.Integration) bool {
index := slices.IndexFunc(current.Spec.Integrations, func(t v0alpha1.ReceiverIntegration) bool {
return t.Type == "webhook"
})
@ -1269,9 +1269,9 @@ func TestIntegrationCRUD(t *testing.T) {
ObjectMeta: v1.ObjectMeta{
Namespace: "default",
},
Spec: v0alpha1.Spec{
Spec: v0alpha1.ReceiverSpec{
Title: defaultReceiver.Spec.Title,
Integrations: []v0alpha1.Integration{},
Integrations: []v0alpha1.ReceiverIntegration{},
},
}
_, err := adminClient.Create(ctx, newReceiver, v1.CreateOptions{})
@ -1285,7 +1285,7 @@ func TestIntegrationCRUD(t *testing.T) {
var receiver *v0alpha1.Receiver
t.Run("should correctly persist all known integrations", func(t *testing.T) {
integrations := make([]v0alpha1.Integration, 0, len(notify.AllKnownConfigsForTesting))
integrations := make([]v0alpha1.ReceiverIntegration, 0, len(notify.AllKnownConfigsForTesting))
keysIter := maps.Keys(notify.AllKnownConfigsForTesting)
keys := slices.Collect(keysIter)
sort.Strings(keys)
@ -1297,7 +1297,7 @@ func TestIntegrationCRUD(t *testing.T) {
ObjectMeta: v1.ObjectMeta{
Namespace: "default",
},
Spec: v0alpha1.Spec{
Spec: v0alpha1.ReceiverSpec{
Title: "all-receivers",
Integrations: integrations,
},
@ -1369,9 +1369,9 @@ func TestIntegrationCRUD(t *testing.T) {
ObjectMeta: v1.ObjectMeta{
Namespace: "default",
},
Spec: v0alpha1.Spec{
Spec: v0alpha1.ReceiverSpec{
Title: fmt.Sprintf("invalid-%s", key),
Integrations: []v0alpha1.Integration{integration},
Integrations: []v0alpha1.ReceiverIntegration{integration},
},
}, v1.CreateOptions{})
require.Errorf(t, err, "Expected error but got successful result: %v", receiver)
@ -1394,9 +1394,9 @@ func TestIntegrationReceiverListSelector(t *testing.T) {
ObjectMeta: v1.ObjectMeta{
Namespace: "default",
},
Spec: v0alpha1.Spec{
Spec: v0alpha1.ReceiverSpec{
Title: "test-receiver-1",
Integrations: []v0alpha1.Integration{
Integrations: []v0alpha1.ReceiverIntegration{
createIntegration(t, "email"),
},
},
@ -1408,9 +1408,9 @@ func TestIntegrationReceiverListSelector(t *testing.T) {
ObjectMeta: v1.ObjectMeta{
Namespace: "default",
},
Spec: v0alpha1.Spec{
Spec: v0alpha1.ReceiverSpec{
Title: "test-receiver-2",
Integrations: []v0alpha1.Integration{
Integrations: []v0alpha1.ReceiverIntegration{
createIntegration(t, "email"),
},
},
@ -1486,16 +1486,16 @@ func persistInitialConfig(t *testing.T, amConfig definitions.PostableUserConfig)
ObjectMeta: v1.ObjectMeta{
Namespace: "default",
},
Spec: v0alpha1.Spec{
Spec: v0alpha1.ReceiverSpec{
Title: receiver.Name,
Integrations: []v0alpha1.Integration{},
Integrations: []v0alpha1.ReceiverIntegration{},
},
}
for _, integration := range receiver.GrafanaManagedReceivers {
settings := common.Unstructured{}
require.NoError(t, settings.UnmarshalJSON(integration.Settings))
toCreate.Spec.Integrations = append(toCreate.Spec.Integrations, v0alpha1.Integration{
toCreate.Spec.Integrations = append(toCreate.Spec.Integrations, v0alpha1.ReceiverIntegration{
Settings: settings.Object,
Type: integration.Type,
DisableResolveMessage: util.Pointer(false),
@ -1519,15 +1519,15 @@ func persistInitialConfig(t *testing.T, amConfig definitions.PostableUserConfig)
require.NoError(t, err)
}
func createIntegration(t *testing.T, integrationType string) v0alpha1.Integration {
func createIntegration(t *testing.T, integrationType string) v0alpha1.ReceiverIntegration {
cfg, ok := notify.AllKnownConfigsForTesting[integrationType]
require.Truef(t, ok, "no known config for integration type %s", integrationType)
return createIntegrationWithSettings(t, integrationType, cfg.Config)
}
func createIntegrationWithSettings(t *testing.T, integrationType string, settingsJson string) v0alpha1.Integration {
func createIntegrationWithSettings(t *testing.T, integrationType string, settingsJson string) v0alpha1.ReceiverIntegration {
settings := common.Unstructured{}
require.NoError(t, settings.UnmarshalJSON([]byte(settingsJson)))
return v0alpha1.Integration{
return v0alpha1.ReceiverIntegration{
Settings: settings.Object,
Type: integrationType,
DisableResolveMessage: util.Pointer(false),

View file

@ -16,11 +16,10 @@ import (
"k8s.io/apimachinery/pkg/api/errors"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/routingtree/v0alpha1"
v0alpha1_timeinterval "github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/timeinterval/v0alpha1"
"github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/alerting/v0alpha1"
"github.com/grafana/grafana/pkg/registry/apps/alerting/notifications/routingtree"
"github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/timeinterval/v0alpha1/fakes"
"github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/alerting/v0alpha1/fakes"
"github.com/grafana/grafana/pkg/bus"
"github.com/grafana/grafana/pkg/infra/tracing"
"github.com/grafana/grafana/pkg/services/accesscontrol"
@ -60,7 +59,7 @@ func TestIntegrationNotAllowedMethods(t *testing.T) {
ObjectMeta: v1.ObjectMeta{
Namespace: "default",
},
Spec: v0alpha1.Spec{},
Spec: v0alpha1.RoutingTreeSpec{},
}
_, err := client.Create(ctx, route, v1.CreateOptions{})
assert.Error(t, err)
@ -204,12 +203,12 @@ func TestIntegrationAccessControl(t *testing.T) {
current, err := adminClient.Get(ctx, v0alpha1.UserDefinedRoutingTreeName, v1.GetOptions{})
require.NoError(t, err)
expected := current.Copy().(*v0alpha1.RoutingTree)
expected.Spec.Routes = []v0alpha1.Route{
expected.Spec.Routes = []v0alpha1.RoutingTreeRoute{
{
Matchers: []v0alpha1.Matcher{
Matchers: []v0alpha1.RoutingTreeMatcher{
{
Label: "test",
Type: v0alpha1.MatcherTypeEqual,
Type: v0alpha1.RoutingTreeMatcherTypeEqual,
Value: "test",
},
},
@ -313,12 +312,12 @@ func TestIntegrationProvisioning(t *testing.T) {
})
t.Run("should not let update if provisioned", func(t *testing.T) {
updated := current.Copy().(*v0alpha1.RoutingTree)
updated.Spec.Routes = []v0alpha1.Route{
updated.Spec.Routes = []v0alpha1.RoutingTreeRoute{
{
Matchers: []v0alpha1.Matcher{
Matchers: []v0alpha1.RoutingTreeMatcher{
{
Label: "test",
Type: v0alpha1.MatcherTypeNotEqual,
Type: v0alpha1.RoutingTreeMatcherTypeNotEqual,
Value: "123",
},
},
@ -370,7 +369,7 @@ func TestIntegrationOptimisticConcurrency(t *testing.T) {
require.NoError(t, err)
updated := current.Copy().(*v0alpha1.RoutingTree)
updated.ResourceVersion = ""
updated.Spec.Routes = append(updated.Spec.Routes, v0alpha1.Route{Continue: true})
updated.Spec.Routes = append(updated.Spec.Routes, v0alpha1.RoutingTreeRoute{Continue: true})
actualUpdated, err := adminClient.Update(ctx, updated, v1.UpdateOptions{})
require.NoError(t, err)
@ -403,11 +402,11 @@ func TestIntegrationDataConsistency(t *testing.T) {
require.NoError(t, err)
}
_, err := common.NewTimeIntervalClient(t, helper.Org1.Admin).Create(ctx, &v0alpha1_timeinterval.TimeInterval{
_, err := common.NewTimeIntervalClient(t, helper.Org1.Admin).Create(ctx, &v0alpha1.TimeInterval{
ObjectMeta: v1.ObjectMeta{
Namespace: "default",
},
Spec: v0alpha1_timeinterval.Spec{
Spec: v0alpha1.TimeIntervalSpec{
Name: timeInterval,
TimeIntervals: fakes.IntervalGenerator{}.GenerateMany(1),
},
@ -447,25 +446,25 @@ func TestIntegrationDataConsistency(t *testing.T) {
createRoute(t, route)
tree, err := client.Get(ctx, v0alpha1.UserDefinedRoutingTreeName, v1.GetOptions{})
require.NoError(t, err)
expected := []v0alpha1.Matcher{
expected := []v0alpha1.RoutingTreeMatcher{
{
Label: "label_match",
Type: v0alpha1.MatcherTypeEqual,
Type: v0alpha1.RoutingTreeMatcherTypeEqual,
Value: "test-123",
},
{
Label: "label_re",
Type: v0alpha1.MatcherTypeEqualRegex,
Type: v0alpha1.RoutingTreeMatcherTypeEqualRegex,
Value: ".*",
},
{
Label: "label_matchers",
Type: v0alpha1.MatcherTypeEqualRegex,
Type: v0alpha1.RoutingTreeMatcherTypeEqualRegex,
Value: "test-321",
},
{
Label: "object-label-matchers",
Type: v0alpha1.MatcherTypeNotEqualRegex,
Type: v0alpha1.RoutingTreeMatcherTypeNotEqualRegex,
Value: "test-456",
},
}
@ -554,7 +553,7 @@ func TestIntegrationDataConsistency(t *testing.T) {
t.Run("correctly reads all fields", func(t *testing.T) {
tree, err := client.Get(ctx, v0alpha1.UserDefinedRoutingTreeName, v1.GetOptions{})
require.NoError(t, err)
assert.Equal(t, v0alpha1.RouteDefaults{
assert.Equal(t, v0alpha1.RoutingTreeRouteDefaults{
Receiver: receiver,
GroupBy: []string{"test-123", "test-456"},
GroupWait: util.Pointer("30s"),
@ -562,7 +561,7 @@ func TestIntegrationDataConsistency(t *testing.T) {
RepeatInterval: util.Pointer("1d"),
}, tree.Spec.Defaults)
assert.Len(t, tree.Spec.Routes, 1)
assert.Equal(t, v0alpha1.Route{
assert.Equal(t, v0alpha1.RoutingTreeRoute{
Continue: true,
Receiver: util.Pointer(receiver),
GroupBy: []string{"test-789"},
@ -571,25 +570,25 @@ func TestIntegrationDataConsistency(t *testing.T) {
RepeatInterval: util.Pointer("1d6h"),
MuteTimeIntervals: []string{timeInterval},
ActiveTimeIntervals: []string{timeInterval},
Matchers: []v0alpha1.Matcher{
Matchers: []v0alpha1.RoutingTreeMatcher{
{
Label: "m",
Type: v0alpha1.MatcherTypeNotEqual,
Type: v0alpha1.RoutingTreeMatcherTypeNotEqual,
Value: "1",
},
{
Label: "n",
Type: v0alpha1.MatcherTypeEqual,
Type: v0alpha1.RoutingTreeMatcherTypeEqual,
Value: "1",
},
{
Label: "o",
Type: v0alpha1.MatcherTypeEqualRegex,
Type: v0alpha1.RoutingTreeMatcherTypeEqualRegex,
Value: "1",
},
{
Label: "p",
Type: v0alpha1.MatcherTypeNotEqualRegex,
Type: v0alpha1.RoutingTreeMatcherTypeNotEqualRegex,
Value: "1",
},
},
@ -653,13 +652,13 @@ func TestIntegrationDataConsistency(t *testing.T) {
tree, err := client.Get(ctx, v0alpha1.UserDefinedRoutingTreeName, v1.GetOptions{})
require.NoError(t, err)
assert.Equal(t, "foo🙂", tree.Spec.Routes[0].GroupBy[0])
expected := []v0alpha1.Matcher{
{Label: "foo🙂", Type: v0alpha1.MatcherTypeEqual, Value: "bar"},
{Label: "_bar1", Type: v0alpha1.MatcherTypeNotEqual, Value: "baz🙂"},
{Label: "0baz", Type: v0alpha1.MatcherTypeEqualRegex, Value: "[a-zA-Z0-9]+,?"},
{Label: "corge", Type: v0alpha1.MatcherTypeNotEqualRegex, Value: "^[0-9]+((,[0-9]{3})*(,[0-9]{0,3})?)?$"},
{Label: "Προμηθέας", Type: v0alpha1.MatcherTypeEqual, Value: "Prom"},
{Label: "犬", Type: v0alpha1.MatcherTypeNotEqual, Value: "Shiba Inu"},
expected := []v0alpha1.RoutingTreeMatcher{
{Label: "foo🙂", Type: v0alpha1.RoutingTreeMatcherTypeEqual, Value: "bar"},
{Label: "_bar1", Type: v0alpha1.RoutingTreeMatcherTypeNotEqual, Value: "baz🙂"},
{Label: "0baz", Type: v0alpha1.RoutingTreeMatcherTypeEqualRegex, Value: "[a-zA-Z0-9]+,?"},
{Label: "corge", Type: v0alpha1.RoutingTreeMatcherTypeNotEqualRegex, Value: "^[0-9]+((,[0-9]{3})*(,[0-9]{0,3})?)?$"},
{Label: "Προμηθέας", Type: v0alpha1.RoutingTreeMatcherTypeEqual, Value: "Prom"},
{Label: "犬", Type: v0alpha1.RoutingTreeMatcherTypeNotEqual, Value: "Shiba Inu"},
}
assert.ElementsMatch(t, expected, tree.Spec.Routes[0].Matchers)
})

View file

@ -13,7 +13,7 @@ import (
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/templategroup/v0alpha1"
"github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/alerting/v0alpha1"
"github.com/grafana/grafana/pkg/bus"
"github.com/grafana/grafana/pkg/infra/tracing"
"github.com/grafana/grafana/pkg/services/accesscontrol"
@ -52,7 +52,7 @@ func TestIntegrationResourceIdentifier(t *testing.T) {
ObjectMeta: v1.ObjectMeta{
Namespace: "default",
},
Spec: v0alpha1.Spec{
Spec: v0alpha1.TemplateGroupSpec{
Title: "templateGroup",
Content: `{{ define "test" }} test {{ end }}`,
},
@ -110,7 +110,7 @@ func TestIntegrationResourceIdentifier(t *testing.T) {
defaultDefn, err := templates.DefaultTemplate()
require.NoError(t, err)
require.Equal(t, v0alpha1.Spec{
require.Equal(t, v0alpha1.TemplateGroupSpec{
Title: v0alpha1.DefaultTemplateTitle,
Content: defaultDefn.Template,
}, actual.Spec)
@ -226,7 +226,7 @@ func TestIntegrationAccessControl(t *testing.T) {
ObjectMeta: v1.ObjectMeta{
Namespace: "default",
},
Spec: v0alpha1.Spec{
Spec: v0alpha1.TemplateGroupSpec{
Title: fmt.Sprintf("template-group-1-%s", tc.user.Identity.GetLogin()),
Content: `{{ define "test" }} test {{ end }}`,
},
@ -387,7 +387,7 @@ func TestIntegrationProvisioning(t *testing.T) {
ObjectMeta: v1.ObjectMeta{
Namespace: "default",
},
Spec: v0alpha1.Spec{
Spec: v0alpha1.TemplateGroupSpec{
Title: "template-group-1",
Content: `{{ define "test" }} test {{ end }}`,
},
@ -432,7 +432,7 @@ func TestIntegrationOptimisticConcurrency(t *testing.T) {
ObjectMeta: v1.ObjectMeta{
Namespace: "default",
},
Spec: v0alpha1.Spec{
Spec: v0alpha1.TemplateGroupSpec{
Title: "template-group-1",
Content: `{{ define "test" }} test {{ end }}`,
},
@ -516,7 +516,7 @@ func TestIntegrationPatch(t *testing.T) {
ObjectMeta: v1.ObjectMeta{
Namespace: "default",
},
Spec: v0alpha1.Spec{
Spec: v0alpha1.TemplateGroupSpec{
Title: "template-group",
Content: `{{ define "test" }} test {{ end }}`,
},
@ -576,7 +576,7 @@ func TestIntegrationListSelector(t *testing.T) {
ObjectMeta: v1.ObjectMeta{
Namespace: "default",
},
Spec: v0alpha1.Spec{
Spec: v0alpha1.TemplateGroupSpec{
Title: "test1",
Content: `{{ define "test1" }} test {{ end }}`,
},
@ -588,7 +588,7 @@ func TestIntegrationListSelector(t *testing.T) {
ObjectMeta: v1.ObjectMeta{
Namespace: "default",
},
Spec: v0alpha1.Spec{
Spec: v0alpha1.TemplateGroupSpec{
Title: "test2",
Content: `{{ define "test2" }} test {{ end }}`,
},

View file

@ -17,8 +17,8 @@ import (
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/timeinterval/v0alpha1"
"github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/timeinterval/v0alpha1/fakes"
"github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/alerting/v0alpha1"
"github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/alerting/v0alpha1/fakes"
"github.com/grafana/grafana/pkg/bus"
"github.com/grafana/grafana/pkg/infra/tracing"
"github.com/grafana/grafana/pkg/registry/apps/alerting/notifications/routingtree"
@ -64,7 +64,7 @@ func TestIntegrationResourceIdentifier(t *testing.T) {
ObjectMeta: v1.ObjectMeta{
Namespace: "default",
},
Spec: v0alpha1.Spec{
Spec: v0alpha1.TimeIntervalSpec{
Name: "time-newInterval",
TimeIntervals: fakes.IntervalGenerator{}.GenerateMany(2),
},
@ -201,7 +201,7 @@ func TestIntegrationTimeIntervalAccessControl(t *testing.T) {
ObjectMeta: v1.ObjectMeta{
Namespace: "default",
},
Spec: v0alpha1.Spec{
Spec: v0alpha1.TimeIntervalSpec{
Name: fmt.Sprintf("time-interval-1-%s", tc.user.Identity.GetLogin()),
TimeIntervals: fakes.IntervalGenerator{}.GenerateMany(2),
},
@ -361,7 +361,7 @@ func TestIntegrationTimeIntervalProvisioning(t *testing.T) {
ObjectMeta: v1.ObjectMeta{
Namespace: "default",
},
Spec: v0alpha1.Spec{
Spec: v0alpha1.TimeIntervalSpec{
Name: "time-interval-1",
TimeIntervals: fakes.IntervalGenerator{}.GenerateMany(2),
},
@ -408,7 +408,7 @@ func TestIntegrationTimeIntervalOptimisticConcurrency(t *testing.T) {
ObjectMeta: v1.ObjectMeta{
Namespace: "default",
},
Spec: v0alpha1.Spec{
Spec: v0alpha1.TimeIntervalSpec{
Name: "time-interval",
TimeIntervals: fakes.IntervalGenerator{}.GenerateMany(2),
},
@ -492,7 +492,7 @@ func TestIntegrationTimeIntervalPatch(t *testing.T) {
ObjectMeta: v1.ObjectMeta{
Namespace: "default",
},
Spec: v0alpha1.Spec{
Spec: v0alpha1.TimeIntervalSpec{
Name: "time-interval",
TimeIntervals: fakes.IntervalGenerator{}.GenerateMany(2),
},
@ -532,9 +532,9 @@ func TestIntegrationTimeIntervalPatch(t *testing.T) {
result, err := adminClient.Patch(ctx, current.Name, types.JSONPatchType, patchData, v1.PatchOptions{})
require.NoError(t, err)
expectedSpec := v0alpha1.Spec{
expectedSpec := v0alpha1.TimeIntervalSpec{
Name: current.Spec.Name,
TimeIntervals: []v0alpha1.Interval{
TimeIntervals: []v0alpha1.TimeIntervalInterval{
expected,
},
}
@ -557,7 +557,7 @@ func TestIntegrationTimeIntervalListSelector(t *testing.T) {
ObjectMeta: v1.ObjectMeta{
Namespace: "default",
},
Spec: v0alpha1.Spec{
Spec: v0alpha1.TimeIntervalSpec{
Name: "test1",
TimeIntervals: fakes.IntervalGenerator{}.GenerateMany(2),
},
@ -569,7 +569,7 @@ func TestIntegrationTimeIntervalListSelector(t *testing.T) {
ObjectMeta: v1.ObjectMeta{
Namespace: "default",
},
Spec: v0alpha1.Spec{
Spec: v0alpha1.TimeIntervalSpec{
Name: "test2",
TimeIntervals: fakes.IntervalGenerator{}.GenerateMany(2),
},
@ -790,20 +790,20 @@ func TestIntegrationTimeIntervalValidation(t *testing.T) {
testCases := []struct {
name string
interval v0alpha1.Spec
interval v0alpha1.TimeIntervalSpec
}{
{
name: "missing name",
interval: v0alpha1.Spec{
interval: v0alpha1.TimeIntervalSpec{
Name: "",
TimeIntervals: fakes.IntervalGenerator{}.GenerateMany(1),
},
},
{
name: "invalid interval",
interval: v0alpha1.Spec{
interval: v0alpha1.TimeIntervalSpec{
Name: "test",
TimeIntervals: []v0alpha1.Interval{
TimeIntervals: []v0alpha1.TimeIntervalInterval{
{
DaysOfMonth: []string{"1-31"},
},