Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNotAvailable = errors.New("CMX metadata service not available")
ErrNotAvailable is returned when the CMX metadata service is not reachable. This is the normal case when the CLI is not running inside a Firecracker VM.
Functions ¶
func GetAccessToken ¶
func GetAccessToken(meta *VMMetadata) (string, error)
GetAccessToken returns a valid access token for the given VMMetadata, using a cached token when possible and refreshing it when it is about to expire.
Types ¶
type VMMetadata ¶
type VMMetadata struct {
ClientID string `json:"client_id"`
ClientSecret string `json:"client_secret"`
APIURL string `json:"api_url"`
TokenEndpoint string `json:"token_endpoint"`
}
VMMetadata holds the OIDC client credentials provisioned by vendor-api into the Firecracker MMDS.
func GetVMMetadata ¶
func GetVMMetadata() (*VMMetadata, error)
GetVMMetadata attempts to read OIDC credentials from the Firecracker MMDS. It returns ErrNotAvailable if the metadata service is not reachable (i.e. the CLI is not running inside a CMX VM).
Firecracker MMDS v1 returns a newline-separated key listing when querying a nested object path. Sending Accept: application/json causes it to return the full JSON subtree instead, which is what we need to parse in one request.