Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexport pkg/cosign/remote.StaticLayer #483

Merged
merged 1 commit into from
Jul 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions pkg/cosign/remote/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ func UploadFiles(ref name.Reference, files []File, getMt MediaTypeGetter, remote
}

func UploadFile(b []byte, ref name.Reference, layerMt, configMt types.MediaType, remoteOpts ...remote.Option) (v1.Image, error) {
l := &StaticLayer{
B: b,
Mt: layerMt,
l := &staticLayer{
b: b,
mt: layerMt,
}

emptyOci := mutate.MediaType(empty.Image, types.OCIManifestSchema1)
Expand Down
42 changes: 21 additions & 21 deletions pkg/cosign/remote/remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ func SignatureImage(ref name.Reference, opts ...remote.Option) (v1.Image, error)
}

func findDuplicate(sigImage v1.Image, payload []byte, dupeDetector signature.Verifier, annotations map[string]string) ([]byte, error) {
l := &StaticLayer{
B: payload,
Mt: SimpleSigningMediaType,
l := &staticLayer{
b: payload,
mt: SimpleSigningMediaType,
}

sigDigest, err := l.Digest()
Expand Down Expand Up @@ -150,9 +150,9 @@ type UploadOpts struct {
}

func UploadSignature(signature, payload []byte, dst name.Reference, opts UploadOpts) (uploadedSig []byte, err error) {
l := &StaticLayer{
B: payload,
Mt: SimpleSigningMediaType,
l := &staticLayer{
b: payload,
mt: SimpleSigningMediaType,
}

base, err := SignatureImage(dst, opts.RemoteOpts...)
Expand Down Expand Up @@ -194,38 +194,38 @@ func UploadSignature(signature, payload []byte, dst name.Reference, opts UploadO
return signature, nil
}

type StaticLayer struct {
B []byte
Mt types.MediaType
type staticLayer struct {
b []byte
mt types.MediaType
}

func (l *StaticLayer) Digest() (v1.Hash, error) {
h, _, err := v1.SHA256(bytes.NewReader(l.B))
func (l *staticLayer) Digest() (v1.Hash, error) {
h, _, err := v1.SHA256(bytes.NewReader(l.b))
return h, err
}

// DiffID returns the Hash of the uncompressed layer.
func (l *StaticLayer) DiffID() (v1.Hash, error) {
h, _, err := v1.SHA256(bytes.NewReader(l.B))
func (l *staticLayer) DiffID() (v1.Hash, error) {
h, _, err := v1.SHA256(bytes.NewReader(l.b))
return h, err
}

// Compressed returns an io.ReadCloser for the compressed layer contents.
func (l *StaticLayer) Compressed() (io.ReadCloser, error) {
return ioutil.NopCloser(bytes.NewReader(l.B)), nil
func (l *staticLayer) Compressed() (io.ReadCloser, error) {
return ioutil.NopCloser(bytes.NewReader(l.b)), nil
}

// Uncompressed returns an io.ReadCloser for the uncompressed layer contents.
func (l *StaticLayer) Uncompressed() (io.ReadCloser, error) {
return ioutil.NopCloser(bytes.NewReader(l.B)), nil
func (l *staticLayer) Uncompressed() (io.ReadCloser, error) {
return ioutil.NopCloser(bytes.NewReader(l.b)), nil
}

// Size returns the compressed size of the Layer.
func (l *StaticLayer) Size() (int64, error) {
return int64(len(l.B)), nil
func (l *staticLayer) Size() (int64, error) {
return int64(len(l.b)), nil
}

// MediaType returns the media type of the Layer.
func (l *StaticLayer) MediaType() (types.MediaType, error) {
return l.Mt, nil
func (l *staticLayer) MediaType() (types.MediaType, error) {
return l.mt, nil
}