Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion cmd/sops/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
publishcmd "go.mozilla.org/sops/v3/cmd/sops/subcommand/publish"
"go.mozilla.org/sops/v3/cmd/sops/subcommand/updatekeys"
"go.mozilla.org/sops/v3/config"
"go.mozilla.org/sops/v3/encrypt"
"go.mozilla.org/sops/v3/gcpkms"
"go.mozilla.org/sops/v3/hcvault"
"go.mozilla.org/sops/v3/keys"
Expand Down Expand Up @@ -796,7 +797,7 @@ func main() {
if err != nil {
return toExitError(err)
}
output, err = encrypt(encryptOpts{
output, err = encrypt.Encrypt(encrypt.EncryptOpts{
OutputStore: outputStore,
InputStore: inputStore,
InputPath: fileName,
Expand Down
8 changes: 4 additions & 4 deletions cmd/sops/encrypt.go → encrypt/encrypt.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package encrypt

import (
"io/ioutil"
Expand All @@ -14,7 +14,7 @@ import (
"go.mozilla.org/sops/v3/version"
)

type encryptOpts struct {
type EncryptOpts struct {
Cipher sops.Cipher
InputStore sops.Store
OutputStore sops.Store
Expand Down Expand Up @@ -46,7 +46,7 @@ func (err *fileAlreadyEncryptedError) UserError() string {
return wordwrap.WrapString(message, 75)
}

func ensureNoMetadata(opts encryptOpts, branch sops.TreeBranch) error {
func ensureNoMetadata(opts EncryptOpts, branch sops.TreeBranch) error {
for _, b := range branch {
if b.Key == "sops" {
return &fileAlreadyEncryptedError{}
Expand All @@ -55,7 +55,7 @@ func ensureNoMetadata(opts encryptOpts, branch sops.TreeBranch) error {
return nil
}

func encrypt(opts encryptOpts) (encryptedFile []byte, err error) {
func Encrypt(opts EncryptOpts) (encryptedFile []byte, err error) {
// Load the file
fileBytes, err := ioutil.ReadFile(opts.InputPath)
if err != nil {
Expand Down