Conversation
64984b9 to
f71555b
Compare
fbec789 to
3708c30
Compare
aed4596 to
8d57167
Compare
ef97c0e to
6789276
Compare
There was a problem hiding this comment.
Can you please invoke make charts to also regenerate the Helm Chart incl. this CRD.
| if string(b) != "[null]" { | ||
|
|
||
| // Due to some Cisco IOSX ouptut we also match [ \n null \n] | ||
| nullTypeRe := regexp.MustCompile(`^\[\s*null\s*]$`) |
There was a problem hiding this comment.
nit: can you move this variable outside of the function, so that we don't recreated this regexp instance on every function call?
| EtherBundle IFaceSpeed = "etherbundle" | ||
| ) | ||
|
|
||
| type BunldePortActivity string |
| StateShutDown PhysIfStateType = "im-state-shutdown" | ||
| ) | ||
|
|
||
| // Represent physical and bundle interfaces as part of the same struct as they share a lot of common configuration |
There was a problem hiding this comment.
| // Represent physical and bundle interfaces as part of the same struct as they share a lot of common configuration | |
| // Iface represents physical and bundle interfaces as part of the same struct as they share a lot of common configuration |
Type comments should start with the type name.
| } | ||
| if string(b) != "[null]" { | ||
|
|
||
| // Due to some Cisco IOSX ouptut we also match [ \n null \n] |
There was a problem hiding this comment.
| // Due to some Cisco IOSX ouptut we also match [ \n null \n] | |
| // Due to some Cisco IOS-XR output we also match [ \n null \n] |
| func (m *MockClient) Create(ctx context.Context, conf ...gnmiext.Configurable) error { | ||
| return nil | ||
| } | ||
|
|
There was a problem hiding this comment.
I think this was left by mistake and should be removed.
internal/util/ip.go
Outdated
There was a problem hiding this comment.
Please don't introduce a util package for reasons explained in the Google Go Styleguide 1.
At the same time, as both functions are pretty simple and could be just oneline statements, I would just inline them in the only place they are currently used.
Footnotes
-
https://google.github.io/styleguide/go/decisions#naming:~:text=Avoid%20uninformative%20package%20names%20like%20util%2C%20utility%2C%20common%2C%20helper%2C%20model%2C%20testhelper%2C%20and%20so%20on%20that%20would%20tempt%20users%20of%20the%20package%20to%20rename%20it%20when%20importing%2E%20See. ↩
3af44d9 to
6b3940f
Compare
f8c1dcc to
cda5b26
Compare
|
|
||
| err = c.GetConfig(ctx, got) | ||
| if err != nil && !errors.Is(err, ErrNil) { | ||
| return fmt.Errorf("gnmiext: failed to retrieve current config for %s: %w", cf.XPath(), err) | ||
| } | ||
| // If the current configuration is equal to the desired configuration, skip the update. | ||
| // This avoids unnecessary updates and potential disruptions. | ||
| if err == nil && reflect.DeepEqual(cf, got) { | ||
| c.logger.V(1).Info("Configuration is already up-to-date", "path", cf.XPath()) | ||
| continue | ||
|
|
||
| // If the current configuration does not exist, continue to set the desired configuration. | ||
| if status.Code(err) != codes.NotFound { | ||
| if err != nil && !errors.Is(err, ErrNil) { | ||
| return fmt.Errorf("gnmiext: failed to retrieve current config for %s: %w", cf.XPath(), err) | ||
| } | ||
| // If the current configuration is equal to the desired configuration, skip the update. | ||
| // This avoids unnecessary updates and potential disruptions. | ||
| if err == nil && reflect.DeepEqual(cf, got) { | ||
| c.logger.V(1).Info("Configuration is already up-to-date", "path", cf.XPath()) | ||
| continue | ||
| } | ||
| } | ||
|
|
There was a problem hiding this comment.
| err = c.GetConfig(ctx, got) | |
| if err != nil && !errors.Is(err, ErrNil) { | |
| return fmt.Errorf("gnmiext: failed to retrieve current config for %s: %w", cf.XPath(), err) | |
| } | |
| // If the current configuration is equal to the desired configuration, skip the update. | |
| // This avoids unnecessary updates and potential disruptions. | |
| if err == nil && reflect.DeepEqual(cf, got) { | |
| c.logger.V(1).Info("Configuration is already up-to-date", "path", cf.XPath()) | |
| continue | |
| // If the current configuration does not exist, continue to set the desired configuration. | |
| if status.Code(err) != codes.NotFound { | |
| if err != nil && !errors.Is(err, ErrNil) { | |
| return fmt.Errorf("gnmiext: failed to retrieve current config for %s: %w", cf.XPath(), err) | |
| } | |
| // If the current configuration is equal to the desired configuration, skip the update. | |
| // This avoids unnecessary updates and potential disruptions. | |
| if err == nil && reflect.DeepEqual(cf, got) { | |
| c.logger.V(1).Info("Configuration is already up-to-date", "path", cf.XPath()) | |
| continue | |
| } | |
| } | |
| err = c.GetConfig(ctx, got) | |
| if err != nil && !errors.Is(err, ErrNil) && status.Code(err) != codes.NotFound { | |
| return fmt.Errorf("gnmiext: failed to retrieve current config for %s: %w", cf.XPath(), err) | |
| } | |
| // If the current configuration is equal to the desired configuration, skip the update. | |
| // This avoids unnecessary updates and potential disruptions. | |
| if err == nil && reflect.DeepEqual(cf, got) { | |
| c.logger.V(1).Info("Configuration is already up-to-date", "path", cf.XPath()) | |
| continue | |
| } |
why not just add status.Code(err) != codes.NotFound to the existing if case?
There was a problem hiding this comment.
If i remember correctly, I wanted to skip the DeepEqual, but your suggestions improves code readability, which I like. So I am going with that.
0986b0b to
597e61c
Compare
In Cisco IOS XR the yang empty type is not implemented correctly for bundle-interfaces. Instead of returning "[null]" as defined in the RFC, "[\n null \n]" is. We simply work around of this.
For Bundle- and Bundlesubinterfaces creation fails, as the gnmi Update/Patch call, checks whether the object exists or not. We skip this check once if the gnmi call returns a NotFound error code.
597e61c to
274259e
Compare
274259e to
1f094cd
Compare
Merging this branch will increase overall coverage
Coverage by fileChanged files (no unit tests)
Please note that the "Total", "Covered", and "Missed" counts above refer to code statements instead of lines of code. The value in brackets refers to the test coverage of that file in the old version of the code. Changed unit test files
|
No description provided.