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

Function projectHash

internal/tracing/attributes.go:179–196  ·  view source on GitHub ↗

projectHash returns a checksum from the JSON encoding of the project.

(p *types.Project)

Source from the content-addressed store, hash-verified

177
178// projectHash returns a checksum from the JSON encoding of the project.
179func 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}

Callers 2

TestProjectHashFunction · 0.85
ProjectOptionsFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestProjectHashFunction · 0.68