Update gophercloud: Remove v1/appiversions

Using OpenStack service catalog to do version detection
This commit is contained in:
FengyunPan
2017-09-26 23:16:34 +08:00
parent b35aa85560
commit 5f056f007a
8 changed files with 1 additions and 324 deletions

View File

@@ -29,7 +29,6 @@ filegroup(
name = "all-srcs",
srcs = [
":package-srcs",
"//vendor/github.com/gophercloud/gophercloud/openstack/blockstorage/v1/apiversions:all-srcs",
"//vendor/github.com/gophercloud/gophercloud/openstack/blockstorage/v1/volumes:all-srcs",
"//vendor/github.com/gophercloud/gophercloud/openstack/blockstorage/v2/volumes:all-srcs",
"//vendor/github.com/gophercloud/gophercloud/openstack/common/extensions:all-srcs",

View File

@@ -1,30 +0,0 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")
go_library(
name = "go_default_library",
srcs = [
"doc.go",
"requests.go",
"results.go",
"urls.go",
],
visibility = ["//visibility:public"],
deps = [
"//vendor/github.com/gophercloud/gophercloud:go_default_library",
"//vendor/github.com/gophercloud/gophercloud/pagination:go_default_library",
],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)

View File

@@ -1,3 +0,0 @@
// Package apiversions provides information and interaction with the different
// API versions for the OpenStack Block Storage service, code-named Cinder.
package apiversions

View File

@@ -1,20 +0,0 @@
package apiversions
import (
"github.com/gophercloud/gophercloud"
"github.com/gophercloud/gophercloud/pagination"
)
// List lists all the Cinder API versions available to end-users.
func List(c *gophercloud.ServiceClient) pagination.Pager {
return pagination.NewPager(c, listURL(c), func(r pagination.PageResult) pagination.Page {
return APIVersionPage{pagination.SinglePageBase(r)}
})
}
// Get will retrieve the volume type with the provided ID. To extract the volume
// type from the result, call the Extract method on the GetResult.
func Get(client *gophercloud.ServiceClient, v string) (r GetResult) {
_, r.Err = client.Get(getURL(client, v), &r.Body, nil)
return
}

View File

@@ -1,49 +0,0 @@
package apiversions
import (
"github.com/gophercloud/gophercloud"
"github.com/gophercloud/gophercloud/pagination"
)
// APIVersion represents an API version for Cinder.
type APIVersion struct {
ID string `json:"id"` // unique identifier
Status string `json:"status"` // current status
Updated string `json:"updated"` // date last updated
}
// APIVersionPage is the page returned by a pager when traversing over a
// collection of API versions.
type APIVersionPage struct {
pagination.SinglePageBase
}
// IsEmpty checks whether an APIVersionPage struct is empty.
func (r APIVersionPage) IsEmpty() (bool, error) {
is, err := ExtractAPIVersions(r)
return len(is) == 0, err
}
// ExtractAPIVersions takes a collection page, extracts all of the elements,
// and returns them a slice of APIVersion structs. It is effectively a cast.
func ExtractAPIVersions(r pagination.Page) ([]APIVersion, error) {
var s struct {
Versions []APIVersion `json:"versions"`
}
err := (r.(APIVersionPage)).ExtractInto(&s)
return s.Versions, err
}
// GetResult represents the result of a get operation.
type GetResult struct {
gophercloud.Result
}
// Extract is a function that accepts a result and extracts an API version resource.
func (r GetResult) Extract() (*APIVersion, error) {
var s struct {
Version *APIVersion `json:"version"`
}
err := r.ExtractInto(&s)
return s.Version, err
}

View File

@@ -1,18 +0,0 @@
package apiversions
import (
"net/url"
"strings"
"github.com/gophercloud/gophercloud"
)
func getURL(c *gophercloud.ServiceClient, version string) string {
return c.ServiceURL(strings.TrimRight(version, "/") + "/")
}
func listURL(c *gophercloud.ServiceClient) string {
u, _ := url.Parse(c.ServiceURL(""))
u.Path = "/"
return u.String()
}