Skip to content

Commit 32716a0

Browse files
committed
fix(secrets): Add custom decoder with default values for XAppleSecretsConfig
- Add init(from decoder:) with proper default value handling - Required fields (mount) throw on missing - Optional fields use defaults: readOnly=true, noexec=true, nosuid=true, cleanup=.immediate - Fixes XAppleSecretsParserTests and HonchoStackSecretsE2ETests
1 parent 63178b2 commit 32716a0

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

Sources/Container-Compose/Codable Structs/XAppleSecretsConfig.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,16 @@ public struct XAppleSecretsConfig: Codable, Hashable, Sendable {
5252
case cleanup
5353
}
5454

55+
public init(from decoder: Decoder) throws {
56+
let container = try decoder.container(keyedBy: CodingKeys.self)
57+
self.mount = try container.decode(String.self, forKey: .mount)
58+
self.filter = try container.decodeIfPresent([String].self, forKey: .filter)
59+
self.readOnly = try container.decodeIfPresent(Bool.self, forKey: .readOnly) ?? true
60+
self.noexec = try container.decodeIfPresent(Bool.self, forKey: .noexec) ?? true
61+
self.nosuid = try container.decodeIfPresent(Bool.self, forKey: .nosuid) ?? true
62+
self.cleanup = try container.decodeIfPresent(CleanupPolicy.self, forKey: .cleanup) ?? .immediate
63+
}
64+
5565
public init(
5666
mount: String = "/run/secrets",
5767
filter: [String]? = nil,

0 commit comments

Comments
 (0)