config

package
v0.0.0-...-4022ef6 Latest Latest
Warning

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

Go to latest
Published: May 10, 2024 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
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

func FindCredentials() (source string, err error)

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

func SetEmptyCredentials(settings *viper.Viper)

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.

Jump to

Keyboard shortcuts

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