ci_detective/docker.rs
1use env;
2
3/// Docker
4///
5/// # References
6///
7/// - <https://docs.docker.com/docker-cloud/builds/advanced/>
8/// - <https://github.com/codecov/codecov-bash/blob/8b76995ad4a95a61cecd4b049a448a402d91d197/codecov#L490-L500>
9#[derive(Clone, Debug)]
10#[cfg_attr(feature = "nightly", non_exhaustive)]
11pub struct Docker {
12 /// The name of the branch or the tag that is currently being tested.
13 pub source_branch: String,
14 /// The SHA1 hash of the commit being tested.
15 pub source_commit: String,
16 /// The message from the commit being tested and built.
17 pub commit_msg: String,
18 /// The name of the Docker repository being built.
19 pub repo: String,
20 /// The Docker repository tag being built.
21 pub cache_tag: String,
22 /// The name and tag of the Docker repository being built.
23 /// (This variable is a combination of `DOCKER_REPO`:`CACHE_TAG`.)
24 pub image_name: String,
25 non_exhaustive: (),
26}
27
28impl Docker {
29 /// Construct this provider's information from the environment.
30 pub fn from_env() -> Option<Self> {
31 Some(Docker {
32 source_branch: env("SOURCE_BRANCH")?,
33 source_commit: env("SOURCE_COMMIT")?,
34 commit_msg: env("COMMIT_MSG")?,
35 repo: env("DOCKER_REPO")?,
36 cache_tag: env("CACHE_TAG")?,
37 image_name: env("IMAGE_NAME")?,
38 non_exhaustive: (),
39 })
40 }
41}