mirror of
https://github.com/regclient/regclient.git
synced 2025-04-17 11:37:11 +03:00
I feel like I need to explain, this is all to move the descriptor package. The platform package could not use the predefined errors in types because of a circular dependency from descriptor. The most appropriate way to reorg this is to move descriptor out of the type package since it was more complex than a self contained type. When doing that, type aliases were needed to avoid breaking changes to existing users. Those aliases themselves caused circular dependency loops because of the media types and errors, so those were also pulled out to separate packages. All of the old values were aliased and deprecated, and to fix the linter, those deprecations were fixed by updating the imports... everywhere. Signed-off-by: Brandon Mitchell <git@bmitch.net>
41 lines
1.3 KiB
Go
41 lines
1.3 KiB
Go
package regclient
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"github.com/regclient/regclient/scheme"
|
|
"github.com/regclient/regclient/types/errs"
|
|
"github.com/regclient/regclient/types/ref"
|
|
"github.com/regclient/regclient/types/tag"
|
|
)
|
|
|
|
// TagDelete deletes a tag from the registry. Since there's no API for this,
|
|
// you'd want to normally just delete the manifest. However multiple tags may
|
|
// point to the same manifest, so instead you must:
|
|
// 1. Make a manifest, for this we put a few labels and timestamps to be unique.
|
|
// 2. Push that manifest to the tag.
|
|
// 3. Delete the digest for that new manifest that is only used by that tag.
|
|
func (rc *RegClient) TagDelete(ctx context.Context, r ref.Ref) error {
|
|
if !r.IsSet() {
|
|
return fmt.Errorf("ref is not set: %s%.0w", r.CommonName(), errs.ErrInvalidReference)
|
|
}
|
|
schemeAPI, err := rc.schemeGet(r.Scheme)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return schemeAPI.TagDelete(ctx, r)
|
|
}
|
|
|
|
// TagList returns a tag list from a repository
|
|
func (rc *RegClient) TagList(ctx context.Context, r ref.Ref, opts ...scheme.TagOpts) (*tag.List, error) {
|
|
if !r.IsSetRepo() {
|
|
return nil, fmt.Errorf("ref is not set: %s%.0w", r.CommonName(), errs.ErrInvalidReference)
|
|
}
|
|
schemeAPI, err := rc.schemeGet(r.Scheme)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return schemeAPI.TagList(ctx, r, opts...)
|
|
}
|