Move deps from _workspace/ to vendor/
godep restore pushd $GOPATH/src/github.com/appc/spec git co master popd go get go4.org/errorutil rm -rf Godeps godep save ./... git add vendor git add -f $(git ls-files --other vendor/) git co -- Godeps/LICENSES Godeps/.license_file_state Godeps/OWNERS
This commit is contained in:
7
vendor/github.com/rackspace/gophercloud/openstack/compute/v2/images/doc.go
generated
vendored
Normal file
7
vendor/github.com/rackspace/gophercloud/openstack/compute/v2/images/doc.go
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
// Package images provides information and interaction with the image API
|
||||
// resource in the OpenStack Compute service.
|
||||
//
|
||||
// An image is a collection of files used to create or rebuild a server.
|
||||
// Operators provide a number of pre-built OS images by default. You may also
|
||||
// create custom images from cloud servers you have launched.
|
||||
package images
|
||||
109
vendor/github.com/rackspace/gophercloud/openstack/compute/v2/images/requests.go
generated
vendored
Normal file
109
vendor/github.com/rackspace/gophercloud/openstack/compute/v2/images/requests.go
generated
vendored
Normal file
@@ -0,0 +1,109 @@
|
||||
package images
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/rackspace/gophercloud"
|
||||
"github.com/rackspace/gophercloud/pagination"
|
||||
)
|
||||
|
||||
// ListOptsBuilder allows extensions to add additional parameters to the
|
||||
// List request.
|
||||
type ListOptsBuilder interface {
|
||||
ToImageListQuery() (string, error)
|
||||
}
|
||||
|
||||
// ListOpts contain options for limiting the number of Images returned from a call to ListDetail.
|
||||
type ListOpts struct {
|
||||
// When the image last changed status (in date-time format).
|
||||
ChangesSince string `q:"changes-since"`
|
||||
// The number of Images to return.
|
||||
Limit int `q:"limit"`
|
||||
// UUID of the Image at which to set a marker.
|
||||
Marker string `q:"marker"`
|
||||
// The name of the Image.
|
||||
Name string `q:"name"`
|
||||
// The name of the Server (in URL format).
|
||||
Server string `q:"server"`
|
||||
// The current status of the Image.
|
||||
Status string `q:"status"`
|
||||
// The value of the type of image (e.g. BASE, SERVER, ALL)
|
||||
Type string `q:"type"`
|
||||
}
|
||||
|
||||
// ToImageListQuery formats a ListOpts into a query string.
|
||||
func (opts ListOpts) ToImageListQuery() (string, error) {
|
||||
q, err := gophercloud.BuildQueryString(opts)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return q.String(), nil
|
||||
}
|
||||
|
||||
// ListDetail enumerates the available images.
|
||||
func ListDetail(client *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager {
|
||||
url := listDetailURL(client)
|
||||
if opts != nil {
|
||||
query, err := opts.ToImageListQuery()
|
||||
if err != nil {
|
||||
return pagination.Pager{Err: err}
|
||||
}
|
||||
url += query
|
||||
}
|
||||
|
||||
createPage := func(r pagination.PageResult) pagination.Page {
|
||||
return ImagePage{pagination.LinkedPageBase{PageResult: r}}
|
||||
}
|
||||
|
||||
return pagination.NewPager(client, url, createPage)
|
||||
}
|
||||
|
||||
// Get acquires additional detail about a specific image by ID.
|
||||
// Use ExtractImage() to interpret the result as an openstack Image.
|
||||
func Get(client *gophercloud.ServiceClient, id string) GetResult {
|
||||
var result GetResult
|
||||
_, result.Err = client.Get(getURL(client, id), &result.Body, nil)
|
||||
return result
|
||||
}
|
||||
|
||||
// Delete deletes the specified image ID.
|
||||
func Delete(client *gophercloud.ServiceClient, id string) DeleteResult {
|
||||
var result DeleteResult
|
||||
_, result.Err = client.Delete(deleteURL(client, id), nil)
|
||||
return result
|
||||
}
|
||||
|
||||
// IDFromName is a convienience function that returns an image's ID given its name.
|
||||
func IDFromName(client *gophercloud.ServiceClient, name string) (string, error) {
|
||||
imageCount := 0
|
||||
imageID := ""
|
||||
if name == "" {
|
||||
return "", fmt.Errorf("An image name must be provided.")
|
||||
}
|
||||
pager := ListDetail(client, &ListOpts{
|
||||
Name: name,
|
||||
})
|
||||
pager.EachPage(func(page pagination.Page) (bool, error) {
|
||||
imageList, err := ExtractImages(page)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
for _, i := range imageList {
|
||||
if i.Name == name {
|
||||
imageCount++
|
||||
imageID = i.ID
|
||||
}
|
||||
}
|
||||
return true, nil
|
||||
})
|
||||
|
||||
switch imageCount {
|
||||
case 0:
|
||||
return "", fmt.Errorf("Unable to find image: %s", name)
|
||||
case 1:
|
||||
return imageID, nil
|
||||
default:
|
||||
return "", fmt.Errorf("Found %d images matching %s", imageCount, name)
|
||||
}
|
||||
}
|
||||
95
vendor/github.com/rackspace/gophercloud/openstack/compute/v2/images/results.go
generated
vendored
Normal file
95
vendor/github.com/rackspace/gophercloud/openstack/compute/v2/images/results.go
generated
vendored
Normal file
@@ -0,0 +1,95 @@
|
||||
package images
|
||||
|
||||
import (
|
||||
"github.com/mitchellh/mapstructure"
|
||||
"github.com/rackspace/gophercloud"
|
||||
"github.com/rackspace/gophercloud/pagination"
|
||||
)
|
||||
|
||||
// GetResult temporarily stores a Get response.
|
||||
type GetResult struct {
|
||||
gophercloud.Result
|
||||
}
|
||||
|
||||
// DeleteResult represents the result of an image.Delete operation.
|
||||
type DeleteResult struct {
|
||||
gophercloud.ErrResult
|
||||
}
|
||||
|
||||
// Extract interprets a GetResult as an Image.
|
||||
func (gr GetResult) Extract() (*Image, error) {
|
||||
if gr.Err != nil {
|
||||
return nil, gr.Err
|
||||
}
|
||||
|
||||
var decoded struct {
|
||||
Image Image `mapstructure:"image"`
|
||||
}
|
||||
|
||||
err := mapstructure.Decode(gr.Body, &decoded)
|
||||
return &decoded.Image, err
|
||||
}
|
||||
|
||||
// Image is used for JSON (un)marshalling.
|
||||
// It provides a description of an OS image.
|
||||
type Image struct {
|
||||
// ID contains the image's unique identifier.
|
||||
ID string
|
||||
|
||||
Created string
|
||||
|
||||
// MinDisk and MinRAM specify the minimum resources a server must provide to be able to install the image.
|
||||
MinDisk int
|
||||
MinRAM int
|
||||
|
||||
// Name provides a human-readable moniker for the OS image.
|
||||
Name string
|
||||
|
||||
// The Progress and Status fields indicate image-creation status.
|
||||
// Any usable image will have 100% progress.
|
||||
Progress int
|
||||
Status string
|
||||
|
||||
Updated string
|
||||
}
|
||||
|
||||
// ImagePage contains a single page of results from a List operation.
|
||||
// Use ExtractImages to convert it into a slice of usable structs.
|
||||
type ImagePage struct {
|
||||
pagination.LinkedPageBase
|
||||
}
|
||||
|
||||
// IsEmpty returns true if a page contains no Image results.
|
||||
func (page ImagePage) IsEmpty() (bool, error) {
|
||||
images, err := ExtractImages(page)
|
||||
if err != nil {
|
||||
return true, err
|
||||
}
|
||||
return len(images) == 0, nil
|
||||
}
|
||||
|
||||
// NextPageURL uses the response's embedded link reference to navigate to the next page of results.
|
||||
func (page ImagePage) NextPageURL() (string, error) {
|
||||
type resp struct {
|
||||
Links []gophercloud.Link `mapstructure:"images_links"`
|
||||
}
|
||||
|
||||
var r resp
|
||||
err := mapstructure.Decode(page.Body, &r)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return gophercloud.ExtractNextURL(r.Links)
|
||||
}
|
||||
|
||||
// ExtractImages converts a page of List results into a slice of usable Image structs.
|
||||
func ExtractImages(page pagination.Page) ([]Image, error) {
|
||||
casted := page.(ImagePage).Body
|
||||
var results struct {
|
||||
Images []Image `mapstructure:"images"`
|
||||
}
|
||||
|
||||
err := mapstructure.Decode(casted, &results)
|
||||
return results.Images, err
|
||||
}
|
||||
15
vendor/github.com/rackspace/gophercloud/openstack/compute/v2/images/urls.go
generated
vendored
Normal file
15
vendor/github.com/rackspace/gophercloud/openstack/compute/v2/images/urls.go
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
package images
|
||||
|
||||
import "github.com/rackspace/gophercloud"
|
||||
|
||||
func listDetailURL(client *gophercloud.ServiceClient) string {
|
||||
return client.ServiceURL("images", "detail")
|
||||
}
|
||||
|
||||
func getURL(client *gophercloud.ServiceClient, id string) string {
|
||||
return client.ServiceURL("images", id)
|
||||
}
|
||||
|
||||
func deleteURL(client *gophercloud.ServiceClient, id string) string {
|
||||
return client.ServiceURL("images", id)
|
||||
}
|
||||
Reference in New Issue
Block a user