Skip to content

Commit

Permalink
feat(cli): add config file support for Torii service
Browse files Browse the repository at this point in the history
Added the ability to specify a config file for the Torii service.
The file is read and encoded in base64 for the update process.
  • Loading branch information
steebchen committed Nov 9, 2024
1 parent 0e2c6af commit 9e75f1b
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 6 deletions.
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

0 comments on commit 9e75f1b

Please sign in to comment.