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

feat: add --logs command to rivet actor create #584

Closed
Closed
Changes from 1 commit
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
Prev Previous commit
Next Next commit
feat: automatically select regoin when creating actor
NathanFlurry committed Nov 25, 2024
commit bfab65d2838e0dffc3b744348ab118aba8ce11b9
32 changes: 30 additions & 2 deletions packages/cli/src/commands/actor/create.rs
Original file line number Diff line number Diff line change
@@ -34,7 +34,7 @@ pub struct Opts {
environment: String,

#[clap(long, short = 'r')]
region: String,
region: Option<String>,

/// Tags to use for both the actor & build tags. This allows for creating actors quickly since
/// the tags are often identical between the two.
@@ -170,8 +170,36 @@ impl Opts {
})
.transpose()?;

// Auto-select region if needed
let region = if let Some(region) = &self.region {
region.clone()
} else {
let regions = apis::actor_regions_api::actor_regions_list(
&ctx.openapi_config_cloud,
Some(&ctx.project.name_id.to_string()),
Some(&self.environment),
)
.await?;

// TODO(RVT-4207): Improve automatic region selection logic
// Choose a region
let auto_region = if let Some(ideal_region) = regions
.regions
.iter()
.filter(|r| r.id == "lax" || r.id == "local")
.next()
{
ideal_region.id.clone()
} else {
regions.regions.first().context("no regions")?.id.clone()
};
println!("Automatically selected region: {auto_region}");

auto_region
};

let request = models::ActorCreateActorRequest {
region: self.region.clone(),
region,
tags: Some(serde_json::json!(actor_tags)),
build: self
.build