Skip to content

Commit

Permalink
Merge pull request #21 from alexeldeib/ace/bugfix
Browse files Browse the repository at this point in the history
fix: allow failure reading config file
  • Loading branch information
jasmingacic authored Aug 9, 2019
2 parents 045e531 + b214d29 commit 00eb086
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ var rootCmd = &cobra.Command{

func packetConnect(cmd *cobra.Command, args []string) {
if packetToken == "" {
fmt.Println("Packet authentication token not provided. Please either set the 'PACKET_TOKEN' environment variable or create a JSON configuration file.")
fmt.Println("Packet authentication token not provided. Please either set the 'PACKET_TOKEN' environment variable or create a JSON or YAML configuration file.")
os.Exit(1)
}
client, err := packngo.NewClientWithBaseURL("Packet CLI", packetToken, nil, "https://api.packet.net/")
Expand Down Expand Up @@ -86,11 +86,7 @@ func initConfig() {
viper.AddConfigPath(userHomeDir())
}

err := viper.ReadInConfig()
if err != nil {
fmt.Printf("Unable to read in config file, check the file path and defaults (./packet-cli.{yaml,json} in user home directory) and try again")
os.Exit(1)
}
viper.ReadInConfig()

if viper.GetString("token") != "" {
packetToken = viper.GetString("token")
Expand Down

0 comments on commit 00eb086

Please sign in to comment.