launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #30720
[Merge] ~cjwatson/launchpad:charm-codehosting-sync-branches-action into launchpad:master
Colin Watson has proposed merging ~cjwatson/launchpad:charm-codehosting-sync-branches-action into launchpad:master.
Commit message:
charm: Add a sync-branches action to launchpad-codehosting
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/455646
Since this needs to be used by the staging-restore script, it's neater to wrap it up in an action.
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:charm-codehosting-sync-branches-action into launchpad:master.
diff --git a/charm/launchpad-codehosting/actions.yaml b/charm/launchpad-codehosting/actions.yaml
index 86aae0a..bca43bd 100644
--- a/charm/launchpad-codehosting/actions.yaml
+++ b/charm/launchpad-codehosting/actions.yaml
@@ -9,3 +9,12 @@ stop-services:
will persist across a reboot. It also doesn't disable cron jobs, since
those are handled by the cron-control mechanism instead; see
lp.services.scripts.base.cronscript_enabled.)
+sync-branches:
+ description: |
+ Sync branch data from production to a non-production environment.
+ params:
+ branches:
+ type: string
+ description: A space-separated list of branches to sync.
+ required:
+ - branches
diff --git a/charm/launchpad-codehosting/actions/actions.py b/charm/launchpad-codehosting/actions/actions.py
index cbac43e..a424399 100755
--- a/charm/launchpad-codehosting/actions/actions.py
+++ b/charm/launchpad-codehosting/actions/actions.py
@@ -15,6 +15,7 @@ basic.bootstrap_charm_deps()
basic.init_config_states()
from charmhelpers.core import hookenv # noqa: E402
+from ols import base # noqa: E402
def start_services():
@@ -31,6 +32,22 @@ def stop_services():
hookenv.action_set({"result": "Services stopped"})
+def sync_branches():
+ params = hookenv.action_get()
+ script = Path(base.code_dir(), "scripts", "sync-branches.py")
+ command = [
+ "sudo",
+ "-H",
+ "-u",
+ base.user(),
+ "LPCONFIG=launchpad-codehosting",
+ "--",
+ script,
+ ] + params["branches"].split()
+ subprocess.run(command, check=True)
+ hookenv.action_set({"result": "Branches synced"})
+
+
def main(argv):
action = Path(argv[0]).name
try:
@@ -38,6 +55,8 @@ def main(argv):
start_services()
elif action == "stop-services":
stop_services()
+ elif action == "sync-branches":
+ sync_branches()
else:
hookenv.action_fail(f"Action {action} not implemented.")
except Exception:
diff --git a/charm/launchpad-codehosting/actions/sync-branches b/charm/launchpad-codehosting/actions/sync-branches
new file mode 120000
index 0000000..405a394
--- /dev/null
+++ b/charm/launchpad-codehosting/actions/sync-branches
@@ -0,0 +1 @@
+actions.py
\ No newline at end of file