Documentation ¶
Index ¶
Constants ¶
const ( // ClientIDLen specifies the length of Arduino IoT Cloud client ids. ClientIDLen = 32 // ClientSecretLen specifies the length of Arduino IoT Cloud client secrets. ClientSecretLen = 64 // OrganizationLen specifies the length of Arduino IoT Cloud organization. OrganizationLen = 36 // EnvPrefix is the prefix environment variables should have to be // fetched as credentials parameters during the credentials retrieval. EnvPrefix = "ARDUINO_CLOUD" // CredentialsFilename specifies the name of the credentials file. CredentialsFilename = "arduino-cloud-credentials" )
Variables ¶
This section is empty.
Functions ¶
func FindCredentials ¶
FindCredentials looks for credentials in environment variables or in credentials file. Returns the source of found credentials (env or filepath). Returns an error if credentials are not found specifying paths where the credentials are searched.
func SetEmptyCredentials ¶
SetEmptyCredentials sets the default credentials values to empty strings.
Types ¶
type Credentials ¶
type Credentials struct { Client string `mapstructure:"client"` // Client ID of the user; mandatory. Secret string `mapstructure:"secret"` // Secret ID of the user, unique for each Client ID; mandatory. Organization string `mapstructure:"organization"` // Organization ID of the user; this is considered optional. }
Credentials contains the parameters of Arduino IoT Cloud credentials.
func RetrieveCredentials ¶
func RetrieveCredentials() (cred *Credentials, err error)
RetrieveCredentials retrieves credentials from environment variables or credentials file. Returns error if credentials are not found or if found credentials are invalid.
func (*Credentials) IsEmpty ¶
func (c *Credentials) IsEmpty() bool
IsEmpty checks if Credentials has no mandatory params set. Optional parameters are not considered here.
func (*Credentials) Validate ¶
func (c *Credentials) Validate() error
Validate the credentials. If credentials are not valid, it returns an error explaining the reason.