-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathmigrate.go
More file actions
90 lines (68 loc) · 2.63 KB
/
migrate.go
File metadata and controls
90 lines (68 loc) · 2.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
package migrate
import (
"fmt"
"github.com/spf13/cobra"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
"github.com/opendatahub-io/odh-cli/cmd/migrate/list"
"github.com/opendatahub-io/odh-cli/cmd/migrate/prepare"
"github.com/opendatahub-io/odh-cli/cmd/migrate/run"
)
const (
cmdName = "migrate"
cmdShort = "Manage cluster migrations"
)
const cmdLong = `
The migrate command manages cluster migrations for OpenShift AI components.
Use 'migrate list' to see available migrations filtered by version compatibility.
Use 'migrate prepare' to backup resources before migration.
Use 'migrate run' to execute one or more migrations sequentially.
Migrations are version-aware and only execute when applicable to the current
cluster state. Each migration can be run in dry-run mode to preview changes
before applying them.
Available subcommands:
list List available migrations for a target version
prepare Execute preparation steps (backups) for migrations
run Execute one or more migrations
`
const cmdExample = `
# List available migrations for version 3.0
kubectl odh migrate list --target-version 3.0.0
# List all migrations including non-applicable ones
kubectl odh migrate list --all
# Prepare for migration (creates backups)
kubectl odh migrate prepare --migration kueue.rhbok.migrate --target-version 3.0.0
# Run a migration with confirmation prompts
kubectl odh migrate run --migration kueue.rhbok.migrate --target-version 3.0.0
# Run migration in dry-run mode (preview changes only)
kubectl odh migrate run --migration kueue.rhbok.migrate --target-version 3.0.0 --dry-run
# Run multiple migrations sequentially
kubectl odh migrate run --migration kueue.rhbok.migrate --migration other.migration --target-version 3.0.0 --yes
`
// AddCommand adds the migrate command to the root command.
func AddCommand(root *cobra.Command, flags *genericclioptions.ConfigFlags) error {
streams := genericiooptions.IOStreams{
In: root.InOrStdin(),
Out: root.OutOrStdout(),
ErrOut: root.ErrOrStderr(),
}
cmd := &cobra.Command{
Use: cmdName,
Short: cmdShort,
Long: cmdLong,
Example: cmdExample,
SilenceUsage: true,
SilenceErrors: true,
}
if err := list.AddCommand(cmd, flags, streams); err != nil {
return fmt.Errorf("adding list subcommand: %w", err)
}
if err := prepare.AddCommand(cmd, flags, streams); err != nil {
return fmt.Errorf("adding prepare subcommand: %w", err)
}
if err := run.AddCommand(cmd, flags, streams); err != nil {
return fmt.Errorf("adding run subcommand: %w", err)
}
root.AddCommand(cmd)
return nil
}