Help us shape the future of Go! Take the 2026 Go Developer Survey

client

package
v1.21.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 22, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const AcmeActionLabel = MetricsContextKey("acme_action")

AcmeActionLabel is the context key for storing the logical ACME operation name.

Variables

This section is empty.

Functions

func NewInstrumentedClient added in v0.6.0

func NewInstrumentedClient(metrics *metrics.Metrics, client *http.Client) *http.Client

NewInstrumentedClient takes a *http.Client and returns a *http.Client that has its RoundTripper wrapped with instrumentation.

Types

type FakeACME

type FakeACME struct {
	FakeAuthorizeOrder          func(ctx context.Context, id []acme.AuthzID, opt ...acme.OrderOption) (*acme.Order, error)
	FakeGetOrder                func(ctx context.Context, url string) (*acme.Order, error)
	FakeFetchCert               func(ctx context.Context, url string, bundle bool) ([][]byte, error)
	FakeListCertAlternates      func(ctx context.Context, url string) ([]string, error)
	FakeWaitOrder               func(ctx context.Context, url string) (*acme.Order, error)
	FakeCreateOrderCert         func(ctx context.Context, finalizeURL string, csr []byte, bundle bool) (der [][]byte, certURL string, err error)
	FakeAccept                  func(ctx context.Context, chal *acme.Challenge) (*acme.Challenge, error)
	FakeGetChallenge            func(ctx context.Context, url string) (*acme.Challenge, error)
	FakeGetAuthorization        func(ctx context.Context, url string) (*acme.Authorization, error)
	FakeWaitAuthorization       func(ctx context.Context, url string) (*acme.Authorization, error)
	FakeRegister                func(ctx context.Context, a *acme.Account, prompt func(tosURL string) bool) (*acme.Account, error)
	FakeGetReg                  func(ctx context.Context, url string) (*acme.Account, error)
	FakeHTTP01ChallengeResponse func(token string) (string, error)
	FakeDNS01ChallengeRecord    func(token string) (string, error)
	FakeDiscover                func(ctx context.Context) (acme.Directory, error)
	FakeUpdateReg               func(ctx context.Context, a *acme.Account) (*acme.Account, error)
	FakeGetRenewalInfo          func(ctx context.Context, cert *x509.Certificate) (*acme.RenewalInfoResponse, error)
}

FakeACME implements Interface and can be used as a mock acme.Client in tests.

func (*FakeACME) Accept added in v1.8.0

func (f *FakeACME) Accept(ctx context.Context, chal *acme.Challenge) (*acme.Challenge, error)

func (*FakeACME) AuthorizeOrder added in v1.8.0

func (f *FakeACME) AuthorizeOrder(ctx context.Context, id []acme.AuthzID, opt ...acme.OrderOption) (*acme.Order, error)

func (*FakeACME) CreateOrderCert added in v1.8.0

func (f *FakeACME) CreateOrderCert(ctx context.Context, finalizeURL string, csr []byte, bundle bool) (der [][]byte, certURL string, err error)

func (*FakeACME) DNS01ChallengeRecord

func (f *FakeACME) DNS01ChallengeRecord(token string) (string, error)

func (*FakeACME) Discover added in v0.7.0

func (f *FakeACME) Discover(ctx context.Context) (acme.Directory, error)

func (*FakeACME) FetchCert added in v1.8.0

func (f *FakeACME) FetchCert(ctx context.Context, url string, bundle bool) ([][]byte, error)

func (*FakeACME) GetAuthorization

func (f *FakeACME) GetAuthorization(ctx context.Context, url string) (*acme.Authorization, error)

func (*FakeACME) GetChallenge

func (f *FakeACME) GetChallenge(ctx context.Context, url string) (*acme.Challenge, error)

func (*FakeACME) GetOrder

func (f *FakeACME) GetOrder(ctx context.Context, url string) (*acme.Order, error)

func (*FakeACME) GetReg added in v1.8.0

func (f *FakeACME) GetReg(ctx context.Context, url string) (*acme.Account, error)

func (*FakeACME) GetRenewalInfo added in v1.21.0

func (f *FakeACME) GetRenewalInfo(ctx context.Context, cert *x509.Certificate) (*acme.RenewalInfoResponse, error)

