Class: Harbor::KamalAdapter
- Inherits:
-
Object
- Object
- Harbor::KamalAdapter
- Defined in:
- lib/harbor/kamal_adapter.rb
Defined Under Namespace
Classes: Result
Instance Attribute Summary collapse
-
#project ⇒ Object
readonly
Returns the value of attribute project.
Instance Method Summary collapse
- #app_version(destination: nil) ⇒ Object
- #audit_log(destination: nil) ⇒ Object
-
#deploy(destination: nil, skip_push: false, timeout_seconds: nil) ⇒ Object
Write operations — shell out to kamal CLI.
- #details(destination: nil) ⇒ Object
- #exec_command(command, role: nil, destination: nil, timeout_seconds: nil) ⇒ Object
-
#initialize(project, config: nil) ⇒ KamalAdapter
constructor
A new instance of KamalAdapter.
- #logs(role: nil, lines: 100, grep: nil, destination: nil) ⇒ Object
- #maintenance(enabled:, destination: nil) ⇒ Object
- #proxy_details(destination: nil) ⇒ Object
- #rollback(version:, destination: nil, timeout_seconds: nil) ⇒ Object
-
#status(destination: nil) ⇒ Object
Read-only operations — run kamal commands and capture output.
Constructor Details
#initialize(project, config: nil) ⇒ KamalAdapter
Returns a new instance of KamalAdapter.
11 12 13 14 |
# File 'lib/harbor/kamal_adapter.rb', line 11 def initialize(project, config: nil) @project = project @config = config end |
Instance Attribute Details
#project ⇒ Object (readonly)
Returns the value of attribute project.
9 10 11 |
# File 'lib/harbor/kamal_adapter.rb', line 9 def project @project end |
Instance Method Details
#app_version(destination: nil) ⇒ Object
34 35 36 |
# File 'lib/harbor/kamal_adapter.rb', line 34 def app_version(destination: nil) run_kamal("app", "version", destination: destination) end |
#audit_log(destination: nil) ⇒ Object
67 68 69 |
# File 'lib/harbor/kamal_adapter.rb', line 67 def audit_log(destination: nil) run_kamal("audit", destination: destination) end |
#deploy(destination: nil, skip_push: false, timeout_seconds: nil) ⇒ Object
Write operations — shell out to kamal CLI
44 45 46 47 48 |
# File 'lib/harbor/kamal_adapter.rb', line 44 def deploy(destination: nil, skip_push: false, timeout_seconds: nil) args = ["deploy"] args << "--skip-push" if skip_push run_kamal(*args, destination: destination, timeout: timeout_seconds) end |
#details(destination: nil) ⇒ Object
30 31 32 |
# File 'lib/harbor/kamal_adapter.rb', line 30 def details(destination: nil) run_kamal("details", destination: destination) end |
#exec_command(command, role: nil, destination: nil, timeout_seconds: nil) ⇒ Object
54 55 56 57 58 59 60 |
# File 'lib/harbor/kamal_adapter.rb', line 54 def exec_command(command, role: nil, destination: nil, timeout_seconds: nil) validate_exec_command!(command) args = ["app", "exec", command] args += ["-r", role] if role run_kamal(*args, destination: destination, timeout: timeout_seconds) end |
#logs(role: nil, lines: 100, grep: nil, destination: nil) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/harbor/kamal_adapter.rb', line 22 def logs(role: nil, lines: 100, grep: nil, destination: nil) args = ["app", "logs"] args += ["-r", role] if role args += ["-n", lines.to_s] if lines args += ["--grep", grep] if grep run_kamal(*args, destination: destination) end |
#maintenance(enabled:, destination: nil) ⇒ Object
62 63 64 65 |
# File 'lib/harbor/kamal_adapter.rb', line 62 def maintenance(enabled:, destination: nil) subcmd = enabled ? "maintenance" : "live" run_kamal("app", subcmd, destination: destination) end |
#proxy_details(destination: nil) ⇒ Object
38 39 40 |
# File 'lib/harbor/kamal_adapter.rb', line 38 def proxy_details(destination: nil) run_kamal("proxy", "details", destination: destination) end |
#rollback(version:, destination: nil, timeout_seconds: nil) ⇒ Object
50 51 52 |
# File 'lib/harbor/kamal_adapter.rb', line 50 def rollback(version:, destination: nil, timeout_seconds: nil) run_kamal("rollback", version, destination: destination, timeout: timeout_seconds) end |
#status(destination: nil) ⇒ Object
Read-only operations — run kamal commands and capture output
18 19 20 |
# File 'lib/harbor/kamal_adapter.rb', line 18 def status(destination: nil) run_kamal("app", "details", destination: destination) end |