Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions pkg/api/handlers/libpod/artifacts.go
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,11 @@ func PushArtifact(w http.ResponseWriter, r *http.Request) {
return
}

if errors.Is(err, libartifact_types.ErrArtifactNotExist) {
utils.ArtifactNotFound(w, name, err)
return
}

utils.InternalServerError(w, err)
return
}
Expand Down
11 changes: 11 additions & 0 deletions pkg/domain/infra/abi/artifact.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/sirupsen/logrus"
"go.podman.io/common/libimage"
"go.podman.io/common/pkg/libartifact/types"
"go.podman.io/image/v5/docker/reference"
)

func (ir *ImageEngine) ArtifactInspect(ctx context.Context, name string, _ entities.ArtifactInspectOptions) (*entities.ArtifactInspectReport, error) {
Expand Down Expand Up @@ -57,6 +58,16 @@ func (ir *ImageEngine) ArtifactList(ctx context.Context, _ entities.ArtifactList
}

func (ir *ImageEngine) ArtifactPull(ctx context.Context, name string, opts entities.ArtifactPullOptions) (*entities.ArtifactPullReport, error) {
named, err := reference.Parse(name)
if err != nil {
return nil, fmt.Errorf("parsing reference %q: %w", name, err)
}
namedRef, ok := named.(reference.Named)
if !ok {
return nil, fmt.Errorf("reference %q is not a Named reference", name)
}
name = reference.TagNameOnly(namedRef).String()

pullOptions := &libimage.CopyOptions{}
pullOptions.AuthFilePath = opts.AuthFilePath
pullOptions.CertDirPath = opts.CertDirPath
Expand Down
10 changes: 7 additions & 3 deletions test/apiv2/python/rest_api/test_v2_0_0_artifact.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

class ArtifactTestCase(APITestCase):
def test_add(self):
ARTIFACT_NAME = "quay.io/myimage/myartifact:latest"
ARTIFACT_NAME = "quay.io/myimage/myartifact"
file = ArtifactFile()
parameters: dict[str, str | list[str]] = {
"name": ARTIFACT_NAME,
Expand Down Expand Up @@ -43,6 +43,10 @@ def test_add(self):
# Assert blob media type fallback detection is working
self.assertEqual(artifact_layer["mediaType"], "application/octet-stream")

# Assert latest tag was added by default
self.assertEqual(inspect_response_json["Name"], "quay.io/myimage/myartifact:latest")


def test_add_with_replace(self):
ARTIFACT_NAME = "quay.io/myimage/newartifact:latest"

Expand Down Expand Up @@ -128,7 +132,7 @@ def test_add_with_append(self):
self.assertEqual(len(artifact_layers), 2)

def test_add_with_artifactMIMEType_override(self):
ARTIFACT_NAME = "quay.io/myimage/myartifact_artifactType:latest"
ARTIFACT_NAME = "quay.io/myimage/myartifact_artifact_type:latest"
file = ArtifactFile()
parameters: dict[str, str | list[str]] = {
"name": ARTIFACT_NAME,
Expand Down Expand Up @@ -672,7 +676,7 @@ def test_push_missing_artifact(self):

# Assert return error response is json and contains correct message
self.assertIn(
"no descriptor found for reference",
"artifact does not exist",
rjson["cause"],
)

Expand Down
2 changes: 1 addition & 1 deletion test/e2e/artifact_created_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ var _ = Describe("Podman artifact created timestamp", func() {

// Inspect artifact
a := podmanTest.InspectArtifact(artifactName)
Expect(a.Name).To(Equal(artifactName))
Expect(a.Name).To(Equal(artifactName + ":latest"))

// Check that created annotation exists and is in valid RFC3339 format
createdStr, exists := a.Manifest.Annotations["org.opencontainers.image.created"]
Expand Down
22 changes: 9 additions & 13 deletions test/e2e/artifact_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,12 @@ var _ = Describe("Podman artifact", func() {

a := podmanTest.InspectArtifact(artifact1Name)

Expect(a.Name).To(Equal(artifact1Name))
Expect(a.Name).To(Equal(artifact1Name + ":latest"))

// Adding an artifact with an existing name should fail
addAgain := podmanTest.Podman([]string{"artifact", "add", artifact1Name, artifact1File})
addAgain.WaitWithDefaultTimeout()
Expect(addAgain).Should(ExitWithError(125, fmt.Sprintf("Error: %s: artifact already exists", artifact1Name)))
Expect(addAgain).Should(ExitWithError(125, fmt.Sprintf("Error: %s: artifact already exists", artifact1Name+":latest")))
})

It("podman artifact add with options", func() {
Expand All @@ -109,7 +109,7 @@ var _ = Describe("Podman artifact", func() {
podmanTest.PodmanExitCleanly("artifact", "add", "--file-type", yamlType, "--type", artifactType, "--annotation", annotation1, "--annotation", annotation2, artifact1Name, artifact1File)

a := podmanTest.InspectArtifact(artifact1Name)
Expect(a.Name).To(Equal(artifact1Name))
Expect(a.Name).To(Equal(artifact1Name + ":latest"))
Expect(a.Manifest.ArtifactType).To(Equal(artifactType))
Expect(a.Manifest.Layers[0].Annotations["color"]).To(Equal("blue"))
Expect(a.Manifest.Layers[0].Annotations["flavor"]).To(Equal("lemon"))
Expand All @@ -131,7 +131,7 @@ var _ = Describe("Podman artifact", func() {
podmanTest.PodmanExitCleanly("artifact", "add", artifact1Name, artifact1File1, artifact1File2)

a := podmanTest.InspectArtifact(artifact1Name)
Expect(a.Name).To(Equal(artifact1Name))
Expect(a.Name).To(Equal(artifact1Name + ":latest"))

Expect(a.Manifest.Layers).To(HaveLen(2))
})
Expand Down Expand Up @@ -168,7 +168,7 @@ var _ = Describe("Podman artifact", func() {

a := podmanTest.InspectArtifact(artifact1Name)

Expect(a.Name).To(Equal(artifact1Name))
Expect(a.Name).To(Equal(artifact1Name + ":latest"))
})

It("podman artifact push with authorization", func() {
Expand Down Expand Up @@ -476,7 +476,7 @@ var _ = Describe("Podman artifact", func() {
podmanTest.PodmanExitCleanly("artifact", "add", "--append", "--annotation", annotation1, artifact1Name, artifact3File)

a = podmanTest.InspectArtifact(artifact1Name)
Expect(a.Name).To(Equal(artifact1Name))
Expect(a.Name).To(Equal(artifact1Name + ":latest"))
Expect(a.Manifest.Layers).To(HaveLen(3))

for _, l := range a.Manifest.Layers {
Expand Down Expand Up @@ -522,7 +522,6 @@ var _ = Describe("Podman artifact", func() {

artifact1Name := "localhost/test/artifact1"
podmanTest.PodmanExitCleanly("artifact", "add", artifact1Name, artifact1File)

f, err := os.OpenFile(artifact1File, os.O_APPEND|os.O_WRONLY, 0644)
Expect(err).ToNot(HaveOccurred())
_, err = f.WriteString("This is modification.")
Expand Down Expand Up @@ -587,16 +586,13 @@ var _ = Describe("Podman artifact", func() {
podmanTest.PodmanExitCleanly("artifact", "add", "--type", artifactType, artifact1Name, artifact1File)

a := podmanTest.InspectArtifact(artifact1Name)
Expect(a.Name).To(Equal(artifact1Name))
Expect(a.Name).To(Equal(artifact1Name + ":latest"))
Expect(a.Manifest.ArtifactType).To(Equal(artifactType))

podmanTest.PodmanExitCleanly("artifact", "add", "--append", artifact1Name, artifact2File)

a = podmanTest.InspectArtifact(artifact1Name)
Expect(a.Name).To(Equal(artifact1Name))
Expect(a.Manifest.ArtifactType).To(Equal(artifactType))
Expect(a.Manifest.Layers).To(HaveLen(2))

Expect(a.Name).To(Equal(artifact1Name + ":latest"))
failSession := podmanTest.Podman([]string{"artifact", "add", "--type", artifactType, "--append", artifact1Name, artifact3File})
failSession.WaitWithDefaultTimeout()
Expect(failSession).Should(ExitWithError(125, "Error: append option is not compatible with type option"))
Expand All @@ -615,7 +611,7 @@ var _ = Describe("Podman artifact", func() {

// Inspect artifact
a := podmanTest.InspectArtifact(artifact1Name)
Expect(a.Name).To(Equal(artifact1Name))
Expect(a.Name).To(Equal(artifact1Name + ":latest"))

// Check that created annotation exists and is in valid Unix nanosecond format
createdStr, exists := a.Manifest.Annotations["org.opencontainers.image.created"]
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/inspect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ var _ = Describe("Podman inspect", func() {
inspect = podmanTest.Podman([]string{"inspect", "--format", "{{.Name}}", artifactName})
inspect.WaitWithDefaultTimeout()
Expect(inspect).Should(ExitCleanly())
Expect(inspect.OutputToString()).To(Equal(artifactName))
Expect(inspect.OutputToString()).To(Equal(artifactName + ":latest"))

inspect2 := podmanTest.Podman([]string{"inspect", "--format", "{{.Digest}}", artifactName})
inspect2.WaitWithDefaultTimeout()
Expand Down
17 changes: 16 additions & 1 deletion vendor/go.podman.io/common/pkg/libartifact/artifact.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 31 additions & 12 deletions vendor/go.podman.io/common/pkg/libartifact/store/store.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.