Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multi namespace #26

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

simon-feamzy
Copy link

this modification allows digram generation for many namespace.

@mkimuram
Copy link
Owner

mkimuram commented Apr 2, 2021

@simon-feamzy

Thank you for sending PR.
Your idea for supporting multiple namespaces sounds nice. Good work!

I think that you are trying to add below three features in the one PR:

  1. Supporting multiple namespace
  2. Supporting CronJob
  3. Adding Google-cloud-sdk

Could you separate this PR into 3 PRs?

Quick feedback for each feature is as below:

  1. Supporting multiple namespace
    Can we handle below two use cases in a different ways?

    1. Creating one file per one namespace: Just run the command multiple times for one namespace.
    2. Creating one merged file for all specified namespace: Just generate one merged file in the go code.

    Then, we just need to modify -n option to take namespaces via a string array and loop over the namespaces to add each to a single graph.

  2. Supporting CronJob
    Current codes looks good to me, so it will be able to merge once you separate the PR and add test codes for it.

  3. Adding Google-cloud-sdk
    I didn't get why it is needed. Let's discuss from the use cases.

@mkimuram
Copy link
Owner

mkimuram commented Apr 2, 2021

Opened separated issues below. Let's discuss further there. I think that you can continue using this PR for #28 or create new PR.

  1. Supporting multiple namespace
    Feature Request: Add Multiple namespaces Support #28

  2. Supporting CronJob
    Feature Request: Add CronJob Support #27

  3. Adding Google-cloud-sdk
    Discuss whether Google Cloud SDK is need to be bundled #29

Copy link
Owner

@mkimuram mkimuram left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@simon-feamzy

These are just my ideas. You can continue sending separate PRs without modifying them.
Let's discuss further once PR is separated.

@@ -1,4 +1,4 @@
IMAGE ?= mkimuram/k8sviz
IMAGE ?= sguerard/k8sviz
TAG ?= 0.3
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, you don't need to modify Makefile. Instead, Just call below:

IMAGE=guerard/k8sviz make image-build

if outType == "dot" {
if err := g.WriteDotFile(outFile); err != nil {
fmt.Fprintf(os.Stderr, "Failed to output %q file with format %q for namespace %q: %v\n", outFile, outType, namespace, err)
words := strings.Split(namespace, ",")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To parse comma separated strings to a slice of string, https://golang.org/src/flag/example_test.go might be a good reference.

fmt.Fprintf(os.Stderr, "Failed to output %q file with format %q for namespace %q: %v\n", outFile, outType, namespace, err)
os.Exit(1)

g := graph.NewGraph(res, dir)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's make NewGraph take a slice of resources and handle single name case and multiple namespaces case in the same way.

fmt.Fprintf(os.Stderr, "Failed to get namespace %q: %v\n", namespace, err)
os.Exit(1)
}
//if !strings.Contains(namespace,",") {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If namespaces are parsed into the slice(see below), we will be able to check for all the namespaces here.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By "below", I meant this comment. It appeared above this comment :)

@@ -125,15 +123,15 @@ func (g *Graph) generateCommon() {
if err != nil {
fmt.Fprintf(os.Stderr, "Failed to set to digraph: %v\n", err)
}
err = g.gviz.SetName("G")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep top level graph "G" and add multiple subgraphs for each namespace inside it.

@xeruf
Copy link

xeruf commented Jan 13, 2024

hey, any chance to get this into production? would love it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants