get.porter.sh/porter@v1.3.0/pkg/schema/constraint.go (about)

     1  package schema
     2  
     3  import (
     4  	"fmt"
     5  
     6  	"github.com/Masterminds/semver/v3"
     7  )
     8  
     9  // MustParseConstraint converts the string value to a semver range. This will panic if it is not a valid constraint and is intended to initialize package variables with well-known schema version values.
    10  // Example:
    11  // var SupportedInstallationSchemaVersion = schema.MustParseConstraint("1.0.x")
    12  func MustParseConstraint(value string) *semver.Constraints {
    13  	c, err := semver.NewConstraint(value)
    14  	if err != nil {
    15  		panic(fmt.Errorf("invalid semver constraint %s: %w", value, err))
    16  	}
    17  	return c
    18  }