Skip to content

Commit

Permalink
Allow configuring cloudflare base url using CF_BASE_URL key (#12)
Browse files Browse the repository at this point in the history
Signed-off-by: Tamal Saha <[email protected]>
  • Loading branch information
tamalsaha authored Jan 7, 2023
1 parent 9503857 commit 2ca03ee
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 11 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -201,4 +201,4 @@ require (
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
)

replace sigs.k8s.io/external-dns => github.com/kubeops/external-dns v0.11.2-0.20221109000240-41ce234ffc5e
replace sigs.k8s.io/external-dns => github.com/kubeops/external-dns v0.11.2-0.20230107143116-9307da40ba75
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -952,8 +952,8 @@ github.com/kr/pty v1.1.5/go.mod h1:9r2w37qlBe7rQ6e1fg1S/9xpWHSnaqNdHD3WcMdbPDA=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/kubeops/external-dns v0.11.2-0.20221109000240-41ce234ffc5e h1:NmR3K6ugP7SoXyG/iQz9jun659vwuWLlMocgNVCFo9A=
github.com/kubeops/external-dns v0.11.2-0.20221109000240-41ce234ffc5e/go.mod h1:PxwL2DeB0bSamqe7WYWBGVMc+cgwJJEHf2uo3nkR4tg=
github.com/kubeops/external-dns v0.11.2-0.20230107143116-9307da40ba75 h1:r2PLArpErZ53gIOGYCbbWsCIlzl5jgDNO8BymgMN1as=
github.com/kubeops/external-dns v0.11.2-0.20230107143116-9307da40ba75/go.mod h1:PxwL2DeB0bSamqe7WYWBGVMc+cgwJJEHf2uo3nkR4tg=
github.com/lann/builder v0.0.0-20180802200727-47ae307949d0/go.mod h1:dXGbAdH5GtBTC4WfIxhKZfyBF/HBFgRZSWwZ9g/He9o=
github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0/go.mod h1:vmVJ0l/dxyfGW6FmdpVm2joNMFikkuWg0EoCKLGUMNw=
github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y=
Expand Down
12 changes: 8 additions & 4 deletions pkg/credentials/cloudflare.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
)

const (
CFBaseURL = "CF_BASE_URL"
CFApiToken = "CF_API_TOKEN"
CFApiKey = "CF_API_KEY"
CFApiEmail = "CF_API_EMAIL"
Expand Down Expand Up @@ -64,13 +65,16 @@ func setCloudflareCredentials(ctx context.Context, kc client.Client, edns *exter
return errors.New("invalid cloudflare provider secret")
}

if string(secret.Data[CFApiToken][:]) != "" {
return os.Setenv("CF_API_TOKEN", string(secret.Data["CF_API_TOKEN"][:]))
if string(secret.Data[CFBaseURL]) != "" {
return os.Setenv(CFBaseURL, string(secret.Data[CFBaseURL]))
}
if string(secret.Data[CFApiToken]) != "" {
return os.Setenv(CFApiToken, string(secret.Data[CFApiToken]))
} else {
if err := os.Setenv(CFApiKey, string(secret.Data[CFApiKey][:])); err != nil {
if err := os.Setenv(CFApiKey, string(secret.Data[CFApiKey])); err != nil {
return err
}
if err := os.Setenv(CFApiEmail, string(secret.Data[CFApiEmail][:])); err != nil {
if err := os.Setenv(CFApiEmail, string(secret.Data[CFApiEmail])); err != nil {
return err
}
}
Expand Down
4 changes: 2 additions & 2 deletions vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1488,7 +1488,7 @@ sigs.k8s.io/controller-runtime/pkg/webhook
sigs.k8s.io/controller-runtime/pkg/webhook/admission
sigs.k8s.io/controller-runtime/pkg/webhook/conversion
sigs.k8s.io/controller-runtime/pkg/webhook/internal/metrics
# sigs.k8s.io/external-dns v0.13.1 => github.com/kubeops/external-dns v0.11.2-0.20221109000240-41ce234ffc5e
# sigs.k8s.io/external-dns v0.13.1 => github.com/kubeops/external-dns v0.11.2-0.20230107143116-9307da40ba75
## explicit; go 1.18
sigs.k8s.io/external-dns/endpoint
sigs.k8s.io/external-dns/pkg/apis/externaldns
Expand Down Expand Up @@ -1560,4 +1560,4 @@ sigs.k8s.io/structured-merge-diff/v4/value
# sigs.k8s.io/yaml v1.3.0
## explicit; go 1.12
sigs.k8s.io/yaml
# sigs.k8s.io/external-dns => github.com/kubeops/external-dns v0.11.2-0.20221109000240-41ce234ffc5e
# sigs.k8s.io/external-dns => github.com/kubeops/external-dns v0.11.2-0.20230107143116-9307da40ba75

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2ca03ee

Please sign in to comment.