MCPcopy Index your code
hub / github.com/docker/cli / BuildKitEnabled

Method BuildKitEnabled

cli/command/cli.go:151–177  ·  view source on GitHub ↗

BuildKitEnabled returns buildkit is enabled or not.

()

Source from the content-addressed store, hash-verified

149
150// BuildKitEnabled returns buildkit is enabled or not.
151func (cli *DockerCli) BuildKitEnabled() (bool, error) {
152 // use DOCKER_BUILDKIT env var value if set and not empty
153 if v := os.Getenv("DOCKER_BUILDKIT"); v != "" {
154 enabled, err := strconv.ParseBool(v)
155 if err != nil {
156 return false, fmt.Errorf("DOCKER_BUILDKIT environment variable expects boolean value: %w", err)
157 }
158 return enabled, nil
159 }
160 // if a builder alias is defined, we are using BuildKit
161 aliasMap := cli.ConfigFile().Aliases
162 if _, ok := aliasMap["builder"]; ok {
163 return true, nil
164 }
165
166 si := cli.ServerInfo()
167 if si.BuildkitVersion == build.BuilderBuildKit {
168 // The daemon advertised BuildKit as the preferred builder; this may
169 // be either a Linux daemon or a Windows daemon with experimental
170 // BuildKit support enabled.
171 return true, nil
172 }
173
174 // otherwise, assume BuildKit is enabled for Linux, but disabled for
175 // Windows / WCOW, which does not yet support BuildKit by default.
176 return si.OSType != "windows", nil
177}
178
179// HooksEnabled returns whether plugin hooks are enabled.
180func (cli *DockerCli) HooksEnabled() bool {

Callers

nothing calls this directly

Calls 2

ConfigFileMethod · 0.95
ServerInfoMethod · 0.95

Tested by

no test coverage detected