@@ -55,9 +55,10 @@ func NewCreateOptions() *CreateOptions {
5555 OBServer : & param.OBServerSpec {
5656 Storage : & param.OBServerStorageSpec {},
5757 },
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 ),
6162 }
6263}
6364
@@ -75,14 +76,20 @@ func (o *CreateOptions) Validate() error {
7576}
7677
7778func (o * CreateOptions ) Parse (_ * cobra.Command , args []string ) error {
79+ // Parse the zone topology
7880 topology , err := utils .MapZonesToTopology (o .Zones )
7981 if err != nil {
8082 return err
8183 }
84+ // Parse the parameters
8285 parameters , err := utils .MapParameters (o .KvParameters )
8386 if err != nil {
8487 return err
8588 }
89+ // Parse the BackupVolume related flags
90+ if o .BackupVolume .Address == "" || o .BackupVolume .Path == "" {
91+ o .BackupVolume = nil
92+ }
8693 o .Parameters = parameters
8794 o .Topology = topology
8895 o .Name = args [0 ]
@@ -256,7 +263,7 @@ func buildMonitorTemplate(monitorSpec *param.MonitorSpec) *apitypes.MonitorTempl
256263 return monitorTemplate
257264}
258265
259- // Create an OBClusterInstance
266+ // CreateOBClusterInstance creates an OBClusterInstance
260267func CreateOBClusterInstance (param * CreateOptions ) * v1alpha1.OBCluster {
261268 observerTemplate := buildOBServerTemplate (param .OBServer )
262269 monitorTemplate := buildMonitorTemplate (param .Monitor )
@@ -296,6 +303,7 @@ func (o *CreateOptions) AddFlags(cmd *cobra.Command) {
296303 o .AddObserverFlags (cmd )
297304 o .AddZoneFlags (cmd )
298305 o .AddParameterFlags (cmd )
306+ o .AddBackupVolumeFlags (cmd )
299307}
300308
301309// AddZoneFlags adds the zone-related flags to the command.
@@ -342,8 +350,8 @@ func (o *CreateOptions) AddMonitorFlags(cmd *cobra.Command) {
342350// AddBackupVolumeFlags adds the backup-volume-related flags to the command.
343351func (o * CreateOptions ) AddBackupVolumeFlags (cmd * cobra.Command ) {
344352 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" )
347355 cmd .Flags ().AddFlagSet (backupVolumeFlags )
348356}
349357
0 commit comments