Without this we won't do a proper cacche check because we skip the
labels part of the config.
Signed-off-by: Doug Davis <dug@us.ibm.com>
| ... | ... |
@@ -4585,14 +4585,29 @@ func TestBuildLabelsCache(t *testing.T) {
|
| 4585 | 4585 |
`FROM busybox |
| 4586 | 4586 |
LABEL Vendor=Acme1`, true) |
| 4587 | 4587 |
if err != nil || id1 == id2 {
|
| 4588 |
- t.Fatalf("Build 2 should have worked & NOT used cache(%s,%s): %v", id1, id2, err)
|
|
| 4588 |
+ t.Fatalf("Build 3 should have worked & NOT used cache(%s,%s): %v", id1, id2, err)
|
|
| 4589 | 4589 |
} |
| 4590 | 4590 |
|
| 4591 | 4591 |
id2, err = buildImage(name, |
| 4592 | 4592 |
`FROM busybox |
| 4593 | 4593 |
LABEL Vendor Acme`, true) // Note: " " and "=" should be same |
| 4594 | 4594 |
if err != nil || id1 != id2 {
|
| 4595 |
- t.Fatalf("Build 3 should have worked & used cache(%s,%s): %v", id1, id2, err)
|
|
| 4595 |
+ t.Fatalf("Build 4 should have worked & used cache(%s,%s): %v", id1, id2, err)
|
|
| 4596 |
+ } |
|
| 4597 |
+ |
|
| 4598 |
+ // Now make sure the cache isn't used by mistake |
|
| 4599 |
+ id1, err = buildImage(name, |
|
| 4600 |
+ `FROM busybox |
|
| 4601 |
+ LABEL f1=b1 f2=b2`, false) |
|
| 4602 |
+ if err != nil {
|
|
| 4603 |
+ t.Fatalf("Build 5 should have worked: %q", err)
|
|
| 4604 |
+ } |
|
| 4605 |
+ |
|
| 4606 |
+ id2, err = buildImage(name, |
|
| 4607 |
+ `FROM busybox |
|
| 4608 |
+ LABEL f1="b1 f2=b2"`, true) |
|
| 4609 |
+ if err != nil || id1 == id2 {
|
|
| 4610 |
+ t.Fatalf("Build 6 should have worked & NOT used the cache(%s,%s): %q", id1, id2, err)
|
|
| 4596 | 4611 |
} |
| 4597 | 4612 |
|
| 4598 | 4613 |
logDone("build - label cache")
|
| ... | ... |
@@ -19,6 +19,7 @@ func Compare(a, b *Config) bool {
|
| 19 | 19 |
} |
| 20 | 20 |
if len(a.Cmd) != len(b.Cmd) || |
| 21 | 21 |
len(a.Env) != len(b.Env) || |
| 22 |
+ len(a.Labels) != len(b.Labels) || |
|
| 22 | 23 |
len(a.PortSpecs) != len(b.PortSpecs) || |
| 23 | 24 |
len(a.ExposedPorts) != len(b.ExposedPorts) || |
| 24 | 25 |
len(a.Entrypoint) != len(b.Entrypoint) || |
| ... | ... |
@@ -36,6 +37,11 @@ func Compare(a, b *Config) bool {
|
| 36 | 36 |
return false |
| 37 | 37 |
} |
| 38 | 38 |
} |
| 39 |
+ for k, v := range a.Labels {
|
|
| 40 |
+ if v != b.Labels[k] {
|
|
| 41 |
+ return false |
|
| 42 |
+ } |
|
| 43 |
+ } |
|
| 39 | 44 |
for i := 0; i < len(a.PortSpecs); i++ {
|
| 40 | 45 |
if a.PortSpecs[i] != b.PortSpecs[i] {
|
| 41 | 46 |
return false |