func newRootCmd()

in cmd/root.go [88:150]


func newRootCmd() *cobra.Command {
	o := migrateOptions{
		fetchClientFunc: fetchClients,
	}
	ctx, cancel := context.WithCancel(context.Background())

	cmd := &cobra.Command{
		Use:   "gkeconvert",
		Short: "Convert a GCE legacy network to a VPC network and upgrade GKE clusters.",
		Long: `This script converts a GCE legacy network to a VPC network (by switching
the network to custom subnet mode). It then performs GKE cluster upgrades to ensure
the clusters are compatible with a VPC network.`,

		PreRun: func(cmd *cobra.Command, args []string) {
			cobra.CheckErr(o.ValidateFlags())
			setupCloseHandler(cancel)
		},
		Run: func(cmd *cobra.Command, args []string) {
			cobra.CheckErr(o.Complete(ctx))
			cobra.CheckErr(o.Run(ctx))
		},
	}

	flags := cmd.Flags()

	flags.StringVarP(&o.projectID, projectFlag, "p", o.projectID, "project ID")

	// Target network options.
	flags.StringVarP(&o.selectedNetwork, networkFlag, "n", o.selectedNetwork, "GCE network to process.")

	// Concurrency options.
	flags.Uint16VarP(&o.concurrentClusters, concurrentClustersFlag, "C", 1, "Number of clusters per network to upgrade concurrently.")

	// Polling options.
	flags.DurationVar(&o.pollingInterval, pollingIntervalFlag, 15*time.Second, "Period between polling attempts.")
	flags.DurationVar(&o.pollingDeadline, pollingDeadlineFlag, 24*time.Hour, "Deadline for a long running operation to complete (e.g. to upgrade a cluster node pool).")

	// Cluster upgrade options.
	flags.StringVar(&o.desiredControlPlaneVersion, desiredControlPlaneVersionFlag, o.desiredControlPlaneVersion,
		`Desired GKE version for all cluster control planes.
For more information, see https://cloud.google.com/kubernetes-engine/versioning#versioning_scheme
Note:
  This version must be equal to or greater than the lowest control plane version on the network.`)
	flags.StringVar(&o.desiredNodeVersion, desiredNodeVersionFlag, clusters.DefaultVersion,
		`Desired GKE version for all cluster nodes. For more information, see https://cloud.google.com/kubernetes-engine/versioning#versioning_scheme
Note:
  This version must be greater than the lowest node pool version on the network as node pools cannot be upgraded in-place.`)

	flags.BoolVar(&o.inPlaceControlPlaneUpgrade, inPlaceControlPlaneUpgradeFlag, false,
		`Perform in-place control plane upgrade for all clusters.`)

	flags.BoolVar(&o.validateOnly, validateOnlyFlag, true,
		`Only run validation on the network and cluster resources; do not perform conversion`)

	// Test options.
	flags.StringVar(&o.containerBasePath, containerBasePathFlag, o.containerBasePath, "Custom URL for the container API endpoint (for testing).")

	cmd.MarkFlagRequired(projectFlag)
	cmd.MarkFlagRequired(networkFlag)
	flags.MarkHidden(containerBasePathFlag)

	return cmd
}