-
Notifications
You must be signed in to change notification settings - Fork 173
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
[specific ci=Group1-Docker-Commands] Add support for network labels #4138
[specific ci=Group1-Docker-Commands] Add support for network labels #4138
Conversation
@hmahmood @sflxn The code changes for label support are concentrated in these files:
The other changes are just a refactor to improve readability by replacing 5+ function input args with one struct containing those fields. |
b4326c4
to
d3df9b9
Compare
lib/portlayer/network/context.go
Outdated
@@ -133,7 +137,17 @@ func NewContext(config *Configuration, kv kvstore.KeyValueStore) (*Context, erro | |||
} | |||
|
|||
subnet := net.IPNet{IP: n.Gateway.IP.Mask(n.Gateway.Mask), Mask: n.Gateway.Mask} | |||
s, err := ctx.newScope(n.Type, nn, &subnet, n.Gateway.IP, n.Nameservers, pools) | |||
|
|||
scopeData = ScopeData{ |
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.
This should be a pointer.
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.
Fixed all occurrences. Thanks!
lib/portlayer/network/context.go
Outdated
@@ -310,44 +324,48 @@ func (c *Context) addScope(s *Scope) error { | |||
return nil | |||
} | |||
|
|||
func (c *Context) newScopeCommon(id uid.UID, name, scopeType string, subnet *net.IPNet, gateway net.IP, dns []net.IP, pools []string, network object.NetworkReference) (*Scope, error) { | |||
func (c *Context) newScopeCommon(id uid.UID, scopeType string, network object.NetworkReference, scopeData ScopeData) (*Scope, error) { |
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.
Make scopeData a pointer.
d3df9b9
to
8dcef49
Compare
8dcef49
to
2d2bede
Compare
2d2bede
to
c1fe817
Compare
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.
LGTM, not sure why you pushed test cases down instead of just tacking onto the end, but it is fine.
c1fe817
to
3b59821
Compare
* Adds the 'annotations' field in the portlayer's Scope struct to store user-specified labels for networks. The labels map is base64-encoded on the persona for the portlayer and decoded on the persona while populating network info for network list calls. * Refactors scope creation logic in the portlayer to improve readability. Replaces several func input args with one struct containing all needed fields. * Adds integration tests for creating, filtering and inspecting a network with labels.
3b59821
to
3051ee0
Compare
Adds support for labels in
network create
andnetwork inspect
. With this change,network ls -f label=...
also works as expected.Fixes #3738