-
Notifications
You must be signed in to change notification settings - Fork 510
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
Clustering policytype list #860
Clustering policytype list #860
Conversation
Build succeeded.
|
@jtopjian: Requesting code review. I'm working with JackKuei on implementing the senlin APIs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dkt26111 Thanks for this!
Overall this is really good. There are a handful of small nits that I wouldn't consider blocking (just things to clean up in the next PR).
However, one thing I'm curious about is if this is applicable here:
If so, then it looks like this API call supports options for listing (limit, marker, sort, etc). Can you verify if this is true (I'm setting up a Senlin and Zaqar environment to help you folks out with validating these PRs but I'm running blind at the moment).
If list options are a thing, we'll want to add proper support for ListOpts
. A simple example of how to implement that is here:
gophercloud/openstack/identity/v2/tenants/requests.go
Lines 8 to 30 in 7e3b870
// ListOpts filters the Tenants that are returned by the List call. | |
type ListOpts struct { | |
// Marker is the ID of the last Tenant on the previous page. | |
Marker string `q:"marker"` | |
// Limit specifies the page size. | |
Limit int `q:"limit"` | |
} | |
// List enumerates the Tenants to which the current token has access. | |
func List(client *gophercloud.ServiceClient, opts *ListOpts) pagination.Pager { | |
url := listURL(client) | |
if opts != nil { | |
q, err := gophercloud.BuildQueryString(opts) | |
if err != nil { | |
return pagination.Pager{Err: err} | |
} | |
url += q.String() | |
} | |
return pagination.NewPager(client, url, func(r pagination.PageResult) pagination.Page { | |
return TenantPage{pagination.LinkedPageBase{PageResult: r}} | |
}) | |
} |
gophercloud/openstack/identity/v2/tenants/results.go
Lines 23 to 44 in 7e3b870
// TenantPage is a single page of Tenant results. | |
type TenantPage struct { | |
pagination.LinkedPageBase | |
} | |
// IsEmpty determines whether or not a page of Tenants contains any results. | |
func (r TenantPage) IsEmpty() (bool, error) { | |
tenants, err := ExtractTenants(r) | |
return len(tenants) == 0, err | |
} | |
// NextPageURL extracts the "next" link from the tenants_links section of the result. | |
func (r TenantPage) NextPageURL() (string, error) { | |
var s struct { | |
Links []gophercloud.Link `json:"tenants_links"` | |
} | |
err := r.ExtractInto(&s) | |
if err != nil { | |
return "", err | |
} | |
return gophercloud.ExtractNextURL(s.Links) | |
} |
SupportStatus map[string][]SupportStatusType `json:"support_status,omitempty"` | ||
} | ||
|
||
// SupportStatus represents the support status information for a clustering policy type |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SupportStatusType?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, you are correct. I will fix this.
import "github.com/gophercloud/gophercloud" | ||
|
||
var apiVersion = "v1" | ||
var apiName = "policy-types" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: these could be constants:
const (
apiVersion = "v1"
apiName = "policy-types"
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree. I'll fix it.
type PolicyType struct { | ||
Name string `json:"name"` | ||
Version string `json:"version"` | ||
SupportStatus map[string][]SupportStatusType `json:"support_status,omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: omitempty
isn't really needed here - it's only useful in requests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll fix that too.
@dkt26111 whoops - actually, my mistake. I was looking at policy list and not policy type list :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If everything looks good to you in the latest commits, you can go ahead and merge it. I will work with Jackkuei to rebase #824 . |
Build succeeded.
|
@dkt26111 All looks good! Really nice work on this. A note on microversions: we haven't figured out a good way of handling them in Gophercloud yet. Basic microversion stuff like what you're testing here is totally fine. However if there will be times when, for example, a version 1.5 request or response body is different than a 1.0 request/body (meaning the struct fields are different and/or incompatible), this is the area we're still looking into. We can discuss different options if we get into that situation with Senlin. |
* Clustering PolicyType list implementation * ran gofmt * fix policytype list example * add policytype list acceptance test * remove admin required * Fix review comments * add acceptance test for microversion 1.5 * Fix wrong method name
For #823
Links to the line numbers/files in the OpenStack source code that support the
code in this PR:
API doc:
https://developer.openstack.org/api-ref/clustering/#list-policy-types
API code:
https://github.com/openstack/senlin/blob/master/senlin/api/openstack/v1/policy_types.py#L30