github.com/migueleliasweb/helm@v2.6.1+incompatible/pkg/chartutil/capabilities.go (about)

     1  /*
     2  Copyright 2017 The Kubernetes Authors All rights reserved.
     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  	"k8s.io/apimachinery/pkg/version"
    20  	tversion "k8s.io/helm/pkg/proto/hapi/version"
    21  )
    22  
    23  // DefaultVersionSet is the default version set, which includes only Core V1 ("v1").
    24  var DefaultVersionSet = NewVersionSet("v1")
    25  
    26  // Capabilities describes the capabilities of the Kubernetes cluster that Tiller is attached to.
    27  type Capabilities struct {
    28  	// List of all supported API versions
    29  	APIVersions VersionSet
    30  	// KubeVerison is the Kubernetes version
    31  	KubeVersion *version.Info
    32  	// TillerVersion is the Tiller version
    33  	//
    34  	// This always comes from pkg/version.GetVersionProto().
    35  	TillerVersion *tversion.Version
    36  }
    37  
    38  // VersionSet is a set of Kubernetes API versions.
    39  type VersionSet map[string]interface{}
    40  
    41  // NewVersionSet creates a new version set from a list of strings.
    42  func NewVersionSet(apiVersions ...string) VersionSet {
    43  	vs := VersionSet{}
    44  	for _, v := range apiVersions {
    45  		vs[v] = struct{}{}
    46  	}
    47  	return vs
    48  }
    49  
    50  // Has returns true if the version string is in the set.
    51  //
    52  //	vs.Has("extensions/v1beta1")
    53  func (v VersionSet) Has(apiVersion string) bool {
    54  	_, ok := v[apiVersion]
    55  	return ok
    56  }