Skip to content

Commit 343b8b3

Browse files
committed
add native toolchain definition to connector metadata
1 parent 4160af1 commit 343b8b3

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

crates/cli/src/lib.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ mod native_operations;
99
use std::path::PathBuf;
1010

1111
use clap::Subcommand;
12+
use metadata::NativeToolchainDefinition;
1213
use tokio::fs;
1314

1415
use ndc_postgres_configuration as configuration;
@@ -134,6 +135,20 @@ async fn initialize(with_metadata: bool, context: Context<impl Environment>) ->
134135
action: metadata::DockerComposeWatchAction::SyncAndRestart,
135136
ignore: vec![],
136137
}],
138+
native_toolchain_definition: Some(NativeToolchainDefinition {
139+
commands: vec![
140+
("start".to_string(), metadata::CommandDefinition {
141+
command_type: metadata::CommandType::ShellScript,
142+
bash: "#!/usr/bin/env bash\nset -eu -o pipefail\nHASURA_CONFIGURATION_DIRECTORY=\"$HASURA_PLUGIN_CONNECTOR_CONTEXT_PATH\" ndc-postgres serve".to_string(),
143+
powershell: String::new(),
144+
}),
145+
("update".to_string(), metadata::CommandDefinition {
146+
command_type: metadata::CommandType::ShellScript,
147+
bash: "#!/usr/bin/env bash\nset -eu -o pipefail\n\"$HOME/.ddn/plugins/bin/hasura-ndc_postgres\" update".to_string(),
148+
powershell: String::new(),
149+
}),
150+
].into_iter().collect(),
151+
})
137152
};
138153

139154
fs::write(metadata_file, serde_yaml::to_string(&metadata)?).await?;

crates/cli/src/metadata.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
//!
33
//! See https://github.com/hasura/ndc-hub/blob/main/rfcs/0001-packaging.md#connector-definition.
44
5+
use std::collections::BTreeMap;
6+
57
use serde::{Deserialize, Serialize};
68

79
#[derive(Debug, Serialize, Deserialize)]
@@ -14,6 +16,8 @@ pub struct ConnectorMetadataDefinition {
1416
pub cli_plugin: Option<CliPluginDefinition>,
1517
#[serde(skip_serializing_if = "Vec::is_empty")]
1618
pub docker_compose_watch: DockerComposeWatch,
19+
#[serde(skip_serializing_if = "Option::is_none")]
20+
pub native_toolchain_definition: Option<NativeToolchainDefinition>,
1721
}
1822

1923
#[derive(Debug, Serialize, Deserialize)]
@@ -75,3 +79,25 @@ pub enum DockerComposeWatchAction {
7579
#[serde(rename = "sync+restart")]
7680
SyncAndRestart,
7781
}
82+
83+
#[derive(Debug, Serialize, Deserialize)]
84+
#[serde(rename_all = "camelCase")]
85+
pub struct NativeToolchainDefinition {
86+
pub commands: BTreeMap<CommandName, CommandDefinition>,
87+
}
88+
89+
pub type CommandName = String;
90+
91+
#[derive(Debug, Serialize, Deserialize)]
92+
#[serde(rename_all = "camelCase")]
93+
pub struct CommandDefinition {
94+
#[serde(rename = "type")]
95+
pub command_type: CommandType,
96+
pub bash: String,
97+
pub powershell: String,
98+
}
99+
100+
#[derive(Debug, Serialize, Deserialize)]
101+
pub enum CommandType {
102+
ShellScript,
103+
}

0 commit comments

Comments
 (0)