...

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

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

     1  //
     2  // Copyright 2023 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 remote
    17  
    18  import (
    19  	"github.com/google/go-containerregistry/pkg/name"
    20  	v1 "github.com/google/go-containerregistry/pkg/v1"
    21  	"github.com/sigstore/cosign/v2/pkg/oci"
    22  )
    23  
    24  // SignedUnknown provides access to signed metadata without directly accessing
    25  // the underlying entity.  This can be used to access signature metadata for
    26  // digests that have not been published (yet).
    27  func SignedUnknown(digest name.Digest, options ...Option) oci.SignedEntity {
    28  	o := makeOptions(digest.Context(), options...)
    29  	return &unknown{
    30  		digest: digest,
    31  		opt:    o,
    32  	}
    33  }
    34  
    35  type unknown struct {
    36  	digest name.Digest
    37  	opt    *options
    38  }
    39  
    40  var _ oci.SignedEntity = (*unknown)(nil)
    41  
    42  // Digest implements digestable
    43  func (i *unknown) Digest() (v1.Hash, error) {
    44  	return v1.NewHash(i.digest.DigestStr())
    45  }
    46  
    47  // Signatures implements oci.SignedEntity
    48  func (i *unknown) Signatures() (oci.Signatures, error) {
    49  	return signatures(i, i.opt)
    50  }
    51  
    52  // Attestations implements oci.SignedEntity
    53  func (i *unknown) Attestations() (oci.Signatures, error) {
    54  	return attestations(i, i.opt)
    55  }
    56  
    57  // Attachment implements oci.SignedEntity
    58  func (i *unknown) Attachment(name string) (oci.File, error) {
    59  	return attachment(i, name, i.opt)
    60  }
    61  

View as plain text