Skip to content

Commit a429b0d

Browse files
Merge pull request #21 from ConductorOne/luisinasantos/containerize-connector
Containerize connector
2 parents ad63751 + eaf4590 commit a429b0d

File tree

9 files changed

+58
-174
lines changed

9 files changed

+58
-174
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Generate capabilities and config schema
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
generate_outputs:
10+
if: github.actor != 'github-actions[bot]'
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
with:
17+
token: ${{ secrets.RELENG_GITHUB_TOKEN }}
18+
19+
- name: Setup Go
20+
uses: actions/setup-go@v5
21+
with:
22+
go-version-file: "go.mod"
23+
24+
- name: Build
25+
run: go build -o connector ./cmd/baton-tableau
26+
27+
- name: Run and save config output
28+
run: ./connector config > config_schema.json
29+
30+
- name: Run and save capabilities output
31+
env:
32+
BATON_ACCESS_TOKEN_NAME: ${{ secrets.BATON_ACCESS_TOKEN_NAME }}
33+
BATON_ACCESS_TOKEN_SECRET: ${{ secrets.BATON_ACCESS_TOKEN_SECRET }}
34+
BATON_SERVER_PATH: ${{ secrets.BATON_SERVER_PATH }}
35+
run: ./connector capabilities > baton_capabilities.json
36+
37+
- name: Commit changes
38+
uses: EndBug/add-and-commit@v9
39+
with:
40+
default_author: github_actions
41+
message: "Updating baton config schema and capabilities."
42+
add: |
43+
config_schema.json
44+
baton_capabilities.json

.github/workflows/release.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ jobs:
99
release:
1010
uses: ConductorOne/github-workflows/.github/workflows/release.yaml@v2
1111
with:
12-
lambda: false
1312
tag: ${{ github.ref_name }}
1413
secrets:
1514
RELENG_GITHUB_TOKEN: ${{ secrets.RELENG_GITHUB_TOKEN }}

.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-tableau", "lambda"]
3+
COPY baton-tableau /

cmd/baton-tableau/main.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func main() {
2525
_, cmd, err := config.DefineConfiguration(
2626
ctx,
2727
"baton-tableau",
28-
getConnector[*cfg.Tableau],
28+
getConnector,
2929
cfg.Config,
3030
)
3131
if err != nil {
@@ -42,18 +42,18 @@ func main() {
4242
}
4343
}
4444

45-
func getConnector[T field.Configurable](ctx context.Context, config T) (types.ConnectorServer, error) {
45+
func getConnector(ctx context.Context, tc *cfg.Tableau) (types.ConnectorServer, error) {
4646
l := ctxzap.Extract(ctx)
47-
if err := field.Validate(cfg.Config, config); err != nil {
47+
if err := field.Validate(cfg.Config, tc); err != nil {
4848
return nil, err
4949
}
5050

51-
apiVersion := config.GetString(cfg.APIVersion.FieldName)
51+
apiVersion := tc.ApiVersion
5252
if apiVersion == "" {
5353
apiVersion = "3.17"
5454
}
5555

56-
serverPath := config.GetString(cfg.ServerPath.FieldName)
56+
serverPath := tc.ServerPath
5757
baseUrl, err := url.JoinPath("https://", serverPath, "api", apiVersion)
5858
if err != nil {
5959
l.Error("error creating base url", zap.Error(err))
@@ -62,9 +62,9 @@ func getConnector[T field.Configurable](ctx context.Context, config T) (types.Co
6262
cb, err := connector.New(
6363
ctx,
6464
baseUrl,
65-
config.GetString(cfg.SiteID.FieldName),
66-
config.GetString(cfg.AccessTokenName.FieldName),
67-
config.GetString(cfg.AccessTokenSecret.FieldName),
65+
tc.SiteId,
66+
tc.AccessTokenName,
67+
tc.AccessTokenSecret,
6868
)
6969
if err != nil {
7070
l.Error("error creating connector", zap.Error(err))

pkg/config/config.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,22 @@ import (
77
var (
88
AccessTokenName = field.StringField(
99
"access-token-name",
10+
field.WithRequired(true),
1011
field.WithDisplayName("Access Token Name"),
1112
field.WithDescription("Access token name used to connect to the Tableau API"),
1213
)
1314

1415
AccessTokenSecret = field.StringField(
1516
"access-token-secret",
17+
field.WithRequired(true),
1618
field.WithDisplayName("Access Token Secret"),
1719
field.WithDescription("Access token secret used to connect to the Tableau API"),
1820
field.WithIsSecret(true),
1921
)
2022

2123
ServerPath = field.StringField(
2224
"server-path",
25+
field.WithRequired(true),
2326
field.WithDisplayName("Server Path"),
2427
field.WithDescription("Base URL of your Tableau Server or Tableau Cloud instance"),
2528
)

0 commit comments

Comments
 (0)