Skip to content

Commit 52ec590

Browse files
distinguish between host and ip in ingressHost (#259)
* - removed trailing slash from hostName - distinguish between ip and host * small fix * bump * defVersion bump * bump defVersion
1 parent ccdb7fb commit 52ec590

File tree

7 files changed

+27
-15
lines changed

7 files changed

+27
-15
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
VERSION=v0.0.237
1+
VERSION=v0.0.238
22

33
OUT_DIR=dist
44
YEAR?=$(shell date +"%Y")

cmd/commands/common.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,6 @@ func getIngressHostFromUserInput(ctx context.Context, opts *RuntimeInstallOption
462462
}
463463

464464
opts.IngressHost = ingressHostInput
465-
opts.HostName = util.ParseHostNameFromIngressHost(ingressHostInput)
466465

467466
return nil
468467
}
@@ -511,7 +510,6 @@ func setIngressHost(ctx context.Context, opts *RuntimeInstallOptions) error {
511510

512511
if store.Get().Silent {
513512
log.G(ctx).Warnf("Using ingress host %s", foundIngressHost)
514-
opts.HostName = foundHostName
515513
opts.IngressHost = foundIngressHost
516514
} else {
517515
err = getIngressHostFromUserInput(ctx, opts, foundIngressHost)

cmd/commands/runtime.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"encoding/hex"
2121
"fmt"
2222
"io"
23+
"net/url"
2324
"os"
2425
"strconv"
2526
"strings"
@@ -394,6 +395,20 @@ func ensureIngressHost(cmd *cobra.Command, opts *RuntimeInstallOptions) error {
394395
}
395396
}
396397

398+
parsed, err := url.Parse(opts.IngressHost)
399+
if err != nil {
400+
return err
401+
}
402+
403+
isIP, err := util.IsIP(parsed.Host)
404+
if err != nil {
405+
return err
406+
}
407+
408+
if !isIP {
409+
opts.HostName = parsed.Host
410+
}
411+
397412
log.G(cmd.Context()).Infof("Using ingress host: %s", opts.IngressHost)
398413

399414
log.G(cmd.Context()).Info("Validating ingress host")

docs/releases/release_notes.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ cf version
2323

2424
```bash
2525
# download and extract the binary
26-
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.0.237/cf-linux-amd64.tar.gz | tar zx
26+
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.0.238/cf-linux-amd64.tar.gz | tar zx
2727

2828
# move the binary to your $PATH
2929
mv ./cf-linux-amd64 /usr/local/bin/cf
@@ -36,7 +36,7 @@ cf version
3636

3737
```bash
3838
# download and extract the binary
39-
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.0.237/cf-darwin-amd64.tar.gz | tar zx
39+
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.0.238/cf-darwin-amd64.tar.gz | tar zx
4040

4141
# move the binary to your $PATH
4242
mv ./cf-darwin-amd64 /usr/local/bin/cf

manifests/runtime.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ metadata:
44
name: "{{ name }}"
55
namespace: "{{ namespace }}"
66
spec:
7-
defVersion: 1.0.0
8-
version: 0.0.237
7+
defVersion: 1.0.1
8+
version: 0.0.238
99
bootstrapSpecifier: github.com/codefresh-io/cli-v2/manifests/argo-cd
1010
components:
1111
- name: events

pkg/store/store.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ var (
3030
buildDate = ""
3131
gitCommit = ""
3232
segmentWriteKey = ""
33-
maxDefVersion = "1.0.0"
33+
maxDefVersion = "1.0.1"
3434
RuntimeDefURL = "manifests/runtime.yaml"
3535
ArgoAgentURL = "manifests/argo-agent/agent.yaml"
3636
)

pkg/util/util.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -187,11 +187,6 @@ func DecorateErrorWithDocsLink(err error, link ...string) error {
187187
return fmt.Errorf("%s\nfor more information: %s", err.Error(), link[0])
188188
}
189189

190-
func ParseHostNameFromIngressHost(ingressHost string) string {
191-
split := strings.Split(ingressHost, "//")
192-
return split[1]
193-
}
194-
195190
func reportCancel(status reporter.CliStepStatus) {
196191
reporter.G().ReportStep(reporter.CliStepData{
197192
Step: reporter.SIGNAL_TERMINATION,
@@ -201,6 +196,10 @@ func reportCancel(status reporter.CliStepStatus) {
201196
})
202197
}
203198

199+
func IsIP(s string) (bool, error) {
200+
return regexp.MatchString(`^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$`, s)
201+
}
202+
204203
func RunNetworkTest(ctx context.Context, kubeFactory kube.Factory, urls ...string) error {
205204
const networkTestsTimeout = 120 * time.Second
206205
var testerPodName string
@@ -232,14 +231,14 @@ func RunNetworkTest(ctx context.Context, kubeFactory kube.Factory, urls ...strin
232231
defer func() {
233232
deferErr := client.BatchV1().Jobs(store.Get().DefaultNamespace).Delete(ctx, store.Get().NetworkTesterName, metav1.DeleteOptions{})
234233
if deferErr != nil {
235-
log.G(ctx).Error("fail to delete job resource '%s': %s", store.Get().NetworkTesterName, deferErr.Error())
234+
log.G(ctx).Errorf("fail to delete job resource '%s': %s", store.Get().NetworkTesterName, deferErr.Error())
236235
}
237236
}()
238237

239238
defer func(name *string) {
240239
deferErr := client.CoreV1().Pods(store.Get().DefaultNamespace).Delete(ctx, *name, metav1.DeleteOptions{})
241240
if deferErr != nil {
242-
log.G(ctx).Error("fail to delete tester pod '%s': %s", testerPodName, deferErr.Error())
241+
log.G(ctx).Errorf("fail to delete tester pod '%s': %s", testerPodName, deferErr.Error())
243242
}
244243
}(&testerPodName)
245244

0 commit comments

Comments
 (0)