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

Gnocchi: implement resource types List method #55

Merged
merged 3 commits into from
Jun 28, 2018

Conversation

ozerovandrei
Copy link
Contributor

@ozerovandrei ozerovandrei mentioned this pull request Jun 16, 2018
5 tasks
Add new resourcetypes package with List method.
Add tests and a documentation example.
@ozerovandrei ozerovandrei force-pushed the gnocchi-resource-type-list branch from e497b0f to 03a74c8 Compare June 16, 2018 18:10
Copy link
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.

@ozerovandrei I apologize for the delay.

I've left one inline comment. In addition, I think the Attribute type might need some changes. According to the REST API docs there are a set amount of "types": string, bool, number, etc. This is reflected in the code, too:

Each type can have different attributes. For example, a "number" type has min and max but a "string" does not.

I wonder if it would be best to model Attribute like:

type Attribute {
  Type string
  Required bool
  Extra map[string]interface{}
}

Thoughts?

}

// ResourceTypeAttribute represents single attribute of a Gnocchi resource type.
type ResourceTypeAttribute struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we call this Attribute?

@ozerovandrei
Copy link
Contributor Author

@jtopjian Hello.
Attribute was tricky. I haven't started implementing another PR for the #54, because I haven't been sure about current implementation.
Will try to change it according to your request.

@jtopjian
Copy link
Contributor

Sounds good. Another option is to leave Attribute as a generic map[string]interface{}. I guess it depends on if the attributes will be usable or just for informational purposes.

Rename resource type attributes to Attributes struct, use cutom field
"Extra" with map[string]interface{} type instead of different fields.
Those fields will be different for different attribute types.
@ozerovandrei
Copy link
Contributor Author

@jtopjian I made changes related to Attribute field. I think that it's better to have at least Name and Type as separate fields inside the structure because they're common between all attribute types.

@jtopjian
Copy link
Contributor

@ozerovandrei This still felt a little strange to me and then I realized it is because we're trying to convert a map of values into an array.

How about something like this: jtopjian@89b3bbb

@ozerovandrei
Copy link
Contributor Author

@jtopjian it's because I've tried to do a very strong structure types without any maps from the beginning of that PR. Some Go developer told me to so so once: #issuecomment-362023884 😉

But yeah, I can change this, why not.

@jtopjian
Copy link
Contributor

That discussion is still applicable. :)

What I'm proposing is modeling the data in its normal map/object/hash/dict form and not coalescing it into an array/list/slice.

Migrate from list to map representation for the attribute details to
make it more similar to the actual Gnocchi response JSON.
@ozerovandrei
Copy link
Contributor Author

@jtopjian I thought about it and I think that your variant is better, because it looks more similar to actual Gnocchi response structure.
I've applied those changes.

Copy link
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!

@jtopjian
Copy link
Contributor

@ozerovandrei Just to confirm: you're finished with this and it's mergeable?

@ozerovandrei
Copy link
Contributor Author

@jtopjian yes, it is ready.

@jtopjian jtopjian merged commit d7844b1 into gophercloud:master Jun 28, 2018
@ozerovandrei ozerovandrei deleted the gnocchi-resource-type-list branch June 28, 2018 06:49
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.

2 participants