Skip to content

Commit

Permalink
test(unit): fix flaky "should return error when admin address is not …
Browse files Browse the repository at this point in the history
…allowed" test (#7933)

fix(kuma-cp): use SortedKeys function in error msg

Signed-off-by: Ilya Lobkov <[email protected]>
  • Loading branch information
lobkovilya authored Sep 29, 2023
1 parent aa2d3c5 commit 0c6694e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions pkg/xds/generator/admin_proxy_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import (

"github.com/asaskevich/govalidator"
"github.com/pkg/errors"
"golang.org/x/exp/maps"

core_xds "github.com/kumahq/kuma/pkg/core/xds"
util_maps "github.com/kumahq/kuma/pkg/util/maps"
xds_context "github.com/kumahq/kuma/pkg/xds/context"
envoy_common "github.com/kumahq/kuma/pkg/xds/envoy"
envoy_clusters "github.com/kumahq/kuma/pkg/xds/envoy/clusters"
Expand Down Expand Up @@ -60,7 +60,7 @@ func (g AdminProxyGenerator) Generate(ctx context.Context, xdsCtx xds_context.Co
envoyAdminClusterName := envoy_names.GetEnvoyAdminClusterName()
adminAddress := proxy.Metadata.GetAdminAddress()
if _, ok := adminAddressAllowedValues[adminAddress]; !ok {
return nil, errors.Errorf("envoy admin cluster is not allowed to have addresses other than %v", maps.Keys(adminAddressAllowedValues))
return nil, errors.Errorf("envoy admin cluster is not allowed to have addresses other than %v", util_maps.SortedKeys(adminAddressAllowedValues))
}
switch adminAddress {
case "", "0.0.0.0":
Expand Down
2 changes: 1 addition & 1 deletion pkg/xds/generator/admin_proxy_generator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,6 @@ var _ = Describe("AdminProxyGenerator", func() {
// when
_, err := generator.Generate(context.Background(), ctx, proxy)
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(Equal(`envoy admin cluster is not allowed to have addresses other than [127.0.0.1 0.0.0.0 ::1 :: ]`))
Expect(err.Error()).To(Equal(`envoy admin cluster is not allowed to have addresses other than [ 0.0.0.0 127.0.0.1 :: ::1]`))
})
})

0 comments on commit 0c6694e

Please sign in to comment.