// NewGeneralToolsConstraint returns a ToolsConstraint for tools with matching major/minor version numbers.
326871
func NewGeneralToolsConstraint(majorVersion, minorVersion int, params simplestreams.LookupParams) *ToolsConstraint {
	return &ToolsConstraint{LookupParams: params, Version: version.Zero,
		MajorVersion: majorVersion, MinorVersion: minorVersion}
}
735633
func (s *Backup) SetToolsVersion(v string) *Backup {
	s.ToolsVersion = &v
	return s
}
93213
func (e *extractorImpl) GetConstraints(applications ...string) ([]constraints.Value, error) {
	return e.application.GetConstraints(applications...)
}
1272371
func (j *Job) Constrain(c *Constraint) *Job {
	j.Constraints = append(j.Constraints, c)
	return j
}
901340
func NewConstraint() *constraint {
	return &constraint{
		Handler: admission.NewHandler(admission.Create, admission.Update),
	}
}
558628
func NewInternalAPIEngine(g *GlobalContext) (*InternalAPIEngine, error) {
	cliConfig, err := genClientConfigForInternalAPI(g)
	if err != nil {
		return nil, err
	}

	i := &InternalAPIEngine{
		BaseAPIEngine{
			config:       cliConfig,
			clients:      make(map[int]*Client),
			Contextified: NewContextified(g),
		},
	}
	return i, nil
}
515275
func (r *Application) AddConstraint(constraints ...string) *Application {
	if r.Constraints == nil {
		r.EmptyConstraints()
	}

	c := *r.Constraints
	c = append(c, constraints)
	r.Constraints = &c

	return r
}
674152
func MustCompile(constraint string) go_version.Constraints {
	verCheck, err := Compile(constraint)
	if err != nil {
		panic(fmt.Errorf("Cannot compile go-version constraint '%s' %s", constraint, err))
	}
	return verCheck
}
606048
func (c *Client) SetModelConstraints(args params.SetConstraints) error {
	if err := c.checkCanWrite(); err != nil {
		return err
	}

	if err := c.check.ChangeAllowed(); err != nil {
		return errors.Trace(err)
	}
	return c.api.stateAccessor.SetModelConstraints(args.Constraints)
}
84644
func (s *AutoScalingPolicyDescription) SetConstraints(v *ScalingConstraints) *AutoScalingPolicyDescription {
	s.Constraints = v
	return s
}
521523
func (db *deviceBackend) DeviceConstraints(id string) (map[string]DeviceConstraints, error) {
	devices, err := readDeviceConstraints(db.mb, id)
	if err == nil {
		return devices, nil
	} else if errors.IsNotFound(err) {
		return map[string]DeviceConstraints{}, nil
	}
	return nil, err
}
100379
func (j *AuroraJob) AddLimitConstraint(name string, limit int32) Job {
	j.jobConfig.TaskConfig.Constraints = append(j.jobConfig.TaskConfig.Constraints,
		&aurora.Constraint{
			Name: name,
			Constraint: &aurora.TaskConstraint{
				Value: nil,
				Limit: &aurora.LimitConstraint{Limit: limit},
			},
		})

	return j
}
794791
func New(store *store.MemoryStore) *ConstraintEnforcer {
	return &ConstraintEnforcer{
		store:    store,
		stopChan: make(chan struct{}),
		doneChan: make(chan struct{}),
	}
}
90962
func (api *APIBase) SetConstraints(args params.SetConstraints) error {
	if err := api.checkCanWrite(); err != nil {
		return err
	}
	if err := api.check.ChangeAllowed(); err != nil {
		return errors.Trace(err)
	}
	app, err := api.backend.Application(args.ApplicationName)
	if err != nil {
		return err
	}
	return app.SetConstraints(args.Constraints)
}
1090321
func UniqueConstraint(t *testing.T, repo grimoire.Repo) {
	extra1 := Extra{}
	extra2 := Extra{}
	repo.From(extras).Set("slug", "slug1").MustInsert(&extra1)
	repo.From(extras).Set("slug", "slug2").MustInsert(&extra2)

	t.Run("UniqueConstraint", func(t *testing.T) {
		// inserting
		err := repo.From(extras).Set("slug", extra1.Slug).Insert(nil)
		assertConstraint(t, err, errors.UniqueConstraint, "slug")

		// updating
		err = repo.From(extras).Find(extra2.ID).Set("slug", extra1.Slug).Update(nil)
		assertConstraint(t, err, errors.UniqueConstraint, "slug")
	})
}
374447
func NewConstraint(exp string) (*Constraint, error) {
	sep := ""
	constraint := &Constraint{}

	switch {
	case strings.Contains(exp, "=="):
		sep = "=="
		constraint.MustMatch = true
	case strings.Contains(exp, "!="):
		sep = "!="
		constraint.MustMatch = false
	default:
		return nil, errors.New("constraint expression missing valid operator: '==' or '!='")
	}

	kv := strings.SplitN(exp, sep, 2)
	if len(kv) == 2 {
		// At the moment, it only supports tags
		if kv[0] != "tag" {
			return nil, errors.New("constraint must be tag-based. Syntax: tag==us-*")
		}

		constraint.Key = kv[0]
		constraint.Regex = kv[1]
		return constraint, nil
	}

	return nil, fmt.Errorf("incorrect constraint expression: %s", exp)
}
339728
func OptionGeneric(generic map[string]interface{}) SandboxOption {
	return func(sb *sandbox) {
		if sb.config.generic == nil {
			sb.config.generic = make(map[string]interface{}, len(generic))
		}
		for k, v := range generic {
			sb.config.generic[k] = v
		}
	}
}