gofmt the project files (#205)

This commit is contained in:
Fei Xu
2018-05-19 07:13:34 +08:00
committed by Robbie Zhang
parent 3fe94966f6
commit 8068f3cac8
11 changed files with 54 additions and 53 deletions

View File

@@ -13,8 +13,8 @@ import (
// AADMock implements a AAD mock server .
type AADMock struct {
server *httptest.Server
OnAcquireToken func(http.ResponseWriter,*http.Request)
server *httptest.Server
OnAcquireToken func(http.ResponseWriter, *http.Request)
}
// NewAADMock creates a new AAD server mocker.
@@ -26,7 +26,7 @@ func NewAADMock() *AADMock {
}
// Start the AAD server mocker.
func (mock *AADMock)start() {
func (mock *AADMock) start() {
if mock.server != nil {
return
}
@@ -40,8 +40,8 @@ func (mock *AADMock)start() {
w.WriteHeader(http.StatusOK)
token := adal.Token{
AccessToken: "Test Token",
NotBefore: strconv.FormatInt(time.Now().UnixNano(), 10),
ExpiresIn: strconv.FormatInt(int64(time.Minute), 10),
NotBefore: strconv.FormatInt(time.Now().UnixNano(), 10),
ExpiresIn: strconv.FormatInt(int64(time.Minute), 10),
}
b := new(bytes.Buffer)
@@ -51,7 +51,7 @@ func (mock *AADMock)start() {
}
// GetServerURL returns the mock server URL.
func (mock *AADMock)GetServerURL() string {
func (mock *AADMock) GetServerURL() string {
if mock.server != nil {
return mock.server.URL
}
@@ -60,7 +60,7 @@ func (mock *AADMock)GetServerURL() string {
}
// Close terminates the AAD server mocker.
func (mock *AADMock)Close() {
func (mock *AADMock) Close() {
if mock.server != nil {
mock.server.Close()
mock.server = nil

View File

@@ -12,10 +12,10 @@ import (
// ACIMock implements a Azure Container Instance mock server.
type ACIMock struct {
server *httptest.Server
OnCreate func(string, string, string, *aci.ContainerGroup) (int, interface{})
OnGetContainerGroups func(string, string) (int, interface{})
OnGetContainerGroup func(string, string, string) (int, interface{})
server *httptest.Server
OnCreate func(string, string, string, *aci.ContainerGroup) (int, interface{})
OnGetContainerGroups func(string, string) (int, interface{})
OnGetContainerGroup func(string, string, string) (int, interface{})
}
const (

View File

@@ -18,8 +18,8 @@ import (
azure "github.com/virtual-kubelet/virtual-kubelet/providers/azure/client"
"github.com/virtual-kubelet/virtual-kubelet/providers/azure/client/aci"
"k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes/fake"
)
@@ -29,7 +29,7 @@ const (
fakeClientID = "f14193ad-4c4c-4876-a18a-c0badb3bbd40"
fakeClientSecret = "VGhpcyBpcyBhIHNlY3JldAo="
fakeTenantID = "8cb81aca-83fe-4c6f-b667-4ec09c45a8bf"
fakeNodeName = "vk"
fakeNodeName = "vk"
)
// Tests create pod without resource spec
@@ -47,7 +47,7 @@ func TestCreatePodWithoutResourceSpec(t *testing.T) {
assert.Equal(t, fakeSubscription, subscription, "Subscription doesn't match")
assert.Equal(t, fakeResourceGroup, resourceGroup, "Resource group doesn't match")
assert.NotNil(t, cg, "Container group is nil")
assert.Equal(t, podNamespace + "-" + podName, containerGroup, "Container group name is not expected")
assert.Equal(t, podNamespace+"-"+podName, containerGroup, "Container group name is not expected")
assert.NotNil(t, cg.ContainerGroupProperties, "Container group properties should not be nil")
assert.NotNil(t, cg.ContainerGroupProperties.Containers, "Containers should not be nil")
assert.Equal(t, 1, len(cg.ContainerGroupProperties.Containers), "1 Container is expected")
@@ -95,7 +95,7 @@ func TestCreatePodWithResourceRequestOnly(t *testing.T) {
assert.Equal(t, fakeSubscription, subscription, "Subscription doesn't match")
assert.Equal(t, fakeResourceGroup, resourceGroup, "Resource group doesn't match")
assert.NotNil(t, cg, "Container group is nil")
assert.Equal(t, podNamespace + "-" + podName, containerGroup, "Container group name is not expected")
assert.Equal(t, podNamespace+"-"+podName, containerGroup, "Container group name is not expected")
assert.NotNil(t, cg.ContainerGroupProperties, "Container group properties should not be nil")
assert.NotNil(t, cg.ContainerGroupProperties.Containers, "Containers should not be nil")
assert.Equal(t, 1, len(cg.ContainerGroupProperties.Containers), "1 Container is expected")
@@ -120,7 +120,7 @@ func TestCreatePodWithResourceRequestOnly(t *testing.T) {
Name: "nginx",
Resources: v1.ResourceRequirements{
Requests: v1.ResourceList{
"cpu": resource.MustParse("1.981"),
"cpu": resource.MustParse("1.981"),
"memory": resource.MustParse("3.49G"),
},
},
@@ -149,7 +149,7 @@ func TestCreatePodWithResourceRequestAndLimit(t *testing.T) {
assert.Equal(t, fakeSubscription, subscription, "Subscription doesn't match")
assert.Equal(t, fakeResourceGroup, resourceGroup, "Resource group doesn't match")
assert.NotNil(t, cg, "Container group is nil")
assert.Equal(t, podNamespace + "-" + podName, containerGroup, "Container group name is not expected")
assert.Equal(t, podNamespace+"-"+podName, containerGroup, "Container group name is not expected")
assert.NotNil(t, cg.ContainerGroupProperties, "Container group properties should not be nil")
assert.NotNil(t, cg.ContainerGroupProperties.Containers, "Containers should not be nil")
assert.Equal(t, 1, len(cg.ContainerGroupProperties.Containers), "1 Container is expected")
@@ -175,11 +175,11 @@ func TestCreatePodWithResourceRequestAndLimit(t *testing.T) {
Name: "nginx",
Resources: v1.ResourceRequirements{
Requests: v1.ResourceList{
"cpu": resource.MustParse("1.981"),
"cpu": resource.MustParse("1.981"),
"memory": resource.MustParse("3.49G"),
},
Limits: v1.ResourceList{
"cpu": resource.MustParse("3999m"),
"cpu": resource.MustParse("3999m"),
"memory": resource.MustParse("8010M"),
},
},
@@ -252,8 +252,8 @@ func TestGetPodsWithoutResourceRequestsLimits(t *testing.T) {
},
Resources: aci.ResourceRequirements{
Requests: &aci.ResourceRequests{
CPU: 0.99,
MemoryInGB: 1.5,
CPU: 0.99,
MemoryInGB: 1.5,
},
},
},
@@ -308,7 +308,7 @@ func TestGetPodWithoutResourceRequestsLimits(t *testing.T) {
aciServerMocker.OnGetContainerGroup = func(subscription, resourceGroup, containerGroup string) (int, interface{}) {
assert.Equal(t, fakeSubscription, subscription, "Subscription doesn't match")
assert.Equal(t, fakeResourceGroup, resourceGroup, "Resource group doesn't match")
assert.Equal(t, podNamespace + "-" + podName, containerGroup, "Container group name is not expected")
assert.Equal(t, podNamespace+"-"+podName, containerGroup, "Container group name is not expected")
return http.StatusOK, aci.ContainerGroup{
Tags: map[string]string{
@@ -330,8 +330,8 @@ func TestGetPodWithoutResourceRequestsLimits(t *testing.T) {
},
Resources: aci.ResourceRequirements{
Requests: &aci.ResourceRequests{
CPU: 0.99,
MemoryInGB: 1.5,
CPU: 0.99,
MemoryInGB: 1.5,
},
},
},

View File

@@ -35,4 +35,4 @@ func NewAcsCredential(filepath string) (*AcsCredential, error) {
log.Printf("Load ACS credential file %q successfully", filepath)
return &cred, nil
}
}

View File

@@ -6,9 +6,9 @@ import (
"strings"
"testing"
"github.com/google/uuid"
azure "github.com/virtual-kubelet/virtual-kubelet/providers/azure/client"
"github.com/virtual-kubelet/virtual-kubelet/providers/azure/client/resourcegroups"
"github.com/google/uuid"
)
var (
@@ -72,9 +72,9 @@ func TestMain(m *testing.M) {
func TestNewClient(t *testing.T) {
auth, err := azure.NewAuthenticationFromFile("../../../../credentials.json")
if err != nil {
log.Fatalf("Failed to load Azure authentication file: %v", err)
}
if err != nil {
log.Fatalf("Failed to load Azure authentication file: %v", err)
}
c, err := NewClient(auth)
if err != nil {

View File

@@ -29,33 +29,33 @@ type Authentication struct {
// credentials.
func NewAuthentication(azureCloud, clientID, clientSecret, subscriptionID, tenantID string) *Authentication {
environment := PublicCloud
switch azureCloud {
case PublicCloud.Name:
environment = PublicCloud
break;
break
case USGovernmentCloud.Name:
environment = USGovernmentCloud
break;
break
case ChinaCloud.Name:
environment = ChinaCloud
break;
break
case GermanCloud.Name:
environment = GermanCloud
break;
break
}
return &Authentication{
ClientID: clientID,
ClientSecret: clientSecret,
SubscriptionID: subscriptionID,
TenantID: tenantID,
ActiveDirectoryEndpoint: environment.ActiveDirectoryEndpoint,
ResourceManagerEndpoint: environment.ResourceManagerEndpoint,
GraphResourceID: environment.GraphEndpoint,
SQLManagementEndpoint: environment.SQLDatabaseDNSSuffix,
GalleryEndpoint: environment.GalleryEndpoint,
ManagementEndpoint: environment.ServiceManagementEndpoint,
ClientID: clientID,
ClientSecret: clientSecret,
SubscriptionID: subscriptionID,
TenantID: tenantID,
ActiveDirectoryEndpoint: environment.ActiveDirectoryEndpoint,
ResourceManagerEndpoint: environment.ResourceManagerEndpoint,
GraphResourceID: environment.GraphEndpoint,
SQLManagementEndpoint: environment.SQLDatabaseDNSSuffix,
GalleryEndpoint: environment.GalleryEndpoint,
ManagementEndpoint: environment.ServiceManagementEndpoint,
}
}

View File

@@ -5,8 +5,8 @@ import (
"io"
"strings"
"github.com/virtual-kubelet/virtual-kubelet/providers"
"github.com/BurntSushi/toml"
"github.com/virtual-kubelet/virtual-kubelet/providers"
)
type providerConfig struct {