Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package config

import (
"fmt"
"os"

"github.com/spf13/viper"
)
Expand All @@ -39,10 +40,24 @@ func Retrieve() (*Config, error) {
v.AddConfigPath(".")
err := v.ReadInConfig()
if err != nil {
err = fmt.Errorf("%s: %w", "retrieving config file", err)
fmt.Errorf("%s: %w", "retrieving config file", err)
} else {
v.Unmarshal(conf)
}

client, found := os.LookupEnv("ARDUINO_CLOUD_CLIENT")
if !found {
err = fmt.Errorf("%s: %w", "Unable to retrieve token client", err)
return nil, err

}
secret, found := os.LookupEnv("ARDUINO_CLOUD_SECRET")
if !found {
err = fmt.Errorf("%s: %w", "Unable to retrieve token secret", err)
return nil, err
}

v.Unmarshal(conf)
conf.Client = client
conf.Secret = secret
return conf, nil
}