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
25
pkg/cmd/attestation/artifact/file.go
Normal file
25
pkg/cmd/attestation/artifact/file.go
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
package artifact
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/github/gh-attestation/pkg/artifact/digest"
|
||||
)
|
||||
|
||||
func digestLocalFileArtifact(filename, digestAlg string) (*DigestedArtifact, error) {
|
||||
data, err := os.Open(filename)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to get open local artifact: %w", err)
|
||||
}
|
||||
defer data.Close()
|
||||
digest, err := digest.CalculateDigestWithAlgorithm(data, digestAlg)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to calculate local artifact digest: %w", err)
|
||||
}
|
||||
return &DigestedArtifact{
|
||||
URL: fmt.Sprintf("file://%s", filename),
|
||||
digest: digest,
|
||||
digestAlg: digestAlg,
|
||||
}, nil
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue