Skip to content

Commit

Permalink
Add regions argument to deployments (#71)
Browse files Browse the repository at this point in the history
  • Loading branch information
steebchen authored Aug 20, 2024
1 parent 418e7ce commit 2288a9a
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 2 deletions.
12 changes: 10 additions & 2 deletions cli/src/command/deployments/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use slot::credential::Credentials;
use slot::graphql::deployments::create_deployment::CreateDeploymentCreateDeployment::{
KatanaConfig, MadaraConfig, ToriiConfig,
};
use slot::graphql::deployments::create_deployment::{self, *};
use slot::graphql::deployments::create_deployment::*;
use slot::graphql::deployments::CreateDeployment;
use slot::graphql::{GraphQLQuery, Response};

Expand All @@ -18,11 +18,18 @@ use super::{services::CreateServiceCommands, Tier};
pub struct CreateArgs {
#[arg(help = "The name of the project.")]
pub project: String,

#[arg(short, long, default_value = "basic")]
#[arg(value_name = "tier")]
#[arg(help = "Deployment tier.")]
pub tier: Tier,

#[arg(short, long)]
#[arg(help = "The list of regions to deploy to.")]
#[arg(value_name = "regions")]
#[arg(value_delimiter = ',')]
pub regions: Option<Vec<String>>,

#[command(subcommand)]
create_commands: CreateServiceCommands,
}
Expand Down Expand Up @@ -95,12 +102,13 @@ impl CreateArgs {
tier,
service,
wait: Some(true),
regions: self.regions.clone(),
});

let user = Credentials::load()?;
let client = Client::new_with_token(user.access_token);

let res: Response<create_deployment::ResponseData> = client.query(&request_body).await?;
let res: Response<ResponseData> = client.query(&request_body).await?;
if let Some(errors) = res.errors.clone() {
for err in errors {
println!("Error: {}", err.message);
Expand Down
42 changes: 42 additions & 0 deletions slot/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -12156,6 +12156,30 @@
}
}
},
{
"args": [],
"deprecationReason": null,
"description": null,
"isDeprecated": false,
"name": "regions",
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "LIST",
"name": null,
"ofType": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
}
}
}
},
{
"args": [],
"deprecationReason": null,
Expand Down Expand Up @@ -21002,6 +21026,24 @@
"name": "Boolean",
"ofType": null
}
},
{
"defaultValue": null,
"description": null,
"name": "regions",
"type": {
"kind": "LIST",
"name": null,
"ofType": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
}
}
}
],
"deprecationReason": null,
Expand Down
2 changes: 2 additions & 0 deletions slot/src/graphql/deployments/create.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ mutation CreateDeployment(
$service: CreateServiceInput!
$tier: DeploymentTier!
$wait: Boolean
$regions: [String!]
) {
createDeployment(
name: $project
service: $service
tier: $tier
wait: $wait
regions: $regions
) {
__typename
... on KatanaConfig {
Expand Down

0 comments on commit 2288a9a

Please sign in to comment.