Skip to content

Commit

Permalink
Support migration from TPR to CRD (#211)
Browse files Browse the repository at this point in the history
* Upgrade to client-go 4.0.0
* Fixed fake client
  • Loading branch information
Mir Shahriar authored and tamalsaha committed Aug 29, 2017
1 parent 4cae273 commit da708f9
Show file tree
Hide file tree
Showing 654 changed files with 88,733 additions and 67,158 deletions.
50 changes: 31 additions & 19 deletions api/extensions/tprs.yaml
Original file line number Diff line number Diff line change
@@ -1,29 +1,41 @@
metadata:
name: pod-alert.monitoring.appscode.com
name: podalerts.monitoring.appscode.com
labels:
app: searchlight
apiVersion: extensions/v1beta1
kind: ThirdPartyResource
description: "Searchlight by AppsCode - Alerts for Kubernetes"
versions:
- name: v1alpha1
app: searchlight
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
spec:
group: monitoring.appscode.com
names:
kind: PodAlert
plural: podalerts
scope: Namespaced
version: v1alpha1
---
metadata:
name: node-alert.monitoring.appscode.com
name: nodealerts.monitoring.appscode.com
labels:
app: searchlight
apiVersion: extensions/v1beta1
kind: ThirdPartyResource
description: "Searchlight by AppsCode - Node Alerts for Kubernetes"
versions:
- name: v1alpha1
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
spec:
group: monitoring.appscode.com
names:
kind: NodeAlert
plural: nodealerts
scope: Namespaced
version: v1alpha1
---
metadata:
name: cluster-alert.monitoring.appscode.com
name: clusteralerts.monitoring.appscode.com
labels:
app: searchlight
apiVersion: extensions/v1beta1
kind: ThirdPartyResource
description: "Searchlight by AppsCode - Cluster Alerts for Kubernetes"
versions:
- name: v1alpha1
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
spec:
group: monitoring.appscode.com
names:
kind: ClusterAlert
plural: clusteralerts
scope: Namespaced
version: v1alpha1
2 changes: 1 addition & 1 deletion api/install/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func init() {
GroupName: aci.GroupName,
VersionPreferenceOrder: []string{aci.V1alpha1SchemeGroupVersion.Version},
ImportPrefix: "github.com/appscode/searchlight/api",
RootScopedKinds: sets.NewString("ThirdPartyResource"),
RootScopedKinds: sets.NewString("CustomResourceDefinition"),
AddInternalObjectsToScheme: aci.AddToScheme,
},
announced.VersionToSchemeFunc{
Expand Down
8 changes: 0 additions & 8 deletions client/clientset/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,6 @@ func (*extendedCodec) DecodeParameters(parameters url.Values, from schema.GroupV
if len(parameters) == 0 {
return nil
}
_, okDelete := into.(*metav1.DeleteOptions)
if _, okList := into.(*metav1.ListOptions); okList || okDelete {
from = schema.GroupVersion{Version: "v1"}
}
return runtime.NewParameterCodec(api.Scheme).DecodeParameters(parameters, from, into)
}

Expand All @@ -139,10 +135,6 @@ func (c *extendedCodec) EncodeParameters(obj runtime.Object, to schema.GroupVers
if obj == nil {
return result, nil
}
_, okDelete := obj.(*metav1.DeleteOptions)
if _, okList := obj.(*metav1.ListOptions); okList || okDelete {
to = schema.GroupVersion{Version: "v1"}
}
return runtime.NewParameterCodec(api.Scheme).EncodeParameters(obj, to)
}

Expand Down
3 changes: 2 additions & 1 deletion client/clientset/fake/cluster_alert.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ type FakeClusterAlert struct {
}

var resourceClusterAlert = tapi.V1alpha1SchemeGroupVersion.WithResource(tapi.ResourceTypeClusterAlert)
var kindClusterAlert = tapi.V1alpha1SchemeGroupVersion.WithKind(tapi.ResourceKindClusterAlert)

// Get returns the ClusterAlert by name.
func (mock *FakeClusterAlert) Get(name string) (*tapi.ClusterAlert, error) {
Expand All @@ -30,7 +31,7 @@ func (mock *FakeClusterAlert) Get(name string) (*tapi.ClusterAlert, error) {
// List returns the a of ClusterAlerts.
func (mock *FakeClusterAlert) List(opts metav1.ListOptions) (*tapi.ClusterAlertList, error) {
obj, err := mock.Fake.
Invokes(testing.NewListAction(resourceClusterAlert, mock.ns, opts), &tapi.ClusterAlert{})
Invokes(testing.NewListAction(resourceClusterAlert, kindClusterAlert, mock.ns, opts), &tapi.ClusterAlert{})

if obj == nil {
return nil, err
Expand Down
4 changes: 2 additions & 2 deletions client/clientset/fake/extensions.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type FakeExtensionClient struct {
var _ clientset.ExtensionInterface = &FakeExtensionClient{}

func NewFakeExtensionClient(objects ...runtime.Object) *FakeExtensionClient {
o := testing.NewObjectTracker(api.Registry, api.Scheme, api.Codecs.UniversalDecoder())
o := testing.NewObjectTracker(api.Scheme, api.Codecs.UniversalDecoder())
for _, obj := range objects {
if obj.GetObjectKind().GroupVersionKind().Group == "monitoring.appscode.com" {
if err := o.Add(obj); err != nil {
Expand All @@ -26,7 +26,7 @@ func NewFakeExtensionClient(objects ...runtime.Object) *FakeExtensionClient {
}

fakePtr := testing.Fake{}
fakePtr.AddReactor("*", "*", testing.ObjectReaction(o, api.Registry.RESTMapper()))
fakePtr.AddReactor("*", "*", testing.ObjectReaction(o))

fakePtr.AddWatchReactor("*", testing.DefaultWatchReactor(watch.NewFake(), nil))

Expand Down
3 changes: 2 additions & 1 deletion client/clientset/fake/node_alert.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ type FakeNodeAlert struct {
}

var resourceNodeAlert = tapi.V1alpha1SchemeGroupVersion.WithResource(tapi.ResourceTypeNodeAlert)
var kindNodeAlert = tapi.V1alpha1SchemeGroupVersion.WithKind(tapi.ResourceKindNodeAlert)

// Get returns the NodeAlert by name.
func (mock *FakeNodeAlert) Get(name string) (*tapi.NodeAlert, error) {
Expand All @@ -30,7 +31,7 @@ func (mock *FakeNodeAlert) Get(name string) (*tapi.NodeAlert, error) {
// List returns the a of NodeAlerts.
func (mock *FakeNodeAlert) List(opts metav1.ListOptions) (*tapi.NodeAlertList, error) {
obj, err := mock.Fake.
Invokes(testing.NewListAction(resourceNodeAlert, mock.ns, opts), &tapi.NodeAlert{})
Invokes(testing.NewListAction(resourceNodeAlert, kindNodeAlert, mock.ns, opts), &tapi.NodeAlert{})

if obj == nil {
return nil, err
Expand Down
3 changes: 2 additions & 1 deletion client/clientset/fake/pod_alert.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ type FakePodAlert struct {
}

var resourcePodAlert = tapi.V1alpha1SchemeGroupVersion.WithResource(tapi.ResourceTypePodAlert)
var kindPodAlert = tapi.V1alpha1SchemeGroupVersion.WithKind(tapi.ResourceKindPodAlert)

// Get returns the PodAlert by name.
func (mock *FakePodAlert) Get(name string) (*tapi.PodAlert, error) {
Expand All @@ -30,7 +31,7 @@ func (mock *FakePodAlert) Get(name string) (*tapi.PodAlert, error) {
// List returns the a of PodAlerts.
func (mock *FakePodAlert) List(opts metav1.ListOptions) (*tapi.PodAlertList, error) {
obj, err := mock.Fake.
Invokes(testing.NewListAction(resourcePodAlert, mock.ns, opts), &tapi.PodAlert{})
Invokes(testing.NewListAction(resourcePodAlert, kindPodAlert, mock.ns, opts), &tapi.PodAlert{})

if obj == nil {
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion data/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[Website](https://appscode.com)[Slack](https://appscode.slack.com)[Twitter](https://twitter.com/AppsCodeHQ)

Searchlight by AppsCode is a Kubernetes operator for [Icinga](https://www.icinga.com/). If you are running production workloads in Kubernetes, you probably want to be alerted when things go wrong. Icinga periodically runs various checks on a Kubernetes cluster and sends notifications if detects an issue. It also nicely supplements whitebox monitoring tools like, [Prometheus](https://prometheus.io/) with blackbox monitoring can catch problems that are otherwise invisible, and also serves as a fallback in case internal systems completely fail. Searchlight is a TPR controller for Kubernetes built around Icinga to address these issues. This package contains static data files used by Searchlight.
Searchlight by AppsCode is a Kubernetes operator for [Icinga](https://www.icinga.com/). If you are running production workloads in Kubernetes, you probably want to be alerted when things go wrong. Icinga periodically runs various checks on a Kubernetes cluster and sends notifications if detects an issue. It also nicely supplements whitebox monitoring tools like, [Prometheus](https://prometheus.io/) with blackbox monitoring can catch problems that are otherwise invisible, and also serves as a fallback in case internal systems completely fail. Searchlight is a CRD controller for Kubernetes built around Icinga to address these issues. This package contains static data files used by Searchlight.
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<img src="/cover.jpg">


Searchlight by AppsCode is a Kubernetes operator for [Icinga](https://www.icinga.com/). If you are running production workloads in Kubernetes, you probably want to be alerted when things go wrong. Icinga periodically runs various checks on a Kubernetes cluster and sends notifications if detects an issue. It also nicely supplements whitebox monitoring tools like, [Prometheus](https://prometheus.io/) with blackbox monitoring can catch problems that are otherwise invisible, and also serves as a fallback in case internal systems completely fail. Searchlight is a TPR controller for Kubernetes built around Icinga to address these issues. Searchlight can do the following things for you:
Searchlight by AppsCode is a Kubernetes operator for [Icinga](https://www.icinga.com/). If you are running production workloads in Kubernetes, you probably want to be alerted when things go wrong. Icinga periodically runs various checks on a Kubernetes cluster and sends notifications if detects an issue. It also nicely supplements whitebox monitoring tools like, [Prometheus](https://prometheus.io/) with blackbox monitoring can catch problems that are otherwise invisible, and also serves as a fallback in case internal systems completely fail. Searchlight is a CRD controller for Kubernetes built around Icinga to address these issues. Searchlight can do the following things for you:

- Periodically run various checks on a Kubernetes cluster and its nodes or pods.
- Includes a [suite of check commands](/docs/reference/hyperalert/hyperalert.md) written specifically for Kubernetes.
Expand Down
2 changes: 1 addition & 1 deletion docs/cluster-alerts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# ClusterAlerts

## What is ClusterAlert
A `ClusterAlert` is a Kubernetes `Third Party Object` (TPR). It provides declarative configuration of [Icinga services](https://www.icinga.com/docs/icinga2/latest/doc/09-object-types/#service) for cluster level alerts in a Kubernetes native way. You only need to describe the desired check command and notifier in a ClusterAlert object, and the Searchlight operator will create Icinga2 hosts, services and notifications to the desired state for you.
A `ClusterAlert` is a Kubernetes `Custom Resource Definition` (CRD). It provides declarative configuration of [Icinga services](https://www.icinga.com/docs/icinga2/latest/doc/09-object-types/#service) for cluster level alerts in a Kubernetes native way. You only need to describe the desired check command and notifier in a ClusterAlert object, and the Searchlight operator will create Icinga2 hosts, services and notifications to the desired state for you.

## ClusterAlert Spec
As with all other Kubernetes objects, a ClusterAlert needs `apiVersion`, `kind`, and `metadata` fields. It also needs a `.spec` section. Below is an example ClusterAlert object.
Expand Down
2 changes: 1 addition & 1 deletion docs/node-alerts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# NodeAlerts

## What is NodeAlert
A `NodeAlert` is a Kubernetes `Third Party Object` (TPR). It provides declarative configuration of [Icinga services](https://www.icinga.com/docs/icinga2/latest/doc/09-object-types/#service) for Nodes in a Kubernetes native way. You only need to describe the desired check command and notifier in a NodeAlert object, and the Searchlight operator will create Icinga2 hosts, services and notifications to the desired state for you.
A `NodeAlert` is a Kubernetes `Custom Resource Definition` (CRD). It provides declarative configuration of [Icinga services](https://www.icinga.com/docs/icinga2/latest/doc/09-object-types/#service) for Nodes in a Kubernetes native way. You only need to describe the desired check command and notifier in a NodeAlert object, and the Searchlight operator will create Icinga2 hosts, services and notifications to the desired state for you.

## NodeAlert Spec
As with all other Kubernetes objects, a NodeAlert needs `apiVersion`, `kind`, and `metadata` fields. It also needs a `.spec` section. Below is an example NodeAlert object.
Expand Down
2 changes: 1 addition & 1 deletion docs/pod-alerts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# PodAlerts

## What is PodAlert
A `PodAlert` is a Kubernetes `Third Party Object` (TPR). It provides declarative configuration of [Icinga services](https://www.icinga.com/docs/icinga2/latest/doc/09-object-types/#service) for Pods in a Kubernetes native way. You only need to describe the desired check command and notifier in a PodAlert object, and the Searchlight operator will create Icinga2 hosts, services and notifications to the desired state for you.
A `PodAlert` is a Kubernetes `Custom Resource Definition` (CRD). It provides declarative configuration of [Icinga services](https://www.icinga.com/docs/icinga2/latest/doc/09-object-types/#service) for Pods in a Kubernetes native way. You only need to describe the desired check command and notifier in a PodAlert object, and the Searchlight operator will create Icinga2 hosts, services and notifications to the desired state for you.

## PodAlert Spec
As with all other Kubernetes objects, a PodAlert needs `apiVersion`, `kind`, and `metadata` fields. It also needs a `.spec` section. Below is an example PodAlert object.
Expand Down
Loading

0 comments on commit da708f9

Please sign in to comment.