Skip to content

Commit a038e9d

Browse files
authored
containerize connector (#36)
* containerize connector * fix lint
1 parent 3cfb7a7 commit a038e9d

File tree

12 files changed

+163
-242
lines changed

12 files changed

+163
-242
lines changed
Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
name: Generate connector capabilities
1+
name: Generate capabilities and config schema
22

33
on:
44
push:
55
branches:
66
- main
77

88
jobs:
9-
calculate-capabilities:
9+
generate_outputs:
10+
if: github.actor != 'github-actions[bot]'
1011
runs-on: ubuntu-latest
1112

1213
steps:
@@ -18,21 +19,26 @@ jobs:
1819
- name: Setup Go
1920
uses: actions/setup-go@v5
2021
with:
21-
go-version-file: 'go.mod'
22+
go-version-file: "go.mod"
2223

2324
- name: Build
2425
run: go build -o connector ./cmd/baton-auth0
2526

26-
- name: Run and save output
27+
- name: Run and save config output
28+
run: ./connector config > config_schema.json
29+
30+
- name: Run and save capabilities output
2731
env:
2832
BATON_AUTH0_BASE_URL: "https://dev-n8a8p1kmt7k0ebdz.us.auth0.com"
29-
BATON_AUTH0_CLIENT_ID: EiajnMCHSnpjNdhAtQZ3SkG2cxE7JGII
33+
BATON_AUTH0_CLIENT_ID: "EiajnMCHSnpjNdhAtQZ3SkG2cxE7JGII"
3034
BATON_AUTH0_CLIENT_SECRET: ${{ secrets.BATON_AUTH0_CLIENT_SECRET }}
3135
run: ./connector capabilities > baton_capabilities.json
3236

3337
- name: Commit changes
3438
uses: EndBug/add-and-commit@v9
3539
with:
3640
default_author: github_actions
37-
message: 'Updating baton capabilities.'
38-
add: 'baton_capabilities.json'
41+
message: "Updating baton config schema and capabilities."
42+
add: |
43+
config_schema.json
44+
baton_capabilities.json

.github/workflows/release.yaml

Lines changed: 5 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -6,56 +6,8 @@ on:
66
- '*'
77

88
jobs:
9-
goreleaser:
10-
runs-on: macos-latest
11-
steps:
12-
- name: Checkout
13-
uses: actions/checkout@v4
14-
with:
15-
fetch-depth: 0
16-
- name: Set up Go
17-
uses: actions/setup-go@v5
18-
with:
19-
go-version: 1.22.x
20-
- name: Set up Gon
21-
run: brew tap conductorone/gon && brew install conductorone/gon/gon
22-
- name: Import Keychain Certs
23-
uses: apple-actions/import-codesign-certs@v1
24-
with:
25-
p12-file-base64: ${{ secrets.APPLE_SIGNING_KEY_P12 }}
26-
p12-password: ${{ secrets.APPLE_SIGNING_KEY_P12_PASSWORD }}
27-
- name: Run GoReleaser
28-
uses: goreleaser/goreleaser-action@v6
29-
with:
30-
version: "~> v2"
31-
args: release --clean
32-
env:
33-
GITHUB_TOKEN: ${{ secrets.RELENG_GITHUB_TOKEN }}
34-
AC_PASSWORD: ${{ secrets.AC_PASSWORD }}
35-
AC_PROVIDER: ${{ secrets.AC_PROVIDER }}
36-
goreleaser-docker:
37-
runs-on: ubuntu-latest
38-
steps:
39-
- name: Checkout
40-
uses: actions/checkout@v4
41-
with:
42-
fetch-depth: 0
43-
- name: Set up Go
44-
uses: actions/setup-go@v5
45-
with:
46-
go-version: 1.22.x
47-
- name: Docker Login
48-
uses: docker/login-action@v1
49-
with:
50-
registry: ghcr.io
51-
username: ${{ github.repository_owner }}
52-
password: ${{ secrets.RELENG_GITHUB_TOKEN }}
53-
- name: Set up Docker Buildx
54-
uses: docker/setup-buildx-action@v1
55-
- name: Run GoReleaser
56-
uses: goreleaser/goreleaser-action@v6
57-
with:
58-
version: "~> v2"
59-
args: release --clean -f .goreleaser.docker.yaml
60-
env:
61-
GITHUB_TOKEN: ${{ secrets.RELENG_GITHUB_TOKEN }}
9+
release:
10+
uses: ConductorOne/github-workflows/.github/workflows/release.yaml@v2
11+
with:
12+
tag: ${{ github.ref_name }}
13+
lambda: true

.gon-amd64.json

Lines changed: 0 additions & 13 deletions
This file was deleted.

.gon-arm64.json

Lines changed: 0 additions & 13 deletions
This file was deleted.

.goreleaser.docker.yaml

Lines changed: 0 additions & 55 deletions
This file was deleted.

.goreleaser.yaml

Lines changed: 0 additions & 84 deletions
This file was deleted.

Dockerfile.lambda

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
FROM public.ecr.aws/lambda/provided:al2023
2+
ENTRYPOINT ["/baton-auth0", "lambda"]
3+
COPY baton-auth0 /

Makefile

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,39 @@
11
GOOS = $(shell go env GOOS)
22
GOARCH = $(shell go env GOARCH)
33
BUILD_DIR = dist/${GOOS}_${GOARCH}
4+
GENERATED_CONF := pkg/config/conf.gen.go
45

56
ifeq ($(GOOS),windows)
67
OUTPUT_PATH = ${BUILD_DIR}/baton-auth0.exe
78
else
89
OUTPUT_PATH = ${BUILD_DIR}/baton-auth0
910
endif
1011

12+
# Set the build tag conditionally based on ENABLE_LAMBDA
13+
ifdef BATON_LAMBDA_SUPPORT
14+
BUILD_TAGS=-tags baton_lambda_support
15+
else
16+
BUILD_TAGS=
17+
endif
18+
1119
.PHONY: build
12-
build:
13-
go build -o ${OUTPUT_PATH} ./cmd/baton-auth0
20+
build: $(GENERATED_CONF)
21+
go build ${BUILD_TAGS} -o ${OUTPUT_PATH} ./cmd/baton-auth0
22+
23+
$(GENERATED_CONF): pkg/config/schema.go go.mod
24+
@echo "Generating $(GENERATED_CONF)..."
25+
go generate ./pkg/config
26+
27+
generate: $(GENERATED_CONF)
1428

1529
.PHONY: update-deps
1630
update-deps:
1731
go get -d -u ./...
1832
go mod tidy -v
1933
go mod vendor
2034

21-
.PHONY: add-dep
22-
add-dep:
35+
.PHONY: add-deps
36+
add-deps:
2337
go mod tidy -v
2438
go mod vendor
2539

cmd/baton-auth0/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func main() {
2727
ctx,
2828
connectorName,
2929
getConnector,
30-
config2.ConfigurationSchema,
30+
config2.Config,
3131
)
3232
if err != nil {
3333
fmt.Fprintln(os.Stderr, err.Error())

0 commit comments

Comments
 (0)