mirror of https://github.com/status-im/consul.git
[1.8.x] command: when generating envoy bootstrap configs to stdout do not mix informational logs into the json (#9985)
Backport of #9980 to `1.8.x` Conflicts: - just the generated golden command/ files - envoy.go and envoy_test.go
This commit is contained in:
parent
0d0f14f901
commit
89e4e3d534
|
@ -0,0 +1,3 @@
|
|||
```release-note:bug
|
||||
command: when generating envoy bootstrap configs to stdout do not mix informational logs into the json
|
||||
```
|
|
@ -23,13 +23,6 @@ import (
|
|||
)
|
||||
|
||||
func New(ui cli.Ui) *cmd {
|
||||
ui = &cli.PrefixedUi{
|
||||
OutputPrefix: "==> ",
|
||||
InfoPrefix: " ",
|
||||
ErrorPrefix: "==> ",
|
||||
Ui: ui,
|
||||
}
|
||||
|
||||
c := &cmd{UI: ui}
|
||||
c.init()
|
||||
return c
|
||||
|
@ -352,7 +345,11 @@ func (c *cmd) run(args []string) int {
|
|||
return 1
|
||||
}
|
||||
|
||||
c.UI.Output(fmt.Sprintf("Registered service: %s", svc.Name))
|
||||
if !c.bootstrap {
|
||||
// We need stdout to be reserved exclusively for the JSON blob, so
|
||||
// we omit logging this to Info which also writes to stdout.
|
||||
c.UI.Info(fmt.Sprintf("Registered service: %s", svc.Name))
|
||||
}
|
||||
}
|
||||
|
||||
// Generate config
|
||||
|
@ -364,7 +361,7 @@ func (c *cmd) run(args []string) int {
|
|||
|
||||
if c.bootstrap {
|
||||
// Just output it and we are done
|
||||
os.Stdout.Write(bootstrapJson)
|
||||
c.UI.Output(string(bootstrapJson))
|
||||
return 0
|
||||
}
|
||||
|
||||
|
@ -523,7 +520,6 @@ func (c *cmd) grpcAddress(httpCfg *api.Config) (GRPC, error) {
|
|||
// This is the dev mode default and recommended production setting if
|
||||
// enabled.
|
||||
port = 8502
|
||||
c.UI.Info(fmt.Sprintf("Defaulting to grpc port = %d", port))
|
||||
}
|
||||
addr = fmt.Sprintf("localhost:%v", port)
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@ package envoy
|
|||
import (
|
||||
"encoding/json"
|
||||
"flag"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"io/ioutil"
|
||||
"net"
|
||||
"net/http"
|
||||
|
@ -13,12 +12,14 @@ import (
|
|||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/mitchellh/cli"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/hashicorp/consul/agent"
|
||||
"github.com/hashicorp/consul/agent/xds"
|
||||
"github.com/hashicorp/consul/api"
|
||||
"github.com/hashicorp/consul/sdk/testutil"
|
||||
"github.com/mitchellh/cli"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
var update = flag.Bool("update", false, "update golden files")
|
||||
|
@ -770,10 +771,7 @@ func TestGenerateConfig(t *testing.T) {
|
|||
require.NoError(err) // Error cases should have returned above
|
||||
require.Equal(&tc.WantArgs, got)
|
||||
|
||||
// Actual template output goes to stdout direct to avoid prefix in UI, so
|
||||
// generate it again here to assert on.
|
||||
actual, err := c.generateConfig()
|
||||
require.NoError(err)
|
||||
actual := ui.OutputWriter.Bytes()
|
||||
|
||||
// If we got the arg handling write, verify output
|
||||
golden := filepath.Join("testdata", tc.Name+".golden")
|
||||
|
|
|
@ -123,3 +123,4 @@
|
|||
]
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -114,3 +114,4 @@
|
|||
]
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -13,4 +13,4 @@
|
|||
"id": "test-proxy"
|
||||
},
|
||||
"custom_field": "foo"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -114,3 +114,4 @@
|
|||
]
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -123,3 +123,4 @@
|
|||
]
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -123,3 +123,4 @@
|
|||
]
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -136,3 +136,4 @@
|
|||
]
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -127,3 +127,4 @@
|
|||
]
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -114,3 +114,4 @@
|
|||
]
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -114,3 +114,4 @@
|
|||
]
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -114,3 +114,4 @@
|
|||
]
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -113,3 +113,4 @@
|
|||
]
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -187,3 +187,4 @@
|
|||
]
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -187,3 +187,4 @@
|
|||
]
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -187,3 +187,4 @@
|
|||
]
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -187,3 +187,4 @@
|
|||
]
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -187,3 +187,4 @@
|
|||
]
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -72,3 +72,4 @@
|
|||
]
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -114,3 +114,4 @@
|
|||
]
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -114,3 +114,4 @@
|
|||
]
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -114,3 +114,4 @@
|
|||
]
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -114,3 +114,4 @@
|
|||
]
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -147,3 +147,4 @@
|
|||
]
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue