Skip to content
Closed
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
13 changes: 13 additions & 0 deletions cli/command/image/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
units "github.com/docker/go-units"
"github.com/pkg/errors"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
"golang.org/x/net/context"
)

Expand Down Expand Up @@ -77,6 +78,15 @@ func (o buildOptions) contextFromStdin() bool {
return o.context == "-"
}

func setDefaultsFromConfig(cli command.Cli, flags *pflag.FlagSet, options *buildOptions) {
if !flags.Changed("stream") && isSessionSupported(cli) {
// if stream is not set try the default from config file
if v := cli.ConfigFile().BuildStreamContext; v != nil {
options.stream = *v
}
}
}

func newBuildOptions() buildOptions {
ulimits := make(map[string]*units.Ulimit)
return buildOptions{
Expand All @@ -98,6 +108,9 @@ func NewBuildCommand(dockerCli command.Cli) *cobra.Command {
Args: cli.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
options.context = args[0]

setDefaultsFromConfig(dockerCli, cmd.Flags(), &options)

return runBuild(dockerCli, options)
},
}
Expand Down
1 change: 1 addition & 0 deletions cli/config/configfile/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ type ConfigFile struct {
NodesFormat string `json:"nodesFormat,omitempty"`
PruneFilters []string `json:"pruneFilters,omitempty"`
Proxies map[string]ProxyConfig `json:"proxies,omitempty"`
BuildStreamContext *bool `json:"buildStreamContext,omitempty"`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thaJeztah buildStreamContext or streamBuildContext?

Copy link
Contributor

@dnephin dnephin Jun 29, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess most of these start with the object name (service, images, etc). but buildStreamContext doesn't read too well.

How about buildAlwaysStreamContext (or buildDefaultStreamContext) ? That way it's a little more clear what this is enabling.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Argh. naming. hm

Do we have other contexts other than for build? For booleans, I always liked, e.g. enableSomething (EnableContextStreaming e.g.), but that may be a bit too verbose

Do we expect more build-related options? If so, possibly have a build key, containing stream-context (in the JSON)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd be good with a build key.

I don't think Enable is right, it's not enabling a feature, it's just changing the default.

}

// ProxyConfig contains proxy configuration settings
Expand Down