func (*FakeACME) HTTP01ChallengeResponse

func (f *FakeACME) HTTP01ChallengeResponse(token string) (string, error)

func (*FakeACME) ListCertAlternates added in v1.8.0

func (f *FakeACME) ListCertAlternates(ctx context.Context, url string) ([]string, error)

func (*FakeACME) Register added in v1.8.0

func (f *FakeACME) Register(ctx context.Context, a *acme.Account, prompt func(tosURL string) bool) (*acme.Account, error)

func (*FakeACME) UpdateReg added in v1.8.0

func (f *FakeACME) UpdateReg(ctx context.Context, a *acme.Account) (*acme.Account, error)

func (*FakeACME) WaitAuthorization

func (f *FakeACME) WaitAuthorization(ctx context.Context, url string) (*acme.Authorization, error)

func (*FakeACME) WaitOrder

func (f *FakeACME) WaitOrder(ctx context.Context, url string) (*acme.Order, error)

type Interface

type Interface interface {
	AuthorizeOrder(ctx context.Context, id []acme.AuthzID, opt ...acme.OrderOption) (*acme.Order, error)
	GetOrder(ctx context.Context, url string) (*acme.Order, error)
	FetchCert(ctx context.Context, url string, bundle bool) ([][]byte, error)
	ListCertAlternates(ctx context.Context, url string) ([]string, error)
	WaitOrder(ctx context.Context, url string) (*acme.Order, error)
	CreateOrderCert(ctx context.Context, finalizeURL string, csr []byte, bundle bool) (der [][]byte, certURL string, err error)
	// Accept will (in success cases) be called once per a Challenge once it
	// has passed self-check and is ready to be verified by the ACME server.
	Accept(ctx context.Context, chal *acme.Challenge) (*acme.Challenge, error)
	GetChallenge(ctx context.Context, url string) (*acme.Challenge, error)
	// GetAuthorization will be called once for each required authorization
	// for an Order. Additionally it will be called most likely once when a
	// Challenge has been scheduled for processing to retrieve its status.
	GetAuthorization(ctx context.Context, url string) (*acme.Authorization, error)
	// WaitAuthorization will, in success cases, be called once per
	// Challenge after it has been accepted.
	WaitAuthorization(ctx context.Context, url string) (*acme.Authorization, error)
	Register(ctx context.Context, acct *acme.Account, prompt func(tosURL string) bool) (*acme.Account, error)
	GetReg(ctx context.Context, url string) (*acme.Account, error)
	// HTTP01ChallengeResponse will be called once when a cert-manager.io
	// Challenge for an http-01 challenge type is being created.
	HTTP01ChallengeResponse(token string) (string, error)
	// DNS01ChallengeResponse will be called once when a cert-manager.io
	// Challenge for an http-01 challenge type is being created.
	DNS01ChallengeRecord(token string) (string, error)
	Discover(ctx context.Context) (acme.Directory, error)
	UpdateReg(ctx context.Context, a *acme.Account) (*acme.Account, error)
	// GetRenewalInfo will be called when cert-manager needs ACME renewal
	// information for an issued certificate, for example to determine the
	// suggested renewal window published by the ACME server. It returns the
	// server's renewal information for the certificate. A non-nil error means
	// the renewal information could not be retrieved or parsed.
	GetRenewalInfo(ctx context.Context, cert *x509.Certificate) (*acme.RenewalInfoResponse, error)
}

Interface is an Automatic Certificate Management Environment (ACME) client implementing an Order-based flow.

For more information see https://pkg.go.dev/golang.org/x/crypto/acme#Client and RFC 8555 (https://tools.ietf.org/html/rfc8555).

type MetricsContextKey added in v1.19.0

type MetricsContextKey string

MetricsContextKey is the type used for context keys in the metrics package. Using a custom type prevents key collisions with other packages.

type Transport added in v0.6.0

type Transport struct {
	// contains filtered or unexported fields
}

Transport is an http.RoundTripper that instruments every request it processes: it records Prometheus metrics for the request and caps the size of the response body to guard against an ACME server returning an unbounded body.

func (*Transport) RoundTrip added in v0.6.0

func (it *Transport) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip implements http.RoundTripper. It forwards the request to the wrapped RoundTripper and measures the time it took in Prometheus summary.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL