ops_team 1.6.1 → 1.9.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 717c2ad8be725cfd550b88f3df1e54d2cb4b2047f161c6aca3ee59a23c27aa31
4
- data.tar.gz: c92b3b36d66d387735b6ea7c5dcd1fc52ad8f5656364855fd947cad152b515b0
3
+ metadata.gz: 6748a5f3f6c8e89731bd41488a8173dff6d2198dbd4498f02311b50aafa762e9
4
+ data.tar.gz: eb846d4e60073e8c575d11d51cca4f2d1de64cdae84698a5ef432d3723b7f0bf
5
5
  SHA512:
6
- metadata.gz: 479c079172a46dd0f08a999d32bedb44b32c61ef1060371efc8a2ead1196a247fd075b6b44594baca6d2ca07c8b659ed4d300ecbd4c45389c1108d16b37b4efc
7
- data.tar.gz: d03837188b042bf484fa48b79cb312b0a20295872c0670fd430fe63d80bee42f2b53f5445edd5522fa7511ec48af4228d1c9539a90ec15001c3e05ed47c315cf
6
+ metadata.gz: ad9dd5ec65d37be0852049d68d73e98e7469dbc06db976b9c76b1cad39a0c1b65ccbc67dcc43d57453b0ab15061ba27ee5b655955394e4406eb4e73955ee0ea4
7
+ data.tar.gz: f05344a3215f9b015ec0d3890b7fd378263205908fb357e10cdd13a8c2489e40cb77b59b0c963b0f6ae8d3061380915153dd4405765c4535cdd0f8e966538dff
data/lib/action.rb CHANGED
@@ -5,18 +5,15 @@ require 'secrets'
5
5
  # represents one action to be performed in the shell
6
6
  # can assemble a command line from a command and args
7
7
  class Action
8
- class NotAllowedInEnvError < StandardError; end
8
+ attr_reader :name
9
9
 
10
- def initialize(config, args)
10
+ def initialize(name, config, args)
11
+ @name = name
11
12
  @config = config
12
13
  @args = args
13
14
  end
14
15
 
15
16
  def run
16
- unless allowed_in_current_env?
17
- raise NotAllowedInEnvError, "Action not allowed in #{Environment.environment} environment."
18
- end
19
-
20
17
  if perform_shell_expansion?
21
18
  Kernel.exec(to_s)
22
19
  else
@@ -62,6 +59,18 @@ class Action
62
59
  @config["load_secrets"].nil? ? false : @config["load_secrets"]
63
60
  end
64
61
 
62
+ def execute_in_env?(env)
63
+ !skip_in_envs.include?(env)
64
+ end
65
+
66
+ def allowed_in_env?(env)
67
+ return false if not_in_envs.include?(env)
68
+
69
+ return false if in_envs.any? && !in_envs.include?(env)
70
+
71
+ true
72
+ end
73
+
65
74
  private
66
75
 
67
76
  def to_a
@@ -76,12 +85,8 @@ class Action
76
85
  @config["in_envs"] || []
77
86
  end
78
87
 
79
- def allowed_in_current_env?
80
- return false if not_in_envs.include?(Environment.environment)
81
-
82
- return false if in_envs.any? && !in_envs.include?(Environment.environment)
83
-
84
- true
88
+ def skip_in_envs
89
+ @config["skip_in_envs"] || []
85
90
  end
86
91
 
87
92
  def perform_shell_expansion?
data/lib/action_list.rb CHANGED
@@ -37,7 +37,7 @@ class ActionList
37
37
  @aliases = {}
38
38
 
39
39
  actions_list.each do |name, config|
40
- action = Action.new(config, @args)
40
+ action = Action.new(name, config, @args)
41
41
 
42
42
  @actions[name] = action
43
43
  @aliases[action.alias] = action
@@ -4,18 +4,46 @@ require 'dependency'
4
4
 
5
5
  module Dependencies
6
6
  class Custom < Dependency
