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

specgen docs #232

Merged
merged 22 commits into from
Jan 9, 2025
Merged
Changes from 19 commits
Commits
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
45 changes: 43 additions & 2 deletions specgen/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,44 @@
# Specgen
# specgen

TBD
## Overview

`specgen` is a tool that generates connector specifications and writes them to
`connector.yaml`. The input to `specgen` are source and destination
hariso marked this conversation as resolved.
Show resolved Hide resolved
configuration structs returned by the `Config()` methods in the connectors.

`specgen` is run as part of `go generate`. It also needs access to the
`sdk.Connector` variable that holds references to constructor functions for the
source and the destination, so it's best to place it in the `connector.go` file.
The following is an example from the Kafka connector:

```go
//go:generate specgen

// Package kafka contains implementations for Kafka source and destination
// connectors for Conduit.
package kafka

import (
_ "embed"

sdk "github.com/conduitio/conduit-connector-sdk"
)

//go:embed connector.yaml
var specs string

var Connector = sdk.Connector{
NewSpecification: sdk.YAMLSpecification(specs),
NewSource: NewSource,
NewDestination: NewDestination,
}
```

`specgen` generates the specification in the following phases:

1. Extract the specifications from the source and destination configuration
struct.
hariso marked this conversation as resolved.
Show resolved Hide resolved
2. Combine the extracted specification with the existing one in `connector.yaml`.

hariso marked this conversation as resolved.
Show resolved Hide resolved
More detailed information about `specgen` and `connector.yaml` can be found in
the [Conduit documentation](https://conduit.io/docs/developing/connectors/connector-specification).
Loading