-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuildspec.rs
84 lines (67 loc) · 1.68 KB
/
buildspec.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
use serde::{Deserialize,Serialize};
use std::fs;
#[derive(Serialize,Deserialize,Clone)]
pub struct Exists {
pub path: String
}
#[derive(Serialize,Deserialize,Clone)]
pub struct Contents {
pub file: String,
pub regex: String
}
#[derive(Serialize,Deserialize,Clone)]
pub struct Script {
pub command: String,
pub allow_fail: Option<bool>
}
#[derive(Serialize,Deserialize,Clone)]
pub struct Detect {
pub exists: Option<Vec<Exists>>,
pub scripts: Option<Vec<Script>>
}
#[derive(Serialize,Deserialize,Clone)]
pub struct Remote {
pub url: String,
pub to: String
}
#[derive(Serialize,Deserialize,Clone)]
pub struct Local {
pub from: String,
pub to: String
}
#[derive(Serialize,Deserialize,Clone)]
pub struct BuildStep {
pub local: Option<Vec<Local>>,
pub remote: Option<Vec<Remote>>,
pub scripts: Option<Vec<Script>>
}
//Should these be optional?
#[derive(Serialize,Deserialize,Clone)]
pub struct Layer {
pub name: String,
pub cache: bool,
pub launch: bool,
pub build: bool
}
#[derive(Serialize,Deserialize,Clone)]
pub struct Env {
pub key: String,
pub default: String
}
#[derive(Serialize,Deserialize,Clone)]
pub struct Buildspec {
pub name: String,
pub layers: Vec<Layer>,
pub environment: Vec<Env>,
pub detect: Detect,
pub build: Vec<BuildStep>,
pub process: Option<String>
}
impl Buildspec {
pub fn read_specfile(args: &clap::ArgMatches) -> Self{
let specfile = args.value_of("specfile").unwrap();
println!("specfile: {}",specfile.clone());
let specfile_contents = fs::read_to_string(specfile).expect("Cannot Read File");
serde_json::from_str(&specfile_contents).unwrap()
}
}