Skip to content

Commit

Permalink
Merge pull request #1 from sw-samuraj/feature/add-logging-for-key-loa…
Browse files Browse the repository at this point in the history
…ding

Add logging to key loading
  • Loading branch information
sw-samuraj committed Aug 28, 2018
2 parents f19d313 + 2101478 commit 428e7f6
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions oci/oci.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func NewDiscovery(conf *SDConfig, logger *log.Logger) (*discovery, error) {
if logger == nil {
logger = log.New()
}
privateKey, err := loadKey(conf.KeyFile)
privateKey, err := loadKey(conf.KeyFile, logger)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -248,9 +248,10 @@ func (d *discovery) refresh() (tg *targetgroup.Group, err error) {
return tg, nil
}

func loadKey(keyFile string) (string, error) {
func loadKey(keyFile string, logger *log.Logger) (string, error) {
data, err := ioutil.ReadFile(keyFile)
if err != nil {
logger.WithFields(log.Fields{"func": "loadKey", "err": err}).Error("can't load a key")
return "", err
}
return string(data), nil
Expand Down

0 comments on commit 428e7f6

Please sign in to comment.