Пример #1
0
func (c *Client) lookupImage(client *dockerregistry.Registry, lookupName, imageName, tag string) (flux.ImageDescription, error) {
	// Minor cheat: this will give the correct result even if the
	// imageName includes a host
	id := flux.MakeImageID("", imageName, tag)
	img := flux.ImageDescription{ID: id}

	meta, err := client.Manifest(lookupName, tag)
	if err != nil {
		return img, err
	}
	// the manifest includes some v1-backwards-compatibility data,
	// oddly called "History", which are layer metadata as JSON
	// strings; these appear most-recent (i.e., topmost layer) first,
	// so happily we can just decode the first entry to get a created
	// time.
	type v1image struct {
		Created time.Time `json:"created"`
	}
	var topmost v1image
	if err = json.Unmarshal([]byte(meta.History[0].V1Compatibility), &topmost); err == nil {
		img.CreatedAt = topmost.Created
	}

	return img, err
}
Пример #2
0
func TestMakeImage(t *testing.T) {
	for want, in := range imageParsingExamples {
		out := flux.MakeImageID(in.Registry, in.Name, in.Tag)
		if string(out) != want {
			t.Fatalf("%#v.String(): %s != %s", in, out, want)
		}
	}
}