File tree Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ type Container struct {
30
30
31
31
// CreatedTime returns the time when the container was created parsed from the Created field.
32
32
func (c * Container ) CreatedTime () time.Time {
33
- if c .created .IsZero () {
33
+ if c .created .IsZero () && c . Created != "" {
34
34
created , err := time .Parse (time .RFC3339Nano , c .Created )
35
35
if err != nil {
36
36
return time.Time {}
@@ -213,3 +213,24 @@ func (c *ServiceContainer) ConflictingServicePorts(ports []PortSpec) ([]PortSpec
213
213
214
214
return conflicting , nil
215
215
}
216
+
217
+ // UnmarshalJSON implements custom unmarshalling for ServiceContainer to override the custom unmarshaler
218
+ // of the embedded Container field.
219
+ func (c * ServiceContainer ) UnmarshalJSON (data []byte ) error {
220
+ // Unmarshal everything except Container into a temporary struct. Keep this in sync with ServiceContainer.
221
+ var temp struct {
222
+ ServiceSpec ServiceSpec
223
+ }
224
+ if err := json .Unmarshal (data , & temp ); err != nil {
225
+ return err
226
+ }
227
+
228
+ // Let Container's UnmarshalJSON handle its part.
229
+ if err := json .Unmarshal (data , & c .Container ); err != nil {
230
+ return err
231
+ }
232
+
233
+ c .ServiceSpec = temp .ServiceSpec
234
+
235
+ return nil
236
+ }
You can’t perform that action at this time.
0 commit comments