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 +4 -4
- data/.rubocop.yml +9 -4
- data/README.md +5 -0
- data/{gitlab-swat.gemspec → gitlab_swat.gemspec} +4 -6
- data/lib/cog_cmd/swat/reload.rb +1 -1
- data/lib/cog_cmd/swat/strike.rb +1 -1
- data/lib/rails_loader.rb +1 -1
- data/spec/rails_loader_spec.rb +3 -3
- data/spec/swat_dryrun_spec.rb +3 -3
- data/spec/swat_reload_spec.rb +15 -15
- data/spec/swat_strike_spec.rb +5 -4
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7ed01cc88af1e9fe76a883abb9bca46193bbab7c
|
4
|
+
data.tar.gz: edc42911534f120e21d3f51947410bffbf946089
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b2604e5caeb9060948625862970c47728508aa1b273e98d0ade9be64bd64e91349d65510b2af25d7088df2c25b9377b723cc4796a5740f313ac584c07e64f7c8
|
7
|
+
data.tar.gz: 59a301df2c16b15a20075817349f0f182878b944b4b8bbef8139e8a6e3a970c8de16e0ec7e9f6beb5fb14c02a846007d01f688d3c0f821dc9df62ebd510332f9
|
data/.rubocop.yml
CHANGED
@@ -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.
|
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
|
-
|
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
|
data/lib/cog_cmd/swat/reload.rb
CHANGED
data/lib/cog_cmd/swat/strike.rb
CHANGED
@@ -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(' ')}")
|
14
|
+
response.content = rails.run("execute #{request.args.join(' ')}")
|
15
15
|
end
|
16
16
|
end
|
17
17
|
end
|
data/lib/rails_loader.rb
CHANGED
data/spec/rails_loader_spec.rb
CHANGED
@@ -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("
|
10
|
-
|
11
|
-
"
|
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
|
data/spec/swat_dryrun_spec.rb
CHANGED
@@ -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("
|
18
|
-
"
|
19
|
-
"
|
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
|
data/spec/swat_reload_spec.rb
CHANGED
@@ -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(
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
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(
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
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(
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
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
|
|
data/spec/swat_strike_spec.rb
CHANGED
@@ -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("
|
18
|
-
|
19
|
-
|
20
|
-
|
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.
|
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
|
-
|
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
|
-
-
|
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
|