mirror of https://github.com/docker/compose.git
Volume command is only available in aci context type, with ACI specific flags
Signed-off-by: Guillaume Tardif <guillaume.tardif@docker.com>
This commit is contained in:
parent
18ad20f1c5
commit
38a8f5310b
cli
|
@ -20,14 +20,15 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
"github.com/docker/compose-cli/aci"
|
"github.com/docker/compose-cli/aci"
|
||||||
"github.com/docker/compose-cli/api/client"
|
"github.com/docker/compose-cli/api/client"
|
||||||
"github.com/docker/compose-cli/progress"
|
"github.com/docker/compose-cli/progress"
|
||||||
"github.com/spf13/cobra"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Command manage volumes
|
// ACICommand manage volumes
|
||||||
func Command() *cobra.Command {
|
func ACICommand() *cobra.Command {
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "volume",
|
Use: "volume",
|
||||||
Short: "Manages volumes",
|
Short: "Manages volumes",
|
||||||
|
@ -42,7 +43,7 @@ func Command() *cobra.Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
func createVolume() *cobra.Command {
|
func createVolume() *cobra.Command {
|
||||||
opts := aci.VolumeCreateOptions{}
|
aciOpts := aci.VolumeCreateOptions{}
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "create",
|
Use: "create",
|
||||||
Short: "Creates an Azure file share to use as ACI volume.",
|
Short: "Creates an Azure file share to use as ACI volume.",
|
||||||
|
@ -54,7 +55,7 @@ func createVolume() *cobra.Command {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
err = progress.Run(ctx, func(ctx context.Context) error {
|
err = progress.Run(ctx, func(ctx context.Context) error {
|
||||||
_, err := c.VolumeService().Create(ctx, opts)
|
_, err := c.VolumeService().Create(ctx, aciOpts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -68,13 +69,13 @@ func createVolume() *cobra.Command {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd.Flags().StringVar(&opts.Account, "storage-account", "", "Storage account name")
|
cmd.Flags().StringVar(&aciOpts.Account, "storage-account", "", "Storage account name")
|
||||||
cmd.Flags().StringVar(&opts.Fileshare, "fileshare", "", "Fileshare name")
|
cmd.Flags().StringVar(&aciOpts.Fileshare, "fileshare", "", "Fileshare name")
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
func rmVolume() *cobra.Command {
|
func rmVolume() *cobra.Command {
|
||||||
opts := aci.VolumeDeleteOptions{}
|
aciOpts := aci.VolumeDeleteOptions{}
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "rm",
|
Use: "rm",
|
||||||
Short: "Deletes an Azure file share and/or the Azure storage account.",
|
Short: "Deletes an Azure file share and/or the Azure storage account.",
|
||||||
|
@ -84,12 +85,12 @@ func rmVolume() *cobra.Command {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return c.VolumeService().Delete(cmd.Context(), opts)
|
return c.VolumeService().Delete(cmd.Context(), aciOpts)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd.Flags().StringVar(&opts.Account, "storage-account", "", "Storage account name")
|
cmd.Flags().StringVar(&aciOpts.Account, "storage-account", "", "Storage account name")
|
||||||
cmd.Flags().StringVar(&opts.Fileshare, "fileshare", "", "Fileshare name")
|
cmd.Flags().StringVar(&aciOpts.Fileshare, "fileshare", "", "Fileshare name")
|
||||||
cmd.Flags().BoolVar(&opts.DeleteAccount, "delete-storage-account", false, "Also delete storage account")
|
cmd.Flags().BoolVar(&aciOpts.DeleteAccount, "delete-storage-account", false, "Also delete storage account")
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
|
@ -135,7 +135,6 @@ func main() {
|
||||||
|
|
||||||
// Place holders
|
// Place holders
|
||||||
cmd.EcsCommand(),
|
cmd.EcsCommand(),
|
||||||
volume.Command(),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
helpFunc := root.HelpFunc()
|
helpFunc := root.HelpFunc()
|
||||||
|
@ -185,6 +184,11 @@ func main() {
|
||||||
ctype = cc.Type()
|
ctype = cc.Type()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ctype == store.AciContextType {
|
||||||
|
// we can also pass ctype as a parameter to the volume command and customize subcommands, flags, etc. when we have other backend implementations
|
||||||
|
root.AddCommand(volume.ACICommand())
|
||||||
|
}
|
||||||
|
|
||||||
metrics.Track(ctype, os.Args[1:], root.PersistentFlags())
|
metrics.Track(ctype, os.Args[1:], root.PersistentFlags())
|
||||||
|
|
||||||
ctx = apicontext.WithCurrentContext(ctx, currentContext)
|
ctx = apicontext.WithCurrentContext(ctx, currentContext)
|
||||||
|
|
Loading…
Reference in New Issue