Skip to content

Commit

Permalink
Generate connector yaml (#180)
Browse files Browse the repository at this point in the history
  • Loading branch information
lovromazgon authored Feb 4, 2025
1 parent 421eaf1 commit 42c3104
Show file tree
Hide file tree
Showing 28 changed files with 909 additions and 521 deletions.
46 changes: 45 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: release
on:
push:
tags:
- v*
- '*'

permissions:
contents: write
Expand All @@ -18,6 +18,50 @@ jobs:
with:
fetch-depth: 0

- name: Validate Tag Format
run: |
TAG=${GITHUB_REF#refs/tags/}
SV_REGEX="^v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-((0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*)(\.(0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*))*))?(\+([0-9a-zA-Z-]+(\.[0-9a-zA-Z-]+)*))?$"
if ! [[ $TAG =~ $SV_REGEX ]]; then
echo "$TAG is NOT a valid tag (expected format: v<semver>)"
exit 1
fi
- name: Check Version Consistency
run: |
# Extract tag and remove 'v' prefix if exists
TAG=${GITHUB_REF#refs/tags/}
# Read version from connector.yaml
YAML_VERSION=$(yq e '.specification.version' connector.yaml)
# Compare versions
if [[ "$TAG" != "$YAML_VERSION" ]]; then
echo "Version mismatch detected:"
echo "Git Tag: $TAG"
echo "connector.yaml Version: $YAML_VERSION"
exit 1
fi
- name: Delete Invalid Tag
if: failure()
uses: actions/github-script@v7
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const tag = context.ref.replace('refs/tags/', '')
try {
await github.rest.git.deleteRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: `tags/${tag}`
})
} catch (error) {
console.log('Error deleting tag:', error)
}
- name: Set up Go
uses: actions/setup-go@v5
with:
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ test: test-kafka test-redpanda
.PHONY: generate
generate:
go generate ./...
conn-sdk-cli readmegen -w

.PHONY: fmt
fmt: ## Format Go files using gofumpt and gci.
Expand Down
306 changes: 241 additions & 65 deletions README.md

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions common/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ type Config struct {
}

// Validate executes manual validations beyond what is defined in struct tags.
func (c Config) Validate() error {
func (c Config) Validate(ctx context.Context) error {
var multierr []error

if err := c.ConfigSASL.Validate(); err != nil {
if err := c.ConfigSASL.Validate(ctx); err != nil {
multierr = append(multierr, err)
}
if err := c.ConfigTLS.Validate(); err != nil {
if err := c.ConfigTLS.Validate(ctx); err != nil {
multierr = append(multierr, err)
}

Expand Down
2 changes: 1 addition & 1 deletion common/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func TestConfig_Validate(t *testing.T) {
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
is := is.New(t)
err := tc.cfg.Validate()
err := tc.cfg.Validate(context.Background())
is.True(err != nil)
if actualErr, ok := tc.wantErr.(error); ok {
is.True(errors.Is(err, actualErr))
Expand Down
3 changes: 2 additions & 1 deletion common/sasl.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package common

import (
"context"
"errors"
"fmt"

Expand All @@ -36,7 +37,7 @@ type ConfigSASL struct {
}

// Validate executes manual validations beyond what is defined in struct tags.
func (c ConfigSASL) Validate() error {
func (c ConfigSASL) Validate(context.Context) error {
var multierr []error

if _, err := c.sasl(); err != nil {
Expand Down
3 changes: 2 additions & 1 deletion common/tls.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package common

import (
"context"
"crypto/tls"
"crypto/x509"
"fmt"
Expand All @@ -36,7 +37,7 @@ type ConfigTLS struct {
}

// Validate executes manual validations beyond what is defined in struct tags.
func (c ConfigTLS) Validate() error {
func (c ConfigTLS) Validate(context.Context) error {
_, err := c.tls()
return err
}
Expand Down
11 changes: 10 additions & 1 deletion connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,25 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:generate conn-sdk-cli 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 version = "(devel)"

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

0 comments on commit 42c3104

Please sign in to comment.