Skip to content

Commit

Permalink
Merge pull request #10335 from euank/EmptyLayerConfig
Browse files Browse the repository at this point in the history
Allow empty layer configs in manifests
  • Loading branch information
Arnaud Porterie committed Jan 26, 2015
2 parents ed8e89c + d477d42 commit 74014e4
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 5 deletions.
8 changes: 3 additions & 5 deletions graph/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package graph
import (
"bytes"
"encoding/json"
"errors"
"fmt"
"io"
"io/ioutil"
Expand Down Expand Up @@ -71,14 +70,13 @@ func (s *TagStore) newManifest(localName, remoteName, tag string) ([]byte, error
if err != nil {
return nil, err
}
if layer.Config == nil {
return nil, errors.New("Missing layer configuration")
}
manifest.Architecture = layer.Architecture
manifest.FSLayers = make([]*registry.FSLayer, 0, 4)
manifest.History = make([]*registry.ManifestHistory, 0, 4)
var metadata runconfig.Config
metadata = *layer.Config
if layer.Config != nil {
metadata = *layer.Config
}

for ; layer != nil; layer, err = layer.GetParent() {
if err != nil {
Expand Down
36 changes: 36 additions & 0 deletions integration-cli/docker_cli_push_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@ package main

import (
"fmt"
"io/ioutil"
"os"
"os/exec"
"strings"
"testing"
"time"

"github.com/docker/docker/vendor/src/code.google.com/p/go/src/pkg/archive/tar"
)

// pulling an image from the central registry should work
Expand Down Expand Up @@ -80,3 +84,35 @@ func TestPushInterrupt(t *testing.T) {

logDone("push - interrupted")
}

func TestPushEmptyLayer(t *testing.T) {
defer setupRegistry(t)()
repoName := fmt.Sprintf("%v/dockercli/emptylayer", privateRegistryURL)
emptyTarball, err := ioutil.TempFile("", "empty_tarball")
if err != nil {
t.Fatalf("Unable to create test file: %v", err)
}
tw := tar.NewWriter(emptyTarball)
err = tw.Close()
if err != nil {
t.Fatalf("Error creating empty tarball: %v", err)
}
freader, err := os.Open(emptyTarball.Name())
if err != nil {
t.Fatalf("Could not open test tarball: %v", err)
}

importCmd := exec.Command(dockerBinary, "import", "-", repoName)
importCmd.Stdin = freader
out, _, err := runCommandWithOutput(importCmd)
if err != nil {
t.Errorf("import failed with errors: %v, output: %q", err, out)
}

// Now verify we can push it
pushCmd := exec.Command(dockerBinary, "push", repoName)
if out, _, err := runCommandWithOutput(pushCmd); err != nil {
t.Fatalf("pushing the image to the private registry has failed: %s, %v", out, err)
}
logDone("push - empty layer config to private registry")
}

0 comments on commit 74014e4

Please sign in to comment.