gitlab-swat 0.1.0 → 0.1.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
  SHA1:
3
- metadata.gz: d7764e07cd7efc9efec68895fe07f7c8a2c3db9d
4
- data.tar.gz: 679cc6ac1ae287113cb9fc3f70c6282c2eaaedb6
3
+ metadata.gz: 7ed01cc88af1e9fe76a883abb9bca46193bbab7c
4
+ data.tar.gz: edc42911534f120e21d3f51947410bffbf946089
5
5
  SHA512:
6
- metadata.gz: f323d1a8b248bad4c21b11a734a97697bb96961df59dee5b724dbe64bf4ecda27773a8120b40438349097c6f5511a30c60996412671fb40a49f8fe5e6b00deef
7
- data.tar.gz: d5165ea4b0ebfb42e9ddc10d63fae6b8e2a5b1ea80e30f324ed0514b2ec99fc812b674684aebe3cb21f2e16bef0c0f40698f9bbe88dde91f0a57bc031d508a0a
6
+ metadata.gz: b2604e5caeb9060948625862970c47728508aa1b273e98d0ade9be64bd64e91349d65510b2af25d7088df2c25b9377b723cc4796a5740f313ac584c07e64f7c8
7
+ data.tar.gz: 59a301df2c16b15a20075817349f0f182878b944b4b8bbef8139e8a6e3a970c8de16e0ec7e9f6beb5fb14c02a846007d01f688d3c0f821dc9df62ebd510332f9
@@ -1,3 +1,12 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.3.3
3
+ Include:
4
+ - 'lib/**/*.rb'
5
+ Exclude:
6
+ - 'Gemfile'
7
+ - 'spec/**/*.rb'
8
+ - 'vendor/**/*'
9
+
1
10
  # Commonly used screens these days easily fit more than 80 characters.
2
11
  Metrics/LineLength:
3
12
  Max: 120
@@ -24,7 +33,3 @@ Metrics/MethodLength:
24
33
 
25
34
  Metrics/AbcSize:
26
35
  Enabled: false
27
-
28
- Metrics/BlockLength:
29
- Exclude:
30
- - 'spec/**/*.rb'
data/README.md CHANGED
@@ -72,6 +72,7 @@ Any stage that raises an exception will stop the execution, and will force and e
72
72
  ```sh
73
73
  $ SCRIPTS_LOCAL_PATH=/home/user/src/gitlab.com/gitlab-cog/swat/scripts RAILS_RUNNER_COMMAND="rails r /home/user/src/gitlab.com/gitlab-cog/swat/lib/swat_run.rb" RAILS_WORKING_DIR=/home/user/src/gitlab.com/gitlab-cog/rails-project COG_COMMAND="dryrun" COG_ARGV_0="test" COG_ARGV_1="success" COG_ARGV_2="success" COG_ARGC=3 ./cog-command
74
74
  COG_TEMPLATE: execution_result
75
+ JSON
75
76
  {"execution_mode":"dryrun","prepare":{"successful":true,"output":"preparation is fine so far"},"pre_check":{"successful":true,"output":"all is gut"}}
76
77
  ```
77
78
 
@@ -80,6 +81,7 @@ COG_TEMPLATE: execution_result
80
81
  ```sh
81
82
  $ SCRIPTS_LOCAL_PATH=/home/user/src/gitlab.com/gitlab-cog/swat/scripts RAILS_RUNNER_COMMAND="rails r /home/user/src/gitlab.com/gitlab-cog/swat/lib/swat_run.rb" RAILS_WORKING_DIR=/home/user/src/gitlab.com/gitlab-cog/rails-project COG_COMMAND="strike" COG_ARGV_0="test" COG_ARGV_1="success" COG_ARGV_2="success" COG_ARGC=3 ./cog-command
82
83
  COG_TEMPLATE: execution_result
84
+ JSON
83
85
  {"execution_mode":"execute","prepare":{"successful":true,"output":"preparation is fine so far"},"pre_check":{"successful":true,"output":"all is gut"},"execute":{"successful":true,"output":"Context so far is {:prepared=\u003e\"done\", :checks=\u003e\"done\"}"}}
84
86
  ```
85
87
 
@@ -87,15 +89,18 @@ COG_TEMPLATE: execution_result
87
89
 
88
90
  ```sh
89
91
  $ SCRIPTS_LOCAL_PATH=/tmp/testing-cog/second SCRIPTS_REMOTE_URL=$(pwd) COG_COMMAND="reload" ./cog-command
92
+ JSON
90
93
  {"source":"/home/user/src/gitlab.com/gitlab-cog/swat","target":"/tmp/testing-cog/scripts","action":"clone","wiped":false, "head":"1234 current commit"}
91
94
  ```
