diff --git a/api/server/router/build/build_routes.go b/api/server/router/build/build_routes.go index fb67534af2..44a3930af1 100644 --- a/api/server/router/build/build_routes.go +++ b/api/server/router/build/build_routes.go @@ -163,13 +163,17 @@ func newImageBuildOptions(ctx context.Context, r *http.Request) (*types.ImageBui } func parseVersion(s string) (types.BuilderVersion, error) { - if s == "" || s == string(types.BuilderV1) { + if s == "" { return types.BuilderV1, nil } - if s == string(types.BuilderBuildKit) { + switch types.BuilderVersion(s) { + case types.BuilderV1: + return types.BuilderV1, nil + case types.BuilderBuildKit: return types.BuilderBuildKit, nil + default: + return "", errors.Errorf("invalid version %s", s) } - return "", errors.Errorf("invalid version %s", s) } func (br *buildRouter) postPrune(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error { diff --git a/api/types/client.go b/api/types/client.go index 8363ed736e..ce67c19781 100644 --- a/api/types/client.go +++ b/api/types/client.go @@ -205,7 +205,7 @@ const ( // BuilderV1 is the first generation builder in docker daemon BuilderV1 BuilderVersion = "1" // BuilderBuildKit is builder based on moby/buildkit project - BuilderBuildKit = "2" + BuilderBuildKit BuilderVersion = "2" ) // ImageBuildResponse holds information