Skip to content

Commit

Permalink
RFC: Include CLI packaging information within the connector metadata (#…
Browse files Browse the repository at this point in the history
…322)

# Add Binary CLI Plugin Packaging Information to
`connector-metadata.yaml`

This PR introduces changes to improve the management of binary CLI
plugin information in the `connector-metadata.yaml` file.

## Key Changes

1. Extended `connector-metadata.json` to include binary CLI plugin
packaging information.
2. Added a new optional `version` field to the
`ConnectorMetadataDefinition` type for future versioning.
3. Extend `BinaryCliPluginDefinition` to accommodate inline binary CLI
definition.

## Addition of `connector-metadata-types`

A significant part of this PR is the introduction of
`connector-metadata-types`. This file contains TypeScript type
definitions for the `connector-metadata.json` structure and is meant to
act as the source of truth for the schema of the
`connector-metadata.json` file. As we advance, it is expected that if
any changes are proposed in the connector metadata structure, they also
update the `connectorTypes.ts` file in the `connector-metadata-types`
folder.
  • Loading branch information
codingkarthik authored Oct 16, 2024
1 parent e505ac6 commit 862ab1a
Show file tree
Hide file tree
Showing 12 changed files with 2,001 additions and 1 deletion.
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.
Loading

0 comments on commit 862ab1a

Please sign in to comment.