92
95
 
93
96
  ```sh
94
97
  $ SCRIPTS_LOCAL_PATH=/tmp/testing-cog/second SCRIPTS_REMOTE_URL=$(pwd) COG_COMMAND="reload" ./cog-command
98
+ JSON
95
99
  {"source":"/home/user/src/gitlab.com/gitlab-cog/swat","target":"/tmp/testing-cog/scripts","action":"pull","wiped":false, "head":"1234 current commit"}
96
100
  ```
97
101
 
98
102
  ```sh
99
103
  $ SCRIPTS_LOCAL_PATH=/tmp/testing-cog/second SCRIPTS_REMOTE_URL=$(pwd) COG_COMMAND="reload" COG_OPTS=wipe COG_OPT_WIPE=true ./cog-command
104
+ JSON
100
105
  {"source":"/home/user/src/gitlab.com/gitlab-cog/swat","target":"/tmp/testing-cog/scripts","action":"clone","wiped":true, "head":"1234 current commit"}
101
106
  ```
@@ -1,15 +1,13 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "gitlab-swat"
3
- s.version = "0.1.0"
3
+ s.version = "0.1.1"
4
4
  s.date = "2017-04-01"
5
5
  s.summary = "ChatOps Cog Bundle that enables admins to remotely run predefined scripts in a rails console"
6
6
  s.description = <<~eos
7
7
  A Successful Deployment Ends Peacefully With No Bullets Fired.
8
- If That’s Simply Not Possible, SWAT Uses Special Weapons and Tactics to Keep the Public Safe
9
-
10
- GitLab-Swat allows admins to quickly deploy scripts that can be remotely executed through a rails console
11
-
12
- Allowing fast action by using an external git repository as the scripts source, but keeping safety high by
8
+ If That’s Simply Not Possible, SWAT Uses Special Weapons and Tactics to Keep the Public Safe\n\n
9
+ GitLab-Swat allows admins to quickly deploy scripts that can be remotely executed through a rails console\n
10
+ Enabling fast action by using an external git repository as the scripts source, but keeping safety high by
13
11
  enforcing a prepare-pre check-execute model that allows execution break at any stage if things are not going
14
12
  as expected
15
13
  eos
@@ -14,7 +14,7 @@ module CogCmd
14
14
  result = { source: git.source,
15
15
  target: git.target,
16
16
  wiped: wipe? }.merge(git.update)
17
- response.content = result.to_json
17
+ response.content = result
18
18
  end
19
19
 
20
20
  def wipe?
@@ -11,7 +11,7 @@ module CogCmd
11
11
  def run_command
12
12
  rails = ::Swat::RailsLoader.new
13
13
  response.template = "execution_result"
14
- response.content = rails.run("execute #{request.args.join(' ')}").to_s
14
+ response.content = rails.run("execute #{request.args.join(' ')}")
15
15
  end
16
16
  end
17
17
  end
@@ -37,7 +37,7 @@ module Swat
37
37
  fail "Command #{args} failed with err: '#{stderr.read.strip}' " \
38
38
  "out: '#{stdout.read.strip}'"
39
39
  end
40
- stdout.read.strip
40
+ JSON.parse(stdout.read.strip)
41
41
  end
42
42
  end
43
43
  end
@@ -6,9 +6,9 @@ describe Swat::RailsLoader do
6
6
  expect(::Swat::RailsLoader
7
7
  .new("./spec/helpers/rails_stub.rb lib/swat_run.rb")
8
8
  .run("dryrun test success"))
9
- .to eq("{\"execution_mode\":\"dryrun\",\"prepare\":{\"successful\":true," \
10
- "\"output\":\"preparation is fine so far\"}," \
11
- "\"pre_check\":{\"successful\":true,\"output\":\"all is gut\"}}")
9
+ .to eq("execution_mode"=>"dryrun",
10
+ "prepare"=>{"successful"=>true, "output"=>"preparation is fine so far"},
11
+ "pre_check"=>{"successful"=>true, "output"=>"all is gut"})
12
12
  end
13
13
 
14
14
  it "can err out when the return code is not 0" do
@@ -14,8 +14,8 @@ describe CogCmd::Swat::Dryrun do
14
14
  command.run_command
15
15
  end
16
16
  expect(command.response.content)
