github.com/Beeketing/helm@v2.12.1+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  
    16  package chartutil
    17  
    18  import (
    19  	"fmt"
    20  	"runtime"
    21  
    22  	"k8s.io/apimachinery/pkg/version"
    23  	tversion "k8s.io/helm/pkg/proto/hapi/version"
    24  )
    25  
    26  var (
    27  	// DefaultVersionSet is the default version set, which includes only Core V1 ("v1").
    28  	DefaultVersionSet = NewVersionSet("v1")
    29  
    30  	// DefaultKubeVersion is the default kubernetes version
    31  	DefaultKubeVersion = &version.Info{
    32  		Major:      "1",
    33  		Minor:      "9",
    34  		GitVersion: "v1.9.0",
    35  		GoVersion:  runtime.Version(),
    36  		Compiler:   runtime.Compiler,
    37  		Platform:   fmt.Sprintf("%s/%s", runtime.GOOS, runtime.GOARCH),
    38  	}
    39  )
    40  
    41  // Capabilities describes the capabilities of the Kubernetes cluster that Tiller is attached to.
    42  type Capabilities struct {
    43  	// List of all supported API versions
    44  	APIVersions VersionSet
    45  	// KubeVersion is the Kubernetes version
    46  	KubeVersion *version.Info
    47  	// TillerVersion is the Tiller version
    48  	//
    49  	// This always comes from pkg/version.GetVersionProto().
    50  	TillerVersion *tversion.Version
    51  }
    52  
    53  // VersionSet is a set of Kubernetes API versions.
    54  type VersionSet map[string]interface{}
    55  
    56  // NewVersionSet creates a new version set from a list of strings.
    57  func NewVersionSet(apiVersions ...string) VersionSet {
    58  	vs := VersionSet{}
    59  	for _, v := range apiVersions {
    60  		vs[v] = struct{}{}
    61  	}
    62  	return vs
    63  }
    64  
    65  // Has returns true if the version string is in the set.
    66  //
    67  //	vs.Has("extensions/v1beta1")
    68  func (v VersionSet) Has(apiVersion string) bool {
    69  	_, ok := v[apiVersion]
    70  	return ok
    71  }