Skip to content

Commit 847f9aa

Browse files
committed
refactor: rename structs in container and secrets to avoid conflicts
1 parent 8e4c49a commit 847f9aa

File tree

3 files changed

+44
-44
lines changed

3 files changed

+44
-44
lines changed

crates/tracel-xtask-macros/src/lib.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -674,21 +674,21 @@ fn get_subcommand_variant_map() -> HashMap<&'static str, proc_macro2::TokenStrea
674674
"ContainerSubCommand",
675675
quote! {
676676
#[doc = r"Build a container."]
677-
Build(BuildSubCmdArgs),
677+
Build(ContainerBuildSubCmdArgs),
678678
#[doc = r"Show current latest and rollback images in registry."]
679-
List(ListSubCmdArgs),
679+
List(ContainerListSubCmdArgs),
680680
#[doc = r"Pull a container from a registry."]
681-
Pull(PullSubCmdArgs),
681+
Pull(ContainerPullSubCmdArgs),
682682
#[doc = r"Push a container to a registry."]
683-
Push(PushSubCmdArgs),
683+
Push(ContainerPushSubCmdArgs),
684684
#[doc = r"Promote a pushed container to latest."]
685-
Promote(PromoteSubCmdArgs),
685+
Promote(ContainerPromoteSubCmdArgs),
686686
#[doc = r"Rollback previously released container to latest."]
687-
Rollback(RollbackSubCmdArgs),
687+
Rollback(ContainerRollbackSubCmdArgs),
688688
#[doc = r"Rollout last promoted container."]
689-
Rollout(RolloutSubCmdArgs),
689+
Rollout(ContainerRolloutSubCmdArgs),
690690
#[doc = r"Run a local container."]
691-
Run(RunSubCmdArgs),
691+
Run(ContainerRunSubCmdArgs),
692692
},
693693
),
694694
(
@@ -753,11 +753,11 @@ fn get_subcommand_variant_map() -> HashMap<&'static str, proc_macro2::TokenStrea
753753
"SecretsSubCommand",
754754
quote! {
755755
#[doc = r"Fetch latest version of a secret and open the default editor to edit it."]
756-
Edit(EditSubCmdArgs),
756+
Edit(SecretsEditSubCmdArgs),
757757
#[doc = r"Fetch the secrets and write an environment file to a specified path."]
758-
EnvFile(EnvFileSubCmdArgs),
758+
EnvFile(SecretsEnvFileSubCmdArgs),
759759
#[doc = r"Show the latest version of a secret."]
760-
View(ViewSubCmdArgs),
760+
View(SecretsViewSubCmdArgs),
761761
},
762762
),
763763
(

crates/tracel-xtask/src/commands/container.rs

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
/// Current implementation uses `docker` and `AWS ECR` as container registry.
33
use std::path::PathBuf;
44

5-
use crate::prelude::*;
65
use crate::prelude::anyhow::Context as _;
6+
use crate::prelude::*;
77
use crate::utils::aws_cli::{
88
aws_account_id, ec2_autoscaling_latest_instance_refresh_status,
99
ec2_autoscaling_start_instance_refresh, ecr_compute_next_numeric_tag, ecr_docker_login,
@@ -18,12 +18,12 @@ pub struct ContainerCmdArgs {}
1818

1919
impl Default for ContainerSubCommand {
2020
fn default() -> Self {
21-
ContainerSubCommand::Build(BuildSubCmdArgs::default())
21+
ContainerSubCommand::Build(ContainerBuildSubCmdArgs::default())
2222
}
2323
}
2424

2525
#[derive(clap::Args, Default, Clone, PartialEq)]
26-
pub struct BuildSubCmdArgs {
26+
pub struct ContainerBuildSubCmdArgs {
2727
/// Path to build file relative to context directory (i.e. a Dockerfile)
2828
pub build_file: PathBuf,
2929
/// Build context directory (default to repository root)
@@ -41,7 +41,7 @@ pub struct BuildSubCmdArgs {
4141
}
4242

4343
#[derive(clap::Args, Default, Clone, PartialEq)]
44-
pub struct ListSubCmdArgs {
44+
pub struct ContainerListSubCmdArgs {
4545
/// Region where the container repository lives
4646
#[arg(long)]
4747
pub region: String,
@@ -51,7 +51,7 @@ pub struct ListSubCmdArgs {
5151
}
5252

5353
#[derive(clap::Args, Default, Clone, PartialEq)]
54-
pub struct PullSubCmdArgs {
54+
pub struct ContainerPullSubCmdArgs {
5555
/// Region where the container repository lives
5656
#[arg(long)]
5757
pub region: String,
@@ -67,7 +67,7 @@ pub struct PullSubCmdArgs {
6767
}
6868

6969
#[derive(clap::Args, Default, Clone, PartialEq)]
70-
pub struct PushSubCmdArgs {
70+
pub struct ContainerPushSubCmdArgs {
7171
/// Local image name (the one used in the build command)
7272
#[arg(long)]
7373
pub image: String,
@@ -89,7 +89,7 @@ pub struct PushSubCmdArgs {
8989
}
9090

9191
#[derive(clap::Args, Default, Clone, PartialEq)]
92-
pub struct PromoteSubCmdArgs {
92+
pub struct ContainerPromoteSubCmdArgs {
9393
/// Region where the container repository lives
9494
#[arg(long)]
9595
pub region: String,
@@ -102,7 +102,7 @@ pub struct PromoteSubCmdArgs {
102102
}
103103

104104
#[derive(clap::Args, Clone, PartialEq, Debug)]
105-
pub struct RolloutSubCmdArgs {
105+
pub struct ContainerRolloutSubCmdArgs {
106106
/// Region of the Auto Scaling Group
107107
#[arg(long)]
108108
pub region: String,
@@ -112,36 +112,36 @@ pub struct RolloutSubCmdArgs {
112112
pub asg: String,
113113

114114
/// Strategy for instance refresh (Rolling is the standard choice for zero-downtime rollouts)
115-
#[arg(long, value_name = "Rolling", default_value_t = RolloutSubCmdArgs::default().strategy)]
115+
#[arg(long, value_name = "Rolling", default_value_t = ContainerRolloutSubCmdArgs::default().strategy)]
116116
pub strategy: String,
117117

118118
/// Seconds for instance warmup
119-
#[arg(long, value_name = "SECS", default_value_t = RolloutSubCmdArgs::default().instance_warmup)]
119+
#[arg(long, value_name = "SECS", default_value_t = ContainerRolloutSubCmdArgs::default().instance_warmup)]
120120
pub instance_warmup: u64,
121121

122122
/// Minimum healthy percentage during the rollout
123-
#[arg(long, value_name = "PCT", default_value_t = RolloutSubCmdArgs::default().min_healthy_percentage)]
123+
#[arg(long, value_name = "PCT", default_value_t = ContainerRolloutSubCmdArgs::default().min_healthy_percentage)]
124124
pub min_healthy_percentage: u8,
125125

126126
/// If set, skip replacing instances that already match the launch template/config
127-
#[arg(long, default_value_t = RolloutSubCmdArgs::default().skip_matching)]
127+
#[arg(long, default_value_t = ContainerRolloutSubCmdArgs::default().skip_matching)]
128128
pub skip_matching: bool,
129129

130130
/// Wait until the refresh completes
131-
#[arg(long, default_value_t = RolloutSubCmdArgs::default().wait)]
131+
#[arg(long, default_value_t = ContainerRolloutSubCmdArgs::default().wait)]
132132
pub wait: bool,
133133

134134
/// Max seconds to wait when --wait is set
135-
#[arg(long, default_value_t = RolloutSubCmdArgs::default().wait_timeout_secs)]
135+
#[arg(long, default_value_t = ContainerRolloutSubCmdArgs::default().wait_timeout_secs)]
136136
pub wait_timeout_secs: u64,
137137

138138
/// Poll interval seconds when --wait is set
139-
#[arg(long, default_value_t = RolloutSubCmdArgs::default().wait_poll_secs)]
139+
#[arg(long, default_value_t = ContainerRolloutSubCmdArgs::default().wait_poll_secs)]
140140
pub wait_poll_secs: u64,
141141
}
142142

143143
#[derive(clap::Args, Default, Clone, PartialEq)]
144-
pub struct RunSubCmdArgs {
144+
pub struct ContainerRunSubCmdArgs {
145145
/// Fully qualified image reference (e.g. 123.dkr.ecr.us-east-1.amazonaws.com/bc-backend:latest)
146146
#[arg(long)]
147147
pub image: String,
@@ -163,7 +163,7 @@ pub struct RunSubCmdArgs {
163163
pub extra_arg: Vec<String>,
164164
}
165165

166-
impl Default for RolloutSubCmdArgs {
166+
impl Default for ContainerRolloutSubCmdArgs {
167167
fn default() -> Self {
168168
Self {
169169
region: String::new(),
@@ -180,7 +180,7 @@ impl Default for RolloutSubCmdArgs {
180180
}
181181

182182
#[derive(clap::Args, Default, Clone, PartialEq)]
183-
pub struct RollbackSubCmdArgs {
183+
pub struct ContainerRollbackSubCmdArgs {
184184
/// Region where the container repository lives
185185
#[arg(long)]
186186
pub region: String,
@@ -206,7 +206,7 @@ pub fn handle_command(
206206
}
207207
}
208208

209-
fn build(build_args: BuildSubCmdArgs) -> anyhow::Result<()> {
209+
fn build(build_args: ContainerBuildSubCmdArgs) -> anyhow::Result<()> {
210210
let context_dir = build_args.context_dir.unwrap_or(git_repo_root_or_cwd()?);
211211
let build_file_path = if build_args.build_file.is_absolute() {
212212
build_args.build_file.clone()
@@ -230,7 +230,7 @@ fn build(build_args: BuildSubCmdArgs) -> anyhow::Result<()> {
230230
docker_cli(args, None, None, "docker build failed")
231231
}
232232

233-
fn list(list_args: ListSubCmdArgs) -> anyhow::Result<()> {
233+
fn list(list_args: ContainerListSubCmdArgs) -> anyhow::Result<()> {
234234
let ecr_repository = &list_args.repository;
235235
let latest_present = ecr_get_manifest(ecr_repository, &list_args.region, "latest")?.is_some();
236236
let rollback_present =
@@ -281,7 +281,7 @@ fn list(list_args: ListSubCmdArgs) -> anyhow::Result<()> {
281281
Ok(())
282282
}
283283

284-
fn pull(args: PullSubCmdArgs) -> anyhow::Result<()> {
284+
fn pull(args: ContainerPullSubCmdArgs) -> anyhow::Result<()> {
285285
let account_id = aws_account_id()?;
286286
eprintln!(
287287
"📥 Pulling image from ECR\n Account: {account_id}\n Region: {}\n Repo: {}\n Tag: {}",
@@ -308,7 +308,7 @@ fn pull(args: PullSubCmdArgs) -> anyhow::Result<()> {
308308
Ok(())
309309
}
310310

311-
fn push(push_args: PushSubCmdArgs) -> anyhow::Result<()> {
311+
fn push(push_args: ContainerPushSubCmdArgs) -> anyhow::Result<()> {
312312
ecr_ensure_repo_exists(&push_args.repository, &push_args.region)?;
313313
// check if the container as already been pushed
314314
if let Some(existing_manifest) = ecr_get_manifest(
@@ -407,7 +407,7 @@ fn push(push_args: PushSubCmdArgs) -> anyhow::Result<()> {
407407
}
408408

409409
/// promote: point N to `latest` and move the previous `latest` to `rollback`
410-
fn promote(promote_args: PromoteSubCmdArgs) -> anyhow::Result<()> {
410+
fn promote(promote_args: ContainerPromoteSubCmdArgs) -> anyhow::Result<()> {
411411
// Fetch current 'latest' and the target tag's manifest.
412412
let prev_latest_manifest =
413413
ecr_get_manifest(&promote_args.repository, &promote_args.region, "latest")
@@ -462,7 +462,7 @@ fn promote(promote_args: PromoteSubCmdArgs) -> anyhow::Result<()> {
462462
}
463463

464464
/// rollback: promote 'rollback' to 'latest' and then remove the 'rollback' tag
465-
fn rollback(rollback_args: RollbackSubCmdArgs) -> anyhow::Result<()> {
465+
fn rollback(rollback_args: ContainerRollbackSubCmdArgs) -> anyhow::Result<()> {
466466
use anyhow::Context;
467467
// Fetch the manifest of the 'rollback' tag
468468
let rb = ecr_get_manifest(&rollback_args.repository, &rollback_args.region, "rollback")?
@@ -508,7 +508,7 @@ fn rollback(rollback_args: RollbackSubCmdArgs) -> anyhow::Result<()> {
508508
}
509509

510510
/// rollout: rollout latest promoted container
511-
fn rollout(args: RolloutSubCmdArgs) -> anyhow::Result<()> {
511+
fn rollout(args: ContainerRolloutSubCmdArgs) -> anyhow::Result<()> {
512512
use anyhow::Context;
513513
use std::{
514514
io::{self, Write},
@@ -607,7 +607,7 @@ fn rollout(args: RolloutSubCmdArgs) -> anyhow::Result<()> {
607607
Ok(())
608608
}
609609

610-
fn run(args: RunSubCmdArgs) -> anyhow::Result<()> {
610+
fn run(args: ContainerRunSubCmdArgs) -> anyhow::Result<()> {
611611
let mut cli_args: Vec<String> = vec!["run".into(), "--rm".into()];
612612

613613
if let Some(ref name) = args.name {

crates/tracel-xtask/src/commands/secrets.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ pub struct SecretsCmdArgs {}
1717

1818
impl Default for SecretsSubCommand {
1919
fn default() -> Self {
20-
SecretsSubCommand::View(ViewSubCmdArgs::default())
20+
SecretsSubCommand::View(SecretsViewSubCmdArgs::default())
2121
}
2222
}
2323

2424
#[derive(clap::Args, Default, Clone, PartialEq)]
25-
pub struct EditSubCmdArgs {
25+
pub struct SecretsEditSubCmdArgs {
2626
/// Region where the secret lives
2727
#[arg(long)]
2828
pub region: String,
@@ -33,7 +33,7 @@ pub struct EditSubCmdArgs {
3333
}
3434

3535
#[derive(clap::Args, Default, Clone, PartialEq)]
36-
pub struct EnvFileSubCmdArgs {
36+
pub struct SecretsEnvFileSubCmdArgs {
3737
/// Output file path. If omitted, writes to stdout.
3838
#[arg(long)]
3939
pub output: Option<std::path::PathBuf>,
@@ -48,7 +48,7 @@ pub struct EnvFileSubCmdArgs {
4848
}
4949

5050
#[derive(clap::Args, Default, Clone, PartialEq)]
51-
pub struct ViewSubCmdArgs {
51+
pub struct SecretsViewSubCmdArgs {
5252
/// Region where the secret lives
5353
#[arg(long)]
5454
pub region: String,
@@ -71,15 +71,15 @@ pub fn handle_command(
7171
}
7272

7373
/// `view` subcommand: fetch and print the secret.
74-
fn view(args: ViewSubCmdArgs) -> anyhow::Result<()> {
74+
fn view(args: SecretsViewSubCmdArgs) -> anyhow::Result<()> {
7575
let value = secretsmanager_get_secret_string(&args.secret_id, &args.region)?;
7676
println!("{value}");
7777
Ok(())
7878
}
7979

8080
/// Fetch secret into a temp file, open editor,
8181
/// ask to commit or discard on close and then push a new version if confirmed.
82-
fn edit(args: EditSubCmdArgs) -> anyhow::Result<()> {
82+
fn edit(args: SecretsEditSubCmdArgs) -> anyhow::Result<()> {
8383
// 1) fetch current secret value
8484
let original = secretsmanager_get_secret_string(&args.secret_id, &args.region)?;
8585
// 2) create temp file path
@@ -138,7 +138,7 @@ fn edit(args: EditSubCmdArgs) -> anyhow::Result<()> {
138138
Ok(())
139139
}
140140

141-
fn env_file(args: EnvFileSubCmdArgs) -> anyhow::Result<()> {
141+
fn env_file(args: SecretsEnvFileSubCmdArgs) -> anyhow::Result<()> {
142142
if args.secret_ids.is_empty() {
143143
eprintln!("No secrets provided.");
144144
return Ok(());

0 commit comments

Comments
 (0)