Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion jwt/grp/groupcontext.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
TenantPrefix: Tn = Tenant-Prefix
GroupType: Pg = PermissionGroup
SecondLevelOU: Srv
Referenz: App (App-Permission)
Reference: App (App-Permission)
innerGroupName: kaas-clustername-namespace-role
Permission: Full | Mod | Read

Expand Down
2 changes: 1 addition & 1 deletion pkg/genericcli/generic.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
// U is the update request for an entity.
// R is the response object of an entity.
type GenericCLI[C any, U any, R any] struct {
// internally we map everyhing to multi arg cli to reduce code redundance
// internally we map everything to multi arg cli to reduce code redundance
multiCLI *MultiArgGenericCLI[C, U, R]
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/healthstatus/delayed-error-check_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func TestDelayErrors(t *testing.T) {
},
},
{
name: "ignores first error after intial success",
name: "ignores first error after initial success",
hc: DelayErrors(log, 1, &recordedCheck{
name: "record",
states: []currentState{
Expand Down
9 changes: 9 additions & 0 deletions pkg/tag/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@ func NewTagMap(labels []string) TagMap {
return result
}

// Slice returns the tagMap as a slice, duplicates removed
func (tm TagMap) Slice() []string {
var result []string
for k, v := range tm {
result = append(result, fmt.Sprintf("%s=%s", k, v))
}
return result
}

// Contains returns true when the given key is contained in the label map.
func (tm TagMap) Contains(key, value string) bool {
v, ok := tm[key]
Expand Down
26 changes: 26 additions & 0 deletions pkg/tag/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/google/go-cmp/cmp"
"github.com/metal-stack/metal-lib/pkg/testcommon"
"github.com/stretchr/testify/require"
)

func TestTagMap_Contains(t *testing.T) {
Expand Down Expand Up @@ -176,3 +177,28 @@ func TestTagMap_Get(t *testing.T) {
})
}
}

func TestTagMap_Slice(t *testing.T) {
tests := []struct {
name string
tm TagMap
want []string
}{
{
name: "no duplicates",
tm: NewTagMap([]string{"color=red", "size=small"}),
want: []string{"color=red", "size=small"},
},
{
name: "with duplicates",
tm: NewTagMap([]string{"color=red", "color=red", "size=small"}),
want: []string{"color=red", "size=small"},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := tt.tm.Slice()
require.ElementsMatch(t, tt.want, got)
})
}
}