pkg/ cmd/: kgctl autodetect mesh granularity#197
Conversation
3a1d492 to
0470794
Compare
30f4835 to
413a465
Compare
| // 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.
| return errors.New("failed to optain granularity: could not get any nodes") | |
| return errors.New("failed to obtain granularity: could not get any nodes") |
| 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.
| // Optain the Granularity by looking at the annotation of the first node. | |
| // Obtain the Granularity by looking at the annotation of the first node. |
| 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.
| // Optain the Granularity by looking at the annotation of the first node. | |
| // Obtain the Granularity by looking at the annotation of the first node. |
| // 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.
| return errors.New("failed to optain granularity: could not get any nodes") | |
| return errors.New("failed to obtain granularity: could not get any nodes") |
| case mesh.LogicalGranularity: | ||
| case mesh.FullGranularity: | ||
| default: | ||
| return fmt.Errorf("mesh granularity %v unsupported", opts.granularity) |
There was a problem hiding this comment.
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
| 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.
| // Optain the Granularity by looking at the annotation of the first node. | |
| // Obtain the Granularity by looking at the annotation of the first node. |
| // 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.
| return errors.New("failed to optain granularity: could not get any nodes") | |
| return errors.New("failed to obtain granularity: could not get any nodes") |
| 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.
How about we turn this block into a helper since we seem to have the same logic repeated 3 times?
squat
left a comment
There was a problem hiding this comment.
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
kubectlSigned-off-by: leonnicolas leonloechner@gmx.de