Skip to content

Commit

Permalink
feat: apply sat command now translates git branches to commit id when
Browse files Browse the repository at this point in the history
creating CFS configurations
  • Loading branch information
Manuel Sopena Ballesteros committed Aug 21, 2024
1 parent e9e9fb9 commit a13a551
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 10 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ publish = false # cargo
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
# mesa = "0.40.11"
mesa = { path = "../mesa" } # Only for development purposes
mesa = "0.40.12"
# mesa = { path = "../mesa" } # Only for development purposes
strum = "0.25.0"
strum_macros = "0.25"
chrono = "0.4.31"
Expand Down
2 changes: 1 addition & 1 deletion src/cli/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ pub fn build_cli(hsm_group: Option<&String>) -> Command {
.subcommand(Command::new("stop-running-session")
.visible_alias("srs")
.arg_required_else_help(true)
.about("Stops a session")
.about("WIP - Stops a session")
.arg(arg!(<SESSION_NAME> "Session name to stop").required(true))
)
}
Expand Down
2 changes: 2 additions & 0 deletions src/cli/commands/apply_cluster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ pub async fn exec(
hsm_group_available_vec: &Vec<String>,
ansible_verbosity_opt: Option<u8>,
ansible_passthrough_opt: Option<&String>,
gitea_base_url: &str,
gitea_token: &str,
// tag: &str,
do_not_reboot: bool,
Expand All @@ -35,6 +36,7 @@ pub async fn exec(
hsm_group_available_vec,
ansible_verbosity_opt,
ansible_passthrough_opt,
gitea_base_url,
gitea_token,
do_not_reboot,
None,
Expand Down
2 changes: 2 additions & 0 deletions src/cli/commands/apply_configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ pub async fn exec(
vault_secret_path: &str,
vault_role_id: &str,
k8s_api_url: &str,
gitea_base_url: &str,
gitea_token: &str,
// tag: &str,
output_opt: Option<&String>,
Expand Down Expand Up @@ -100,6 +101,7 @@ pub async fn exec(
shasta_token,
shasta_base_url,
shasta_root_cert,
gitea_base_url,
gitea_token,
&cray_product_catalog,
configuration_yaml,
Expand Down
2 changes: 2 additions & 0 deletions src/cli/commands/apply_image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ pub async fn exec(
// tag: &str,
hsm_group_available_vec: &[String],
k8s_api_url: &str,
gitea_base_url: &str,
gitea_token: &str,
_output_opt: Option<&String>,
) {
Expand Down Expand Up @@ -152,6 +153,7 @@ pub async fn exec(
shasta_token,
shasta_base_url,
shasta_root_cert,
gitea_base_url,
gitea_token,
&cray_product_catalog,
configuration_yaml,
Expand Down
7 changes: 4 additions & 3 deletions src/cli/commands/apply_sat_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@ use crate::{
common::{
self,
sat_file::{
self, import_images_section_in_sat_file,
sessiontemplate::{Image, ImsDetails},
validate_sat_file_configurations_section, validate_sat_file_images_section, SatFile,
self, import_images_section_in_sat_file, validate_sat_file_configurations_section,
validate_sat_file_images_section, SatFile,
},
},
};
Expand All @@ -50,6 +49,7 @@ pub async fn exec(
hsm_group_available_vec: &Vec<String>,
ansible_verbosity_opt: Option<u8>,
ansible_passthrough_opt: Option<&String>,
gitea_base_url: &str,
gitea_token: &str,
do_not_reboot: bool,
prehook: Option<&String>,
Expand Down Expand Up @@ -318,6 +318,7 @@ pub async fn exec(
shasta_token,
shasta_base_url,
shasta_root_cert,
gitea_base_url,
gitea_token,
&cray_product_catalog,
configuration_yaml,
Expand Down
4 changes: 4 additions & 0 deletions src/cli/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1061,6 +1061,7 @@ pub async fn process_cli(
vault_secret_path,
vault_role_id,
k8s_api_url,
gitea_base_url,
gitea_token,
// &tag,
cli_apply_configuration.get_one::<String>("output"),
Expand Down Expand Up @@ -1188,6 +1189,7 @@ pub async fn process_cli(
// &tag,
&hsm_group_available_vec,
k8s_api_url,
gitea_base_url,
gitea_token,
cli_apply_image.get_one::<String>("output"),
)
Expand Down Expand Up @@ -1246,6 +1248,7 @@ pub async fn process_cli(
.cloned()
.map(|ansible_verbosity| ansible_verbosity.parse::<u8>().unwrap()),
cli_apply_cluster.get_one::<String>("ansible-passthrough"),
gitea_base_url,
gitea_token,
// &tag,
*cli_apply_cluster
Expand Down Expand Up @@ -1327,6 +1330,7 @@ pub async fn process_cli(
.cloned()
.map(|ansible_verbosity| ansible_verbosity.parse::<u8>().unwrap()),
ansible_passthrough.as_ref(),
gitea_base_url,
gitea_token,
cli_apply_sat_file.get_flag("do-not-reboot"),
prehook,
Expand Down
14 changes: 10 additions & 4 deletions src/common/sat_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ impl SatFile {
.as_mut()
.unwrap_or(&mut Vec::new())
.retain(|image| image_name_sessiontemplate_vec.contains(&image.name));

if self.images.as_ref().is_some_and(|images| images.is_empty()) {
self.images = None;
}
}
}
}
Expand Down Expand Up @@ -325,10 +329,6 @@ pub mod configuration {
#[derive(Deserialize, Serialize, Debug)]
#[serde(untagged)] // <-- this is important. More info https://serde.rs/enum-representations.html#untagged
pub enum Product {
ProductVersion {
name: String,
version: String,
},
ProductVersionBranch {
name: String,
version: Option<String>,
Expand All @@ -339,6 +339,10 @@ pub mod configuration {
version: Option<String>,
commit: String,
},
ProductVersion {
name: String,
version: String,
},
}

#[derive(Deserialize, Serialize, Debug)]
Expand Down Expand Up @@ -618,6 +622,7 @@ pub async fn create_cfs_configuration_from_sat_file(
shasta_token: &str,
shasta_base_url: &str,
shasta_root_cert: &[u8],
gitea_base_url: &str,
gitea_token: &str,
cray_product_catalog: &BTreeMap<String, String>,
sat_file_configuration_yaml: &serde_yaml::Value,
Expand All @@ -630,6 +635,7 @@ pub async fn create_cfs_configuration_from_sat_file(

let mut cfs_configuration = CfsConfigurationRequest::from_sat_file_serde_yaml(
shasta_root_cert,
gitea_base_url,
gitea_token,
sat_file_configuration_yaml,
cray_product_catalog,
Expand Down

0 comments on commit a13a551

Please sign in to comment.