From e38839b6811ccd2ab9a481bf61679246a3945154 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 13 Sep 2024 20:52:55 +0200 Subject: [PATCH 1/4] Bump actions/download-artifact from 3.0.1 to 4.1.7 in /.github/workflows in the github_actions group across 1 directory (#3217) Bump actions/download-artifact Bumps the github_actions group with 1 update in the /.github/workflows directory: [actions/download-artifact](https://github.com/actions/download-artifact). Updates `actions/download-artifact` from 3.0.1 to 4.1.7 - [Release notes](https://github.com/actions/download-artifact/releases) - [Commits](https://github.com/actions/download-artifact/compare/v3.0.1...v4.1.7) --- updated-dependencies: - dependency-name: actions/download-artifact dependency-type: direct:production dependency-group: github_actions ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/build_pipelinesrelease_template.yml | 6 +++--- .github/workflows/porter.yml | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build_pipelinesrelease_template.yml b/.github/workflows/build_pipelinesrelease_template.yml index b98536a13..a7b51bceb 100644 --- a/.github/workflows/build_pipelinesrelease_template.yml +++ b/.github/workflows/build_pipelinesrelease_template.yml @@ -112,7 +112,7 @@ jobs: with: go-version: ${{ inputs.goVersion }} - name: Download Cross-Compiled Porter Binaries - uses: actions/download-artifact@v4.1.0 + uses: actions/download-artifact@v4.1.7 with: name: xbuild-bin path: bin @@ -141,7 +141,7 @@ jobs: with: go-version: ${{ inputs.goVersion }} - name: Download Cross-Compiled Porter Binaries - uses: actions/download-artifact@v4.1.0 + uses: actions/download-artifact@v4.1.7 with: name: xbuild-bin path: bin @@ -182,7 +182,7 @@ jobs: with: go-version: ${{ inputs.goVersion }} - name: Download Cross-Compiled Porter Binaries - uses: actions/download-artifact@v4.1.0 + uses: actions/download-artifact@v4.1.7 with: name: xbuild-bin path: bin diff --git a/.github/workflows/porter.yml b/.github/workflows/porter.yml index 0173e8286..a65bd38b0 100644 --- a/.github/workflows/porter.yml +++ b/.github/workflows/porter.yml @@ -111,7 +111,7 @@ jobs: cache: true - run: go version - name: Download Cross-Compiled Porter Binaries - uses: actions/download-artifact@v3.0.1 + uses: actions/download-artifact@v4.1.7 with: name: xbuild-bin path: bin @@ -129,7 +129,7 @@ jobs: - name: checkout uses: actions/checkout@v3.5.0 - name: Download Cross-Compiled Porter Binaries - uses: actions/download-artifact@v3.0.1 + uses: actions/download-artifact@v4.1.7 with: name: xbuild-bin path: bin From 430e321e60a8c0b437565eca35315876c82ba327 Mon Sep 17 00:00:00 2001 From: Kim Christensen <2461567+kichristensen@users.noreply.github.com> Date: Tue, 17 Sep 2024 08:23:25 +0200 Subject: [PATCH 2/4] fix: Update version of upload-artifact (#3219) fix: Update upload-artifact action version Signed-off-by: Kim Christensen --- .github/workflows/build_pipelinesrelease_template.yml | 10 +++++----- .github/workflows/porter.yml | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build_pipelinesrelease_template.yml b/.github/workflows/build_pipelinesrelease_template.yml index a7b51bceb..78fa9ef38 100644 --- a/.github/workflows/build_pipelinesrelease_template.yml +++ b/.github/workflows/build_pipelinesrelease_template.yml @@ -35,7 +35,7 @@ jobs: run: mage build shell: bash - name: Publish Native Binaries - uses: actions/upload-artifact@v4.0.0 + uses: actions/upload-artifact@v4.4.0 with: name: build-bin path: "${{ github.workspace }}/bin" @@ -56,7 +56,7 @@ jobs: run: mage XBuildAll shell: bash - name: Publish Release Binaries - uses: actions/upload-artifact@v4.0.0 + uses: actions/upload-artifact@v4.4.0 with: name: xbuild-bin path: "${{ github.workspace }}/bin" @@ -112,7 +112,7 @@ jobs: with: go-version: ${{ inputs.goVersion }} - name: Download Cross-Compiled Porter Binaries - uses: actions/download-artifact@v4.1.7 + uses: actions/download-artifact@v4.1.8 with: name: xbuild-bin path: bin @@ -141,7 +141,7 @@ jobs: with: go-version: ${{ inputs.goVersion }} - name: Download Cross-Compiled Porter Binaries - uses: actions/download-artifact@v4.1.7 + uses: actions/download-artifact@v4.1.8 with: name: xbuild-bin path: bin @@ -182,7 +182,7 @@ jobs: with: go-version: ${{ inputs.goVersion }} - name: Download Cross-Compiled Porter Binaries - uses: actions/download-artifact@v4.1.7 + uses: actions/download-artifact@v4.1.8 with: name: xbuild-bin path: bin diff --git a/.github/workflows/porter.yml b/.github/workflows/porter.yml index a65bd38b0..01a406f53 100644 --- a/.github/workflows/porter.yml +++ b/.github/workflows/porter.yml @@ -38,7 +38,7 @@ jobs: fi shell: bash - name: Publish Native Binaries - uses: actions/upload-artifact@v3.1.1 + uses: actions/upload-artifact@v4.4.0 with: name: build-bin path: "${{ github.workspace }}/bin" @@ -58,7 +58,7 @@ jobs: run: go run mage.go -v XBuildAll shell: bash - name: Publish Release Binaries - uses: actions/upload-artifact@v3.1.1 + uses: actions/upload-artifact@v4.4.0 with: name: xbuild-bin path: "${{ github.workspace }}/bin" @@ -111,7 +111,7 @@ jobs: cache: true - run: go version - name: Download Cross-Compiled Porter Binaries - uses: actions/download-artifact@v4.1.7 + uses: actions/download-artifact@v4.1.8 with: name: xbuild-bin path: bin @@ -129,7 +129,7 @@ jobs: - name: checkout uses: actions/checkout@v3.5.0 - name: Download Cross-Compiled Porter Binaries - uses: actions/download-artifact@v4.1.7 + uses: actions/download-artifact@v4.1.8 with: name: xbuild-bin path: bin From 8ab04309d4dbe815fa08db5935b6ad41775b5b00 Mon Sep 17 00:00:00 2001 From: Kim Christensen <2461567+kichristensen@users.noreply.github.com> Date: Thu, 19 Sep 2024 05:43:37 +0200 Subject: [PATCH 3/4] Correct the Cosign links that have stopped working (#3220) fix: Correct the Cosign links that have stopped working Signed-off-by: Kim Christensen Co-authored-by: schristoff <28318173+schristoff@users.noreply.github.com> --- docs/content/docs/operations/signing-bundles.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/content/docs/operations/signing-bundles.md b/docs/content/docs/operations/signing-bundles.md index 858c3a8d9..caffdd1c6 100644 --- a/docs/content/docs/operations/signing-bundles.md +++ b/docs/content/docs/operations/signing-bundles.md @@ -27,9 +27,9 @@ Learn how to configure Porter to sign bundles. 1. Cosign is installed and is available on the on the `PATH`. 2. A key-pair for signing is available. -Instructions on for the install Cosign can be found on the [Cosign Installation page](https://docs.sigstore.dev/system_config/installation/), and instructions on how to generate a key-pair can be found in the [Cosign Quickstart Guide](https://docs.sigstore.dev/signing/quickstart/#signing-with-a-generated-key). +Instructions on for the install Cosign can be found on the [Cosign Installation page](https://docs.sigstore.dev/cosign/system_config/installation/), and instructions on how to generate a key-pair can be found in the [Cosign Signing with Self-Managed Keys](https://docs.sigstore.dev/cosign/key_management/signing_with_self-managed_keys/). -🚧 Currently Porter does not support [Keyless Signing](https://docs.sigstore.dev/signing/overview/) or reading the key-pair from anything but files. +🚧 Currently Porter does not support [Keyless Signing](https://docs.sigstore.dev/cosign/signing/overview/) or reading the key-pair from anything but files. ### Configuration @@ -100,5 +100,5 @@ To sign run [porter publish](/cli/porter_publish/) with the `--sign-bundle` flag A bundle can be verified before installation by adding the `--verify-bundle` flag to [porter install](/cli/porter_publish/). -[Cosign]: https://docs.sigstore.dev/signing/quickstart/ +[Cosign]: https://docs.sigstore.dev/quickstart/quickstart-cosign/ [Notation]: https://notaryproject.dev/docs/quickstart-guides/quickstart-sign-image-artifact/ \ No newline at end of file From f61648fcb851ab4bf6d062b593b3d5ccd6e91bdb Mon Sep 17 00:00:00 2001 From: Kim Christensen <2461567+kichristensen@users.noreply.github.com> Date: Thu, 19 Sep 2024 05:50:31 +0200 Subject: [PATCH 4/4] Upgrade should not be allowed if installation is not installed (#3213) fix: Upgrade should not be allowed if installation is not installed Signed-off-by: Kim Christensen --- .github/workflows/porter-integration-pr.yml | 30 +++++++++++++++++ pkg/porter/upgrade.go | 4 +++ .../bundle-with-failing-install/helpers.sh | 18 +++++++++++ .../bundle-with-failing-install/porter.yaml | 29 +++++++++++++++++ tests/integration/upgrade_test.go | 32 +++++++++++++++++++ 5 files changed, 113 insertions(+) create mode 100755 tests/integration/testdata/bundles/bundle-with-failing-install/helpers.sh create mode 100644 tests/integration/testdata/bundles/bundle-with-failing-install/porter.yaml create mode 100644 tests/integration/upgrade_test.go diff --git a/.github/workflows/porter-integration-pr.yml b/.github/workflows/porter-integration-pr.yml index 1314a4265..1f17d194f 100644 --- a/.github/workflows/porter-integration-pr.yml +++ b/.github/workflows/porter-integration-pr.yml @@ -154,3 +154,33 @@ jobs: PORTER_INTEG_FILE: signing_test.go run: go run mage.go -v TestIntegration shell: bash + upgrade_test_integ: + runs-on: ubuntu-latest + steps: + - name: checkout + uses: actions/checkout@v4.1.0 + - uses: actions/setup-go@v4 + with: + go-version: "${{ env.GOVERSION }}" + cache: true + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Cache Docker layers + uses: actions/cache@v3 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + - name: Docker Login + uses: docker/login-action@v3.0.0 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Configure Agent + run: go run mage.go build + shell: bash + - name: Integration Test + env: + PORTER_INTEG_FILE: upgrade_test.go + run: go run mage.go -v TestIntegration + shell: bash diff --git a/pkg/porter/upgrade.go b/pkg/porter/upgrade.go index 0758cb9b8..3fed12d48 100644 --- a/pkg/porter/upgrade.go +++ b/pkg/porter/upgrade.go @@ -64,6 +64,10 @@ func (p *Porter) UpgradeBundle(ctx context.Context, opts *UpgradeOptions) error return span.Errorf("could not find installation %s/%s: %w", opts.Namespace, opts.Name, err) } + if !i.IsInstalled() { + return span.Errorf("The installation cannot be upgraded, because it is not installed. Verify the installation name and namespace, and if correct, use porter install.") + } + if opts.Reference != "" { i.TrackBundle(opts.GetReference()) } else if opts.Version != "" { diff --git a/tests/integration/testdata/bundles/bundle-with-failing-install/helpers.sh b/tests/integration/testdata/bundles/bundle-with-failing-install/helpers.sh new file mode 100755 index 000000000..ece2563e0 --- /dev/null +++ b/tests/integration/testdata/bundles/bundle-with-failing-install/helpers.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +set -euo pipefail + +install() { + echo Hello World + exit 1 +} + +upgrade() { + echo World 2.0 +} + +uninstall() { + echo Goodbye World +} + +# Call the requested function and pass the arguments as-is +"$@" diff --git a/tests/integration/testdata/bundles/bundle-with-failing-install/porter.yaml b/tests/integration/testdata/bundles/bundle-with-failing-install/porter.yaml new file mode 100644 index 000000000..7ec17bb6e --- /dev/null +++ b/tests/integration/testdata/bundles/bundle-with-failing-install/porter.yaml @@ -0,0 +1,29 @@ +schemaVersion: 1.0.1 +name: porter-failing-install +version: 0.1.0 +description: "A bundle that always fails installation" +registry: "localhost:5000" + +mixins: + - exec + +install: + - exec: + description: "Install Hello World" + command: ./helpers.sh + arguments: + - install + +upgrade: + - exec: + description: "Upgrade Hello World" + command: ./helpers.sh + arguments: + - upgrade + +uninstall: + - exec: + description: "Uninstall Hello World" + command: ./helpers.sh + arguments: + - uninstall diff --git a/tests/integration/upgrade_test.go b/tests/integration/upgrade_test.go new file mode 100644 index 000000000..e48fac9db --- /dev/null +++ b/tests/integration/upgrade_test.go @@ -0,0 +1,32 @@ +//go:build integration + +package integration + +import ( + "testing" + + "get.porter.sh/porter/pkg/porter" + "github.com/stretchr/testify/require" +) + +func TestUpgrade_failedInstallation(t *testing.T) { + p := porter.NewTestPorter(t) + defer p.Close() + ctx := p.SetupIntegrationTest() + + p.AddTestBundleDir("testdata/bundles/bundle-with-failing-install", false) + + installOpts := porter.NewInstallOptions() + err := installOpts.Validate(ctx, []string{}, p.Porter) + require.NoError(t, err) + + err = p.InstallBundle(ctx, installOpts) + require.Error(t, err, "Installation should fail") + + upgradeOpts := porter.NewUpgradeOptions() + err = upgradeOpts.Validate(ctx, []string{}, p.Porter) + require.NoError(t, err) + + err = p.UpgradeBundle(ctx, upgradeOpts) + require.Error(t, err, "Upgrade should fail, because the installation failed") +}