/
left76
/
ccli7
Обзор
Документация
Войти
/
left76
/
ccli7
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
cli/command/config/remove.go
53 строки
1 KB
Kir Kolyshkin
Switch from x/net/context to context
12 май 2018, 02:49
12 май 2018, 02:49
6f8070d
Код
Авторство
О чём код?
package config import ( "context" "fmt" "strings" "github.com/docker/cli/cli" "github.com/docker/cli/cli/command" "github.com/pkg/errors" "github.com/spf13/cobra" ) type removeOptions struct { names []string } func newConfigRemoveCommand(dockerCli command.Cli) *cobra.Command { return &cobra.Command{ Use: "rm CONFIG [CONFIG...]", Aliases: []string{"remove"}, Short: "Remove one or more configs", Args: cli.RequiresMinArgs(1), RunE: func(cmd *cobra.Command, args []string) error { opts := removeOptions{ names: args, } return runConfigRemove(dockerCli, opts) }, } } func runConfigRemove(dockerCli command.Cli, opts removeOptions) error { client := dockerCli.Client() ctx := context.Background() var errs []string for _, name := range opts.names { if err := client.ConfigRemove(ctx, name); err != nil { errs = append(errs, err.Error()) continue } fmt.Fprintln(dockerCli.Out(), name) } if len(errs) > 0 { return errors.Errorf("%s", strings.Join(errs, "\n")) } return nil }