100 lines
2.2 KiB
Swift
100 lines
2.2 KiB
Swift
import Foundation
|
|
|
|
/// Represents configurable settings for the command line tool.
|
|
public struct Configuration: Codable, Equatable, Sendable {
|
|
public let args: [String]?
|
|
public let useVaultArgs: Bool
|
|
public let playbook: Playbook?
|
|
public let template: Template
|
|
public let vault: Vault
|
|
|
|
public init(
|
|
args: [String]? = nil,
|
|
useVaultArgs: Bool = true,
|
|
playbook: Playbook? = nil,
|
|
template: Template = .init(),
|
|
vault: Vault = .init()
|
|
) {
|
|
self.args = args
|
|
self.useVaultArgs = useVaultArgs
|
|
self.playbook = playbook
|
|
self.template = template
|
|
self.vault = vault
|
|
}
|
|
|
|
public static var mock: Self {
|
|
.init(
|
|
args: [],
|
|
useVaultArgs: true,
|
|
playbook: nil,
|
|
template: .mock,
|
|
vault: .mock
|
|
)
|
|
}
|
|
|
|
public struct Playbook: Codable, Equatable, Sendable {
|
|
|
|
public let directory: String?
|
|
public let inventory: String?
|
|
public let version: String?
|
|
|
|
public init(
|
|
directory: String? = nil,
|
|
inventory: String? = nil,
|
|
version: String? = nil
|
|
) {
|
|
self.directory = directory
|
|
self.inventory = inventory
|
|
self.version = version
|
|
}
|
|
|
|
public static var mock: Self { .init() }
|
|
}
|
|
|
|
public struct Template: Codable, Equatable, Sendable {
|
|
public let url: String?
|
|
public let version: String?
|
|
public let directory: String?
|
|
|
|
public init(
|
|
url: String? = nil,
|
|
version: String? = nil,
|
|
directory: String? = nil
|
|
) {
|
|
self.url = url
|
|
self.version = version
|
|
self.directory = directory
|
|
}
|
|
|
|
public static var mock: Self {
|
|
.init(
|
|
url: "https://git.example.com/consult-template.git",
|
|
version: "1.0.0",
|
|
directory: "/path/to/local/template-directory"
|
|
)
|
|
}
|
|
}
|
|
|
|
public struct Vault: Codable, Equatable, Sendable {
|
|
public let args: [String]?
|
|
public let encryptId: String?
|
|
|
|
public init(
|
|
args: [String]? = nil,
|
|
encryptId: String? = nil
|
|
) {
|
|
self.args = args
|
|
self.encryptId = encryptId
|
|
}
|
|
|
|
public static var mock: Self {
|
|
.init(
|
|
args: [
|
|
"--vault-id=myId@$SCRIPTS/vault-gopass-client"
|
|
],
|
|
encryptId: "myId"
|
|
)
|
|
}
|
|
}
|
|
}
|