MCPcopy Create free account
hub / github.com/baidu/EasyFaaS / CheckCode

Method CheckCode

pkg/funclet/code/check.go:32–43  ·  view source on GitHub ↗

CheckCode

(ctx *context.Context, filename, codeSha256 string)

Source from the content-addressed store, hash-verified

30
31// CheckCode
32func (codeMgr *Manager) CheckCode(ctx *context.Context, filename, codeSha256 string) bool {
33 defer ctx.Logger.TimeTrack(time.Now(), "Checksum", zap.String("filename", filename))
34 s, err := codeMgr.calSHA256(ctx, filename)
35 if err != nil {
36 return false
37 }
38 if s != codeSha256 {
39 ctx.Logger.Warnf("Check code failed, expected %s, got %s", codeSha256, s)
40 return false
41 }
42 return true
43}
44
45func (codeMgr *Manager) calSHA256(ctx *context.Context, filename string) (string, error) {
46 hasher := sha256.New()

Callers

nothing calls this directly

Calls 4

calSHA256Method · 0.95
TimeTrackMethod · 0.80
WarnfMethod · 0.80
StringMethod · 0.65

Tested by

no test coverage detected