7
+ class CustomConfigError < StandardError; end
8
+
9
+ def initialize(definition)
10
+ super
11
+ @definition = definition
12
+ @name, @config = parse_definition
13
+ end
14
+
7
15
  def met?
8
- # we always want to try to meet this dependency
9
16
  false
10
17
  end
11
18
 
19
+ def always_act?
20
+ true
21
+ end
22
+
12
23
  def meet
13
- # this dependency is just a custom, idempotent command
14
- execute(name)
24
+ execute(up_command) if up_command
15
25
  end
16
26
 
17
27
  def unmeet
18
- true
28
+ execute(down_command) if down_command
29
+ end
30
+
31
+ private
32
+
33
+ def up_command
34
+ @up_command ||= @definition.is_a?(Hash) ? @config["up"] : name
35
+ end
36
+
37
+ def down_command
38
+ @down_command ||= @config["down"]
39
+ end
40
+
41
+ def parse_definition
42
+ return @definition, {} if @definition.is_a?(String)
43
+ return @definition.first if @definition.is_a?(Hash)
44
+
45
+ raise CustomConfigError, "Expected custom dependency @definition '#{@definition}' " \
46
+ "to be a String or a Hash; received #{@definition.class}."
19
47
  end
20
48
  end
21
49
  end
@@ -6,7 +6,7 @@ require 'dependency'
6
6
 
7
7
  module Dependencies
8
8
  class Sshkey < Dependency
9
- DEFAULT_KEY_SIZE = 2048
9
+ DEFAULT_KEY_SIZE = 4096
10
10
  DEFAULT_KEY_ALGO = "rsa"
11
11
  DEFAULT_KEY_LIFETIME_S = 3600
12
12
  DEFAULT_KEY_FILE_COMMENT_COMMAND = "$USER@`hostname -s`"
@@ -83,7 +83,7 @@ module Dependencies
83
83
  end
84
84
 
85
85
  def opt_key_algo
86
- DEFAULT_KEY_ALGO
86
+ Options.get("sshkey.key_algo") || DEFAULT_KEY_ALGO
87
87
  end
88
88
 
89
89
  def passphrase
data/lib/ops.rb CHANGED
@@ -59,7 +59,7 @@ class Ops
59
59
  rescue AppConfig::ParsingError => e
60
60
  Output.error("Error parsing app config: #{e}")
61
61
  exit(ERROR_LOADING_APP_CONFIG_EXIT_CODE)
62
- rescue Action::NotAllowedInEnvError => e
62
+ rescue Runner::NotAllowedInEnvError => e
63
63
  Output.error("Error running action #{@action_name}: #{e}")
64
64
  exit(ACTION_NOT_ALLOWED_IN_ENV_EXIT_CODE)
65
65
  end
data/lib/runner.rb CHANGED
@@ -10,6 +10,7 @@ require 'environment'
10
10
  class Runner
11
11
  class UnknownActionError < StandardError; end
12
12
  class ActionConfigError < StandardError; end
13
+ class NotAllowedInEnvError < StandardError; end
13
14
 
14
15
  def initialize(action_name, args, config, config_path)
15
16
  @action_name = action_name
@@ -29,8 +30,8 @@ class Runner
29
30
  raise ActionConfigError, action.config_errors.join("; ") unless action.config_valid?
30
31
 
31
32
  do_before_action
32
- Output.notice("Running '#{action}' in environment '#{ENV['environment']}'...")
33
- action.run
33
+
34
+ run_action
34
35
  end
35
36
 
36
37
  def suggestions
@@ -72,6 +73,20 @@ class Runner
72
73
  @forward ||= Forwards.new(@config, @args).get(@action_name)
73
74
  end
74
75
 
76
+ def run_action
77
+ unless action.allowed_in_env?(Environment.environment)
78
+ raise NotAllowedInEnvError, "Action not allowed in #{Environment.environment} environment."
79
+ end
80
+
81
+ unless action.execute_in_env?(Environment.environment)
82
+ Output.warn("Skipping action '#{action.name}' in environment #{Environment.environment}.")
83
+ return true
84
+ end
85
+
86
+ Output.notice("Running '#{action}' in environment '#{ENV['environment']}'...")
87
+ action.run
88
+ end
89
+
75
90
  def action
