capistrano-data_plane_api 0.4.0 → 0.4.1

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: 129252a41d4e576802ee27f312f06875a71b8e9e116fe984c45d0ff4d83e0b08
4
- data.tar.gz: f9ef93c427519821ca84336b437d3e9707992bc7550e075077c7ac42711becae
3
+ metadata.gz: 7e249ffdb15e8e4386e46dc9d188e4a7248ef4323adce5b66604d7589e06c4ff
4
+ data.tar.gz: 814dddc14e0b26f0ff6f98d388e4740410ca87322b53d53d7269e7d8d2b0a809
5
5
  SHA512:
6
- metadata.gz: bb2eea9deb79ac6387b2d27b988074c3e9cd13e25ce05d057af29ef135407539f0896aba1ece6c68abf48472f70778e265f0031c664d1a9bd2486c2337596898
7
- data.tar.gz: 7f8eedc6fa57fee424309618b5f5bdba5bde4c4fb9e19fb241484e4197a013cc01365d51a0fc26f2751704bc54fc4a77598b176211be8e8aea72959ba49ff07b
6
+ metadata.gz: 0511d4dcf7ea85ebbab93180092810408a6234dba46b1d61d28b28cbe1fd58ff32a08a8246eb094165f4e4c0360ea9f19313a8cdd24acfc1dae1abbab02b465a
7
+ data.tar.gz: fb92d42d547fe7a2d1ca586eb2996bfc155365abfea6edd996376eacc470118f954f6a188caa5b554897c54224d284326024b061e176f92f6f0ecc8a307d698b
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- capistrano-data_plane_api (0.4.0)
4
+ capistrano-data_plane_api (0.4.1)
5
5
  booleans (~> 0.1)
6
6
  data_plane_api (>= 0.2)
7
7
  pastel (< 1)
@@ -19,7 +19,7 @@ GEM
19
19
  public_suffix (>= 2.0.2, < 7.0)
20
20
  ast (2.4.3)
21
21
  base64 (0.2.0)
22
- benchmark (0.2.1)
22
+ benchmark (0.5.0)
23
23
  bigdecimal (3.1.9)
24
24
  booleans (0.1.3)
25
25
  sorbet-runtime (>= 0.5)
@@ -47,23 +47,23 @@ GEM
47
47
  net-http (0.6.0)
48
48
  uri
49
49
  netrc (0.11.0)
50
- parallel (1.26.3)
50
+ parallel (1.27.0)
51
51
  parser (3.3.7.4)
52
52
  ast (~> 2.4.1)
53
53
  racc
54
54
  pastel (0.8.0)
55
55
  tty-color (~> 0.5)
56
- prism (1.4.0)
56
+ prism (1.9.0)
57
57
  public_suffix (6.0.1)
58
58
  racc (1.8.1)
59
59
  rainbow (3.1.1)
60
60
  rake (13.0.6)
61
- rbi (0.3.1)
61
+ rbi (0.3.9)
62
62
  prism (~> 1.0)
63
63
  rbs (>= 3.4.4)
64
- sorbet-runtime (>= 0.5.9204)
65
- rbs (3.9.2)
64
+ rbs (3.10.3)
66
65
  logger
66
+ tsort
67
67
  regexp_parser (2.10.0)
68
68
  rexml (3.4.1)
69
69
  rubocop (1.75.2)
@@ -92,18 +92,19 @@ GEM
92
92
  shale (< 2.0)
93
93
  sorbet-runtime (> 0.5)
94
94
  shoulda-context (2.0.0)
95
- sorbet (0.5.12003)
96
- sorbet-static (= 0.5.12003)
97
- sorbet-runtime (0.5.12003)
98
- sorbet-static (0.5.12003-universal-darwin)
99
- sorbet-static (0.5.12003-x86_64-linux)
100
- sorbet-static-and-runtime (0.5.12003)
101
- sorbet (= 0.5.12003)
102
- sorbet-runtime (= 0.5.12003)
103
- spoom (1.6.1)
95
+ sorbet (0.6.12940)
96
+ sorbet-static (= 0.6.12940)
97
+ sorbet-runtime (0.6.12940)
98
+ sorbet-static (0.6.12940-universal-darwin)
99
+ sorbet-static (0.6.12940-x86_64-linux)
100
+ sorbet-static-and-runtime (0.6.12940)
101
+ sorbet (= 0.6.12940)
102
+ sorbet-runtime (= 0.6.12940)
103
+ spoom (1.6.3)
104
104
  erubi (>= 1.10.0)
