Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1e9b787

Browse filesBrowse files
committed
Drop support for neutron prehistoric time format
1 parent 0660b75 commit 1e9b787
Copy full SHA for 1e9b787

File tree

Expand file treeCollapse file tree

5 files changed

+8
-177
lines changed
Filter options
Expand file treeCollapse file tree

5 files changed

+8
-177
lines changed

‎openstack/networking/v2/extensions/layer3/floatingips/results.go

Copy file name to clipboardExpand all lines: openstack/networking/v2/extensions/layer3/floatingips/results.go
+2-41Lines changed: 2 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package floatingips
22

33
import (
4-
"encoding/json"
54
"time"
65

76
"github.com/gophercloud/gophercloud/v2"
@@ -42,8 +41,8 @@ type FloatingIP struct {
4241

4342
// UpdatedAt and CreatedAt contain ISO-8601 timestamps of when the state of
4443
// the floating ip last changed, and when it was created.
45-
UpdatedAt time.Time `json:"-"`
46-
CreatedAt time.Time `json:"-"`
44+
UpdatedAt time.Time `json:"updated_at"`
45+
CreatedAt time.Time `json:"created_at"`
4746

4847
// ProjectID is the project owner of the floating IP.
4948
ProjectID string `json:"project_id"`
@@ -61,44 +60,6 @@ type FloatingIP struct {
6160
RevisionNumber int `json:"revision_number"`
6261
}
6362

64-
func (r *FloatingIP) UnmarshalJSON(b []byte) error {
65-
type tmp FloatingIP
66-
67-
// Support for older neutron time format
68-
var s1 struct {
69-
tmp
70-
CreatedAt gophercloud.JSONRFC3339NoZ `json:"created_at"`
71-
UpdatedAt gophercloud.JSONRFC3339NoZ `json:"updated_at"`
72-
}
73-
74-
err := json.Unmarshal(b, &s1)
75-
if err == nil {
76-
*r = FloatingIP(s1.tmp)
77-
r.CreatedAt = time.Time(s1.CreatedAt)
78-
r.UpdatedAt = time.Time(s1.UpdatedAt)
79-
80-
return nil
81-
}
82-
83-
// Support for newer neutron time format
84-
var s2 struct {
85-
tmp
86-
CreatedAt time.Time `json:"created_at"`
87-
UpdatedAt time.Time `json:"updated_at"`
88-
}
89-
90-
err = json.Unmarshal(b, &s2)
91-
if err != nil {
92-
return err
93-
}
94-
95-
*r = FloatingIP(s2.tmp)
96-
r.CreatedAt = time.Time(s2.CreatedAt)
97-
r.UpdatedAt = time.Time(s2.UpdatedAt)
98-
99-
return nil
100-
}
101-
10263
type commonResult struct {
10364
gophercloud.Result
10465
}

‎openstack/networking/v2/extensions/security/groups/results.go

Copy file name to clipboardExpand all lines: openstack/networking/v2/extensions/security/groups/results.go
+2-41Lines changed: 2 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package groups
22

33
import (
4-
"encoding/json"
54
"time"
65

76
"github.com/gophercloud/gophercloud/v2"
@@ -33,8 +32,8 @@ type SecGroup struct {
3332

3433
// UpdatedAt and CreatedAt contain ISO-8601 timestamps of when the state of the
3534
// security group last changed, and when it was created.
36-
UpdatedAt time.Time `json:"-"`
37-
CreatedAt time.Time `json:"-"`
35+
UpdatedAt time.Time `json:"updated_at"`
36+
CreatedAt time.Time `json:"created_at"`
3837

3938
// ProjectID is the project owner of the security group.
4039
ProjectID string `json:"project_id"`
@@ -46,44 +45,6 @@ type SecGroup struct {
4645
RevisionNumber int `json:"revision_number"`
4746
}
4847

49-
func (r *SecGroup) UnmarshalJSON(b []byte) error {
50-
type tmp SecGroup
51-
52-
// Support for older neutron time format
53-
var s1 struct {
54-
tmp
55-
CreatedAt gophercloud.JSONRFC3339NoZ `json:"created_at"`
56-
UpdatedAt gophercloud.JSONRFC3339NoZ `json:"updated_at"`
57-
}
58-
59-
err := json.Unmarshal(b, &s1)
60-
if err == nil {
61-
*r = SecGroup(s1.tmp)
62-
r.CreatedAt = time.Time(s1.CreatedAt)
63-
r.UpdatedAt = time.Time(s1.UpdatedAt)
64-
65-
return nil
66-
}
67-
68-
// Support for newer neutron time format
69-
var s2 struct {
70-
tmp
71-
CreatedAt time.Time `json:"created_at"`
72-
UpdatedAt time.Time `json:"updated_at"`
73-
}
74-
75-
err = json.Unmarshal(b, &s2)
76-
if err != nil {
77-
return err
78-
}
79-
80-
*r = SecGroup(s2.tmp)
81-
r.CreatedAt = time.Time(s2.CreatedAt)
82-
r.UpdatedAt = time.Time(s2.UpdatedAt)
83-
84-
return nil
85-
}
86-
8748
// SecGroupPage is the page returned by a pager when traversing over a
8849
// collection of security groups.
8950
type SecGroupPage struct {

‎openstack/networking/v2/extensions/subnetpools/results.go

Copy file name to clipboardExpand all lines: openstack/networking/v2/extensions/subnetpools/results.go
+2-15Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,10 @@ type SubnetPool struct {
6767
ProjectID string `json:"project_id"`
6868

6969
// CreatedAt is the time at which subnetpool has been created.
70-
CreatedAt time.Time `json:"-"`
70+
CreatedAt time.Time `json:"created_at"`
7171

7272
// UpdatedAt is the time at which subnetpool has been created.
73-
UpdatedAt time.Time `json:"-"`
73+
UpdatedAt time.Time `json:"updated_at"`
7474

7575
// Prefixes is the list of subnet prefixes to assign to the subnetpool.
7676
// Neutron API merges adjacent prefixes and treats them as a single prefix.
@@ -125,18 +125,12 @@ func (r *SubnetPool) UnmarshalJSON(b []byte) error {
125125
DefaultPrefixLen any `json:"default_prefixlen"`
126126
MinPrefixLen any `json:"min_prefixlen"`
127127
MaxPrefixLen any `json:"max_prefixlen"`
128-
129-
CreatedAt gophercloud.JSONRFC3339NoZ `json:"created_at"`
130-
UpdatedAt gophercloud.JSONRFC3339NoZ `json:"updated_at"`
131128
}
132129

133130
err := json.Unmarshal(b, &s1)
134131
if err == nil {
135132
*r = SubnetPool(s1.tmp)
136133

137-
r.CreatedAt = time.Time(s1.CreatedAt)
138-
r.UpdatedAt = time.Time(s1.UpdatedAt)
139-
140134
switch t := s1.DefaultPrefixLen.(type) {
141135
case string:
142136
if r.DefaultPrefixLen, err = strconv.Atoi(t); err != nil {
@@ -173,15 +167,11 @@ func (r *SubnetPool) UnmarshalJSON(b []byte) error {
173167
return nil
174168
}
175169

176-
// Support for newer neutron time format
177170
var s2 struct {
178171
tmp
179172
DefaultPrefixLen any `json:"default_prefixlen"`
180173
MinPrefixLen any `json:"min_prefixlen"`
181174
MaxPrefixLen any `json:"max_prefixlen"`
182-
183-
CreatedAt time.Time `json:"created_at"`
184-
UpdatedAt time.Time `json:"updated_at"`
185175
}
186176

187177
err = json.Unmarshal(b, &s2)
@@ -191,9 +181,6 @@ func (r *SubnetPool) UnmarshalJSON(b []byte) error {
191181

192182
*r = SubnetPool(s2.tmp)
193183

194-
r.CreatedAt = time.Time(s2.CreatedAt)
195-
r.UpdatedAt = time.Time(s2.UpdatedAt)
196-
197184
switch t := s2.DefaultPrefixLen.(type) {
198185
case string:
199186
if r.DefaultPrefixLen, err = strconv.Atoi(t); err != nil {

‎openstack/networking/v2/networks/results.go

Copy file name to clipboardExpand all lines: openstack/networking/v2/networks/results.go
+2-41Lines changed: 2 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package networks
22

33
import (
4-
"encoding/json"
54
"time"
65

76
"github.com/gophercloud/gophercloud/v2"
@@ -75,8 +74,8 @@ type Network struct {
7574

7675
// UpdatedAt and CreatedAt contain ISO-8601 timestamps of when the state of the
7776
// network last changed, and when it was created.
78-
UpdatedAt time.Time `json:"-"`
79-
CreatedAt time.Time `json:"-"`
77+
UpdatedAt time.Time `json:"updated_at"`
78+
CreatedAt time.Time `json:"created_at"`
8079

8180
// ProjectID is the project owner of the network.
8281
ProjectID string `json:"project_id"`
@@ -95,44 +94,6 @@ type Network struct {
9594
RevisionNumber int `json:"revision_number"`
9695
}
9796

98-
func (r *Network) UnmarshalJSON(b []byte) error {
99-
type tmp Network
100-
101-
// Support for older neutron time format
102-
var s1 struct {
103-
tmp
104-
CreatedAt gophercloud.JSONRFC3339NoZ `json:"created_at"`
105-
UpdatedAt gophercloud.JSONRFC3339NoZ `json:"updated_at"`
106-
}
107-
108-
err := json.Unmarshal(b, &s1)
109-
if err == nil {
110-
*r = Network(s1.tmp)
111-
r.CreatedAt = time.Time(s1.CreatedAt)
112-
r.UpdatedAt = time.Time(s1.UpdatedAt)
113-
114-
return nil
115-
}
116-
117-
// Support for newer neutron time format
118-
var s2 struct {
119-
tmp
120-
CreatedAt time.Time `json:"created_at"`
121-
UpdatedAt time.Time `json:"updated_at"`
122-
}
123-
124-
err = json.Unmarshal(b, &s2)
125-
if err != nil {
126-
return err
127-
}
128-
129-
*r = Network(s2.tmp)
130-
r.CreatedAt = time.Time(s2.CreatedAt)
131-
r.UpdatedAt = time.Time(s2.UpdatedAt)
132-
133-
return nil
134-
}
135-
13697
// NetworkPage is the page returned by a pager when traversing over a
13798
// collection of networks.
13899
type NetworkPage struct {

‎openstack/networking/v2/ports/results.go

Copy file name to clipboardExpand all lines: openstack/networking/v2/ports/results.go
-39Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package ports
22

33
import (
4-
"encoding/json"
54
"time"
65

76
"github.com/gophercloud/gophercloud/v2"
@@ -124,44 +123,6 @@ type Port struct {
124123
UpdatedAt time.Time `json:"updated_at"`
125124
}
126125

127-
func (r *Port) UnmarshalJSON(b []byte) error {
128-
type tmp Port
129-
130-
// Support for older neutron time format
131-
var s1 struct {
132-
tmp
133-
CreatedAt gophercloud.JSONRFC3339NoZ `json:"created_at"`
134-
UpdatedAt gophercloud.JSONRFC3339NoZ `json:"updated_at"`
135-
}
136-
137-
err := json.Unmarshal(b, &s1)
138-
if err == nil {
139-
*r = Port(s1.tmp)
140-
r.CreatedAt = time.Time(s1.CreatedAt)
141-
r.UpdatedAt = time.Time(s1.UpdatedAt)
142-
143-
return nil
144-
}
145-
146-
// Support for newer neutron time format
147-
var s2 struct {
148-
tmp
149-
CreatedAt time.Time `json:"created_at"`
150-
UpdatedAt time.Time `json:"updated_at"`
151-
}
152-
153-
err = json.Unmarshal(b, &s2)
154-
if err != nil {
155-
return err
156-
}
157-
158-
*r = Port(s2.tmp)
159-
r.CreatedAt = time.Time(s2.CreatedAt)
160-
r.UpdatedAt = time.Time(s2.UpdatedAt)
161-
162-
return nil
163-
}
164-
165126
// PortPage is the page returned by a pager when traversing over a collection
166127
// of network ports.
167128
type PortPage struct {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.