2018-02-05 16:05:59 -05:00
|
|
|
package cache // import "github.com/docker/docker/image/cache"
|
2014-02-11 23:04:39 -05:00
|
|
|
|
2017-04-21 15:08:11 -04:00
|
|
|
import (
|
|
|
|
"github.com/docker/docker/api/types/container"
|
|
|
|
)
|
2015-12-18 13:36:17 -05:00
|
|
|
|
2017-01-03 13:19:27 -05:00
|
|
|
// compare two Config struct. Do not compare the "Image" nor "Hostname" fields
|
2014-02-11 23:04:39 -05:00
|
|
|
// If OpenStdin is set, then it differs
|
2017-01-03 13:19:27 -05:00
|
|
|
func compare(a, b *container.Config) bool {
|
2014-02-11 23:04:39 -05:00
|
|
|
if a == nil || b == nil ||
|
|
|
|
a.OpenStdin || b.OpenStdin {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
if a.AttachStdout != b.AttachStdout ||
|
|
|
|
a.AttachStderr != b.AttachStderr ||
|
|
|
|
a.User != b.User ||
|
|
|
|
a.OpenStdin != b.OpenStdin ||
|
2014-04-08 05:26:09 -04:00
|
|
|
a.Tty != b.Tty {
|
2014-02-11 23:04:39 -05:00
|
|
|
return false
|
|
|
|
}
|
2015-04-10 20:05:21 -04:00
|
|
|
|
2016-02-29 06:28:37 -05:00
|
|
|
if len(a.Cmd) != len(b.Cmd) ||
|
2014-02-11 23:04:39 -05:00
|
|
|
len(a.Env) != len(b.Env) ||
|
2015-03-20 08:14:31 -04:00
|
|
|
len(a.Labels) != len(b.Labels) ||
|
2014-02-11 23:04:39 -05:00
|
|
|
len(a.ExposedPorts) != len(b.ExposedPorts) ||
|
2016-02-29 06:28:37 -05:00
|
|
|
len(a.Entrypoint) != len(b.Entrypoint) ||
|
2014-02-11 23:04:39 -05:00
|
|
|
len(a.Volumes) != len(b.Volumes) {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2016-02-29 06:28:37 -05:00
|
|
|
for i := 0; i < len(a.Cmd); i++ {
|
|
|
|
if a.Cmd[i] != b.Cmd[i] {
|
2014-02-11 23:04:39 -05:00
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for i := 0; i < len(a.Env); i++ {
|
|
|
|
if a.Env[i] != b.Env[i] {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
2015-03-20 08:14:31 -04:00
|
|
|
for k, v := range a.Labels {
|
|
|
|
if v != b.Labels[k] {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
2014-02-11 23:04:39 -05:00
|
|
|
for k := range a.ExposedPorts {
|
|
|
|
if _, exists := b.ExposedPorts[k]; !exists {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
2015-04-10 20:05:21 -04:00
|
|
|
|
2016-02-29 06:28:37 -05:00
|
|
|
for i := 0; i < len(a.Entrypoint); i++ {
|
|
|
|
if a.Entrypoint[i] != b.Entrypoint[i] {
|
2014-02-11 23:04:39 -05:00
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for key := range a.Volumes {
|
|
|
|
if _, exists := b.Volumes[key]; !exists {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true
|
|
|
|
}
|