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

feature: add network ls command #642

Merged
merged 1 commit into from
Jan 29, 2018
Merged

feature: add network ls command #642

merged 1 commit into from
Jan 29, 2018

Conversation

ZouRui89
Copy link
Contributor

@ZouRui89 ZouRui89 commented Jan 25, 2018

Signed-off-by: Zou Rui [email protected]

1.Describe what this PR did
add network ls implementation on API side
2.Does this pull request fix one issue?

NONE
3.Describe how you did it

4.Describe how to verify it

$ pouch network ls
NETWORK ID        NAME     DRIVE    SCOPE
6f7aba8a58        net2     bridge
55f134176c        net3     bridge
e495f50913        net1     bridge

5.Special notes for reviews

apis/swagger.yml Outdated
- `id=<network-id>` Matches all or part of a network ID.
- `label=<key>` or `label=<key>=<value>` of a network label.
- `name=<network-name>` Matches all or part of a network name.
- `scope=["swarm"|"global"|"local"]` Filters networks by scope (`swarm`, `global`, or `local`).
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please remove all these filter things, since we do not use them in a quite long time.

@allencloud
Copy link
Collaborator

Ci fails:

# github.com/alibaba/pouch/apis/server
apis/server/network_bridge.go:48:80: cannot use name (type *"github.com/alibaba/pouch/network/types".Network) as type string in field value
make: *** [server] Error 2
Makefile:23: recipe for target 'server' failed
make: *** [test] Error 2

@codecov-io
Copy link

codecov-io commented Jan 25, 2018

Codecov Report

Merging #642 into master will decrease coverage by 0.18%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #642      +/-   ##
==========================================
- Coverage   14.21%   14.02%   -0.19%     
==========================================
  Files          65       65              
  Lines        3736     3786      +50     
==========================================
  Hits          531      531              
- Misses       3159     3209      +50     
  Partials       46       46
Impacted Files Coverage Δ
cli/network.go 0% <0%> (ø) ⬆️
client/network.go 0% <0%> (ø) ⬆️
daemon/mgr/network.go 0% <0%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9b769f7...1d24e27. Read the comment docs.

@allencloud allencloud added this to the v0.2-milestone milestone Jan 25, 2018
apis/swagger.yml Outdated
schema:
type: "array"
items:
$ref: "#/definitions/NetworkListResp"
Copy link
Collaborator

Choose a reason for hiding this comment

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

I do not think this correct. Since in code you returned respNetworks := types.NetworkListResp{Networks: []*types.NetworkInfo{}, Warnings: nil}. But here you returned []types.NetworkListResp. They are not the same.

You have already defined Networks in NetworkListResp as an array. So you do not need to make this api to return an array of NetworkListResp. This is not correct, to be honest. @ZouRui89

@allencloud allencloud changed the title feature: add network ls implementation on API side: feature: add network ls implementation on API side Jan 26, 2018
@ZouRui89 ZouRui89 changed the title feature: add network ls implementation on API side feature: add network ls implementation Jan 26, 2018
@rudyfly
Copy link
Collaborator

rudyfly commented Jan 26, 2018

please merge two commits.

@ZouRui89 ZouRui89 changed the title feature: add network ls implementation feature: add network ls command Jan 26, 2018
Copy link
Collaborator

@rudyfly rudyfly left a comment

Choose a reason for hiding this comment

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

Exciting feature what I need.

cli/network.go Outdated

// networkListExample shows examples in network list command, and is used in auto-generated cli docs.
func networkListExample() string {
return ``
Copy link
Collaborator

Choose a reason for hiding this comment

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

add example.

respNetworks.Networks = append(respNetworks.Networks, &types.NetworkInfo{
Name: net.Name,
ID: net.ID,
})
Copy link
Collaborator

Choose a reason for hiding this comment

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

Network driver is necessary.

cli/network.go Outdated
n.cli = c

n.cmd = &cobra.Command{
Use: "list [OPTIONS] [NAME]",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please remove [OPTIONS] [NAME], since you specified no flag and no args is accpeted.

path = "/networks"
resp, err = request.Get(path)
c.Assert(err, check.IsNil)
c.Assert(resp.StatusCode, check.Equals, 200)
Copy link
Contributor

Choose a reason for hiding this comment

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

Could also verify the Name, Driver field.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is test for list API, not inspect API. So maybe we add this in inspect API.

@ZouRui89
Copy link
Contributor Author

Updated @allencloud

cli/network.go Outdated
display.AddRow([]string{"NETWORK ID", "NAME", "DRIVER", "SCOPE"})
for _, network := range resp.Networks {
display.AddRow([]string{
network.ID,
Copy link
Collaborator

Choose a reason for hiding this comment

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

change the id to short id is better?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think short ID is better, since the original ones is too long. And it may make output in cli not so readable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree with you two.

@rudyfly
Copy link
Collaborator

rudyfly commented Jan 29, 2018

LGTM

@pouchrobot pouchrobot added the LGTM one maintainer or community participant agrees to merge the pull reuqest. label Jan 29, 2018
@rudyfly rudyfly merged commit 24e3f35 into AliyunContainerService:master Jan 29, 2018
tiny1990 added a commit to tiny1990/pouch that referenced this pull request Jan 30, 2018
feature: add network ls implementation on API side: (AliyunContainerService#642)
@ZouRui89 ZouRui89 deleted the net_ls branch January 30, 2018 02:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
areas/cli areas/network kind/feature LGTM one maintainer or community participant agrees to merge the pull reuqest. size/XL
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants