Skip to content

Commit

Permalink
fix upgrade (#634)
Browse files Browse the repository at this point in the history
* fix upgrade

* bump

* fix

* fix --version
  • Loading branch information
danielm-codefresh authored Nov 7, 2022
1 parent b41448b commit 8111859
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION=v0.1.1
VERSION=v0.1.2

OUT_DIR=dist
YEAR?=$(shell date +"%Y")
Expand Down
8 changes: 0 additions & 8 deletions cmd/commands/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -900,14 +900,6 @@ func runRuntimeUpgrade(ctx context.Context, opts *RuntimeUpgradeOptions) error {
return fmt.Errorf("failed to load current runtime definition: %w", err)
}

if !newRt.Spec.Version.GreaterThan(curRt.Spec.Version) {
err = fmt.Errorf("current runtime version (%s) is greater than or equal to the specified version (%s)", curRt.Spec.Version, newRt.Spec.Version)
}
handleCliStep(reporter.UpgradeStepLoadRuntimeDefinition, "Comparing runtime versions", err, true, false)
if err != nil {
return err
}

log.G(ctx).Infof("Upgrading runtime \"%s\" to version: v%s", opts.RuntimeName, newRt.Spec.Version)
newComponents, err := curRt.Upgrade(fs, newRt, opts.CommonConfig)
handleCliStep(reporter.UpgradeStepUpgradeRuntime, "Upgrading runtime", err, false, false)
Expand Down
2 changes: 1 addition & 1 deletion cmd/commands/runtime_install.go
Original file line number Diff line number Diff line change
Expand Up @@ -2153,5 +2153,5 @@ func getRuntimeDef(runtimeDef, versionStr string) string {
if strings.Contains(runtimeDef, "cli-v2") {
return strings.Replace(runtimeDef, "/releases/latest/download", "/releases/download/v"+version.String(), 1)
}
return runtimeDef + "?ref=v" + version.String()
return strings.Replace(runtimeDef, "stable", version.String(), 1)
}
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.1/cf-linux-amd64.tar.gz | tar zx
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.1.2/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.1/cf-darwin-amd64.tar.gz | tar zx
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.1.2/cf-darwin-amd64.tar.gz | tar zx

# move the binary to your $PATH
mv ./cf-darwin-amd64 /usr/local/bin/cf
Expand Down
7 changes: 4 additions & 3 deletions hack/get-manifests-location.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@ BRANCH="$1"

DEFAULT_MANIFESTS_LOCATION="https://raw.githubusercontent.com/codefresh-io/csdp-official/stable/csdp/hybrid/basic/runtime.yaml"
RUNTIME_DEFINITION_URL="https://raw.githubusercontent.com/codefresh-io/csdp-official/$BRANCH/csdp/hybrid/basic/runtime.yaml"
RUNTIME_DEFINITION_FILE="/codefresh/volume/runtime.yaml"

git ls-remote --heads ${REPO} ${BRANCH} | grep ${BRANCH} >/dev/null

if [ "$?" == "1" ]; then
# No matching branch was found in csdp-official
echo "$DEFAULT_MANIFESTS_LOCATION"
curl --silent "$DEFAULT_MANIFESTS_LOCATION" > $RUNTIME_DEFINITION_FILE
echo $RUNTIME_DEFINITION_FILE
exit 0
fi

RUNTIME_DEFINITION_FILE="/codefresh/volume/runtime.yaml"
curl --silent "$RUNTIME_DEFINITION_URL" | yq "(.spec.components[] | select(.type == \"kustomize\") | .url) += \"?ref=$BRANCH\"" | yq ".spec.bootstrapSpecifier += \"?ref=$BRANCH\"" >$RUNTIME_DEFINITION_FILE
curl --silent "$RUNTIME_DEFINITION_URL" | yq "(.spec.components[] | select(.type == \"kustomize\") | .url) += \"?ref=$BRANCH\"" | yq ".spec.bootstrapSpecifier += \"?ref=$BRANCH\"" > $RUNTIME_DEFINITION_FILE
echo $RUNTIME_DEFINITION_FILE
2 changes: 1 addition & 1 deletion pkg/runtime/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ func GetRuntimeDefURL(versionStr string) string {

version := semver.MustParse(versionStr)
if version.Compare(store.Get().LastRuntimeVersionInCLI) <= 0 {
runtimeDefURL = store.Get().RuntimeDefURL
runtimeDefURL = store.Get().OldRuntimeDefURL
}

return runtimeDefURL
Expand Down
3 changes: 3 additions & 0 deletions pkg/util/kube/kube.go
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,9 @@ func DeleteSecretWithFinalizer(ctx context.Context, kubeFactory kube.Factory, se
}

err = client.CoreV1().Secrets(secret.Namespace).Delete(ctx, secret.Name, metav1.DeleteOptions{})
if errors.IsNotFound(err) {
return nil
}

return err
}
Expand Down

0 comments on commit 8111859

Please sign in to comment.