Documentation ¶
Index ¶
- Constants
- Variables
- type Credentials
- func (c *Credentials) Credentials() (string, time.Time, error)
- func (c *Credentials) Decorate(headers http.Header) error
- func (c *Credentials) MarkInvalid(ctx context.Context)
- func (c *Credentials) Start()
- func (c *Credentials) Stop()
- func (c *Credentials) WaitUntilFetched(ctx context.Context)
- func (c *Credentials) WaitUntilValid(ctx context.Context)
- type Option
- func AddDecorateListener(listener event.DecorateListener, cancel ...*event.CancelListenerFunc) Option
- func AddFetchListener(listener event.FetchListener, cancel ...*event.CancelListenerFunc) Option
- func AssumedLifetime(lifetime time.Duration) Option
- func BootRetryWait(bootRetryWait time.Duration) Option
- func FirmwareVersion(firmwareVersion string) Option
- func HTTPClient(client *http.Client) Option
- func HardwareManufacturer(hardwareManufacturer string) Option
- func HardwareModel(hardwareModel string) Option
- func IgnoreBody() Option
- func LastRebootReason(lastRebootReason string) Option
- func LastReconnectReason(lastReconnectReason func() string) Option
- func LocalStorage(fs fs.FS, filename string, perm iofs.FileMode) Option
- func MacAddress(macAddress wrp.DeviceID) Option
- func NowFunc(nowFunc func() time.Time) Option
- func PartnerID(partnerID func() string) Option
- func RefetchPercent(percent float64) Option
- func Required() Option
- func SerialNumber(serialNumber string) Option
- func URL(url string) Option
- func XmidtProtocol(xmidtProtocol string) Option
Constants ¶
const (
DefaultRefetchPercent = 90.0
)
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Credentials ¶
type Credentials struct {
// contains filtered or unexported fields
}
Notes:
- The network interface is set via the http.Client.
- If v4, v6 or both are desired, it is set via the http.Client.
- The timeout is set via the http.Client.
- The maximum redirect count is set via the http.Client.
- mTLS is set via the http.Client.
- The TLS version is set via the http.Client.
func New ¶
func New(opts ...Option) (*Credentials, error)
New creates a new credentials service object.
func (*Credentials) Credentials ¶
func (c *Credentials) Credentials() (string, time.Time, error)
func (*Credentials) Decorate ¶
func (c *Credentials) Decorate(headers http.Header) error
Decorate decorates the headers with the credentials. If the credentials are not valid, an error is returned.
func (*Credentials) MarkInvalid ¶
func (c *Credentials) MarkInvalid(ctx context.Context)
MarkInvalid marks the credentials as invalid and causes the service to immediately attempt to fetch new credentials.
func (*Credentials) WaitUntilFetched ¶
func (c *Credentials) WaitUntilFetched(ctx context.Context)
WaitUntilFetched blocks until an attempt to fetch the credentials has been made or the context is canceled.
func (*Credentials) WaitUntilValid ¶
func (c *Credentials) WaitUntilValid(ctx context.Context)
WaitUntilValid blocks until the credentials are valid or the context is canceled.
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
Option is the interface implemented by types that can be used to configure the credentials.
func AddDecorateListener ¶
func AddDecorateListener(listener event.DecorateListener, cancel ...*event.CancelListenerFunc) Option
AddDecorateListener adds a listener for decorate events. If the optional cancel parameter is provided, it is set to a function that can be used to cancel the listener.
func AddFetchListener ¶
func AddFetchListener(listener event.FetchListener, cancel ...*event.CancelListenerFunc) Option
AddFetchListener adds a listener for fetch events. If the optional cancel parameter is provided, it is set to a function that can be used to cancel the listener.
func AssumedLifetime ¶
AssumedLifetime is the lifetime of the credentials that is assumed if the credentials service does not return a lifetime. A value of zero means that no assumed lifetime is used. The default is zero.
func BootRetryWait ¶
BootRetryWait is the time to wait before retrying the request. Any value less than or equal to zero is treated as zero.
func FirmwareVersion ¶
FirmwareVersion is the firmware version of the device.
func HTTPClient ¶
HTTPClient is the HTTP client used to fetch the credentials.
func HardwareManufacturer ¶
HardwareManufacturer is the hardware manufacturer of the device.
func HardwareModel ¶
HardwareModel is the hardware model of the device.
func IgnoreBody ¶
func IgnoreBody() Option
IgnoreBody is a flag that indicates whether the body of the response should be ignored instead of examined for an expiration time. The default is to examine the body.
func LastRebootReason ¶
LastRebootReason is the reason for the most recent reboot of the device.
func LastReconnectReason ¶
LastReconnectReason is the reason for the most recent reconnect of the device. This is a dynamic value that is obtained by calling the function provided.
func LocalStorage ¶
LocalStorage is the local storage used to cache the credentials.
The filename (and path) is relative to the provided filesystem.
func MacAddress ¶
func MacAddress(macAddress wrp.DeviceID) Option
MacAddress is the MAC address of the device.
func PartnerID ¶
PartnerID is the partner ID of the device. This is a dynamic value that is obtained by calling the function provided.
func RefetchPercent ¶
RefetchPercent is the percentage of the lifetime of the credentials that must pass before a refetch is attempted. The accepted range is 0.0 to 100.0. If 0.0 is specified the default is used. The default is 90.0.
func Required ¶
func Required() Option
Required is a flag that indicates whether the credentials are required to successfully decorate a request. The default is optional.
func SerialNumber ¶
SerialNumber is the serial number of the device.
func XmidtProtocol ¶
XmidtProtocol is the protocol version used by the device to communicate with the Xmidt cluster.