diff --git a/connector-definition/.hasura-connector/Dockerfile b/connector-definition/.hasura-connector/Dockerfile index 7db4a00..879419d 100644 --- a/connector-definition/.hasura-connector/Dockerfile +++ b/connector-definition/.hasura-connector/Dockerfile @@ -12,4 +12,4 @@ ENV HASURA_CONNECTOR_PORT=8080 # Expose the port specified by the HASURA_CONNECTOR_PORT environment variable EXPOSE $HASURA_CONNECTOR_PORT -ENTRYPOINT [ "./dist/cli/index.js", "start" ] \ No newline at end of file +ENTRYPOINT [ "./dist/cli/index.js" ] \ No newline at end of file diff --git a/connector-definition/.hasura-connector/connector-metadata.yaml b/connector-definition/.hasura-connector/connector-metadata.yaml index 9ab864d..b40d4a8 100644 --- a/connector-definition/.hasura-connector/connector-metadata.yaml +++ b/connector-definition/.hasura-connector/connector-metadata.yaml @@ -12,4 +12,3 @@ supportedEnvironmentVariables: default: "100" commands: update: docker run --rm -e AZURE_COSMOS_KEY="$AZURE_COSMOS_KEY" -e AZURE_COSMOS_DB_NAME="$AZURE_COSMOS_DB_NAME" -e AZURE_COSMOS_ENDPOINT="$AZURE_COSMOS_ENDPOINT" -v "$HASURA_PLUGIN_CONNECTOR_CONTEXT_PATH":/etc/connector ghcr.io/hasura/ndc-azure-cosmos:v0.1.1 update - start: docker run --rm -e AZURE_COSMOS_KEY="$AZURE_COSMOS_KEY" -e AZURE_COSMOS_DB_NAME="$AZURE_COSMOS_DB_NAME" -e AZURE_COSMOS_ENDPOINT="$AZURE_COSMOS_ENDPOINT" -v "$HASURA_PLUGIN_CONNECTOR_CONTEXT_PATH":/etc/connector ghcr.io/hasura/ndc-azure-cosmos:v0.1.1 start diff --git a/src/cli/index.ts b/src/cli/index.ts index 929a6b5..2e4350e 100644 --- a/src/cli/index.ts +++ b/src/cli/index.ts @@ -2,7 +2,6 @@ import { Command, Option } from "commander"; import * as updateCmd from "./update"; -import * as startCmd from "./start"; import { createConnector } from "../connector"; import { version } from "../../package.json" import * as sdk from "@hasura/ndc-sdk-typescript"; @@ -12,9 +11,38 @@ function main() { program.addCommand(updateCmd.cmd); - program.addCommand(startCmd.cmd); + program.action(async (options: sdk.ServerOptions) => { + program.addOption( + new Option("--configuration ") + .env("HASURA_CONFIGURATION_DIRECTORY") + .default(".") + ) + program.addOption( + new Option("--port ") + .env("HASURA_CONNECTOR_PORT") + .default(8080) + .argParser(parseIntOption) + ) + program.addOption( + new Option("--service-token-secret ").env("HASURA_SERVICE_TOKEN_SECRET") + ) + program.addOption(new Option("--log-level ").env("HASURA_LOG_LEVEL").default("info")) + program.addOption(new Option("--pretty-print-logs").env("HASURA_PRETTY_PRINT_LOGS").default(false)) + + const connector = createConnector(); + await sdk.startServer(connector, options) + }); program.parse(process.argv); } +function parseIntOption(value: string, _previous: number): number { + // parseInt takes a string and a radix + const parsedValue = parseInt(value, 10); + if (isNaN(parsedValue)) { + console.error("Not a valid integer."); + } + return parsedValue; +} + main() diff --git a/src/cli/start.ts b/src/cli/start.ts deleted file mode 100644 index 7037a13..0000000 --- a/src/cli/start.ts +++ /dev/null @@ -1,37 +0,0 @@ -import { Command, Option } from "commander"; -import * as sdk from "@hasura/ndc-sdk-typescript"; -import { createConnector } from "../connector" - -export const cmd = new Command("start") - .description( - "Imports the containers from the specified Azure Cosmos DB and infers the schema by introspecting the containers." - ) - .addOption( - new Option("--configuration ") - .env("HASURA_CONFIGURATION_DIRECTORY") - .default(".") - ) - .addOption( - new Option("--port ") - .env("HASURA_CONNECTOR_PORT") - .default(8080) - .argParser(parseIntOption) - ) - .addOption( - new Option("--service-token-secret ").env("HASURA_SERVICE_TOKEN_SECRET") - ) - .addOption(new Option("--log-level ").env("HASURA_LOG_LEVEL").default("info")) - .addOption(new Option("--pretty-print-logs").env("HASURA_PRETTY_PRINT_LOGS").default(false)) - .action(async (options: sdk.ServerOptions) => { - const connector = createConnector(); - await sdk.startServer(connector, options) - }); - -function parseIntOption(value: string, _previous: number): number { - // parseInt takes a string and a radix - const parsedValue = parseInt(value, 10); - if (isNaN(parsedValue)) { - console.error("Not a valid integer."); - } - return parsedValue; -}