Clean up source with go fmt

Change-Id: Iaa5382f2fd35764ba7e795c5ae8e5b9b780eac31
This commit is contained in:
Dean Troyer 2016-12-14 18:30:42 -06:00
parent d6e0b326e1
commit d38d3def62
12 changed files with 85 additions and 87 deletions

View File

@ -47,10 +47,10 @@ func main() {
// Authenticate with a project name, username, password. // Authenticate with a project name, username, password.
creds = openstack.AuthOpts{ creds = openstack.AuthOpts{
AuthUrl: config.Host, AuthUrl: config.Host,
ProjectName: config.ProjectName, ProjectName: config.ProjectName,
Username: config.Username, Username: config.Username,
Password: config.Password, Password: config.Password,
} }
auth, err = openstack.DoAuthRequest(creds) auth, err = openstack.DoAuthRequest(creds)
if err != nil { if err != nil {
@ -64,10 +64,10 @@ func main() {
// Authenticate with a project id, username, password. // Authenticate with a project id, username, password.
creds = openstack.AuthOpts{ creds = openstack.AuthOpts{
AuthUrl: config.Host, AuthUrl: config.Host,
ProjectId: config.ProjectID, ProjectId: config.ProjectID,
Username: config.Username, Username: config.Username,
Password: config.Password, Password: config.Password,
} }
auth, err = openstack.DoAuthRequest(creds) auth, err = openstack.DoAuthRequest(creds)
if err != nil { if err != nil {

View File

@ -35,10 +35,10 @@ func main() {
// that has active object storage. // that has active object storage.
// Authenticate with a project name, username, password. // Authenticate with a project name, username, password.
creds := openstack.AuthOpts{ creds := openstack.AuthOpts{
AuthUrl: config.Host, AuthUrl: config.Host,
ProjectName: config.ProjectName, ProjectName: config.ProjectName,
Username: config.Username, Username: config.Username,
Password: config.Password, Password: config.Password,
} }
auth, err := openstack.DoAuthRequest(creds) auth, err := openstack.DoAuthRequest(creds)
if err != nil { if err != nil {

View File

@ -31,10 +31,10 @@ func main() {
// Authenticate with a username, password, tenant id. // Authenticate with a username, password, tenant id.
creds := openstack.AuthOpts{ creds := openstack.AuthOpts{
AuthUrl: config.Host, AuthUrl: config.Host,
ProjectName: config.ProjectName, ProjectName: config.ProjectName,
Username: config.Username, Username: config.Username,
Password: config.Password, Password: config.Password,
} }
auth, err := openstack.DoAuthRequest(creds) auth, err := openstack.DoAuthRequest(creds)
if err != nil { if err != nil {

View File

@ -21,8 +21,8 @@ import (
"net/http" "net/http"
"time" "time"
"git.openstack.org/openstack/golang-client.git/volume/v2"
"git.openstack.org/openstack/golang-client.git/openstack" "git.openstack.org/openstack/golang-client.git/openstack"
"git.openstack.org/openstack/golang-client.git/volume/v2"
) )
// Volume examples. // Volume examples.
@ -31,10 +31,10 @@ func main() {
// Authenticate with a username, password, tenant id. // Authenticate with a username, password, tenant id.
creds := openstack.AuthOpts{ creds := openstack.AuthOpts{
AuthUrl: config.Host, AuthUrl: config.Host,
ProjectName: config.ProjectName, ProjectName: config.ProjectName,
Username: config.Username, Username: config.Username,
Password: config.Password, Password: config.Password,
} }
auth, err := openstack.DoAuthRequest(creds) auth, err := openstack.DoAuthRequest(creds)
if err != nil { if err != nil {

View File

@ -37,7 +37,7 @@ type testconfig struct {
ProjectName string ProjectName string
Container string Container string
ImageRegion string ImageRegion string
Debug bool Debug bool
} }
// getConfig provides access to credentials in other tests and examples. // getConfig provides access to credentials in other tests and examples.

View File

@ -30,10 +30,10 @@ const (
func getAuthOpts() openstack.AuthOpts { func getAuthOpts() openstack.AuthOpts {
return openstack.AuthOpts{ return openstack.AuthOpts{
AuthUrl: "http://localhost:5000/v2.0", AuthUrl: "http://localhost:5000/v2.0",
ProjectName: "demo", ProjectName: "demo",
Username: "demo", Username: "demo",
Password: "demo", Password: "demo",
} }
} }

View File

@ -137,8 +137,7 @@ func TestDeleteContainer(t *testing.T) {
defer apiServer.Close() defer apiServer.Close()
sess := testGetSession() sess := testGetSession()
if err := objectstorage.DeleteContainer(sess, apiServer.URL+containerPrefix, if err := objectstorage.DeleteContainer(sess, apiServer.URL+containerPrefix); err != nil {
); err != nil {
t.Error(err) t.Error(err)
} }
} }
@ -259,8 +258,7 @@ func TestCopyObject(t *testing.T) {
defer apiServer.Close() defer apiServer.Close()
sess := testGetSession() sess := testGetSession()
if err := objectstorage.CopyObject(sess, apiServer.URL+objPrefix, destURL, if err := objectstorage.CopyObject(sess, apiServer.URL+objPrefix, destURL); err != nil {
); err != nil {
t.Error(err) t.Error(err)
} }
} }

View File

@ -61,7 +61,7 @@ func NewUserPassV2(ao AuthOpts) (upv2 *UserPassV2, err error) {
Password: ao.Password, Password: ao.Password,
}, },
ProjectName: ao.ProjectName, ProjectName: ao.ProjectName,
ProjectId: ao.ProjectId, ProjectId: ao.ProjectId,
}, },
} }
return upv2, nil return upv2, nil

View File

@ -75,7 +75,7 @@ func DoAuthRequest(authopts AuthOpts) (AuthRef, error) {
return nil, err return nil, err
} }
_, err = PostJSON(auth_mod.AuthUrl + "/tokens", nil, nil, &auth_mod, &auth) _, err = PostJSON(auth_mod.AuthUrl+"/tokens", nil, nil, &auth_mod, &auth)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -153,7 +153,7 @@ func (s *Session) RequestJSON(
headers.Add("Content-Type", "application/json") headers.Add("Content-Type", "application/json")
} }
resp, err = s.Request(method, url, params, headers, &bodyjson) resp, err = s.Request(method, url, params, headers, &bodyjson)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -48,46 +48,46 @@ type Service struct {
// Response is a structure for all properties of // Response is a structure for all properties of
// an volume for a non detailed query // an volume for a non detailed query
type Response struct { type Response struct {
ID string `json:"id"` ID string `json:"id"`
Links []map[string]string `json:"links"` Links []map[string]string `json:"links"`
Name string `json:"name"` Name string `json:"name"`
} }
// DetailResponse is a structure for all properties of // DetailResponse is a structure for all properties of
// an volume for a detailed query // an volume for a detailed query
type DetailResponse struct { type DetailResponse struct {
ID string `json:"id"` ID string `json:"id"`
Attachments []map[string]string `json:"attachments"` Attachments []map[string]string `json:"attachments"`
Links []map[string]string `json:"links"` Links []map[string]string `json:"links"`
Metadata map[string]string `json:"metadata"` Metadata map[string]string `json:"metadata"`
Protected bool `json:"protected"` Protected bool `json:"protected"`
Status string `json:"status"` Status string `json:"status"`
MigrationStatus string `json:"migration_status"` MigrationStatus string `json:"migration_status"`
UserID string `json:"user_id"` UserID string `json:"user_id"`
Encrypted bool `json:"encrypted"` Encrypted bool `json:"encrypted"`
Multiattach bool `json:"multiattach"` Multiattach bool `json:"multiattach"`
CreatedAt util.RFC8601DateTime `json:"created_at"` CreatedAt util.RFC8601DateTime `json:"created_at"`
Description string `json:"description"` Description string `json:"description"`
Volume_type string `json:"volume_type"` Volume_type string `json:"volume_type"`
Name string `json:"name"` Name string `json:"name"`
Source_volid string `json:"source_volid"` Source_volid string `json:"source_volid"`
Snapshot_id string `json:"snapshot_id"` Snapshot_id string `json:"snapshot_id"`
Size int64 `json:"size"` Size int64 `json:"size"`
Aavailability_zone string `json:"availability_zone"` Aavailability_zone string `json:"availability_zone"`
Rreplication_status string `json:"replication_status"` Rreplication_status string `json:"replication_status"`
Consistencygroup_id string `json:"consistencygroup_id"` Consistencygroup_id string `json:"consistencygroup_id"`
} }
// QueryParameters is a structure that // QueryParameters is a structure that
// contains the filter, sort, and paging parameters for // contains the filter, sort, and paging parameters for
// an volume or volumedetail query. // an volume or volumedetail query.
type QueryParameters struct { type QueryParameters struct {
All_tenant int64 All_tenant int64
Marker string Marker string
Limit int64 Limit int64
SortKey string SortKey string
SortDirection SortDirection SortDirection SortDirection
} }
// SortDirection of the sort, ascending or descending. // SortDirection of the sort, ascending or descending.

View File

@ -21,10 +21,10 @@ import (
"strings" "strings"
"testing" "testing"
"git.openstack.org/openstack/golang-client.git/volume/v2"
"git.openstack.org/openstack/golang-client.git/openstack" "git.openstack.org/openstack/golang-client.git/openstack"
"git.openstack.org/openstack/golang-client.git/testUtil" "git.openstack.org/openstack/golang-client.git/testUtil"
"git.openstack.org/openstack/golang-client.git/util" "git.openstack.org/openstack/golang-client.git/util"
"git.openstack.org/openstack/golang-client.git/volume/v2"
) )
var tokn = "ae5aebe5-6a5d-4a40-840a-9736a067aff4" var tokn = "ae5aebe5-6a5d-4a40-840a-9736a067aff4"
@ -40,9 +40,9 @@ func TestListVolumes(t *testing.T) {
t.Error(errors.New("Incorrect number of volumes found")) t.Error(errors.New("Incorrect number of volumes found"))
} }
expectedVolume := volume.Response{ expectedVolume := volume.Response{
Name: "volume_test1", Name: "volume_test1",
ID: "f5fc9874-fc89-4814-a358-23ba83a6115f", ID: "f5fc9874-fc89-4814-a358-23ba83a6115f",
Links: []map[string]string{{"href": "http://172.16.197.131:8776/v2/1d8837c5fcef4892951397df97661f97/volumes/f5fc9874-fc89-4814-a358-23ba83a6115f", "rel": "self"}, Links: []map[string]string{{"href": "http://172.16.197.131:8776/v2/1d8837c5fcef4892951397df97661f97/volumes/f5fc9874-fc89-4814-a358-23ba83a6115f", "rel": "self"},
{"href": "http://172.16.197.131:8776/1d8837c5fcef4892951397df97661f97/volumes/f5fc9874-fc89-4814-a358-23ba83a6115f", "rel": "bookmark"}}} {"href": "http://172.16.197.131:8776/1d8837c5fcef4892951397df97661f97/volumes/f5fc9874-fc89-4814-a358-23ba83a6115f", "rel": "bookmark"}}}
// Verify first one matches expected values // Verify first one matches expected values
testUtil.Equals(t, expectedVolume, volumes[0]) testUtil.Equals(t, expectedVolume, volumes[0])
@ -63,28 +63,28 @@ func TestListVolumeDetails(t *testing.T) {
} }
createdAt, _ := util.NewDateTime(`"2014-09-29T14:44:31"`) createdAt, _ := util.NewDateTime(`"2014-09-29T14:44:31"`)
expectedVolumeDetail := volume.DetailResponse{ expectedVolumeDetail := volume.DetailResponse{
ID: "30becf77-63fe-4f5e-9507-a0578ffe0949", ID: "30becf77-63fe-4f5e-9507-a0578ffe0949",
Attachments: []map[string]string{{"attachment_id": "ddb2ac07-ed62-49eb-93da-73b258dd9bec", "host_name": "host_test", "volume_id": "30becf77-63fe-4f5e-9507-a0578ffe0949", "device": "/dev/vdb", "id": "30becf77-63fe-4f5e-9507-a0578ffe0949", "server_id": "0f081aae-1b0c-4b89-930c-5f2562460c72"}}, Attachments: []map[string]string{{"attachment_id": "ddb2ac07-ed62-49eb-93da-73b258dd9bec", "host_name": "host_test", "volume_id": "30becf77-63fe-4f5e-9507-a0578ffe0949", "device": "/dev/vdb", "id": "30becf77-63fe-4f5e-9507-a0578ffe0949", "server_id": "0f081aae-1b0c-4b89-930c-5f2562460c72"}},
Links: []map[string]string{{"href": "http://172.16.197.131:8776/v2/1d8837c5fcef4892951397df97661f97/volumes/30becf77-63fe-4f5e-9507-a0578ffe0949", "rel": "self"}, Links: []map[string]string{{"href": "http://172.16.197.131:8776/v2/1d8837c5fcef4892951397df97661f97/volumes/30becf77-63fe-4f5e-9507-a0578ffe0949", "rel": "self"},
{"href": "http://172.16.197.131:8776/1d8837c5fcef4892951397df97661f97/volumes/30becf77-63fe-4f5e-9507-a0578ffe0949", "rel": "bookmark"}}, {"href": "http://172.16.197.131:8776/1d8837c5fcef4892951397df97661f97/volumes/30becf77-63fe-4f5e-9507-a0578ffe0949", "rel": "bookmark"}},
Metadata: map[string]string{"readonly": "false", "attached_mode": "rw"}, Metadata: map[string]string{"readonly": "false", "attached_mode": "rw"},
Protected: false, Protected: false,
Status: "available", Status: "available",
MigrationStatus: "", MigrationStatus: "",
UserID: "a971aa69-c61a-4a49-b392-b0e41609bc5d", UserID: "a971aa69-c61a-4a49-b392-b0e41609bc5d",
Encrypted: false, Encrypted: false,
Multiattach: false, Multiattach: false,
CreatedAt: createdAt, CreatedAt: createdAt,
Description: "test volume", Description: "test volume",
Volume_type: "test_type", Volume_type: "test_type",
Name: "test_volume", Name: "test_volume",
Source_volid: "4b58bbb8-3b00-4f87-8243-8c622707bbab", Source_volid: "4b58bbb8-3b00-4f87-8243-8c622707bbab",
Snapshot_id: "cc488e4a-9649-4e5f-ad12-20ab37c683b5", Snapshot_id: "cc488e4a-9649-4e5f-ad12-20ab37c683b5",
Size: 2, Size: 2,
Aavailability_zone: "default_cluster", Aavailability_zone: "default_cluster",
Rreplication_status: "", Rreplication_status: "",
Consistencygroup_id: ""} Consistencygroup_id: ""}
testUtil.Equals(t, expectedVolumeDetail, volumes[0]) testUtil.Equals(t, expectedVolumeDetail, volumes[0])
} }
@ -98,7 +98,7 @@ func TestLimitFilterUrlProduced(t *testing.T) {
func TestAll_tenantFilterUrlProduced(t *testing.T) { func TestAll_tenantFilterUrlProduced(t *testing.T) {
testVolumeQueryParameter(t, "volumes?all_tenant=1", testVolumeQueryParameter(t, "volumes?all_tenant=1",
volume.QueryParameters{All_tenant: 1}) volume.QueryParameters{All_tenant: 1})
} }
func TestMarkerUrlProduced(t *testing.T) { func TestMarkerUrlProduced(t *testing.T) {