Skip to content
This repository was archived by the owner on Aug 26, 2021. It is now read-only.
Open
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
38 changes: 18 additions & 20 deletions pkg/kubelego/configure.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,28 +26,26 @@ func (kl *KubeLego) TlsIgnoreDuplicatedSecrets(tlsSlice []kubelego.Tls) []kubele

output := []kubelego.Tls{}
for key, slice := range tlsBySecret {
if len(slice) == 1 {
output = append(output, slice...)
continue
}

texts := []string{}
for _, elem := range slice {
texts = append(
texts,
fmt.Sprintf(
"ingress %s/%s (hosts: %s)",
elem.IngressMetadata().Namespace,
elem.IngressMetadata().Name,
strings.Join(elem.Hosts(), ", "),
),
output = append(output, slice[0])
if len(slice) > 1 {
texts := []string{}
for _, elem := range slice[1:] {
texts = append(
texts,
fmt.Sprintf(
"ingress %s/%s (hosts: %s)",
elem.IngressMetadata().Namespace,
elem.IngressMetadata().Name,
strings.Join(elem.Hosts(), ", "),
),
)
}
kl.Log().Warnf(
"the secret %s is used multiple times. These linked TLS ingress elements where ignored: %s",
key,
strings.Join(texts, ", "),
)
}
kl.Log().Warnf(
"the secret %s is used multiple times. These linked TLS ingress elements where ignored: %s",
key,
strings.Join(texts, ", "),
)
}

return output
Expand Down
2 changes: 1 addition & 1 deletion pkg/kubelego/configure_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,5 @@ func TestKubeLego_TlsIgnoreDuplicatedSecrets(t *testing.T) {
k := New("test")
input := getTlsExample()
output := k.TlsIgnoreDuplicatedSecrets(input)
assert.EqualValues(t, 2, len(output))
assert.EqualValues(t, 3, len(output))
}