MCPcopy Index your code
hub / github.com/cloudnative-pg/cloudnative-pg / Get

Function Get

pkg/executablehash/executablehash.go:48–75  ·  view source on GitHub ↗

Get gets the hashcode of the executable of this binary

()

Source from the content-addressed store, hash-verified

46
47// Get gets the hashcode of the executable of this binary
48func Get() (string, error) {
49 var err error
50
51 mx.Lock()
52 defer mx.Unlock()
53
54 if processBinaryHash != "" {
55 return processBinaryHash, nil
56 }
57
58 // Look for the binary of the operator
59 binaryFileStream, err := Stream()
60 if err != nil {
61 return "", err
62 }
63 defer func() {
64 err = binaryFileStream.Close()
65 }()
66
67 encoder := sha256.New()
68 _, err = io.Copy(encoder, binaryFileStream)
69 if err != nil {
70 return "", err
71 }
72
73 processBinaryHash = fmt.Sprintf("%x", encoder.Sum(nil))
74 return processBinaryHash, err
75}
76
77// GetByName gets the hashcode of a binary given its filename
78func GetByName(name string) (string, error) {

Callers 2

GetStatusMethod · 0.92

Calls 2

StreamFunction · 0.85
CloseMethod · 0.65

Tested by

no test coverage detected