mirror of
https://github.com/wahyd4/cert-manager.git
synced 2026-08-09 05:06:38 +10:00
Rename command to 'migrate-api-version'
Signed-off-by: James Munnelly <jmunnelly@apple.com>
This commit is contained in:
@@ -6,7 +6,7 @@ go_library(
|
||||
importpath = "github.com/jetstack/cert-manager/cmd/ctl/pkg/upgrade",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//cmd/ctl/pkg/upgrade/migrate:go_default_library",
|
||||
"//cmd/ctl/pkg/upgrade/migrateapiversion:go_default_library",
|
||||
"@com_github_spf13_cobra//:go_default_library",
|
||||
"@io_k8s_cli_runtime//pkg/genericclioptions:go_default_library",
|
||||
],
|
||||
@@ -23,7 +23,7 @@ filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [
|
||||
":package-srcs",
|
||||
"//cmd/ctl/pkg/upgrade/migrate:all-srcs",
|
||||
"//cmd/ctl/pkg/upgrade/migrateapiversion:all-srcs",
|
||||
],
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:public"],
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ go_library(
|
||||
"command.go",
|
||||
"migrator.go",
|
||||
],
|
||||
importpath = "github.com/jetstack/cert-manager/cmd/ctl/pkg/upgrade/migrate",
|
||||
importpath = "github.com/jetstack/cert-manager/cmd/ctl/pkg/upgrade/migrateapiversion",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//cmd/ctl/pkg/build:go_default_library",
|
||||
+3
-3
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package migrate
|
||||
package migrateapiversion
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -44,7 +44,7 @@ This command must be run with a cluster running cert-manager v1.0 or greater.`))
|
||||
|
||||
example = templates.Examples(i18n.T(build.WithTemplate(`
|
||||
# Check the cert-manager installation is ready to be upgraded to v1.7
|
||||
{{.BuildName}} upgrade migrate
|
||||
{{.BuildName}} upgrade migrate-api-version
|
||||
`)))
|
||||
)
|
||||
|
||||
@@ -69,7 +69,7 @@ func NewOptions(ioStreams genericclioptions.IOStreams) *Options {
|
||||
func NewCmdMigrate(ctx context.Context, ioStreams genericclioptions.IOStreams) *cobra.Command {
|
||||
o := NewOptions(ioStreams)
|
||||
cmd := &cobra.Command{
|
||||
Use: "migrate",
|
||||
Use: "migrate-api-version",
|
||||
Short: "Migrate all existing persisted cert-manager resources to the v1 API version",
|
||||
Long: long,
|
||||
Example: example,
|
||||
+1
-1
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package migrate
|
||||
package migrateapiversion
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -22,7 +22,7 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
"k8s.io/cli-runtime/pkg/genericclioptions"
|
||||
|
||||
"github.com/jetstack/cert-manager/cmd/ctl/pkg/upgrade/migrate"
|
||||
"github.com/jetstack/cert-manager/cmd/ctl/pkg/upgrade/migrateapiversion"
|
||||
)
|
||||
|
||||
func NewCmdUpgrade(ctx context.Context, ioStreams genericclioptions.IOStreams) *cobra.Command {
|
||||
@@ -32,7 +32,7 @@ func NewCmdUpgrade(ctx context.Context, ioStreams genericclioptions.IOStreams) *
|
||||
Long: `Note: this command does NOT actually upgrade cert-manager installations`,
|
||||
}
|
||||
|
||||
cmds.AddCommand(migrate.NewCmdMigrate(ctx, ioStreams))
|
||||
cmds.AddCommand(migrateapiversion.NewCmdMigrate(ctx, ioStreams))
|
||||
|
||||
return cmds
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ go_test(
|
||||
"//pkg/webhook/handlers/testdata/apis/testgroup/crds:all-srcs",
|
||||
],
|
||||
deps = [
|
||||
"//cmd/ctl/pkg/upgrade/migrate:go_default_library",
|
||||
"//cmd/ctl/pkg/upgrade/migrateapiversion:go_default_library",
|
||||
"//pkg/webhook/handlers:go_default_library",
|
||||
"//pkg/webhook/handlers/testdata/apis/testgroup/install:go_default_library",
|
||||
"//pkg/webhook/handlers/testdata/apis/testgroup/v1:go_default_library",
|
||||
|
||||
@@ -31,7 +31,7 @@ import (
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||
|
||||
"github.com/jetstack/cert-manager/cmd/ctl/pkg/upgrade/migrate"
|
||||
"github.com/jetstack/cert-manager/cmd/ctl/pkg/upgrade/migrateapiversion"
|
||||
"github.com/jetstack/cert-manager/pkg/webhook/handlers"
|
||||
"github.com/jetstack/cert-manager/pkg/webhook/handlers/testdata/apis/testgroup/install"
|
||||
"github.com/jetstack/cert-manager/pkg/webhook/handlers/testdata/apis/testgroup/v1"
|
||||
@@ -134,7 +134,7 @@ func TestCtlUpgradeMigrate(t *testing.T) {
|
||||
}
|
||||
|
||||
// Run the migrator and migrate all objects to the 'nonStorageVersion' (which is now the new storage version)
|
||||
migrator := migrate.NewMigrator(cl, false, os.Stdout, os.Stderr)
|
||||
migrator := migrateapiversion.NewMigrator(cl, false, os.Stdout, os.Stderr)
|
||||
migrated, err := migrator.Run(ctx, nonStorageVersion, []string{crdName})
|
||||
if err != nil {
|
||||
t.Errorf("migrator failed to run: %v", err)
|
||||
@@ -212,7 +212,7 @@ func TestCtlUpgradeMigrate_FailsIfStorageVersionDoesNotEqualTargetVersion(t *tes
|
||||
}
|
||||
|
||||
// We expect this to fail, as we are attempting to migrate to the 'nonStorageVersion'.
|
||||
migrator := migrate.NewMigrator(cl, false, os.Stdout, os.Stderr)
|
||||
migrator := migrateapiversion.NewMigrator(cl, false, os.Stdout, os.Stderr)
|
||||
migrated, err := migrator.Run(ctx, nonStorageVersion, []string{crdName})
|
||||
if err == nil {
|
||||
t.Errorf("expected an error to be returned but we got none")
|
||||
@@ -275,7 +275,7 @@ func TestCtlUpgradeMigrate_SkipsMigrationIfNothingToDo(t *testing.T) {
|
||||
}
|
||||
|
||||
// We expect this to succeed and for the migration to not be run
|
||||
migrator := migrate.NewMigrator(cl, false, os.Stdout, os.Stderr)
|
||||
migrator := migrateapiversion.NewMigrator(cl, false, os.Stdout, os.Stderr)
|
||||
migrated, err := migrator.Run(ctx, storageVersion, []string{crdName})
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
@@ -335,7 +335,7 @@ func TestCtlUpgradeMigrate_ForcesMigrationIfSkipStoredVersionCheckIsEnabled(t *t
|
||||
}
|
||||
|
||||
// We expect this to force a migration
|
||||
migrator := migrate.NewMigrator(cl, true, os.Stdout, os.Stderr)
|
||||
migrator := migrateapiversion.NewMigrator(cl, true, os.Stdout, os.Stderr)
|
||||
migrated, err := migrator.Run(ctx, storageVersion, []string{crdName})
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
|
||||
Reference in New Issue
Block a user