From 75a7a4224049e25fb906c887a9dbe2c65048cdb7 Mon Sep 17 00:00:00 2001 From: Samir Talwar Date: Mon, 11 Mar 2024 16:29:27 +0100 Subject: [PATCH 1/2] Add a Docker Compose watch item to the connector metadata. This teaches the DDN CLI that the configuration should be synced, and the connector container restarted, whenever the configuration changes. --- crates/cli/src/lib.rs | 7 ++++++- crates/cli/src/metadata.rs | 2 +- ...itialize_tests__initialize_directory_with_metadata.snap | 4 ++++ ...ialize_directory_with_metadata_and_release_version.snap | 4 ++++ 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/crates/cli/src/lib.rs b/crates/cli/src/lib.rs index 613999fb3..0307f46f3 100644 --- a/crates/cli/src/lib.rs +++ b/crates/cli/src/lib.rs @@ -102,7 +102,12 @@ async fn initialize(with_metadata: bool, context: Context) -> name: "ndc-postgres".to_string(), version: context.release_version.unwrap_or("latest").to_string(), }), - docker_compose_watch: vec![], + docker_compose_watch: vec![metadata::DockerComposeWatchItem { + path: "./".to_string(), + target: Some("/etc/connector".to_string()), + action: metadata::DockerComposeWatchAction::SyncAndRestart, + ignore: vec![], + }], }; fs::write(metadata_file, serde_yaml::to_string(&metadata)?).await?; diff --git a/crates/cli/src/metadata.rs b/crates/cli/src/metadata.rs index c8660c694..74d2c8d1c 100644 --- a/crates/cli/src/metadata.rs +++ b/crates/cli/src/metadata.rs @@ -60,9 +60,9 @@ pub type DockerComposeWatch = Vec; #[serde(rename_all = "camelCase")] pub struct DockerComposeWatchItem { pub path: String, - pub action: DockerComposeWatchAction, #[serde(skip_serializing_if = "Option::is_none")] pub target: Option, + pub action: DockerComposeWatchAction, #[serde(skip_serializing_if = "Vec::is_empty")] pub ignore: Vec, } diff --git a/crates/cli/tests/snapshots/initialize_tests__initialize_directory_with_metadata.snap b/crates/cli/tests/snapshots/initialize_tests__initialize_directory_with_metadata.snap index bb5fec058..0783e02c6 100644 --- a/crates/cli/tests/snapshots/initialize_tests__initialize_directory_with_metadata.snap +++ b/crates/cli/tests/snapshots/initialize_tests__initialize_directory_with_metadata.snap @@ -13,3 +13,7 @@ commands: cliPlugin: name: ndc-postgres version: latest +dockerComposeWatch: +- path: ./ + target: /etc/connector + action: sync+restart diff --git a/crates/cli/tests/snapshots/initialize_tests__initialize_directory_with_metadata_and_release_version.snap b/crates/cli/tests/snapshots/initialize_tests__initialize_directory_with_metadata_and_release_version.snap index 902bfbb5d..223fff081 100644 --- a/crates/cli/tests/snapshots/initialize_tests__initialize_directory_with_metadata_and_release_version.snap +++ b/crates/cli/tests/snapshots/initialize_tests__initialize_directory_with_metadata_and_release_version.snap @@ -13,3 +13,7 @@ commands: cliPlugin: name: ndc-postgres version: v1.2.3 +dockerComposeWatch: +- path: ./ + target: /etc/connector + action: sync+restart From 7858841ce0fc0a4bad25ae0da5f6fe696931acfc Mon Sep 17 00:00:00 2001 From: Samir Talwar Date: Mon, 11 Mar 2024 16:40:58 +0100 Subject: [PATCH 2/2] Add a changelog entry. --- changelog.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/changelog.md b/changelog.md index 94bf3beb6..918971b25 100644 --- a/changelog.md +++ b/changelog.md @@ -2,6 +2,11 @@ ## [Unreleased] +### Added + +- The CLI plugin now integrates with the DDN CLI's `watch` functionality. + ([#360](https://github.com/hasura/ndc-postgres/pull/360)) + ## [v0.4.1] - 2024-03-06 ### Fixed