Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Cmd = &cobra.Command{ Use: "migrate", Short: "Migrates to the new Config Sync architecture by enabling the multi-repo mode.", Long: "Migrates to the new Config Sync architecture by enabling the multi-repo mode. It provides you with additional features and gives you the flexibility to sync to a single repository, or multiple repositories.", Args: cobra.ExactArgs(0), RunE: func(cmd *cobra.Command, args []string) error { cmd.SilenceUsage = true var contexts []string if len(flags.Contexts) == 0 { currentContext, err := restconfig.CurrentContextName() if err != nil { return fmt.Errorf("failed to get current context name with err: %v", errors.Cause(err)) } contexts = append(contexts, currentContext) } else if len(flags.Contexts) != 1 || flags.Contexts[0] != "all" { contexts = flags.Contexts } clientMap, err := status.ClusterClients(cmd.Context(), contexts) if err != nil { return err } var migrationContexts []string migrationError := false for context, c := range clientMap { migrationContexts = append(migrationContexts, context) fmt.Println() fmt.Println(util.Separator) fmt.Printf("Enabling the multi-repo mode on cluster %q ...\n", context) cs := &status.ClusterState{Ref: context} if !c.IsInstalled(cmd.Context(), cs) || !c.IsConfigured(cmd.Context(), cs) { printError(cs.Error) migrationError = true continue } isMulti, err := c.ConfigManagement.IsMultiRepo(cmd.Context()) if err != nil { printError(err) migrationError = true continue } if isMulti != nil && *isMulti { printNotice("The cluster is already running in the multi-repo mode. No migration is needed") continue } rootSync, rsYamlFile, err := saveRootSyncYAML(cmd.Context(), c.ConfigManagement, context) if err != nil { printError(err) migrationError = true continue } cm, cmYamlFile, err := saveConfigManagementYAML(cmd.Context(), c.ConfigManagement, context) if err != nil { printError(err) migrationError = true continue } printHint(`Resources for the multi-repo mode have been saved in a temp folder. If the migration process is terminated, it can be recovered manually by running the following commands: kubectl apply -f %s && \ kubectl wait --for condition=established crd rootsyncs.configsync.gke.io && \ kubectl apply -f %s`, cmYamlFile, rsYamlFile) if dryRun { dryrun() } else if err := migrate(cmd.Context(), c, cm, rootSync); err != nil { printError(err) migrationError = true } } if migrationError { fmt.Println("\nFinished migration with errors. Please see above for errors and check the status with `nomos status`.") } else { fmt.Printf("\nFinished migration on the contexts: %s. Please check the sync status with `nomos status`.\n", strings.Join(migrationContexts, ", ")) } return nil }, }
Cmd performs the migration from mono-repo to multi-repo for all the provided contexts.
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.