github.com/doitroot/helm@v3.0.0-beta.3+incompatible/pkg/chartutil/compatible.go (about) 1 /* 2 Copyright The Helm Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package chartutil 18 19 import "github.com/Masterminds/semver" 20 21 // IsCompatibleRange compares a version to a constraint. 22 // It returns true if the version matches the constraint, and false in all other cases. 23 func IsCompatibleRange(constraint, ver string) bool { 24 sv, err := semver.NewVersion(ver) 25 if err != nil { 26 return false 27 } 28 29 c, err := semver.NewConstraint(constraint) 30 if err != nil { 31 return false 32 } 33 return c.Check(sv) 34 }