Skip to content

Conversation

@0xJacky
Copy link

@0xJacky 0xJacky commented May 10, 2025

1. Background

lego (commit e9a255d) embedded several full-blown cloud SDKs just to talk to their DNS APIs.

On macOS (MacBook Pro M2 Pro) this produced:

Metric Before (e9a255d) After (this PR) Δ
Binary size 158 MB 80 MB ▼ 49 %
Build time `30.59 s 17.82 s ▼ 42 %

The bottleneck was a handful of vendored SDKs that together weighed ~48 MB of source code:

Package Size
github.com/yandex-cloud/go-genproto 26 MB
github.com/aliyun/alibaba-cloud-sdk-go 9.6 MB
github.com/tencentcloud/tencentcloud-go/tencentcloud/dnspod 3.5 MB
github.com/sacloud/iaas-api-go 3.3 MB
github.com/yandex-cloud/go-sdk 2.0 MB
github.com/cloudflare/cloudflare-go 1.7 MB
github.com/oracle/oci-go-sdk/v65 1.4 MB
github.com/huaweicloud/huaweicloud-sdk-go-v3 1.0 MB

Why simplification is feasible:
The popular ACME client acme.sh performs the same DNS-01 operations with nothing more than shell + curl calls, proving that a lightweight approach is both practical and battle-tested.

2. What this PR does

  • Re-implements seven DNS providers using either

    • 🔹 libdns lightweight interfaces, or
    • 🔹 plain HTTP requests via Go’s std-lib.
  • Removes all the SDKs listed above from go.mod.

  • Phase 1 providers fully migrated & tested (both unit tests and live tests):

    • alidns
    • yandex (Yandex Cloud)
    • tencentdns
    • sakuracloud
    • huaweicloud
    • cloudflare
    • oraclecloud

3. Impact

Aspect Status
Functionality ✔️ No behaviour change – API surface identical.
Binary size ✔️ -77 MB (Mac)
Compile time ✔️ -13 s on M2 Pro; scales across CI.
Dependencies ✔️ SDK count reduced, smaller go.sum, faster go mod download.

4. Future work

  • AWS/Route53 and AWS/lightsail – still drags in the full aws-sdk-go. Plan to replace them with hand-rolled API calls.

5. Checklist

  • Passed all unit tests and live tests
  • No public API changes

@0xJacky 0xJacky marked this pull request as ready for review May 10, 2025 15:07
@ldez ldez closed this May 10, 2025
@ldez ldez added the declined label May 10, 2025
@ldez
Copy link
Member

ldez commented May 10, 2025

This is not something we want to do.

Using official clients is a way to ease the maintenance.

Before doing this type of PR, it's better to open an issue to ask what the project wants.

Also, your PR contains a wrong rebase, a lot of lint issues, design issues, and unrelated changes.

@ldez
Copy link
Member

ldez commented Jul 15, 2025

@0xJacky For your information, I asked DNS providers if they could improve their library size, and some of them did it, so I updated the modules:

v4.23.1 master Δ
without stripping 158MB 98MB -60MB / -38%
with stripping * 109MB 69MB -40MB / -37%

*: This is the way we build the official binaries, and I recommend using it. (go build -trimpath -ldflags '-s -w')

Some other DNS providers will improve their API client size, so this will continue to be improved in the future.

@0xJacky
Copy link
Author

0xJacky commented Jul 15, 2025

Thanks for your hard works! This seems to be a better solution. 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

2 participants