Skip to content

Commit

Permalink
CR-15313-invalid-tunnel-url (#632)
Browse files Browse the repository at this point in the history
* moved tunnel ingressHost calc into runtimeInstallCommandPreRunHandler
  • Loading branch information
ATGardner authored Nov 6, 2022
1 parent 4c25ce7 commit 0a0a848
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 21 deletions.
2 changes: 1 addition & 1 deletion CODEOWNERS
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION=v0.1.0
VERSION=v0.1.1

OUT_DIR=dist
YEAR?=$(shell date +"%Y")
Expand Down
36 changes: 19 additions & 17 deletions cmd/commands/runtime_install.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,17 +201,6 @@ func NewRuntimeInstallCommand() *cobra.Command {
return fmt.Errorf("invalid access-mode %s, must be one of: ingress|tunnel", accessMode)
}

if installationOpts.AccessMode == platmodel.AccessModeTunnel {
installationOpts.featuresToInstall = append(installationOpts.featuresToInstall, runtime.InstallFeatureIngressless)
accountId, err := cfConfig.GetCurrentContext().GetAccountId(ctx)
if err != nil {
return fmt.Errorf("failed creating ingressHost for tunnel: %w", err)
}

installationOpts.TunnelSubdomain = fmt.Sprintf("%s-%s", accountId, installationOpts.RuntimeName)
installationOpts.IngressHost = fmt.Sprintf("https://%s.%s", installationOpts.TunnelSubdomain, installationOpts.TunnelDomain)
}

err := runtimeInstallCommandPreRunHandler(cmd, installationOpts)
handleCliStep(reporter.InstallPhasePreCheckFinish, "Finished pre installation checks", err, true, false)
if err != nil {
Expand All @@ -222,21 +211,22 @@ func NewRuntimeInstallCommand() *cobra.Command {
return util.DecorateErrorWithDocsLink(fmt.Errorf("pre installation error: %w", err), store.Get().RequirementsLink)
}

if installationOpts.runtimeDef == "" {
installationOpts.runtimeDef = runtime.GetRuntimeDefURL(installationOpts.versionStr)
}

finalParameters = map[string]string{
"Codefresh context": cfConfig.CurrentContext,
"Kube context": installationOpts.kubeContext,
"Runtime name": installationOpts.RuntimeName,
"Repository URL": installationOpts.InsCloneOpts.Repo,
"Ingress host": installationOpts.IngressHost,
"Ingress class": installationOpts.IngressClass,
"Internal ingress host": installationOpts.InternalIngressHost,
"Installing demo resources": strconv.FormatBool(installationOpts.InstallDemoResources),
}

if installationOpts.AccessMode == platmodel.AccessModeTunnel {
finalParameters["Tunnel URL"] = installationOpts.IngressHost
} else {
finalParameters["Ingress host"] = installationOpts.IngressHost
finalParameters["Internal ingress host"] = installationOpts.InternalIngressHost
}

if err := getApprovalFromUser(ctx, finalParameters, "runtime install"); err != nil {
return err
}
Expand Down Expand Up @@ -339,6 +329,14 @@ func runtimeInstallCommandPreRunHandler(cmd *cobra.Command, opts *RuntimeInstall
if opts.AccessMode == platmodel.AccessModeTunnel {
handleCliStep(reporter.InstallStepPreCheckEnsureIngressClass, "-skipped (ingressless)-", err, true, false)
handleCliStep(reporter.InstallStepPreCheckEnsureIngressHost, "-skipped (ingressless)-", err, true, false)
opts.featuresToInstall = append(opts.featuresToInstall, runtime.InstallFeatureIngressless)
accountId, err := cfConfig.GetCurrentContext().GetAccountId(ctx)
if err != nil {
return fmt.Errorf("failed creating ingressHost for tunnel: %w", err)
}

opts.TunnelSubdomain = fmt.Sprintf("%s-%s", accountId, opts.RuntimeName)
opts.IngressHost = fmt.Sprintf("https://%s.%s", opts.TunnelSubdomain, opts.TunnelDomain)
} else {
err = ensureRoutingControllerSupported(ctx, opts)
handleCliStep(reporter.InstallStepPreCheckEnsureIngressClass, "Getting ingress class", err, true, false)
Expand Down Expand Up @@ -387,6 +385,10 @@ func runtimeInstallCommandPreRunHandler(cmd *cobra.Command, opts *RuntimeInstall
log.G(ctx).Infof("using repo '%s' as shared config repo for this account", sharedConfigRepo)
}

if opts.runtimeDef == "" {
opts.runtimeDef = runtime.GetRuntimeDefURL(opts.versionStr)
}

opts.Insecure = true // installs argo-cd in insecure mode, we need this so that the eventsource can talk to the argocd-server with http
opts.CommonConfig = &runtime.CommonConfig{CodefreshBaseURL: cfConfig.GetCurrentContext().URL}

Expand Down
4 changes: 2 additions & 2 deletions docs/releases/release_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ cf version

```bash
# download and extract the binary
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.1.0/cf-linux-amd64.tar.gz | tar zx
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.1.1/cf-linux-amd64.tar.gz | tar zx

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

```bash
# download and extract the binary
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.1.0/cf-darwin-amd64.tar.gz | tar zx
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.1.1/cf-darwin-amd64.tar.gz | tar zx

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

0 comments on commit 0a0a848

Please sign in to comment.