1616
1717import ContainerizationError
1818import ContainerizationExtras
19+ import Foundation
1920
2021/// Configuration parameters for network creation.
2122public struct NetworkConfiguration : Codable , Sendable , Identifiable {
@@ -25,6 +26,9 @@ public struct NetworkConfiguration: Codable, Sendable, Identifiable {
2526 /// The network type
2627 public let mode : NetworkMode
2728
29+ /// When the network was created.
30+ public let creationDate : Date
31+
2832 /// The preferred CIDR address for the subnet, if specified
2933 public let subnet : String ?
3034
@@ -39,6 +43,7 @@ public struct NetworkConfiguration: Codable, Sendable, Identifiable {
3943 labels: [ String : String ] = [ : ]
4044 ) throws {
4145 self . id = id
46+ self . creationDate = Date ( )
4247 self . mode = mode
4348 self . subnet = subnet
4449 self . labels = labels
@@ -47,6 +52,7 @@ public struct NetworkConfiguration: Codable, Sendable, Identifiable {
4752
4853 enum CodingKeys : String , CodingKey {
4954 case id
55+ case creationDate
5056 case mode
5157 case subnet
5258 case labels
@@ -58,6 +64,7 @@ public struct NetworkConfiguration: Codable, Sendable, Identifiable {
5864 let container = try decoder. container ( keyedBy: CodingKeys . self)
5965
6066 id = try container. decode ( String . self, forKey: . id)
67+ creationDate = try container. decodeIfPresent ( Date . self, forKey: . creationDate) ?? Date ( timeIntervalSince1970: 0 )
6168 mode = try container. decode ( NetworkMode . self, forKey: . mode)
6269 subnet = try container. decodeIfPresent ( String . self, forKey: . subnet)
6370 labels = try container. decodeIfPresent ( [ String : String ] . self, forKey: . labels) ?? [ : ]
0 commit comments