...

Source file src/github.com/sigstore/cosign/v2/pkg/oci/empty/empty.go

Documentation: github.com/sigstore/cosign/v2/pkg/oci/empty

     1  //
     2  // Copyright 2021 The Sigstore Authors.
     3  //
     4  // Licensed under the Apache License, Version 2.0 (the "License");
     5  // you may not use this file except in compliance with the License.
     6  // You may obtain a copy of the License at
     7  //
     8  //     http://www.apache.org/licenses/LICENSE-2.0
     9  //
    10  // Unless required by applicable law or agreed to in writing, software
    11  // distributed under the License is distributed on an "AS IS" BASIS,
    12  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  // See the License for the specific language governing permissions and
    14  // limitations under the License.
    15  
    16  package empty
    17  
    18  import (
    19  	v1 "github.com/google/go-containerregistry/pkg/v1"
    20  	"github.com/google/go-containerregistry/pkg/v1/empty"
    21  	"github.com/google/go-containerregistry/pkg/v1/mutate"
    22  	"github.com/google/go-containerregistry/pkg/v1/types"
    23  
    24  	"github.com/sigstore/cosign/v2/pkg/oci"
    25  )
    26  
    27  // Signatures constructs an empty oci.Signatures.
    28  func Signatures() oci.Signatures {
    29  	base := empty.Image
    30  	if !oci.DockerMediaTypes() {
    31  		base = mutate.MediaType(base, types.OCIManifestSchema1)
    32  		base = mutate.ConfigMediaType(base, types.OCIConfigJSON)
    33  	}
    34  	return &emptyImage{
    35  		Image: base,
    36  	}
    37  }
    38  
    39  type emptyImage struct {
    40  	v1.Image
    41  }
    42  
    43  var _ oci.Signatures = (*emptyImage)(nil)
    44  
    45  // Get implements oci.Signatures
    46  func (*emptyImage) Get() ([]oci.Signature, error) {
    47  	return nil, nil
    48  }
    49  

View as plain text