28 lines
496 B
Go
28 lines
496 B
Go
package sopshelper
|
|
|
|
import (
|
|
// "go.mozilla.org/sops/v3/decrypt"
|
|
"os"
|
|
|
|
"github.com/getsops/sops/v3/decrypt"
|
|
"github.com/sirupsen/logrus"
|
|
)
|
|
|
|
type Sops struct{}
|
|
|
|
func NewSops() SopsHelper {
|
|
return &Sops{}
|
|
}
|
|
func (sops Sops) Decrypt(filepath string) ([]byte, error) {
|
|
logrus.Infof("trying to decrypt: %s", filepath)
|
|
encFile, err := os.ReadFile(filepath)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
res, err := decrypt.Data(encFile, "yaml")
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return res, nil
|
|
}
|