remove libartifact from podman

pkg/libartifact has been moved to common and as such needs to be removed
from podman and the new common vendored in along with required deps.

https://issues.redhat.com/browse/RUN-3618

Signed-off-by: Brent Baude <bbaude@redhat.com>
This commit is contained in:
Brent Baude
2025-10-15 14:44:50 -05:00
parent 571031f375
commit cfd4cc0932
165 changed files with 2118 additions and 2598 deletions

View File

@@ -17,6 +17,7 @@ package name
import (
// nolint: depguard
_ "crypto/sha256" // Recommended by go-digest.
"encoding"
"encoding/json"
"strings"
@@ -32,8 +33,11 @@ type Digest struct {
original string
}
// Ensure Digest implements Reference
var _ Reference = (*Digest)(nil)
var _ encoding.TextMarshaler = (*Digest)(nil)
var _ encoding.TextUnmarshaler = (*Digest)(nil)
var _ json.Marshaler = (*Digest)(nil)
var _ json.Unmarshaler = (*Digest)(nil)
// Context implements Reference.
func (d Digest) Context() Repository {
@@ -79,6 +83,21 @@ func (d *Digest) UnmarshalJSON(data []byte) error {
return nil
}
// MarshalText formats the digest into a string for text serialization.
func (d Digest) MarshalText() ([]byte, error) {
return []byte(d.String()), nil
}
// UnmarshalText parses a text string into a Digest.
func (d *Digest) UnmarshalText(data []byte) error {
n, err := NewDigest(string(data))
if err != nil {
return err
}
*d = n
return nil
}
// NewDigest returns a new Digest representing the given name.
func NewDigest(name string, opts ...Option) (Digest, error) {
// Split on "@"

View File

@@ -15,6 +15,8 @@
package name
import (
"encoding"
"encoding/json"
"net"
"net/url"
"path"
@@ -37,6 +39,11 @@ type Registry struct {
registry string
}
var _ encoding.TextMarshaler = (*Registry)(nil)
var _ encoding.TextUnmarshaler = (*Registry)(nil)
var _ json.Marshaler = (*Registry)(nil)
var _ json.Unmarshaler = (*Registry)(nil)
// RegistryStr returns the registry component of the Registry.
func (r Registry) RegistryStr() string {
return r.registry
@@ -140,3 +147,33 @@ func NewInsecureRegistry(name string, opts ...Option) (Registry, error) {
opts = append(opts, Insecure)
return NewRegistry(name, opts...)
}
// MarshalJSON formats the Registry into a string for JSON serialization.
func (r Registry) MarshalJSON() ([]byte, error) { return json.Marshal(r.String()) }
// UnmarshalJSON parses a JSON string into a Registry.
func (r *Registry) UnmarshalJSON(data []byte) error {
var s string
if err := json.Unmarshal(data, &s); err != nil {
return err
}
n, err := NewRegistry(s)
if err != nil {
return err
}
*r = n
return nil
}
// MarshalText formats the registry into a string for text serialization.
func (r Registry) MarshalText() ([]byte, error) { return []byte(r.String()), nil }
// UnmarshalText parses a text string into a Registry.
func (r *Registry) UnmarshalText(data []byte) error {
n, err := NewRegistry(string(data))
if err != nil {
return err
}
*r = n
return nil
}

View File

@@ -15,6 +15,8 @@
package name
import (
"encoding"
"encoding/json"
"fmt"
"strings"
)
@@ -31,6 +33,11 @@ type Repository struct {
repository string
}
var _ encoding.TextMarshaler = (*Repository)(nil)
var _ encoding.TextUnmarshaler = (*Repository)(nil)
var _ json.Marshaler = (*Repository)(nil)
var _ json.Unmarshaler = (*Repository)(nil)
// See https://docs.docker.com/docker-hub/official_repos
func hasImplicitNamespace(repo string, reg Registry) bool {
return !strings.ContainsRune(repo, '/') && reg.RegistryStr() == DefaultRegistry
@@ -119,3 +126,33 @@ func (r Repository) Digest(identifier string) Digest {
d.original = d.Name()
return d
}
// MarshalJSON formats the Repository into a string for JSON serialization.
func (r Repository) MarshalJSON() ([]byte, error) { return json.Marshal(r.String()) }
// UnmarshalJSON parses a JSON string into a Repository.
func (r *Repository) UnmarshalJSON(data []byte) error {
var s string
if err := json.Unmarshal(data, &s); err != nil {
return err
}
n, err := NewRepository(s)
if err != nil {
return err
}
*r = n
return nil
}
// MarshalText formats the repository name into a string for text serialization.
func (r Repository) MarshalText() ([]byte, error) { return []byte(r.String()), nil }
// UnmarshalText parses a text string into a Repository.
func (r *Repository) UnmarshalText(data []byte) error {
n, err := NewRepository(string(data))
if err != nil {
return err
}
*r = n
return nil
}

View File

@@ -15,6 +15,8 @@
package name
import (
"encoding"
"encoding/json"
"strings"
)
@@ -31,8 +33,11 @@ type Tag struct {
original string
}
// Ensure Tag implements Reference
var _ Reference = (*Tag)(nil)
var _ encoding.TextMarshaler = (*Tag)(nil)
var _ encoding.TextUnmarshaler = (*Tag)(nil)
var _ json.Marshaler = (*Tag)(nil)
var _ json.Unmarshaler = (*Tag)(nil)
// Context implements Reference.
func (t Tag) Context() Repository {
@@ -80,6 +85,9 @@ func NewTag(name string, opts ...Option) (Tag, error) {
if len(parts) > 1 && !strings.Contains(parts[len(parts)-1], regRepoDelimiter) {
base = strings.Join(parts[:len(parts)-1], tagDelim)
tag = parts[len(parts)-1]
if tag == "" {
return Tag{}, newErrBadName("%s must specify a tag name after the colon", name)
}
}
// We don't require a tag, but if we get one check it's valid,
@@ -106,3 +114,33 @@ func NewTag(name string, opts ...Option) (Tag, error) {
original: name,
}, nil
}
// MarshalJSON formats the Tag into a string for JSON serialization.
func (t Tag) MarshalJSON() ([]byte, error) { return json.Marshal(t.String()) }
// UnmarshalJSON parses a JSON string into a Tag.
func (t *Tag) UnmarshalJSON(data []byte) error {
var s string
if err := json.Unmarshal(data, &s); err != nil {
return err
}
n, err := NewTag(s)
if err != nil {
return err
}
*t = n
return nil
}
// MarshalText formats the tag into a string for text serialization.
func (t Tag) MarshalText() ([]byte, error) { return []byte(t.String()), nil }
// UnmarshalText parses a text string into a Tag.
func (t *Tag) UnmarshalText(data []byte) error {
n, err := NewTag(string(data))
if err != nil {
return err
}
*t = n
return nil
}

View File

@@ -16,12 +16,12 @@ package v1
import (
"crypto"
"encoding"
"encoding/hex"
"encoding/json"
"fmt"
"hash"
"io"
"strconv"
"strings"
)
@@ -34,6 +34,11 @@ type Hash struct {
Hex string
}
var _ encoding.TextMarshaler = (*Hash)(nil)
var _ encoding.TextUnmarshaler = (*Hash)(nil)
var _ json.Marshaler = (*Hash)(nil)
var _ json.Unmarshaler = (*Hash)(nil)
// String reverses NewHash returning the string-form of the hash.
func (h Hash) String() string {
return fmt.Sprintf("%s:%s", h.Algorithm, h.Hex)
@@ -49,14 +54,12 @@ func NewHash(s string) (Hash, error) {
}
// MarshalJSON implements json.Marshaler
func (h Hash) MarshalJSON() ([]byte, error) {
return json.Marshal(h.String())
}
func (h Hash) MarshalJSON() ([]byte, error) { return json.Marshal(h.String()) }
// UnmarshalJSON implements json.Unmarshaler
func (h *Hash) UnmarshalJSON(data []byte) error {
s, err := strconv.Unquote(string(data))
if err != nil {
var s string
if err := json.Unmarshal(data, &s); err != nil {
return err
}
return h.parse(s)
@@ -64,15 +67,11 @@ func (h *Hash) UnmarshalJSON(data []byte) error {
// MarshalText implements encoding.TextMarshaler. This is required to use
// v1.Hash as a key in a map when marshalling JSON.
func (h Hash) MarshalText() (text []byte, err error) {
return []byte(h.String()), nil
}
func (h Hash) MarshalText() ([]byte, error) { return []byte(h.String()), nil }
// UnmarshalText implements encoding.TextUnmarshaler. This is required to use
// v1.Hash as a key in a map when unmarshalling JSON.
func (h *Hash) UnmarshalText(text []byte) error {
return h.parse(string(text))
}
func (h *Hash) UnmarshalText(text []byte) error { return h.parse(string(text)) }
// Hasher returns a hash.Hash for the named algorithm (e.g. "sha256")
func Hasher(name string) (hash.Hash, error) {