manta_server/backend_dispatcher/apply_session.rs
1//! [`ApplySessionTrait`] impl for [`StaticBackendDispatcher`].
2//!
3//! Forwards to the backend's "apply ad-hoc CFS session" helper, which
4//! builds a `CfsConfigurationRequest` from the supplied Gitea repos +
5//! commit ids, POSTs it to `cfs/v3/configurations`, then POSTs a
6//! `CfsSessionPostRequest` to `cfs/v3/sessions` that runs the
7//! playbook with the supplied Ansible options.
8//!
9//! Ochami uses the trait default and returns [`Error::Message`]
10//! ("Apply session command not implemented for this backend").
11
12use super::*;
13
14impl ApplySessionTrait for StaticBackendDispatcher {
15 /// Build a CFS configuration from `repos_name_vec` /
16 /// `repos_last_commit_id_vec` and run an Ansible session against it.
17 ///
18 /// Returns `(cfs_configuration_name, cfs_session_name)` — the names
19 /// of the artifacts created on the backend.
20 ///
21 /// # Errors
22 ///
23 /// Forwards backend errors verbatim: [`Error::CsmError`] on CFS
24 /// rejection (e.g. duplicate configuration name when the helper
25 /// retries), [`Error::LocalGitError`] when Gitea metadata lookup
26 /// fails, [`Error::Message`] on Ochami.
27 async fn apply_session(
28 &self,
29 gitea_token: &str,
30 gitea_base_url: &str,
31 token: &str,
32 cfs_conf_sess_name: Option<&str>,
33 playbook_yaml_file_name_opt: Option<&str>,
34 group_name: Option<&str>,
35 repos_name_vec: &[&str],
36 repos_last_commit_id_vec: &[&str],
37 ansible_limit: Option<&str>,
38 ansible_verbosity: Option<&str>,
39 ansible_passthrough: Option<&str>,
40 ) -> Result<(String, String), Error> {
41 dispatch!(
42 self,
43 apply_session,
44 gitea_token,
45 gitea_base_url,
46 token,
47 cfs_conf_sess_name,
48 playbook_yaml_file_name_opt,
49 group_name,
50 repos_name_vec,
51 repos_last_commit_id_vec,
52 ansible_limit,
53 ansible_verbosity,
54 ansible_passthrough
55 )
56 }
57}