mirror of https://github.com/docker/cli.git
Merge pull request #3978 from thaJeztah/minor_cleanups
some minor cleanups
This commit is contained in:
commit
5acb64944f
|
@ -95,16 +95,16 @@ func runCreate(dockerCli command.Cli, flags *pflag.FlagSet, options *createOptio
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
copts.env = *opts.NewListOptsRef(&newEnv, nil)
|
copts.env = *opts.NewListOptsRef(&newEnv, nil)
|
||||||
containerConfig, err := parse(flags, copts, dockerCli.ServerInfo().OSType)
|
containerCfg, err := parse(flags, copts, dockerCli.ServerInfo().OSType)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
reportError(dockerCli.Err(), "create", err.Error(), true)
|
reportError(dockerCli.Err(), "create", err.Error(), true)
|
||||||
return cli.StatusError{StatusCode: 125}
|
return cli.StatusError{StatusCode: 125}
|
||||||
}
|
}
|
||||||
if err = validateAPIVersion(containerConfig, dockerCli.Client().ClientVersion()); err != nil {
|
if err = validateAPIVersion(containerCfg, dockerCli.Client().ClientVersion()); err != nil {
|
||||||
reportError(dockerCli.Err(), "create", err.Error(), true)
|
reportError(dockerCli.Err(), "create", err.Error(), true)
|
||||||
return cli.StatusError{StatusCode: 125}
|
return cli.StatusError{StatusCode: 125}
|
||||||
}
|
}
|
||||||
response, err := createContainer(context.Background(), dockerCli, containerConfig, options)
|
response, err := createContainer(context.Background(), dockerCli, containerCfg, options)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -199,10 +199,10 @@ func newCIDFile(path string) (*cidFile, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
//nolint:gocyclo
|
//nolint:gocyclo
|
||||||
func createContainer(ctx context.Context, dockerCli command.Cli, containerConfig *containerConfig, opts *createOptions) (*container.CreateResponse, error) {
|
func createContainer(ctx context.Context, dockerCli command.Cli, containerCfg *containerConfig, opts *createOptions) (*container.CreateResponse, error) {
|
||||||
config := containerConfig.Config
|
config := containerCfg.Config
|
||||||
hostConfig := containerConfig.HostConfig
|
hostConfig := containerCfg.HostConfig
|
||||||
networkingConfig := containerConfig.NetworkingConfig
|
networkingConfig := containerCfg.NetworkingConfig
|
||||||
|
|
||||||
warnOnOomKillDisable(*hostConfig, dockerCli.Err())
|
warnOnOomKillDisable(*hostConfig, dockerCli.Err())
|
||||||
warnOnLocalhostDNS(*hostConfig, dockerCli.Err())
|
warnOnLocalhostDNS(*hostConfig, dockerCli.Err())
|
||||||
|
@ -293,8 +293,8 @@ func createContainer(ctx context.Context, dockerCli command.Cli, containerConfig
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, warning := range response.Warnings {
|
for _, w := range response.Warnings {
|
||||||
fmt.Fprintf(dockerCli.Err(), "WARNING: %s\n", warning)
|
fmt.Fprintf(dockerCli.Err(), "WARNING: %s\n", w)
|
||||||
}
|
}
|
||||||
err = containerIDFile.Write(response.ID)
|
err = containerIDFile.Write(response.ID)
|
||||||
return &response, err
|
return &response, err
|
||||||
|
|
|
@ -49,11 +49,11 @@ func parseRun(args []string) (*container.Config, *container.HostConfig, *network
|
||||||
return nil, nil, nil, err
|
return nil, nil, nil, err
|
||||||
}
|
}
|
||||||
// TODO: fix tests to accept ContainerConfig
|
// TODO: fix tests to accept ContainerConfig
|
||||||
containerConfig, err := parse(flags, copts, runtime.GOOS)
|
containerCfg, err := parse(flags, copts, runtime.GOOS)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, nil, err
|
return nil, nil, nil, err
|
||||||
}
|
}
|
||||||
return containerConfig.Config, containerConfig.HostConfig, containerConfig.NetworkingConfig, err
|
return containerCfg.Config, containerCfg.HostConfig, containerCfg.NetworkingConfig, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func setupRunFlags() (*pflag.FlagSet, *containerOptions) {
|
func setupRunFlags() (*pflag.FlagSet, *containerOptions) {
|
||||||
|
|
|
@ -105,22 +105,22 @@ func runRun(dockerCli command.Cli, flags *pflag.FlagSet, ropts *runOptions, copt
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
copts.env = *opts.NewListOptsRef(&newEnv, nil)
|
copts.env = *opts.NewListOptsRef(&newEnv, nil)
|
||||||
containerConfig, err := parse(flags, copts, dockerCli.ServerInfo().OSType)
|
containerCfg, err := parse(flags, copts, dockerCli.ServerInfo().OSType)
|
||||||
// just in case the parse does not exit
|
// just in case the parse does not exit
|
||||||
if err != nil {
|
if err != nil {
|
||||||
reportError(dockerCli.Err(), "run", err.Error(), true)
|
reportError(dockerCli.Err(), "run", err.Error(), true)
|
||||||
return cli.StatusError{StatusCode: 125}
|
return cli.StatusError{StatusCode: 125}
|
||||||
}
|
}
|
||||||
if err = validateAPIVersion(containerConfig, dockerCli.CurrentVersion()); err != nil {
|
if err = validateAPIVersion(containerCfg, dockerCli.CurrentVersion()); err != nil {
|
||||||
reportError(dockerCli.Err(), "run", err.Error(), true)
|
reportError(dockerCli.Err(), "run", err.Error(), true)
|
||||||
return cli.StatusError{StatusCode: 125}
|
return cli.StatusError{StatusCode: 125}
|
||||||
}
|
}
|
||||||
return runContainer(dockerCli, ropts, copts, containerConfig)
|
return runContainer(dockerCli, ropts, copts, containerCfg)
|
||||||
}
|
}
|
||||||
|
|
||||||
//nolint:gocyclo
|
//nolint:gocyclo
|
||||||
func runContainer(dockerCli command.Cli, opts *runOptions, copts *containerOptions, containerConfig *containerConfig) error {
|
func runContainer(dockerCli command.Cli, opts *runOptions, copts *containerOptions, containerCfg *containerConfig) error {
|
||||||
config := containerConfig.Config
|
config := containerCfg.Config
|
||||||
stdout, stderr := dockerCli.Out(), dockerCli.Err()
|
stdout, stderr := dockerCli.Out(), dockerCli.Err()
|
||||||
client := dockerCli.Client()
|
client := dockerCli.Client()
|
||||||
|
|
||||||
|
@ -144,7 +144,7 @@ func runContainer(dockerCli command.Cli, opts *runOptions, copts *containerOptio
|
||||||
ctx, cancelFun := context.WithCancel(context.Background())
|
ctx, cancelFun := context.WithCancel(context.Background())
|
||||||
defer cancelFun()
|
defer cancelFun()
|
||||||
|
|
||||||
createResponse, err := createContainer(ctx, dockerCli, containerConfig, &opts.createOptions)
|
createResponse, err := createContainer(ctx, dockerCli, containerCfg, &opts.createOptions)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
reportError(stderr, "run", err.Error(), true)
|
reportError(stderr, "run", err.Error(), true)
|
||||||
return runStartContainerErr(err)
|
return runStartContainerErr(err)
|
||||||
|
|
Loading…
Reference in New Issue