don't export the exsisting TarSum struct and call the interface 'TarSum'
instead.
Signed-off-by: Vincent Batts <vbatts@redhat.com>
| ... | ... |
@@ -93,12 +93,12 @@ type Builder struct {
|
| 93 | 93 |
// both of these are controlled by the Remove and ForceRemove options in BuildOpts |
| 94 | 94 |
TmpContainers map[string]struct{} // a map of containers used for removes
|
| 95 | 95 |
|
| 96 |
- dockerfile *parser.Node // the syntax tree of the dockerfile |
|
| 97 |
- image string // image name for commit processing |
|
| 98 |
- maintainer string // maintainer name. could probably be removed. |
|
| 99 |
- cmdSet bool // indicates is CMD was set in current Dockerfile |
|
| 100 |
- context tarsum.TarSumInterface // the context is a tarball that is uploaded by the client |
|
| 101 |
- contextPath string // the path of the temporary directory the local context is unpacked to (server side) |
|
| 96 |
+ dockerfile *parser.Node // the syntax tree of the dockerfile |
|
| 97 |
+ image string // image name for commit processing |
|
| 98 |
+ maintainer string // maintainer name. could probably be removed. |
|
| 99 |
+ cmdSet bool // indicates is CMD was set in current Dockerfile |
|
| 100 |
+ context tarsum.TarSum // the context is a tarball that is uploaded by the client |
|
| 101 |
+ contextPath string // the path of the temporary directory the local context is unpacked to (server side) |
|
| 102 | 102 |
|
| 103 | 103 |
} |
| 104 | 104 |
|
| ... | ... |
@@ -167,7 +167,10 @@ func (b *Builder) runContextCommand(args []string, allowRemote bool, allowDecomp |
| 167 | 167 |
if err != nil {
|
| 168 | 168 |
return err |
| 169 | 169 |
} |
| 170 |
- tarSum := &tarsum.TarSum{Reader: r, DisableCompression: true}
|
|
| 170 |
+ tarSum, err := tarsum.NewTarSum(r, true, tarsum.Version0) |
|
| 171 |
+ if err != nil {
|
|
| 172 |
+ return err |
|
| 173 |
+ } |
|
| 171 | 174 |
if _, err := io.Copy(ioutil.Discard, tarSum); err != nil {
|
| 172 | 175 |
return err |
| 173 | 176 |
} |
| ... | ... |
@@ -28,24 +28,24 @@ const ( |
| 28 | 28 |
// This is used for calculating checksums of layers of an image, in some cases |
| 29 | 29 |
// including the byte payload of the image's json metadata as well, and for |
| 30 | 30 |
// calculating the checksums for buildcache. |
| 31 |
-func NewTarSum(r io.Reader, dc bool, v Version) (TarSumInterface, error) {
|
|
| 31 |
+func NewTarSum(r io.Reader, dc bool, v Version) (TarSum, error) {
|
|
| 32 | 32 |
if _, ok := tarSumVersions[v]; !ok {
|
| 33 | 33 |
return nil, ErrVersionNotImplemented |
| 34 | 34 |
} |
| 35 |
- return &TarSum{Reader: r, DisableCompression: dc, tarSumVersion: v}, nil
|
|
| 35 |
+ return &tarSum{Reader: r, DisableCompression: dc, tarSumVersion: v}, nil
|
|
| 36 | 36 |
} |
| 37 | 37 |
|
| 38 |
-// TarSumInterface is the generic interface for calculating fixed time |
|
| 38 |
+// TarSum is the generic interface for calculating fixed time |
|
| 39 | 39 |
// checksums of a tar archive |
| 40 |
-type TarSumInterface interface {
|
|
| 40 |
+type TarSum interface {
|
|
| 41 | 41 |
io.Reader |
| 42 | 42 |
GetSums() map[string]string |
| 43 | 43 |
Sum([]byte) string |
| 44 | 44 |
Version() Version |
| 45 | 45 |
} |
| 46 | 46 |
|
| 47 |
-// TarSum struct is the structure for a Version0 checksum calculation |
|
| 48 |
-type TarSum struct {
|
|
| 47 |
+// tarSum struct is the structure for a Version0 checksum calculation |
|
| 48 |
+type tarSum struct {
|
|
| 49 | 49 |
io.Reader |
| 50 | 50 |
tarR *tar.Reader |
| 51 | 51 |
tarW *tar.Writer |
| ... | ... |
@@ -62,11 +62,11 @@ type TarSum struct {
|
| 62 | 62 |
tarSumVersion Version // this field is not exported so it can not be mutated during use |
| 63 | 63 |
} |
| 64 | 64 |
|
| 65 |
-func (ts TarSum) Version() Version {
|
|
| 65 |
+func (ts tarSum) Version() Version {
|
|
| 66 | 66 |
return ts.tarSumVersion |
| 67 | 67 |
} |
| 68 | 68 |
|
| 69 |
-func (ts TarSum) selectHeaders(h *tar.Header, v Version) (set [][2]string) {
|
|
| 69 |
+func (ts tarSum) selectHeaders(h *tar.Header, v Version) (set [][2]string) {
|
|
| 70 | 70 |
for _, elem := range [][2]string{
|
| 71 | 71 |
{"name", h.Name},
|
| 72 | 72 |
{"mode", strconv.Itoa(int(h.Mode))},
|
| ... | ... |
@@ -89,7 +89,7 @@ func (ts TarSum) selectHeaders(h *tar.Header, v Version) (set [][2]string) {
|
| 89 | 89 |
return |
| 90 | 90 |
} |
| 91 | 91 |
|
| 92 |
-func (ts *TarSum) encodeHeader(h *tar.Header) error {
|
|
| 92 |
+func (ts *tarSum) encodeHeader(h *tar.Header) error {
|
|
| 93 | 93 |
for _, elem := range ts.selectHeaders(h, ts.Version()) {
|
| 94 | 94 |
if _, err := ts.h.Write([]byte(elem[0] + elem[1])); err != nil {
|
| 95 | 95 |
return err |
| ... | ... |
@@ -98,7 +98,7 @@ func (ts *TarSum) encodeHeader(h *tar.Header) error {
|
| 98 | 98 |
return nil |
| 99 | 99 |
} |
| 100 | 100 |
|
| 101 |
-func (ts *TarSum) Read(buf []byte) (int, error) {
|
|
| 101 |
+func (ts *tarSum) Read(buf []byte) (int, error) {
|
|
| 102 | 102 |
if ts.gz == nil {
|
| 103 | 103 |
ts.bufTar = bytes.NewBuffer([]byte{})
|
| 104 | 104 |
ts.bufGz = bytes.NewBuffer([]byte{})
|
| ... | ... |
@@ -197,7 +197,7 @@ func (ts *TarSum) Read(buf []byte) (int, error) {
|
| 197 | 197 |
return ts.bufGz.Read(buf) |
| 198 | 198 |
} |
| 199 | 199 |
|
| 200 |
-func (ts *TarSum) Sum(extra []byte) string {
|
|
| 200 |
+func (ts *tarSum) Sum(extra []byte) string {
|
|
| 201 | 201 |
var sums []string |
| 202 | 202 |
|
| 203 | 203 |
for _, sum := range ts.sums {
|
| ... | ... |
@@ -217,6 +217,6 @@ func (ts *TarSum) Sum(extra []byte) string {
|
| 217 | 217 |
return checksum |
| 218 | 218 |
} |
| 219 | 219 |
|
| 220 |
-func (ts *TarSum) GetSums() map[string]string {
|
|
| 220 |
+func (ts *tarSum) GetSums() map[string]string {
|
|
| 221 | 221 |
return ts.sums |
| 222 | 222 |
} |