Skip to content

Commit fadcdfe

Browse files
committed
Merge branch 'unstable' into stable
2 parents 4150832 + 0a1a1b5 commit fadcdfe

26 files changed

+163
-110
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@ All notable changes to this project will be documented in this file.
77
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
88
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
99

10+
## [1.5.0-1] - 2025-06-17
11+
12+
### Added
13+
14+
- You can choose in what format Deployer should `cat` your Actions, Pipelines or project configurations, by using `deployer cat ... -f json/toml/yaml`.
15+
16+
### Changed
17+
18+
- Small CI fixes with Rust `nightly-1.89.0` on GitHub.
19+
1020
## [1.5.0] - 2025-06-17
1121

1222
### Added

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "deployer"
3-
version = "1.5.0"
3+
version = "1.5.0-1"
44
edition = "2024"
55

66
[dependencies]

src/actions.rs

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
//!
33
//! Action is the main entity of Deployer. Actions as part of Pipelines are used to build, install, and deploy processes.
44
5+
#[cfg(feature = "tui")]
6+
use anyhow::bail;
57
#[cfg(feature = "tui")]
68
use colored::Colorize;
79
use serde::{Deserialize, Serialize};
@@ -28,7 +30,7 @@ use crate::actions::{
2830
test::TestAction,
2931
};
3032
#[cfg(feature = "tui")]
31-
use crate::cmd::{CatActionArgs, NewActionArgs};
33+
use crate::cmd::{CatActionArgs, EditActionArgs, NewActionArgs};
3234
#[cfg(feature = "tui")]
3335
use crate::configs::{DeployerGlobalConfig, DeployerProjectOptions};
3436
#[cfg(feature = "tui")]
@@ -274,7 +276,7 @@ pub fn list_actions(globals: &DeployerGlobalConfig) {
274276
for action in actions {
275277
let action_info = action.info.to_str();
276278
let action_title = if let Some(title) = &action.title {
277-
&format!("[{}]", title)
279+
&format!("[{title}]")
278280
} else {
279281
""
280282
};
@@ -313,7 +315,7 @@ pub fn remove_action(globals: &mut DeployerGlobalConfig) -> anyhow::Result<()> {
313315
action.info.to_str(),
314316
{
315317
if let Some(title) = &action.title {
316-
format!(" - `{}`", title)
318+
format!(" - `{title}`")
317319
} else {
318320
"".into()
319321
}
@@ -353,7 +355,7 @@ pub fn new_action(globals: &mut DeployerGlobalConfig, args: &NewActionArgs) -> a
353355
let ext = ConfigExtension::decide(&std::path::PathBuf::from(from_file))?;
354356
let action = read_checked::<DescribedAction>(from_file, ext)
355357
.map_err(|e| {
356-
panic!("Can't read provided Action file due to: {}", e);
358+
panic!("Can't read provided Action file due to: {e}");
357359
})
358360
.unwrap();
359361
actions.insert(action.info.clone(), action.clone());
@@ -365,7 +367,7 @@ pub fn new_action(globals: &mut DeployerGlobalConfig, args: &NewActionArgs) -> a
365367
Ok(described_action)
366368
}
367369

368-
/// Prints Action as JSON.
370+
/// Prints Action as JSON/TOML/YAML.
369371
#[cfg(feature = "tui")]
370372
pub fn cat_action(globals: &DeployerGlobalConfig, args: &CatActionArgs) -> anyhow::Result<()> {
371373
let action = match globals
@@ -376,15 +378,20 @@ pub fn cat_action(globals: &DeployerGlobalConfig, args: &CatActionArgs) -> anyho
376378
Some(action) => action,
377379
};
378380

379-
let action_json = serde_json::to_string_pretty(&action).unwrap();
380-
println!("{}", action_json);
381+
let action_ser = match args.format.as_deref() {
382+
Some("json") | None => serde_json::to_string_pretty(&action).unwrap(),
383+
Some("toml") => toml::to_string_pretty(&action).unwrap(),
384+
Some("yaml") | Some("yml") => serde_yaml::to_string_pretty(&action).unwrap(),
385+
_ => bail!("Unsupported output format!"),
386+
};
387+
println!("{action_ser}");
381388

382389
Ok(())
383390
}
384391

385392
/// Edits the Action.
386393
#[cfg(feature = "tui")]
387-
pub fn edit_action(globals: &mut DeployerGlobalConfig, args: &CatActionArgs) -> anyhow::Result<()> {
394+
pub fn edit_action(globals: &mut DeployerGlobalConfig, args: &EditActionArgs) -> anyhow::Result<()> {
388395
let described_action = match globals
389396
.actions_registry
390397
.get_mut(&args.action_short_info_and_version.to_info()?)

src/actions/observe.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,15 @@ impl Execute for ObserveAction {
4444
let (jrtx, jrrx) = mpsc::channel(1);
4545
let (jftx, mut jfrx) = mpsc::channel(1);
4646
if let Err(e) = cli.tx.send((jrrx, jftx)).await {
47-
crate::rw::log(format!("Can't send task exchange channels! Error: {:?}", e));
47+
crate::rw::log(format!("Can't send task exchange channels! Error: {e:?}"));
4848
return Ok((false, vec![]));
4949
}
5050

5151
let owned_env = OwnedEnvironment::new(env.run_dir);
5252
let observe = self.clone();
5353

5454
if let Err(e) = jrtx.send((observe, owned_env)).await {
55-
crate::rw::log(format!("Can't send `observe` task! Error: {:?}", e));
55+
crate::rw::log(format!("Can't send `observe` task! Error: {e:?}"));
5656
return Ok((false, vec![]));
5757
}
5858

src/actions/patch.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,7 @@ impl Execute for PatchAction {
4545
Ok(0) if self.ignore_fails.is_none_or(|v| !v) => Ok((false, vec![format!("{}", i18n::PATCH_DONE_ZERO_TIMES)])),
4646
Ok(num) => Ok((
4747
true,
48-
vec![format!(
49-
"{}",
50-
i18n::PATCH_DONE.replace("{}", format!("{}", num).as_str())
51-
)],
48+
vec![format!("{}", i18n::PATCH_DONE.replace("{}", format!("{num}").as_str()))],
5249
)),
5350
}
5451
}

src/ansible.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ pub async fn execute_pipeline_with_ansible(
167167
}
168168

169169
CustomCommand {
170-
bash_c: format!("ansible-playbook -i inventory.ini {}", playbook_filename),
170+
bash_c: format!("ansible-playbook -i inventory.ini {playbook_filename}"),
171171
..Default::default()
172172
}
173173
.execute_observer(env)

src/cmd.rs

Lines changed: 45 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -109,33 +109,24 @@ pub enum CatType {
109109
Remote(CatRemoteArgs),
110110
}
111111

112-
/// `Edit` types.
113-
#[derive(Subcommand)]
114-
pub enum EditType {
115-
/// Edits an Action
116-
Action(CatActionArgs),
117-
/// Edits a Pipeline
118-
Pipeline(CatPipelineArgs),
119-
/// Edits Project settings
120-
#[clap(visible_alias("."))]
121-
Project,
122-
/// Edits an information about remote hosts
123-
#[cfg(feature = "ssh-remotes")]
124-
Remote(CatRemoteArgs),
125-
}
126-
127112
/// Cat Actions' options.
128113
#[derive(Args)]
129114
pub struct CatActionArgs {
130115
/// {short-name}@{version}
131116
pub action_short_info_and_version: String,
117+
/// Output format (JSON by default)
118+
#[arg(short('f'), long)]
119+
pub format: Option<String>,
132120
}
133121

134122
/// Cat Pipelines' options.
135123
#[derive(Args)]
136124
pub struct CatPipelineArgs {
137125
/// {short-name}@{version}
138126
pub pipeline_short_info_and_version: String,
127+
/// Output format (JSON by default)
128+
#[arg(short('f'), long)]
129+
pub format: Option<String>,
139130
}
140131

141132
/// Cat Project' options.
@@ -144,6 +135,9 @@ pub struct CatProjectArgs {
144135
/// Prints all `bash` commands instead of JSON.
145136
#[arg(short('n'), long)]
146137
pub cat_all_shell_commands: bool,
138+
/// Output format (JSON by default)
139+
#[arg(short('f'), long)]
140+
pub format: Option<String>,
147141
}
148142

149143
/// Cat Remote' options.
@@ -153,6 +147,42 @@ pub struct CatRemoteArgs {
153147
pub remote_host_short_info: String,
154148
}
155149

150+
/// `Edit` types.
151+
#[derive(Subcommand)]
152+
pub enum EditType {
153+
/// Edits an Action
154+
Action(EditActionArgs),
155+
/// Edits a Pipeline
156+
Pipeline(EditPipelineArgs),
157+
/// Edits Project settings
158+
#[clap(visible_alias("."))]
159+
Project,
160+
/// Edits an information about remote hosts
161+
#[cfg(feature = "ssh-remotes")]
162+
Remote(EditRemoteArgs),
163+
}
164+
165+
/// Edit Actions' options.
166+
#[derive(Args)]
167+
pub struct EditActionArgs {
168+
/// {short-name}@{version}
169+
pub action_short_info_and_version: String,
170+
}
171+
172+
/// Edit Pipelines' options.
173+
#[derive(Args)]
174+
pub struct EditPipelineArgs {
175+
/// {short-name}@{version}
176+
pub pipeline_short_info_and_version: String,
177+
}
178+
179+
/// Edit Remote' options.
180+
#[derive(Args)]
181+
pub struct EditRemoteArgs {
182+
/// Remote host shortname.
183+
pub remote_host_short_info: String,
184+
}
185+
156186
/// `New` types.
157187
#[derive(Subcommand)]
158188
pub enum NewType {

src/containered.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ CMD ["/app/deployer", "run", "{pipeline-name}", "--current"{no-pipe}]
5252
async fn run_simple(env: &RunEnvironment<'_>, bash_c: String) -> anyhow::Result<()> {
5353
if !(CustomCommand {
5454
bash_c: {
55-
log(format!("Given command: `{}`", bash_c));
55+
log(format!("Given command: `{bash_c}`"));
5656
bash_c
5757
},
5858
ignore_fails: None,
@@ -132,10 +132,10 @@ pub fn generate_single_pipeline_config(
132132
}
133133

134134
let config_filepath = DEPL_CONFIG_FILE.replace("{pipeline-name}", pipeline.title.as_str());
135-
log(format!("Prev config on {:?}", config_filepath));
135+
log(format!("Prev config on {config_filepath:?}"));
136136
let prev_config = crate::rw::read::<DeployerProjectOptions>(env.run_dir, config_filepath.as_str());
137137
if prev_config != minimal_project_config {
138-
log(format!("Saving minimal pipeline config on {:?}", config_filepath));
138+
log(format!("Saving minimal pipeline config on {config_filepath:?}"));
139139
crate::rw::write(env.run_dir, config_filepath.as_str(), &minimal_project_config);
140140
fs::set_permissions(
141141
env.run_dir.join(config_filepath.as_str()),
@@ -215,7 +215,7 @@ pub fn generate_dockerfile(
215215
)
216216
.replace("{pipeline-name}", &pipeline.title)
217217
.replace("{no-pipe}", if env.no_pipe { r#", "--no-pipe""# } else { "" });
218-
let filepath = env.run_dir.join(format!("Dockerfile.{}", exclusive_exec_tag));
218+
let filepath = env.run_dir.join(format!("Dockerfile.{exclusive_exec_tag}"));
219219
let mut dockerfile = fs::File::options()
220220
.create(true)
221221
.write(true)
@@ -299,7 +299,7 @@ async fn check_and_pull_once(
299299
exit(1);
300300
}
301301
repls.base_from = opts.base_image.as_deref().unwrap_or(BASE_IMAGE).to_owned();
302-
repls.base_to = format!("{}_executor:latest", exclusive_exec_tag);
302+
repls.base_to = format!("{exclusive_exec_tag}_executor:latest");
303303
}
304304
if repls
305305
.depl_from
@@ -347,7 +347,7 @@ async fn check_and_pull_once(
347347
.as_deref()
348348
.unwrap_or(BASE_IMAGE)
349349
.to_owned();
350-
repls.depl_to = format!("{}_builder:latest", exclusive_exec_tag);
350+
repls.depl_to = format!("{exclusive_exec_tag}_builder:latest");
351351
}
352352
opts.base_image = Some(repls.base_to.to_owned());
353353
opts.build_deployer_base_image = Some(repls.depl_to.to_owned());
@@ -397,8 +397,7 @@ pub async fn execute_pipeline_containered(
397397
exclusive_exec_tag,
398398
if opts.use_containerd_local_storage_cache.is_some_and(|v| v) && is_docker(&opts) {
399399
format!(
400-
" --cache-to type=local,dest=.docker-cache/{},compression=zstd --cache-from type=local,src=.docker-cache/{}",
401-
exclusive_exec_tag, exclusive_exec_tag
400+
" --cache-to type=local,dest=.docker-cache/{exclusive_exec_tag},compression=zstd --cache-from type=local,src=.docker-cache/{exclusive_exec_tag}"
402401
)
403402
} else {
404403
String::from("")
@@ -436,7 +435,7 @@ pub async fn execute_pipeline_containered(
436435
if let Some(port_bindings) = opts.port_bindings {
437436
port_bindings
438437
.iter()
439-
.map(|PortBinding { from, to }| format!(" -p {}:{}", from, to))
438+
.map(|PortBinding { from, to }| format!(" -p {from}:{to}"))
440439
.collect::<Vec<_>>()
441440
.join("")
442441
} else {

src/entities/containered_opts.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ impl ContainerizedRunStrategy {
138138

139139
fn concat(&self, env: &RunEnvironment, config_filepath: &str) -> String {
140140
self.copy_cmds.join("\n")
141-
+ format!("\nCOPY {} deploy-config.yaml\n", config_filepath).as_str()
141+
+ format!("\nCOPY {config_filepath} deploy-config.yaml\n").as_str()
142142
+ self
143143
.pre_cache_cmds
144144
.iter()

src/entities/custom_command.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ impl Execute for CustomCommand {
164164
}
165165

166166
for bash_c in &cmds {
167-
let bash_c_info = format!(r#"{} -c "{}""#, shell, bash_c).green();
167+
let bash_c_info = format!(r#"{shell} -c "{bash_c}""#).green();
168168

169169
let mut cmd = async_process::Command::new(&shell);
170170
cmd.current_dir(env.run_dir).arg("-c").arg(bash_c);
@@ -181,10 +181,10 @@ impl Execute for CustomCommand {
181181

182182
if self.daemon.is_some_and(|v| v) {
183183
self.start_daemon(env, child).await?;
184-
if let Some(daemon_wait_seconds) = self.daemon_wait_seconds {
185-
if daemon_wait_seconds > 0 {
186-
std::thread::sleep(std::time::Duration::from_secs(daemon_wait_seconds));
187-
}
184+
if let Some(daemon_wait_seconds) = self.daemon_wait_seconds
185+
&& daemon_wait_seconds > 0
186+
{
187+
std::thread::sleep(std::time::Duration::from_secs(daemon_wait_seconds));
188188
}
189189
continue;
190190
}
@@ -345,7 +345,7 @@ impl CustomCommand {
345345

346346
let mut session = remote.open_session(&rt)?;
347347
for bash_c in &cmds {
348-
let bash_c_info = format!(r#"{} -c "{} && echo $?""#, shell, bash_c).green();
348+
let bash_c_info = format!(r#"{shell} -c "{bash_c} && echo $?""#).green();
349349
let (s, out) = remote.exec(bash_c, &mut session, &rt)?;
350350

351351
let mut composed = compose_output(
@@ -406,7 +406,7 @@ pub fn compose_output(
406406
if i == total && line.trim().is_empty() {
407407
break;
408408
}
409-
output.push(format!(">>> {}", line));
409+
output.push(format!(">>> {line}"));
410410
}
411411
}
412412
if !stderr.trim().is_empty() {
@@ -419,7 +419,7 @@ pub fn compose_output(
419419
if i == total && line.trim().is_empty() {
420420
break;
421421
}
422-
output.push(format!(">>> {}", line));
422+
output.push(format!(">>> {line}"));
423423
}
424424
}
425425

0 commit comments

Comments
 (0)