change all time fields to have type time.Time (#190)
* add Volume.Unmarshal
* add volumetenants.VolumeExt.Unmarshal
* create servers.Server time.Time fields
* json.Unmarshal can correctly handle time.RFC3339 (Server time fields)
* add v3 Token UnmarshalJSON method
* check for empty string when unmarshaling time
* add Member UnmarshalJSON
* v3 tokens.Token ExtractInto
* v3 trust.Trust UnmarshalJSON
* time.Time fields swift response objects
* time.Time fields for orchestration response objects
* time.Time fields for shared file systems response objects
* if we don't use pointers for the custom time fields, we don't need to check if they're nil
* style guide fixes: 'r' for receiver, 's' for struct
* remove unnecessary pointers from UnmarshalJSON methods
diff --git a/openstack/orchestration/v1/stackevents/results.go b/openstack/orchestration/v1/stackevents/results.go
index 6c7f183..46fb0ff 100644
--- a/openstack/orchestration/v1/stackevents/results.go
+++ b/openstack/orchestration/v1/stackevents/results.go
@@ -1,6 +1,9 @@
package stackevents
import (
+ "encoding/json"
+ "time"
+
"github.com/gophercloud/gophercloud"
"github.com/gophercloud/gophercloud/pagination"
)
@@ -10,7 +13,7 @@
// The name of the resource for which the event occurred.
ResourceName string `json:"resource_name"`
// The time the event occurred.
- Time gophercloud.JSONRFC3339NoZ `json:"event_time"`
+ Time time.Time `json:"-"`
// The URLs to the event.
Links []gophercloud.Link `json:"links"`
// The logical ID of the stack resource.
@@ -27,6 +30,24 @@
ResourceProperties map[string]interface{} `json:"resource_properties"`
}
+func (r *Event) UnmarshalJSON(b []byte) error {
+ type tmp Event
+ var s struct {
+ tmp
+ Time gophercloud.JSONRFC3339NoZ `json:"event_time"`
+ }
+ err := json.Unmarshal(b, &s)
+ if err != nil {
+ return err
+ }
+
+ *r = Event(s.tmp)
+
+ r.Time = time.Time(s.Time)
+
+ return nil
+}
+
// FindResult represents the result of a Find operation.
type FindResult struct {
gophercloud.Result