-
Notifications
You must be signed in to change notification settings - Fork 130
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
pkg/ cmd/: kgctl autodetect mesh granularity #197
Conversation
3a1d492
to
0470794
Compare
30f4835
to
413a465
Compare
cmd/kgctl/graph.go
Outdated
// Optain the Granularity by looking at the annotation of the first node. | ||
if opts.granularity == mesh.AutoGranularity { | ||
if len(ns) == 0 { | ||
return errors.New("failed to optain granularity: could not get any nodes") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return errors.New("failed to optain granularity: could not get any nodes") | |
return errors.New("failed to obtain granularity: could not get any nodes") |
cmd/kgctl/graph.go
Outdated
@@ -38,6 +39,20 @@ func runGraph(_ *cobra.Command, _ []string) error { | |||
if err != nil { | |||
return fmt.Errorf("failed to list peers: %v", err) | |||
} | |||
// Optain the Granularity by looking at the annotation of the first node. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Optain the Granularity by looking at the annotation of the first node. | |
// Obtain the Granularity by looking at the annotation of the first node. |
cmd/kgctl/showconf.go
Outdated
@@ -121,6 +121,19 @@ func runShowConfNode(_ *cobra.Command, args []string) error { | |||
if err != nil { | |||
return fmt.Errorf("failed to list peers: %v", err) | |||
} | |||
// Optain the Granularity by looking at the annotation of the first node. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Optain the Granularity by looking at the annotation of the first node. | |
// Obtain the Granularity by looking at the annotation of the first node. |
cmd/kgctl/showconf.go
Outdated
// Optain the Granularity by looking at the annotation of the first node. | ||
if opts.granularity == mesh.AutoGranularity { | ||
if len(ns) == 0 { | ||
return errors.New("failed to optain granularity: could not get any nodes") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return errors.New("failed to optain granularity: could not get any nodes") | |
return errors.New("failed to obtain granularity: could not get any nodes") |
cmd/kgctl/showconf.go
Outdated
case mesh.LogicalGranularity: | ||
case mesh.FullGranularity: | ||
default: | ||
return fmt.Errorf("mesh granularity %v unsupported", opts.granularity) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we can make this a more complete phrase?
return fmt.Errorf("mesh granularity %v unsupported", opts.granularity) | |
return fmt.Errorf("mesh granularity %q is not supported", opts.granularity) |
and same above and below.
Also, I think it's nice to quote the values that produce the error to show that it is something funny that came from the user
cmd/kgctl/showconf.go
Outdated
@@ -208,6 +221,19 @@ func runShowConfPeer(_ *cobra.Command, args []string) error { | |||
if err != nil { | |||
return fmt.Errorf("failed to list peers: %v", err) | |||
} | |||
// Optain the Granularity by looking at the annotation of the first node. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Optain the Granularity by looking at the annotation of the first node. | |
// Obtain the Granularity by looking at the annotation of the first node. |
cmd/kgctl/showconf.go
Outdated
// Optain the Granularity by looking at the annotation of the first node. | ||
if opts.granularity == mesh.AutoGranularity { | ||
if len(ns) == 0 { | ||
return errors.New("failed to optain granularity: could not get any nodes") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return errors.New("failed to optain granularity: could not get any nodes") | |
return errors.New("failed to obtain granularity: could not get any nodes") |
cmd/kgctl/graph.go
Outdated
@@ -38,6 +39,20 @@ func runGraph(_ *cobra.Command, _ []string) error { | |||
if err != nil { | |||
return fmt.Errorf("failed to list peers: %v", err) | |||
} | |||
// Optain the Granularity by looking at the annotation of the first node. | |||
if opts.granularity == mesh.AutoGranularity { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about we turn this block into a helper since we seem to have the same logic repeated 3 times?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice I like this idea. I think that in the future, we could stick all of these annotations that report a status, vs the ones that are declarative, into a json struct in a kilo.squat.ai/status
annotation. I think this could be clearer for the user and would avoid people thinking they can edit the annotations
413a465
to
4584f01
Compare
Addes granularity annotation to auto detect the mesh granularity when using kubectl Signed-off-by: leonnicolas <leonloechner@gmx.de>
4584f01
to
088578b
Compare
Addes granularity annotation to auto detect the mesh granularity when
using
kubectl
Signed-off-by: leonnicolas leonloechner@gmx.de