Skip to content

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

Merged
robert-chiniquy merged 3 commits intomainfrom
rch/testability/fix-base-url
Mar 5, 2026
Merged

Add --base-url flag for connector testability#9
robert-chiniquy merged 3 commits intomainfrom
rch/testability/fix-base-url

Conversation

@robert-chiniquy
Copy link
Contributor

@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-fastly/main.go,pkg/config/conf.gen.go,pkg/config/config.go,pkg/connector/connector.go

Testing

The connector can now be tested against mock servers:

baton-fastly --base-url http://localhost:8080 [other-flags]

Related

Part of the Connector Testability initiative.

Summary by CodeRabbit

  • New Features
    • Added configuration option to override the Fastly API URL, enabling easier testing and development workflows with alternative endpoints.

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-fastly/main.go,pkg/config/conf.gen.go,pkg/config/config.go,pkg/connector/connector.go
@robert-chiniquy robert-chiniquy requested a review from a team February 8, 2026 07:51
@coderabbitai
Copy link

coderabbitai bot commented Feb 8, 2026

Warning

Rate limit exceeded

@robert-chiniquy has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 1 minutes and 59 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

Walkthrough

The changes introduce a new "base-url" configuration parameter to override the Fastly API URL for testing purposes. A BaseUrl field is added to the generated Fastly struct, a new StringField configuration is created, and the connector's initialization function is updated to accept and conditionally use the baseURL parameter.

Changes

Cohort / File(s) Summary
Configuration Definitions
pkg/config/conf.gen.go, pkg/config/config.go
Added BaseUrl field to Fastly struct and introduced a new BaseURLField StringField configuration with description "Override the Fastly API URL (for testing)". Configuration schema expanded to include the new field.
Connector Initialization
pkg/connector/connector.go
Updated New function signature to accept baseURL parameter. Conditional logic added: if baseURL is provided, client is created via fastly.NewClientForEndpoint(); otherwise via fastly.NewClient(). Current user is retrieved post-initialization to populate the Fastly instance.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A URL base-d dream takes flight,
Configuration blooms, shining bright,
Conditional paths, both left and right,
Testing awaits in fresh sunlight! ✨

🚥 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 'Add --base-url flag for connector testability' clearly and specifically describes the main change: adding a new CLI flag for base URL configuration to enable testing against alternative endpoints.
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. Properly uses fastly.NewClientForEndpoint when baseURL is non-empty, falls back to fastly.NewClient for default behavior.

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)
@robert-chiniquy robert-chiniquy merged commit 631079e into main Mar 5, 2026
5 checks passed
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