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
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
39 changes: 0 additions & 39 deletions .github/workflows/capabilities.yaml

This file was deleted.

46 changes: 46 additions & 0 deletions .github/workflows/capabilities_and_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Generate capabilities and config schema

on:
push:
branches:
- main

jobs:
generate_outputs:
if: github.actor != 'github-actions[bot]'
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
token: ${{ secrets.RELENG_GITHUB_TOKEN }}

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: "go.mod"

- name: Build
run: go build -o connector ./cmd/baton-google-bigquery

- name: Run and save config output
run: ./connector config > config_schema.json

- name: Write credentials to file
run: |
cat << EOF > ./creds.json
${{ secrets.BATON_CREDENTIALS_JSON }}
EOF

- name: Run and save capabilities output
run: ./connector capabilities --credentials-json-file-path=creds.json > baton_capabilities.json

- name: Commit changes
uses: EndBug/add-and-commit@v9
with:
default_author: github_actions
message: "Updating baton config schema and capabilities."
add: |
config_schema.json
baton_capabilities.json
35 changes: 23 additions & 12 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,34 +1,43 @@
name: ci
on: pull_request

on:
pull_request:
types: [opened, reopened, synchronize]
push:
branches:
- main
jobs:
go-lint:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: 1.22.x
- name: Checkout code
uses: actions/checkout@v4
go-version-file: go.mod
- name: Generate config
run: make gen
- name: Run linters
uses: golangci/golangci-lint-action@v4
uses: golangci/golangci-lint-action@v8
with:
version: latest
args: --timeout=3m
go-test:
strategy:
matrix:
go-version: [1.22.x]
platform: [ubuntu-latest]
runs-on: ${{ matrix.platform }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Go
if: success()
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@v4
go-version-file: go.mod
- name: Generate config
run: make gen
- name: go tests
run: (set -o pipefail && go test -v -covermode=count -json ./... | tee test.json)
- name: annotate go tests
Expand All @@ -45,12 +54,14 @@ jobs:
BATON: baton
BATON_GOOGLE_BIGQUERY: ./baton-google-bigquery
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: 1.22.x
- name: Checkout code
uses: actions/checkout@v4
go-version-file: go.mod
- name: Generate config
run: make gen
- name: Build baton-google-bigquery
run: go build ./cmd/baton-google-bigquery
- name: Install baton
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ jobs:
uses: ConductorOne/github-workflows/.github/workflows/release.yaml@v4
with:
tag: ${{ github.ref_name }}
lambda: false
secrets:
RELENG_GITHUB_TOKEN: ${{ secrets.RELENG_GITHUB_TOKEN }}
APPLE_SIGNING_KEY_P12: ${{ secrets.APPLE_SIGNING_KEY_P12 }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*.so
*.dylib
*.c1z
baton-google-bigquery

# Test binary, built with `go test -c`
*.test
Expand Down
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
version: "2"
linters-settings:
exhaustive:
default-signifies-exhaustive: true
Expand Down
12 changes: 11 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-google-bigquery.exe
Expand All @@ -9,9 +10,15 @@ OUTPUT_PATH = ${BUILD_DIR}/baton-google-bigquery
endif

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

$(GENERATED_CONF): pkg/config/config.go go.mod
@echo "Generating $(GENERATED_CONF)..."
go run pkg/config/gen/gen.go > $(GENERATED_CONF)

generate: $(GENERATED_CONF)

.PHONY: update-deps
update-deps:
go get -d -u ./...
Expand All @@ -26,3 +33,6 @@ add-dep:
.PHONY: lint
lint:
golangci-lint run

.PHONY: gen
gen: $(GENERATED_CONF)
57 changes: 5 additions & 52 deletions cmd/baton-google-bigquery/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,63 +2,16 @@ package main

import (
"context"
"fmt"
"os"

cfg "github.com/conductorone/baton-google-bigquery/pkg/config"
"github.com/conductorone/baton-google-bigquery/pkg/connector"
configSchema "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"
"github.com/conductorone/baton-sdk/pkg/config"
"github.com/conductorone/baton-sdk/pkg/connectorrunner"
)

const (
version = "dev"
connectorName = "baton-google-bigquery"
credentialsJSONFilePath = "credentials-json-file-path"
)

var (
credentialsJSONFilePathField = field.StringField(credentialsJSONFilePath, field.WithRequired(true), field.WithDescription("JSON credentials file name for the Google identity platform account."))
configurationFields = []field.SchemaField{credentialsJSONFilePathField}
)
var version = "dev"

func main() {
ctx := context.Background()
_, cmd, err := configSchema.DefineConfiguration(ctx,
connectorName,
getConnector,
field.NewConfiguration(configurationFields),
)
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, cfg *viper.Viper) (types.ConnectorServer, error) {
l := ctxzap.Extract(ctx)
cb, err := connector.New(ctx, cfg.GetString(credentialsJSONFilePath))
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
config.RunConnector(ctx, "baton-google-bigquery", version, cfg.Config, connector.New, connectorrunner.WithDefaultCapabilitiesConnectorBuilderV2(&connector.GoogleBigQuery{}))
}
13 changes: 13 additions & 0 deletions git_commands.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
cd /Users/laurenleach/go/src/github.com/ConductorOne/baton-google-bigquery

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

interestingly the leftover file here is different than in a few other repos.

git add pkg/config
git add .github/workflows/capabilities_and_config.yaml
git add Makefile
git add cmd/baton-google-bigquery/main.go
git add .github/workflows/ci.yaml
git add .github/workflows/release.yaml
git add go.mod
git add pkg/connector/connector.go
git rm .github/workflows/capabilities.yaml
git rm .github/workflows/main.yaml
git status
Loading
Loading