diff --git a/cmd/dm/dm.go b/cmd/dm/dm.go index 93c91e707..9e33bf5a9 100644 --- a/cmd/dm/dm.go +++ b/cmd/dm/dm.go @@ -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 { diff --git a/cmd/expandybird/main.go b/cmd/expandybird/main.go index d067bbe5b..332ffa33d 100644 --- a/cmd/expandybird/main.go +++ b/cmd/expandybird/main.go @@ -6,7 +6,7 @@ you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 - + Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/cmd/expandybird/service/service.go b/cmd/expandybird/service/service.go index 384083ecb..e12fdda8a 100644 --- a/cmd/expandybird/service/service.go +++ b/cmd/expandybird/service/service.go @@ -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" @@ -86,7 +86,7 @@ func NewExpansionHandler(backend expander.Expander) restful.RouteFunction { } util.LogHandlerExit("expandybird", http.StatusOK, "OK", resp.ResponseWriter) - message := fmt.Sprintf("\nConfig:\n%s\nLayout:\n%s\n", response.Config, response.Layout) + message := fmt.Sprintf("\nConfig:\n%s\nLayout:\n%s\n", response.Config, response.Layout) util.LogHandlerText("expandybird", message) resp.WriteEntity(response) } diff --git a/cmd/manager/deployments.go b/cmd/manager/deployments.go index ae174763b..993dc1678 100644 --- a/cmd/manager/deployments.go +++ b/cmd/manager/deployments.go @@ -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" ) diff --git a/cmd/manager/manager/deployer.go b/cmd/manager/manager/deployer.go index e47b2c5f5..9c9c70190 100644 --- a/cmd/manager/manager/deployer.go +++ b/cmd/manager/manager/deployer.go @@ -6,7 +6,7 @@ you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 - + Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/cmd/manager/manager/deployer_test.go b/cmd/manager/manager/deployer_test.go index e1ee1b340..6947119ae 100644 --- a/cmd/manager/manager/deployer_test.go +++ b/cmd/manager/manager/deployer_test.go @@ -6,7 +6,7 @@ you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 - + Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -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" ) diff --git a/cmd/manager/manager/expander_test.go b/cmd/manager/manager/expander_test.go index 423686698..6e803e6ea 100644 --- a/cmd/manager/manager/expander_test.go +++ b/cmd/manager/manager/expander_test.go @@ -6,7 +6,7 @@ you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 - + Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -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", }, diff --git a/cmd/manager/manager/manager.go b/cmd/manager/manager/manager.go index 827142e5b..e62488256 100644 --- a/cmd/manager/manager/manager.go +++ b/cmd/manager/manager/manager.go @@ -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" ) diff --git a/cmd/manager/manager/manager_test.go b/cmd/manager/manager/manager_test.go index 0a04d167b..3065f281a 100644 --- a/cmd/manager/manager/manager_test.go +++ b/cmd/manager/manager/manager_test.go @@ -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") diff --git a/cmd/manager/manager/typeresolver.go b/cmd/manager/manager/typeresolver.go index 67a9f63f4..449003fee 100644 --- a/cmd/manager/manager/typeresolver.go +++ b/cmd/manager/manager/typeresolver.go @@ -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 diff --git a/cmd/manager/manager/typeresolver_test.go b/cmd/manager/manager/typeresolver_test.go index 1fcd4f499..0c1b1719c 100644 --- a/cmd/manager/manager/typeresolver_test.go +++ b/cmd/manager/manager/typeresolver_test.go @@ -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) diff --git a/cmd/manager/repository/persistent/persistent.go b/cmd/manager/repository/persistent/persistent.go index 0ab0ec825..f5a9e0ca9 100644 --- a/cmd/manager/repository/persistent/persistent.go +++ b/cmd/manager/repository/persistent/persistent.go @@ -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" diff --git a/cmd/manager/repository/test_common.go b/cmd/manager/repository/test_common.go index a2b5fb8c2..7f20b7d0c 100644 --- a/cmd/manager/repository/test_common.go +++ b/cmd/manager/repository/test_common.go @@ -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", diff --git a/cmd/manager/repository/transient/transient.go b/cmd/manager/repository/transient/transient.go index 0125f762b..4655709c7 100644 --- a/cmd/manager/repository/transient/transient.go +++ b/cmd/manager/repository/transient/transient.go @@ -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. diff --git a/cmd/resourcifier/configurations.go b/cmd/resourcifier/configurations.go index 272008bef..f2d9f93dc 100644 --- a/cmd/resourcifier/configurations.go +++ b/cmd/resourcifier/configurations.go @@ -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" diff --git a/cmd/resourcifier/main.go b/cmd/resourcifier/main.go index 62b94d928..7d82e983a 100644 --- a/cmd/resourcifier/main.go +++ b/cmd/resourcifier/main.go @@ -6,7 +6,7 @@ you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 - + Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/pkg/chart/locator_test.go b/pkg/chart/locator_test.go index cf87d6eb4..67bfcf751 100644 --- a/pkg/chart/locator_test.go +++ b/pkg/chart/locator_test.go @@ -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 { diff --git a/pkg/registry/registryprovider.go b/pkg/registry/registryprovider.go index 87e9d7261..c1f356c8a 100644 --- a/pkg/registry/registryprovider.go +++ b/pkg/registry/registryprovider.go @@ -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} diff --git a/pkg/registry/registryprovider_test.go b/pkg/registry/registryprovider_test.go index bd41b354d..968d51a8a 100644 --- a/pkg/registry/registryprovider_test.go +++ b/pkg/registry/registryprovider_test.go @@ -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) diff --git a/pkg/util/httpclient_test.go b/pkg/util/httpclient_test.go index c7b7eef46..001ebccc4 100644 --- a/pkg/util/httpclient_test.go +++ b/pkg/util/httpclient_test.go @@ -6,7 +6,7 @@ you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 - + Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/pkg/util/kubernetesutil_test.go b/pkg/util/kubernetesutil_test.go index 04304a43d..0f1513135 100644 --- a/pkg/util/kubernetesutil_test.go +++ b/pkg/util/kubernetesutil_test.go @@ -6,7 +6,7 @@ you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 - + Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.