105
105
  prism (>= 0.28.0)
106
- rbi (>= 0.2.3)
106
+ rbi (>= 0.3.3)
107
+ rexml (>= 3.2.6)
107
108
  sorbet-static-and-runtime (>= 0.5.10187)
108
109
  thor (>= 0.19.2)
109
110
  strings (0.2.1)
@@ -121,7 +122,8 @@ GEM
121
122
  spoom (>= 1.2.0)
122
123
  thor (>= 1.2.0)
123
124
  yard-sorbet
124
- thor (1.2.1)
125
+ thor (1.5.0)
126
+ tsort (0.2.0)
125
127
  tty-box (0.7.0)
126
128
  pastel (~> 0.8)
127
129
  strings (~> 0.2.0)
@@ -137,9 +139,7 @@ GEM
137
139
  addressable (>= 2.8.0)
138
140
  crack (>= 0.3.2)
139
141
  hashdiff (>= 0.4.0, < 2.0.0)
140
- webrick (1.7.0)
141
- yard (0.9.28)
142
- webrick (~> 1.7.0)
142
+ yard (0.9.38)
143
143
  yard-sorbet (0.9.0)
144
144
  sorbet-runtime
145
145
  yard
@@ -13,7 +13,7 @@ module Capistrano
13
13
  class Args
14
14
  PRINTABLE_ENV_VARS = %w[BRANCH NO_MIGRATIONS NO_ASSET_PRECOMPILATION].freeze
15
15
 
16
- #: (Array[untyped]?) -> instance
16
+ #: (?Array[untyped]?) -> instance
17
17
  def self.parse(options = nil) # rubocop:disable Metrics/MethodLength, Style/ClassMethodsDefinitions
18
18
  args = new
19
19
 
@@ -237,13 +237,13 @@ module Capistrano
237
237
  @group = backend.name
238
238
  end
239
239
 
240
- #: (String | Symbol | nil) -> String
240
+ #: (?String | Symbol | nil) -> String
241
241
  def deploy_command(stage = nil)
242
242
  used_stage = stage || self.stage
243
243
  "cap #{used_stage} #{rake}"
244
244
  end
245
245
 
246
- #: (String | Symbol | nil) -> String
246
+ #: (?String | Symbol | nil) -> String
247
247
  def humanized_deploy_command(stage = nil)
248
248
  result = ::String.new
249
249
  PRINTABLE_ENV_VARS.each do |env_var_name|
@@ -30,10 +30,10 @@ module Capistrano
30
30
  @backend = nil
31
31
  @start_time = nil
32
32
  @end_time = nil
33
- @state = T.let(:pending, Symbol)
34
- @server_stats = T.let({}, T::Hash[String, Deploy::ServerStats])
35
- @seconds = T.let(nil, T.nilable(Integer))
36
- @update_states_in_stats = T.let(false, T::Boolean)
33
+ @state = :pending #: Symbol
34
+ @server_stats = {} #: Hash[String, Deploy::ServerStats]
35
+ @seconds = nil #: Integer?
36
+ @update_states_in_stats = false #: bool
37
37
  end
38
38
 
39
39
  #: (String) -> Deploy::ServerStats
@@ -8,28 +8,41 @@ module Capistrano
8
8
  # in a particular HAProxy backend/group.
9
9
  class Group
10
10
  class << self
11
- #: (Args) -> Symbol
11
+ #: (Args) -> DeploymentStats
12
12
  def call(args)
13
13
  new(args).call
14
14
  end
15
15
  end
16
16
 
17
+ #: Configuration::Backend?
18
+ attr_reader :backend
19
+
20
+ #: Array[Configuration::Server]?
21
+ attr_reader :servers
22
+
23
+ #: DeploymentStats
24
+ attr_reader :deployment_stats
25
+
26
+ #: Symbol
27
+ attr_reader :state
28
+
17
29
  #: (Args) -> void
