diff --git a/age/keysource.go b/age/keysource.go index d2f6e2ec8..f52d6f442 100644 --- a/age/keysource.go +++ b/age/keysource.go @@ -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" @@ -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) } diff --git a/age/keysource_test.go b/age/keysource_test.go index bf6e3ffe1..f2b592489 100644 --- a/age/keysource_test.go +++ b/age/keysource_test.go @@ -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) @@ -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) @@ -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()