You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
portainer/api/exec/common.go

51 lines
684 B

package exec
import "regexp"
var stackNameNormalizeRegex = regexp.MustCompile("[^-_a-z0-9]+")
type StringSet map[string]bool
func NewStringSet() StringSet {
return make(StringSet)
}
func (s StringSet) Add(x string) {
s[x] = true
}
func (s StringSet) Remove(x string) {
if s.Contains(x) {
delete(s, x)
}
}
func (s StringSet) Contains(x string) bool {
_, ok := s[x]
return ok
}
func (s StringSet) Len() int {
return len(s)
}
func (s StringSet) List() []string {
list := make([]string, s.Len())
i := 0
for k, _ := range s {
list[i] = k
i++
}
return list
}
func (s StringSet) Union(x StringSet) {
if x.Len() != 0 {
for k := range x {
s.Add(k)
}
}
}