Skip to content

Commit

Permalink
Add hpa printer
Browse files Browse the repository at this point in the history
Signed-off-by: GuessWhoSamFoo <[email protected]>
  • Loading branch information
GuessWhoSamFoo committed Sep 24, 2019
1 parent 2720b57 commit 37faede
Show file tree
Hide file tree
Showing 10 changed files with 529 additions and 18 deletions.
2 changes: 1 addition & 1 deletion internal/config/dash.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ func (l *Live) CRDWatcher() CRDWatcher {
return l.crdWatcher
}

// Store returns an object store.
// ObjectStore returns an object store.
func (l *Live) ObjectStore() store.Store {
return l.objectStore
}
Expand Down
11 changes: 11 additions & 0 deletions internal/describer/objects.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"sync"

appsv1 "k8s.io/api/apps/v1"
"k8s.io/api/autoscaling/v2beta2"
batchv1 "k8s.io/api/batch/v1"
batchv1beta1 "k8s.io/api/batch/v1beta1"
corev1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -136,6 +137,15 @@ func initNamespacedOverview() *Section {
workloadsStatefulSets,
)

dlbHorizontalPodAutoscalers := NewResource(ResourceOptions{
Path: "/discovery-and-load-balancing/horizontal-pod-autoscalers",
ObjectStoreKey: store.Key{APIVersion: "autoscaling/v2beta2", Kind: "HorizontalPodAutoscaler"},
ListType: &v2beta2.HorizontalPodAutoscalerList{},
ObjectType: &v2beta2.HorizontalPodAutoscaler{},
Titles: ResourceTitle{List: "Discovery & Load Balancing / Horizontal Pod Autoscaler", Object: "Horizontal Pod Autoscaler"},
IconName: icon.OverviewHorizontalPodAutoscaler,
})

dlbIngresses := NewResource(ResourceOptions{
Path: "/discovery-and-load-balancing/ingresses",
ObjectStoreKey: store.Key{APIVersion: "extensions/v1beta1", Kind: "Ingress"},
Expand All @@ -157,6 +167,7 @@ func initNamespacedOverview() *Section {
discoveryAndLoadBalancingDescriber := NewSection(
"/discovery-and-load-balancing",
"Discovery and Load Balancing",
dlbHorizontalPodAutoscalers,
dlbIngresses,
dlbServices,
)
Expand Down
1 change: 1 addition & 0 deletions internal/gvk/gvk.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ var (
ExtDeployment = schema.GroupVersionKind{Group: "extensions", Version: "v1beta1", Kind: "Deployment"}
ExtReplicaSet = schema.GroupVersionKind{Group: "extensions", Version: "v1beta1", Kind: "ReplicaSet"}
Event = schema.GroupVersionKind{Version: "v1", Kind: "Event"}
HorizontalPodAutoscaler = schema.GroupVersionKind{Group: "autoscaling", Version: "v2beta2", Kind: "HorizontalPodAutoscaler"}
Ingress = schema.GroupVersionKind{Group: "extensions", Version: "v1beta1", Kind: "Ingress"}
Job = schema.GroupVersionKind{Group: "batch", Version: "v1", Kind: "Job"}
Node = schema.GroupVersionKind{Version: "v1", Kind: "Node"}
Expand Down
2 changes: 2 additions & 0 deletions internal/modules/overview/navigation.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ func workloadEntries(ctx context.Context, prefix, namespace string, objectStore

func discoAndLBEntries(ctx context.Context, prefix, namespace string, objectStore store.Store, _ bool) ([]navigation.Navigation, bool, error) {
neh := navigation.EntriesHelper{}
neh.Add("Horizontal Pod Autoscalers", "horizontal-pod-autoscalers", icon.OverviewHorizontalPodAutoscaler,
loading.IsObjectLoading(ctx, namespace, store.KeyFromGroupVersionKind(gvk.HorizontalPodAutoscaler), objectStore))
neh.Add("Ingresses", "ingresses", icon.OverviewIngress,
loading.IsObjectLoading(ctx, namespace, store.KeyFromGroupVersionKind(gvk.Ingress), objectStore))
neh.Add("Services", "services", icon.OverviewService,
Expand Down
3 changes: 3 additions & 0 deletions internal/modules/overview/path.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ var (
gvk.Pod,
gvk.ReplicationController,
gvk.StatefulSet,
gvk.HorizontalPodAutoscaler,
gvk.Ingress,
gvk.Service,
gvk.ConfigMap,
Expand Down Expand Up @@ -79,6 +80,8 @@ func gvkPath(namespace, apiVersion, kind, name string) (string, error) {
p = "/config-and-storage/persistent-volume-claims"
case apiVersion == "v1" && kind == "ServiceAccount":
p = "/config-and-storage/service-accounts"
case (apiVersion == "autoscaling/v1" || apiVersion == "autoscaling/v2beta2") && kind == "HorizontalPodAutoscaler":
p = "/discovery-and-load-balancing/horizontal-pod-autoscalers"
case apiVersion == "extensions/v1beta1" && kind == "Ingress":
p = "/discovery-and-load-balancing/ingresses"
case apiVersion == "v1" && kind == "Service":
Expand Down
2 changes: 2 additions & 0 deletions internal/printer/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ func AddHandlers(p Handler) error {
DaemonSetHandler,
DeploymentHandler,
DeploymentListHandler,
HorizontalPodAutoscalerHandler,
HorizontalPodAutoscalerListHandler,
IngressListHandler,
IngressHandler,
JobListHandler,
Expand Down
Loading

0 comments on commit 37faede

Please sign in to comment.