Merge pull request #16 from prymitive/fixes

fix(config): command line flags are parsed twice, drop automatic parsing
This commit is contained in:
Łukasz Mierzwa
2018-09-12 22:29:40 +01:00
committed by GitHub
3 changed files with 30 additions and 4 deletions

View File

@@ -3,7 +3,6 @@ package config
import (
"bufio"
"bytes"
"flag"
"path"
"strings"
"time"
@@ -80,9 +79,6 @@ func init() {
func (config *configSchema) Read() {
v := viper.New()
pflag.CommandLine.AddGoFlagSet(flag.CommandLine)
pflag.Parse()
err := v.BindPFlags(pflag.CommandLine)
if err != nil {
log.Errorf("Failed to bind flag set to the configuration: %s", err)

View File

@@ -25,6 +25,18 @@ const Grid = observer(
return <FatalError message={alertStore.status.error} />;
}
if (
alertStore.data.upstreams.counters &&
alertStore.data.upstreams.counters.total === 1 &&
alertStore.data.upstreams.counters.healthy === 0 &&
alertStore.data.upstreams.instances[0] &&
alertStore.data.upstreams.instances[0].error !== ""
) {
return (
<FatalError message={alertStore.data.upstreams.instances[0].error} />
);
}
return (
<React.Fragment>
{alertStore.data.upstreams.instances

View File

@@ -33,6 +33,24 @@ describe("<Grid />", () => {
expect(tree.text()).toBe("<AlertGrid />");
});
it("renders FatalError if there's only one upstream and it's unhealthy", () => {
alertStore.data.upstreams = {
counters: { total: 1, healthy: 0, failed: 1 },
instances: [{ name: "am1", uri: "http://am1", error: "error" }]
};
const tree = ShallowGrid();
expect(tree.text()).toBe("<FatalError />");
});
it("renders FatalError if there's only one upstream and it's unhealthy but without any error", () => {
alertStore.data.upstreams = {
counters: { total: 1, healthy: 0, failed: 1 },
instances: [{ name: "am1", uri: "http://am1", error: "" }]
};
const tree = ShallowGrid();
expect(tree.text()).toBe("<AlertGrid />");
});
it("renders UpstreamError for each unhealthy upstream", () => {
alertStore.data.upstreams = {
counters: { total: 3, healthy: 1, failed: 2 },