feat: Integrates playbook client into hpa-executable.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import ArgumentParser
|
||||
import CliClient
|
||||
import Dependencies
|
||||
import PlaybookClient
|
||||
|
||||
struct GenerateProjectTemplateCommand: AsyncParsableCommand {
|
||||
|
||||
@@ -39,24 +40,16 @@ struct GenerateProjectTemplateCommand: AsyncParsableCommand {
|
||||
var extraOptions: [String] = []
|
||||
|
||||
mutating func run() async throws {
|
||||
@Dependency(\.cliClient) var cliClient
|
||||
@Dependency(\.playbookClient) var playbookClient
|
||||
|
||||
var arguments = [
|
||||
"--tags", "repo-template",
|
||||
"--extra-vars", "output_dir=\(path)"
|
||||
]
|
||||
|
||||
if let varsDir = templateVars {
|
||||
arguments.append(contentsOf: ["--extra-vars", "repo_vars_dir=\(varsDir)"])
|
||||
}
|
||||
|
||||
if noVault {
|
||||
arguments.append(contentsOf: ["--extra-vars", "use_vault=false"])
|
||||
}
|
||||
|
||||
try await cliClient.runPlaybookCommand(
|
||||
globals.playbookOptions(arguments: arguments, configuration: nil),
|
||||
logging: globals.loggingOptions(commandName: Self.commandName)
|
||||
)
|
||||
try await playbookClient.run.generateTemplate(.init(
|
||||
shared: globals.sharedPlaybookRunOptions(
|
||||
commandName: Self.commandName,
|
||||
extraOptions: extraOptions
|
||||
),
|
||||
templateDirectory: path,
|
||||
templateVarsDirectory: templateVars,
|
||||
useVault: !noVault
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user