Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix both disk wipe and deprecated command invocations #88

Merged
merged 3 commits into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions cmd/disk_partition.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,8 @@ func init() {

diskCommand.AddCommand(diskPartitionCommand)

rootCmd.AddCommand(&cobra.Command{
Use: "partition-disk",
Deprecated: "use \"disk partition\"",
Run: diskPartitionCommand.Run,
})
deprecated := *diskPartitionCommand
deprecated.Use = "partition-disk"
deprecated.Deprecated = "use \"disk partition\""
rootCmd.AddCommand(&deprecated)
}
6 changes: 4 additions & 2 deletions cmd/disk_wipe.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"context"
"errors"
"os"
"time"

"github.com/bmc-toolbox/common"
"github.com/metal-toolbox/ironlib"
Expand Down Expand Up @@ -32,9 +33,9 @@ func init() {
logger.With("error", err).Fatal("--timeout argument is invalid")
}

verbose, err := cmd.Flags().GetBool("verbose")
verbose, err := cmd.Flags().GetBool("debug")
if err != nil {
logger.With("error", err).Fatal("--verbose argument is invalid")
logger.With("error", err).Fatal("--debug argument is invalid")
}

driveName := args[0]
Expand Down Expand Up @@ -90,5 +91,6 @@ func init() {
},
}

diskCommand.PersistentFlags().Duration("timeout", 1*time.Minute, "Time to wait for wipe to complete")
diskCommand.AddCommand(cmd)
}
27 changes: 13 additions & 14 deletions cmd/partition_format.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/spf13/cobra"
)

var partitionFormatPartitionCommand = &cobra.Command{
var partitionFormatCommand = &cobra.Command{
Use: "format",
Short: "Formats a partition",
Long: "Formats a partition with your choice of filesystem",
Expand Down Expand Up @@ -49,21 +49,20 @@ var partitionFormatPartitionCommand = &cobra.Command{
}

func init() {
partitionFormatPartitionCommand.PersistentFlags().String("device", "", "Block device")
partitionFormatPartitionCommand.PersistentFlags().String("filesystem-device", "", "Filesystem Block device")
partitionFormatCommand.PersistentFlags().String("device", "", "Block device")
partitionFormatCommand.PersistentFlags().String("filesystem-device", "", "Filesystem Block device")

partitionFormatPartitionCommand.PersistentFlags().Uint("partition", 0, "Partition number")
partitionFormatCommand.PersistentFlags().Uint("partition", 0, "Partition number")

partitionFormatPartitionCommand.PersistentFlags().String("format", "ext4", "Filesystem to be applied to the partition")
markFlagAsRequired(partitionFormatPartitionCommand, "format")
partitionFormatCommand.PersistentFlags().String("format", "ext4", "Filesystem to be applied to the partition")
markFlagAsRequired(partitionFormatCommand, "format")

partitionFormatPartitionCommand.PersistentFlags().String("mount-point", "/", "Filesystem mount point")
partitionFormatPartitionCommand.PersistentFlags().StringSlice("options", []string{}, "Filesystem creation options")
partitionCommand.AddCommand(partitionFormatPartitionCommand)
partitionFormatCommand.PersistentFlags().String("mount-point", "/", "Filesystem mount point")
partitionFormatCommand.PersistentFlags().StringSlice("options", []string{}, "Filesystem creation options")
partitionCommand.AddCommand(partitionFormatCommand)

rootCmd.AddCommand(&cobra.Command{
Use: "format-partition",
Deprecated: "use \"partition format\"",
Run: partitionFormatPartitionCommand.Run,
})
deprecated := *partitionFormatCommand
deprecated.Use = "format-partition"
deprecated.Deprecated = "use \"partition format\""
rootCmd.AddCommand(&deprecated)
}