sigs.k8s.io/release-sdk@v0.11.1-0.20240417074027-8061fb5e4952/sign/object.go (about)

     1  /*
     2  Copyright 2022 The Kubernetes 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  
    17  package sign
    18  
    19  // SignedObject contains additional metadata from the signing and verification
    20  // process.
    21  type SignedObject struct {
    22  	image *SignedImage
    23  	file  *SignedFile
    24  }
    25  
    26  // Image returns the image of the signed object and nil if it's a file.
    27  func (s *SignedObject) Image() *SignedImage {
    28  	return s.image
    29  }
    30  
    31  // File returns the file of the signed object and nil if it's an image.
    32  func (s *SignedObject) File() *SignedFile {
    33  	return s.file
    34  }
    35  
    36  // SignedFile contains additional metadata from the signing and verification
    37  // process.
    38  type SignedFile struct {
    39  	path            string
    40  	sha256          string
    41  	signaturePath   string
    42  	certificatePath string
    43  }
    44  
    45  // Path returns the path hash of the signed file.
    46  func (s *SignedFile) Path() string {
    47  	return s.path
    48  }
    49  
    50  // SHA256 returns the SHA256 hash of the signed file.
    51  func (s *SignedFile) SHA256() string {
    52  	return s.sha256
    53  }
    54  
    55  // SignaturePath returns the path to the Signature output of the signed file.
    56  func (s *SignedFile) SignaturePath() string {
    57  	return s.signaturePath
    58  }
    59  
    60  // CertificatePath returns the path to the Certificate output of the signed file.
    61  func (s *SignedFile) CertificatePath() string {
    62  	return s.certificatePath
    63  }
    64  
    65  // SignedImage contains additional metadata from the signing and verification
    66  // process.
    67  type SignedImage struct {
    68  	reference string
    69  	digest    string
    70  	signature string
    71  }
    72  
    73  // Reference returns the OCI registry reference of the object.
    74  func (s *SignedImage) Reference() string {
    75  	return s.reference
    76  }
    77  
    78  // Digest returns the digest of the signed object.
    79  func (s *SignedImage) Digest() string {
    80  	return s.digest
    81  }
    82  
    83  // Signature returns the signature of the signed object.
    84  func (s *SignedImage) Signature() string {
    85  	return s.signature
    86  }