18
30
  def initialize(args)
19
31
  @args = args
20
- @deployment_stats = T.let(DeploymentStats.new, DeploymentStats)
21
- @backend = T.let(nil, T.nilable(Configuration::Backend))
22
- @servers = T.let(nil, T.nilable(T::Array[Configuration::Server]))
32
+ @deployment_stats = DeploymentStats.new #: DeploymentStats
33
+ @backend = nil #: Configuration::Backend?
34
+ @servers = nil #: Array[Configuration::Server]?
35
+ @state = :pending #: Symbol
23
36
  end
24
37
 
25
- # Whether the deployment has been successful
26
- #: -> Symbol
38
+ # Carries out the deployment and returns the stats
39
+ #
40
+ #: -> DeploymentStats
27
41
  def call
28
42
  @backend = ::Capistrano::DataPlaneApi.find_backend(T.must(@args.group))
29
- @servers = servers(@backend)
43
+ @servers = get_servers(@backend)
30
44
  start_deployment
31
45
 
32
- state = :pending
33
46
  @servers&.each do |server|
34
47
  server_stats = @deployment_stats[T.must(server.name)]
35
48
  puts COLORS.bold.blue("Deploying the app to `#{server.stage}` -- `#{@backend.name}:#{server.name}`")
@@ -43,27 +56,27 @@ module Capistrano
43
56
  deploy_command = @args.deploy_command(server.stage)
44
57
  case system deploy_command
45
58
  when true
46
- state = :success
59
+ @state = :success
47
60
  when false
48
- state = :failed
61
+ @state = :failed
49
62
  when nil
50
- state = :pending
63
+ @state = :pending
51
64
  end
52
65
 
53
66
  server_stats.end_time = ::Time.now
54
- server_stats.state = state
67
+ server_stats.state = @state
55
68
 
56
- next if state == :success
69
+ next if @state == :success
57
70
 
58
71
  puts COLORS.bold.red("Command `#{deploy_command}` failed")
59
72
  break
60
73
  end
61
74
 
62
- return :pending if @args.test?
75
+ return @deployment_stats if @args.test?
63
76
 
64
- finish_deployment(state: state)
77
+ finish_deployment(state: @state)
65
78
  print_summary
66
- state
79
+ @deployment_stats
67
80
  end
68
81
 
69
82
  private
@@ -77,7 +90,7 @@ module Capistrano
77
90
  end
78
91
  end
79
92
 
80
- #: (Symbol) -> void
93
+ #: (?state: Symbol) -> void
81
94
  def finish_deployment(state: :success)
82
95
  @deployment_stats.end_time = ::Time.now
83
96
  @deployment_stats.state = state
@@ -89,7 +102,7 @@ module Capistrano
89
102
  end
90
103
 
91
104
  #: (Configuration::Backend) -> Array[Configuration::Server]?
92
- def servers(backend)
105
+ def get_servers(backend)
93
106
  return backend.servers unless @args.only?
94
107
 
95
108
  chosen_servers = []
@@ -39,7 +39,7 @@ module Capistrano
39
39
  # Calculate how many seconds have passed
40
40
  # since the given point in time.
41
41
  #
42
- #: (Time, Time) -> Integer
42
+ #: (Time, ?to: Time) -> Integer
43
43
  def seconds_since(time, to: ::Time.now)
44
44
  (to - time).to_i
45
45
  end
@@ -30,7 +30,7 @@ module Capistrano
30
30
  #: String
31
31
  attr_accessor :operational_state
32
32
 
