Skip to content

Add --base-url flag for connector testability#19

Open
robert-chiniquy wants to merge 3 commits intomainfrom
rch/testability/fix-base-url
Open

Add --base-url flag for connector testability#19
robert-chiniquy wants to merge 3 commits intomainfrom
rch/testability/fix-base-url

Conversation

@robert-chiniquy
Copy link

@robert-chiniquy robert-chiniquy commented Feb 8, 2026

Summary

Adds the --base-url CLI flag to enable overriding the default API endpoint for testing purposes.

Changes

  • Added BaseURLField to configuration
  • Updated client/connector to accept and use the base URL override
  • When --base-url is provided, it takes precedence over the default API URL

Files Modified

cmd/baton-cloudflare-zero-trust/config.go,cmd/baton-cloudflare-zero-trust/main.go,pkg/connector/connector.go

Testing

The connector can now be tested against mock servers:

baton-cloudflare-zero-trust --base-url http://localhost:8080 [other-flags]

Related

Part of the Connector Testability initiative.

Summary by CodeRabbit

  • New Features
    • Added support for configuring a custom API endpoint base URL, enabling connection to alternate API environments.

This change adds a --base-url CLI flag to allow overriding the default API
endpoint for testing purposes. When provided, the connector will use this
URL instead of the hardcoded production API URL.

This is part of the Connector Testability initiative to enable mock server
testing without modifying connector code.

Files changed: cmd/baton-cloudflare-zero-trust/config.go,cmd/baton-cloudflare-zero-trust/main.go,pkg/connector/connector.go
@robert-chiniquy robert-chiniquy requested a review from a team February 8, 2026 07:42
@coderabbitai
Copy link

coderabbitai bot commented Feb 8, 2026

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters (1)
  • cmd/baton-cloudflare-zero-trust/config.go is excluded by none and included by none

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Walkthrough

The New function in the connector package now accepts an additional baseURL parameter and conditionally passes it to the underlying Cloudflare client initialization through variadic options when a non-empty baseURL is provided.

Changes

Cohort / File(s) Summary
Connector Configuration
pkg/connector/connector.go
Added baseURL parameter to the New function signature. Function now builds a local options slice and conditionally appends cloudflare.BaseURL(baseURL) before passing options to both API key and API token initialization paths.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A baseURL hops through the gate,
Our connector, now more ornate,
Options flow where once were few,
Flexible paths, both old and new! 🌿

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding a --base-url flag to improve connector testability.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch rch/testability/fix-base-url

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@russellhaering russellhaering left a comment

Choose a reason for hiding this comment

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

LGTM - base-url flag implementation looks correct. Cleanest approach of the batch -- leverages cloudflare-go SDK's native BaseURL option, correctly applied to both API key and API token auth paths.

base-url is a dev/testing concern, not user-facing configuration.
Mark it WithHidden(true) so it doesn't appear in the hosted UI.

Good feedback from Geoff:
ConductorOne/baton-trayai#63 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants