Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Capture the path to the deployment zip from the CLI. #28

Merged
merged 1 commit into from
Nov 18, 2024
Merged
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
14 changes: 11 additions & 3 deletions src/cmd/deploy.rs
Original file line number Diff line number Diff line change
@@ -1,24 +1,32 @@
use std::path::PathBuf;

use crate::adapters::ChiSquareEngine;
use crate::adapters::{CloudWatch, MockIngress};
use crate::config::deploy::DeploySubcommand;
use crate::{adapters::Monitor, Pipeline};
use miette::Result;

#[derive(Default)]
pub struct Deploy;
pub struct Deploy {
artifact_path: PathBuf,
}

impl Deploy {
/// initialize the deployment command. Using a constructor here
/// is largely to make the look-and-feel of the cmd API similar
/// between different commands.
pub fn new() -> Self {
Self
pub fn new(args: DeploySubcommand) -> Self {
Self {
artifact_path: args.artifact_path,
}
}

/// deploy the canary, monitoring it, and ultimately promoting
/// or yanking the deployment.
pub async fn dispatch(self) -> Result<()> {
// • Load the monitor from the user's config.
let monitor = CloudWatch::load_from_conf().await?;
// • TODO: Create the ingress, passing in the path to the deployment artifact.
// • Set up our deployment pipeline.
Pipeline::builder()
.monitor(monitor)
Expand Down
5 changes: 3 additions & 2 deletions src/config/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ use clap::Subcommand;
use miette::Result;

use crate::cmd::{Deploy, Version};
use crate::config::deploy::DeploySubcommand;

/// one of the top-level commands accepted by
/// the canary CLI.
#[derive(Subcommand, Clone)]
pub enum CanaryCommand {
/// Deploy the canary, dynamically ramping traffic up as canary gains statistical
/// confidence in the canary.
Deploy,
Deploy(DeploySubcommand),
/// Print the CLI version and exit
Version,
}
Expand All @@ -18,7 +19,7 @@ impl CanaryCommand {
/// dispatch the user-provided arguments to the command handler.
pub async fn dispatch(&self) -> Result<()> {
match self.clone() {
Self::Deploy => Deploy::new().dispatch().await,
Self::Deploy(args) => Deploy::new(args).dispatch().await,
Self::Version => Version::new().dispatch(),
}
}
Expand Down
10 changes: 10 additions & 0 deletions src/config/deploy/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
use std::path::PathBuf;

use clap::Args;

/// Deploy a serverless function with a self-promoting canary.
#[derive(Args, Clone)]
pub struct DeploySubcommand {
#[arg(value_name = "FILE")]
pub artifact_path: PathBuf,
}
2 changes: 2 additions & 0 deletions src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ pub use flags::Flags;

mod colors;
mod command;
/// Contains the description of the `multi deploy` position arguments and flags.
pub mod deploy;
mod flags;