33
- #: (String, String, Symbol, String, String) -> void
33
+ #: (String, String, ?state: Symbol, ?admin_state: String, ?operational_state: String) -> void
34
34
  def initialize(
35
35
  server_name,
36
36
  backend_name,
@@ -43,7 +43,7 @@ module Capistrano
43
43
  @state = state
44
44
  @admin_state = admin_state
45
45
  @operational_state = operational_state
46
- @seconds = T.let(nil, T.nilable(Integer))
46
+ @seconds = nil #: Integer?
47
47
  end
48
48
 
49
49
  #: -> String
@@ -87,15 +87,12 @@ module Capistrano
87
87
  HAPROXY
88
88
  end
89
89
 
90
- SERVER_TITLE_COLORS = T.let(
91
- {
92
- pending: :yellow,
93
- failed: :red,
94
- success: :green,
95
- info: :blue,
96
- }.freeze,
97
- T::Hash[Symbol, Symbol],
98
- )
90
+ SERVER_TITLE_COLORS = {
91
+ pending: :yellow,
92
+ failed: :red,
93
+ success: :green,
94
+ info: :blue,
95
+ }.freeze #: Hash[Symbol, Symbol]
99
96
  private_constant :SERVER_TITLE_COLORS
100
97
 
101
98
  #: -> String
@@ -108,15 +105,12 @@ module Capistrano
108
105
  "#{@backend_name}:#{@server_name}"
109
106
  end
110
107
 
111
- STATE_EMOJIS = T.let(
112
- {
113
- pending: '🟡',
114
- failed: '',
115
- success: '',
116
- info: 'ℹ️',
117
- }.freeze,
118
- T::Hash[Symbol, String],
119
- )
108
+ STATE_EMOJIS = {
109
+ pending: '🟡',
110
+ failed: '',
111
+ success: '',
112
+ info: 'ℹ️',
113
+ }.freeze #: Hash[Symbol, String]
120
114
  private_constant :STATE_EMOJIS
121
115
 
122
116
  #: -> String
@@ -13,14 +13,14 @@ module Capistrano
13
13
  #
14
14
  #: -> void
15
15
  def call
16
- result = call!
17
- abort if result == :failed
16
+ stats = call!
17
+ abort if stats.state == :failed
18
18
  end
19
19
 
20
20
  # Returns when the deployment is over.
21
21
  # Returns the final state of the deployment as a symbol `:failed`, `:pending` or `:success`
22
22
  #
23
- #: -> Symbol
23
+ #: -> DeploymentStats
24
24
  def call!
25
25
  args = Args.parse
26
26
  puts COLORS.bold.blue('Running the deployment script')
@@ -14,7 +14,7 @@ module Capistrano
14
14
  # This implementation of `dig` uses `public_send` under the hood.
15
15
  #
16
16
  # @raise [TypeError] value has no #dig method
17
- #: (untyped) -> untyped
17
+ #: (*untyped) -> untyped
18
18
  def dig(*args)
19
19
  return unless args.size.positive?
20
20
 
@@ -5,25 +5,19 @@ module Capistrano
5
5
  module DataPlaneApi
6
6
  # Provides helper methods
7
7
  module Helper
8
- ADMIN_STATE_COLORS = T.let(
9
- {
10
- 'unknown' => :on_red,
11
- 'drain' => :on_blue,
12
- 'ready' => :on_green,
13
- 'maint' => :on_yellow,
14
- }.freeze,
15
- T::Hash[String, Symbol],
16
- )
17
-
18
- OPERATIONAL_STATE_COLORS = T.let(
19
- {
20
- 'unknown' => :on_red,
21
- 'up' => :on_green,
22
- 'down' => :on_red,
23
- 'stopping' => :on_yellow,
24
- }.freeze,
25
- T::Hash[String, Symbol],
26
- )
8
+ ADMIN_STATE_COLORS = {
9
+ 'unknown' => :on_red,
10
+ 'drain' => :on_blue,
11
+ 'ready' => :on_green,
12
+ 'maint' => :on_yellow,
13
+ }.freeze #: Hash[String, Symbol]
14
+
15
+ OPERATIONAL_STATE_COLORS = {
16
+ 'unknown' => :on_red,
17
+ 'up' => :on_green,
18
+ 'down' => :on_red,
19
+ 'stopping' => :on_yellow,
20
+ }.freeze #: Hash[String, Symbol]
27
21
 
28
22
  #: -> bool
29
23
  def no_haproxy?
@@ -15,7 +15,7 @@ module Capistrano
15
15
  # before another frame is printed.
16
16
  #
17
17
  # @param interval: Number of seconds between each screen refresh
18
- #: (Integer) { (String) -> Object } -> void
18
+ #: (?interval: Integer) { (String) -> Object } -> void
19
19
  def call(interval: 2, &_block)
20
20
  previous_line_count = 0
21
21
  previous_max_line_length = 0
@@ -3,6 +3,6 @@
3
3
 
4
4
  module Capistrano
5
5
  module DataPlaneApi
6
- VERSION = '0.4.0'
6
+ VERSION = '0.4.1'
7
7
  end
8
8
  end
@@ -82,7 +82,7 @@ module Capistrano
82
82
  # @return: Server state after the change, or `nil`
83
83
  # when no change happened
84
84
  # @raise [Error] The process failed due to some reason
85
- #: (String | Symbol, bool, ::DataPlaneApi::Configuration?) -> Hash[String, untyped]?
85
+ #: (String | Symbol, ?force: bool, ?config: ::DataPlaneApi::Configuration?) -> Hash[String, untyped]?
86
86
  def server_set_drain(deployment_stage, force: false, config: nil)
87
87
  haproxy_server, haproxy_backend = find_server_and_backend(deployment_stage)
88
88
  servers = T.must haproxy_backend.servers
@@ -119,7 +119,7 @@ module Capistrano
119
119
  # @param force: Change the server's state even when no other server is `up`
120
120
  # @return: Server state after the change, or `nil` when no change happened
121
121
  # @raise [Error] The process failed due to some reason
122
- #: (String | Symbol, bool, ::DataPlaneApi::Configuration?) -> Hash[String, untyped]?
122
+ #: (String | Symbol, ?force: bool, ?config: ::DataPlaneApi::Configuration?) -> Hash[String, untyped]?
123
123
  def server_set_maint(deployment_stage, force: false, config: nil)
124
124
  haproxy_server, haproxy_backend = find_server_and_backend(deployment_stage)
125
125
  servers = T.must haproxy_backend.servers
@@ -155,7 +155,7 @@ module Capistrano
155
155
  #
156
156
  # @return: Server state after the change, or `nil` when no change happened
157
157
  # @raise [Error] The process failed due to some reason
158
- #: (String | Symbol, ::DataPlaneApi::Configuration?) -> Hash[String, untyped]?
158
+ #: (String | Symbol, ?config: ::DataPlaneApi::Configuration?) -> Hash[String, untyped]?
159
159
  def server_set_ready(deployment_stage, config: nil)
160
160
  haproxy_server, haproxy_backend = find_server_and_backend(deployment_stage)
161
161
  servers = T.must haproxy_backend.servers
@@ -192,7 +192,7 @@ module Capistrano
192
192
  #
193
193
  # @return: Server state
194
194
  # @raise [Error] The process failed due to some reason
195
- #: (String | Symbol, ::DataPlaneApi::Configuration?) -> Hash[String, untyped]?
195
+ #: (String | Symbol, ?config: ::DataPlaneApi::Configuration?) -> Hash[String, untyped]?
196
196
  def server_get_state(deployment_stage, config: nil)
197
197
  haproxy_server, haproxy_backend = find_server_and_backend(deployment_stage)
198
198
 
@@ -246,7 +246,7 @@ module Capistrano
246
246
  [T.must(haproxy_server), haproxy_backend]
247
247
  end
248
248
 
249
- #: (Symbol | String, ::DataPlaneApi::Configuration?) -> Faraday::Response
249
+ #: (Symbol | String, ?config: ::DataPlaneApi::Configuration?) -> Faraday::Response
250
250
  def get_backend_servers_settings(backend_name, config: nil)
251
251
  haproxy_backend = find_backend(backend_name)
252
252
  conf = ::DataPlaneApi::Configuration.new(
@@ -267,7 +267,7 @@ module Capistrano
267
267
  response
268
268
  end
269
269
 
270
- #: (Symbol | String, Symbol | String, ::DataPlaneApi::Configuration?) -> Faraday::Response
270
+ #: (Symbol | String, Symbol | String, ?config: ::DataPlaneApi::Configuration?) -> Faraday::Response
271
271
  def get_server_settings(backend_name, server_name, config: nil)
272
272
  haproxy_backend = find_backend(backend_name)
273
273
  conf = ::DataPlaneApi::Configuration.new(
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-data_plane_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mateusz Drewniak