github.com/koderover/helm@v2.17.0+incompatible/pkg/chartutil/capabilities.go (about) 1 /* 2 Copyright The Helm Authors. 3 Licensed under the Apache License, Version 2.0 (the "License"); 4 you may not use this file except in compliance with the License. 5 You may obtain a copy of the License at 6 7 http://www.apache.org/licenses/LICENSE-2.0 8 9 Unless required by applicable law or agreed to in writing, software 10 distributed under the License is distributed on an "AS IS" BASIS, 11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 See the License for the specific language governing permissions and 13 limitations under the License. 14 */ 15 //go:generate go run generator/capabilities_default_versions_generate.go 16 17 package chartutil 18 19 import ( 20 "fmt" 21 "runtime" 22 23 "k8s.io/apimachinery/pkg/version" 24 tversion "k8s.io/helm/pkg/proto/hapi/version" 25 ) 26 27 var ( 28 // DefaultVersionSet is the default version set in included in Kubernetes for workloads 29 // Default versions as of Kubernetes 1.14 30 DefaultVersionSet = NewVersionSet(defaultVersions()...) 31 32 // DefaultKubeVersion is the default kubernetes version 33 DefaultKubeVersion = &version.Info{ 34 Major: "1", 35 Minor: "14", 36 GitVersion: "v1.14.0", 37 GoVersion: runtime.Version(), 38 Compiler: runtime.Compiler, 39 Platform: fmt.Sprintf("%s/%s", runtime.GOOS, runtime.GOARCH), 40 } 41 ) 42 43 // Capabilities describes the capabilities of the Kubernetes cluster that Tiller is attached to. 44 type Capabilities struct { 45 // APIVersions list of all supported API versions 46 APIVersions VersionSet 47 // KubeVersion is the Kubernetes version 48 KubeVersion *version.Info 49 // TillerVersion is the Tiller version 50 // 51 // This always comes from pkg/version.GetVersionProto(). 52 TillerVersion *tversion.Version 53 } 54 55 // VersionSet is a set of Kubernetes API versions. 56 type VersionSet map[string]interface{} 57 58 // NewVersionSet creates a new version set from a list of strings. 59 func NewVersionSet(apiVersions ...string) VersionSet { 60 vs := VersionSet{} 61 for _, v := range apiVersions { 62 vs[v] = struct{}{} 63 } 64 return vs 65 } 66 67 // Has returns true if the version string is in the set. 68 // 69 // vs.Has("extensions/v1beta1") 70 func (v VersionSet) Has(apiVersion string) bool { 71 _, ok := v[apiVersion] 72 return ok 73 }