github.com/DataDog/datadog-agent/pkg/security/secl@v0.55.0-devel.0.20240517055856-10c4965fea94/validators/version_constraint.go (about) 1 // Unless explicitly stated otherwise all files in this repository are licensed 2 // under the Apache License Version 2.0. 3 // This product includes software developed at Datadog (https://www.datadoghq.com/). 4 // Copyright 2016-present Datadog, Inc. 5 6 // Package validators holds validators related files 7 package validators 8 9 import ( 10 "strings" 11 12 "github.com/Masterminds/semver/v3" 13 ) 14 15 // ValidateAgentVersionConstraint validates an agent version constraint 16 func ValidateAgentVersionConstraint(constraint string) (*semver.Constraints, error) { 17 trimmedConstraint := strings.TrimSpace(constraint) 18 if trimmedConstraint == "" { 19 return semver.NewConstraint("*") 20 } 21 return semver.NewConstraint(trimmedConstraint) 22 }