From 8672452033def01f350a00fc30aa8ea9b0b9d569 Mon Sep 17 00:00:00 2001 From: ston1th Date: Sat, 10 Apr 2021 16:16:45 +0200 Subject: [PATCH] fixed another reload bug --- pkg/haproxy/config.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pkg/haproxy/config.go b/pkg/haproxy/config.go index 8215565..365e67b 100644 --- a/pkg/haproxy/config.go +++ b/pkg/haproxy/config.go @@ -1,6 +1,9 @@ package haproxy -import "encoding/json" +import ( + "encoding/json" + "sort" +) type Config struct { LoadBalancers []*LoadBalancer @@ -15,6 +18,11 @@ func NewConfig(m map[string][]byte) (c Config, err error) { } c.LoadBalancers = append(c.LoadBalancers, lb) } + if len(c.LoadBalancers) > 1 { + sort.SliceStable(c.LoadBalancers, func(i, j int) bool { + return c.LoadBalancers[i].Name < c.LoadBalancers[j].Name + }) + } return }