Skip to content

Create public encrypt pkg and references to it#2166

Open
manute wants to merge 2 commits into
getsops:mainfrom
manute:main
Open

Create public encrypt pkg and references to it#2166
manute wants to merge 2 commits into
getsops:mainfrom
manute:main

Conversation

@manute
Copy link
Copy Markdown
Contributor

@manute manute commented May 2, 2026

Creates the encrypt pkg and refactorize the code to change all the references to it

Signed-off-by: Manuel Alonso <434575+manute@users.noreply.github.com>
@felixfontein felixfontein changed the title feat(encrypt): create encrypt pkg and references to it Create public encrypt pkg and references to it May 2, 2026
@felixfontein felixfontein linked an issue May 2, 2026 that may be closed by this pull request
@nachtjasmin
Copy link
Copy Markdown

nachtjasmin commented May 19, 2026

Unfortunately, the given package interface is pretty rudimentary and requires a lot of manual plumbing by callers to work with the stores and all that. In comparison, the decrypt package provides much more integration and doesn't require callers to duplicate current behaviour from the current CLI. :/

I tried to integrate it but stopped after I realised that I'd duplicate the CLI at several points.

@manute
Copy link
Copy Markdown
Contributor Author

manute commented May 19, 2026

@nachtjasmin yeah I noticed that, thanks for the feedback. This PR it is only to have it as public interface to not have to duplicate the file - so with the pkg of this PR you can implement a method like :

func EncryptWith(awsKmsArn, filePath string) ([]byte, error) {

	masterKey := kms.MasterKey{
		Arn: awsKmsArn,
	}

	opts := encrypt.EncryptOpts{
		Cipher: aes.NewCipher(),
		KeyServices: []keyservice.KeyServiceClient{
			keyservice.NewLocalClient(),
		},
		InputStore:  &yaml.Store{},
		OutputStore: &yaml.Store{},
		InputPath:   filePath,
		EncryptConfig: encrypt.EncryptConfig{
			KeyGroups: []sops.KeyGroup{
				[]keys.MasterKey{&masterKey},
			},
		},
	}

	return encrypt.Encrypt(opts)
}

so at least you have more control over it 👍🏽

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[request] encrypt package

2 participants