external-dns/vendor/github.com/cloudflare/cloudflare-go/options.go
Nick Jüttner cb5863344b CloudFlare as a new provider (#140)
* CloudFlare Provider

* updating glide

* gofmt cloudflare_test.go

* Unset envs to test NewCloudFlareProvider

* More tests

* fix(cloudflare): fix compiler errors resulting from merge

* Typo

* Undo vendor changes

* decrease api calls, fix some nits

* Cloudflare iteration (#2)

* reduce the number of API calls

* match by type and name for record id

* improve coverage and fix the bug with suitable zone

* tests failed due to wrong formatting

* add cloudflare integration to the main

* vendor cloudflare deps

* fix cloudflare zone detection + tests

* fix conflicting test function names
2017-06-16 11:28:13 +02:00

40 lines
1009 B
Go

package cloudflare
import "net/http"
// Option is a functional option for configuring the API client.
type Option func(*API) error
// HTTPClient accepts a custom *http.Client for making API calls.
func HTTPClient(client *http.Client) Option {
return func(api *API) error {
api.httpClient = client
return nil
}
}
// Headers allows you to set custom HTTP headers when making API calls (e.g. for
// satisfying HTTP proxies, or for debugging).
func Headers(headers http.Header) Option {
return func(api *API) error {
api.headers = headers
return nil
}
}
// parseOptions parses the supplied options functions and returns a configured
// *API instance.
func (api *API) parseOptions(opts ...Option) error {
// Range over each options function and apply it to our API type to
// configure it. Options functions are applied in order, with any
// conflicting options overriding earlier calls.
for _, option := range opts {
err := option(api)
if err != nil {
return err
}
}
return nil
}