ref(*): Moves packages to internal

These packages are generally used only for logic inside of Helm and
can later be re-exported as needed

Signed-off-by: Taylor Thomas <taylor.thomas@microsoft.com>
pull/6176/head
Taylor Thomas 5 years ago
parent 811e6554b2
commit c9c95ea148

@ -31,10 +31,9 @@ import (
const templateDesc = ` const templateDesc = `
Render chart templates locally and display the output. Render chart templates locally and display the output.
This does not require Helm. However, any values that would normally be Any values that would normally be looked up or retrieved in-cluster will be
looked up or retrieved in-cluster will be faked locally. Additionally, none faked locally. Additionally, none of the server-side testing of chart validity
of the server-side testing of chart validity (e.g. whether an API is supported) (e.g. whether an API is supported) is done.
is done.
` `
func newTemplateCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { func newTemplateCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {

@ -64,4 +64,4 @@ Notable differences from .gitignore:
- The evaluation of escape sequences has not been tested for compatibility - The evaluation of escape sequences has not been tested for compatibility
- There is no support for '\!' as a special leading sequence. - There is no support for '\!' as a special leading sequence.
*/ */
package ignore // import "helm.sh/helm/pkg/ignore" package ignore // import "helm.sh/helm/internal/ignore"

@ -1,6 +1,6 @@
/* /*
Copyright The Helm Authors.go are held by The Go Authors, 2009 and are provided under Copyright (c) for portions of walk.go are held by The Go Authors, 2009 and are
the BSD license. provided under the BSD license.
https://github.com/golang/go/blob/master/LICENSE https://github.com/golang/go/blob/master/LICENSE

@ -1,6 +1,6 @@
/* /*
Copyright The Helm Authors.go are held by The Go Authors, 2009 and are provided under Copyright (c) for portions of walk_test.go are held by The Go Authors, 2009 and are
the BSD license. provided under the BSD license.
https://github.com/golang/go/blob/master/LICENSE https://github.com/golang/go/blob/master/LICENSE

@ -19,8 +19,6 @@ package version // import "helm.sh/helm/internal/version"
import ( import (
"flag" "flag"
"runtime" "runtime"
hversion "helm.sh/helm/pkg/version"
) )
var ( var (
@ -41,6 +39,18 @@ var (
gitTreeState = "" gitTreeState = ""
) )
// BuildInfo describes the compile time information.
type BuildInfo struct {
// Version is the current semver.
Version string `json:"version,omitempty"`
// GitCommit is the git sha1.
GitCommit string `json:"git_commit,omitempty"`
// GitTreeState is the state of the git tree.
GitTreeState string `json:"git_tree_state,omitempty"`
// GoVersion is the version of the Go compiler used.
GoVersion string `json:"go_version,omitempty"`
}
// GetVersion returns the semver string of the version // GetVersion returns the semver string of the version
func GetVersion() string { func GetVersion() string {
if metadata == "" { if metadata == "" {
@ -50,8 +60,8 @@ func GetVersion() string {
} }
// Get returns build info // Get returns build info
func Get() hversion.BuildInfo { func Get() BuildInfo {
v := hversion.BuildInfo{ v := BuildInfo{
Version: GetVersion(), Version: GetVersion(),
GitCommit: gitCommit, GitCommit: gitCommit,
GitTreeState: gitTreeState, GitTreeState: gitTreeState,

@ -44,7 +44,6 @@ import (
"helm.sh/helm/pkg/repo" "helm.sh/helm/pkg/repo"
"helm.sh/helm/pkg/storage" "helm.sh/helm/pkg/storage"
"helm.sh/helm/pkg/storage/driver" "helm.sh/helm/pkg/storage/driver"
"helm.sh/helm/pkg/version"
) )
// releaseNameMaxLen is the maximum length of a release name. // releaseNameMaxLen is the maximum length of a release name.
@ -340,7 +339,7 @@ func (c *Configuration) renderResources(ch *chart.Chart, values chartutil.Values
} }
if ch.Metadata.KubeVersion != "" { if ch.Metadata.KubeVersion != "" {
if !version.IsCompatibleRange(ch.Metadata.KubeVersion, caps.KubeVersion.String()) { if !chartutil.IsCompatibleRange(ch.Metadata.KubeVersion, caps.KubeVersion.String()) {
return hs, b, "", errors.Errorf("chart requires kubernetesVersion: %s which is incompatible with Kubernetes %s", ch.Metadata.KubeVersion, caps.KubeVersion.String()) return hs, b, "", errors.Errorf("chart requires kubernetesVersion: %s which is incompatible with Kubernetes %s", ch.Metadata.KubeVersion, caps.KubeVersion.String())
} }
} }

@ -24,9 +24,9 @@ import (
"github.com/pkg/errors" "github.com/pkg/errors"
"helm.sh/helm/internal/ignore"
"helm.sh/helm/internal/sympath"
"helm.sh/helm/pkg/chart" "helm.sh/helm/pkg/chart"
"helm.sh/helm/pkg/ignore"
"helm.sh/helm/pkg/sympath"
) )
// DirLoader loads a chart from a directory // DirLoader loads a chart from a directory

@ -14,5 +14,21 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
// Package version represents the current version of the project. package chartutil
package version // import "helm.sh/helm/pkg/version"
import "github.com/Masterminds/semver"
// IsCompatibleRange compares a version to a constraint.
// It returns true if the version matches the constraint, and false in all other cases.
func IsCompatibleRange(constraint, ver string) bool {
sv, err := semver.NewVersion(ver)
if err != nil {
return false
}
c, err := semver.NewConstraint(constraint)
if err != nil {
return false
}
return c.Check(sv)
}

@ -15,33 +15,10 @@ limitations under the License.
*/ */
// Package version represents the current version of the project. // Package version represents the current version of the project.
package version // import "helm.sh/helm/pkg/version" package chartutil
import "testing" import "testing"
func TestIsCompatible(t *testing.T) {
tests := []struct {
client string
server string
expected bool
}{
{"v2.0.0-alpha.4", "v2.0.0-alpha.4", true},
{"v2.0.0-alpha.3", "v2.0.0-alpha.4", false},
{"v2.0.0", "v2.0.0-alpha.4", false},
{"v2.0.0-alpha.4", "v2.0.0", false},
{"v2.0.0", "v2.0.1", true},
{"v2.0.1", "v2.0.0", true},
{"v2.0.0", "v2.1.1", true},
{"v2.1.0", "v2.0.1", false},
}
for _, tt := range tests {
if IsCompatible(tt.client, tt.server) != tt.expected {
t.Errorf("expected client(%s) and server(%s) to be %v", tt.client, tt.server, tt.expected)
}
}
}
func TestIsCompatibleRange(t *testing.T) { func TestIsCompatibleRange(t *testing.T) {
tests := []struct { tests := []struct {
constraint string constraint string

@ -20,7 +20,6 @@ import (
"strings" "strings"
"helm.sh/helm/pkg/chart" "helm.sh/helm/pkg/chart"
"helm.sh/helm/pkg/version"
) )
// ProcessDependencies checks through this chart's dependencies, processing accordingly. // ProcessDependencies checks through this chart's dependencies, processing accordingly.
@ -113,7 +112,7 @@ func getAliasDependency(charts []*chart.Chart, dep *chart.Dependency) *chart.Cha
if c.Name() != dep.Name { if c.Name() != dep.Name {
continue continue
} }
if !version.IsCompatibleRange(dep.Version, c.Metadata.Version) { if !IsCompatibleRange(dep.Version, c.Metadata.Version) {
continue continue
} }
@ -144,7 +143,7 @@ func processDependencyEnabled(c *chart.Chart, v map[string]interface{}) error {
Loop: Loop:
for _, existing := range c.Dependencies() { for _, existing := range c.Dependencies() {
for _, req := range c.Metadata.Dependencies { for _, req := range c.Metadata.Dependencies {
if existing.Name() == req.Name && version.IsCompatibleRange(req.Version, existing.Metadata.Version) { if existing.Name() == req.Name && IsCompatibleRange(req.Version, existing.Metadata.Version) {
continue Loop continue Loop
} }
} }

@ -23,7 +23,6 @@ import (
"helm.sh/helm/pkg/chart" "helm.sh/helm/pkg/chart"
"helm.sh/helm/pkg/chart/loader" "helm.sh/helm/pkg/chart/loader"
"helm.sh/helm/pkg/version"
) )
func loadChart(t *testing.T, path string) *chart.Chart { func loadChart(t *testing.T, path string) *chart.Chart {
@ -258,7 +257,7 @@ func TestGetAliasDependency(t *testing.T) {
} }
if req[0].Version != "" { if req[0].Version != "" {
if !version.IsCompatibleRange(req[0].Version, aliasChart.Metadata.Version) { if !IsCompatibleRange(req[0].Version, aliasChart.Metadata.Version) {
t.Fatalf("dependency chart version is not in the compatible range") t.Fatalf("dependency chart version is not in the compatible range")
} }
} }
@ -270,7 +269,7 @@ func TestGetAliasDependency(t *testing.T) {
} }
req[0].Version = "something else which is not in the compatible range" req[0].Version = "something else which is not in the compatible range"
if version.IsCompatibleRange(req[0].Version, aliasChart.Metadata.Version) { if IsCompatibleRange(req[0].Version, aliasChart.Metadata.Version) {
t.Fatalf("dependency chart version which is not in the compatible range should cause a failure other than a success ") t.Fatalf("dependency chart version which is not in the compatible range should cause a failure other than a success ")
} }
} }

@ -26,11 +26,11 @@ import (
"github.com/pkg/errors" "github.com/pkg/errors"
"helm.sh/helm/internal/urlutil"
"helm.sh/helm/pkg/getter" "helm.sh/helm/pkg/getter"
"helm.sh/helm/pkg/helmpath" "helm.sh/helm/pkg/helmpath"
"helm.sh/helm/pkg/provenance" "helm.sh/helm/pkg/provenance"
"helm.sh/helm/pkg/repo" "helm.sh/helm/pkg/repo"
"helm.sh/helm/pkg/urlutil"
) )
// VerificationStrategy describes a strategy for determining whether to verify a chart. // VerificationStrategy describes a strategy for determining whether to verify a chart.

@ -30,14 +30,14 @@ import (
"github.com/pkg/errors" "github.com/pkg/errors"
"sigs.k8s.io/yaml" "sigs.k8s.io/yaml"
"helm.sh/helm/internal/resolver"
"helm.sh/helm/internal/urlutil"
"helm.sh/helm/pkg/chart" "helm.sh/helm/pkg/chart"
"helm.sh/helm/pkg/chart/loader" "helm.sh/helm/pkg/chart/loader"
"helm.sh/helm/pkg/chartutil" "helm.sh/helm/pkg/chartutil"
"helm.sh/helm/pkg/getter" "helm.sh/helm/pkg/getter"
"helm.sh/helm/pkg/helmpath" "helm.sh/helm/pkg/helmpath"
"helm.sh/helm/pkg/repo" "helm.sh/helm/pkg/repo"
"helm.sh/helm/pkg/resolver"
"helm.sh/helm/pkg/urlutil"
) )
// Manager handles the lifecycle of fetching, resolving, and storing dependencies. // Manager handles the lifecycle of fetching, resolving, and storing dependencies.

@ -23,9 +23,9 @@ import (
"github.com/pkg/errors" "github.com/pkg/errors"
"helm.sh/helm/internal/tlsutil"
"helm.sh/helm/internal/urlutil"
"helm.sh/helm/internal/version" "helm.sh/helm/internal/version"
"helm.sh/helm/pkg/tlsutil"
"helm.sh/helm/pkg/urlutil"
) )
// HTTPGetter is the efault HTTP(/S) backend handler // HTTPGetter is the efault HTTP(/S) backend handler

@ -31,10 +31,10 @@ import (
"github.com/pkg/errors" "github.com/pkg/errors"
"sigs.k8s.io/yaml" "sigs.k8s.io/yaml"
"helm.sh/helm/internal/urlutil"
"helm.sh/helm/pkg/chart" "helm.sh/helm/pkg/chart"
"helm.sh/helm/pkg/chart/loader" "helm.sh/helm/pkg/chart/loader"
"helm.sh/helm/pkg/provenance" "helm.sh/helm/pkg/provenance"
"helm.sh/helm/pkg/urlutil"
) )
var indexPath = "index.yaml" var indexPath = "index.yaml"

@ -1,65 +0,0 @@
/*
Copyright The Helm Authors.
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 version // import "helm.sh/helm/pkg/version"
import (
"fmt"
"strings"
"github.com/Masterminds/semver"
)
// IsCompatible tests if a client and server version are compatible.
func IsCompatible(client, server string) bool {
if isUnreleased(client) || isUnreleased(server) {
return true
}
cv, err := semver.NewVersion(client)
if err != nil {
return false
}
sv, err := semver.NewVersion(server)
if err != nil {
return false
}
constraint := fmt.Sprintf("^%d.%d.x", cv.Major(), cv.Minor())
if cv.Prerelease() != "" || sv.Prerelease() != "" {
constraint = cv.String()
}
return IsCompatibleRange(constraint, server)
}
// IsCompatibleRange compares a version to a constraint.
// It returns true if the version matches the constraint, and false in all other cases.
func IsCompatibleRange(constraint, ver string) bool {
sv, err := semver.NewVersion(ver)
if err != nil {
return false
}
c, err := semver.NewConstraint(constraint)
if err != nil {
return false
}
return c.Check(sv)
}
func isUnreleased(v string) bool {
return strings.HasSuffix(v, "unreleased")
}

@ -1,29 +0,0 @@
/*
Copyright The Helm Authors.
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 version // import "helm.sh/helm/pkg/version"
// BuildInfo describes the compile time information.
type BuildInfo struct {
// Version is the current semver.
Version string `json:"version,omitempty"`
// GitCommit is the git sha1.
GitCommit string `json:"git_commit,omitempty"`
// GitTreeState is the state of the git tree.
GitTreeState string `json:"git_tree_state,omitempty"`
// GoVersion is the version of the Go compiler used.
GoVersion string `json:"go_version,omitempty"`
}
Loading…
Cancel
Save