style(*): gofmt

pull/291/head
Adam Reese 9 years ago
parent 8876c7e54b
commit 4134afee10

@ -275,7 +275,7 @@ func callService(path, method, action string, reader io.ReadCloser) {
panic(fmt.Errorf("cannot parse url (%s): %s\n", path, err))
}
URL.Path = strings.TrimRight(URL.Path, "/") + "/" + strings.TrimLeft(path, "/")
URL.Path = strings.TrimRight(URL.Path, "/") + "/" + strings.TrimLeft(path, "/")
resp := callHTTP(URL.String(), method, action, reader)
var j interface{}
if err := json.Unmarshal([]byte(resp), &j); err != nil {

@ -17,8 +17,8 @@ limitations under the License.
package service
import (
"github.com/kubernetes/deployment-manager/pkg/common"
"github.com/kubernetes/deployment-manager/cmd/expandybird/expander"
"github.com/kubernetes/deployment-manager/pkg/common"
"github.com/kubernetes/deployment-manager/pkg/util"
"errors"

@ -33,11 +33,11 @@ import (
"github.com/ghodss/yaml"
"github.com/gorilla/mux"
"github.com/kubernetes/deployment-manager/pkg/common"
"github.com/kubernetes/deployment-manager/cmd/manager/manager"
"github.com/kubernetes/deployment-manager/cmd/manager/repository"
"github.com/kubernetes/deployment-manager/cmd/manager/repository/persistent"
"github.com/kubernetes/deployment-manager/cmd/manager/repository/transient"
"github.com/kubernetes/deployment-manager/pkg/common"
"github.com/kubernetes/deployment-manager/pkg/registry"
"github.com/kubernetes/deployment-manager/pkg/util"
)

@ -26,8 +26,8 @@ import (
"strings"
"testing"
"github.com/kubernetes/deployment-manager/pkg/util"
"github.com/kubernetes/deployment-manager/pkg/common"
"github.com/kubernetes/deployment-manager/pkg/util"
"github.com/ghodss/yaml"
)

@ -26,8 +26,8 @@ import (
"strings"
"testing"
"github.com/kubernetes/deployment-manager/pkg/util"
"github.com/kubernetes/deployment-manager/pkg/common"
"github.com/kubernetes/deployment-manager/pkg/util"
"github.com/ghodss/yaml"
)
@ -64,15 +64,15 @@ resources:
`)
var validImportFilesTestCaseData = []*common.ImportFile{
&common.ImportFile{
{
Name: "test-type.py",
Content: "test-type.py validTemplateTestCaseData content",
},
&common.ImportFile{
{
Name: "test.py",
Content: "test.py validTemplateTestCaseData content",
},
&common.ImportFile{
{
Name: "test2.py",
Content: "test2.py validTemplateTestCaseData content",
},

@ -24,8 +24,8 @@ import (
"strings"
"time"
"github.com/kubernetes/deployment-manager/pkg/common"
"github.com/kubernetes/deployment-manager/cmd/manager/repository"
"github.com/kubernetes/deployment-manager/pkg/common"
"github.com/kubernetes/deployment-manager/pkg/registry"
"github.com/kubernetes/deployment-manager/pkg/util"
)

@ -29,16 +29,16 @@ import (
var template = common.Template{Name: "test", Content: "test"}
var layout = common.Layout{
Resources: []*common.LayoutResource{&common.LayoutResource{Resource: common.Resource{Name: "test", Type: "test"}}},
Resources: []*common.LayoutResource{{Resource: common.Resource{Name: "test", Type: "test"}}},
}
var configuration = common.Configuration{
Resources: []*common.Resource{&common.Resource{Name: "test", Type: "test"}},
Resources: []*common.Resource{{Name: "test", Type: "test"}},
}
var resourcesWithSuccessState = common.Configuration{
Resources: []*common.Resource{&common.Resource{Name: "test", Type: "test", State: &common.ResourceState{Status: common.Created}}},
Resources: []*common.Resource{{Name: "test", Type: "test", State: &common.ResourceState{Status: common.Created}}},
}
var resourcesWithFailureState = common.Configuration{
Resources: []*common.Resource{&common.Resource{
Resources: []*common.Resource{{
Name: "test",
Type: "test",
State: &common.ResourceState{
@ -64,7 +64,7 @@ var deployment = common.Deployment{
var deploymentList = []common.Deployment{deployment, {Name: "test2"}}
var typeInstMap = map[string][]string{"test": []string{"test"}}
var typeInstMap = map[string][]string{"test": {"test"}}
var errTest = errors.New("test error")

@ -180,7 +180,7 @@ func (tr *typeResolver) ResolveTypes(config *common.Configuration, imports []*co
for _, u := range urls {
if len(fetched[u]) == 0 {
// If this import URL is new to us, add it to the URLs to fetch.
toFetch = append(toFetch, &fetchUnit{[]fetchableURL{fetchableURL{urlRegistry, u}}})
toFetch = append(toFetch, &fetchUnit{[]fetchableURL{{urlRegistry, u}}})
} else {
// If this is not a new import URL and we've already fetched its contents,
// reuse them. Also, check if we also found a schema for that import URL and

@ -118,7 +118,7 @@ resources:
`
func TestIncludedImport(t *testing.T) {
imports := []*common.ImportFile{&common.ImportFile{Name: "foo.py"}}
imports := []*common.ImportFile{{Name: "foo.py"}}
test := resolverTestCase{
config: includeImport,
imports: imports,
@ -133,11 +133,11 @@ resources:
`
func TestSingleUrl(t *testing.T) {
finalImports := []*common.ImportFile{&common.ImportFile{Name: "http://my-fake-url", Path: "http://my-fake-url", Content: "my-content"}}
finalImports := []*common.ImportFile{{Name: "http://my-fake-url", Path: "http://my-fake-url", Content: "my-content"}}
responses := map[string]responseAndError{
"http://my-fake-url": responseAndError{nil, http.StatusOK, "my-content"},
"http://my-fake-url.schema": responseAndError{nil, http.StatusNotFound, ""},
"http://my-fake-url": {nil, http.StatusOK, "my-content"},
"http://my-fake-url.schema": {nil, http.StatusNotFound, ""},
}
test := resolverTestCase{
@ -151,7 +151,7 @@ func TestSingleUrl(t *testing.T) {
func TestSingleUrlWith500(t *testing.T) {
responses := map[string]responseAndError{
"http://my-fake-url": responseAndError{nil, http.StatusInternalServerError, "my-content"},
"http://my-fake-url": {nil, http.StatusInternalServerError, "my-content"},
}
test := resolverTestCase{
@ -171,16 +171,16 @@ imports:
func TestSingleUrlWithSchema(t *testing.T) {
finalImports := []*common.ImportFile{
&common.ImportFile{Name: "http://my-fake-url", Path: "http://my-fake-url", Content: "my-content"},
&common.ImportFile{Name: "schema-import", Content: "schema-import"},
&common.ImportFile{Name: "http://my-fake-url.schema", Content: schema1},
{Name: "http://my-fake-url", Path: "http://my-fake-url", Content: "my-content"},
{Name: "schema-import", Content: "schema-import"},
{Name: "http://my-fake-url.schema", Content: schema1},
}
responses := map[string]responseAndError{
"http://my-fake-url": responseAndError{nil, http.StatusOK, "my-content"},
"http://my-fake-url.schema": responseAndError{nil, http.StatusOK, schema1},
"my-next-url": responseAndError{nil, http.StatusOK, "schema-import"},
"my-next-url.schema": responseAndError{nil, http.StatusNotFound, ""},
"http://my-fake-url": {nil, http.StatusOK, "my-content"},
"http://my-fake-url.schema": {nil, http.StatusOK, schema1},
"my-next-url": {nil, http.StatusOK, "schema-import"},
"my-next-url.schema": {nil, http.StatusNotFound, ""},
}
test := resolverTestCase{
@ -210,18 +210,18 @@ resources:
func TestTooManyImports(t *testing.T) {
responses := map[string]responseAndError{
"http://my-fake-url": responseAndError{nil, http.StatusOK, "my-content"},
"http://my-fake-url.schema": responseAndError{nil, http.StatusNotFound, ""},
"http://my-fake-url1": responseAndError{nil, http.StatusOK, "my-content"},
"http://my-fake-url1.schema": responseAndError{nil, http.StatusNotFound, ""},
"http://my-fake-url2": responseAndError{nil, http.StatusOK, "my-content"},
"http://my-fake-url2.schema": responseAndError{nil, http.StatusNotFound, ""},
"http://my-fake-url3": responseAndError{nil, http.StatusOK, "my-content"},
"http://my-fake-url3.schema": responseAndError{nil, http.StatusNotFound, ""},
"http://my-fake-url4": responseAndError{nil, http.StatusOK, "my-content"},
"http://my-fake-url4.schema": responseAndError{nil, http.StatusNotFound, ""},
"http://my-fake-url5": responseAndError{nil, http.StatusOK, "my-content"},
"http://my-fake-url5.schema": responseAndError{nil, http.StatusNotFound, ""},
"http://my-fake-url": {nil, http.StatusOK, "my-content"},
"http://my-fake-url.schema": {nil, http.StatusNotFound, ""},
"http://my-fake-url1": {nil, http.StatusOK, "my-content"},
"http://my-fake-url1.schema": {nil, http.StatusNotFound, ""},
"http://my-fake-url2": {nil, http.StatusOK, "my-content"},
"http://my-fake-url2.schema": {nil, http.StatusNotFound, ""},
"http://my-fake-url3": {nil, http.StatusOK, "my-content"},
"http://my-fake-url3.schema": {nil, http.StatusNotFound, ""},
"http://my-fake-url4": {nil, http.StatusOK, "my-content"},
"http://my-fake-url4.schema": {nil, http.StatusNotFound, ""},
"http://my-fake-url5": {nil, http.StatusOK, "my-content"},
"http://my-fake-url5.schema": {nil, http.StatusNotFound, ""},
}
test := resolverTestCase{
@ -250,21 +250,21 @@ imports:
func TestSharedImport(t *testing.T) {
finalImports := []*common.ImportFile{
&common.ImportFile{Name: "http://my-fake-url", Path: "http://my-fake-url", Content: "my-content"},
&common.ImportFile{Name: "http://my-fake-url1", Path: "http://my-fake-url1", Content: "my-content-1"},
&common.ImportFile{Name: "schema-import", Content: "schema-import"},
&common.ImportFile{Name: "schema-import-1", Content: "schema-import"},
&common.ImportFile{Name: "http://my-fake-url.schema", Content: schema1},
&common.ImportFile{Name: "http://my-fake-url1.schema", Content: schema2},
{Name: "http://my-fake-url", Path: "http://my-fake-url", Content: "my-content"},
{Name: "http://my-fake-url1", Path: "http://my-fake-url1", Content: "my-content-1"},
{Name: "schema-import", Content: "schema-import"},
{Name: "schema-import-1", Content: "schema-import"},
{Name: "http://my-fake-url.schema", Content: schema1},
{Name: "http://my-fake-url1.schema", Content: schema2},
}
responses := map[string]responseAndError{
"http://my-fake-url": responseAndError{nil, http.StatusOK, "my-content"},
"http://my-fake-url.schema": responseAndError{nil, http.StatusOK, schema1},
"http://my-fake-url1": responseAndError{nil, http.StatusOK, "my-content-1"},
"http://my-fake-url1.schema": responseAndError{nil, http.StatusOK, schema2},
"my-next-url": responseAndError{nil, http.StatusOK, "schema-import"},
"my-next-url.schema": responseAndError{nil, http.StatusNotFound, ""},
"http://my-fake-url": {nil, http.StatusOK, "my-content"},
"http://my-fake-url.schema": {nil, http.StatusOK, schema1},
"http://my-fake-url1": {nil, http.StatusOK, "my-content-1"},
"http://my-fake-url1.schema": {nil, http.StatusOK, schema2},
"my-next-url": {nil, http.StatusOK, "schema-import"},
"my-next-url.schema": {nil, http.StatusNotFound, ""},
}
test := resolverTestCase{
@ -287,31 +287,31 @@ resources:
func TestShortGithubUrl(t *testing.T) {
finalImports := []*common.ImportFile{
&common.ImportFile{
{
Name: "github.com/kubernetes/application-dm-templates/common/replicatedservice:v1",
Path: "https://raw.githubusercontent.com/kubernetes/application-dm-templates/master/common/replicatedservice/v1/replicatedservice.py",
Content: "my-content"},
&common.ImportFile{
{
Name: "github.com/kubernetes/application-dm-templates/common/replicatedservice:v2",
Path: "https://raw.githubusercontent.com/kubernetes/application-dm-templates/master/common/replicatedservice/v2/replicatedservice.py",
Content: "my-content-2"},
}
downloadResponses := map[string]registry.DownloadResponse{
"https://raw.githubusercontent.com/kubernetes/application-dm-templates/master/common/replicatedservice/v1/replicatedservice.py": registry.DownloadResponse{Err: nil, Code: http.StatusOK, Body: "my-content"},
"https://raw.githubusercontent.com/kubernetes/application-dm-templates/master/common/replicatedservice/v1/replicatedservice.py.schema": registry.DownloadResponse{Err: nil, Code: http.StatusNotFound, Body: ""},
"https://raw.githubusercontent.com/kubernetes/application-dm-templates/master/common/replicatedservice/v2/replicatedservice.py": registry.DownloadResponse{Err: nil, Code: http.StatusOK, Body: "my-content-2"},
"https://raw.githubusercontent.com/kubernetes/application-dm-templates/master/common/replicatedservice/v2/replicatedservice.py.schema": registry.DownloadResponse{Err: nil, Code: http.StatusNotFound, Body: ""},
"https://raw.githubusercontent.com/kubernetes/application-dm-templates/master/common/replicatedservice/v1/replicatedservice.py": {Err: nil, Code: http.StatusOK, Body: "my-content"},
"https://raw.githubusercontent.com/kubernetes/application-dm-templates/master/common/replicatedservice/v1/replicatedservice.py.schema": {Err: nil, Code: http.StatusNotFound, Body: ""},
"https://raw.githubusercontent.com/kubernetes/application-dm-templates/master/common/replicatedservice/v2/replicatedservice.py": {Err: nil, Code: http.StatusOK, Body: "my-content-2"},
"https://raw.githubusercontent.com/kubernetes/application-dm-templates/master/common/replicatedservice/v2/replicatedservice.py.schema": {Err: nil, Code: http.StatusNotFound, Body: ""},
}
githubURLMaps := map[registry.Type]registry.TestURLAndError{
registry.NewTypeOrDie("common", "replicatedservice", "v1"): registry.TestURLAndError{URL: "https://raw.githubusercontent.com/kubernetes/application-dm-templates/master/common/replicatedservice/v1/replicatedservice.py", Err: nil},
registry.NewTypeOrDie("common", "replicatedservice", "v2"): registry.TestURLAndError{URL: "https://raw.githubusercontent.com/kubernetes/application-dm-templates/master/common/replicatedservice/v2/replicatedservice.py", Err: nil},
registry.NewTypeOrDie("common", "replicatedservice", "v1"): {URL: "https://raw.githubusercontent.com/kubernetes/application-dm-templates/master/common/replicatedservice/v1/replicatedservice.py", Err: nil},
registry.NewTypeOrDie("common", "replicatedservice", "v2"): {URL: "https://raw.githubusercontent.com/kubernetes/application-dm-templates/master/common/replicatedservice/v2/replicatedservice.py", Err: nil},
}
gcsURLMaps := map[registry.Type]registry.TestURLAndError{
registry.NewTypeOrDie("common", "replicatedservice", "v1"): registry.TestURLAndError{URL: "https://raw.githubusercontent.com/kubernetes/application-dm-templates/master/common/replicatedservice/v1/replicatedservice.py", Err: nil},
registry.NewTypeOrDie("common", "replicatedservice", "v2"): registry.TestURLAndError{URL: "https://raw.githubusercontent.com/kubernetes/application-dm-templates/master/common/replicatedservice/v2/replicatedservice.py", Err: nil},
registry.NewTypeOrDie("common", "replicatedservice", "v1"): {URL: "https://raw.githubusercontent.com/kubernetes/application-dm-templates/master/common/replicatedservice/v1/replicatedservice.py", Err: nil},
registry.NewTypeOrDie("common", "replicatedservice", "v2"): {URL: "https://raw.githubusercontent.com/kubernetes/application-dm-templates/master/common/replicatedservice/v2/replicatedservice.py", Err: nil},
}
grp := registry.NewTestGithubRegistryProviderWithDownloads("github.com/kubernetes/application-dm-templates", githubURLMaps, downloadResponses)

@ -25,8 +25,8 @@ import (
"os"
"time"
"github.com/kubernetes/deployment-manager/pkg/common"
"github.com/kubernetes/deployment-manager/cmd/manager/repository"
"github.com/kubernetes/deployment-manager/pkg/common"
"gopkg.in/mgo.v2"
"gopkg.in/mgo.v2/bson"

@ -213,8 +213,8 @@ func TestRepositoryDeleteDeploymentWorksForget(t *testing.T, r Repository) {
// TestRepositoryTypeInstances checks that type instances can be listed and retrieved successfully.
func TestRepositoryTypeInstances(t *testing.T, r Repository) {
d1Map := map[string][]*common.TypeInstance{
"t1": []*common.TypeInstance{
&common.TypeInstance{
"t1": {
{
Name: "i1",
Type: "t1",
Deployment: "d1",
@ -225,8 +225,8 @@ func TestRepositoryTypeInstances(t *testing.T, r Repository) {
}
d2Map := map[string][]*common.TypeInstance{
"t2": []*common.TypeInstance{
&common.TypeInstance{
"t2": {
{
Name: "i2",
Type: "t2",
Deployment: "d2",
@ -237,8 +237,8 @@ func TestRepositoryTypeInstances(t *testing.T, r Repository) {
}
d3Map := map[string][]*common.TypeInstance{
"t2": []*common.TypeInstance{
&common.TypeInstance{
"t2": {
{
Name: "i3",
Type: "t2",
Deployment: "d3",

@ -23,8 +23,8 @@ import (
"sync"
"time"
"github.com/kubernetes/deployment-manager/pkg/common"
"github.com/kubernetes/deployment-manager/cmd/manager/repository"
"github.com/kubernetes/deployment-manager/pkg/common"
)
// deploymentTypeInstanceMap stores type instances mapped by deployment name.

@ -17,8 +17,8 @@ limitations under the License.
package main
import (
"github.com/kubernetes/deployment-manager/pkg/common"
"github.com/kubernetes/deployment-manager/cmd/resourcifier/configurator"
"github.com/kubernetes/deployment-manager/pkg/common"
"github.com/kubernetes/deployment-manager/pkg/util"
"encoding/json"

@ -22,9 +22,9 @@ import (
func TestParse(t *testing.T) {
tests := map[string]Locator{
"helm:host/bucket/name#1.2.3": Locator{Scheme: "helm", Host: "host", Bucket: "bucket", Name: "name", Version: "1.2.3"},
"https://host/bucket/name-1.2.3.tgz": Locator{Scheme: "https", Host: "host", Bucket: "bucket", Name: "name", Version: "1.2.3"},
"http://host/bucket/name-1.2.3.tgz": Locator{Scheme: "http", Host: "host", Bucket: "bucket", Name: "name", Version: "1.2.3"},
"helm:host/bucket/name#1.2.3": {Scheme: "helm", Host: "host", Bucket: "bucket", Name: "name", Version: "1.2.3"},
"https://host/bucket/name-1.2.3.tgz": {Scheme: "https", Host: "host", Bucket: "bucket", Name: "name", Version: "1.2.3"},
"http://host/bucket/name-1.2.3.tgz": {Scheme: "http", Host: "host", Bucket: "bucket", Name: "name", Version: "1.2.3"},
}
for start, expect := range tests {

@ -168,7 +168,7 @@ type githubRegistryProvider struct {
// NewGithubRegistryProvider creates a GithubRegistryProvider.
func NewGithubRegistryProvider(cp common.CredentialProvider) GithubRegistryProvider {
if cp == nil {
// TODO: replace this panic with an error return.
// TODO: replace this panic with an error return.
panic(fmt.Errorf("no credential provider"))
}
return &githubRegistryProvider{cp: cp}
@ -240,7 +240,7 @@ type gcsRegistryProvider struct {
// NewGCSRegistryProvider creates a GCSRegistryProvider.
func NewGCSRegistryProvider(cp common.CredentialProvider) GCSRegistryProvider {
if cp == nil {
// TODO: replace this panic with an error return.
// TODO: replace this panic with an error return.
panic(fmt.Errorf("no credential provider"))
}
return &gcsRegistryProvider{cp: cp}

@ -36,13 +36,13 @@ func testURLConversionDriver(rp RegistryProvider, tests map[string]TestURLAndErr
func TestShortGithubURLTemplateMapping(t *testing.T) {
githubURLMaps := map[Type]TestURLAndError{
NewTypeOrDie("common", "replicatedservice", "v1"): TestURLAndError{"https://raw.githubusercontent.com/kubernetes/application-dm-templates/master/common/replicatedservice/v1/replicatedservice.py", nil},
NewTypeOrDie("storage", "redis", "v1"): TestURLAndError{"https://raw.githubusercontent.com/kubernetes/application-dm-templates/master/storage/redis/v1/redis.jinja", nil},
NewTypeOrDie("common", "replicatedservice", "v1"): {"https://raw.githubusercontent.com/kubernetes/application-dm-templates/master/common/replicatedservice/v1/replicatedservice.py", nil},
NewTypeOrDie("storage", "redis", "v1"): {"https://raw.githubusercontent.com/kubernetes/application-dm-templates/master/storage/redis/v1/redis.jinja", nil},
}
tests := map[string]TestURLAndError{
"github.com/kubernetes/application-dm-templates/common/replicatedservice:v1": TestURLAndError{"https://raw.githubusercontent.com/kubernetes/application-dm-templates/master/common/replicatedservice/v1/replicatedservice.py", nil},
"github.com/kubernetes/application-dm-templates/storage/redis:v1": TestURLAndError{"https://raw.githubusercontent.com/kubernetes/application-dm-templates/master/storage/redis/v1/redis.jinja", nil},
"github.com/kubernetes/application-dm-templates/common/replicatedservice:v1": {"https://raw.githubusercontent.com/kubernetes/application-dm-templates/master/common/replicatedservice/v1/replicatedservice.py", nil},
"github.com/kubernetes/application-dm-templates/storage/redis:v1": {"https://raw.githubusercontent.com/kubernetes/application-dm-templates/master/storage/redis/v1/redis.jinja", nil},
}
grp := NewTestGithubRegistryProvider("github.com/kubernetes/application-dm-templates", githubURLMaps)
@ -52,13 +52,13 @@ func TestShortGithubURLTemplateMapping(t *testing.T) {
func TestShortGithubURLPackageMapping(t *testing.T) {
githubURLMaps := map[Type]TestURLAndError{
NewTypeOrDie("", "mongodb", ""): TestURLAndError{"https://raw.githubusercontent.com/helm/charts/master/mongodb/manifests/mongodb.yaml", nil},
NewTypeOrDie("", "redis", ""): TestURLAndError{"https://raw.githubusercontent.com/helm/charts/master/redis/manifests/redis.yaml", nil},
NewTypeOrDie("", "mongodb", ""): {"https://raw.githubusercontent.com/helm/charts/master/mongodb/manifests/mongodb.yaml", nil},
NewTypeOrDie("", "redis", ""): {"https://raw.githubusercontent.com/helm/charts/master/redis/manifests/redis.yaml", nil},
}
tests := map[string]TestURLAndError{
"github.com/helm/charts/mongodb": TestURLAndError{"https://raw.githubusercontent.com/helm/charts/master/mongodb/manifests/mongodb.yaml", nil},
"github.com/helm/charts/redis": TestURLAndError{"https://raw.githubusercontent.com/helm/charts/master/redis/manifests/redis.yaml", nil},
"github.com/helm/charts/mongodb": {"https://raw.githubusercontent.com/helm/charts/master/mongodb/manifests/mongodb.yaml", nil},
"github.com/helm/charts/redis": {"https://raw.githubusercontent.com/helm/charts/master/redis/manifests/redis.yaml", nil},
}
grp := NewTestGithubRegistryProvider("github.com/helm/charts", githubURLMaps)

Loading…
Cancel
Save