@@ -55,9 +55,10 @@ func NewCreateOptions() *CreateOptions {
55
55
OBServer : & param.OBServerSpec {
56
56
Storage : & param.OBServerStorageSpec {},
57
57
},
58
- Parameters : make ([]modelcommon.KVPair , 0 ),
59
- Zones : make (map [string ]string ),
60
- Topology : make ([]param.ZoneTopology , 0 ),
58
+ BackupVolume : & param.NFSVolumeSpec {},
59
+ Parameters : make ([]modelcommon.KVPair , 0 ),
60
+ Zones : make (map [string ]string ),
61
+ Topology : make ([]param.ZoneTopology , 0 ),
61
62
}
62
63
}
63
64
@@ -75,14 +76,20 @@ func (o *CreateOptions) Validate() error {
75
76
}
76
77
77
78
func (o * CreateOptions ) Parse (_ * cobra.Command , args []string ) error {
79
+ // Parse the zone topology
78
80
topology , err := utils .MapZonesToTopology (o .Zones )
79
81
if err != nil {
80
82
return err
81
83
}
84
+ // Parse the parameters
82
85
parameters , err := utils .MapParameters (o .KvParameters )
83
86
if err != nil {
84
87
return err
85
88
}
89
+ // Parse the BackupVolume related flags
90
+ if o .BackupVolume .Address == "" || o .BackupVolume .Path == "" {
91
+ o .BackupVolume = nil
92
+ }
86
93
o .Parameters = parameters
87
94
o .Topology = topology
88
95
o .Name = args [0 ]
@@ -256,7 +263,7 @@ func buildMonitorTemplate(monitorSpec *param.MonitorSpec) *apitypes.MonitorTempl
256
263
return monitorTemplate
257
264
}
258
265
259
- // Create an OBClusterInstance
266
+ // CreateOBClusterInstance creates an OBClusterInstance
260
267
func CreateOBClusterInstance (param * CreateOptions ) * v1alpha1.OBCluster {
261
268
observerTemplate := buildOBServerTemplate (param .OBServer )
262
269
monitorTemplate := buildMonitorTemplate (param .Monitor )
@@ -296,6 +303,7 @@ func (o *CreateOptions) AddFlags(cmd *cobra.Command) {
296
303
o .AddObserverFlags (cmd )
297
304
o .AddZoneFlags (cmd )
298
305
o .AddParameterFlags (cmd )
306
+ o .AddBackupVolumeFlags (cmd )
299
307
}
300
308
301
309
// AddZoneFlags adds the zone-related flags to the command.
@@ -342,8 +350,8 @@ func (o *CreateOptions) AddMonitorFlags(cmd *cobra.Command) {
342
350
// AddBackupVolumeFlags adds the backup-volume-related flags to the command.
343
351
func (o * CreateOptions ) AddBackupVolumeFlags (cmd * cobra.Command ) {
344
352
backupVolumeFlags := pflag .NewFlagSet (FLAGSET_BACKUP_VOLUME , pflag .ContinueOnError )
345
- backupVolumeFlags .StringVar (& o .BackupVolume .Address , FLAG_BACKUP_ADDRESS , DEFAULT_BACKUP_ADDRESS , "The storage class of the backup storage" )
346
- backupVolumeFlags .StringVar (& o .BackupVolume .Path , FLAG_BACKUP_PATH , DEFAULT_BACKUP_PATH , "The size of the backup storage" )
353
+ backupVolumeFlags .StringVar (& o .BackupVolume .Address , FLAG_BACKUP_ADDRESS , "" , "The storage class of the backup storage" )
354
+ backupVolumeFlags .StringVar (& o .BackupVolume .Path , FLAG_BACKUP_PATH , "" , "The size of the backup storage" )
347
355
cmd .Flags ().AddFlagSet (backupVolumeFlags )
348
356
}
349
357
0 commit comments