mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #12611 from LK4D4/remove_eng_chain_pull
Remove chain of engine passing from builder to loadManifest
This commit is contained in:
commit
ccbb93e1cd
7 changed files with 18 additions and 25 deletions
|
@ -708,7 +708,7 @@ func (s *Server) postCommit(eng *engine.Engine, version version.Version, w http.
|
||||||
Config: c,
|
Config: c,
|
||||||
}
|
}
|
||||||
|
|
||||||
imgID, err := builder.Commit(s.daemon, eng, cont, containerCommitConfig)
|
imgID, err := builder.Commit(s.daemon, cont, containerCommitConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -764,7 +764,7 @@ func (s *Server) postImagesCreate(eng *engine.Engine, version version.Version, w
|
||||||
imagePullConfig.Json = false
|
imagePullConfig.Json = false
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := s.daemon.Repositories().Pull(image, tag, imagePullConfig, eng); err != nil {
|
if err := s.daemon.Repositories().Pull(image, tag, imagePullConfig); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
} else { //import
|
} else { //import
|
||||||
|
@ -785,7 +785,7 @@ func (s *Server) postImagesCreate(eng *engine.Engine, version version.Version, w
|
||||||
imageImportConfig.Json = false
|
imageImportConfig.Json = false
|
||||||
}
|
}
|
||||||
|
|
||||||
newConfig, err := builder.BuildFromConfig(s.daemon, eng, &runconfig.Config{}, imageImportConfig.Changes)
|
newConfig, err := builder.BuildFromConfig(s.daemon, &runconfig.Config{}, imageImportConfig.Changes)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -1327,7 +1327,7 @@ func (s *Server) postBuild(eng *engine.Engine, version version.Version, w http.R
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := builder.Build(s.daemon, eng, buildConfig); err != nil {
|
if err := builder.Build(s.daemon, buildConfig); err != nil {
|
||||||
// Do not write the error in the http output if it's still empty.
|
// Do not write the error in the http output if it's still empty.
|
||||||
// This prevents from writing a 200(OK) when there is an interal error.
|
// This prevents from writing a 200(OK) when there is an interal error.
|
||||||
if !output.Flushed() {
|
if !output.Flushed() {
|
||||||
|
|
|
@ -31,7 +31,6 @@ import (
|
||||||
"github.com/docker/docker/builder/command"
|
"github.com/docker/docker/builder/command"
|
||||||
"github.com/docker/docker/builder/parser"
|
"github.com/docker/docker/builder/parser"
|
||||||
"github.com/docker/docker/daemon"
|
"github.com/docker/docker/daemon"
|
||||||
"github.com/docker/docker/engine"
|
|
||||||
"github.com/docker/docker/pkg/fileutils"
|
"github.com/docker/docker/pkg/fileutils"
|
||||||
"github.com/docker/docker/pkg/streamformatter"
|
"github.com/docker/docker/pkg/streamformatter"
|
||||||
"github.com/docker/docker/pkg/stringid"
|
"github.com/docker/docker/pkg/stringid"
|
||||||
|
@ -80,7 +79,6 @@ func init() {
|
||||||
// processing as it evaluates the parsing result.
|
// processing as it evaluates the parsing result.
|
||||||
type Builder struct {
|
type Builder struct {
|
||||||
Daemon *daemon.Daemon
|
Daemon *daemon.Daemon
|
||||||
Engine *engine.Engine
|
|
||||||
|
|
||||||
// effectively stdio for the run. Because it is not stdio, I said
|
// effectively stdio for the run. Because it is not stdio, I said
|
||||||
// "Effectively". Do not use stdio anywhere in this package for any reason.
|
// "Effectively". Do not use stdio anywhere in this package for any reason.
|
||||||
|
|
|
@ -454,7 +454,7 @@ func (b *Builder) pullImage(name string) (*imagepkg.Image, error) {
|
||||||
Json: b.StreamFormatter.Json(),
|
Json: b.StreamFormatter.Json(),
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := b.Daemon.Repositories().Pull(remote, tag, imagePullConfig, b.Engine); err != nil {
|
if err := b.Daemon.Repositories().Pull(remote, tag, imagePullConfig); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,6 @@ import (
|
||||||
"github.com/docker/docker/api"
|
"github.com/docker/docker/api"
|
||||||
"github.com/docker/docker/builder/parser"
|
"github.com/docker/docker/builder/parser"
|
||||||
"github.com/docker/docker/daemon"
|
"github.com/docker/docker/daemon"
|
||||||
"github.com/docker/docker/engine"
|
|
||||||
"github.com/docker/docker/graph"
|
"github.com/docker/docker/graph"
|
||||||
"github.com/docker/docker/pkg/archive"
|
"github.com/docker/docker/pkg/archive"
|
||||||
"github.com/docker/docker/pkg/httputils"
|
"github.com/docker/docker/pkg/httputils"
|
||||||
|
@ -83,7 +82,7 @@ func NewBuildConfig() *Config {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func Build(d *daemon.Daemon, e *engine.Engine, buildConfig *Config) error {
|
func Build(d *daemon.Daemon, buildConfig *Config) error {
|
||||||
var (
|
var (
|
||||||
repoName string
|
repoName string
|
||||||
tag string
|
tag string
|
||||||
|
@ -150,7 +149,6 @@ func Build(d *daemon.Daemon, e *engine.Engine, buildConfig *Config) error {
|
||||||
|
|
||||||
builder := &Builder{
|
builder := &Builder{
|
||||||
Daemon: d,
|
Daemon: d,
|
||||||
Engine: e,
|
|
||||||
OutStream: &streamformatter.StdoutFormater{
|
OutStream: &streamformatter.StdoutFormater{
|
||||||
Writer: buildConfig.Stdout,
|
Writer: buildConfig.Stdout,
|
||||||
StreamFormatter: sf,
|
StreamFormatter: sf,
|
||||||
|
@ -188,7 +186,7 @@ func Build(d *daemon.Daemon, e *engine.Engine, buildConfig *Config) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func BuildFromConfig(d *daemon.Daemon, e *engine.Engine, c *runconfig.Config, changes []string) (*runconfig.Config, error) {
|
func BuildFromConfig(d *daemon.Daemon, c *runconfig.Config, changes []string) (*runconfig.Config, error) {
|
||||||
ast, err := parser.Parse(bytes.NewBufferString(strings.Join(changes, "\n")))
|
ast, err := parser.Parse(bytes.NewBufferString(strings.Join(changes, "\n")))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -203,7 +201,6 @@ func BuildFromConfig(d *daemon.Daemon, e *engine.Engine, c *runconfig.Config, ch
|
||||||
|
|
||||||
builder := &Builder{
|
builder := &Builder{
|
||||||
Daemon: d,
|
Daemon: d,
|
||||||
Engine: e,
|
|
||||||
Config: c,
|
Config: c,
|
||||||
OutStream: ioutil.Discard,
|
OutStream: ioutil.Discard,
|
||||||
ErrStream: ioutil.Discard,
|
ErrStream: ioutil.Discard,
|
||||||
|
@ -219,13 +216,13 @@ func BuildFromConfig(d *daemon.Daemon, e *engine.Engine, c *runconfig.Config, ch
|
||||||
return builder.Config, nil
|
return builder.Config, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func Commit(d *daemon.Daemon, eng *engine.Engine, name string, c *daemon.ContainerCommitConfig) (string, error) {
|
func Commit(d *daemon.Daemon, name string, c *daemon.ContainerCommitConfig) (string, error) {
|
||||||
container, err := d.Get(name)
|
container, err := d.Get(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
newConfig, err := BuildFromConfig(d, eng, c.Config, c.Changes)
|
newConfig, err := BuildFromConfig(d, c.Config, c.Changes)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,6 @@ import (
|
||||||
|
|
||||||
"github.com/Sirupsen/logrus"
|
"github.com/Sirupsen/logrus"
|
||||||
"github.com/docker/distribution/digest"
|
"github.com/docker/distribution/digest"
|
||||||
"github.com/docker/docker/engine"
|
|
||||||
"github.com/docker/docker/registry"
|
"github.com/docker/docker/registry"
|
||||||
"github.com/docker/docker/trust"
|
"github.com/docker/docker/trust"
|
||||||
"github.com/docker/docker/utils"
|
"github.com/docker/docker/utils"
|
||||||
|
@ -18,7 +17,7 @@ import (
|
||||||
// contains no signatures by a trusted key for the name in the manifest, the
|
// contains no signatures by a trusted key for the name in the manifest, the
|
||||||
// image is not considered verified. The parsed manifest object and a boolean
|
// image is not considered verified. The parsed manifest object and a boolean
|
||||||
// for whether the manifest is verified is returned.
|
// for whether the manifest is verified is returned.
|
||||||
func (s *TagStore) loadManifest(eng *engine.Engine, manifestBytes []byte, dgst, ref string) (*registry.ManifestData, bool, error) {
|
func (s *TagStore) loadManifest(manifestBytes []byte, dgst, ref string) (*registry.ManifestData, bool, error) {
|
||||||
sig, err := libtrust.ParsePrettySignature(manifestBytes, "signatures")
|
sig, err := libtrust.ParsePrettySignature(manifestBytes, "signatures")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, false, fmt.Errorf("error parsing payload: %s", err)
|
return nil, false, fmt.Errorf("error parsing payload: %s", err)
|
||||||
|
|
|
@ -12,7 +12,6 @@ import (
|
||||||
|
|
||||||
"github.com/Sirupsen/logrus"
|
"github.com/Sirupsen/logrus"
|
||||||
"github.com/docker/distribution/digest"
|
"github.com/docker/distribution/digest"
|
||||||
"github.com/docker/docker/engine"
|
|
||||||
"github.com/docker/docker/image"
|
"github.com/docker/docker/image"
|
||||||
"github.com/docker/docker/pkg/progressreader"
|
"github.com/docker/docker/pkg/progressreader"
|
||||||
"github.com/docker/docker/pkg/streamformatter"
|
"github.com/docker/docker/pkg/streamformatter"
|
||||||
|
@ -29,7 +28,7 @@ type ImagePullConfig struct {
|
||||||
OutStream io.Writer
|
OutStream io.Writer
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *TagStore) Pull(image string, tag string, imagePullConfig *ImagePullConfig, eng *engine.Engine) error {
|
func (s *TagStore) Pull(image string, tag string, imagePullConfig *ImagePullConfig) error {
|
||||||
var (
|
var (
|
||||||
sf = streamformatter.NewStreamFormatter(imagePullConfig.Json)
|
sf = streamformatter.NewStreamFormatter(imagePullConfig.Json)
|
||||||
)
|
)
|
||||||
|
@ -74,7 +73,7 @@ func (s *TagStore) Pull(image string, tag string, imagePullConfig *ImagePullConf
|
||||||
}
|
}
|
||||||
|
|
||||||
logrus.Debugf("pulling v2 repository with local name %q", repoInfo.LocalName)
|
logrus.Debugf("pulling v2 repository with local name %q", repoInfo.LocalName)
|
||||||
if err := s.pullV2Repository(eng, r, imagePullConfig.OutStream, repoInfo, tag, sf, imagePullConfig.Parallel); err == nil {
|
if err := s.pullV2Repository(r, imagePullConfig.OutStream, repoInfo, tag, sf, imagePullConfig.Parallel); err == nil {
|
||||||
s.eventsService.Log("pull", logName, "")
|
s.eventsService.Log("pull", logName, "")
|
||||||
return nil
|
return nil
|
||||||
} else if err != registry.ErrDoesNotExist && err != ErrV2RegistryUnavailable {
|
} else if err != registry.ErrDoesNotExist && err != ErrV2RegistryUnavailable {
|
||||||
|
@ -369,7 +368,7 @@ type downloadInfo struct {
|
||||||
err chan error
|
err chan error
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *TagStore) pullV2Repository(eng *engine.Engine, r *registry.Session, out io.Writer, repoInfo *registry.RepositoryInfo, tag string, sf *streamformatter.StreamFormatter, parallel bool) error {
|
func (s *TagStore) pullV2Repository(r *registry.Session, out io.Writer, repoInfo *registry.RepositoryInfo, tag string, sf *streamformatter.StreamFormatter, parallel bool) error {
|
||||||
endpoint, err := r.V2RegistryEndpoint(repoInfo.Index)
|
endpoint, err := r.V2RegistryEndpoint(repoInfo.Index)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if repoInfo.Index.Official {
|
if repoInfo.Index.Official {
|
||||||
|
@ -393,14 +392,14 @@ func (s *TagStore) pullV2Repository(eng *engine.Engine, r *registry.Session, out
|
||||||
return registry.ErrDoesNotExist
|
return registry.ErrDoesNotExist
|
||||||
}
|
}
|
||||||
for _, t := range tags {
|
for _, t := range tags {
|
||||||
if downloaded, err := s.pullV2Tag(eng, r, out, endpoint, repoInfo, t, sf, parallel, auth); err != nil {
|
if downloaded, err := s.pullV2Tag(r, out, endpoint, repoInfo, t, sf, parallel, auth); err != nil {
|
||||||
return err
|
return err
|
||||||
} else if downloaded {
|
} else if downloaded {
|
||||||
layersDownloaded = true
|
layersDownloaded = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if downloaded, err := s.pullV2Tag(eng, r, out, endpoint, repoInfo, tag, sf, parallel, auth); err != nil {
|
if downloaded, err := s.pullV2Tag(r, out, endpoint, repoInfo, tag, sf, parallel, auth); err != nil {
|
||||||
return err
|
return err
|
||||||
} else if downloaded {
|
} else if downloaded {
|
||||||
layersDownloaded = true
|
layersDownloaded = true
|
||||||
|
@ -415,7 +414,7 @@ func (s *TagStore) pullV2Repository(eng *engine.Engine, r *registry.Session, out
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *TagStore) pullV2Tag(eng *engine.Engine, r *registry.Session, out io.Writer, endpoint *registry.Endpoint, repoInfo *registry.RepositoryInfo, tag string, sf *streamformatter.StreamFormatter, parallel bool, auth *registry.RequestAuthorization) (bool, error) {
|
func (s *TagStore) pullV2Tag(r *registry.Session, out io.Writer, endpoint *registry.Endpoint, repoInfo *registry.RepositoryInfo, tag string, sf *streamformatter.StreamFormatter, parallel bool, auth *registry.RequestAuthorization) (bool, error) {
|
||||||
logrus.Debugf("Pulling tag from V2 registry: %q", tag)
|
logrus.Debugf("Pulling tag from V2 registry: %q", tag)
|
||||||
|
|
||||||
manifestBytes, manifestDigest, err := r.GetV2ImageManifest(endpoint, repoInfo.RemoteName, tag, auth)
|
manifestBytes, manifestDigest, err := r.GetV2ImageManifest(endpoint, repoInfo.RemoteName, tag, auth)
|
||||||
|
@ -425,7 +424,7 @@ func (s *TagStore) pullV2Tag(eng *engine.Engine, r *registry.Session, out io.Wri
|
||||||
|
|
||||||
// loadManifest ensures that the manifest payload has the expected digest
|
// loadManifest ensures that the manifest payload has the expected digest
|
||||||
// if the tag is a digest reference.
|
// if the tag is a digest reference.
|
||||||
manifest, verified, err := s.loadManifest(eng, manifestBytes, manifestDigest, tag)
|
manifest, verified, err := s.loadManifest(manifestBytes, manifestDigest, tag)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, fmt.Errorf("error verifying manifest: %s", err)
|
return false, fmt.Errorf("error verifying manifest: %s", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -138,7 +138,7 @@ func setupBaseImage() {
|
||||||
AuthConfig: ®istry.AuthConfig{},
|
AuthConfig: ®istry.AuthConfig{},
|
||||||
}
|
}
|
||||||
d := getDaemon(eng)
|
d := getDaemon(eng)
|
||||||
if err := d.Repositories().Pull(unitTestImageName, "", imagePullConfig, eng); err != nil {
|
if err := d.Repositories().Pull(unitTestImageName, "", imagePullConfig); err != nil {
|
||||||
logrus.Fatalf("Unable to pull the test image: %s", err)
|
logrus.Fatalf("Unable to pull the test image: %s", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue