Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC: Include CLI packaging information within the connector metadata #322

Merged
merged 37 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
210c50e
Add connector types and scripts to generate and validate
codingkarthik Oct 3, 2024
6a2c049
add a Github workflow to validate the schema
codingkarthik Oct 3, 2024
de9278d
add the current branch to test GH workflow
codingkarthik Oct 3, 2024
5cd7deb
minor changes
codingkarthik Oct 3, 2024
83359b9
revert back the unwanted changes
codingkarthik Oct 3, 2024
160c154
added working-directory
codingkarthik Oct 3, 2024
82e0c0e
change directory
codingkarthik Oct 3, 2024
887ce5b
fix syntax error
codingkarthik Oct 3, 2024
4d18c9a
debug package-lock existence
codingkarthik Oct 3, 2024
537bdc8
add working-directory
codingkarthik Oct 3, 2024
7ee7f0f
remove working-directory 1
codingkarthik Oct 3, 2024
6adbacf
minor changes
codingkarthik Oct 3, 2024
ce93da8
modify the script again
codingkarthik Oct 3, 2024
3d2eaac
remove newline
codingkarthik Oct 3, 2024
f3530c4
add README
codingkarthik Oct 3, 2024
8ab7a3c
include a link to the connector packaging
codingkarthik Oct 3, 2024
fbf695c
update original README
codingkarthik Oct 3, 2024
5b0310c
binary CLI > native CLI
codingkarthik Oct 3, 2024
c134eb1
update the RFC
codingkarthik Oct 3, 2024
189f02b
update README
codingkarthik Oct 3, 2024
7714011
make platforms optional
codingkarthik Oct 3, 2024
40e6c8c
minor changes
codingkarthik Oct 4, 2024
603f571
correct the JSON schema
codingkarthik Oct 4, 2024
cb67c9e
use FilePath instead of File
codingkarthik Oct 4, 2024
dfc583e
incorporate minor changes
codingkarthik Oct 4, 2024
46ec08a
Merge branch 'main' into kc/cli-plugin-packaging-v1
codingkarthik Oct 4, 2024
00c8c53
remove the redundant connectorTypes file
codingkarthik Oct 7, 2024
3361a1f
extend the BinaryCliPluginDefinition
codingkarthik Oct 7, 2024
3e139ad
make the fields in the BinaryInlineCliPluginDefinition required
codingkarthik Oct 8, 2024
87f48e0
Merge branch 'main' into kc/cli-plugin-packaging-v1
codingkarthik Oct 8, 2024
6130b69
remove `files` from BinaryCliPluginPlatform
codingkarthik Oct 8, 2024
0e537e5
remove redundant type
codingkarthik Oct 8, 2024
4a93567
Merge branch 'main' into kc/cli-plugin-packaging-v1
codingkarthik Oct 14, 2024
089de52
remove files and document `uri`
codingkarthik Oct 15, 2024
51e9486
modify the documentation of the field
codingkarthik Oct 16, 2024
82b7bb2
update the schema
codingkarthik Oct 16, 2024
8432d59
Merge branch 'main' into kc/cli-plugin-packaging-v1
codingkarthik Oct 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions .github/workflows/validate-connector-metadata-schema.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Validate Connector Metadata JSON Schema

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
validate-schema:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: '18'

- name: Install dependencies
working-directory: connector-metadata-types
run: npm ci

- name: Generate and compare schema
working-directory: connector-metadata-types
run: |
npm run generate-schema new-schema.json
if [ -f schema.json ]; then
if cmp -s schema.json new-schema.json; then
echo "Schema is up to date"
else
echo "Error: Generated schema does not match the existing schema"
echo "Diff between schema.json and new-schema.json:"
diff -u schema.json new-schema.json || true
exit 1
fi
else
echo "Error: schema.json does not exist"
exit 1
fi
rm new-schema.json
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ implementation][NDC reference].

[NDC specification]: http://hasura.github.io/ndc-spec/
[NDC reference]: https://github.com/hasura/ndc-spec/tree/main/ndc-reference

[Connector metadata packaging]: ./connector-metadata-types/README.md
11 changes: 11 additions & 0 deletions connector-metadata-types/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Dependency directories
node_modules/

# TypeScript compiled output
dist/
build/
*.js
*.js.map

