projectHash returns a checksum from the JSON encoding of the project.
(p *types.Project)
| 177 | |
| 178 | // projectHash returns a checksum from the JSON encoding of the project. |
| 179 | func projectHash(p *types.Project) (string, bool) { |
| 180 | if p == nil { |
| 181 | return "", false |
| 182 | } |
| 183 | // disabled services aren't included in the output, so make a copy with |
| 184 | // all the services active for hashing |
| 185 | var err error |
| 186 | p, err = p.WithServicesEnabled(append(p.ServiceNames(), p.DisabledServiceNames()...)...) |
| 187 | if err != nil { |
| 188 | return "", false |
| 189 | } |
| 190 | projData, err := json.Marshal(p) |
| 191 | if err != nil { |
| 192 | return "", false |
| 193 | } |
| 194 | d := sha256.Sum256(projData) |
| 195 | return fmt.Sprintf("%x", d), true |
| 196 | } |
no outgoing calls