| 54 | } |
| 55 | |
| 56 | func getRuntimeClient(configClient *configuration.Client) *runtime.Client { |
| 57 | runtimeClient := &runtime.Client{} |
| 58 | |
| 59 | _, globalConf, err := configClient.GetGlobalConfiguration("") |
| 60 | if err != nil { |
| 61 | logrus.Warn("Cannot read HAProxy runtime API configuration; resorting to default...") |
| 62 | return nil |
| 63 | } |
| 64 | |
| 65 | if len(globalConf.RuntimeApis) != 0 { |
| 66 | socketList := make([]string, 0, 1) |
| 67 | for _, r := range globalConf.RuntimeApis { |
| 68 | socketList = append(socketList, *r.Address) |
| 69 | } |
| 70 | |
| 71 | if err = runtimeClient.Init(socketList, "", 0); err != nil { |
| 72 | logrus.Warn("Error setting up HAProxy runtime client, not using one") |
| 73 | return nil |
| 74 | } |
| 75 | } else { |
| 76 | logrus.Warn("HAProxy runtime API not configured, not using it") |
| 77 | return nil |
| 78 | } |
| 79 | |
| 80 | return runtimeClient |
| 81 | } |
| 82 | |
| 83 | func getHAProxyClient() *clientnative.HAProxyClient { |
| 84 | client := &clientnative.HAProxyClient{} |