github.com/diafour/helm@v3.0.0-beta.3+incompatible/pkg/gates/gates.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 gates 17 18 import ( 19 "fmt" 20 "os" 21 ) 22 23 // Gate is the name of the feature gate. 24 type Gate string 25 26 // String returns the string representation of this feature gate. 27 func (g Gate) String() string { 28 return string(g) 29 } 30 31 // IsEnabled determines whether a certain feature gate is enabled. 32 func (g Gate) IsEnabled() bool { 33 return os.Getenv(string(g)) != "" 34 } 35 36 func (g Gate) Error() error { 37 return fmt.Errorf("this feature has been marked as experimental and is not enabled by default. Please set %s=1 in your environment to use this feature", g.String()) 38 }