Skip to content
This repository has been archived by the owner on Jan 19, 2023. It is now read-only.

Add network policy printer #813

Merged
merged 2 commits into from
Apr 17, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 11 additions & 0 deletions internal/describer/objects.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
batchv1beta1 "k8s.io/api/batch/v1beta1"
corev1 "k8s.io/api/core/v1"
"k8s.io/api/extensions/v1beta1"
networkingv1 "k8s.io/api/networking/v1"
rbacv1 "k8s.io/api/rbac/v1"

"github.com/vmware-tanzu/octant/pkg/icon"
Expand Down Expand Up @@ -164,12 +165,22 @@ func initNamespacedOverview() *Section {
IconName: icon.OverviewService,
})

dlbNetworkPolicies := NewResource(ResourceOptions{
Path: "/discovery-and-load-balancing/network-policies",
ObjectStoreKey: store.Key{APIVersion: "networking.k8s.io/v1", Kind: "NetworkPolicy"},
ListType: &networkingv1.NetworkPolicyList{},
ObjectType: &networkingv1.NetworkPolicy{},
Titles: ResourceTitle{List: "Discovery & Load Balancing / Network Policies", Object: "Network Policy"},
IconName: icon.OverviewNetworkPolicy,
})

discoveryAndLoadBalancingDescriber := NewSection(
"/discovery-and-load-balancing",
"Discovery and Load Balancing",
dlbHorizontalPodAutoscalers,
dlbIngresses,
dlbServices,
dlbNetworkPolicies,
)

csConfigMaps := NewResource(ResourceOptions{
Expand Down
1 change: 1 addition & 0 deletions internal/gvk/gvk.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ var (
Job = schema.GroupVersionKind{Group: "batch", Version: "v1", Kind: "Job"}
Node = schema.GroupVersionKind{Version: "v1", Kind: "Node"}
Namespace = schema.GroupVersionKind{Version: "v1", Kind: "Namespace"}
NetworkPolicy = schema.GroupVersionKind{Group: "networking.k8s.io", Version: "v1", Kind: "NetworkPolicy"}
ServiceAccount = schema.GroupVersionKind{Version: "v1", Kind: "ServiceAccount"}
Secret = schema.GroupVersionKind{Version: "v1", Kind: "Secret"}
Service = schema.GroupVersionKind{Version: "v1", Kind: "Service"}
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 @@ -64,6 +64,8 @@ func discoAndLBEntries(ctx context.Context, prefix, namespace string, objectStor
loading.IsObjectLoading(ctx, namespace, store.KeyFromGroupVersionKind(gvk.Ingress), objectStore))
neh.Add("Services", "services",
loading.IsObjectLoading(ctx, namespace, store.KeyFromGroupVersionKind(gvk.Service), objectStore))
neh.Add("Network Policies", "network-policies",
loading.IsObjectLoading(ctx, namespace, store.KeyFromGroupVersionKind(gvk.NetworkPolicy), objectStore))

children, err := neh.Generate(prefix, namespace, "")
if err != nil {
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 @@ -28,6 +28,7 @@ var (
gvk.HorizontalPodAutoscaler,
gvk.Ingress,
gvk.Service,
gvk.NetworkPolicy,
gvk.ConfigMap,
gvk.Secret,
gvk.PersistentVolumeClaim,
Expand Down Expand Up @@ -86,6 +87,8 @@ func gvkPath(namespace, apiVersion, kind, name string) (string, error) {
p = "/discovery-and-load-balancing/ingresses"
case apiVersion == "v1" && kind == "Service":
p = "/discovery-and-load-balancing/services"
case apiVersion == "networking.k8s.io/v1" && kind == "NetworkPolicy":
p = "/discovery-and-load-balancing/network-policies"
case apiVersion == "rbac.authorization.k8s.io/v1" && kind == "Role":
p = "/rbac/roles"
case apiVersion == "rbac.authorization.k8s.io/v1" && kind == "RoleBinding":
Expand Down
2 changes: 2 additions & 0 deletions internal/printer/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ func AddHandlers(p Handler) error {
NodeListHandler,
NamespaceHandler,
NamespaceListHandler,
NetworkPolicyHandler,
NetworkPolicyListHandler,
ReplicaSetHandler,
ReplicaSetListHandler,
ReplicationControllerHandler,
Expand Down