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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
34 changes: 34 additions & 0 deletions .github/workflows/capabilities.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Generate connector capabilities

on:
push:
branches:
- main

jobs:
calculate-capabilities:
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-expensify

- name: Run and save output
run: ./connector capabilities --partner-user-id "test-id" --partner-user-secret "test-secret" > baton_capabilities.json

- name: Commit changes
uses: EndBug/add-and-commit@v9
with:
default_author: github_actions
message: 'Updating baton capabilities.'
add: 'baton_capabilities.json'
35 changes: 35 additions & 0 deletions .github/workflows/output_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Output config schema

on:
push:
branches:
- main

jobs:
output-config-schema:
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-expensify

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

- name: Commit changes
uses: EndBug/add-and-commit@v9
with:
default_author: github_actions
message: 'Updating config schema.'
add: 'config_schema.json'
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-expensify
aws-region: us-west-2
- name: Login to Amazon ECR
uses: aws-actions/amazon-ecr-login@v2
- name: Checkout
uses: actions/checkout@v2
with:
Expand Down
2 changes: 1 addition & 1 deletion .gon-arm64.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"source": ["./dist/macos-arm64_darwin_arm64/baton-expensify"],
"source": ["./dist/macos-arm64_darwin_arm64_v8.0/baton-expensify"],
"bundle_id": "com.conductorone.baton-expensify",
"apple_id": {
"username" : "justin.gallardo@conductorone.com"
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-expensify"
- use: buildx
goos: linux
goarch: arm64
dockerfile: Dockerfile.lambda
image_templates:
- "168442440833.dkr.ecr.us-west-2.amazonaws.com/baton-expensify:{{ .Version }}-arm64"
build_flag_templates:
- "--platform=linux/arm64/v8"
- "--label=org.opencontainers.image.created={{.Date}}"
- "--label=org.opencontainers.image.title=baton-expensify"
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
- "--label=org.opencontainers.image.version={{.Version}}"
- "--label=org.opencontainers.image.source=https://github.com/conductorone/baton-expensify"
docker_manifests:
- name_template: ghcr.io/conductorone/baton-expensify:{{ .Version }}
image_templates:
Expand Down
2 changes: 1 addition & 1 deletion .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ builds:
hooks:
post:
- gon .gon-arm64.json
- mv dist/baton-expensify-darwin-arm64.signed.zip dist/macos-arm64_darwin_arm64/baton-expensify
- mv dist/baton-expensify-darwin-arm64.signed.zip dist/macos-arm64_darwin_arm64_v8.0/baton-expensify
archives:
- id: linux-archive
builds:
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-expensify", "lambda"]
COPY baton-expensify /
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-expensify.exe
else
OUTPUT_PATH = ${BUILD_DIR}/baton-expensify
endif

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

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

$(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
36 changes: 0 additions & 36 deletions cmd/baton-expensify/config.go

This file was deleted.

22 changes: 12 additions & 10 deletions cmd/baton-expensify/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ import (
"fmt"
"os"

cfg "github.com/conductorone/baton-expensify/pkg/config"
"github.com/conductorone/baton-expensify/pkg/connector"
"github.com/conductorone/baton-sdk/pkg/cli"
"github.com/conductorone/baton-sdk/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"
Expand All @@ -18,15 +19,18 @@ var version = "dev"
func main() {
ctx := context.Background()

cfg := &config{}
cmd, err := cli.NewCmd(ctx, "baton-expensify", cfg, validateConfig, getConnector)
_, cmd, err := config.DefineConfiguration(
ctx,
"baton-expensify",
getConnector,
cfg.Config,
)
if err != nil {
fmt.Fprintln(os.Stderr, err.Error())
os.Exit(1)
}

cmd.Version = version
cmdFlags(cmd)

err = cmd.Execute()
if err != nil {
Expand All @@ -35,20 +39,18 @@ func main() {
}
}

func getConnector(ctx context.Context, cfg *config) (types.ConnectorServer, error) {
func getConnector(ctx context.Context, ec *cfg.Expensify) (types.ConnectorServer, error) {
l := ctxzap.Extract(ctx)

cb, err := connector.New(ctx, cfg.PartnerUserID, cfg.PartnerUserSecret)
cb, err := connector.New(ctx, ec.PartnerUserId, ec.PartnerUserSecret)
if err != nil {
l.Error("error creating connector", zap.Error(err))
return nil, err
}

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

return c, nil
return connector, nil
}
Loading
Loading