feat: Begins vault commands, adds nodes for rendering discussion documentation.
This commit is contained in:
@@ -3,7 +3,7 @@ import Foundation
|
||||
import ShellClient
|
||||
|
||||
/// Represents the configuration.
|
||||
public struct Configuration: Codable {
|
||||
public struct Configuration: Codable, Sendable {
|
||||
|
||||
public let playbookDir: String?
|
||||
public let inventoryPath: String?
|
||||
@@ -11,6 +11,7 @@ public struct Configuration: Codable {
|
||||
public let templateRepoVersion: String?
|
||||
public let templateDir: String?
|
||||
public let defaultPlaybookArgs: [String]?
|
||||
public let defaultVaultArgs: [String]?
|
||||
|
||||
fileprivate enum CodingKeys: String, CodingKey {
|
||||
case playbookDir = "HPA_PLAYBOOK_DIR"
|
||||
@@ -19,6 +20,7 @@ public struct Configuration: Codable {
|
||||
case templateRepoVersion = "HPA_TEMPLATE_VERSION"
|
||||
case templateDir = "HPA_TEMPLATE_DIR"
|
||||
case defaultPlaybookArgs = "HPA_DEFAULT_PLAYBOOK_ARGS"
|
||||
case defaultVaultArgs = "HPA_DEFAULT_VAULT_ARGS"
|
||||
}
|
||||
|
||||
public static func fromEnv(
|
||||
@@ -31,16 +33,14 @@ public struct Configuration: Codable {
|
||||
let hpaValues: [String: String] = env.filter { $0.key.contains("HPA") }
|
||||
logger.debug("HPA env vars: \(hpaValues)")
|
||||
|
||||
let defaultArgs: [String]? = hpaValues.value(key: .defaultPlaybookArgs)
|
||||
.flatMap { $0.split(separator: ",").map(String.init) }
|
||||
|
||||
return Configuration(
|
||||
playbookDir: hpaValues.value(key: .playbookDir),
|
||||
inventoryPath: hpaValues.value(key: .inventoryPath),
|
||||
templateRepo: hpaValues.value(key: .templateRepo),
|
||||
templateRepoVersion: hpaValues.value(key: .templateRepoVersion),
|
||||
templateDir: hpaValues.value(key: .templateDir),
|
||||
defaultPlaybookArgs: defaultArgs
|
||||
playbookDir: hpaValues.value(for: .playbookDir),
|
||||
inventoryPath: hpaValues.value(for: .inventoryPath),
|
||||
templateRepo: hpaValues.value(for: .templateRepo),
|
||||
templateRepoVersion: hpaValues.value(for: .templateRepoVersion),
|
||||
templateDir: hpaValues.value(for: .templateDir),
|
||||
defaultPlaybookArgs: hpaValues.array(for: .defaultPlaybookArgs),
|
||||
defaultVaultArgs: hpaValues.array(for: .defaultVaultArgs)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -51,7 +51,8 @@ public struct Configuration: Codable {
|
||||
templateRepo: "https://git.example.com/consult-template.git",
|
||||
templateRepoVersion: "main",
|
||||
templateDir: "/path/to/local/template",
|
||||
defaultPlaybookArgs: ["--vault-id=myId@$SCRIPTS/vault-gopass-client"]
|
||||
defaultPlaybookArgs: ["--tags", "debug"],
|
||||
defaultVaultArgs: ["--vault-id=myId@$SCRIPTS/vault-gopass-client"]
|
||||
)
|
||||
}
|
||||
|
||||
@@ -82,7 +83,11 @@ public struct Configuration: Codable {
|
||||
}
|
||||
|
||||
extension [String: String] {
|
||||
fileprivate func value(key codingKey: Configuration.CodingKeys) -> String? {
|
||||
fileprivate func value(for codingKey: Configuration.CodingKeys) -> String? {
|
||||
self[codingKey.rawValue]
|
||||
}
|
||||
|
||||
fileprivate func array(for codingKey: Configuration.CodingKeys) -> [String]? {
|
||||
value(for: codingKey).flatMap { $0.split(separator: ",").map(String.init) }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user