-
Notifications
You must be signed in to change notification settings - Fork 517
[network-creation]: Add createdAt field #791
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,6 +16,7 @@ | |
|
|
||
| import ContainerizationError | ||
| import ContainerizationExtras | ||
| import Foundation | ||
|
|
||
| /// Configuration parameters for network creation. | ||
| public struct NetworkConfiguration: Codable, Sendable, Identifiable { | ||
|
|
@@ -24,6 +25,9 @@ public struct NetworkConfiguration: Codable, Sendable, Identifiable { | |
|
|
||
| /// The network type | ||
| public let mode: NetworkMode | ||
|
|
||
| /// When the network was created. | ||
| public let createdAt: Date | ||
|
|
||
| /// The preferred CIDR address for the subnet, if specified | ||
| public let subnet: String? | ||
|
|
@@ -39,6 +43,7 @@ public struct NetworkConfiguration: Codable, Sendable, Identifiable { | |
| labels: [String: String] = [:] | ||
| ) throws { | ||
| self.id = id | ||
| self.createdAt = Date() | ||
| self.mode = mode | ||
| self.subnet = subnet | ||
| self.labels = labels | ||
|
|
@@ -47,6 +52,7 @@ public struct NetworkConfiguration: Codable, Sendable, Identifiable { | |
|
|
||
| enum CodingKeys: String, CodingKey { | ||
| case id | ||
| case createdAt | ||
| case mode | ||
| case subnet | ||
| case labels | ||
|
|
@@ -58,6 +64,7 @@ public struct NetworkConfiguration: Codable, Sendable, Identifiable { | |
| let container = try decoder.container(keyedBy: CodingKeys.self) | ||
|
|
||
| id = try container.decode(String.self, forKey: .id) | ||
| createdAt = try container.decode(Date.self, forKey: .createdAt) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| mode = try container.decode(NetworkMode.self, forKey: .mode) | ||
| subnet = try container.decodeIfPresent(String.self, forKey: .subnet) | ||
| labels = try container.decodeIfPresent([String: String].self, forKey: .labels) ?? [:] | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -53,4 +53,11 @@ public enum NetworkState: Codable, Sendable { | |
| case .running(let configuration, _): configuration.id | ||
| } | ||
| } | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This pattern could get out of hand as we add more configuration attributes. Perhaps we could have a
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think I understand what you kinda mean? Do we want to update public var configuration: NetworkConfiguration? {
switch self {
case .created(let configuration): configuration
case .running(let configuration, _): configuration
}
}
public var createdAt: Date? {
configuration?.createdAt
} |
||
| public var createdAt: Date { | ||
| switch self { | ||
| case .created(let configuration): configuration.createdAt | ||
| case .running(let configuration, _): configuration.createdAt | ||
| } | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.