Skip to content

Commit

Permalink
Rename SopsAgeSshPrivateKeyEnv to SopsAgeSshPrivateKeyFileEnv
Browse files Browse the repository at this point in the history
Signed-off-by: haoqixu <hq.xu0o0@gmail.com>
  • Loading branch information
haoqixu committed Dec 16, 2024
1 parent 9bd489a commit b325a74
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions age/keysource.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ const (
// SopsAgeKeyFileEnv can be set as an environment variable pointing to an
// age keys file.
SopsAgeKeyFileEnv = "SOPS_AGE_KEY_FILE"
// SopsAgeSshPrivateKeyEnv can be set as an environment variable pointing to
// SopsAgeSshPrivateKeyFileEnv can be set as an environment variable pointing to
// a private SSH key file.
SopsAgeSshPrivateKeyEnv = "SOPS_AGE_SSH_PRIVATE_KEY"
SopsAgeSshPrivateKeyFileEnv = "SOPS_AGE_SSH_PRIVATE_KEY_FILE"
// SopsAgeKeyUserConfigPath is the default age keys file path in
// getUserConfigDir().
SopsAgeKeyUserConfigPath = "sops/age/keys.txt"
Expand Down Expand Up @@ -306,7 +306,7 @@ func parseSSHIdentityFromPrivateKeyFile(keyPath string) (age.Identity, error) {
// environment variable is not present, it will fall back to `~/.ssh/id_ed25519`
// or `~/.ssh/id_rsa`. If no age SSH identity is found, it will return nil.
func loadAgeSSHIdentity() (age.Identity, error) {
sshKeyFilePath, ok := os.LookupEnv(SopsAgeSshPrivateKeyEnv)
sshKeyFilePath, ok := os.LookupEnv(SopsAgeSshPrivateKeyFileEnv)
if ok {
return parseSSHIdentityFromPrivateKeyFile(sshKeyFilePath)
}
Expand Down
6 changes: 3 additions & 3 deletions age/keysource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ func TestMasterKey_Decrypt(t *testing.T) {

assert.NoError(t, os.MkdirAll(filepath.Dir(keyPath), 0o700))
assert.NoError(t, os.WriteFile(keyPath, []byte(mockSshIdentity), 0o644))
t.Setenv(SopsAgeSshPrivateKeyEnv, keyPath)
t.Setenv(SopsAgeSshPrivateKeyFileEnv, keyPath)

got, err := key.Decrypt()
assert.NoError(t, err)
Expand Down Expand Up @@ -407,7 +407,7 @@ func TestMasterKey_loadIdentities(t *testing.T) {
assert.Len(t, got, 1)
})

t.Run(SopsAgeSshPrivateKeyEnv, func(t *testing.T) {
t.Run(SopsAgeSshPrivateKeyFileEnv, func(t *testing.T) {
tmpDir := t.TempDir()
overwriteUserConfigDir(t, tmpDir)

Expand All @@ -418,7 +418,7 @@ func TestMasterKey_loadIdentities(t *testing.T) {

assert.NoError(t, os.MkdirAll(filepath.Dir(keyPath), 0o700))
assert.NoError(t, os.WriteFile(keyPath, []byte(mockSshIdentity), 0o644))
t.Setenv(SopsAgeSshPrivateKeyEnv, keyPath)
t.Setenv(SopsAgeSshPrivateKeyFileEnv, keyPath)

key := &MasterKey{}
got, err := key.loadIdentities()
Expand Down

0 comments on commit b325a74

Please sign in to comment.