Commit b7204242 authored by Jacob Vosmaer's avatar Jacob Vosmaer

Set s.bytes only once

parent 5837c3fb
......@@ -33,6 +33,13 @@ func (s *Secret) getBytes() []byte {
}
func (s *Secret) setBytes() ([]byte, error) {
s.Lock()
defer s.Unlock()
if s.bytes != nil {
return s.bytes, nil
}
base64Bytes, err := ioutil.ReadFile(s.Path)
if err != nil {
return nil, fmt.Errorf("read Secret.Path: %v", err)
......@@ -48,9 +55,6 @@ func (s *Secret) setBytes() ([]byte, error) {
return nil, fmt.Errorf("expected %d secretBytes in %s, found %d", numSecretBytes, s.Path, n)
}
s.Lock()
defer s.Unlock()
s.bytes = secretBytes
return secretBytes, nil
return s.bytes, nil
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment