Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions .github/workflows/capabilities_and_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
go-version-file: "go.mod"

- name: Build
run: go build -o connector ./cmd/baton-notion
Expand All @@ -34,7 +34,7 @@ jobs:
uses: EndBug/add-and-commit@v9
with:
default_author: github_actions
message: 'Updating baton config schema and capabilities.'
message: "Updating baton config schema and capabilities."
add: |
config_schema.json
baton_capabilities.json
13 changes: 9 additions & 4 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
name: ci
on: pull_request
on:
pull_request:
types: [opened, reopened, synchronize]
push:
branches:
- main
jobs:
go-lint:
runs-on: ubuntu-latest
Expand All @@ -9,7 +14,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
go-version-file: 'go.mod'
- name: Run linters
uses: golangci/golangci-lint-action@v8
with:
Expand All @@ -27,11 +32,11 @@ jobs:
- name: Install Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
go-version-file: 'go.mod'
- name: go tests
run: go test -v -covermode=count -json ./... > test.json
- name: annotate go tests
if: always()
uses: guyarb/golang-test-annotations@v0.5.1
uses: guyarb/golang-test-annotations@v0.6.0
with:
test-results: test.json
113 changes: 113 additions & 0 deletions CONTAINERIZATION_COMPLETE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
# Baton-Notion Containerization - Complete

## Summary

The baton-notion connector has been successfully containerized following the patterns from baton-databricks PR #35 and baton-contentful PR #48. All code changes have been made and are ready to commit.

## Changes Made

### 1. Created pkg/config Package Structure
- **pkg/config/config.go**: Main configuration file with field definitions and validation
- **pkg/config/conf.gen.go**: Auto-generated configuration struct (Notion type)
- **pkg/config/gen/gen.go**: Generator program for config code generation

### 2. Updated Main Entry Point
- **cmd/baton-notion/main.go**:
- Now imports and uses pkg/config instead of local config
- Uses `cfg.Notion` struct instead of `viper.Viper`
- Added `connectorrunner.WithDefaultCapabilitiesConnectorBuilder`
- Updated getConnector signature to accept `*cfg.Notion`

### 3. Removed Old Configuration
- **Deleted**: cmd/baton-notion/config.go (moved to pkg/config/config.go)

### 4. Updated Build System
- **Makefile**:
- Added GENERATED_CONF variable
- Build now depends on generated config
- Added generate target for config generation

### 5. Updated CI/CD Workflows
- **. github/workflows/ci.yaml**:
- Added push trigger for main branch
- Updated golang-test-annotations to v0.6.0
- Quoted go-version-file values

- **Created .github/workflows/capabilities.yaml**:
- Separate workflow for generating capabilities
- Runs on push to main branch
- Uses BATON_SCIM_TOKEN secret

- **Deleted .github/workflows/capabilities_and_config.yaml**:
- Replaced with separate capabilities workflow
- Config schema now generated automatically by SDK

### 6. Dependency Changes
- **go.mod**: viper moved from direct to indirect dependency

## Branch Status

- **Branch**: containerize-baton-notion
- **Status**: All changes made, ready to commit and push

## Next Steps

To complete the containerization, run these commands:

```bash
cd /Users/laurenleach/go/src/github.com/ConductorOne/baton-notion

# Stage all changes
git add -A

# Commit with detailed message
git commit -m "Containerize baton-notion connector

- Created pkg/config package with generated configuration structure
- Moved configuration from cmd/baton-notion/config.go to pkg/config/config.go
- Added config generation support with pkg/config/gen/gen.go
- Updated main.go to use new config structure and WithDefaultCapabilitiesConnectorBuilder
- Updated Makefile to include config generation as build dependency
- Updated CI workflow to trigger on push to main branch
- Created separate capabilities.yaml workflow
- Removed combined capabilities_and_config.yaml workflow
- Updated golang-test-annotations to v0.6.0

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>"

# Push the branch
git push -u origin containerize-baton-notion
```

