Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix build #301

Merged
merged 1 commit into from
Mar 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions apis/incidents/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,29 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// +genclient
// +genclient:skipVerbs=get,list,update,patch,deleteCollection,watch
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

type Acknowledgement struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
metav1.TypeMeta
metav1.ObjectMeta

Request AcknowledgementRequest `json:"request"`
Response AcknowledgementResponse `json:"response,omitempty"`
Request AcknowledgementRequest
Response AcknowledgementResponse
}

type AcknowledgementRequest struct {
// Comment by user
Comment string `json:"comment"`
Comment string

// Skip sending notification
// +optional
SkipNotify bool `json:"skipNotify,omitempty"`
SkipNotify bool
}

type AcknowledgementResponse struct {
// The time at which the acknowledgement was done.
// +optional
Timestamp metav1.Time `json:"timestamp,omitempty"`
Timestamp metav1.Time
}
2 changes: 1 addition & 1 deletion apis/incidents/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ const (
ResourceSingularAcknowledgement = "acknowledgement"
)

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +genclient
// +genclient:skipVerbs=get,list,update,patch,deleteCollection,watch
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

type Acknowledgement struct {
metav1.TypeMeta `json:",inline"`
Expand Down
57 changes: 57 additions & 0 deletions apis/monitoring/cluster_alert.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package monitoring

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

type CheckCluster string

// +genclient
// +genclient:skipVerbs=updateStatus
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

type ClusterAlert struct {
metav1.TypeMeta
// Standard object's metadata.
// More info: http://releases.k8s.io/release-1.2/docs/devel/api-conventions.md#metadata
metav1.ObjectMeta

// Spec is the desired state of the ClusterAlert.
// More info: http://releases.k8s.io/release-1.2/docs/devel/api-conventions.md#spec-and-status
Spec ClusterAlertSpec
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// ClusterAlertList is a collection of ClusterAlert.
type ClusterAlertList struct {
metav1.TypeMeta
// Standard object's metadata.
// More info: http://releases.k8s.io/release-1.2/docs/devel/api-conventions.md#metadata
metav1.ListMeta

// Items is the list of ClusterAlert.
Items []ClusterAlert
}

// ClusterAlertSpec describes the ClusterAlert the user wishes to create.
type ClusterAlertSpec struct {
// Icinga CheckCommand name
Check CheckCluster

// How frequently Icinga Service will be checked
CheckInterval metav1.Duration

// How frequently notifications will be send
AlertInterval metav1.Duration

// Secret containing notifier credentials
NotifierSecretName string

// NotifierParams contains information to send notifications for Incident
// State, UserUid, Method
Receivers []Receiver

// Vars contains Icinga Service variables to be used in CheckCommand
Vars map[string]string
}
5 changes: 5 additions & 0 deletions apis/monitoring/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// +k8s:deepcopy-gen=package,register

// Package api is the internal version of the API.
// +groupName=monitoring.appscode.com
package monitoring
66 changes: 66 additions & 0 deletions apis/monitoring/incident.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package monitoring

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// +genclient
// +genclient:skipVerbs=updateStatus
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

type Incident struct {
metav1.TypeMeta
// Standard object's metadata.
// More info: http://releases.k8s.io/release-1.2/docs/devel/api-conventions.md#metadata
metav1.ObjectMeta

// Derived information about the incident.
// +optional
Status IncidentStatus
}

type IncidentStatus struct {
// state of incident, such as Critical, Warning, OK
LastNotificationType IncidentNotificationType

// Notifications for the incident, such as problem or acknowledge.
// +optional
Notifications []IncidentNotification
}

type IncidentNotificationType string

type IncidentNotification struct {
// incident notification type.
Type IncidentNotificationType
// brief output of check command for the incident
// +optional
CheckOutput string
// name of user making comment
// +optional
Author *string
// comment made by user
// +optional
Comment *string
// The time at which this notification was first recorded. (Time of server receipt is in TypeMeta.)
// +optional
FirstTimestamp metav1.Time
// The time at which the most recent occurrence of this notification was recorded.
// +optional
LastTimestamp metav1.Time
// state of incident, such as Critical, Warning, OK, Unknown
LastState string
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// IncidentList is a collection of Incident.
type IncidentList struct {
metav1.TypeMeta
// Standard object's metadata.
// More info: http://releases.k8s.io/release-1.2/docs/devel/api-conventions.md#metadata
metav1.ListMeta

// Items is the list of Incident.
Items []Incident
}
17 changes: 16 additions & 1 deletion apis/monitoring/install/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,27 @@ limitations under the License.
package install

import (
"github.com/appscode/searchlight/apis/monitoring"
"github.com/appscode/searchlight/apis/monitoring/v1alpha1"
"k8s.io/apimachinery/pkg/apimachinery/announced"
"k8s.io/apimachinery/pkg/apimachinery/registered"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/sets"
)

// Install registers the API group and adds types to a scheme
func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *registered.APIRegistrationManager, scheme *runtime.Scheme) {
// unused
if err := announced.NewGroupMetaFactory(
&announced.GroupMetaFactoryArgs{
GroupName: monitoring.GroupName,
RootScopedKinds: sets.NewString(),
VersionPreferenceOrder: []string{v1alpha1.SchemeGroupVersion.Version},
AddInternalObjectsToScheme: monitoring.AddToScheme,
},
announced.VersionToSchemeFunc{
v1alpha1.SchemeGroupVersion.Version: v1alpha1.AddToScheme,
},
).Announce(groupFactoryRegistry).RegisterAndEnable(registry, scheme); err != nil {
panic(err)
}
}
61 changes: 61 additions & 0 deletions apis/monitoring/node_alert.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package monitoring

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

type CheckNode string

// +genclient
// +genclient:skipVerbs=updateStatus
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

type NodeAlert struct {
metav1.TypeMeta
// Standard object's metadata.
// More info: http://releases.k8s.io/release-1.2/docs/devel/api-conventions.md#metadata
metav1.ObjectMeta

// Spec is the desired state of the NodeAlert.
// More info: http://releases.k8s.io/release-1.2/docs/devel/api-conventions.md#spec-and-status
Spec NodeAlertSpec
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// NodeAlertList is a collection of NodeAlert.
type NodeAlertList struct {
metav1.TypeMeta
// Standard object's metadata.
// More info: http://releases.k8s.io/release-1.2/docs/devel/api-conventions.md#metadata
metav1.ListMeta

// Items is the list of NodeAlert.
Items []NodeAlert
}

// NodeAlertSpec describes the NodeAlert the user wishes to create.
type NodeAlertSpec struct {
Selector map[string]string

NodeName *string

// Icinga CheckCommand name
Check CheckNode

// How frequently Icinga Service will be checked
CheckInterval metav1.Duration

// How frequently notifications will be send
AlertInterval metav1.Duration

// Secret containing notifier credentials
NotifierSecretName string

// NotifierParams contains information to send notifications for Incident
// State, UserUid, Method
Receivers []Receiver

// Vars contains Icinga Service variables to be used in CheckCommand
Vars map[string]string
}
61 changes: 61 additions & 0 deletions apis/monitoring/pod_alert.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package monitoring

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

type CheckPod string

// +genclient
// +genclient:skipVerbs=updateStatus
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

type PodAlert struct {
metav1.TypeMeta
// Standard object's metadata.
// More info: http://releases.k8s.io/release-1.2/docs/devel/api-conventions.md#metadata
metav1.ObjectMeta

// Spec is the desired state of the PodAlert.
// More info: http://releases.k8s.io/release-1.2/docs/devel/api-conventions.md#spec-and-status
Spec PodAlertSpec
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// PodAlertList is a collection of PodAlert.
type PodAlertList struct {
metav1.TypeMeta
// Standard object's metadata.
// More info: http://releases.k8s.io/release-1.2/docs/devel/api-conventions.md#metadata
metav1.ListMeta

// Items is the list of PodAlert.
Items []PodAlert
}

// PodAlertSpec describes the PodAlert the user wishes to create.
type PodAlertSpec struct {
Selector *metav1.LabelSelector

PodName *string

// Icinga CheckCommand name
Check CheckPod

// How frequently Icinga Service will be checked
CheckInterval metav1.Duration

// How frequently notifications will be send
AlertInterval metav1.Duration

// Secret containing notifier credentials
NotifierSecretName string

// NotifierParams contains information to send notifications for Incident
// State, UserUid, Method
Receivers []Receiver

// Vars contains Icinga Service variables to be used in CheckCommand
Vars map[string]string
}
39 changes: 38 additions & 1 deletion apis/monitoring/register.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,41 @@
package monitoring

// GroupName is the group name use in this package
import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
)

const GroupName = "monitoring.appscode.com"

// SchemeGroupVersion is group version used to register these objects
var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: runtime.APIVersionInternal}

// Kind takes an unqualified kind and returns back a Group qualified GroupKind
func Kind(kind string) schema.GroupKind {
return SchemeGroupVersion.WithKind(kind).GroupKind()
}

// Resource takes an unqualified resource and returns back a Group qualified GroupResource
func Resource(resource string) schema.GroupResource {
return SchemeGroupVersion.WithResource(resource).GroupResource()
}

var (
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
AddToScheme = SchemeBuilder.AddToScheme
)

// Adds the list of known types to api.Scheme.
func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(SchemeGroupVersion,
&ClusterAlert{},
&ClusterAlertList{},
&NodeAlert{},
&NodeAlertList{},
&PodAlert{},
&PodAlertList{},
&Incident{},
&IncidentList{},
)
return nil
}
12 changes: 12 additions & 0 deletions apis/monitoring/types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package monitoring

type Receiver struct {
// For which state notification will be sent
State string

// To whom notification will be sent
To []string

// How this notification will be sent
Notifier string
}
6 changes: 3 additions & 3 deletions apis/monitoring/v1alpha1/doc.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Package v1alpha1 is the v1alpha1 version of the API.

// +k8s:deepcopy-gen=package,register
// +k8s:deepcopy-gen=package
// +k8s:conversion-gen=github.com/appscode/searchlight/apis/monitoring
// +k8s:openapi-gen=true
// +k8s:defaulter-gen=TypeMeta

// Package v1alpha1 is the v1alpha1 version of the API.
// +groupName=monitoring.appscode.com
package v1alpha1
Loading