Skip to content

Commit a40cb41

Browse files
committed
feat: new gcp_secrets base command
1 parent fe80a35 commit a40cb41

7 files changed

Lines changed: 1268 additions & 102 deletions

File tree

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

Lines changed: 86 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,22 @@ pub fn base_commands(args: TokenStream, input: TokenStream) -> TokenStream {
195195

196196
// Supported commands and their quoted expansions
197197
let mut variant_map: HashMap<&str, proc_macro2::TokenStream> = HashMap::new();
198+
variant_map.insert(
199+
"AwsContainer",
200+
quote! {
201+
#[command(alias = "container")]
202+
#[doc = r"Manage AWS containers lifecycle, from build to deployment."]
203+
AwsContainer(tracel_xtask::commands::aws_container::AwsContainerCmdArgs)
204+
},
205+
);
206+
variant_map.insert(
207+
"AwsSecrets",
208+
quote! {
209+
#[command(alias = "secrets")]
210+
#[doc = r"Manage secrets through AWS secrets manager."]
211+
AwsSecrets(tracel_xtask::commands::aws_secrets::AwsSecretsCmdArgs)
212+
},
213+
);
198214
variant_map.insert(
199215
"Build",
200216
quote! {
@@ -230,14 +246,6 @@ pub fn base_commands(args: TokenStream, input: TokenStream) -> TokenStream {
230246
Compile(tracel_xtask::commands::compile::CompileCmdArgs)
231247
},
232248
);
233-
variant_map.insert(
234-
"AwsContainer",
235-
quote! {
236-
#[command(alias = "container")]
237-
#[doc = r"Manage AWS containers lifecycle, from build to deployment."]
238-
AwsContainer(tracel_xtask::commands::aws_container::AwsContainerCmdArgs)
239-
},
240-
);
241249
variant_map.insert(
242250
"Coverage",
243251
quote! {
@@ -280,6 +288,13 @@ pub fn base_commands(args: TokenStream, input: TokenStream) -> TokenStream {
280288
GcpContainer(tracel_xtask::commands::gcp_container::GcpContainerCmdArgs)
281289
},
282290
);
291+
variant_map.insert(
292+
"GcpSecrets",
293+
quote! {
294+
#[doc = r"Manage secrets through GCP secrets manager."]
295+
GcpSecrets(tracel_xtask::commands::gcp_secrets::GcpSecretsCmdArgs)
296+
},
297+
);
283298
variant_map.insert(
284299
"Host",
285300
quote! {
@@ -308,13 +323,6 @@ pub fn base_commands(args: TokenStream, input: TokenStream) -> TokenStream {
308323
Publish(tracel_xtask::commands::publish::PublishCmdArgs)
309324
},
310325
);
311-
variant_map.insert(
312-
"Secrets",
313-
quote! {
314-
#[doc = r"Manage secrets."]
315-
Secrets(tracel_xtask::commands::secrets::SecretsCmdArgs)
316-
},
317-
);
318326
variant_map.insert(
319327
"Test",
320328
quote! {
@@ -934,6 +942,50 @@ pub fn extend_command_args(args: TokenStream, input: TokenStream) -> TokenStream
934942

935943
fn get_subcommand_variant_map() -> HashMap<&'static str, proc_macro2::TokenStream> {
936944
HashMap::from([
945+
(
946+
"AwsContainerSubCommand",
947+
quote! {
948+
#[doc = r"Build a container."]
949+
Build(AwsContainerBuildSubCmdArgs),
950+
#[doc = r"Start a terminal session on a container host instance."]
951+
Host(AwsContainerHostSubCmdArgs),
952+
#[doc = r"Show current latest and rollback images in registry."]
953+
List(AwsContainerListSubCmdArgs),
954+
#[doc = r"Show Cloudwatch logs of the container."]
955+
Logs(AwsContainerLogsSubCmdArgs),
956+
#[doc = r"Pull a container from a registry."]
957+
Pull(AwsContainerPullSubCmdArgs),
958+
#[doc = r"Push a container to a registry."]
959+
Push(AwsContainerPushSubCmdArgs),
960+
#[doc = r"Promote a pushed container to latest."]
961+
Promote(AwsContainerPromoteSubCmdArgs),
962+
#[doc = r"Rollback previously released container to latest."]
963+
Rollback(AwsContainerRollbackSubCmdArgs),
964+
#[doc = r"Rollout last promoted container."]
965+
Rollout(AwsContainerRolloutSubCmdArgs),
966+
#[doc = r"Run a local container."]
967+
Run(AwsContainerRunSubCmdArgs),
968+
},
969+
),
970+
(
971+
"AwsSecretsSubCommand",
972+
quote! {
973+
#[doc = r"Create an empty secret (metadata only, no version)."]
974+
Create(AwsSecretsCreateSubCmdArgs),
975+
#[doc = r"Copy a secret value from one secret ID to another in the same region."]
976+
Copy(AwsSecretsCopySubCmdArgs),
977+
#[doc = r"Fetch latest version of a secret and open the default editor to edit it."]
978+
Edit(AwsSecretsEditSubCmdArgs),
979+
#[doc = r"Fetch the secrets and write an environment file to a specified path."]
980+
EnvFile(AwsSecretsEnvFileSubCmdArgs),
981+
#[doc = r"List all versions of a secret."]
982+
List(AwsSecretsListSubCmdArgs),
983+
#[doc = r"Push new key-value pairs to existing secrets."]
984+
Push(AwsSecretsPushSubCmdArgs),
985+
#[doc = r"Show the latest version of a secret."]
986+
View(AwsSecretsViewSubCmdArgs),
987+
},
988+
),
937989
(
938990
"BumpSubCommand",
939991
quote! {
@@ -962,31 +1014,6 @@ fn get_subcommand_variant_map() -> HashMap<&'static str, proc_macro2::TokenStrea
9621014
Typos,
9631015
},
9641016
),
965-
(
966-
"AwsContainerSubCommand",
967-
quote! {
968-
#[doc = r"Build a container."]
969-
Build(AwsContainerBuildSubCmdArgs),
970-
#[doc = r"Start a terminal session on a container host instance."]
971-
Host(AwsContainerHostSubCmdArgs),
972-
#[doc = r"Show current latest and rollback images in registry."]
973-
List(AwsContainerListSubCmdArgs),
974-
#[doc = r"Show Cloudwatch logs of the container."]
975-
Logs(AwsContainerLogsSubCmdArgs),
976-
#[doc = r"Pull a container from a registry."]
977-
Pull(AwsContainerPullSubCmdArgs),
978-
#[doc = r"Push a container to a registry."]
979-
Push(AwsContainerPushSubCmdArgs),
980-
#[doc = r"Promote a pushed container to latest."]
981-
Promote(AwsContainerPromoteSubCmdArgs),
982-
#[doc = r"Rollback previously released container to latest."]
983-
Rollback(AwsContainerRollbackSubCmdArgs),
984-
#[doc = r"Rollout last promoted container."]
985-
Rollout(AwsContainerRolloutSubCmdArgs),
986-
#[doc = r"Run a local container."]
987-
Run(AwsContainerRunSubCmdArgs),
988-
},
989-
),
9901017
(
9911018
// note: default is manually implemented for this subcommand as the default variant is not a unit variant.
9921019
"CoverageSubCommand",
@@ -1070,6 +1097,25 @@ fn get_subcommand_variant_map() -> HashMap<&'static str, proc_macro2::TokenStrea
10701097
Run(GcpContainerRunSubCmdArgs),
10711098
},
10721099
),
1100+
(
1101+
"GcpSecretsSubCommand",
1102+
quote! {
1103+
#[doc = r"Create an empty secret (metadata only, no version)."]
1104+
Create(GcpSecretsCreateSubCmdArgs),
1105+
#[doc = r"Copy a secret value from one secret ID to another in the same region."]
1106+
Copy(GcpSecretsCopySubCmdArgs),
1107+
#[doc = r"Fetch latest version of a secret and open the default editor to edit it."]
1108+
Edit(GcpSecretsEditSubCmdArgs),
1109+
#[doc = r"Fetch the secrets and write an environment file to a specified path."]
1110+
EnvFile(GcpSecretsEnvFileSubCmdArgs),
1111+
#[doc = r"List all versions of a secret."]
1112+
List(GcpSecretsListSubCmdArgs),
1113+
#[doc = r"Push new key-value pairs to existing secrets."]
1114+
Push(GcpSecretsPushSubCmdArgs),
1115+
#[doc = r"Show the latest version of a secret."]
1116+
View(GcpSecretsViewSubCmdArgs),
1117+
},
1118+
),
10731119
(
10741120
"HostSubCommand",
10751121
quote! {
@@ -1124,25 +1170,6 @@ fn get_subcommand_variant_map() -> HashMap<&'static str, proc_macro2::TokenStrea
11241170
Update,
11251171
},
11261172
),
1127-
(
1128-
"SecretsSubCommand",
1129-
quote! {
1130-
#[doc = r"Create an empty secret (metadata only, no version)."]
1131-
Create(SecretsCreateSubCmdArgs),
1132-
#[doc = r"Copy a secret value from one secret ID to another in the same region."]
1133-
Copy(SecretsCopySubCmdArgs),
1134-
#[doc = r"Fetch latest version of a secret and open the default editor to edit it."]
1135-
Edit(SecretsEditSubCmdArgs),
1136-
#[doc = r"Fetch the secrets and write an environment file to a specified path."]
1137-
EnvFile(SecretsEnvFileSubCmdArgs),
1138-
#[doc = r"List all versions of a secret."]
1139-
List(SecretsListSubCmdArgs),
1140-
#[doc = r"Push new key-value pairs to existing secrets."]
1141-
Push(SecretsPushSubCmdArgs),
1142-
#[doc = r"Show the latest version of a secret."]
1143-
View(SecretsViewSubCmdArgs),
1144-
},
1145-
),
11461173
(
11471174
"TestSubCommand",
11481175
quote! {

0 commit comments

Comments
 (0)