Skip to content

Commit c23aea1

Browse files
authored
Remove receipts migration (#603)
* Remove receipts migration * Remove receiptsmigration check from ci * Rename test * Remove oldenvironment * Code review changes
1 parent badb999 commit c23aea1

File tree

10 files changed

+14
-768
lines changed

10 files changed

+14
-768
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,6 @@ jobs:
6060
- name: Run integration tests
6161
run: hack/run-integration-tests.sh
6262

63-
- name: Verify receipt migration from v0.2.x to v0.3.x
64-
run: hack/verify-receipts-upgrade-migration.sh
65-
6663
- name: Create a new release
6764
if: contains(github.ref, 'tags')
6865
id: create_release

cmd/krew/cmd/root.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,11 @@ func preRun(cmd *cobra.Command, _ []string) error {
141141
if err != nil {
142142
return err
143143
}
144-
if !isMigrated && cmd.Use != "receipts-upgrade" {
145-
fmt.Fprintln(os.Stderr, "You need to perform a migration to continue using krew.\nPlease run `kubectl krew system receipts-upgrade`")
144+
if !isMigrated {
145+
fmt.Fprintln(os.Stderr, `This version of Krew is not supported anymore. Please manually migrate:
146+
1. Uninstall Krew: https://krew.sigs.k8s.io/docs/user-guide/setup/uninstall/
147+
2. Install latest Krew: https://krew.sigs.k8s.io/docs/user-guide/setup/install/
148+
3. Install the plugins you used`)
146149
return errors.New("krew home outdated")
147150
}
148151

cmd/krew/cmd/system.go

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import (
2020
"github.com/spf13/cobra"
2121

2222
"sigs.k8s.io/krew/internal/indexmigration"
23-
"sigs.k8s.io/krew/internal/receiptsmigration"
2423
"sigs.k8s.io/krew/pkg/constants"
2524
)
2625

@@ -37,23 +36,6 @@ This command will be removed without further notice from future versions of krew
3736
Hidden: true,
3837
}
3938

40-
// TODO(corneliusweig) remove migration code with v0.4
41-
// systemCmd represents the system command
42-
var receiptsUpgradeCmd = &cobra.Command{
43-
Use: "receipts-upgrade",
44-
Short: "Perform a migration of the krew home",
45-
Long: `Krew became more awesome! To use the new features, you need to run this
46-
one-time migration, which will reinstall all current plugins.
47-
48-
This command will be removed without further notice from future versions of krew.
49-
`,
50-
Args: cobra.NoArgs,
51-
RunE: func(cmd *cobra.Command, args []string) error {
52-
return receiptsmigration.Migrate(paths)
53-
},
54-
PreRunE: func(_ *cobra.Command, _ []string) error { return ensureIndexesUpdated() },
55-
}
56-
5739
var indexUpgradeCmd = &cobra.Command{
5840
Use: "index-upgrade",
5941
Short: "Perform a migration of the krew index",
@@ -72,6 +54,5 @@ func init() {
7254
if _, ok := os.LookupEnv(constants.EnableMultiIndexSwitch); ok {
7355
systemCmd.AddCommand(indexUpgradeCmd)
7456
}
75-
systemCmd.AddCommand(receiptsUpgradeCmd)
7657
rootCmd.AddCommand(systemCmd)
7758
}

cmd/krew/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@ import (
2121
)
2222

2323
func main() {
24-
cmd.Execute()
2524
defer klog.Flush()
25+
cmd.Execute()
2626
}

hack/verify-receipts-upgrade-migration.sh

Lines changed: 0 additions & 147 deletions
This file was deleted.

integration_test/system_test.go

Lines changed: 8 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,12 @@
1616
package integrationtest
1717

1818
import (
19-
"bytes"
2019
"os"
21-
"path/filepath"
20+
"strings"
2221
"testing"
23-
24-
"sigs.k8s.io/krew/internal/testutil"
2522
)
2623

27-
func TestKrewSystem(t *testing.T) {
24+
func TestKrewUnsupportedVersion(t *testing.T) {
2825
skipShort(t)
2926

3027
test, cleanup := NewTest(t)
@@ -35,61 +32,13 @@ func TestKrewSystem(t *testing.T) {
3532
// needs to be after initial installation
3633
prepareOldKrewRoot(test)
3734

38-
test.Krew("system", "receipts-upgrade").RunOrFailOutput()
39-
test.AssertExecutableInPATH("kubectl-" + validPlugin)
40-
41-
assertReceiptExistsFor(test, validPlugin)
42-
}
43-
44-
func TestKrewSystem_ReceiptForKrew(t *testing.T) {
45-
skipShort(t)
46-
47-
test, cleanup := NewTest(t)
48-
defer cleanup()
49-
50-
prepareOldKrewRoot(test)
51-
touch(test.tempDir, "store/krew/ensure-folder-exists")
52-
53-
test.WithDefaultIndex().Krew("system", "receipts-upgrade").RunOrFailOutput()
54-
55-
assertReceiptExistsFor(test, "krew")
56-
}
57-
58-
func TestKrewSystem_IgnoreAdditionalFolders(t *testing.T) {
59-
skipShort(t)
60-
61-
test, cleanup := NewTest(t)
62-
defer cleanup()
63-
64-
prepareOldKrewRoot(test)
65-
66-
touch(test.tempDir, "store/not-a-plugin/ensure-folder-exists")
67-
out := test.WithDefaultIndex().Krew("system", "receipts-upgrade").RunOrFailOutput()
68-
69-
if !bytes.Contains(out, []byte("Skipping plugin not-a-plugin")) {
70-
t.Errorf("Expected a message that 'not-a-plugin' is skipped, but output was:")
71-
t.Log(string(out))
35+
// any command should fail here
36+
out, err := test.Krew("list").Run()
37+
if err == nil {
38+
t.Error("krew should fail when old receipts structure is detected")
7239
}
73-
}
74-
75-
func TestKrewSystem_IgnoreUnknownPlugins(t *testing.T) {
76-
skipShort(t)
77-
78-
test, cleanup := NewTest(t)
79-
defer cleanup()
80-
81-
test.Krew("install",
82-
"--manifest", filepath.Join("testdata", "foo.yaml"),
83-
"--archive", filepath.Join("testdata", "foo.tar.gz")).
84-
RunOrFail()
85-
86-
prepareOldKrewRoot(test)
87-
88-
out := test.WithDefaultIndex().Krew("system", "receipts-upgrade").RunOrFailOutput()
89-
90-
if !bytes.Contains(out, []byte("Skipping plugin foo")) {
91-
t.Errorf("Expected a message that 'foo' is skipped, but output was:")
92-
t.Log(string(out))
40+
if !strings.Contains(string(out), "Uninstall Krew") {
41+
t.Errorf("output should contain instructions on upgrading: %s", string(out))
9342
}
9443
}
9544

@@ -99,16 +48,3 @@ func prepareOldKrewRoot(test *ITest) {
9948
test.t.Fatal(err)
10049
}
10150
}
102-
103-
func assertReceiptExistsFor(it *ITest, plugin string) {
104-
receipt := "receipts/" + plugin + ".yaml"
105-
_, err := os.Lstat(it.tempDir.Path(receipt))
106-
if err != nil {
107-
it.t.Errorf("Expected plugin receipt %q but found none.", receipt)
108-
}
109-
}
110-
111-
// touch creates a file without content in the temporary directory.
112-
func touch(td *testutil.TempDir, file string) {
113-
td.Write(file, nil)
114-
}

0 commit comments

Comments
 (0)