Skip to content

Commit 5ba55c5

Browse files
authored
Merge pull request #23 from canonical/reduce-secrets
Reduce secrets in configuration to 1
2 parents cf72ac8 + 5d83af8 commit 5ba55c5

File tree

3 files changed

+12
-17
lines changed

3 files changed

+12
-17
lines changed

charmcraft.yaml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,10 @@ config:
7676
This user must be a member of ~git-ubuntu-import.
7777
default: "git-ubuntu-bot"
7878
type: string
79-
lpuser_ssh_key:
79+
lpuser_secret_id:
8080
description: |
81-
An ssh private key that matches with a public key associated with the
82-
lpuser account on Launchpad.
83-
type: secret
84-
lpuser_lp_key:
85-
description: |
86-
A Launchpad keyring entry that allows launchpadlib access, associated
87-
with the lpuser account on Launchpad.
81+
The secret ID for a vault containing the Launchpad user's lp key token
82+
and SSH private key.
8883
type: secret
8984
publish:
9085
description: |

src/charm.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,9 @@ def _num_workers(self) -> int:
100100
@property
101101
def _lpuser_ssh_key(self) -> str | None:
102102
try:
103-
secret_id = str(self.config["lpuser_ssh_key"])
104-
ssh_key_secret = self.model.get_secret(id=secret_id)
105-
ssh_key_data = ssh_key_secret.get_content().get("sshkey")
103+
secret_id = str(self.config["lpuser_secret_id"])
104+
lpuser_secret = self.model.get_secret(id=secret_id)
105+
ssh_key_data = lpuser_secret.get_content().get("sshkey")
106106

107107
if ssh_key_data is not None:
108108
return str(ssh_key_data)
@@ -115,9 +115,9 @@ def _lpuser_ssh_key(self) -> str | None:
115115
@property
116116
def _lpuser_lp_key(self) -> str | None:
117117
try:
118-
secret_id = str(self.config["lpuser_lp_key"])
119-
lp_key_secret = self.model.get_secret(id=secret_id)
120-
lp_key_data = lp_key_secret.get_content().get("lpkey")
118+
secret_id = str(self.config["lpuser_secret_id"])
119+
lpuser_secret = self.model.get_secret(id=secret_id)
120+
lp_key_data = lpuser_secret.get_content().get("lpkey")
121121

122122
if lp_key_data is not None:
123123
return str(lp_key_data)

tests/integration/test_charm.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,10 +183,10 @@ def test_update_config_with_ssh_key(app: str, juju: jubilant.Juju):
183183
with open("tests/integration/test-ssh-key", "r") as file:
184184
file_content = file.read()
185185

186-
secret_uri = juju.add_secret("lpuser-ssh-key", {"sshkey": file_content})
187-
juju.grant_secret("lpuser-ssh-key", app)
186+
secret_uri = juju.add_secret("lpuser-secret-id", {"sshkey": file_content})
187+
juju.grant_secret("lpuser-secret-id", app)
188188

189-
juju.config(app, {"lpuser_ssh_key": secret_uri})
189+
juju.config(app, {"lpuser_secret_id": secret_uri})
190190
juju.wait(jubilant.all_active)
191191

192192
ssh_key = juju.ssh(

0 commit comments

Comments
 (0)