1
0
mirror of https://github.com/regclient/regclient.git synced 2025-07-29 09:01:11 +03:00

Deprecating redundant methods

Signed-off-by: Brandon Mitchell <git@bmitch.net>
This commit is contained in:
Brandon Mitchell
2022-06-26 20:00:47 -04:00
parent c9cbf5a3fa
commit 06a7b6a816
5 changed files with 26 additions and 15 deletions

View File

@ -11,6 +11,7 @@ import (
"github.com/opencontainers/go-digest" "github.com/opencontainers/go-digest"
"github.com/regclient/regclient" "github.com/regclient/regclient"
"github.com/regclient/regclient/internal/rwfs" "github.com/regclient/regclient/internal/rwfs"
"github.com/regclient/regclient/types/manifest"
"github.com/regclient/regclient/types/platform" "github.com/regclient/regclient/types/platform"
"github.com/regclient/regclient/types/ref" "github.com/regclient/regclient/types/ref"
) )
@ -49,7 +50,7 @@ func TestMod(t *testing.T) {
if err != nil { if err != nil {
t.Errorf("failed to parse platform: %v", err) t.Errorf("failed to parse platform: %v", err)
} }
m3DescAmd, err := m3.GetPlatformDesc(&pAMD) m3DescAmd, err := manifest.GetPlatformDesc(m3, &pAMD)
if err != nil { if err != nil {
t.Errorf("failed to get amd64 descriptor: %v", err) t.Errorf("failed to get amd64 descriptor: %v", err)
} }

View File

@ -181,7 +181,7 @@ func (o *OCIDir) ReferrerPut(ctx context.Context, r ref.Ref, m manifest.Manifest
} }
rPush := r rPush := r
rPush.Digest = "" rPush.Digest = ""
rPush.Tag = fmt.Sprintf("%s-%s.%s", desc.Algorithm().String(), stringMax(desc.Hex(), 64), stringMax(m.GetDigest().Hex(), 16)) rPush.Tag = fmt.Sprintf("%s-%s.%s", desc.Algorithm().String(), stringMax(desc.Hex(), 64), stringMax(m.GetDescriptor().Digest.Hex(), 16))
if refType != "" { if refType != "" {
rPush.Tag = fmt.Sprintf("%s.%s", rPush.Tag, stringMax(refType, 5)) rPush.Tag = fmt.Sprintf("%s.%s", rPush.Tag, stringMax(refType, 5))
} }

View File

@ -186,8 +186,8 @@ func (reg *Reg) referrerListExtAPI(ctx context.Context, r ref.Ref) (referrer.Ref
if err != nil { if err != nil {
return rl, err return rl, err
} }
if m.GetMediaType() != types.MediaTypeOCI1ManifestList { if m.GetDescriptor().MediaType != types.MediaTypeOCI1ManifestList {
return rl, fmt.Errorf("unexpected media type for referrers: %s, %w", m.GetMediaType(), types.ErrUnsupportedMediaType) return rl, fmt.Errorf("unexpected media type for referrers: %s, %w", m.GetDescriptor().MediaType, types.ErrUnsupportedMediaType)
} }
rl.Manifest = m rl.Manifest = m
rl.Descriptors, err = m.GetManifestList() rl.Descriptors, err = m.GetManifestList()
@ -277,7 +277,7 @@ func (reg *Reg) ReferrerPut(ctx context.Context, r ref.Ref, m manifest.Manifest)
return fmt.Errorf("digest could not be parsed for %s: %w", r.CommonName(), err) return fmt.Errorf("digest could not be parsed for %s: %w", r.CommonName(), err)
} }
rPush.Digest = "" rPush.Digest = ""
rPush.Tag = fmt.Sprintf("%s-%s.%s", desc.Algorithm().String(), stringMax(desc.Hex(), 64), stringMax(m.GetDigest().Hex(), 16)) rPush.Tag = fmt.Sprintf("%s-%s.%s", desc.Algorithm().String(), stringMax(desc.Hex(), 64), stringMax(m.GetDescriptor().Digest.Hex(), 16))
if refType != "" { if refType != "" {
rPush.Tag = fmt.Sprintf("%s.%s", rPush.Tag, stringMax(refType, 5)) rPush.Tag = fmt.Sprintf("%s.%s", rPush.Tag, stringMax(refType, 5))
} }

View File

@ -18,9 +18,12 @@ type Common interface {
Response() *http.Response Response() *http.Response
RawHeaders() http.Header RawHeaders() http.Header
Digest() digest.Digest // TODO: deprecate // Deprecated: Digest should be replaced by GetDescriptor().Digest
Length() int64 // TODO: deprecate Digest() digest.Digest
MediaType() string // TODO: deprecate // Deprecated: Length should be replaced by GetDescriptor().Size
Length() int64
// Deprecated: MediaType should be replaced by GetDescriptor().MediaType
MediaType() string
} }
type common struct { type common struct {

View File

@ -40,13 +40,20 @@ type Manifest interface {
RawHeaders() (http.Header, error) RawHeaders() (http.Header, error)
SetOrig(interface{}) error SetOrig(interface{}) error
GetConfigDigest() (digest.Digest, error) // TODO: deprecate // Deprecated: GetConfigDigest should be replaced with GetConfig
GetDigest() digest.Digest // TODO: deprecate GetConfigDigest() (digest.Digest, error)
GetMediaType() string // TODO: deprecate // Deprecated: GetDigest should be replaced with GetDescriptor().Digest
GetPlatformDesc(p *platform.Platform) (*types.Descriptor, error) // TODO: deprecate GetDigest() digest.Digest
GetPlatformList() ([]*platform.Platform, error) // TODO: deprecate // Deprecated: GetMediaType should be replaced with GetDescriptor().MediaType
GetRateLimit() types.RateLimit // TODO: deprecate GetMediaType() string
HasRateLimit() bool // TODO: deprecate // Deprecated: GetPlatformDesc method should be replaced with manifest.GetPlatformDesc function
GetPlatformDesc(p *platform.Platform) (*types.Descriptor, error)
// Deprecated: GetPlatformList method should be replaced with manifest.GetPlatformList function
GetPlatformList() ([]*platform.Platform, error)
// Deprecated: GetRateLimit method should be replaced with manifest.GetRateLimit function
GetRateLimit() types.RateLimit
// Deprecated: HasRateLimit method should be replaced with manifest.HasRateLimit function
HasRateLimit() bool
} }
type Annotator interface { type Annotator interface {