Top Level Namespace
Defined Under Namespace
Modules: Wokku
Constant Summary collapse
- CONFIG_DIR =
Wokku::Config::DEFAULT_DIR
- CONFIG_FILE =
File.join(CONFIG_DIR, "config.json")
- VERSION =
Wokku::VERSION
Instance Method Summary collapse
-
#api(method, path, body = nil) ⇒ Object
Top-level helper shims used by command blocks (preserved for compatibility with the existing register-DSL pattern).
- #api_token ⇒ Object
- #api_url ⇒ Object
-
#find_domain(app_id, hostname) ⇒ Object
Look up a domain row by hostname so users can pass the name they know rather than an internal id.
- #load_config ⇒ Object
- #puts_json(data) ⇒ Object
- #register(name, desc, &block) ⇒ Object
-
#resolve_server(explicit: nil) ⇒ Object
Resolve which server to target for a deploy/create.
- #save_config(data) ⇒ Object
- #table(rows, headers: nil) ⇒ Object
Instance Method Details
#api(method, path, body = nil) ⇒ Object
Top-level helper shims used by command blocks (preserved for compatibility with the existing register-DSL pattern).
75 76 77 78 79 80 |
# File 'lib/wokku.rb', line 75 def api(method, path, body = nil) Wokku.api_client.request(method, path, body) rescue Wokku::ApiClient::NotAuthenticated, Wokku::ApiClient::Timeout, Wokku::ApiClient::Unreachable, Wokku::ApiClient::Error => e abort e. end |
#find_domain(app_id, hostname) ⇒ Object
Look up a domain row by hostname so users can pass the name they know rather than an internal id. Returns nil when not found or when the API returns a non-array (error envelope).
10 11 12 13 14 |
# File 'lib/wokku/helpers.rb', line 10 def find_domain(app_id, hostname) list = api(:get, "/apps/#{app_id}/domains") return nil unless list.is_a?(Array) list.find { |d| d["hostname"] == hostname } end |
#puts_json(data) ⇒ Object
87 |
# File 'lib/wokku.rb', line 87 def puts_json(data) = Wokku::Output.puts_json(data) |
#register(name, desc, &block) ⇒ Object
88 |
# File 'lib/wokku.rb', line 88 def register(name, desc, &block) = Wokku::Registry.register(name, desc, &block) |
#resolve_server(explicit: nil) ⇒ Object
Resolve which server to target for a deploy/create. Walks the precedence chain: explicit flag → env → config → auto-pick if only one server → abort with helpful error. Returns the server name or UUID (whatever was explicitly passed/configured).
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/wokku/helpers.rb', line 20 def resolve_server(explicit: nil) return explicit if explicit env = ENV["WOKKU_DEFAULT_SERVER"] return env if env && !env.empty? cfg_default = Wokku::Config.load["default_server"] return cfg_default if cfg_default servers = api(:get, "/servers") unless servers.is_a?(Array) abort "Unexpected response from /servers: #{servers.inspect[0..200]}" end abort "No servers available. Contact wokku.cloud support." if servers.empty? return servers.first["name"] if servers.size == 1 names = servers.map { |s| s["name"] }.join(", ") abort "Multiple servers available (#{names}). Pass --server NAME or set a default: wokku servers:default NAME" end |