monitor_client/api/execute/
repo.rs

1use clap::Parser;
2use derive_empty_traits::EmptyTraits;
3use resolver_api::derive::Request;
4use serde::{Deserialize, Serialize};
5use typeshare::typeshare;
6
7use crate::entities::update::Update;
8
9use super::MonitorExecuteRequest;
10
11//
12
13/// Clones the target repo. Response: [Update].
14///
15/// Note. Repo must have server attached at `server_id`.
16///
17/// 1. Clones the repo on the target server using `git clone https://{$token?}@github.com/${repo} -b ${branch}`.
18/// The token will only be used if a github account is specified,
19/// and must be declared in the periphery configuration on the target server.
20/// 2. If `on_clone` and `on_pull` are specified, they will be executed.
21/// `on_clone` will be executed before `on_pull`.
22#[typeshare]
23#[derive(
24  Serialize,
25  Deserialize,
26  Debug,
27  Clone,
28  PartialEq,
29  Request,
30  EmptyTraits,
31  Parser,
32)]
33#[empty_traits(MonitorExecuteRequest)]
34#[response(Update)]
35pub struct CloneRepo {
36  /// Id or name
37  pub repo: String,
38}
39
40//
41
42/// Pulls the target repo. Response: [Update].
43///
44/// Note. Repo must have server attached at `server_id`.
45///
46/// 1. Pulls the repo on the target server using `git pull`.
47/// 2. If `on_pull` is specified, it will be executed after the pull is complete.
48#[typeshare]
49#[derive(
50  Serialize,
51  Deserialize,
52  Debug,
53  Clone,
54  PartialEq,
55  Request,
56  EmptyTraits,
57  Parser,
58)]
59#[empty_traits(MonitorExecuteRequest)]
60#[response(Update)]
61pub struct PullRepo {
62  /// Id or name
63  pub repo: String,
64}
65
66//
67
68/// Builds the target repo, using the attached builder. Response: [Update].
69///
70/// Note. Repo must have builder attached at `builder_id`.
71///
72/// 1. Spawns the target builder instance (For AWS type. For Server type, just use CloneRepo).
73/// 2. Clones the repo on the builder using `git clone https://{$token?}@github.com/${repo} -b ${branch}`.
74/// The token will only be used if a github account is specified,
75/// and must be declared in the periphery configuration on the builder instance.
76/// 3. If `on_clone` and `on_pull` are specified, they will be executed.
77/// `on_clone` will be executed before `on_pull`.
78#[typeshare]
79#[derive(
80  Serialize,
81  Deserialize,
82  Debug,
83  Clone,
84  PartialEq,
85  Request,
86  EmptyTraits,
87  Parser,
88)]
89#[empty_traits(MonitorExecuteRequest)]
90#[response(Update)]
91pub struct BuildRepo {
92  /// Id or name
93  pub repo: String,
94}
95
96//
97
98/// Cancels the target repo build.
99/// Only does anything if the repo build is `building` when called.
100/// Response: [Update]
101#[typeshare]
102#[derive(
103  Serialize,
104  Deserialize,
105  Debug,
106  Clone,
107  PartialEq,
108  Request,
109  EmptyTraits,
110  Parser,
111)]
112#[empty_traits(MonitorExecuteRequest)]
113#[response(Update)]
114pub struct CancelRepoBuild {
115  /// Can be id or name
116  pub repo: String,
117}