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/regclient/regclient"
"github.com/regclient/regclient/internal/rwfs"
"github.com/regclient/regclient/types/manifest"
"github.com/regclient/regclient/types/platform"
"github.com/regclient/regclient/types/ref"
)
@ -49,7 +50,7 @@ func TestMod(t *testing.T) {
if err != nil {
t.Errorf("failed to parse platform: %v", err)
}
m3DescAmd, err := m3.GetPlatformDesc(&pAMD)
m3DescAmd, err := manifest.GetPlatformDesc(m3, &pAMD)
if err != nil {
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.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 != "" {
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 {
return rl, err
}
if m.GetMediaType() != types.MediaTypeOCI1ManifestList {
return rl, fmt.Errorf("unexpected media type for referrers: %s, %w", m.GetMediaType(), types.ErrUnsupportedMediaType)
if m.GetDescriptor().MediaType != types.MediaTypeOCI1ManifestList {
return rl, fmt.Errorf("unexpected media type for referrers: %s, %w", m.GetDescriptor().MediaType, types.ErrUnsupportedMediaType)
}
rl.Manifest = m
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)
}
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 != "" {
rPush.Tag = fmt.Sprintf("%s.%s", rPush.Tag, stringMax(refType, 5))
}

View File

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

View File

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