commit
bcb5e36dd9
14 changed files with 67 additions and 69 deletions
26
api_test.go
26
api_test.go
|
@ -99,7 +99,7 @@ func TestGetVersion(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
if v.Version != VERSION {
|
||||
t.Errorf("Excepted version %s, %s found", VERSION, v.Version)
|
||||
t.Errorf("Expected version %s, %s found", VERSION, v.Version)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -129,7 +129,7 @@ func TestGetInfo(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
if infos.Images != len(initialImages) {
|
||||
t.Errorf("Excepted images: %d, %d found", len(initialImages), infos.Images)
|
||||
t.Errorf("Expected images: %d, %d found", len(initialImages), infos.Images)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -166,7 +166,7 @@ func TestGetImagesJSON(t *testing.T) {
|
|||
}
|
||||
|
||||
if len(images) != len(initialImages) {
|
||||
t.Errorf("Excepted %d image, %d found", len(initialImages), len(images))
|
||||
t.Errorf("Expected %d image, %d found", len(initialImages), len(images))
|
||||
}
|
||||
|
||||
found := false
|
||||
|
@ -177,7 +177,7 @@ func TestGetImagesJSON(t *testing.T) {
|
|||
}
|
||||
}
|
||||
if !found {
|
||||
t.Errorf("Excepted image %s, %+v found", unitTestImageName, images)
|
||||
t.Errorf("Expected image %s, %+v found", unitTestImageName, images)
|
||||
}
|
||||
|
||||
r2 := httptest.NewRecorder()
|
||||
|
@ -204,7 +204,7 @@ func TestGetImagesJSON(t *testing.T) {
|
|||
}
|
||||
|
||||
if len(images2) != len(initialImages) {
|
||||
t.Errorf("Excepted %d image, %d found", len(initialImages), len(images2))
|
||||
t.Errorf("Expected %d image, %d found", len(initialImages), len(images2))
|
||||
}
|
||||
|
||||
found = false
|
||||
|
@ -236,7 +236,7 @@ func TestGetImagesJSON(t *testing.T) {
|
|||
}
|
||||
|
||||
if len(images3) != 0 {
|
||||
t.Errorf("Excepted 0 image, %d found", len(images3))
|
||||
t.Errorf("Expected 0 image, %d found", len(images3))
|
||||
}
|
||||
|
||||
r4 := httptest.NewRecorder()
|
||||
|
@ -282,7 +282,7 @@ func TestGetImagesViz(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
if line != "digraph docker {\n" {
|
||||
t.Errorf("Excepted digraph docker {\n, %s found", line)
|
||||
t.Errorf("Expected digraph docker {\n, %s found", line)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -313,7 +313,7 @@ func TestGetImagesSearch(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
if len(results) < 2 {
|
||||
t.Errorf("Excepted at least 2 lines, %d found", len(results))
|
||||
t.Errorf("Expected at least 2 lines, %d found", len(results))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -337,7 +337,7 @@ func TestGetImagesHistory(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
if len(history) != 1 {
|
||||
t.Errorf("Excepted 1 line, %d found", len(history))
|
||||
t.Errorf("Expected 1 line, %d found", len(history))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -359,7 +359,7 @@ func TestGetImagesByName(t *testing.T) {
|
|||
if err := json.Unmarshal(r.Body.Bytes(), img); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if img.ID != unitTestImageId {
|
||||
if img.ID != unitTestImageID {
|
||||
t.Errorf("Error inspecting image")
|
||||
}
|
||||
}
|
||||
|
@ -396,7 +396,7 @@ func TestGetContainersJSON(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
if len(containers) != 1 {
|
||||
t.Fatalf("Excepted %d container, %d found", 1, len(containers))
|
||||
t.Fatalf("Expected %d container, %d found", 1, len(containers))
|
||||
}
|
||||
if containers[0].ID != container.ID {
|
||||
t.Fatalf("Container ID mismatch. Expected: %s, received: %s\n", container.ID, containers[0].ID)
|
||||
|
@ -1356,7 +1356,7 @@ func TestDeleteImages(t *testing.T) {
|
|||
}
|
||||
|
||||
if len(images) != len(initialImages)+1 {
|
||||
t.Errorf("Excepted %d images, %d found", len(initialImages)+1, len(images))
|
||||
t.Errorf("Expected %d images, %d found", len(initialImages)+1, len(images))
|
||||
}
|
||||
|
||||
req, err := http.NewRequest("DELETE", "/images/test:test", nil)
|
||||
|
@ -1385,7 +1385,7 @@ func TestDeleteImages(t *testing.T) {
|
|||
}
|
||||
|
||||
if len(images) != len(initialImages) {
|
||||
t.Errorf("Excepted %d image, %d found", len(initialImages), len(images))
|
||||
t.Errorf("Expected %d image, %d found", len(initialImages), len(images))
|
||||
}
|
||||
|
||||
/* if c := runtime.Get(container.Id); c != nil {
|
||||
|
|
|
@ -4,7 +4,6 @@ import (
|
|||
"archive/tar"
|
||||
"bufio"
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/dotcloud/docker/utils"
|
||||
"io"
|
||||
|
@ -251,7 +250,7 @@ func CmdStream(cmd *exec.Cmd) (io.Reader, error) {
|
|||
}
|
||||
errText := <-errChan
|
||||
if err := cmd.Wait(); err != nil {
|
||||
pipeW.CloseWithError(errors.New(err.Error() + ": " + string(errText)))
|
||||
pipeW.CloseWithError(fmt.Errorf("%s: %s", err, errText))
|
||||
} else {
|
||||
pipeW.Close()
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ import (
|
|||
// mkTestContext generates a build context from the contents of the provided dockerfile.
|
||||
// This context is suitable for use as an argument to BuildFile.Build()
|
||||
func mkTestContext(dockerfile string, files [][2]string, t *testing.T) Archive {
|
||||
context, err := mkBuildContext(fmt.Sprintf(dockerfile, unitTestImageId), files)
|
||||
context, err := mkBuildContext(fmt.Sprintf(dockerfile, unitTestImageID), files)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ type testContextTemplate struct {
|
|||
|
||||
// A table of all the contexts to build and test.
|
||||
// A new docker runtime will be created and torn down for each context.
|
||||
var testContexts []testContextTemplate = []testContextTemplate{
|
||||
var testContexts = []testContextTemplate{
|
||||
{
|
||||
`
|
||||
from %s
|
||||
|
|
|
@ -1565,7 +1565,7 @@ func Subcmd(name, signature, description string) *flag.FlagSet {
|
|||
|
||||
func NewDockerCli(in io.ReadCloser, out, err io.Writer, proto, addr string) *DockerCli {
|
||||
var (
|
||||
isTerminal bool = false
|
||||
isTerminal = false
|
||||
terminalFd uintptr
|
||||
)
|
||||
|
||||
|
|
|
@ -142,7 +142,7 @@ func TestRunHostname(t *testing.T) {
|
|||
c := make(chan struct{})
|
||||
go func() {
|
||||
defer close(c)
|
||||
if err := cli.CmdRun("-h", "foobar", unitTestImageId, "hostname"); err != nil {
|
||||
if err := cli.CmdRun("-h", "foobar", unitTestImageID, "hostname"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}()
|
||||
|
@ -335,7 +335,7 @@ func TestRunAttachStdin(t *testing.T) {
|
|||
ch := make(chan struct{})
|
||||
go func() {
|
||||
defer close(ch)
|
||||
cli.CmdRun("-i", "-a", "stdin", unitTestImageId, "sh", "-c", "echo hello && cat")
|
||||
cli.CmdRun("-i", "-a", "stdin", unitTestImageID, "sh", "-c", "echo hello && cat")
|
||||
}()
|
||||
|
||||
// Send input to the command, close stdin
|
||||
|
|
|
@ -494,7 +494,7 @@ func (container *Container) Start(hostConfig *HostConfig) error {
|
|||
// Create the requested bind mounts
|
||||
binds := make(map[string]BindMap)
|
||||
// Define illegal container destinations
|
||||
illegal_dsts := []string{"/", "."}
|
||||
illegalDsts := []string{"/", "."}
|
||||
|
||||
for _, bind := range hostConfig.Binds {
|
||||
// FIXME: factorize bind parsing in parseBind
|
||||
|
@ -513,7 +513,7 @@ func (container *Container) Start(hostConfig *HostConfig) error {
|
|||
}
|
||||
|
||||
// Bail if trying to mount to an illegal destination
|
||||
for _, illegal := range illegal_dsts {
|
||||
for _, illegal := range illegalDsts {
|
||||
if dst == illegal {
|
||||
return fmt.Errorf("Illegal bind destination: %s", dst)
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ func main() {
|
|||
flag.Var(&flHosts, "H", "tcp://host:port to bind/connect to or unix://path/to/socket to use")
|
||||
flag.Parse()
|
||||
if len(flHosts) > 1 {
|
||||
flHosts = flHosts[1:len(flHosts)] //trick to display a nice defaul value in the usage
|
||||
flHosts = flHosts[1:] //trick to display a nice defaul value in the usage
|
||||
}
|
||||
for i, flHost := range flHosts {
|
||||
flHosts[i] = utils.ParseHost(docker.DEFAULTHTTPHOST, docker.DEFAULTHTTPPORT, flHost)
|
||||
|
|
|
@ -18,7 +18,7 @@ import (
|
|||
|
||||
var ErrAlreadyExists = errors.New("Image already exists")
|
||||
|
||||
func UrlScheme() string {
|
||||
func URLScheme() string {
|
||||
u, err := url.Parse(auth.IndexServerAddress())
|
||||
if err != nil {
|
||||
return "https"
|
||||
|
@ -35,8 +35,8 @@ func doWithCookies(c *http.Client, req *http.Request) (*http.Response, error) {
|
|||
|
||||
// Retrieve the history of a given image from the Registry.
|
||||
// Return a list of the parent's json (requested image included)
|
||||
func (r *Registry) GetRemoteHistory(imgId, registry string, token []string) ([]string, error) {
|
||||
req, err := http.NewRequest("GET", registry+"/images/"+imgId+"/ancestry", nil)
|
||||
func (r *Registry) GetRemoteHistory(imgID, registry string, token []string) ([]string, error) {
|
||||
req, err := http.NewRequest("GET", registry+"/images/"+imgID+"/ancestry", nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ func (r *Registry) GetRemoteHistory(imgId, registry string, token []string) ([]s
|
|||
res, err := r.client.Do(req)
|
||||
if err != nil || res.StatusCode != 200 {
|
||||
if res != nil {
|
||||
return nil, fmt.Errorf("Internal server error: %d trying to fetch remote history for %s", res.StatusCode, imgId)
|
||||
return nil, fmt.Errorf("Internal server error: %d trying to fetch remote history for %s", res.StatusCode, imgID)
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
|
@ -64,10 +64,10 @@ func (r *Registry) GetRemoteHistory(imgId, registry string, token []string) ([]s
|
|||
}
|
||||
|
||||
// Check if an image exists in the Registry
|
||||
func (r *Registry) LookupRemoteImage(imgId, registry string, token []string) bool {
|
||||
func (r *Registry) LookupRemoteImage(imgID, registry string, token []string) bool {
|
||||
rt := &http.Transport{Proxy: http.ProxyFromEnvironment}
|
||||
|
||||
req, err := http.NewRequest("GET", registry+"/v1/images/"+imgId+"/json", nil)
|
||||
req, err := http.NewRequest("GET", registry+"/v1/images/"+imgID+"/json", nil)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
@ -114,9 +114,9 @@ func (r *Registry) getImagesInRepository(repository string, authConfig *auth.Aut
|
|||
}
|
||||
|
||||
// Retrieve an image from the Registry.
|
||||
func (r *Registry) GetRemoteImageJSON(imgId, registry string, token []string) ([]byte, int, error) {
|
||||
func (r *Registry) GetRemoteImageJSON(imgID, registry string, token []string) ([]byte, int, error) {
|
||||
// Get the JSON
|
||||
req, err := http.NewRequest("GET", registry+"/images/"+imgId+"/json", nil)
|
||||
req, err := http.NewRequest("GET", registry+"/images/"+imgID+"/json", nil)
|
||||
if err != nil {
|
||||
return nil, -1, fmt.Errorf("Failed to download json: %s", err)
|
||||
}
|
||||
|
@ -142,8 +142,8 @@ func (r *Registry) GetRemoteImageJSON(imgId, registry string, token []string) ([
|
|||
return jsonString, imageSize, nil
|
||||
}
|
||||
|
||||
func (r *Registry) GetRemoteImageLayer(imgId, registry string, token []string) (io.ReadCloser, error) {
|
||||
req, err := http.NewRequest("GET", registry+"/images/"+imgId+"/layer", nil)
|
||||
func (r *Registry) GetRemoteImageLayer(imgID, registry string, token []string) (io.ReadCloser, error) {
|
||||
req, err := http.NewRequest("GET", registry+"/images/"+imgID+"/layer", nil)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Error while getting from the server: %s\n", err)
|
||||
}
|
||||
|
@ -164,7 +164,7 @@ func (r *Registry) GetRemoteTags(registries []string, repository string, token [
|
|||
for _, host := range registries {
|
||||
endpoint := fmt.Sprintf("%s/v1/repositories/%s/tags", host, repository)
|
||||
if !(strings.HasPrefix(endpoint, "http://") || strings.HasPrefix(endpoint, "https://")) {
|
||||
endpoint = fmt.Sprintf("%s://%s", UrlScheme(), endpoint)
|
||||
endpoint = fmt.Sprintf("%s://%s", URLScheme(), endpoint)
|
||||
}
|
||||
req, err := r.opaqueRequest("GET", endpoint, nil)
|
||||
if err != nil {
|
||||
|
@ -295,9 +295,9 @@ func (r *Registry) PushImageJSONRegistry(imgData *ImgData, jsonRaw []byte, regis
|
|||
return nil
|
||||
}
|
||||
|
||||
func (r *Registry) PushImageLayerRegistry(imgId string, layer io.Reader, registry string, token []string) error {
|
||||
func (r *Registry) PushImageLayerRegistry(imgID string, layer io.Reader, registry string, token []string) error {
|
||||
registry = registry + "/v1"
|
||||
req, err := http.NewRequest("PUT", registry+"/images/"+imgId+"/layer", layer)
|
||||
req, err := http.NewRequest("PUT", registry+"/images/"+imgID+"/layer", layer)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ import (
|
|||
|
||||
const (
|
||||
unitTestImageName = "docker-unit-tests"
|
||||
unitTestImageId = "e9aa60c60128cad1"
|
||||
unitTestImageID = "e9aa60c60128cad1"
|
||||
unitTestStoreBase = "/var/lib/docker/unit-tests"
|
||||
testDaemonAddr = "127.0.0.1:4270"
|
||||
testDaemonProto = "tcp"
|
||||
|
@ -49,7 +49,7 @@ func cleanup(runtime *Runtime) error {
|
|||
return err
|
||||
}
|
||||
for _, image := range images {
|
||||
if image.ID != unitTestImageId {
|
||||
if image.ID != unitTestImageID {
|
||||
runtime.graph.Delete(image.ID)
|
||||
}
|
||||
}
|
||||
|
@ -135,11 +135,11 @@ func GetTestImage(runtime *Runtime) *Image {
|
|||
panic(err)
|
||||
}
|
||||
for i := range imgs {
|
||||
if imgs[i].ID == unitTestImageId {
|
||||
if imgs[i].ID == unitTestImageID {
|
||||
return imgs[i]
|
||||
}
|
||||
}
|
||||
panic(fmt.Errorf("Test image %v not found", unitTestImageId))
|
||||
panic(fmt.Errorf("Test image %v not found", unitTestImageID))
|
||||
}
|
||||
|
||||
func TestRuntimeCreate(t *testing.T) {
|
||||
|
|
36
server.go
36
server.go
|
@ -315,8 +315,8 @@ func (srv *Server) ContainerTag(name, repo, tag string, force bool) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (srv *Server) pullImage(r *registry.Registry, out io.Writer, imgId, endpoint string, token []string, sf *utils.StreamFormatter) error {
|
||||
history, err := r.GetRemoteHistory(imgId, endpoint, token)
|
||||
func (srv *Server) pullImage(r *registry.Registry, out io.Writer, imgID, endpoint string, token []string, sf *utils.StreamFormatter) error {
|
||||
history, err := r.GetRemoteHistory(imgID, endpoint, token)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -421,7 +421,7 @@ func (srv *Server) pullRepository(r *registry.Registry, out io.Writer, local, re
|
|||
success := false
|
||||
for _, ep := range repoData.Endpoints {
|
||||
if !(strings.HasPrefix(ep, "http://") || strings.HasPrefix(ep, "https://")) {
|
||||
ep = fmt.Sprintf("%s://%s", registry.UrlScheme(), ep)
|
||||
ep = fmt.Sprintf("%s://%s", registry.URLScheme(), ep)
|
||||
}
|
||||
if err := srv.pullImage(r, out, img.ID, ep+"/v1", repoData.Tokens, sf); err != nil {
|
||||
out.Write(sf.FormatStatus("Error while retrieving image for tag: %s (%s); checking next endpoint", askedTag, err))
|
||||
|
@ -516,20 +516,20 @@ func (srv *Server) ImagePull(name, tag, endpoint string, out io.Writer, sf *util
|
|||
// - Check if the archive exists, if it does not, ask the registry
|
||||
// - If the archive does exists, process the checksum from it
|
||||
// - If the archive does not exists and not found on registry, process checksum from layer
|
||||
func (srv *Server) getChecksum(imageId string) (string, error) {
|
||||
func (srv *Server) getChecksum(imageID string) (string, error) {
|
||||
// FIXME: Use in-memory map instead of reading the file each time
|
||||
if sums, err := srv.runtime.graph.getStoredChecksums(); err != nil {
|
||||
return "", err
|
||||
} else if checksum, exists := sums[imageId]; exists {
|
||||
} else if checksum, exists := sums[imageID]; exists {
|
||||
return checksum, nil
|
||||
}
|
||||
|
||||
img, err := srv.runtime.graph.Get(imageId)
|
||||
img, err := srv.runtime.graph.Get(imageID)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
if _, err := os.Stat(layerArchivePath(srv.runtime.graph.imageRoot(imageId))); err != nil {
|
||||
if _, err := os.Stat(layerArchivePath(srv.runtime.graph.imageRoot(imageID))); err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
// TODO: Ask the registry for the checksum
|
||||
// As the archive is not there, it is supposed to come from a pull.
|
||||
|
@ -618,7 +618,7 @@ func (srv *Server) pushRepository(r *registry.Registry, out io.Writer, name, reg
|
|||
|
||||
for _, ep := range repoData.Endpoints {
|
||||
if !(strings.HasPrefix(ep, "http://") || strings.HasPrefix(ep, "https://")) {
|
||||
ep = fmt.Sprintf("%s://%s", registry.UrlScheme(), ep)
|
||||
ep = fmt.Sprintf("%s://%s", registry.URLScheme(), ep)
|
||||
}
|
||||
out.Write(sf.FormatStatus("Pushing repository %s to %s (%d tags)", name, ep, len(localRepo)))
|
||||
// For each image within the repo, push them
|
||||
|
@ -650,21 +650,21 @@ func (srv *Server) pushRepository(r *registry.Registry, out io.Writer, name, reg
|
|||
return nil
|
||||
}
|
||||
|
||||
func (srv *Server) pushImage(r *registry.Registry, out io.Writer, remote, imgId, ep string, token []string, sf *utils.StreamFormatter) error {
|
||||
func (srv *Server) pushImage(r *registry.Registry, out io.Writer, remote, imgID, ep string, token []string, sf *utils.StreamFormatter) error {
|
||||
out = utils.NewWriteFlusher(out)
|
||||
jsonRaw, err := ioutil.ReadFile(path.Join(srv.runtime.graph.Root, imgId, "json"))
|
||||
jsonRaw, err := ioutil.ReadFile(path.Join(srv.runtime.graph.Root, imgID, "json"))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error while retreiving the path for {%s}: %s", imgId, err)
|
||||
return fmt.Errorf("Error while retreiving the path for {%s}: %s", imgID, err)
|
||||
}
|
||||
out.Write(sf.FormatStatus("Pushing %s", imgId))
|
||||
out.Write(sf.FormatStatus("Pushing %s", imgID))
|
||||
|
||||
// Make sure we have the image's checksum
|
||||
checksum, err := srv.getChecksum(imgId)
|
||||
checksum, err := srv.getChecksum(imgID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
imgData := ®istry.ImgData{
|
||||
ID: imgId,
|
||||
ID: imgID,
|
||||
Checksum: checksum,
|
||||
}
|
||||
|
||||
|
@ -680,11 +680,11 @@ func (srv *Server) pushImage(r *registry.Registry, out io.Writer, remote, imgId,
|
|||
// Retrieve the tarball to be sent
|
||||
var layerData *TempArchive
|
||||
// If the archive exists, use it
|
||||
file, err := os.Open(layerArchivePath(srv.runtime.graph.imageRoot(imgId)))
|
||||
file, err := os.Open(layerArchivePath(srv.runtime.graph.imageRoot(imgID)))
|
||||
if err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
// If the archive does not exist, create one from the layer
|
||||
layerData, err = srv.runtime.graph.TempLayerArchive(imgId, Xz, out)
|
||||
layerData, err = srv.runtime.graph.TempLayerArchive(imgID, Xz, out)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Failed to generate layer archive: %s", err)
|
||||
}
|
||||
|
@ -963,7 +963,7 @@ func (srv *Server) ImageDelete(name string, autoPrune bool) ([]APIRmi, error) {
|
|||
return srv.deleteImage(img, name, tag)
|
||||
}
|
||||
|
||||
func (srv *Server) ImageGetCached(imgId string, config *Config) (*Image, error) {
|
||||
func (srv *Server) ImageGetCached(imgID string, config *Config) (*Image, error) {
|
||||
|
||||
// Retrieve all images
|
||||
images, err := srv.runtime.graph.All()
|
||||
|
@ -981,7 +981,7 @@ func (srv *Server) ImageGetCached(imgId string, config *Config) (*Image, error)
|
|||
}
|
||||
|
||||
// Loop on the children of the given image and check the config
|
||||
for elem := range imageMap[imgId] {
|
||||
for elem := range imageMap[imgID] {
|
||||
img, err := srv.runtime.graph.Get(elem)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
@ -31,7 +31,7 @@ func TestContainerTagImageDelete(t *testing.T) {
|
|||
}
|
||||
|
||||
if len(images) != len(initialImages)+2 {
|
||||
t.Errorf("Excepted %d images, %d found", len(initialImages)+2, len(images))
|
||||
t.Errorf("Expected %d images, %d found", len(initialImages)+2, len(images))
|
||||
}
|
||||
|
||||
if _, err := srv.ImageDelete("utest/docker:tag2", true); err != nil {
|
||||
|
@ -44,7 +44,7 @@ func TestContainerTagImageDelete(t *testing.T) {
|
|||
}
|
||||
|
||||
if len(images) != len(initialImages)+1 {
|
||||
t.Errorf("Excepted %d images, %d found", len(initialImages)+1, len(images))
|
||||
t.Errorf("Expected %d images, %d found", len(initialImages)+1, len(images))
|
||||
}
|
||||
|
||||
if _, err := srv.ImageDelete("utest:tag1", true); err != nil {
|
||||
|
@ -57,7 +57,7 @@ func TestContainerTagImageDelete(t *testing.T) {
|
|||
}
|
||||
|
||||
if len(images) != len(initialImages) {
|
||||
t.Errorf("Excepted %d image, %d found", len(initialImages), len(images))
|
||||
t.Errorf("Expected %d image, %d found", len(initialImages), len(images))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
6
tags.go
6
tags.go
|
@ -197,7 +197,7 @@ func (store *TagStore) Get(repoName string) (Repository, error) {
|
|||
return nil, nil
|
||||
}
|
||||
|
||||
func (store *TagStore) GetImage(repoName, tagOrId string) (*Image, error) {
|
||||
func (store *TagStore) GetImage(repoName, tagOrID string) (*Image, error) {
|
||||
repo, err := store.Get(repoName)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -206,11 +206,11 @@ func (store *TagStore) GetImage(repoName, tagOrId string) (*Image, error) {
|
|||
}
|
||||
//go through all the tags, to see if tag is in fact an ID
|
||||
for _, revision := range repo {
|
||||
if strings.HasPrefix(revision, tagOrId) {
|
||||
if strings.HasPrefix(revision, tagOrID) {
|
||||
return store.graph.Get(revision)
|
||||
}
|
||||
}
|
||||
if revision, exists := repo[tagOrId]; exists {
|
||||
if revision, exists := repo[tagOrID]; exists {
|
||||
return store.graph.Get(revision)
|
||||
}
|
||||
return nil, nil
|
||||
|
|
|
@ -35,13 +35,13 @@ func TestLookupImage(t *testing.T) {
|
|||
t.Errorf("Expected 0 image, 1 found")
|
||||
}
|
||||
|
||||
if img, err := runtime.repositories.LookupImage(unitTestImageId); err != nil {
|
||||
if img, err := runtime.repositories.LookupImage(unitTestImageID); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if img == nil {
|
||||
t.Errorf("Expected 1 image, none found")
|
||||
}
|
||||
|
||||
if img, err := runtime.repositories.LookupImage(unitTestImageName + ":" + unitTestImageId); err != nil {
|
||||
if img, err := runtime.repositories.LookupImage(unitTestImageName + ":" + unitTestImageID); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if img == nil {
|
||||
t.Errorf("Expected 1 image, none found")
|
||||
|
|
|
@ -170,10 +170,9 @@ func SelfPath() string {
|
|||
return path
|
||||
}
|
||||
|
||||
type NopWriter struct {
|
||||
}
|
||||
type NopWriter struct{}
|
||||
|
||||
func (w *NopWriter) Write(buf []byte) (int, error) {
|
||||
func (*NopWriter) Write(buf []byte) (int, error) {
|
||||
return len(buf), nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue