Skip to content

Commit

Permalink
Override cargo package
Browse files Browse the repository at this point in the history
  • Loading branch information
sestrella committed Nov 5, 2024
1 parent 79cdafe commit 7ceb603
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
6 changes: 5 additions & 1 deletion devenv.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@

pre-commit.hooks.clippy.enable = true;
pre-commit.hooks.nixpkgs-fmt.enable = true;
pre-commit.hooks.rustfmt.enable = true;

pre-commit.hooks.rustfmt = {
enable = true;
packageOverrides.cargo = pkgs.cargo;
};

# See full reference at https://devenv.sh/reference/options/
}
23 changes: 13 additions & 10 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,11 @@ impl TryFrom<Container> for SelectableContainer {
type Error = anyhow::Error;

fn try_from(value: Container) -> Result<Self, Self::Error> {
let name = value.name.context("name not found")?;
let arn = value.container_arn.context("container_arn not found")?;
let runtime_id = value.runtime_id.context("runtime_id not found")?;
let name = value.name.context("'name' is not defined")?;
let arn = value
.container_arn
.context("'container_arn' is not defined")?;
let runtime_id = value.runtime_id.context("'runtime_id' is not defined")?;
Ok(SelectableContainer {
name,
arn,
Expand Down Expand Up @@ -196,8 +198,8 @@ async fn main() -> anyhow::Result<()> {
match Cli::parse() {
Cli::Exec(args) => run_exec(&ecs_client, &args).await,
Cli::Logs(args) => {
let cw_logs_client = aws_sdk_cloudwatchlogs::Client::new(&config);
run_logs(&ecs_client, &cw_logs_client, &args).await
let cwlogs_client = aws_sdk_cloudwatchlogs::Client::new(&config);
run_logs(&ecs_client, &cwlogs_client, &args).await
}
}
}
Expand Down Expand Up @@ -232,13 +234,14 @@ async fn run_exec(ecs_client: &aws_sdk_ecs::Client, args: &ExecArgs) -> anyhow::
let region = ecs_client
.config()
.region()
.context("region is not defined")?;
.context("'region' is not defined")?;

let mut command = Command::new(session_manager_path)
.args([
serde_json::to_string(&session)?,
region.to_string(),
"StartSession".to_string(),
// TODO: pass profile
"".to_string(),
serde_json::to_string(&start_session)?,
format!("https://ssm.{}.amazonaws.com", region),
Expand All @@ -252,14 +255,14 @@ async fn run_exec(ecs_client: &aws_sdk_ecs::Client, args: &ExecArgs) -> anyhow::

async fn run_logs(
ecs_client: &aws_sdk_ecs::Client,
cw_logs_client: &aws_sdk_cloudwatchlogs::Client,
_cwlogs_client: &aws_sdk_cloudwatchlogs::Client,
args: &LogsArgs,
) -> anyhow::Result<()> {
let cluster = get_cluster(&ecs_client, &args.cluster).await?;
let task = get_task(&ecs_client, &cluster.arn, &args.task).await?;
let task_definition_arn = task
.task_definition_arn
.context("task_definition_arn not found")?;
.context("'task_definition_arn' is not defined")?;
// let container = get_container(&client, &cluster.arn, &task.arn, &args.container).await?;
let output = ecs_client
.describe_task_definition()
Expand All @@ -268,9 +271,9 @@ async fn run_logs(
.await?;
let container_definition = output
.task_definition
.context("Task definition is not defined")?
.context("'task_definition' is not defined")?
.container_definitions
.context("Container definitions is not defined")?
.context("'container_definitions' is not defined")?
.into_iter()
// TODO: remove hard-coded container name
.find(|container_definition| container_definition.name == Some("action_cable".to_string()))
Expand Down

0 comments on commit 7ceb603

Please sign in to comment.