proper reprs

Signed-off-by: Kenneth Reitz <me@kennethreitz.org>
This commit is contained in:
2017-12-13 12:52:36 -05:00
parent bbd0a9b562
commit e1f3b4b4b7
2 changed files with 14 additions and 2 deletions
+2
View File
@@ -88,6 +88,8 @@ func (r Redis) GetTargetVersions(bp string, target string) []Version {
json_value, _ := redis.Bytes(r.Connection.Do("GET", key))
unpack := NewVersion()
json.Unmarshal(json_value, &unpack)
unpack.Name = key
unpack.Target = NewTarget(NewBuildpack(bp), target)
// Append the results.
results = append(results, unpack)
+12 -2
View File
@@ -19,6 +19,7 @@ var BUILDPACKS = []string { "python", "php", "nodejs", "ruby", "jvm-common" }
type Version struct {
Name string
Target Target
Published string `json:"id"`
IsValid bool `json:"is_valid"`
@@ -36,8 +37,17 @@ func NewVersion() Version {
}
}
func (vd Version) JSON() []byte {
b, _ := json.Marshal(vd)
func (v Version) String() string {
return fmt.Sprintf(
"<Version name='%s' published=%#v, valid=%#v>",
v.Name,
v.IsPublished,
v.IsValid,
)
}
func (v Version) JSON() []byte {
b, _ := json.Marshal(v)
return b
}