Skip to content

Commit

Permalink
feat: add debug logs
Browse files Browse the repository at this point in the history
  • Loading branch information
trois-six committed Apr 28, 2021
1 parent dcd475d commit 1ed7c83
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions pkg/diagram/objects.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/blushft/go-diagrams/diagram"
"github.com/blushft/go-diagrams/nodes/apps"
"github.com/blushft/go-diagrams/nodes/k8s"
"github.com/rs/zerolog/log"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
networkingv1 "k8s.io/api/networking/v1"
Expand All @@ -23,6 +24,8 @@ func (d *Diagram) GenerateDeployments(namespace string, o *appsv1.DeploymentList
continue
}

log.Debug().Msgf("Generating deployment: %s", v.Name)

d.deployments[v.Name] = k8s.Compute.Deploy(
diagram.NodeLabel(v.Name),
diagram.SetFontOptions(diagram.Font{Size: nodeFontSize}),
Expand All @@ -38,6 +41,8 @@ func (d *Diagram) GenerateDaemonSets(namespace string, o *appsv1.DaemonSetList)
continue
}

log.Debug().Msgf("Generating daemonSet: %s", v.Name)

d.daemonSets[v.Name] = k8s.Compute.Ds(
diagram.NodeLabel(v.Name),
diagram.SetFontOptions(diagram.Font{Size: nodeFontSize}),
Expand All @@ -60,6 +65,8 @@ func (d *Diagram) GenerateReplicaSets(namespace string, o *appsv1.ReplicaSetList
continue
}

log.Debug().Msgf("Generating replicaSet: %s", v.Name)

d.replicaSets[v.Name] = k8s.Compute.Rs(
diagram.NodeLabel(v.Name),
diagram.SetFontOptions(diagram.Font{Size: nodeFontSize}),
Expand Down Expand Up @@ -90,6 +97,8 @@ func (d *Diagram) GenerateStatefulSets(namespace string, o *appsv1.StatefulSetLi
continue
}

log.Debug().Msgf("Generating statefulSet: %s", v.Name)

d.statefulSets[v.Name] = k8s.Compute.Sts(
diagram.NodeLabel(v.Name),
diagram.SetFontOptions(diagram.Font{Size: nodeFontSize}),
Expand All @@ -112,6 +121,8 @@ func (d *Diagram) GeneratePods(namespace string, o *corev1.PodList) {
continue
}

log.Debug().Msgf("Generating pod: %s", v.Name)

d.pods[v.Name] = k8s.Compute.Pod(
diagram.NodeLabel(v.Name),
diagram.SetFontOptions(diagram.Font{Size: nodeFontSize}),
Expand All @@ -122,14 +133,17 @@ func (d *Diagram) GeneratePods(namespace string, o *corev1.PodList) {
for _, o := range v.GetOwnerReferences() {
switch strings.ToLower(o.Kind) {
case "daemonset":
log.Debug().Msgf("Adding pod: %s to daemonSetGroups: %s", v.Name, o.Name)
d.daemonSetGroups[o.Name].Add(d.pods[v.Name])
d.namespaceGroups[namespace].Connect(d.daemonSets[o.Name], d.pods[v.Name])
d.pods[v.Name].Label(o.Name + "-\\n" + strings.TrimPrefix(v.Name, o.Name+"-"))
case "replicaset":
log.Debug().Msgf("Adding pod: %s to replicaSetGroup: %s", v.Name, o.Name)
d.replicaSetGroups[o.Name].Add(d.pods[v.Name])
d.namespaceGroups[namespace].Connect(d.replicaSets[o.Name], d.pods[v.Name])
d.pods[v.Name].Label(d.replicaSets[o.Name].Options.Label + "-\\n" + strings.TrimPrefix(v.Name, o.Name+"-"))
case "statefulset":
log.Debug().Msgf("Adding pod: %s to statefulSetGroups: %s", v.Name, o.Name)
d.statefulSetGroups[o.Name].Add(d.pods[v.Name])
d.namespaceGroups[namespace].Connect(d.statefulSets[o.Name], d.pods[v.Name])
d.pods[v.Name].Label(o.Name + "-\\n" + strings.TrimPrefix(v.Name, o.Name+"-"))
Expand Down Expand Up @@ -174,6 +188,8 @@ func (d *Diagram) GenerateServices(namespace string, services *corev1.ServiceLis
continue
}

log.Debug().Msgf("Generating service: %s", svc.Name)

d.services[svc.Name] = k8s.Network.Svc(
diagram.NodeLabel(svc.Name),
diagram.SetFontOptions(diagram.Font{Size: nodeFontSize}),
Expand Down Expand Up @@ -219,6 +235,8 @@ func (d *Diagram) GenerateIngresses(namespace string, o *networkingv1.IngressLis
continue
}

log.Debug().Msgf("Generating ingress: %s", ing.Name)

d.ingresses[ing.Name] = k8s.Network.Ing(
diagram.NodeLabel(ing.Name),
diagram.SetFontOptions(diagram.Font{Size: nodeFontSize}),
Expand Down

0 comments on commit 1ed7c83

Please sign in to comment.