feat: Integrates playbook client into hpa-executable.
This commit is contained in:
@@ -44,6 +44,7 @@ public extension PlaybookClient {
|
||||
struct RunPlaybook: Sendable {
|
||||
public var buildProject: @Sendable (BuildOptions) async throws -> Void
|
||||
public var createProject: @Sendable (CreateOptions, JSONEncoder?) async throws -> Void
|
||||
public var generateTemplate: @Sendable (GenerateTemplateOptions) async throws -> Void
|
||||
|
||||
public func createProject(_ options: CreateOptions) async throws {
|
||||
try await createProject(options, nil)
|
||||
@@ -84,26 +85,6 @@ public extension PlaybookClient {
|
||||
self.shared = shared
|
||||
}
|
||||
|
||||
public init(
|
||||
extraOptions: [String]? = nil,
|
||||
inventoryFilePath: String? = nil,
|
||||
loggingOptions: LoggingOptions,
|
||||
quiet: Bool = false,
|
||||
shell: String? = nil,
|
||||
projectDirectory: String? = nil
|
||||
) {
|
||||
self.init(
|
||||
projectDirectory: projectDirectory,
|
||||
shared: .init(
|
||||
extraOptions: extraOptions,
|
||||
inventoryFilePath: inventoryFilePath,
|
||||
loggingOptions: loggingOptions,
|
||||
quiet: quiet,
|
||||
shell: shell
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
public subscript<T>(dynamicMember keyPath: KeyPath<SharedRunOptions, T>) -> T {
|
||||
shared[keyPath: keyPath]
|
||||
}
|
||||
@@ -128,28 +109,28 @@ public extension PlaybookClient {
|
||||
self.useLocalTemplateDirectory = useLocalTemplateDirectory
|
||||
}
|
||||
|
||||
public subscript<T>(dynamicMember keyPath: KeyPath<SharedRunOptions, T>) -> T {
|
||||
shared[keyPath: keyPath]
|
||||
}
|
||||
}
|
||||
|
||||
@dynamicMemberLookup
|
||||
public struct GenerateTemplateOptions: Equatable, Sendable {
|
||||
public let shared: SharedRunOptions
|
||||
public let templateDirectory: String
|
||||
public let templateVarsDirectory: String?
|
||||
public let useVault: Bool
|
||||
|
||||
public init(
|
||||
extraOptions: [String]? = nil,
|
||||
inventoryFilePath: String? = nil,
|
||||
loggingOptions: LoggingOptions,
|
||||
projectDirectory: String,
|
||||
quiet: Bool = false,
|
||||
shell: String? = nil,
|
||||
template: Configuration.Template? = nil,
|
||||
useLocalTemplateDirectory: Bool = false
|
||||
shared: SharedRunOptions,
|
||||
templateDirectory: String,
|
||||
templateVarsDirectory: String? = nil,
|
||||
useVault: Bool = true
|
||||
) {
|
||||
self.init(
|
||||
projectDirectory: projectDirectory,
|
||||
shared: .init(
|
||||
extraOptions: extraOptions,
|
||||
inventoryFilePath: inventoryFilePath,
|
||||
loggingOptions: loggingOptions,
|
||||
quiet: quiet,
|
||||
shell: shell
|
||||
),
|
||||
template: template,
|
||||
useLocalTemplateDirectory: useLocalTemplateDirectory
|
||||
)
|
||||
self.shared = shared
|
||||
self.templateDirectory = templateDirectory
|
||||
self.templateVarsDirectory = templateVarsDirectory
|
||||
self.useVault = useVault
|
||||
}
|
||||
|
||||
public subscript<T>(dynamicMember keyPath: KeyPath<SharedRunOptions, T>) -> T {
|
||||
@@ -173,7 +154,8 @@ extension PlaybookClient.RunPlaybook: DependencyKey {
|
||||
public static var liveValue: PlaybookClient.RunPlaybook {
|
||||
.init(
|
||||
buildProject: { try await $0.run() },
|
||||
createProject: { try await $0.run(encoder: $1) }
|
||||
createProject: { try await $0.run(encoder: $1) },
|
||||
generateTemplate: { try await $0.run() }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user