Skip to content
This repository has been archived by the owner on Apr 7, 2022. It is now read-only.

Commit

Permalink
Merge pull request #9 from hopkinsth/fix/dot-okta
Browse files Browse the repository at this point in the history
fix/dot-okta
  • Loading branch information
hopkinsth authored Jun 15, 2016
2 parents 2620a27 + 2db8e2e commit 39bf7c3
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
25 changes: 21 additions & 4 deletions config-loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import "os"
import "fmt"
import "errors"

var badCfgErr = errors.New("Bad configuration file!")
var badCfgErr = errors.New("Could not find a suitable oktad config file!")
var awsProfileNotFound = errors.New("AWS profile not found!")

var debugCfg = debug.Debug("oktad:config")
Expand Down Expand Up @@ -78,19 +78,36 @@ func loadConfig(fname string) (*ini.File, error) {
debugCfg("trying to load from config param file")
if _, err := os.Stat(fname); err == nil {
debugCfg("loading %s", fname)
return ini.Load(fname)
f, err := ini.Load(fname)

if err == nil {
return f, nil
}

debugCfg("error loading %s: %s", fname, err)
}

debugCfg("trying to load from CWD")
if _, err := os.Stat(cwdPath); err == nil {
debugCfg("loading %s", cwdPath)
return ini.Load(cwdPath)
f, err := ini.Load(cwdPath)
if err == nil {
return f, nil
}

debugCfg("error loading %s: %s", cwdPath, err)
}

debugCfg("trying to load from home dir")
if _, err := os.Stat(hdirPath); err == nil {
debugCfg("loading %s", hdirPath)
return ini.Load(hdirPath)

f, err := ini.Load(hdirPath)
if err == nil {
return f, nil
}

debugCfg("error loading %s: %s", hdirPath, err)
}

return nil, badCfgErr
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import "github.com/peterh/liner"
import "github.com/aws/aws-sdk-go/aws/credentials"
import "time"

const VERSION = "0.6.0"
const VERSION = "0.6.1"

func main() {
var opts struct {
Expand Down

0 comments on commit 39bf7c3

Please sign in to comment.