move artifact package over
Signed-off-by: Meredith Lancaster <malancas@github.com>
This commit is contained in:
parent
3a08c03cc7
commit
97c10f4c04
10 changed files with 525 additions and 1 deletions
28
pkg/cmd/attestation/artifact/image.go
Normal file
28
pkg/cmd/attestation/artifact/image.go
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
package artifact
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/distribution/reference"
|
||||
"github.com/github/gh-attestation/pkg/artifact/oci"
|
||||
)
|
||||
|
||||
func digestContainerImageArtifact(url string, client oci.Client) (*DigestedArtifact, error) {
|
||||
// try to parse the url as a valid registry reference
|
||||
named, err := reference.Parse(url)
|
||||
if err != nil {
|
||||
// cannot be parsed as a registry reference
|
||||
return nil, fmt.Errorf("artifact %s is not a valid registry reference", url)
|
||||
}
|
||||
|
||||
digest, err := client.GetImageDigest(named.String())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &DigestedArtifact{
|
||||
URL: fmt.Sprintf("oci://%s", named.String()),
|
||||
digest: digest.Hex,
|
||||
digestAlg: digest.Algorithm,
|
||||
}, nil
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue