@@ -4,21 +4,16 @@ import (
44 "bytes"
55 "context"
66 "encoding/json"
7- "errors"
87 "fmt"
98 "io/ioutil"
109 "os"
1110 "path/filepath"
1211 "strconv"
1312 "strings"
1413
15- errors2 "github.com/pkg/errors"
16-
17- "github.com/docker/app/internal"
18- "github.com/docker/cnab-to-oci/remotes"
19-
2014 "github.com/deislabs/cnab-go/bundle"
2115 cnab "github.com/deislabs/cnab-go/driver"
16+ "github.com/docker/app/internal"
2217 "github.com/docker/app/internal/packager"
2318 "github.com/docker/app/types"
2419 "github.com/docker/buildx/build"
@@ -27,24 +22,27 @@ import (
2722 "github.com/docker/buildx/util/progress"
2823 "github.com/docker/cli/cli"
2924 "github.com/docker/cli/cli/command"
25+ "github.com/docker/cnab-to-oci/remotes"
3026 "github.com/docker/distribution/reference"
3127 "github.com/moby/buildkit/client"
3228 "github.com/moby/buildkit/session"
3329 "github.com/moby/buildkit/session/auth/authprovider"
3430 "github.com/moby/buildkit/util/appcontext"
31+ "github.com/pkg/errors"
3532 "github.com/sirupsen/logrus"
3633 "github.com/spf13/cobra"
3734)
3835
3936type buildOptions struct {
40- noCache bool
41- progress string
42- pull bool
43- tag string
44- folder string
45- imageIDFile string
46- args []string
47- quiet bool
37+ noCache bool
38+ progress string
39+ pull bool
40+ tag string
41+ folder string
42+ imageIDFile string
43+ args []string
44+ quiet bool
45+ noResolveImage bool
4846}
4947
5048func Cmd (dockerCli command.Cli ) * cobra.Command {
@@ -63,6 +61,7 @@ $ docker app build . -f myapp.dockerapp -t myrepo/myapp:1.0.0`,
6361 flags := cmd .Flags ()
6462 flags .BoolVar (& opts .noCache , "no-cache" , false , "Do not use cache when building the App image" )
6563 flags .StringVar (& opts .progress , "progress" , "auto" , "Set type of progress output (auto, plain, tty). Use plain to show container output" )
64+ flags .BoolVar (& opts .noResolveImage , "no-resolve-image" , false , "Do not query the registry to resolve image digest" )
6665 flags .StringVarP (& opts .tag , "tag" , "t" , "" , "App image tag, optionally in the 'repo:tag' format" )
6766 flags .StringVarP (& opts .folder , "folder" , "f" , "" , "App definition as a .dockerapp directory" )
6867 flags .BoolVar (& opts .pull , "pull" , false , "Always attempt to pull a newer version of the App image" )
@@ -196,22 +195,22 @@ func buildImageUsingBuildx(app *types.App, contextPath string, opt buildOptions,
196195func fixServiceImageReferences (ctx context.Context , dockerCli command.Cli , bundle * bundle.Bundle , pulledServices []ServiceConfig ) error {
197196 insecureRegistries , err := internal .InsecureRegistriesFromEngine (dockerCli )
198197 if err != nil {
199- return errors2 .Wrapf (err , "could not retrieve insecure registries" )
198+ return errors .Wrapf (err , "could not retrieve insecure registries" )
200199 }
201200 resolver := remotes .CreateResolver (dockerCli .ConfigFile (), insecureRegistries ... )
202201 for _ , service := range pulledServices {
203202 image := bundle .Images [service .Name ]
204203 ref , err := reference .ParseNormalizedNamed (* service .Image )
205204 if err != nil {
206- return errors2 .Wrapf (err , "could not resolve image %s" , * service .Image )
205+ return errors .Wrapf (err , "could not resolve image %s" , * service .Image )
207206 }
208207 _ , desc , err := resolver .Resolve (ctx , ref .String ())
209208 if err != nil {
210- return errors2 .Wrapf (err , "could not resolve image %s" , ref .Name ())
209+ return errors .Wrapf (err , "could not resolve image %s" , ref .Name ())
211210 }
212211 canonical , err := reference .WithDigest (ref , desc .Digest )
213212 if err != nil {
214- return errors2 .Wrapf (err , "could not resolve image %s" , ref .Name ())
213+ return errors .Wrapf (err , "could not resolve image %s" , ref .Name ())
215214 }
216215 image .Image = canonical .String ()
217216 bundle .Images [service .Name ] = image
@@ -251,7 +250,7 @@ func checkMinimalEngineVersion(dockerCli command.Cli) error {
251250 return err
252251 }
253252 if majorVersion < 19 {
254- return errors . New ("'build' require docker engine 19.03 or later" )
253+ return fmt . Errorf ("'build' require docker engine 19.03 or later" )
255254 }
256255 return nil
257256}
0 commit comments