Skip to content

Commit

Permalink
Added config
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Harwood committed Sep 3, 2020
1 parent 668bb4e commit 3e9875a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
11 changes: 11 additions & 0 deletions helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@ import (
"github.com/spf13/viper"
)

func SetConfig() {
viper.SetConfigName("config") // name of config file (without extension)
viper.SetConfigType("yaml") // REQUIRED if the config file does not have the extension in the name
viper.AddConfigPath(".") // path to look for the config file in
err := viper.ReadInConfig() // Find and read the config file
if err != nil { // Handle errors reading the config file
panic(fmt.Errorf("Fatal error config file: %s \n", err))
}

}

func urltpl() string {
return "https://" + viper.GetString("api-key") + ":" + viper.GetString("pass") + "@" + viper.GetString("api-url")
}
Expand Down
1 change: 1 addition & 0 deletions metafields.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ func GetProductMetafield(handle, mfnamspace, mfkey string) {
}

func SetProductMetafield(handle, namespace, key, value, valuetype string) {
SetConfig()
url := urltpl() + "products/" + handle + "/metafields.json"
body := `
{
Expand Down

0 comments on commit 3e9875a

Please sign in to comment.