Skip to content
Merged
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,18 @@ jobs:
AC_PASSWORD: ${{ secrets.AC_PASSWORD }}
AC_PROVIDER: ${{ secrets.AC_PROVIDER }}
goreleaser-docker:
permissions:
id-token: write
contents: read
runs-on: ubuntu-latest
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::168442440833:role/GitHubActionsECRPushRole-baton-postgresql
aws-region: us-west-2
- name: Login to Amazon ECR
uses: aws-actions/amazon-ecr-login@v2
- name: Checkout
uses: actions/checkout@v4
with:
Expand Down
15 changes: 15 additions & 0 deletions .goreleaser.docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ builds:
goarch:
- amd64
- arm64
tags:
- "baton_lambda_support"
dockers:
- use: buildx
goos: linux
Expand Down Expand Up @@ -38,6 +40,19 @@ dockers:
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
- "--label=org.opencontainers.image.version={{.Version}}"
- "--label=org.opencontainers.image.source=https://github.com/conductorone/baton-postgresql"
- use: buildx
goos: linux
goarch: arm64
dockerfile: Dockerfile.lambda
image_templates:
- "168442440833.dkr.ecr.us-west-2.amazonaws.com/baton-postgresql:{{ .Version }}-arm64"
build_flag_templates:
- "--platform=linux/arm64/v8"
- "--label=org.opencontainers.image.created={{.Date}}"
- "--label=org.opencontainers.image.title=baton-postgresql"
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
- "--label=org.opencontainers.image.version={{.Version}}"
- "--label=org.opencontainers.image.source=https://github.com/conductorone/baton-postgresql"
docker_manifests:
- name_template: ghcr.io/conductorone/baton-postgresql:{{ .Version }}
image_templates:
Expand Down
3 changes: 3 additions & 0 deletions Dockerfile.lambda
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM public.ecr.aws/lambda/provided:al2023
ENTRYPOINT ["/baton-postgresql", "lambda"]
COPY baton-postgresql /
18 changes: 16 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,16 +1,30 @@
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-postgresql.exe
else
OUTPUT_PATH = ${BUILD_DIR}/baton-postgresql
endif

# Set the build tag conditionally based on BATON_LAMBDA_SUPPORT
ifdef BATON_LAMBDA_SUPPORT
BUILD_TAGS=-tags baton_lambda_support
else
BUILD_TAGS=
endif

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

$(GENERATED_CONF): pkg/config/config.go go.mod
@echo "Generating $(GENERATED_CONF)..."
go generate ./pkg/config

generate: $(GENERATED_CONF)

.PHONY: update-deps
update-deps:
Expand Down
8 changes: 4 additions & 4 deletions cmd/baton-postgresql/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import (
"fmt"
"os"

cfg "github.com/conductorone/baton-postgresql/pkg/config"
"github.com/conductorone/baton-sdk/pkg/connectorbuilder"
"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"

"github.com/conductorone/baton-postgresql/pkg/connector"
Expand All @@ -20,7 +20,7 @@ var version = "dev"
func main() {
ctx := context.Background()

_, cmd, err := configschema.DefineConfiguration(ctx, "baton-postgresql", getConnector, configuration)
_, cmd, err := configschema.DefineConfiguration(ctx, "baton-postgresql", getConnector, cfg.Config)
if err != nil {
fmt.Fprintln(os.Stderr, err.Error())
os.Exit(1)
Expand All @@ -35,10 +35,10 @@ func main() {
}
}

func getConnector(ctx context.Context, v *viper.Viper) (types.ConnectorServer, error) {
func getConnector(ctx context.Context, pgc *cfg.Postgresql) (types.ConnectorServer, error) {
l := ctxzap.Extract(ctx)

cb, err := connector.New(ctx, v.GetString("dsn"), v.GetStringSlice("schemas"), v.GetBool("include-columns"), v.GetBool("include-large-objects"))
cb, err := connector.New(ctx, pgc.Dsn, pgc.Schemas, pgc.IncludeColumns, pgc.IncludeLargeObjects)
if err != nil {
l.Error("error creating connector", zap.Error(err))
return nil, err
Expand Down
86 changes: 86 additions & 0 deletions pkg/config/conf.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions cmd/baton-postgresql/config.go → pkg/config/config.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package config

import (
"github.com/conductorone/baton-sdk/pkg/field"
Expand All @@ -13,6 +13,7 @@ var (

var relationships = []field.SchemaFieldRelationship{}

var configuration = field.NewConfiguration([]field.SchemaField{
//go:generate go run ./gen
var Config = field.NewConfiguration([]field.SchemaField{
dsn, schemas, includeColumns, includeLargeObjects,
}, relationships...)
10 changes: 10 additions & 0 deletions pkg/config/gen/gen.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package main

import (
cfg "github.com/conductorone/baton-postgresql/pkg/config"
"github.com/conductorone/baton-sdk/pkg/config"
)

func main() {
config.Generate("postgresql", cfg.Config)
}
Loading