File tree Expand file tree Collapse file tree 2 files changed +12
-0
lines changed
Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ import (
1818 "bytes"
1919 "encoding/json"
2020 "errors"
21+ "sync"
2122
2223 v1 "github.com/google/go-containerregistry/pkg/v1"
2324 "github.com/google/go-containerregistry/pkg/v1/partial"
@@ -38,6 +39,8 @@ type image struct {
3839 diffIDMap map [v1.Hash ]v1.Layer
3940 digestMap map [v1.Hash ]v1.Layer
4041 subject * v1.Descriptor
42+
43+ sync.Mutex
4144}
4245
4346var _ v1.Image = (* image )(nil )
@@ -50,6 +53,9 @@ func (i *image) MediaType() (types.MediaType, error) {
5053}
5154
5255func (i * image ) compute () error {
56+ i .Lock ()
57+ defer i .Unlock ()
58+
5359 // Don't re-compute if already computed.
5460 if i .computed {
5561 return nil
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ package mutate
1717import (
1818 "encoding/json"
1919 "fmt"
20+ "sync"
2021
2122 "github.com/google/go-containerregistry/pkg/logs"
2223 v1 "github.com/google/go-containerregistry/pkg/v1"
@@ -71,6 +72,8 @@ type index struct {
7172 indexMap map [v1.Hash ]v1.ImageIndex
7273 layerMap map [v1.Hash ]v1.Layer
7374 subject * v1.Descriptor
75+
76+ sync.Mutex
7477}
7578
7679var _ v1.ImageIndex = (* index )(nil )
@@ -85,6 +88,9 @@ func (i *index) MediaType() (types.MediaType, error) {
8588func (i * index ) Size () (int64 , error ) { return partial .Size (i ) }
8689
8790func (i * index ) compute () error {
91+ i .Lock ()
92+ defer i .Unlock ()
93+
8894 // Don't re-compute if already computed.
8995 if i .computed {
9096 return nil
You can’t perform that action at this time.
0 commit comments