ServiceHash computes the configuration hash for a service.
(o types.ServiceConfig)
| 25 | |
| 26 | // ServiceHash computes the configuration hash for a service. |
| 27 | func 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. |
| 46 | func NetworkHash(o *types.NetworkConfig) (string, error) { |
no outgoing calls