76
91
  return action_list.get(@action_name) if action_list.get(@action_name)
77
92
  return action_list.get_by_alias(@action_name) if action_list.get_by_alias(@action_name)
data/ops_team.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'ops_team'
5
- s.version = '1.6.1'
5
+ s.version = '1.9.0'
6
6
  s.authors = [
7
7
  'nickthecook@gmail.com'
8
8
  ]
@@ -27,7 +27,6 @@ Gem::Specification.new do |s|
27
27
  s.add_runtime_dependency 'colorize', '~> 0.8', '>= 0.8.1'
28
28
  s.add_runtime_dependency 'concurrent-ruby', '~> 1.1', '>= 1.1.7'
29
29
  s.add_runtime_dependency 'ed25519', '~> 1.2', '>= 1.2.4'
30
- s.add_runtime_dependency 'json', '~> 2.5', '>= 2.5.1'
31
30
  s.add_runtime_dependency 'ejson', '~> 1.2', '>= 1.2.1'
32
31
  s.add_runtime_dependency 'net-ssh', '~> 6.1', '>= 6.1.0'
33
32
  s.add_runtime_dependency 'require_all', '~> 1.1', '>= 1.1.6'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ops_team
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.1
4
+ version: 1.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - nickthecook@gmail.com
@@ -90,26 +90,6 @@ dependencies:
90
90
  - - ">="
91
91
  - !ruby/object:Gem::Version
92
92
  version: 1.2.4
93
- - !ruby/object:Gem::Dependency
94
- name: json
95
- requirement: !ruby/object:Gem::Requirement
96
- requirements:
97
- - - "~>"
98
- - !ruby/object:Gem::Version
99
- version: '2.5'
100
- - - ">="
101
- - !ruby/object:Gem::Version
102
- version: 2.5.1
103
- type: :runtime
104
- prerelease: false
105
- version_requirements: !ruby/object:Gem::Requirement
106
- requirements:
107
- - - "~>"
108
- - !ruby/object:Gem::Version
109
- version: '2.5'
110
- - - ">="
111
- - !ruby/object:Gem::Version
112
- version: 2.5.1
113
93
  - !ruby/object:Gem::Dependency
114
94
  name: ejson
115
95
  requirement: !ruby/object:Gem::Requirement
@@ -134,22 +114,22 @@ dependencies:
134
114
  name: net-ssh
135
115
  requirement: !ruby/object:Gem::Requirement
136
116
  requirements:
137
- - - "~>"
138
- - !ruby/object:Gem::Version
139
- version: '6.1'
140
117
  - - ">="
141
118
  - !ruby/object:Gem::Version
142
119
  version: 6.1.0
120
+ - - "~>"
121
+ - !ruby/object:Gem::Version
122
+ version: '6.1'
143
123
  type: :runtime
144
124
  prerelease: false
145
125
  version_requirements: !ruby/object:Gem::Requirement
146
126
  requirements:
147
- - - "~>"
148
- - !ruby/object:Gem::Version
149
- version: '6.1'
150
127
  - - ">="
151
128
  - !ruby/object:Gem::Version
152
129
  version: 6.1.0
130
+ - - "~>"
131
+ - !ruby/object:Gem::Version
132
+ version: '6.1'
153
133
  - !ruby/object:Gem::Dependency
154
134
  name: require_all
155
135
  requirement: !ruby/object:Gem::Requirement
@@ -247,7 +227,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
247
227
  - !ruby/object:Gem::Version
248
228
  version: '0'
249
229
  requirements: []
250
- rubygems_version: 3.2.15
230
+ rubygems_version: 3.0.3.1
251
231
  signing_key:
252
232
  specification_version: 4
253
233
  summary: ops_team handles basic automation for your project, driven by self-documenting