Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
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
  •  
  •  
  •  
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
name: Generate connector capabilities
name: Generate capabilities and config schema

on:
workflow_dispatch:
push:
branches:
- main

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

steps:
Expand All @@ -24,15 +24,17 @@ jobs:
- name: Build
run: go build -o connector ./cmd/baton-cloudflare-zero-trust

- name: Run and save output
env:
BATON_ACCOUNT_ID: example
BATON_API_TOKEN: example
run: ./connector capabilities > baton_capabilities.json
- name: Run and save config output
run: ./connector config > config_schema.json

- name: Run and save capabilities output
run: ./connector --account-id="test" --api-token="test" capabilities > 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'
message: 'Updating baton config schema and capabilities.'
add: |
config_schema.json
baton_capabilities.json
20 changes: 9 additions & 11 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,36 +9,34 @@ 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.23.x
- name: Checkout code
uses: actions/checkout@v4
go-version-file: 'go.mod'
- name: Run linters
uses: golangci/golangci-lint-action@v6
uses: golangci/golangci-lint-action@v8
with:
version: latest
args: --timeout=3m
go-test:
strategy:
matrix:
go-version: [1.23.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: go tests
run: (set -o pipefail && go test -v -covermode=count -json ./... | tee test.json)
run: go test -v -covermode=count -json ./... > test.json
- name: annotate go tests
if: always()
uses: guyarb/golang-test-annotations@v0.5.1
uses: guyarb/golang-test-annotations@v0.6.0
with:
test-results: test.json

Expand Down
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-cloudflare-zero-trust.exe
else
OUTPUT_PATH = ${BUILD_DIR}/baton-cloudflare-zero-trust
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-cloudflare-zero-trust
build: $(GENERATED_CONF)
go build ${BUILD_TAGS} -o ${OUTPUT_PATH} ./cmd/baton-cloudflare-zero-trust

$(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
46 changes: 0 additions & 46 deletions cmd/baton-cloudflare-zero-trust/config.go

This file was deleted.

38 changes: 20 additions & 18 deletions cmd/baton-cloudflare-zero-trust/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,61 +5,63 @@ import (
"fmt"
"os"

configSchema "github.com/conductorone/baton-sdk/pkg/config"
"github.com/conductorone/baton-cloudflare-zero-trust/pkg/connector"
cfg "github.com/conductorone/baton-cloudflare-zero-trust/pkg/config"
"github.com/conductorone/baton-sdk/pkg/config"
"github.com/conductorone/baton-sdk/pkg/connectorbuilder"
"github.com/conductorone/baton-sdk/pkg/connectorrunner"
"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-cloudflare-zero-trust/pkg/connector"
)

const (
version = "dev"
connectorName = "baton-cloudflare-zero-trust"
)
var version = "dev"

func main() {
ctx := context.Background()
_, cmd, err := configSchema.DefineConfiguration(ctx,
connectorName,

_, cmd, err := config.DefineConfiguration(
ctx,
"baton-cloudflare-zero-trust",
getConnector,
fieldConfig,
cfg.Config,
connectorrunner.WithDefaultCapabilitiesConnectorBuilder(&connector.Connector{}),
)
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) {
// getConnector initializes and returns the connector.
func getConnector(ctx context.Context, c *cfg.CloudflareZeroTrust) (types.ConnectorServer, error) {
l := ctxzap.Extract(ctx)

cb, err := connector.New(
ctx,
cfg.GetString(accountIdField.FieldName),
cfg.GetString(apiTokenField.FieldName),
cfg.GetString(apiKeyField.FieldName),
cfg.GetString(emailField.FieldName),
c.AccountId,
c.ApiToken,
c.ApiKey,
c.Email,
)
if err != nil {
l.Error("error creating connector", zap.Error(err))
return nil, err
}

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

return connector, nil
return server, nil
}
23 changes: 11 additions & 12 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
module github.com/conductorone/baton-cloudflare-zero-trust

go 1.23.4
go 1.25.2
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Search for Go version references in configs
rg -n -C 2 'go 1\.25\.2|GOLANG_VERSION|golang:1\.25|1\.25\.2|go 1\.|Go version' --type=toml --type=yaml --type=dockerfile --type=sh .

Repository: ConductorOne/baton-cloudflare-zero-trust

Length of output: 118


🏁 Script executed:

#!/bin/bash
# Also look for CI workflow files
fd -e yaml -e yml . .github/workflows 2>/dev/null | head -20

Repository: ConductorOne/baton-cloudflare-zero-trust

Length of output: 187


🏁 Script executed:

#!/bin/bash
# Check for Dockerfiles
fd -i dockerfile . | head -20

Repository: ConductorOne/baton-cloudflare-zero-trust

Length of output: 193


🏁 Script executed:

#!/bin/bash
# Check for any build/CI related files
find . -maxdepth 3 -type f \( -name ".gitlab-ci.yml" -o -name "*.mk" -o -name "Makefile" -o -name "tox.ini" -o -name ".travis.yml" \) 2>/dev/null

Repository: ConductorOne/baton-cloudflare-zero-trust

Length of output: 94


🏁 Script executed:

cat .github/workflows/ci.yaml

Repository: ConductorOne/baton-cloudflare-zero-trust

Length of output: 2312


🏁 Script executed:

cat .github/workflows/release.yaml

Repository: ConductorOne/baton-cloudflare-zero-trust

Length of output: 720


🏁 Script executed:

cat .github/workflows/capabilities_and_config.yaml

Repository: ConductorOne/baton-cloudflare-zero-trust

Length of output: 1129


🏁 Script executed:

cat Makefile

Repository: ConductorOne/baton-cloudflare-zero-trust

Length of output: 963


🏁 Script executed:

# Check if there's any docker-compose or other container config
fd -i docker-compose . --maxdepth 2

Repository: ConductorOne/baton-cloudflare-zero-trust

Length of output: 66


Update test job in ci.yaml to use Go 1.25.2 from go.mod.

The test job hardcodes go-version: 1.23.x while other CI jobs and go.mod specify 1.25.2. This version mismatch can cause build inconsistencies. Update it to go-version-file: 'go.mod' to align with the rest of the pipeline.

ci.yaml test job (line ~39)
test:
  runs-on: ubuntu-latest
  steps:
    - name: Install Go
      uses: actions/setup-go@v5
      with:
        go-version: 1.23.x  # Change to: go-version-file: 'go.mod'
🤖 Prompt for AI Agents
In `@go.mod` at line 3, The CI test job is hardcoded to Go 1.23.x causing a
mismatch with go.mod (go 1.25.2); edit the test job's Install Go step (the
"test" job and its "Install Go" step in ci.yaml) and replace the go-version:
1.23.x setting with go-version-file: 'go.mod' so the action reads the Go version
from go.mod and aligns the pipeline versions.


require (
github.com/cloudflare/cloudflare-go v0.83.0
github.com/conductorone/baton-sdk v0.3.35
github.com/conductorone/baton-sdk v0.7.10
github.com/ennyjfrick/ruleguard-logfatal v0.0.2
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0
github.com/quasilyte/go-ruleguard/dsl v0.3.22
Expand All @@ -15,6 +15,7 @@ require (
require (
filippo.io/age v1.2.1 // indirect
filippo.io/edwards25519 v1.1.0 // indirect
github.com/Masterminds/semver/v3 v3.4.0 // indirect
github.com/aws/aws-lambda-go v1.47.0 // indirect
github.com/aws/aws-sdk-go-v2 v1.36.3 // indirect
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.10 // indirect
Expand Down Expand Up @@ -43,12 +44,11 @@ require (
github.com/conductorone/dpop/integrations/dpop_oauth2 v0.2.3 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/deckarep/golang-set/v2 v2.7.0 // indirect
github.com/dolthub/maphash v0.1.0 // indirect
github.com/doug-martin/goqu/v9 v9.19.0 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/ebitengine/purego v0.9.1 // indirect
github.com/envoyproxy/protoc-gen-validate v1.2.1 // indirect
github.com/fsnotify/fsnotify v1.8.0 // indirect
github.com/gammazero/deque v1.0.0 // indirect
github.com/glebarez/go-sqlite v1.22.0 // indirect
github.com/go-jose/go-jose/v4 v4.0.5 // indirect
github.com/go-logr/logr v1.4.2 // indirect
Expand All @@ -64,11 +64,11 @@ require (
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jellydator/ttlcache/v3 v3.3.0 // indirect
github.com/klauspost/compress v1.17.11 // indirect
github.com/klauspost/compress v1.18.0 // indirect
github.com/lufia/plan9stats v0.0.0-20240909124753-873cd0166683 // indirect
github.com/magiconair/properties v1.8.9 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/maypok86/otter v1.2.4 // indirect
github.com/maypok86/otter/v2 v2.2.1 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/ncruces/go-strftime v0.1.9 // indirect
github.com/pelletier/go-toml/v2 v2.2.3 // indirect
Expand All @@ -81,17 +81,16 @@ require (
github.com/sagikazarmark/locafero v0.7.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/segmentio/ksuid v1.0.4 // indirect
github.com/shirou/gopsutil/v3 v3.24.5 // indirect
github.com/shoenig/go-m1cpu v0.1.6 // indirect
github.com/shirou/gopsutil/v4 v4.25.11 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/afero v1.12.0 // indirect
github.com/spf13/cast v1.7.1 // indirect
github.com/spf13/cobra v1.8.1 // indirect
github.com/spf13/pflag v1.0.6 // indirect
github.com/stretchr/testify v1.10.0 // indirect
github.com/stretchr/testify v1.11.1 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/tklauser/go-sysconf v0.3.14 // indirect
github.com/tklauser/numcpus v0.9.0 // indirect
github.com/tklauser/go-sysconf v0.3.16 // indirect
github.com/tklauser/numcpus v0.11.0 // indirect
github.com/yusufpapurcu/wmi v1.2.4 // indirect
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
go.opentelemetry.io/contrib/bridges/otelzap v0.10.0 // indirect
Expand All @@ -113,7 +112,7 @@ require (
golang.org/x/net v0.35.0 // indirect
golang.org/x/oauth2 v0.26.0 // indirect
golang.org/x/sync v0.11.0 // indirect
golang.org/x/sys v0.30.0 // indirect
golang.org/x/sys v0.38.0 // indirect
golang.org/x/term v0.29.0 // indirect
golang.org/x/text v0.22.0 // indirect
golang.org/x/time v0.8.0 // indirect
Expand Down
Loading
Loading