TUN-4981: Improve readability of prepareTunnelConfig method
This commit is contained in:
parent
a4a9f45b0a
commit
2afa307765
|
@ -161,7 +161,6 @@ func prepareTunnelConfig(
|
||||||
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")
|
||||||
}
|
}
|
||||||
isQuickTunnel := hostname == ""
|
|
||||||
clientID := c.String("id")
|
clientID := c.String("id")
|
||||||
if !c.IsSet("id") {
|
if !c.IsSet("id") {
|
||||||
clientID, err = generateRandomClientID(log)
|
clientID, err = generateRandomClientID(log)
|
||||||
|
@ -178,19 +177,6 @@ func prepareTunnelConfig(
|
||||||
|
|
||||||
tags = append(tags, tunnelpogs.Tag{Name: "ID", Value: clientID})
|
tags = append(tags, tunnelpogs.Tag{Name: "ID", Value: clientID})
|
||||||
|
|
||||||
var originCert []byte
|
|
||||||
if !isQuickTunnel {
|
|
||||||
originCertPath := c.String("origincert")
|
|
||||||
originCertLog := log.With().
|
|
||||||
Str(LogFieldOriginCertPath, originCertPath).
|
|
||||||
Logger()
|
|
||||||
|
|
||||||
originCert, err = getOriginCert(originCertPath, &originCertLog)
|
|
||||||
if err != nil {
|
|
||||||
return nil, ingress.Ingress{}, errors.Wrap(err, "Error getting origin cert")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
var (
|
||||||
ingressRules ingress.Ingress
|
ingressRules ingress.Ingress
|
||||||
classicTunnel *connection.ClassicTunnelConfig
|
classicTunnel *connection.ClassicTunnelConfig
|
||||||
|
@ -217,6 +203,17 @@ func prepareTunnelConfig(
|
||||||
return nil, ingress.Ingress{}, ingress.ErrURLIncompatibleWithIngress
|
return nil, ingress.Ingress{}, ingress.ErrURLIncompatibleWithIngress
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
originCertPath := c.String("origincert")
|
||||||
|
originCertLog := log.With().
|
||||||
|
Str(LogFieldOriginCertPath, originCertPath).
|
||||||
|
Logger()
|
||||||
|
|
||||||
|
originCert, err := getOriginCert(originCertPath, &originCertLog)
|
||||||
|
if err != nil {
|
||||||
|
return nil, ingress.Ingress{}, errors.Wrap(err, "Error getting origin cert")
|
||||||
|
}
|
||||||
|
|
||||||
classicTunnel = &connection.ClassicTunnelConfig{
|
classicTunnel = &connection.ClassicTunnelConfig{
|
||||||
Hostname: hostname,
|
Hostname: hostname,
|
||||||
OriginCert: originCert,
|
OriginCert: originCert,
|
||||||
|
|
Loading…
Reference in New Issue