GithubHelp home page GithubHelp logo

Comments (4)

joaopapereira avatar joaopapereira commented on August 16, 2024

@ekcasey I tried to replicate this using the test:

when("image exists and as no labels", func() {
	var (
		img    imgutil.Image
		origID string
	)
	it.Before(func() {
		var err error
		h.CreateImageOnLocal(t, dockerClient, repoName, fmt.Sprintf(`
					FROM scratch
					LABEL repo_name_for_randomisation=%s
				`, repoName), nil)
		img, err = imgutil.NewLocalImage(repoName, dockerClient)
		h.AssertNil(t, err)
		origID = h.ImageID(t, repoName)
	})

	it.After(func() {
		h.AssertNil(t, h.DockerRmi(dockerClient, repoName, origID))
	})

	it("sets label and saves label to docker daemon", func() {
		h.AssertNil(t, img.SetLabel("somekey", "new-val"))
		t.Log("set label")
		label, err := img.Label("somekey")
		h.AssertNil(t, err)
		h.AssertEq(t, label, "new-val")
		t.Log("save label")
		_, err = img.Save()
		h.AssertNil(t, err)

		inspect, _, err := dockerClient.ImageInspectWithRaw(context.TODO(), repoName)
		h.AssertNil(t, err)
		label = inspect.Config.Labels["somekey"]
		h.AssertEq(t, strings.TrimSpace(label), "new-val")
	})
})

and it did not panic, do you think this issue is solved already?

from imgutil.

ekcasey avatar ekcasey commented on August 16, 2024

@joaopapereira It looks like there is a label on that test image?

from imgutil.

joaopapereira avatar joaopapereira commented on August 16, 2024

These tests pass

when.Focus("image exists without labels", func() {
	it.Before(func() {
		h.CreateImageOnRemote(t, dockerClient, repoName, fmt.Sprintf(`
					FROM scratch
					CMD ["/bin/sh"]
				`), nil)

		var err error
		img, err = imgutil.NewRemoteImage(repoName, authn.DefaultKeychain)
		h.AssertNil(t, err)
	})

	it("sets label on img object", func() {
		h.AssertNil(t, img.SetLabel("mykey", "new-val"))
		label, err := img.Label("mykey")
		h.AssertNil(t, err)
		h.AssertEq(t, label, "new-val")
	})

	it("saves label", func() {
		h.AssertNil(t, img.SetLabel("mykey", "new-val"))
		_, err := img.Save()
		h.AssertNil(t, err)

		// After Pull
		label := remoteLabel(t, dockerClient, repoName, "mykey")
		h.AssertEq(t, "new-val", label)
	})
})

from imgutil.

ekcasey avatar ekcasey commented on August 16, 2024

@joaopapereira I think it only panics when it is a local image

from imgutil.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.