17
- .to eq("{\"execution_mode\":\"dryrun\",\"prepare\":{\"successful\":true," \
18
- "\"output\":\"preparation is fine so far\"}," \
19
- "\"pre_check\":{\"successful\":true,\"output\":\"all is gut\"}}")
17
+ .to eq("execution_mode"=>"dryrun",
18
+ "prepare"=>{"successful"=>true, "output"=>"preparation is fine so far"},
19
+ "pre_check"=>{"successful"=>true, "output"=>"all is gut"})
20
20
  end
21
21
  end
@@ -14,11 +14,11 @@ describe CogCmd::Swat::Reload do
14
14
  it "reloads the repo" do
15
15
  command = CogCmd::Swat::Reload.new
16
16
  command.run_command
17
- expect(JSON.parse(command.response.content)).to include(
18
- "source" => git.source_repo,
19
- "target" => git.target_dir,
20
- "action" => "clone",
21
- "wiped" => false
17
+ expect(command.response.content).to include(
18
+ source: git.source_repo,
19
+ target: git.target_dir,
20
+ action: "clone",
21
+ wiped: false
22
22
  )
23
23
  end
24
24
 
@@ -28,11 +28,11 @@ describe CogCmd::Swat::Reload do
28
28
  ENV["COG_OPTS"] = "wipe"
29
29
  ENV["COG_OPT_WIPE"] = "true"
30
30
  command.run_command
31
- expect(JSON.parse(command.response.content)).to include(
32
- "source" => git.source_repo,
33
- "target" => git.target_dir,
34
- "action" => "clone",
35
- "wiped" => true
31
+ expect(command.response.content).to include(
32
+ source: git.source_repo,
33
+ target: git.target_dir,
34
+ action: "clone",
35
+ wiped: true
36
36
  )
37
37
  ensure
38
38
  ENV.delete("COG_OPTS")
@@ -45,11 +45,11 @@ describe CogCmd::Swat::Reload do
45
45
  command.run_command
46
46
  command.run_command
47
47
  command.run_command
48
- expect(JSON.parse(command.response.content)).to include(
49
- "source" => git.source_repo,
50
- "target" => git.target_dir,
51
- "action" => "pull",
52
- "wiped" => false
48
+ expect(command.response.content).to include(
49
+ source: git.source_repo,
50
+ target: git.target_dir,
51
+ action: "pull",
52
+ wiped: false
53
53
  )
54
54
  end
55
55
 
@@ -14,9 +14,10 @@ describe CogCmd::Swat::Strike do
14
14
  command.run_command
15
15
  end
16
16
  expect(command.response.content)
17
- .to eq("{\"execution_mode\":\"execute\",\"prepare\":{\"successful\":true," \
18
- "\"output\":\"preparation is fine so far\"},\"pre_check\":{\"successful\":true," \
19
- "\"output\":\"all is gut\"},\"execute\":{\"successful\":true," \
20
- "\"output\":\"Context so far is {:prepared=>\\\"done\\\", :checks=>\\\"done\\\"}\"}}")
17
+ .to eq("execution_mode"=>"execute",
18
+ "prepare"=>{"successful"=>true, "output"=>"preparation is fine so far"},
19
+ "pre_check" => {"successful"=>true, "output"=>"all is gut"},
20
+ "execute"=>{"successful"=>true,
21
+ "output"=>"Context so far is {:prepared=>\"done\", :checks=>\"done\"}"})
21
22
  end
22
23
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gitlab-swat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pablo Carranza
@@ -70,9 +70,10 @@ description: |
70
70
  A Successful Deployment Ends Peacefully With No Bullets Fired.
71
71
  If That’s Simply Not Possible, SWAT Uses Special Weapons and Tactics to Keep the Public Safe
72
72
 
73
+
73
74
  GitLab-Swat allows admins to quickly deploy scripts that can be remotely executed through a rails console
74
75
 
75
- Allowing fast action by using an external git repository as the scripts source, but keeping safety high by
76
+ Enabling fast action by using an external git repository as the scripts source, but keeping safety high by
76
77
  enforcing a prepare-pre check-execute model that allows execution break at any stage if things are not going
77
78
  as expected
78
79
  email: pablo@gitlab.com
@@ -87,7 +88,7 @@ files:
87
88
  - README.md
88
89
  - cog-command
89
90
  - config.yaml
90
- - gitlab-swat.gemspec
91
+ - gitlab_swat.gemspec
91
92
  - lib/cog_cmd/swat/dryrun.rb
92
93
  - lib/cog_cmd/swat/reload.rb
93
94
  - lib/cog_cmd/swat/strike.rb