Improve schema a bit, fix flake locks for examples

This commit is contained in:
notgne2 2020-10-05 20:10:41 -07:00
parent 1de1ad5ff8
commit aabcf6b77d
No known key found for this signature in database
GPG Key ID: BB661E172B42A7F8
5 changed files with 61 additions and 46 deletions

View File

@ -7,10 +7,12 @@
"utils": "utils"
},
"locked": {
"lastModified": 1601952388,
"narHash": "sha256-g5t4JNUl4xmKfKmzo5yzligVNTBHOTgw+vkuebP4B/Q=",
"type": "git",
"url": "file:///home/notgne2/Dev/Serokell/deploy-rs"
"lastModified": 1601952901,
"narHash": "sha256-6U0JIlh6GLqkxdyUiVRbph9k1lVCtWLno2uM/Fd/ZzI=",
"owner": "serokell",
"repo": "deploy-rs",
"rev": "1de1ad5ff893bfcabdf2bfa20d8c93a8cdbb0156",
"type": "github"
},
"original": {
"owner": "serokell",

View File

@ -7,10 +7,12 @@
"utils": "utils"
},
"locked": {
"lastModified": 1601668691,
"narHash": "sha256-HvzPMsgSOQfCRoPtkwLRv09CkNjOsLHjcZtyHF+8Zbs=",
"type": "git",
"url": "file:///home/notgne2/Dev/Serokell/deploy-rs"
"lastModified": 1601952901,
"narHash": "sha256-6U0JIlh6GLqkxdyUiVRbph9k1lVCtWLno2uM/Fd/ZzI=",
"owner": "serokell",
"repo": "deploy-rs",
"rev": "1de1ad5ff893bfcabdf2bfa20d8c93a8cdbb0156",
"type": "github"
},
"original": {
"owner": "serokell",

View File

@ -31,6 +31,29 @@
"properties": {
"hostname": {
"type": "string"
},
"profilesOrder": {
"type": "array",
"items": {
"type": "string"
},
"uniqueItems": true
},
"profiles": {
"type": "object",
"patternProperties": {
"[A-z][A-z0-9_-]*": {
"allOf": [
{
"$ref": "#/definitions/generic_settings"
},
{
"$ref": "#/definitions/profile_settings"
}
]
}
},
"additionalProperties": false
}
},
"required": [
@ -70,27 +93,6 @@
},
{
"$ref": "#/definitions/node_settings"
},
{
"type": "object",
"properties": {
"profiles": {
"type": "object",
"patternProperties": {
"[A-z][A-z0-9_-]*": {
"allOf": [
{
"$ref": "#/definitions/generic_settings"
},
{
"$ref": "#/definitions/profile_settings"
}
]
}
},
"additionalProperties": false
}
}
}
]
}

View File

@ -65,17 +65,22 @@ async fn push_all_profiles(
) -> Result<(), Box<dyn std::error::Error>> {
info!("Pushing all profiles for `{}`", node_name);
let mut profiles_list: Vec<&str> = node.profiles_order.iter().map(|x| x.as_ref()).collect();
let mut profiles_list: Vec<&str> = node
.node_settings
.profiles_order
.iter()
.map(|x| x.as_ref())
.collect();
// Add any profiles which weren't in the provided order list
for profile_name in node.profiles.keys() {
for profile_name in node.node_settings.profiles.keys() {
if !profiles_list.contains(&profile_name.as_str()) {
profiles_list.push(&profile_name);
}
}
for profile_name in profiles_list {
let profile = match node.profiles.get(profile_name) {
let profile = match node.node_settings.profiles.get(profile_name) {
Some(x) => x,
None => good_panic!("No profile was found named `{}`", profile_name),
};
@ -117,17 +122,22 @@ async fn deploy_all_profiles(
) -> Result<(), Box<dyn std::error::Error>> {
info!("Deploying all profiles for `{}`", node_name);
let mut profiles_list: Vec<&str> = node.profiles_order.iter().map(|x| x.as_ref()).collect();
let mut profiles_list: Vec<&str> = node
.node_settings
.profiles_order
.iter()
.map(|x| x.as_ref())
.collect();
// Add any profiles which weren't in the provided order list
for profile_name in node.profiles.keys() {
for profile_name in node.node_settings.profiles.keys() {
if !profiles_list.contains(&profile_name.as_str()) {
profiles_list.push(&profile_name);
}
}
for profile_name in profiles_list {
let profile = match node.profiles.get(profile_name) {
let profile = match node.node_settings.profiles.get(profile_name) {
Some(x) => x,
None => good_panic!("No profile was found named `{}`", profile_name),
};
@ -203,8 +213,8 @@ async fn get_deployment_data(
}
let build_output = build_command
.stdout(Stdio::null())
.stderr(Stdio::null())
// .stdout(Stdio::null())
// .stderr(Stdio::null())
.output()
.await?;
@ -233,7 +243,7 @@ async fn run_deploy(
Some(x) => x,
None => good_panic!("No node was found named `{}`", node_name),
};
let profile = match node.profiles.get(profile_name) {
let profile = match node.node_settings.profiles.get(profile_name) {
Some(x) => x,
None => good_panic!("No profile was found named `{}`", profile_name),
};

View File

@ -29,6 +29,13 @@ pub struct GenericSettings {
#[derive(Deserialize, Debug, Clone)]
pub struct NodeSettings {
pub hostname: String,
pub profiles: HashMap<String, Profile>,
#[serde(
skip_serializing_if = "Vec::is_empty",
default,
rename(deserialize = "profilesOrder")
)]
pub profiles_order: Vec<String>,
}
#[derive(Deserialize, Debug, Clone)]
@ -51,14 +58,6 @@ pub struct Node {
pub generic_settings: GenericSettings,
#[serde(flatten)]
pub node_settings: NodeSettings,
pub profiles: HashMap<String, Profile>,
#[serde(
skip_serializing_if = "Vec::is_empty",
default,
rename(deserialize = "profilesOrder")
)]
pub profiles_order: Vec<String>,
}
#[derive(Deserialize, Debug, Clone)]