Skip to content
This repository was archived by the owner on Aug 15, 2022. It is now read-only.

Machine mount - add mount list handler to machine group - #10382

Merged
ppknap merged 6 commits into
masterfrom
machine_mount_machinegroup_list
Jan 26, 2017
Merged

Machine mount - add mount list handler to machine group#10382
ppknap merged 6 commits into
masterfrom
machine_mount_machinegroup_list

Conversation

@ppknap

@ppknap ppknap commented Jan 21, 2017

Copy link
Copy Markdown
Contributor

Depends on: #10377

Code coverage: 51.3% of statements

How Has This Been Tested?

Unit tests.

Screenshots (if appropriate):

none

Types of changes

  • New feature (non-breaking change which adds functionality)

type ListMountRequest struct {
// ID is an optional identifier for the remote machine. If set, only
// mounts related to this machine will be returned.
ID machine.ID `json:"id"`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

,omitempty

ID machine.ID `json:"id"`

// MountID is an optional identifier of a mount which is meant to be listed.
MountID mount.ID `json:"mountID"`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ditto

if req.ID != "" {
mounts, err := g.mount.All(req.ID)
if err != nil {
return res, nil

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why the early return here? Shouldn't we try req.MountID as well? If req.ID and req.MountID are exclusive, then some check is missing.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If an empty mount from L205 is eliminated then indeed we could early return here.


mms = map[mount.ID]mountsMachine{
req.MountID: mountsMachine{m: m, id: id},
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If g.mount.All failed we'd be adding an empty mount here.

@ppknap
ppknap force-pushed the machine_mount_machinegroup_list branch from dc8e979 to cee851e Compare January 25, 2017 06:37
// ListMount checks the status of mounts and returns their infos. This function
// guarantees that if returned error is nil, response Mounts field is always
// non-nil. It doesn't fail if provided filters contain incorrect values.
func (g *Group) ListMount(req *ListMountRequest) (*ListMountResponse, error) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

could you separate this function into smaller logical parts?, it is hard ( for me ) to follow it


for name, test := range tests {
t.Run(name, func(t *testing.T) {
listMountRes, err := g.ListMount(&test.LMReq)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

could you add t.Parallel here?

@ppknap
ppknap force-pushed the machine_mount_machinegroup_list branch from cf7633e to 0c1c248 Compare January 26, 2017 01:37
@ppknap

ppknap commented Jan 26, 2017

Copy link
Copy Markdown
Contributor Author

@cihangir I'm merging this for now in order to rebase #10383. If you have more change requests, please write them here and I will apply them in next PR.

@ppknap
ppknap merged commit 9e94bb1 into master Jan 26, 2017
@szkl
szkl deleted the machine_mount_machinegroup_list branch January 26, 2017 02:31
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants