...

Source file src/cuelabs.dev/go/oci/ociregistry/ocifilter/readonly.go

Documentation: cuelabs.dev/go/oci/ociregistry/ocifilter

     1  // Copyright 2023 CUE Labs AG
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package ocifilter
    16  
    17  import "cuelabs.dev/go/oci/ociregistry"
    18  
    19  // ReadOnly returns a registry implementation that returns
    20  // an "operation unsupported" error from all entry points that
    21  // mutate the registry.
    22  func ReadOnly(r ociregistry.Interface) ociregistry.Interface {
    23  	// One level deeper so the Reader and Lister values take precedence,
    24  	// following Go's shallower-method-wins rules.
    25  	type deeper struct {
    26  		*ociregistry.Funcs
    27  	}
    28  	return struct {
    29  		ociregistry.Reader
    30  		ociregistry.Lister
    31  		deeper
    32  	}{
    33  		Reader: r,
    34  		Lister: r,
    35  	}
    36  }
    37  

View as plain text