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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -75,7 +75,7 @@ func DoAuthRequest(authopts AuthOpts) (AuthRef, error) {
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 {
return nil, err
}

View File

@ -153,7 +153,7 @@ func (s *Session) RequestJSON(
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 {
return nil, err
}

View File

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

View File

@ -21,10 +21,10 @@ import (
"strings"
"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/testUtil"
"git.openstack.org/openstack/golang-client.git/util"
"git.openstack.org/openstack/golang-client.git/volume/v2"
)
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"))
}
expectedVolume := volume.Response{
Name: "volume_test1",
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"},
Name: "volume_test1",
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"},
{"href": "http://172.16.197.131:8776/1d8837c5fcef4892951397df97661f97/volumes/f5fc9874-fc89-4814-a358-23ba83a6115f", "rel": "bookmark"}}}
// Verify first one matches expected values
testUtil.Equals(t, expectedVolume, volumes[0])
@ -63,28 +63,28 @@ func TestListVolumeDetails(t *testing.T) {
}
createdAt, _ := util.NewDateTime(`"2014-09-29T14:44:31"`)
expectedVolumeDetail := volume.DetailResponse{
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"}},
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"}},
Metadata: map[string]string{"readonly": "false", "attached_mode": "rw"},
Protected: false,
Status: "available",
MigrationStatus: "",
UserID: "a971aa69-c61a-4a49-b392-b0e41609bc5d",
Encrypted: false,
Multiattach: false,
CreatedAt: createdAt,
Description: "test volume",
Volume_type: "test_type",
Name: "test_volume",
Source_volid: "4b58bbb8-3b00-4f87-8243-8c622707bbab",
Snapshot_id: "cc488e4a-9649-4e5f-ad12-20ab37c683b5",
Size: 2,
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"}},
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"}},
Metadata: map[string]string{"readonly": "false", "attached_mode": "rw"},
Protected: false,
Status: "available",
MigrationStatus: "",
UserID: "a971aa69-c61a-4a49-b392-b0e41609bc5d",
Encrypted: false,
Multiattach: false,
CreatedAt: createdAt,
Description: "test volume",
Volume_type: "test_type",
Name: "test_volume",
Source_volid: "4b58bbb8-3b00-4f87-8243-8c622707bbab",
Snapshot_id: "cc488e4a-9649-4e5f-ad12-20ab37c683b5",
Size: 2,
Aavailability_zone: "default_cluster",
Rreplication_status: "",
Consistencygroup_id: ""}
Aavailability_zone: "default_cluster",
Rreplication_status: "",
Consistencygroup_id: ""}
testUtil.Equals(t, expectedVolumeDetail, volumes[0])
}
@ -98,7 +98,7 @@ func TestLimitFilterUrlProduced(t *testing.T) {
func TestAll_tenantFilterUrlProduced(t *testing.T) {
testVolumeQueryParameter(t, "volumes?all_tenant=1",
volume.QueryParameters{All_tenant: 1})
volume.QueryParameters{All_tenant: 1})
}
func TestMarkerUrlProduced(t *testing.T) {