Step 1: move all the grpcAddr logic into the same spot
There is no reason a reader should have to jump around to find this value. It is only used in 1 place
This commit is contained in:
parent
c5f5cfddf6
commit
5092aaf9b8
|
@ -343,21 +343,6 @@ func (c *cmd) Run(args []string) int {
|
|||
return 1
|
||||
}
|
||||
|
||||
// See if we need to lookup grpcAddr
|
||||
if c.grpcAddr == "" {
|
||||
port, err := c.lookupGRPCPort()
|
||||
if err != nil {
|
||||
c.UI.Error(fmt.Sprintf("Error connecting to Consul agent: %s", err))
|
||||
}
|
||||
if port <= 0 {
|
||||
// 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))
|
||||
}
|
||||
c.grpcAddr = fmt.Sprintf("localhost:%v", port)
|
||||
}
|
||||
|
||||
// Generate config
|
||||
bootstrapJson, err := c.generateConfig()
|
||||
if err != nil {
|
||||
|
@ -411,6 +396,21 @@ func (c *cmd) templateArgs() (*BootstrapTplArgs, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
// See if we need to lookup grpcAddr
|
||||
if c.grpcAddr == "" {
|
||||
port, err := c.lookupGRPCPort()
|
||||
if err != nil {
|
||||
c.UI.Error(fmt.Sprintf("Error connecting to Consul agent: %s", err))
|
||||
}
|
||||
if port <= 0 {
|
||||
// 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))
|
||||
}
|
||||
c.grpcAddr = fmt.Sprintf("localhost:%v", port)
|
||||
}
|
||||
|
||||
// Decide on TLS if the scheme is provided and indicates it, if the HTTP env
|
||||
// suggests TLS is supported explicitly (CONSUL_HTTP_SSL) or implicitly
|
||||
// (CONSUL_HTTP_ADDR) is https://
|
||||
|
|
Loading…
Reference in New Issue