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

[specific ci=Group1-Docker-Commands] Add support for network labels #4138

Merged
merged 1 commit into from
Mar 7, 2017

Conversation

anchal-agrawal
Copy link
Contributor

Adds support for labels in network create and network inspect. With this change, network ls -f label=... also works as expected.

Fixes #3738

@anchal-agrawal
Copy link
Contributor Author

anchal-agrawal commented Mar 3, 2017

@hmahmood @sflxn The code changes for label support are concentrated in these files:

lib/apiservers/engine/backends/network.go
lib/apiservers/portlayer/restapi/handlers/scopes_handlers.go
lib/portlayer/network/scope.go

The other changes are just a refactor to improve readability by replacing 5+ function input args with one struct containing those fields.

@@ -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{
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed all occurrences. Thanks!

@@ -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) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Make scopeData a pointer.

@anchal-agrawal anchal-agrawal changed the title [specific ci=Group1-Docker-Commands] Add support for network labels [full ci] Add support for network labels Mar 6, 2017
@anchal-agrawal anchal-agrawal changed the title [full ci] Add support for network labels [specific ci=Group1-Docker-Commands] Add support for network labels Mar 6, 2017
Copy link
Contributor

@mhagen-vmware mhagen-vmware left a 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.

  * 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants