MCPcopy
hub / github.com/docker/compose / ServiceHash

Function ServiceHash

pkg/compose/hash.go:27–43  ·  view source on GitHub ↗

ServiceHash computes the configuration hash for a service.

(o types.ServiceConfig)

Source from the content-addressed store, hash-verified

25
26// ServiceHash computes the configuration hash for a service.
27func ServiceHash(o types.ServiceConfig) (string, error) {
28 // remove the Build config when generating the service hash
29 o.Build = nil
30 o.PullPolicy = ""
31 o.Scale = nil
32 if o.Deploy != nil {
33 o.Deploy.Replicas = nil
34 }
35 o.DependsOn = nil
36 o.Profiles = nil
37
38 bytes, err := json.Marshal(o)
39 if err != nil {
40 return "", err
41 }
42 return digest.SHA256.FromBytes(bytes).Encoded(), nil
43}
44
45// NetworkHash computes the configuration hash for a network.
46func NetworkHash(o *types.NetworkConfig) (string, error) {

Callers 5

runHashFunction · 0.92
TestServiceHashFunction · 0.85
mustServiceHashFunction · 0.85
prepareLabelsMethod · 0.85

Calls

no outgoing calls

Tested by 2

TestServiceHashFunction · 0.68
mustServiceHashFunction · 0.68