## Verification

After pushing, you can verify the changes by:

1. Building locally: `make build`
2. Testing the connector: `./dist/*/baton-notion --help`
3. Generating capabilities: `./dist/*/baton-notion capabilities`
4. Creating a PR on GitHub

## Files Changed

```
D .github/workflows/capabilities_and_config.yaml
M .github/workflows/ci.yaml
A .github/workflows/capabilities.yaml
M Makefile
D cmd/baton-notion/config.go
M cmd/baton-notion/main.go
M go.mod
A pkg/config/config.go
A pkg/config/conf.gen.go
A pkg/config/gen/gen.go
```

## Pattern Consistency

This implementation follows the same pattern as:
- baton-databricks (PR #35)
- baton-contentful (PR #48)
- baton-wiz (recent containerization)

The connector is now fully containerized and ready for use in containerized environments.
10 changes: 9 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
GOOS = $(shell go env GOOS)
GOARCH = $(shell go env GOARCH)
BUILD_DIR = dist/${GOOS}_${GOARCH}
GENERATED_CONF = pkg/config/conf.gen.go

ifeq ($(GOOS),windows)
OUTPUT_PATH = ${BUILD_DIR}/baton-notion.exe
Expand All @@ -9,9 +10,16 @@ OUTPUT_PATH = ${BUILD_DIR}/baton-notion
endif

.PHONY: build
build:
build: $(GENERATED_CONF)
go build -o ${OUTPUT_PATH} ./cmd/baton-notion

$(GENERATED_CONF): pkg/config/config.go go.mod
go generate ./pkg/config

.PHONY: generate
generate:
go generate ./pkg/config

.PHONY: update-deps
update-deps:
go get -d -u ./...
Expand Down
28 changes: 0 additions & 28 deletions cmd/baton-notion/config.go

This file was deleted.

50 changes: 7 additions & 43 deletions cmd/baton-notion/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,60 +6,24 @@ import (
"os"

"github.com/conductorone/baton-notion/pkg/connector"
"github.com/conductorone/baton-sdk/pkg/config"
"github.com/conductorone/baton-sdk/pkg/connectorbuilder"
"github.com/conductorone/baton-sdk/pkg/field"
"github.com/conductorone/baton-sdk/pkg/types"
"github.com/grpc-ecosystem/go-grpc-middleware/logging/zap/ctxzap"
"github.com/spf13/viper"
"go.uber.org/zap"
cfg "github.com/conductorone/baton-notion/pkg/config"
"github.com/conductorone/baton-sdk/pkg/connectorrunner"
)

var version = "dev"

func main() {
ctx := context.Background()

_, cmd, err := config.DefineConfiguration(
err := connectorrunner.RunConnector(
ctx,
"baton-notion",
getConnector,
field.Configuration{
Fields: ConfigurationFields,
},
version,
cfg.Config,
connector.New,
connectorrunner.WithDefaultCapabilitiesConnectorBuilder(&connector.Connector{}),
)
if err != nil {
fmt.Fprintln(os.Stderr, err.Error())
os.Exit(1)
}

cmd.Version = version

err = cmd.Execute()
if err != nil {
fmt.Fprintln(os.Stderr, err.Error())
os.Exit(1)
}
}

func getConnector(ctx context.Context, v *viper.Viper) (types.ConnectorServer, error) {
l := ctxzap.Extract(ctx)
if err := ValidateConfig(v); err != nil {
return nil, err
}

scimToken := v.GetString(scimTokenFlag)

cb, err := connector.New(ctx, scimToken)
if err != nil {
l.Error("error creating connector", zap.Error(err))
return nil, err
}

c, err := connectorbuilder.NewConnector(ctx, cb)
if err != nil {
l.Error("error creating connector", zap.Error(err))
return nil, err
}
return c, nil
}
23 changes: 11 additions & 12 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
module github.com/conductorone/baton-notion

go 1.25
go 1.25.2

require (
github.com/conductorone/baton-sdk v0.4.2
github.com/conductorone/baton-sdk v0.7.10
github.com/ennyjfrick/ruleguard-logfatal v0.0.2
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0
github.com/quasilyte/go-ruleguard/dsl v0.3.22
github.com/spf13/viper v1.20.1
go.uber.org/zap v1.27.0
google.golang.org/grpc v1.71.0
)

require (
filippo.io/age v1.2.1 // indirect
filippo.io/edwards25519 v1.1.0 // indirect
github.com/Masterminds/semver/v3 v3.4.0 // indirect
github.com/aws/aws-lambda-go v1.47.0 // indirect
github.com/aws/aws-sdk-go-v2 v1.36.3 // indirect
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.10 // indirect
Expand Down Expand Up @@ -42,12 +41,11 @@ require (
github.com/conductorone/dpop/integrations/dpop_grpc v0.2.3 // indirect
github.com/conductorone/dpop/integrations/dpop_oauth2 v0.2.3 // indirect
github.com/deckarep/golang-set/v2 v2.7.0 // indirect
github.com/dolthub/maphash v0.1.0 // indirect
github.com/doug-martin/goqu/v9 v9.19.0 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/ebitengine/purego v0.9.1 // indirect
github.com/envoyproxy/protoc-gen-validate v1.2.1 // indirect
github.com/fsnotify/fsnotify v1.8.0 // indirect
github.com/gammazero/deque v1.0.0 // indirect
github.com/glebarez/go-sqlite v1.22.0 // indirect
github.com/go-jose/go-jose/v4 v4.0.5 // indirect
github.com/go-logr/logr v1.4.2 // indirect
Expand All @@ -62,7 +60,7 @@ require (
github.com/klauspost/compress v1.18.0 // indirect
github.com/lufia/plan9stats v0.0.0-20240909124753-873cd0166683 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/maypok86/otter v1.2.4 // indirect
github.com/maypok86/otter/v2 v2.2.1 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/ncruces/go-strftime v0.1.9 // indirect
github.com/pelletier/go-toml/v2 v2.2.3 // indirect
Expand All @@ -73,16 +71,16 @@ require (
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
github.com/sagikazarmark/locafero v0.7.0 // indirect
github.com/segmentio/ksuid v1.0.4 // indirect
github.com/shirou/gopsutil/v3 v3.24.5 // indirect
github.com/shoenig/go-m1cpu v0.1.6 // indirect
github.com/shirou/gopsutil/v4 v4.25.11 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/afero v1.12.0 // indirect
github.com/spf13/cast v1.7.1 // indirect
github.com/spf13/cobra v1.8.1 // indirect
github.com/spf13/pflag v1.0.6 // indirect
github.com/spf13/viper v1.20.1 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/tklauser/go-sysconf v0.3.14 // indirect
github.com/tklauser/numcpus v0.9.0 // indirect
github.com/tklauser/go-sysconf v0.3.16 // indirect
github.com/tklauser/numcpus v0.11.0 // indirect
github.com/yusufpapurcu/wmi v1.2.4 // indirect
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
go.opentelemetry.io/contrib/bridges/otelzap v0.10.0 // indirect
Expand All @@ -99,12 +97,13 @@ require (
go.opentelemetry.io/proto/otlp v1.5.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/ratelimit v0.3.1 // indirect
go.uber.org/zap v1.27.0 // indirect
golang.org/x/crypto v0.34.0 // indirect
golang.org/x/exp v0.0.0-20250128182459-e0ece0dbea4c // indirect
golang.org/x/net v0.35.0 // indirect
golang.org/x/oauth2 v0.26.0 // indirect
golang.org/x/sync v0.11.0 // indirect
golang.org/x/sys v0.30.0 // indirect
golang.org/x/sys v0.38.0 // indirect
golang.org/x/term v0.29.0 // indirect
golang.org/x/text v0.22.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20250218202821-56aae31c358a // indirect
Expand Down
Loading
Loading