proto_pdk_api/api/
source.rs

1use super::is_false;
2use warpgate_api::{api_enum, api_struct};
3
4api_struct!(
5    /// Source code is contained in an archive.
6    pub struct ArchiveSource {
7        /// The URL to download the archive from.
8        pub url: String,
9
10        /// A path prefix within the archive to remove.
11        #[serde(default, skip_serializing_if = "Option::is_none")]
12        pub prefix: Option<String>,
13    }
14);
15
16api_struct!(
17    /// Source code is located in a Git repository.
18    pub struct GitSource {
19        /// The URL of the Git remote.
20        pub url: String,
21
22        /// The branch/commit/tag to checkout.
23        #[serde(default, skip_serializing_if = "Option::is_none")]
24        pub reference: Option<String>,
25
26        /// Include submodules during checkout.
27        #[serde(default, skip_serializing_if = "is_false")]
28        pub submodules: bool,
29    }
30);
31
32api_enum!(
33    /// The location in which source code can be acquired.
34    #[serde(tag = "type", rename_all = "kebab-case")]
35    pub enum SourceLocation {
36        /// Downloaded from an archive.
37        #[cfg_attr(feature = "schematic", schema(nested))]
38        Archive(ArchiveSource),
39
40        /// Cloned from a Git repository.
41        #[cfg_attr(feature = "schematic", schema(nested))]
42        Git(GitSource),
43    }
44);