Permalink
Browse files

Fix time format used for cloud orchestration

The format used to represent time is slightly different than RFC
standard and the one present in golang time lib.
  • Loading branch information...
1 parent 1d8b6f1 commit e1b6cbb857ac72df735dbe6928b14a2264441cda @pratikmallya pratikmallya committed Sep 9, 2015
@@ -67,7 +67,7 @@ const FindOutput = `
"events": [
{
"resource_name": "hello_world",
- "event_time": "2015-02-05T21:33:11Z",
+ "event_time": "2015-02-05T21:33:11",
"links": [
{
"href": "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b/resources/hello_world/events/06feb26f-9298-4a9b-8749-9d770e5d577a",
@@ -90,7 +90,7 @@ const FindOutput = `
},
{
"resource_name": "hello_world",
- "event_time": "2015-02-05T21:33:27Z",
+ "event_time": "2015-02-05T21:33:27",
"links": [
{
"href": "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b/resources/hello_world/events/93940999-7d40-44ae-8de4-19624e7b8d18",
@@ -184,7 +184,7 @@ const ListOutput = `
"events": [
{
"resource_name": "hello_world",
- "event_time": "2015-02-05T21:33:11Z",
+ "event_time": "2015-02-05T21:33:11",
"links": [
{
"href": "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b/resources/hello_world/events/06feb26f-9298-4a9b-8749-9d770e5d577a",
@@ -207,7 +207,7 @@ const ListOutput = `
},
{
"resource_name": "hello_world",
- "event_time": "2015-02-05T21:33:27Z",
+ "event_time": "2015-02-05T21:33:27",
"links": [
{
"href": "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b/resources/hello_world/events/93940999-7d40-44ae-8de4-19624e7b8d18",
@@ -309,7 +309,7 @@ const ListResourceEventsOutput = `
"events": [
{
"resource_name": "hello_world",
- "event_time": "2015-02-05T21:33:11Z",
+ "event_time": "2015-02-05T21:33:11",
"links": [
{
"href": "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b/resources/hello_world/events/06feb26f-9298-4a9b-8749-9d770e5d577a",
@@ -332,7 +332,7 @@ const ListResourceEventsOutput = `
},
{
"resource_name": "hello_world",
- "event_time": "2015-02-05T21:33:27Z",
+ "event_time": "2015-02-05T21:33:27",
"links": [
{
"href": "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b/resources/hello_world/events/93940999-7d40-44ae-8de4-19624e7b8d18",
@@ -408,7 +408,7 @@ const GetOutput = `
{
"event":{
"resource_name": "hello_world",
- "event_time": "2015-02-05T21:33:27Z",
+ "event_time": "2015-02-05T21:33:27",
"links": [
{
"href": "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b/resources/hello_world/events/93940999-7d40-44ae-8de4-19624e7b8d18",
@@ -57,7 +57,7 @@ func (r FindResult) Extract() ([]Event, error) {
for i, eventRaw := range events {
event := eventRaw.(map[string]interface{})
if date, ok := event["event_time"]; ok && date != nil {
- t, err := time.Parse(time.RFC3339, date.(string))
+ t, err := time.Parse(gophercloud.STACK_TIME_FMT, date.(string))
if err != nil {
return nil, err
}
@@ -121,7 +121,7 @@ func ExtractEvents(page pagination.Page) ([]Event, error) {
for i, eventRaw := range events {
event := eventRaw.(map[string]interface{})
if date, ok := event["event_time"]; ok && date != nil {
- t, err := time.Parse(time.RFC3339, date.(string))
+ t, err := time.Parse(gophercloud.STACK_TIME_FMT, date.(string))
if err != nil {
return nil, err
}
@@ -161,7 +161,7 @@ func (r GetResult) Extract() (*Event, error) {
event := r.Body.(map[string]interface{})["event"].(map[string]interface{})
if date, ok := event["event_time"]; ok && date != nil {
- t, err := time.Parse(time.RFC3339, date.(string))
+ t, err := time.Parse(gophercloud.STACK_TIME_FMT, date.(string))
if err != nil {
return nil, err
}
@@ -53,7 +53,7 @@ const FindOutput = `
],
"logical_resource_id": "hello_world",
"resource_status_reason": "state changed",
- "updated_time": "2015-02-05T21:33:11Z",
+ "updated_time": "2015-02-05T21:33:11",
"required_by": [],
"resource_status": "CREATE_IN_PROGRESS",
"physical_resource_id": "49181cd6-169a-4130-9455-31185bbfc5bf",
@@ -117,7 +117,7 @@ const ListOutput = `{
],
"logical_resource_id": "hello_world",
"resource_status_reason": "state changed",
- "updated_time": "2015-02-05T21:33:11Z",
+ "updated_time": "2015-02-05T21:33:11",
"required_by": [],
"resource_status": "CREATE_IN_PROGRESS",
"physical_resource_id": "49181cd6-169a-4130-9455-31185bbfc5bf",
@@ -188,7 +188,7 @@ const GetOutput = `
],
"logical_resource_id": "wordpress_instance",
"resource_status": "CREATE_COMPLETE",
- "updated_time": "2014-12-10T18:34:35Z",
+ "updated_time": "2014-12-10T18:34:35",
"required_by": [],
"resource_status_reason": "state changed",
"physical_resource_id": "00e3a2fe-c65d-403c-9483-4db9930dd194",
@@ -48,7 +48,7 @@ func (r FindResult) Extract() ([]Resource, error) {
for i, resourceRaw := range resources {
resource := resourceRaw.(map[string]interface{})
if date, ok := resource["updated_time"]; ok && date != nil {
- t, err := time.Parse(time.RFC3339, date.(string))
+ t, err := time.Parse(gophercloud.STACK_TIME_FMT, date.(string))
if err != nil {
return nil, err
}
@@ -109,7 +109,7 @@ func ExtractResources(page pagination.Page) ([]Resource, error) {
for i, resourceRaw := range resources {
resource := resourceRaw.(map[string]interface{})
if date, ok := resource["updated_time"]; ok && date != nil {
- t, err := time.Parse(time.RFC3339, date.(string))
+ t, err := time.Parse(gophercloud.STACK_TIME_FMT, date.(string))
if err != nil {
return nil, err
}
@@ -143,7 +143,7 @@ func (r GetResult) Extract() (*Resource, error) {
resource := r.Body.(map[string]interface{})["resource"].(map[string]interface{})
if date, ok := resource["updated_time"]; ok && date != nil {
- t, err := time.Parse(time.RFC3339, date.(string))
+ t, err := time.Parse(gophercloud.STACK_TIME_FMT, date.(string))
if err != nil {
return nil, err
}
@@ -95,7 +95,7 @@ const FullListOutput = `
],
"stack_status_reason": "Stack CREATE completed successfully",
"stack_name": "postman_stack",
- "creation_time": "2015-02-03T20:07:39Z",
+ "creation_time": "2015-02-03T20:07:39",
"updated_time": null,
"stack_status": "CREATE_COMPLETE",
"id": "16ef0584-4458-41eb-87c8-0dc8d5f66c87"
@@ -110,8 +110,8 @@ const FullListOutput = `
],
"stack_status_reason": "Stack successfully updated",
"stack_name": "gophercloud-test-stack-2",
- "creation_time": "2014-12-11T17:39:16Z",
- "updated_time": "2014-12-11T17:40:37Z",
+ "creation_time": "2014-12-11T17:39:16",
+ "updated_time": "2014-12-11T17:40:37",
"stack_status": "UPDATE_COMPLETE",
"id": "db6977b2-27aa-4775-9ae7-6213212d4ada"
}
@@ -181,7 +181,7 @@ const GetOutput = `
"stack_status_reason": "Stack CREATE completed successfully",
"stack_name": "postman_stack",
"outputs": [],
- "creation_time": "2015-02-03T20:07:39Z",
+ "creation_time": "2015-02-03T20:07:39",
"links": [
{
"href": "http://166.76.160.117:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/16ef0584-4458-41eb-87c8-0dc8d5f66c87",
@@ -100,15 +100,15 @@ func ExtractStacks(page pagination.Page) ([]ListedStack, error) {
thisStack := (rawStacks[i]).(map[string]interface{})
if t, ok := thisStack["creation_time"].(string); ok && t != "" {
- creationTime, err := time.Parse(time.RFC3339, t)
+ creationTime, err := time.Parse(gophercloud.STACK_TIME_FMT, t)
if err != nil {
return res.Stacks, err
}
res.Stacks[i].CreationTime = creationTime
}
if t, ok := thisStack["updated_time"].(string); ok && t != "" {
- updatedTime, err := time.Parse(time.RFC3339, t)
+ updatedTime, err := time.Parse(gophercloud.STACK_TIME_FMT, t)
if err != nil {
return res.Stacks, err
}
@@ -170,15 +170,15 @@ func (r GetResult) Extract() (*RetrievedStack, error) {
b := r.Body.(map[string]interface{})["stack"].(map[string]interface{})
if date, ok := b["creation_time"]; ok && date != nil {
- t, err := time.Parse(time.RFC3339, date.(string))
+ t, err := time.Parse(gophercloud.STACK_TIME_FMT, date.(string))
if err != nil {
return nil, err
}
res.Stack.CreationTime = t
}
if date, ok := b["updated_time"]; ok && date != nil {
- t, err := time.Parse(time.RFC3339, date.(string))
+ t, err := time.Parse(gophercloud.STACK_TIME_FMT, date.(string))
if err != nil {
return nil, err
}
@@ -249,15 +249,15 @@ func (r PreviewResult) Extract() (*PreviewedStack, error) {
b := r.Body.(map[string]interface{})["stack"].(map[string]interface{})
if date, ok := b["creation_time"]; ok && date != nil {
- t, err := time.Parse(time.RFC3339, date.(string))
+ t, err := time.Parse(gophercloud.STACK_TIME_FMT, date.(string))
if err != nil {
return nil, err
}
res.Stack.CreationTime = t
}
if date, ok := b["updated_time"]; ok && date != nil {
- t, err := time.Parse(time.RFC3339, date.(string))
+ t, err := time.Parse(gophercloud.STACK_TIME_FMT, date.(string))
if err != nil {
return nil, err
}
View
@@ -113,6 +113,9 @@ func DecodeHeader(from, to interface{}) error {
// RFC3339Milli describes a common time format used by some API responses.
const RFC3339Milli = "2006-01-02T15:04:05.999999Z"
+// Time format used in cloud orchestration
+const STACK_TIME_FMT = "2006-01-02T15:04:05"
+
/*
Link is an internal type to be used in packages of collection resources that are
paginated in a certain way.

0 comments on commit e1b6cbb

Please sign in to comment.