154 lines
3.7 KiB
Swift
154 lines
3.7 KiB
Swift
import Foundation
|
|
|
|
// NOTE: When adding items, then the 'hpa.toml' resource file needs to be updated.
|
|
|
|
/// Represents configurable settings for the application.
|
|
public struct Configuration: Codable, Equatable, Sendable {
|
|
|
|
/// Default arguments / options that can get passed into
|
|
/// ansible-playbook commands.
|
|
public let args: [String]?
|
|
|
|
/// Whether to use the vault arguments as defaults that get passed into
|
|
/// the ansible-playbook commands.
|
|
public let useVaultArgs: Bool
|
|
|
|
/// Configuration for when generating files from templated directories.
|
|
public let generate: Generate?
|
|
|
|
/// Configuration of the ansible-playbook, these are more for developing the
|
|
/// playbook locally and generally not needed by the user.
|
|
public let playbook: Playbook?
|
|
|
|
/// Template configuration options.
|
|
public let template: Template
|
|
|
|
/// Ansible-vault configuration options.
|
|
public let vault: Vault
|
|
|
|
public init(
|
|
args: [String]? = nil,
|
|
useVaultArgs: Bool = true,
|
|
generate: Generate? = nil,
|
|
playbook: Playbook? = nil,
|
|
template: Template = .init(),
|
|
vault: Vault = .init()
|
|
) {
|
|
self.args = args
|
|
self.useVaultArgs = useVaultArgs
|
|
self.generate = generate
|
|
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 Generate: Codable, Equatable, Sendable {
|
|
public let buildDirectory: String?
|
|
public let files: [String]?
|
|
public let includeInHeader: [String]?
|
|
public let outputFileName: String?
|
|
public let pdfEngine: String?
|
|
|
|
public init(
|
|
buildDirectory: String? = nil,
|
|
files: [String]? = nil,
|
|
includeInHeader: [String]? = nil,
|
|
outputFileName: String? = nil,
|
|
pdfEngine: String? = nil
|
|
) {
|
|
self.buildDirectory = buildDirectory
|
|
self.files = files
|
|
self.includeInHeader = includeInHeader
|
|
self.outputFileName = outputFileName
|
|
self.pdfEngine = pdfEngine
|
|
}
|
|
|
|
public static let `default` = Self.mock
|
|
|
|
public static var mock: Self {
|
|
.init(
|
|
buildDirectory: ".build",
|
|
files: ["Report.md", "Definitions.md"],
|
|
includeInHeader: ["head.tex", "footer.tex"],
|
|
outputFileName: "Report",
|
|
pdfEngine: "xelatex"
|
|
)
|
|
}
|
|
}
|
|
|
|
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"
|
|
)
|
|
}
|
|
}
|
|
}
|