diff --git a/Gopkg.lock b/Gopkg.lock index 488c9b1..4302463 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -11,7 +11,7 @@ [[projects]] branch = "master" - digest = "1:5e4f167418977858782db1d8820e8c2ccd368c8857e0806bcbd07d0bc09e1e38" + digest = "1:a6c4b93cbf1598f39f75f8eb10aad73caf515d130c945da2fb9eb96743b23dc7" name = "github.com/bitrise-io/go-steputils" packages = [ "cache", @@ -19,11 +19,11 @@ "tools", ] pruneopts = "UT" - revision = "f540824d77dfd382ce84fd0ee0a9da2fba1cce0a" + revision = "94490ca44ddb645764676a94988f6fc7e3187383" [[projects]] branch = "master" - digest = "1:ac36f3a24032ff200ada6cdc84bd53713607ab2926556bc5d2bb99b7dd902029" + digest = "1:e188bd4ff7f6418d9203ad4a49b23f18d0a7d1b96f4a30bbff6dfea9d75a5dc6" name = "github.com/bitrise-io/go-utils" packages = [ "colorstring", @@ -37,7 +37,7 @@ "retry", ] pruneopts = "UT" - revision = "2c67c48e7086cfd8f9a29bfac2cd420d4dd1d2f9" + revision = "e212188d99b41373b4ff8b69e7b1f677bc427bde" [[projects]] branch = "master" diff --git a/vendor/github.com/bitrise-io/go-steputils/stepconf/stepconf.go b/vendor/github.com/bitrise-io/go-steputils/stepconf/stepconf.go index 027095b..f891923 100644 --- a/vendor/github.com/bitrise-io/go-steputils/stepconf/stepconf.go +++ b/vendor/github.com/bitrise-io/go-steputils/stepconf/stepconf.go @@ -56,7 +56,19 @@ func (s Secret) String() string { // Print the name of the struct with Title case in blue color with followed by a newline, // then print all fields formatted as '- field name: field value` separated by newline. func Print(config interface{}) { - fmt.Printf(toString(config)) + fmt.Print(toString(config)) +} + +func valueString(v reflect.Value) string { + if v.Kind() != reflect.Ptr { + return fmt.Sprintf("%v", v.Interface()) + } + + if !v.IsNil() { + return fmt.Sprintf("%v", v.Elem().Interface()) + } + + return "" } // returns the name of the struct with Title case in blue color followed by a newline, @@ -75,7 +87,7 @@ func toString(config interface{}) string { str := fmt.Sprintf(colorstring.Bluef("%s:\n", strings.Title(t.Name()))) for i := 0; i < t.NumField(); i++ { - str += fmt.Sprintf("- %s: %v\n", t.Field(i).Name, v.Field(i).Interface()) + str += fmt.Sprintf("- %s: %s\n", t.Field(i).Name, valueString(v.Field(i))) } return str @@ -137,6 +149,14 @@ func setField(field reflect.Value, value, constraint string) error { return nil } + if field.Kind() == reflect.Ptr { + // If field is a pointer type, then set its value to be a pointer to a new zero value, matching field underlying type. + var dePtrdType = field.Type().Elem() // get the type field can point to + var newPtrType = reflect.New(dePtrdType) // create new ptr address for type with non-nil zero value + field.Set(newPtrType) // assign value to pointer + field = field.Elem() + } + switch field.Kind() { case reflect.String: field.SetString(value) diff --git a/vendor/github.com/bitrise-io/go-utils/fileutil/fileutil.go b/vendor/github.com/bitrise-io/go-utils/fileutil/fileutil.go index c2c2fb9..80c913b 100644 --- a/vendor/github.com/bitrise-io/go-utils/fileutil/fileutil.go +++ b/vendor/github.com/bitrise-io/go-utils/fileutil/fileutil.go @@ -1,6 +1,7 @@ package fileutil import ( + "encoding/json" "errors" "fmt" "io/ioutil" @@ -57,6 +58,15 @@ func WriteBytesToFile(pth string, fileCont []byte) error { return WriteBytesToFileWithPermission(pth, fileCont, 0) } +// WriteJSONToFile ... +func WriteJSONToFile(pth string, fileCont interface{}) error { + bytes, err := json.Marshal(fileCont) + if err != nil { + return fmt.Errorf("failed to JSON marshal the provided object: %+v", err) + } + return WriteBytesToFile(pth, bytes) +} + // AppendStringToFile ... func AppendStringToFile(pth string, fileCont string) error { return AppendBytesToFile(pth, []byte(fileCont))