# TypeScript configuration
tsconfig.tsbuildinfo
24 changes: 24 additions & 0 deletions connector-metadata-types/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Connector metadata types

This project contains the schema of the connector-metadata.json file that is used in the
package.tgz file of a connector, whenever a new version of a connector is released.

It is expected that whenever authors propose a new RFC that changes the schema
of the connector-metadata.json file, they will update this schema file accordingly in the `connectorTypes.ts` file.

The `schema.json` file is the JSON schema of the current `connector-metadata.json` structure.


## How to update the schema

1. Update the `connectorTypes.ts` file with the new schema.
2. Run `npm run generate-schema schema.json` to update the `schema.json` file.

## Github Actions workflow


The repo includes a GitHub Actions workflow that generates the schema and
compares it with the existing schema file.

This ensures that any changes to the schema generation logic are reflected
in the committed schema file.
118 changes: 118 additions & 0 deletions connector-metadata-types/connectorTypes.ts
codingkarthik marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
export type ConnectorMetadataDefinition = {
version?: 1;
packagingDefinition: PackagingDefinition;
nativeToolchainDefinition?: NativeToolchainDefinition;
supportedEnvironmentVariables: EnvironmentVariableDefinition[];
commands: Commands;
cliPlugin?: BinaryCliPluginDefinition | DockerCliPluginDefinition;
dockerComposeWatch: DockerComposeWatch;
documentationPage?: string;
};

export type PackagingDefinition =
| PrebuiltDockerImagePackaging
| ManagedDockerBuildPackaging;

export type PrebuiltDockerImagePackaging = {
type: "PrebuiltDockerImage";
dockerImage: string;
};

export type ManagedDockerBuildPackaging = {
type: "ManagedDockerBuild";
};

export type NativeToolchainCommands = {
start: string | DockerizedCommand | ShellScriptCommand;
update?: string | DockerizedCommand | ShellScriptCommand;
watch: string | DockerizedCommand | ShellScriptCommand;
};

export type NativeToolchainDefinition = {
commands: NativeToolchainCommands;
};

export type Commands = {
update?: string | DockerizedCommand | ShellScriptCommand;
watch?: string | DockerizedCommand | ShellScriptCommand;
printSchemaAndCapabilities?: string | DockerizedCommand | ShellScriptCommand;
upgradeConfiguration?: string | DockerizedCommand | ShellScriptCommand;
};

export type EnvironmentVariableDefinition = {
name: string;
description: string;
defaultValue?: string;
};

export type DockerizedCommand = {
type: "Dockerized";
dockerImage: string;
commandArgs: string[];
};

export type ShellScriptCommand = {
type: "ShellScript";
bash: string;
powershell: string;
};

export type DockerCliPluginDefinition = {
type: "Docker";
dockerImage: string; // eg "hasura/postgres-data-connector:1.0.0"
};

export type BinaryCliPluginPlatform = {
/**
* The selector identifies the target platform for this configuration.
* It follows the format: <os>-<architecture>
*
* Possible values:
* - darwin-arm64: macOS on ARM64 architecture (e.g., M1 Macs)
* - linux-arm64: Linux on ARM64 architecture
* - darwin-amd64: macOS on x86-64 architecture
* - windows-amd64: Windows on x86-64 architecture
* - linux-amd64: Linux on x86-64 architecture
*/
selector:
| "darwin-arm64"
| "linux-arm64"
| "darwin-amd64"
| "windows-amd64"
| "linux-amd64";
/**
* The URI of the binary file. This should be a URL from which the binary can be downloaded,
* without any authentication.
*/
uri: string;
/**
* The SHA256 hash of the binary file. This is used to verify the integrity of the downloaded binary.
*/
sha256: string;
/**
* The name of the binary file. This is the name of the binary file that will be placed in the bin directory.
*/
bin: string;

files: FilePath[];
};

export type FilePath = {
from: string;
to: string;
};

export type BinaryCliPluginDefinition = {
type: "Binary";
name: string;
platforms: BinaryCliPluginPlatform[];
};

export type DockerComposeWatch = DockerComposeWatchItem[];

export type DockerComposeWatchItem = {
path: string;
action: "rebuild" | "sync" | "sync+restart";
target?: string;
ignore?: string[];
};
Loading
Loading