Skip to main content

ephemeris_forge_forgejo/reconcile/
actions_variables.rs

1use ephemeris_forge::RepoRef;
2
3use super::Client;
4use crate::Live;
5use crate::api::{Api, ForgeError};
6use crate::config::ActionsVariables;
7use crate::operation::actions_variables::Operation;
8
9impl<A: Api> Client<A> {
10    pub(super) async fn read_actions_variables(
11        &self,
12        repository: &RepoRef,
13        config: Option<&ActionsVariables>,
14        live: &mut Live,
15    ) -> Result<(), ForgeError> {
16        if config.is_some() {
17            live.actions_variables = self.api.actions_variables(repository).await?;
18        }
19        Ok(())
20    }
21
22    pub(super) async fn apply_actions_variables(
23        &self,
24        repository: &RepoRef,
25        operation: &Operation,
26    ) -> Result<(), ForgeError> {
27        match operation {
28            Operation::Create { name, body } => {
29                self.api
30                    .create_actions_variable(repository, name, body)
31                    .await
32            }
33            Operation::Update { name, body } => {
34                self.api
35                    .update_actions_variable(repository, name, body)
36                    .await
37            }
38            Operation::Delete { name } => self.api.delete_actions_variable(repository, name).await,
39        }
40    }
41}