TUN-4342: Fix false positive warning about unused hostname property
This commit is contained in:
parent
bc54a7f87b
commit
ae460b340b
|
@ -181,7 +181,7 @@ func runAdhocNamedTunnel(sc *subcommandContext, name, credentialsOutputPath stri
|
||||||
|
|
||||||
if r, ok := routeFromFlag(sc.c); ok {
|
if r, ok := routeFromFlag(sc.c); ok {
|
||||||
if res, err := sc.route(tunnel.ID, r); err != nil {
|
if res, err := sc.route(tunnel.ID, r); err != nil {
|
||||||
sc.log.Err(err).Msg("failed to create route, please create it manually")
|
sc.log.Err(err).Str("route", r.String()).Msg("failed to provision routing, please create it manually via Cloudflare dashboard or UI; most likely you already have a conflicting record there")
|
||||||
} else {
|
} else {
|
||||||
sc.log.Info().Msg(res.SuccessSummary())
|
sc.log.Info().Msg(res.SuccessSummary())
|
||||||
}
|
}
|
||||||
|
|
|
@ -160,10 +160,6 @@ func prepareTunnelConfig(
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Err(err).Str(LogFieldHostname, configHostname).Msg("Invalid hostname")
|
log.Err(err).Str(LogFieldHostname, configHostname).Msg("Invalid hostname")
|
||||||
return nil, ingress.Ingress{}, errors.Wrap(err, "Invalid hostname")
|
return nil, ingress.Ingress{}, errors.Wrap(err, "Invalid hostname")
|
||||||
} else if hostname != "" && isNamedTunnel {
|
|
||||||
log.Warn().Msg("The property `hostname` in your configuration is ignored because you configured a Named Tunnel " +
|
|
||||||
"in the property `tunnel`. Make sure to provision the routing (e.g. via `cloudflared tunnel route`) or else " +
|
|
||||||
"your origin will not be reachable. You should remove the `hostname` property to avoid this warning.")
|
|
||||||
}
|
}
|
||||||
isFreeTunnel := hostname == ""
|
isFreeTunnel := hostname == ""
|
||||||
clientID := c.String("id")
|
clientID := c.String("id")
|
||||||
|
|
|
@ -595,6 +595,12 @@ func runCommand(c *cli.Context) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if c.String("hostname") != "" {
|
||||||
|
sc.log.Warn().Msg("The property `hostname` in your configuration is ignored because you configured a Named Tunnel " +
|
||||||
|
"in the property `tunnel` to run. Make sure to provision the routing (e.g. via `cloudflared tunnel route dns/lb`) or else " +
|
||||||
|
"your origin will not be reachable. You should remove the `hostname` property to avoid this warning.")
|
||||||
|
}
|
||||||
|
|
||||||
return runNamedTunnel(sc, tunnelRef)
|
return runNamedTunnel(sc, tunnelRef)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -72,6 +72,7 @@ type Route interface {
|
||||||
json.Marshaler
|
json.Marshaler
|
||||||
RecordType() string
|
RecordType() string
|
||||||
UnmarshalResult(body io.Reader) (RouteResult, error)
|
UnmarshalResult(body io.Reader) (RouteResult, error)
|
||||||
|
String() string
|
||||||
}
|
}
|
||||||
|
|
||||||
type RouteResult interface {
|
type RouteResult interface {
|
||||||
|
@ -116,6 +117,10 @@ func (dr *DNSRoute) RecordType() string {
|
||||||
return "dns"
|
return "dns"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (dr *DNSRoute) String() string {
|
||||||
|
return fmt.Sprintf("%s %s", dr.RecordType(), dr.userHostname)
|
||||||
|
}
|
||||||
|
|
||||||
func (res *DNSRouteResult) SuccessSummary() string {
|
func (res *DNSRouteResult) SuccessSummary() string {
|
||||||
var msgFmt string
|
var msgFmt string
|
||||||
switch res.CName {
|
switch res.CName {
|
||||||
|
@ -164,6 +169,10 @@ func (lr *LBRoute) RecordType() string {
|
||||||
return "lb"
|
return "lb"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (lb *LBRoute) String() string {
|
||||||
|
return fmt.Sprintf("%s %s %s", lb.RecordType(), lb.lbName, lb.lbPool)
|
||||||
|
}
|
||||||
|
|
||||||
func (lr *LBRoute) UnmarshalResult(body io.Reader) (RouteResult, error) {
|
func (lr *LBRoute) UnmarshalResult(body io.Reader) (RouteResult, error) {
|
||||||
var result LBRouteResult
|
var result LBRouteResult
|
||||||
err := parseResponse(body, &result)
|
err := parseResponse(body, &result)
|
||||||
|
|
Loading…
Reference in New Issue