github.com/hashicorp/nomad/api@v0.0.0-20240306165712-3193ac204f65/constraint.go (about)

     1  // Copyright (c) HashiCorp, Inc.
     2  // SPDX-License-Identifier: MPL-2.0
     3  
     4  package api
     5  
     6  const (
     7  	ConstraintDistinctProperty  = "distinct_property"
     8  	ConstraintDistinctHosts     = "distinct_hosts"
     9  	ConstraintRegex             = "regexp"
    10  	ConstraintVersion           = "version"
    11  	ConstraintSemver            = "semver"
    12  	ConstraintSetContains       = "set_contains"
    13  	ConstraintSetContainsAll    = "set_contains_all"
    14  	ConstraintSetContainsAny    = "set_contains_any"
    15  	ConstraintAttributeIsSet    = "is_set"
    16  	ConstraintAttributeIsNotSet = "is_not_set"
    17  )
    18  
    19  // Constraint is used to serialize a job placement constraint.
    20  type Constraint struct {
    21  	LTarget string `hcl:"attribute,optional"`
    22  	RTarget string `hcl:"value,optional"`
    23  	Operand string `hcl:"operator,optional"`
    24  }
    25  
    26  // NewConstraint generates a new job placement constraint.
    27  func NewConstraint(left, operand, right string) *Constraint {
    28  	return &Constraint{
    29  		LTarget: left,
    30  		RTarget: right,
    31  		Operand: operand,
    32  	}
    33  }