Skip to content

Commit

Permalink
Use prometheus tools from appscode/kutil (#124)
Browse files Browse the repository at this point in the history
  • Loading branch information
tamalsaha authored Nov 15, 2017
1 parent 3c539b6 commit f7015ed
Show file tree
Hide file tree
Showing 54 changed files with 1,287 additions and 1,385 deletions.
28 changes: 16 additions & 12 deletions glide.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 20 additions & 19 deletions pkg/describer/k8sdb_describer.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import (
"fmt"
"io"

tapi "github.com/k8sdb/apimachinery/apis/kubedb/v1alpha1"
mona "github.com/appscode/kutil/tools/monitoring/api"
api "github.com/k8sdb/apimachinery/apis/kubedb/v1alpha1"
core "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
Expand All @@ -15,7 +16,7 @@ import (

const statusUnknown = "Unknown"

func (d *humanReadableDescriber) describeElastic(item *tapi.Elasticsearch, describerSettings *printers.DescriberSettings) (string, error) {
func (d *humanReadableDescriber) describeElastic(item *api.Elasticsearch, describerSettings *printers.DescriberSettings) (string, error) {
clientSet, err := d.ClientSet()
if err != nil {
return "", err
Expand All @@ -25,8 +26,8 @@ func (d *humanReadableDescriber) describeElastic(item *tapi.Elasticsearch, descr
metav1.ListOptions{
LabelSelector: labels.SelectorFromSet(
map[string]string{
tapi.LabelDatabaseKind: item.ResourceKind(),
tapi.LabelDatabaseName: item.Name,
api.LabelDatabaseKind: item.ResourceKind(),
api.LabelDatabaseName: item.Name,
},
).String(),
},
Expand All @@ -37,7 +38,7 @@ func (d *humanReadableDescriber) describeElastic(item *tapi.Elasticsearch, descr

var events *kapi.EventList
if describerSettings.ShowEvents {
item.Kind = tapi.ResourceKindElasticsearch
item.Kind = api.ResourceKindElasticsearch
events, err = clientSet.Core().Events(item.Namespace).Search(scheme.Scheme, item)
if err != nil {
return "", err
Expand Down Expand Up @@ -81,7 +82,7 @@ func (d *humanReadableDescriber) describeElastic(item *tapi.Elasticsearch, descr
})
}

func (d *humanReadableDescriber) describePostgres(item *tapi.Postgres, describerSettings *printers.DescriberSettings) (string, error) {
func (d *humanReadableDescriber) describePostgres(item *api.Postgres, describerSettings *printers.DescriberSettings) (string, error) {
clientSet, err := d.ClientSet()
if err != nil {
return "", err
Expand All @@ -91,8 +92,8 @@ func (d *humanReadableDescriber) describePostgres(item *tapi.Postgres, describer
metav1.ListOptions{
LabelSelector: labels.SelectorFromSet(
map[string]string{
tapi.LabelDatabaseKind: item.ResourceKind(),
tapi.LabelDatabaseName: item.Name,
api.LabelDatabaseKind: item.ResourceKind(),
api.LabelDatabaseName: item.Name,
},
).String(),
},
Expand All @@ -103,7 +104,7 @@ func (d *humanReadableDescriber) describePostgres(item *tapi.Postgres, describer

var events *kapi.EventList
if describerSettings.ShowEvents {
item.Kind = tapi.ResourceKindPostgres
item.Kind = api.ResourceKindPostgres
events, err = clientSet.Core().Events(item.Namespace).Search(scheme.Scheme, item)
if err != nil {
return "", err
Expand Down Expand Up @@ -149,15 +150,15 @@ func (d *humanReadableDescriber) describePostgres(item *tapi.Postgres, describer
})
}

func (d *humanReadableDescriber) describeSnapshot(item *tapi.Snapshot, describerSettings *printers.DescriberSettings) (string, error) {
func (d *humanReadableDescriber) describeSnapshot(item *api.Snapshot, describerSettings *printers.DescriberSettings) (string, error) {
clientSet, err := d.ClientSet()
if err != nil {
return "", err
}

var events *kapi.EventList
if describerSettings.ShowEvents {
item.Kind = tapi.ResourceKindSnapshot
item.Kind = api.ResourceKindSnapshot
events, err = clientSet.Core().Events(item.Namespace).Search(scheme.Scheme, item)
if err != nil {
return "", err
Expand Down Expand Up @@ -192,7 +193,7 @@ func (d *humanReadableDescriber) describeSnapshot(item *tapi.Snapshot, describer
})
}

func (d *humanReadableDescriber) describeDormantDatabase(item *tapi.DormantDatabase, describerSettings *printers.DescriberSettings) (string, error) {
func (d *humanReadableDescriber) describeDormantDatabase(item *api.DormantDatabase, describerSettings *printers.DescriberSettings) (string, error) {
clientSet, err := d.ClientSet()
if err != nil {
return "", err
Expand All @@ -202,8 +203,8 @@ func (d *humanReadableDescriber) describeDormantDatabase(item *tapi.DormantDatab
metav1.ListOptions{
LabelSelector: labels.SelectorFromSet(
map[string]string{
tapi.LabelDatabaseKind: item.Labels[tapi.LabelDatabaseKind],
tapi.LabelDatabaseName: item.Name,
api.LabelDatabaseKind: item.Labels[api.LabelDatabaseKind],
api.LabelDatabaseName: item.Name,
},
).String(),
},
Expand All @@ -214,7 +215,7 @@ func (d *humanReadableDescriber) describeDormantDatabase(item *tapi.DormantDatab

var events *kapi.EventList
if describerSettings.ShowEvents {
item.Kind = tapi.ResourceKindDormantDatabase
item.Kind = api.ResourceKindDormantDatabase
events, err = clientSet.Core().Events(item.Namespace).Search(scheme.Scheme, item)
if err != nil {
return "", err
Expand Down Expand Up @@ -244,7 +245,7 @@ func (d *humanReadableDescriber) describeDormantDatabase(item *tapi.DormantDatab

describeOrigin(item.Spec.Origin, out)

if item.Status.Phase != tapi.DormantDatabasePhaseWipedOut {
if item.Status.Phase != api.DormantDatabasePhaseWipedOut {
listSnapshots(snapshots, out)
}

Expand Down Expand Up @@ -273,7 +274,7 @@ func describeStorage(pvcSpec *core.PersistentVolumeClaimSpec, out io.Writer) {
fmt.Fprintf(out, " Access Modes:\t%s\n", accessModes)
}

func describeMonitor(monitor *tapi.MonitorSpec, out io.Writer) {
func describeMonitor(monitor *mona.AgentSpec, out io.Writer) {
if monitor == nil {
return
}
Expand All @@ -292,7 +293,7 @@ func describeMonitor(monitor *tapi.MonitorSpec, out io.Writer) {
}
}

func listSnapshots(snapshotList *tapi.SnapshotList, out io.Writer) {
func listSnapshots(snapshotList *api.SnapshotList, out io.Writer) {
fmt.Fprint(out, "\n")

if len(snapshotList.Items) == 0 {
Expand Down Expand Up @@ -321,7 +322,7 @@ func listSnapshots(snapshotList *tapi.SnapshotList, out io.Writer) {
w.Flush()
}

func describeOrigin(origin tapi.Origin, out io.Writer) {
func describeOrigin(origin api.Origin, out io.Writer) {
fmt.Fprint(out, "\n")
fmt.Fprint(out, "Origin:\n")
fmt.Fprintf(out, " Name:\t%s\n", origin.Name)
Expand Down
4 changes: 2 additions & 2 deletions vendor/github.com/appscode/go/version/version.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit f7015ed

Please sign in to comment.