Skip to content
This repository was archived by the owner on Dec 21, 2024. It is now read-only.

feat: add env selector #585

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
127 changes: 126 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ uuid = { version = "1.11.0", features = ["v4"] }
url = { version = "2.5.3", features = ["serde"] }
base64 = "0.22.1"
kv-str = { version = "0.1.0", path = "../kv-str" }
inquire = "0.7.5"

[build-dependencies]
anyhow = "1.0"
Expand Down
16 changes: 9 additions & 7 deletions packages/cli/src/commands/actor/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ struct Port {

#[derive(Parser)]
pub struct Opts {
#[clap(index = 1)]
environment: String,
#[clap(long, alias = "env", short = 'e')]
environment: Option<String>,

#[clap(long, short = 'r')]
region: Option<String>,
Expand All @@ -49,7 +49,7 @@ pub struct Opts {
#[clap(long, short = 'b')]
build_tags: Option<String>,

#[clap(long = "env")]
#[clap(long = "env-var")]
env_vars: Option<Vec<String>>,

#[clap(long, value_enum)]
Expand Down Expand Up @@ -98,6 +98,8 @@ impl Opts {
pub async fn execute_inner(&self) -> Result<ExitCode> {
let ctx = toolchain::toolchain_ctx::load().await?;

let env = crate::util::env::get_or_select(&ctx, self.environment.as_ref()).await?;

// Parse tags
let actor_tags = if let Some(t) = &self.actor_tags {
kv_str::from_str::<HashMap<String, String>>(t)?
Expand Down Expand Up @@ -179,7 +181,7 @@ impl Opts {

// Deploys erver
match crate::util::deploy::deploy(crate::util::deploy::DeployOpts {
environment: &self.environment,
environment: &env,
build_tags: Some(build_tags),
})
.await
Expand Down Expand Up @@ -218,7 +220,7 @@ impl Opts {
let regions = apis::actor_regions_api::actor_regions_list(
&ctx.openapi_config_cloud,
Some(&ctx.project.name_id.to_string()),
Some(&self.environment),
Some(&env),
)
.await?;

Expand Down Expand Up @@ -269,7 +271,7 @@ impl Opts {
&ctx.openapi_config_cloud,
request,
Some(&ctx.project.name_id),
Some(&self.environment),
Some(&env),
)
.await
{
Expand All @@ -288,7 +290,7 @@ impl Opts {
crate::util::actor::logs::tail(
&ctx,
crate::util::actor::logs::TailOpts {
environment: &self.environment,
environment: &env,
actor_id,
stream: self
.log_stream
Expand Down
10 changes: 6 additions & 4 deletions packages/cli/src/commands/actor/destroy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ use uuid::Uuid;
#[derive(Parser)]
pub struct Opts {
#[clap(index = 1)]
environment: String,

#[clap(long)]
id: String,

#[clap(long, alias = "env", short = 'e')]
environment: Option<String>,

#[clap(long)]
override_kill_timeout: Option<i64>,
}
Expand All @@ -30,13 +30,15 @@ impl Opts {
pub async fn execute_inner(&self) -> Result<ExitCode> {
let ctx = toolchain::toolchain_ctx::load().await?;

let env = crate::util::env::get_or_select(&ctx, self.environment.as_ref()).await?;

let actor_id = Uuid::parse_str(&self.id).context("invalid id uuid")?;

match apis::actor_api::actor_destroy(
&ctx.openapi_config_cloud,
&actor_id.to_string(),
Some(&ctx.project.name_id),
Some(&self.environment),
Some(&env),
self.override_kill_timeout,
)
.await
Expand Down
10 changes: 6 additions & 4 deletions packages/cli/src/commands/actor/get.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ use uuid::Uuid;
#[derive(Parser)]
pub struct Opts {
#[clap(index = 1)]
environment: String,

#[clap(long)]
id: String,

#[clap(long, alias = "env", short = 'e')]
environment: Option<String>,
}

impl Opts {
Expand All @@ -27,13 +27,15 @@ impl Opts {
pub async fn execute_inner(&self) -> Result<ExitCode> {
let ctx = toolchain::toolchain_ctx::load().await?;

let env = crate::util::env::get_or_select(&ctx, self.environment.as_ref()).await?;

let actor_id = Uuid::parse_str(&self.id).context("invalid id uuid")?;

match apis::actor_api::actor_get(
&ctx.openapi_config_cloud,
&actor_id.to_string(),
Some(&ctx.project.name_id),
Some(&self.environment),
Some(&env),
)
.await
{
Expand Down
8 changes: 5 additions & 3 deletions packages/cli/src/commands/actor/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use toolchain::rivet_api::apis;

#[derive(Parser)]
pub struct Opts {
#[clap(index = 1)]
environment: String,
#[clap(long, alias = "env", short = 'e')]
environment: Option<String>,

#[clap(long)]
tags: Option<String>,
Expand All @@ -32,6 +32,8 @@ impl Opts {
pub async fn execute_inner(&self) -> Result<ExitCode> {
let ctx = toolchain::toolchain_ctx::load().await?;

let env = crate::util::env::get_or_select(&ctx, self.environment.as_ref()).await?;

// Parse tags
let tags = self
.tags
Expand All @@ -43,7 +45,7 @@ impl Opts {
match apis::actor_api::actor_list(
&ctx.openapi_config_cloud,
Some(&ctx.project.name_id),
Some(&self.environment),
Some(&env),
tags_json.as_deref(),
Some(self.include_destroyed),
self.cursor.as_deref(),
Expand Down
10 changes: 6 additions & 4 deletions packages/cli/src/commands/actor/logs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ use uuid::Uuid;
#[derive(Parser)]
pub struct Opts {
#[clap(index = 1)]
environment: String,

#[clap(long)]
id: String,

#[clap(long, alias = "env", short = 'e')]
environment: Option<String>,

#[clap(long, short = 's')]
stream: Option<crate::util::actor::logs::LogStream>,

Expand All @@ -35,12 +35,14 @@ impl Opts {
pub async fn execute_inner(&self) -> Result<ExitCode> {
let ctx = toolchain::toolchain_ctx::load().await?;

let env = crate::util::env::get_or_select(&ctx, self.environment.as_ref()).await?;

let actor_id = Uuid::parse_str(&self.id).context("invalid id uuid")?;

crate::util::actor::logs::tail(
&ctx,
crate::util::actor::logs::TailOpts {
environment: &self.environment,
environment: &env,
actor_id,
stream: self
.stream
Expand Down
Loading
Loading