-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate_deployment.rs
75 lines (67 loc) · 2.14 KB
/
create_deployment.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
extern crate dotenv;
extern crate hop;
extern crate rand;
use std::collections::HashMap;
use std::env;
use dotenv::dotenv;
use rand::Rng;
use hop::Hop;
use hop::types::ignite::{CreateDeploymentConfig, Image, Resources, RestartPolicy, RuntimeType, UpdateDeploymentConfig, VolumeDefinition, VolumeFormat};
#[tokio::main]
async fn main() {
dotenv().ok();
// let my_token = "ptk_xxx";
let my_token = env::var("PROJECT_TOKEN").expect("PROJECT_TOKEN needed!");
let hop = Hop::new(my_token.as_str());
// Example: Creating a deployment
let deployment = hop.ignite.create_deployment(
CreateDeploymentConfig::new(
"postgres",
RuntimeType::Stateful,
"2022-12-28",
None,
Image::new(
Some("postgres"),
None,
None,
),
Some(HashMap::from([
("POSTGRES_PASSWORD", "password")
])),
Resources::new(
1f64,
"1GB",
None,
),
RestartPolicy::Never,
Some(VolumeDefinition {
fs: VolumeFormat::EXT4,
size: "1GB".to_string(),
mountpath: "/lol".to_string(),
}),
None,
),
).await.unwrap();
println!("deployment: {:#?}", deployment);
// let updated_deployment = hop.ignite.update_deployment(
// deployment.id.as_str(),
// // TODO: fix this
// // if None values are removed from the sent config, they won't actually update the config
// // if None values are kept in the sent config, they will be updated to None
// UpdateDeploymentConfig {
// name: None,
// container_strategy: None,
// runtime_type: None,
// version: None,
// cmd: None,
// image: None,
// env: None,
// resources: None,
// restart_policy: None,
// volume: None,
// entrypoint: None,
// }
// ).await.unwrap();
//
// println!("updated_deployment: {:#?}", updated_deployment);
}