Skip to content

List instance actions#1848

Merged
jtopjian merged 1 commit intogophercloud:masterfrom
ovh:listInstanceActions
Feb 13, 2020
Merged

List instance actions#1848
jtopjian merged 1 commit intogophercloud:masterfrom
ovh:listInstanceActions

Conversation

@snigle
Copy link
Copy Markdown
Contributor

@snigle snigle commented Feb 12, 2020

@coveralls
Copy link
Copy Markdown

coveralls commented Feb 12, 2020

Coverage Status

Coverage increased (+0.04%) to 77.09% when pulling b43ad7f on ovh:listInstanceActions into 9fb9244 on gophercloud:master.

@theopenlab-ci
Copy link
Copy Markdown

theopenlab-ci bot commented Feb 12, 2020

Build succeeded.

Copy link
Copy Markdown
Contributor

@jtopjian jtopjian left a comment

Choose a reason for hiding this comment

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

@snigle Really nice work on this. I've left a few comments. Most of them are simple renaming because this is now in a dedicated package.

Please let me know if you have any questions.

)

// ListInstanceActions makes a request against the API to list the servers actions.
func ListInstanceActions(client *gophercloud.ServiceClient, id string) pagination.Pager {
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.

Since this is under its own package (instanceactions), we can rename this to just List.

}

// ListInstanceActions makes a request against the API to get a server action.
func GetInstanceAction(client *gophercloud.ServiceClient, serverID, requestID string) (r InstanceActionResult) {
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.

Similarly, Get.

Message *string `json:"message"`
ProjectID string `json:"project_id"`
RequestID string `json:"request_id"`
StartTime time.Time `json:"start_time"`
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.

The JSON tag should be -:

	StartTime    time.Time `json:"-"`

This will resolve the Travis error, too.


// ExtractInstanceAction interprets the results of a single page from a
// GetInstanceActiones() call, producing a map of instanceAction.
func ExtractInstanceAction(r pagination.Page) (InstanceAction, 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.

I think this function can safely be removed.


// ExtractInstanceActions interprets the results of a single page from a
// ListInstanceActiones() call, producing a map of instanceActions.
func ExtractInstanceActions(r pagination.Page) ([]InstanceAction, 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.

Even though we're renaming some of the other functions (for example, ListInstanceActions to List), this function stays ExtractInstanceActions. It's just weird naming pattern of Gophercloud.

type InstanceAction struct {
Action string `json:"action"`
InstanceUUID string `json:"instance_uuid"`
Message *string `json:"message"`
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.

Having this as *string will cause the value to be nil if there is no message. Is there a reason to do this instead of having an empty value be ""? If there is, I'm OK with keeping this as *string.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It permits to say to the dev that the field be empty.
If it's a pointer is easier for the dev to konw the field is optional and must be checked before used.

@snigle snigle force-pushed the listInstanceActions branch from 70a4f48 to b43ad7f Compare February 13, 2020 09:21
@snigle snigle requested a review from jtopjian February 13, 2020 10:50
@theopenlab-ci
Copy link
Copy Markdown

theopenlab-ci bot commented Feb 13, 2020

Build succeeded.

@snigle
Copy link
Copy Markdown
Contributor Author

snigle commented Feb 13, 2020

Commit of review squashed :
70a4f48

Copy link
Copy Markdown
Contributor

@jtopjian jtopjian left a comment

Choose a reason for hiding this comment

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

LGTM - thank you!

@jtopjian jtopjian merged commit 06e2df9 into gophercloud:master Feb 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants