Skip to content

Commit

Permalink
Add a Docker Compose watch item to the connector metadata. (#360)
Browse files Browse the repository at this point in the history
### What

This teaches the DDN CLI that the configuration should be synced, and
the connector container restarted, whenever the configuration changes.

### How

When emitting connector metadata, we include a `dockerComposeWatch`
item.
  • Loading branch information
SamirTalwar authored Mar 14, 2024
1 parent 7369212 commit 591ef96
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 2 deletions.
5 changes: 5 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))

### Changed

- The ndc-postgres-cli `initialize` command will now generate
Expand Down
7 changes: 6 additions & 1 deletion crates/cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,12 @@ async fn initialize(with_metadata: bool, context: Context<impl Environment>) ->
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?;
Expand Down
2 changes: 1 addition & 1 deletion crates/cli/src/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ pub type DockerComposeWatch = Vec<DockerComposeWatchItem>;
#[serde(rename_all = "camelCase")]
pub struct DockerComposeWatchItem {
pub path: String,
pub action: DockerComposeWatchAction,
#[serde(skip_serializing_if = "Option::is_none")]
pub target: Option<String>,
pub action: DockerComposeWatchAction,
#[serde(skip_serializing_if = "Vec::is_empty")]
pub ignore: Vec<String>,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,7 @@ commands:
cliPlugin:
name: ndc-postgres
version: latest
dockerComposeWatch:
- path: ./
target: /etc/connector
action: sync+restart
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,7 @@ commands:
cliPlugin:
name: ndc-postgres
version: v1.2.3
dockerComposeWatch:
- path: ./
target: /etc/connector
action: sync+restart

0 comments on commit 591ef96

Please sign in to comment.