1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

api/types: minor BuilderVersion refactor

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2019-10-13 14:34:29 +02:00
parent 3152f94362
commit 20e3b5ba2c
No known key found for this signature in database
GPG key ID: 76698F39D527CE8C
2 changed files with 8 additions and 4 deletions

View file

@ -163,13 +163,17 @@ func newImageBuildOptions(ctx context.Context, r *http.Request) (*types.ImageBui
} }
func parseVersion(s string) (types.BuilderVersion, error) { func parseVersion(s string) (types.BuilderVersion, error) {
if s == "" || s == string(types.BuilderV1) { if s == "" {
return types.BuilderV1, nil 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 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 { func (br *buildRouter) postPrune(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {

View file

@ -205,7 +205,7 @@ const (
// BuilderV1 is the first generation builder in docker daemon // BuilderV1 is the first generation builder in docker daemon
BuilderV1 BuilderVersion = "1" BuilderV1 BuilderVersion = "1"
// BuilderBuildKit is builder based on moby/buildkit project // BuilderBuildKit is builder based on moby/buildkit project
BuilderBuildKit = "2" BuilderBuildKit BuilderVersion = "2"
) )
// ImageBuildResponse holds information // ImageBuildResponse holds information