forked from TrueCloudLab/frostfs-node
[#1402] cli: Add cid
flag constant
Also, move common flag constants in `root` file of the `storagegroup` package. Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
parent
6f2363cf31
commit
bc5882fc89
6 changed files with 16 additions and 17 deletions
|
@ -24,8 +24,8 @@ func initSGDeleteCmd() {
|
||||||
|
|
||||||
flags := sgDelCmd.Flags()
|
flags := sgDelCmd.Flags()
|
||||||
|
|
||||||
flags.String("cid", "", "Container ID")
|
flags.String(cidFlag, "", "Container ID")
|
||||||
_ = sgDelCmd.MarkFlagRequired("cid")
|
_ = sgDelCmd.MarkFlagRequired(cidFlag)
|
||||||
|
|
||||||
flags.StringVarP(&sgID, sgIDFlag, "", "", "storage group identifier")
|
flags.StringVarP(&sgID, sgIDFlag, "", "", "storage group identifier")
|
||||||
_ = sgDelCmd.MarkFlagRequired(sgIDFlag)
|
_ = sgDelCmd.MarkFlagRequired(sgIDFlag)
|
||||||
|
|
|
@ -15,11 +15,6 @@ import (
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
|
||||||
sgIDFlag = "id"
|
|
||||||
sgRawFlag = "raw"
|
|
||||||
)
|
|
||||||
|
|
||||||
var sgID string
|
var sgID string
|
||||||
|
|
||||||
var sgGetCmd = &cobra.Command{
|
var sgGetCmd = &cobra.Command{
|
||||||
|
@ -34,8 +29,8 @@ func initSGGetCmd() {
|
||||||
|
|
||||||
flags := sgGetCmd.Flags()
|
flags := sgGetCmd.Flags()
|
||||||
|
|
||||||
flags.String("cid", "", "Container ID")
|
flags.String(cidFlag, "", "Container ID")
|
||||||
_ = sgGetCmd.MarkFlagRequired("cid")
|
_ = sgGetCmd.MarkFlagRequired(cidFlag)
|
||||||
|
|
||||||
flags.StringVarP(&sgID, sgIDFlag, "", "", "storage group identifier")
|
flags.StringVarP(&sgID, sgIDFlag, "", "", "storage group identifier")
|
||||||
_ = sgGetCmd.MarkFlagRequired(sgIDFlag)
|
_ = sgGetCmd.MarkFlagRequired(sgIDFlag)
|
||||||
|
|
|
@ -22,8 +22,8 @@ var sgListCmd = &cobra.Command{
|
||||||
func initSGListCmd() {
|
func initSGListCmd() {
|
||||||
commonflags.Init(sgListCmd)
|
commonflags.Init(sgListCmd)
|
||||||
|
|
||||||
sgListCmd.Flags().String("cid", "", "Container ID")
|
sgListCmd.Flags().String(cidFlag, "", "Container ID")
|
||||||
_ = sgListCmd.MarkFlagRequired("cid")
|
_ = sgListCmd.MarkFlagRequired(cidFlag)
|
||||||
}
|
}
|
||||||
|
|
||||||
func listSG(cmd *cobra.Command, _ []string) {
|
func listSG(cmd *cobra.Command, _ []string) {
|
||||||
|
|
|
@ -36,8 +36,8 @@ func initSGPutCmd() {
|
||||||
|
|
||||||
flags := sgPutCmd.Flags()
|
flags := sgPutCmd.Flags()
|
||||||
|
|
||||||
flags.String("cid", "", "Container ID")
|
flags.String(cidFlag, "", "Container ID")
|
||||||
_ = sgPutCmd.MarkFlagRequired("cid")
|
_ = sgPutCmd.MarkFlagRequired(cidFlag)
|
||||||
|
|
||||||
flags.StringSliceVarP(&sgMembers, sgMembersFlag, "m", nil, "ID list of storage group members")
|
flags.StringSliceVarP(&sgMembers, sgMembersFlag, "m", nil, "ID list of storage group members")
|
||||||
_ = sgPutCmd.MarkFlagRequired(sgMembersFlag)
|
_ = sgPutCmd.MarkFlagRequired(sgMembersFlag)
|
||||||
|
|
|
@ -19,6 +19,12 @@ var Cmd = &cobra.Command{
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const (
|
||||||
|
sgIDFlag = "id"
|
||||||
|
sgRawFlag = "raw"
|
||||||
|
cidFlag = "cid"
|
||||||
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
storageGroupChildCommands := []*cobra.Command{
|
storageGroupChildCommands := []*cobra.Command{
|
||||||
sgPutCmd,
|
sgPutCmd,
|
||||||
|
|
|
@ -20,11 +20,9 @@ func readObjectAddress(cmd *cobra.Command, cnr *cid.ID, obj *oid.ID) oid.Address
|
||||||
}
|
}
|
||||||
|
|
||||||
func readCID(cmd *cobra.Command, id *cid.ID) {
|
func readCID(cmd *cobra.Command, id *cid.ID) {
|
||||||
const flag = "cid"
|
f := cmd.Flag(cidFlag)
|
||||||
|
|
||||||
f := cmd.Flag(flag)
|
|
||||||
if f == nil {
|
if f == nil {
|
||||||
common.ExitOnErr(cmd, "", fmt.Errorf("missing container flag (%s)", flag))
|
common.ExitOnErr(cmd, "", fmt.Errorf("missing container flag (%s)", cidFlag))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue