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

feat(cli): add config file support for update torii cmd #123

Merged
merged 1 commit into from
Nov 9, 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
5 changes: 5 additions & 0 deletions cli/src/command/deployments/services/torii.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,9 @@ pub struct ToriiUpdateArgs {
#[arg(long, short, value_name = "version")]
#[arg(help = "Service version to use.")]
pub version: Option<String>,

#[arg(long)]
#[arg(help = "A config file ")]
#[arg(value_name = "config-file")]
pub config_file: Option<String>,
}
36 changes: 30 additions & 6 deletions cli/src/command/deployments/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
use super::services::UpdateServiceCommands;
use crate::command::deployments::Tier;
use anyhow::Result;
use base64::engine::general_purpose;
use base64::Engine;
use clap::Args;
use slot::api::Client;
use slot::credential::Credentials;
Expand All @@ -11,9 +13,11 @@ use slot::graphql::deployments::update_deployment::UpdateDeploymentUpdateDeploym
};
use slot::graphql::deployments::update_deployment::{
self, UpdateKatanaConfigInput, UpdateServiceConfigInput, UpdateServiceInput,
UpdateToriiConfigInput,
};
use slot::graphql::deployments::{update_deployment::*, UpdateDeployment};
use slot::graphql::GraphQLQuery;
use std::fs;

#[derive(Debug, Args)]
#[command(next_help_heading = "Update options")]
Expand All @@ -36,6 +40,7 @@ impl UpdateArgs {
type_: DeploymentService::katana,
version: config.version.clone(),
config: Some(UpdateServiceConfigInput {
torii: None,
katana: Some(UpdateKatanaConfigInput {
block_time: config.block_time,
disable_fee: config.disable_fee,
Expand All @@ -46,15 +51,34 @@ impl UpdateArgs {
}),
}),
},
UpdateServiceCommands::Torii(config) => UpdateServiceInput {
type_: DeploymentService::torii,
version: config.version.clone(),
config: Some(UpdateServiceConfigInput { katana: None }),
},
UpdateServiceCommands::Torii(config) => {
// Read the file and convert to base64
let config_file_base64 = match &config.config_file {
Some(file_path) => {
let file_contents = fs::read(file_path)?;
Some(general_purpose::STANDARD.encode(file_contents))
}
None => None,
};

UpdateServiceInput {
type_: DeploymentService::torii,
version: config.version.clone(),
config: Some(UpdateServiceConfigInput {
katana: None,
torii: Some(UpdateToriiConfigInput {
config_file: config_file_base64,
}),
}),
}
}
UpdateServiceCommands::Saya(config) => UpdateServiceInput {
type_: DeploymentService::saya,
version: config.version.clone(),
config: Some(UpdateServiceConfigInput { katana: None }),
config: Some(UpdateServiceConfigInput {
katana: None,
torii: None,
}),
},
};

Expand Down
31 changes: 31 additions & 0 deletions slot/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -16612,6 +16612,16 @@
"name": "UpdateKatanaConfigInput",
"ofType": null
}
},
{
"defaultValue": null,
"description": null,
"name": "torii",
"type": {
"kind": "INPUT_OBJECT",
"name": "UpdateToriiConfigInput",
"ofType": null
}
}
],
"interfaces": [],
Expand Down Expand Up @@ -16664,6 +16674,27 @@
"name": "UpdateServiceInput",
"possibleTypes": []
},
{
"description": null,
"enumValues": [],
"fields": [],
"inputFields": [
{
"defaultValue": null,
"description": null,
"name": "configFile",
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
}
],
"interfaces": [],
"kind": "INPUT_OBJECT",
"name": "UpdateToriiConfigInput",
"possibleTypes": []
},
{
"description": "The `Upload` scalar type represents a multipart file upload.",
"enumValues": [],
Expand Down
1 change: 1 addition & 0 deletions slot/src/graphql/deployments/update.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ mutation UpdateDeployment(
}

... on ToriiConfig {
configFile
graphql
grpc
rpc
Expand Down
Loading