82
82
83
83
// NewCmdMigrate defines the `migrate` command that migrate resources from legacy clusters
84
84
func NewCmdMigrate (f util.Factory , parentCommand string ) * cobra.Command {
85
- opts := CommandmigrateOption {}
85
+ opts := CommandMigrateOption {}
86
86
opts .JSONYamlPrintFlags = genericclioptions .NewJSONYamlPrintFlags ()
87
87
88
88
cmd := & cobra.Command {
@@ -114,8 +114,8 @@ func NewCmdMigrate(f util.Factory, parentCommand string) *cobra.Command {
114
114
return cmd
115
115
}
116
116
117
- // CommandmigrateOption holds all command options for migrate
118
- type CommandmigrateOption struct {
117
+ // CommandMigrateOption holds all command options for migrate
118
+ type CommandMigrateOption struct {
119
119
// Cluster is the name of legacy cluster
120
120
Cluster string
121
121
@@ -156,7 +156,7 @@ type CommandmigrateOption struct {
156
156
}
157
157
158
158
// AddFlags adds flags to the specified FlagSet.
159
- func (o * CommandmigrateOption ) AddFlags (flags * pflag.FlagSet ) {
159
+ func (o * CommandMigrateOption ) AddFlags (flags * pflag.FlagSet ) {
160
160
flags .BoolVar (& o .AutoCreatePolicy , "auto-create-policy" , true ,
161
161
"Automatically create a PropagationPolicy for namespace-scoped resources or " +
162
162
"create a ClusterPropagationPolicy for cluster-scoped resources." )
@@ -176,7 +176,7 @@ func (o *CommandmigrateOption) AddFlags(flags *pflag.FlagSet) {
176
176
}
177
177
178
178
// Preflight ensures that options are valid and marshals them if necessary
179
- func (o * CommandmigrateOption ) Preflight (f util.Factory , args []string ) error {
179
+ func (o * CommandMigrateOption ) Preflight (f util.Factory , args []string ) error {
180
180
var err error
181
181
182
182
if len (args ) != 2 {
@@ -232,7 +232,7 @@ func (o *CommandmigrateOption) Preflight(f util.Factory, args []string) error {
232
232
}
233
233
234
234
// Run migrate resources from legacy clusters
235
- func (o * CommandmigrateOption ) Run (f util.Factory , args []string ) error {
235
+ func (o * CommandMigrateOption ) Run (f util.Factory , args []string ) error {
236
236
var memberClusterFactory cmdutil.Factory
237
237
var err error
238
238
@@ -268,7 +268,7 @@ func (o *CommandmigrateOption) Run(f util.Factory, args []string) error {
268
268
return o .migrate (controlPlaneRestConfig , obj , gvr )
269
269
}
270
270
271
- func (o * CommandmigrateOption ) migrate (controlPlaneRestConfig * rest.Config , obj * unstructured.Unstructured ,
271
+ func (o * CommandMigrateOption ) migrate (controlPlaneRestConfig * rest.Config , obj * unstructured.Unstructured ,
272
272
gvr schema.GroupVersionResource ,
273
273
) error {
274
274
if err := preprocessResource (obj ); err != nil {
@@ -277,7 +277,7 @@ func (o *CommandmigrateOption) migrate(controlPlaneRestConfig *rest.Config, obj
277
277
278
278
if o .OutputFormat != "" {
279
279
// only print the resource template and Policy
280
- err := o .printObjectAndPolicy (obj , gvr )
280
+ err := o .printObjectAndPolicy (obj )
281
281
282
282
return err
283
283
}
@@ -393,7 +393,7 @@ type Obj struct {
393
393
}
394
394
395
395
// getObjInfo get obj info in member cluster
396
- func (o * CommandmigrateOption ) getObjInfo (f cmdutil.Factory , cluster string , args []string ) (* Obj , error ) {
396
+ func (o * CommandMigrateOption ) getObjInfo (f cmdutil.Factory , cluster string , args []string ) (* Obj , error ) {
397
397
r := f .NewBuilder ().
398
398
Unstructured ().
399
399
NamespaceParam (o .Namespace ).
@@ -425,7 +425,7 @@ func (o *CommandmigrateOption) getObjInfo(f cmdutil.Factory, cluster string, arg
425
425
}
426
426
427
427
// printObjectAndPolicy print the converted resource
428
- func (o * CommandmigrateOption ) printObjectAndPolicy (obj * unstructured.Unstructured , gvr schema. GroupVersionResource ) error {
428
+ func (o * CommandMigrateOption ) printObjectAndPolicy (obj * unstructured.Unstructured ) error {
429
429
printer , err := o .Printer (nil , nil , false , false )
430
430
if err != nil {
431
431
return fmt .Errorf ("failed to initialize k8s printer. err: %w" , err )
@@ -458,7 +458,7 @@ func (o *CommandmigrateOption) printObjectAndPolicy(obj *unstructured.Unstructur
458
458
}
459
459
460
460
// createPropagationPolicy create PropagationPolicy in Kubeadmiral control plane
461
- func (o * CommandmigrateOption ) createPropagationPolicy (kubeadmiralClient * fedclient.Clientset ) (string , error ) {
461
+ func (o * CommandMigrateOption ) createPropagationPolicy (kubeadmiralClient * fedclient.Clientset ) (string , error ) {
462
462
var policyName string
463
463
if o .PolicyName == "" {
464
464
policyName = names .GeneratePolicyName (o .Namespace , o .name , o .gvk .String ())
@@ -482,7 +482,7 @@ func (o *CommandmigrateOption) createPropagationPolicy(kubeadmiralClient *fedcli
482
482
}
483
483
484
484
// createClusterPropagationPolicy create ClusterPropagationPolicy in Kubeadmiral control plane
485
- func (o * CommandmigrateOption ) createClusterPropagationPolicy (kubeadmiralClient * fedclient.Clientset ) (string , error ) {
485
+ func (o * CommandMigrateOption ) createClusterPropagationPolicy (kubeadmiralClient * fedclient.Clientset ) (string , error ) {
486
486
var policyName string
487
487
if o .PolicyName == "" {
488
488
policyName = names .GeneratePolicyName ("" , o .name , o .gvk .String ())
0 commit comments