cue-labs / oci

Go modules related to OCI (Open Container Initiative) registries
Apache License 2.0
22 stars 3 forks source link

ociregistry/ocimem: implement immutable tag support #23

Closed rogpeppe closed 4 months ago

rogpeppe commented 5 months ago

Many registries implement support for tag immutability. In order to write tests that rely on that behaviour, it would be useful to support it in ocimem.

Proposed new API:

package ocimem

// NewWithConfig returns a new in-memory [ociregistry.Interface]
// implementation using the given configuration. If
// cfg is nil, it's treated the same as a pointer to the zero [Config] value.
func NewWithConfig(cfg0 *Config) *Registry

// Config holds configuration for the registry.
type Config struct {
    // ImmutableTags specifies that tags in the registry cannot
    // be changed. Specifically the following restrictions are enforced:
    // - no deletion of tagged manifests or any blob that a tagged manifest
    // refers to.
    // - no removal of tags from a manifest
    // - no pushing of a tag if that tag already exists, even if it has
    // the same digest.
    ImmutableTags bool
 }

This is backward compatible and leaves the door open for more configuration options.

rogpeppe commented 4 months ago

Fixed by https://review.gerrithub.io/c/cue-labs/oci/+/1176886