mirror of
https://github.com/juanfont/headscale.git
synced 2025-08-11 15:27:37 +00:00
refact: use generics for contains functions
This commit is contained in:
@@ -372,12 +372,12 @@ func nodesToPtables(
|
||||
tags += "," + tag
|
||||
}
|
||||
for _, tag := range machine.InvalidTags {
|
||||
if !containsString(machine.ForcedTags, tag) {
|
||||
if !contains(machine.ForcedTags, tag) {
|
||||
tags += "," + pterm.LightRed(tag)
|
||||
}
|
||||
}
|
||||
for _, tag := range machine.ValidTags {
|
||||
if !containsString(machine.ForcedTags, tag) {
|
||||
if !contains(machine.ForcedTags, tag) {
|
||||
tags += "," + pterm.LightGreen(tag)
|
||||
}
|
||||
}
|
||||
|
@@ -10,6 +10,7 @@ import (
|
||||
"net/url"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -565,9 +566,9 @@ func GetFileMode(key string) fs.FileMode {
|
||||
return fs.FileMode(mode)
|
||||
}
|
||||
|
||||
func containsString(ss []string, s string) bool {
|
||||
for _, v := range ss {
|
||||
if v == s {
|
||||
func contains[T string](ts []T, t T) bool {
|
||||
for _, v := range ts {
|
||||
if reflect.DeepEqual(v,t) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user