wokku-cli 0.5.2 → 0.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 51db3894481aec24701a7fc0172ca81910c1f6967c6a00decbf5d0dadb6454eb
4
- data.tar.gz: 7e3151f3a81c249667e3a1128eaaa58763b40d453c401504f53b35783f5da96c
3
+ metadata.gz: 1c7d8ff79cbc66dc2a088a04025b47c3c36ec6c0a954c68d02d42ee1dee34d46
4
+ data.tar.gz: 8dbc97b262bf992d0d1b63c4c7f6f876ce43866abcf258d203ad6df8b647b8da
5
5
  SHA512:
6
- metadata.gz: c021749b27b73a5c325c1f268de70c329b9aff10c325e67cfe6ef9b2a274f656967e2bb51732393a1548ea19d193255715e8bab66bafd50b7f92de650cbc570a
7
- data.tar.gz: e8c0fe5d6878a6105247fa049153a784885906decdc8cc92f8d3385ef357655f2d54c827658f30e6b6853a2e8eefe853ae37829f6ec92794294e0ec63c62f4c7
6
+ metadata.gz: eea912742f7b73ba8e908f4b85308e309882751f6899dfdb6e5161455091e9b18ca788534e91b01341594b0897f16d0046641ae9a4c2a5cd469cead422bc99b4
7
+ data.tar.gz: '019b37db8b1ccdb848f2b80a6da957490405bfd5c72680c4a067735068fb757c936ee7ecdef0affd3eef24d43ed371933bfdd65d3c24a9418c977fd009d4fdd2'
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.5.3 — 2026-06-26
4
+
5
+ ### Fixed
6
+
7
+ - `databases:create` and `addons:shared:enable` no longer report success optimistically. The CLI used to print "Created"/"Enabled" on any 2xx — including a `202 Accepted` ("queued") — so a database or shared engine that was still provisioning, or that failed afterward, looked done. Both commands now poll until the resource is actually `running` (then "Created"/"ready"), `error` (a clear failure + nonzero exit), or a timeout ("still provisioning — check `wokku addons APP` / `databases:info`"). Poll cadence is tunable via `WOKKU_POLL_ATTEMPTS`/`WOKKU_POLL_INTERVAL`.
8
+
3
9
  ## 0.5.2 — 2026-06-06
4
10
 
5
11
  ### Changed
@@ -40,8 +40,26 @@ end
40
40
  register "addons:shared:enable", "Enable a shared engine on an app (usage: wokku addons:shared:enable APP ENGINE). ENGINE: postgres|redis|memcached|rabbitmq|meilisearch" do
41
41
  id = ARGV.shift || abort("Usage: wokku addons:shared:enable APP ENGINE")
42
42
  engine = ARGV.shift || abort("Missing engine")
43
- data = api(:post, "/apps/#{id}/addons/shared", { engine: engine })
44
- Wokku::Output.status(data["message"] || "Enabled shared #{engine} on #{id}")
43
+ api(:post, "/apps/#{id}/addons/shared", { engine: engine })
44
+
45
+ attempts = (ENV["WOKKU_POLL_ATTEMPTS"] || "30").to_i
46
+ interval = (ENV["WOKKU_POLL_INTERVAL"] || "2").to_f
47
+
48
+ Wokku::Output.status "Enabling shared #{engine} on #{id} — provisioning…" unless Wokku.quiet
49
+ final = poll_until("/apps/#{id}/addons", attempts: attempts, interval: interval) do |list|
50
+ row = Array(list).find { |a| a["service_type"] == engine && a["shared"] }
51
+ row && %w[running error].include?(row["status"])
52
+ end
53
+
54
+ row = Array(final).find { |a| a["service_type"] == engine && a["shared"] }
55
+ case row && row["status"]
56
+ when "running"
57
+ Wokku::Output.status "Shared #{engine} ready on #{id}."
58
+ when "error"
59
+ abort "Shared #{engine} failed to provision on #{id}. See the dashboard or re-run to retry."
60
+ else
61
+ Wokku::Output.status "Shared #{engine} still provisioning on #{id}. Check: wokku addons #{id}"
62
+ end
45
63
  end
46
64
 
47
65
  register "addons:shared:disable", "Disable a shared engine on an app (usage: wokku addons:shared:disable APP ENGINE)" do
@@ -32,7 +32,23 @@ register "databases:create", "Create a database (usage: wokku databases:create N
32
32
  abort "Missing --type (postgres, mysql, redis, mongo)" unless type
33
33
  server = resolve_server(explicit: server)
34
34
  data = api(:post, "/databases", { name: name, service_type: type, server_id: server })
35
- Wokku::Output.status "Created #{data['service_type']} database: #{data['name']}"
35
+
36
+ if data["status"] != "running"
37
+ attempts = (ENV["WOKKU_POLL_ATTEMPTS"] || "15").to_i
38
+ interval = (ENV["WOKKU_POLL_INTERVAL"] || "2").to_f
39
+ data = poll_until("/databases/#{data['name']}", attempts: attempts, interval: interval) do |d|
40
+ %w[running error].include?(d["status"])
41
+ end || { "name" => name, "service_type" => type, "status" => "creating" }
42
+ end
43
+
44
+ case data["status"]
45
+ when "running"
46
+ Wokku::Output.status "Created #{data['service_type']} database: #{data['name']}"
47
+ when "error"
48
+ abort "Database '#{data['name']}' failed to provision."
49
+ else
50
+ Wokku::Output.status "Database '#{data['name']}' is still provisioning. Check: wokku databases:info #{data['name']}"
51
+ end
36
52
  end
37
53
 
38
54
  register "databases:destroy", "Destroy a database (usage: wokku databases:destroy NAME)" do
data/lib/wokku/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Wokku
3
- VERSION = "0.5.2"
3
+ VERSION = "0.5.3"
4
4
  end
data/lib/wokku.rb CHANGED
@@ -80,6 +80,19 @@ rescue Wokku::ApiClient::NotAuthenticated, Wokku::ApiClient::Timeout,
80
80
  abort e.message
81
81
  end
82
82
 
83
+ # Poll GET <path> until the block returns truthy (returns that data) or the
84
+ # attempt budget is exhausted (returns nil). interval is injectable so specs
85
+ # can run with no real sleep.
86
+ def poll_until(path, attempts: 30, interval: 2)
87
+ attempts.times do |i|
88
+ data = api(:get, path)
89
+ return data if yield(data)
90
+
91
+ sleep(interval) if interval.positive? && i < attempts - 1
92
+ end
93
+ nil
94
+ end
95
+
83
96
  def load_config = Wokku::Config.load
84
97
  def save_config(data) = Wokku::Config.save(data)
85
98
  def api_url = Wokku::Config.api_url
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wokku-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Johannes Dwicahyo