Skip to content

Commit

Permalink
refactor: Update Save method to handle base64 encoded secrets
Browse files Browse the repository at this point in the history
The Save method in the SecretHandler struct is updated to handle base64 encoded secrets. If the decodeBase64EncodedSecret flag is set to true, the secret is decoded from base64 and then saved to the specified file. This allows for more flexibility in handling secrets that are stored in base64 format.
  • Loading branch information
h0n9 committed Jun 5, 2024
1 parent 02f350c commit ad08a02
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,24 +55,24 @@ func (handler *SecretHandler) Save(secretID, path string, decodeBase64EncodedSec
return handler.template.Execute(file, m)
}

var (
buff bytes.Buffer
decodedSecret []byte
)

// execute template
var buff bytes.Buffer
err = handler.template.Execute(&buff, m)
if err != nil {
return err
}

// decode base64 encoded secret
decodedSecret, err = util.DecodeBase64StrToBytes(buff.String())
decodedSecret, err := util.DecodeBase64BytesToBytes(buff.Bytes())
if err != nil {
return err
}

// write decoded secret to file
_, err = file.Write(decodedSecret)
return err
if err != nil {
return err
}

return nil
}

0 comments on commit ad08a02

Please sign in to comment.