diff --git a/chart/chart.go b/chart/chart.go index 2f0a35c42..0c8f377d6 100644 --- a/chart/chart.go +++ b/chart/chart.go @@ -1,3 +1,19 @@ +/* +Copyright 2015 The Kubernetes Authors All rights reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +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. +See the License for the specific language governing permissions and +limitations under the License. +*/ + package chart import ( diff --git a/chart/chart_test.go b/chart/chart_test.go index 5a16dc6bf..83289c916 100644 --- a/chart/chart_test.go +++ b/chart/chart_test.go @@ -1,3 +1,19 @@ +/* +Copyright 2015 The Kubernetes Authors All rights reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +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. +See the License for the specific language governing permissions and +limitations under the License. +*/ + package chart import ( diff --git a/chart/chartfile.go b/chart/chartfile.go index 821f941be..e3b0671c6 100644 --- a/chart/chartfile.go +++ b/chart/chartfile.go @@ -1,3 +1,19 @@ +/* +Copyright 2015 The Kubernetes Authors All rights reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +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. +See the License for the specific language governing permissions and +limitations under the License. +*/ + package chart import ( diff --git a/chart/chartfile_test.go b/chart/chartfile_test.go index d1d21d3f3..b5e46dfa6 100644 --- a/chart/chartfile_test.go +++ b/chart/chartfile_test.go @@ -1,3 +1,19 @@ +/* +Copyright 2015 The Kubernetes Authors All rights reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +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. +See the License for the specific language governing permissions and +limitations under the License. +*/ + package chart import ( diff --git a/chart/doc.go b/chart/doc.go index 521446e07..bc0ba2ca2 100644 --- a/chart/doc.go +++ b/chart/doc.go @@ -1,3 +1,19 @@ +/* +Copyright 2015 The Kubernetes Authors All rights reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +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. +See the License for the specific language governing permissions and +limitations under the License. +*/ + /* Package chart implements the Chart format. This package provides tools for working with the Chart format, including the diff --git a/url/url.go b/chart/locator.go similarity index 81% rename from url/url.go rename to chart/locator.go index 37d2f9f4a..7619ec31e 100644 --- a/url/url.go +++ b/chart/locator.go @@ -14,17 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -/* package URL handles Helm-DM URLs - -Helm uses three kinds of URLs: - - - Fully qualified (long) names: https://example.com/foo/bar-1.2.3.tgz - - Short names: helm:example.com/foo/bar#1.2.3 - - Local names: file:///foo/bar - -This package provides utilities for working with this type of URL. -*/ -package url +package chart import ( "errors" @@ -35,10 +25,10 @@ import ( ) // ErrLocal indicates that a local URL was used as a remote URL. -var ErrLocal = errors.New("cannot use local URL as remote") +var ErrLocal = errors.New("cannot use local Locator as remote") // ErrRemote indicates that a remote URL was used as a local URL. -var ErrRemote = errors.New("cannot use remote URL as local") +var ErrRemote = errors.New("cannot use remote Locator as local") const ( SchemeHTTP = "http" @@ -60,7 +50,7 @@ func init() { tnregexp = regexp.MustCompile("^" + TarNameRegex + "$") } -type URL struct { +type Locator struct { // The scheme of the URL. Typically one of http, https, helm, or file. Scheme string // The host information, if applicable. @@ -80,18 +70,7 @@ type URL struct { original string } -func Parse(path string) (*URL, error) { - - // TODO: Do we want to support file:///foo/bar.tgz? - //if strings.HasPrefix(path, SchemeFile+":") { - //path := strings.TrimPrefix(path, SchemeFile+":") - //return &URL{ - //LocalRef: filepath.Clean(path), - //isLocal: true, - //original: path, - //}, nil - //} - +func Parse(path string) (*Locator, error) { u, err := url.Parse(path) if err != nil { return nil, err @@ -104,7 +83,7 @@ func Parse(path string) (*URL, error) { return nil, fmt.Errorf("both bucket and chart name are required in %s: %s", path, u.Path) } // Need to parse opaque data into bucket and chart. - return &URL{ + return &Locator{ Scheme: u.Scheme, Host: parts[0], Bucket: parts[1], @@ -125,7 +104,7 @@ func Parse(path string) (*URL, error) { return nil, err } - return &URL{ + return &Locator{ Scheme: u.Scheme, Host: u.Host, Bucket: parts[1], @@ -134,7 +113,7 @@ func Parse(path string) (*URL, error) { original: path, }, nil case SchemeFile: - return &URL{ + return &Locator{ LocalRef: u.Path, isLocal: true, original: path, @@ -143,7 +122,7 @@ func Parse(path string) (*URL, error) { // In this case... // - if the path is relative or absolute, return it as-is. // - if it's a URL of an unknown scheme, return it as is. - return &URL{ + return &Locator{ LocalRef: path, isLocal: true, original: path, @@ -153,21 +132,21 @@ func Parse(path string) (*URL, error) { } // IsLocal returns true if this is a local path. -func (u *URL) IsLocal() bool { +func (u *Locator) IsLocal() bool { return u.isLocal } // Local returns a local version of the path. // // This will return an error if the URL does not reference a local chart. -func (u *URL) Local() (string, error) { +func (u *Locator) Local() (string, error) { return u.LocalRef, nil } // Short returns a short form URL. // // This will return an error if the URL references a local chart. -func (u *URL) Short() (string, error) { +func (u *Locator) Short() (string, error) { if u.IsLocal() { return "", ErrLocal } @@ -184,7 +163,7 @@ func (u *URL) Short() (string, error) { // If secure is true, this will return an HTTPS URL, otherwise HTTP. // // This will return an error if the URL references a local chart. -func (u *URL) Long(secure bool) (string, error) { +func (u *Locator) Long(secure bool) (string, error) { if u.IsLocal() { return "", ErrLocal } diff --git a/url/url_test.go b/chart/locator_test.go similarity index 91% rename from url/url_test.go rename to chart/locator_test.go index b93ea47c6..cf87d6eb4 100644 --- a/url/url_test.go +++ b/chart/locator_test.go @@ -14,17 +14,17 @@ See the License for the specific language governing permissions and limitations under the License. */ -package url +package chart import ( "testing" ) func TestParse(t *testing.T) { - tests := map[string]URL{ - "helm:host/bucket/name#1.2.3": URL{Scheme: "helm", Host: "host", Bucket: "bucket", Name: "name", Version: "1.2.3"}, - "https://host/bucket/name-1.2.3.tgz": URL{Scheme: "https", Host: "host", Bucket: "bucket", Name: "name", Version: "1.2.3"}, - "http://host/bucket/name-1.2.3.tgz": URL{Scheme: "http", Host: "host", Bucket: "bucket", Name: "name", Version: "1.2.3"}, + 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"}, } for start, expect := range tests {