diff --git a/src/argo_cd.rs b/src/argo_cd.rs index c537f66..1eb2f51 100644 --- a/src/argo_cd.rs +++ b/src/argo_cd.rs @@ -40,8 +40,8 @@ impl ArgoCD { let app_name = self.argo_config.application.as_str(); let url = format!( - "{}/api/v1/applications/{name}/sync", - self.argo_config.base_url, + "{baseUrl}/api/v1/applications/{name}/sync", + baseUrl = self.argo_config.base_url, name = encode(app_name) ); @@ -127,7 +127,7 @@ impl ArgoCD { match argocd_token { Ok(token) => { debug!("Applying bearer token to ArgoCD request"); - request_builder.header("Authorization", format!("Bearer {}", token)) + request_builder.header("Authorization", format!("Bearer {token}")) } Err(_) => { warn!("You're accessing ArgoCD without authentication (missing {} environment variable)", ARGO_CD_TOKEN); @@ -145,8 +145,8 @@ impl ArgoCD { fn wait_for_status_change(&mut self, condition: fn(&Application) -> bool) { let url = format!( - "{}/api/v1/applications/{name}", - self.argo_config.base_url, + "{baseUrl}/api/v1/applications/{name}", + baseUrl = self.argo_config.base_url, name = encode(self.argo_config.application.as_str()) ); diff --git a/tests/rotate.rs b/tests/rotate.rs index a429e50..5818f98 100644 --- a/tests/rotate.rs +++ b/tests/rotate.rs @@ -54,7 +54,7 @@ async fn rotate_secrets() { let (argocd_port, stop_sender) = open_argocd_server_port_forward(&kubectl).await; - let argocd_url = format!("http://localhost:{}", argocd_port); + let argocd_url = format!("http://localhost:{argocd_port}"); let argocd_token = get_argocd_access_token(&kubectl, argocd_url.as_str()).await; create_argocd_application(argocd_url.as_str(), argocd_token.as_str()).await; @@ -160,7 +160,7 @@ async fn rotate_application_sync_timeout() { let (argocd_port, stop_sender) = open_argocd_server_port_forward(&kubectl).await; - let argocd_url = format!("http://localhost:{}", argocd_port); + let argocd_url = format!("http://localhost:{argocd_port}"); let argocd_token = get_argocd_access_token(&kubectl, argocd_url.as_str()).await; create_argocd_application(argocd_url.as_str(), argocd_token.as_str()).await; @@ -406,7 +406,7 @@ async fn create_argocd_application(argocd_url: &str, auth_token: &str) { .build() .expect("Failed to build custom http client for insecure ArgoCD connection"); - let url = format!("{}/api/v1/applications", argocd_url); + let url = format!("{argocd_url}/api/v1/applications"); let argocd_application = json!({ "metadata": { @@ -443,7 +443,7 @@ async fn create_argocd_application(argocd_url: &str, auth_token: &str) { loop { let response = insecure_client .post(&url) - .header("Authorization", format!("Bearer {}", auth_token)) + .header("Authorization", format!("Bearer {auth_token}")) .json(&argocd_application) .send() .await; @@ -498,7 +498,7 @@ async fn wait_for_argocd_application_rollout( let request = client .get(url.as_str()) - .header("Authorization", format!("Bearer {}", argocd_token)) + .header("Authorization", format!("Bearer {argocd_token}")) .build() .expect("Failed to build ArgoCD sync status request"); diff --git a/tests/utilities/src/lib.rs b/tests/utilities/src/lib.rs index 3497071..0d9ec18 100644 --- a/tests/utilities/src/lib.rs +++ b/tests/utilities/src/lib.rs @@ -100,7 +100,7 @@ pub async fn get_kube_client(container: &ContainerAsync) -> Client { .expect("Failed to read kube secure port"); config.clusters.iter_mut().for_each(|cluster| { if let Some(server) = cluster.cluster.as_mut().and_then(|c| c.server.as_mut()) { - *server = format!("https://127.0.0.1:{}", port) + *server = format!("https://127.0.0.1:{port}") } }); @@ -212,7 +212,7 @@ async fn create_namespace(kubectl: &Client, namespace_name: &str) { namespaces .create(&Default::default(), &argocd_namespace) .await - .expect(format!("Failed to create namespace '{}'", namespace_name).as_str()); + .expect(format!("Failed to create namespace '{namespace_name}'").as_str()); } fn create_singleton_btree(key: &str, value: &str) -> Option> { @@ -255,13 +255,7 @@ async fn await_pod_is_running(pods: &Api, label_filter: &str, timeout_durat await_condition(pods.clone(), pod_name.as_str(), is_pod_running()), ) .await - .expect( - format!( - "Timed out waiting for pod matching filter: {}", - label_filter - ) - .as_str(), - ); + .expect(format!("Timed out waiting for pod matching filter: {label_filter}",).as_str()); } async fn get_pod_name_matching_label_filter(pods: &Api, label_filter: &str) -> String { @@ -371,7 +365,7 @@ pub async fn get_argocd_access_token(kubectl: &Client, argocd_url: &str) -> Stri .build() .expect("Failed to build custom http client for insecure ArgoCD connection"); - let url = format!("{}/api/v1/session", argocd_url); + let url = format!("{argocd_url}/api/v1/session"); let authentication_information = json!({ "username": "admin", "password": password @@ -402,7 +396,7 @@ pub async fn get_argocd_access_token(kubectl: &Client, argocd_url: &str) -> Stri pub fn create_vault_client(vault_host: &str, vault_port: u16) -> VaultClient { VaultClient::new( VaultClientSettingsBuilder::default() - .address(format!("http://{}:{}", vault_host, vault_port)) + .address(format!("http://{vault_host}:{vault_port}")) .token("root-token") .build() .expect("Failed to build vault client settings"), @@ -431,7 +425,7 @@ pub async fn read_vault_secret(vault_client: &VaultClient, secret_path: &str) -> pub fn write_string_to_tempfile(content: &str) -> String { let mut dir = temp_dir(); - let filename = format!("temp_file_{}", random::()); + let filename = format!("temp_file_{suffix}", suffix = random::()); dir.push(filename);