sct 0.1.15 → 0.1.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitlab/merge_request_templates/DefinitionOfDone.md +3 -1
- data/Gemfile.lock +2 -6
- data/lib/sct/commands/hostfile.rb +33 -74
- data/lib/sct/version.rb +1 -1
- data/sct.gemspec +0 -1
- metadata +2 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d056bb6dee0b4f63c1f1480dcf45fb72ddc7c56d438c22e198b516337226d10f
|
4
|
+
data.tar.gz: 70e73a9e31b06b96f3e0c39cdc68e830e4eb155f6bf3656d8d8906244c4dbab2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 19cc423a5d5e5e52aa63ed5f2c995c7b87f0c7e8802ede561ecc9326f438e6bc0e1be45e79c63adad37b1bd8db378518d9ec4491fc59b752a32f841991658b1a
|
7
|
+
data.tar.gz: ca64a6c7ab008432005c5f6e53498de49fa3d608be78980963fd79fe4ec79940d0c4364418059dd78c05b7966fa8cdfa06934dea089eee6cc985fa42daae8a5a
|
@@ -3,8 +3,10 @@ The Definition of a Done Code Review
|
|
3
3
|
| by _The Team_ |
|
4
4
|
|---------------------------------:|
|
5
5
|
|
6
|
-
- [ ] Approved (thumbs up) by three other team members (from different operating systems).
|
7
6
|
- [ ] Verified if it worked on all operating systems.
|
7
|
+
- [ ] Windows
|
8
|
+
- [ ] Ubuntu
|
9
|
+
- [ ] MacOs
|
8
10
|
- [ ] Verified if it solved the problem.
|
9
11
|
- [ ] Verified if the help section is updated.
|
10
12
|
- [ ] Verified if it complied with Ruby code standards.
|
data/Gemfile.lock
CHANGED
@@ -1,25 +1,21 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
sct (0.1.
|
4
|
+
sct (0.1.15)
|
5
5
|
class_interface (~> 0.1.1)
|
6
6
|
colored (~> 1.2)
|
7
7
|
commander (~> 4.4.7)
|
8
8
|
highline (>= 1.7.2)
|
9
|
-
hosts (~> 0.1.1)
|
10
9
|
|
11
10
|
GEM
|
12
11
|
remote: https://rubygems.org/
|
13
12
|
specs:
|
14
|
-
class_interface (0.1.
|
13
|
+
class_interface (0.1.2)
|
15
14
|
colored (1.2)
|
16
15
|
commander (4.4.7)
|
17
16
|
highline (~> 2.0.0)
|
18
17
|
diff-lcs (1.3)
|
19
18
|
highline (2.0.3)
|
20
|
-
hosts (0.1.1)
|
21
|
-
linebreak (~> 2.0.1)
|
22
|
-
linebreak (2.0.1)
|
23
19
|
rake (10.5.0)
|
24
20
|
rspec (3.9.0)
|
25
21
|
rspec-core (~> 3.9.0)
|
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'hosts'
|
2
1
|
require 'sct/command_interface'
|
3
2
|
|
4
3
|
module Sct
|
@@ -25,6 +24,29 @@ module Sct
|
|
25
24
|
|
26
25
|
ingressAddress = Sct::Helpers.ingressAddress
|
27
26
|
|
27
|
+
entries = [
|
28
|
+
{
|
29
|
+
host: "spend.cloud.local",
|
30
|
+
comment: "The spend cloud ingress url"
|
31
|
+
},
|
32
|
+
{
|
33
|
+
host: "mail.spend.cloud.local",
|
34
|
+
comment: "The spend cloud mail url"
|
35
|
+
},
|
36
|
+
{
|
37
|
+
host: "config.spend.cloud.local",
|
38
|
+
comment: "The spend cloud config url"
|
39
|
+
},
|
40
|
+
{
|
41
|
+
host: "spend-cloud.spend.cloud.local",
|
42
|
+
comment: "The spend cloud web app url"
|
43
|
+
},
|
44
|
+
{
|
45
|
+
host: "docs.spend.cloud.local",
|
46
|
+
comment: "The spend cloud documentation url"
|
47
|
+
}
|
48
|
+
]
|
49
|
+
|
28
50
|
if options.path
|
29
51
|
hosts_paths = [options.path]
|
30
52
|
else
|
@@ -36,85 +58,22 @@ module Sct
|
|
36
58
|
end
|
37
59
|
|
38
60
|
hosts_paths.each do |hosts_path|
|
61
|
+
line_ending = hosts_path == "/mnt/c/Windows/System32/drivers/etc/hosts" ? "\r\n" : "\n"
|
39
62
|
|
40
|
-
|
41
|
-
hosts = Hosts::File.read(hosts_path)
|
42
|
-
|
43
|
-
if ([ingressAddress].any? { |ip| hosts.to_s =~ /#{ip}/ })
|
44
|
-
puts "Skipped patching #{hosts_path} (already up to date)".green
|
45
|
-
else
|
46
|
-
validate_if_exist(hosts)
|
47
|
-
add_entry(ingressAddress, hosts)
|
48
|
-
hosts.write
|
49
|
-
puts "Patched #{hosts_path} with #{ingressAddress}".green
|
50
|
-
end
|
51
|
-
rescue ArgumentError
|
52
|
-
puts "🔥 Can't read your hostfile".red
|
53
|
-
puts " Please update your hostsfile manually at #{hosts_path} with the following entries"
|
54
|
-
puts " "
|
55
|
-
puts " #{ingressAddress} spend.cloud.local".yellow
|
56
|
-
puts " #{ingressAddress} mail.spend.cloud.local".yellow
|
57
|
-
puts " #{ingressAddress} config.spend.cloud.local".yellow
|
58
|
-
puts " #{ingressAddress} spend-cloud.spend.cloud.local".yellow
|
59
|
-
puts " #{ingressAddress} docs.spend.cloud.local".yellow
|
60
|
-
puts " "
|
61
|
-
end
|
62
|
-
|
63
|
-
end
|
64
|
-
|
65
|
-
end
|
66
|
-
|
67
|
-
def add_entry(url, hosts)
|
68
|
-
spend = Hosts::Entry.new(
|
69
|
-
url,
|
70
|
-
'spend.cloud.local',
|
71
|
-
:comment => 'The spend cloud ingress url'
|
72
|
-
)
|
73
|
-
|
74
|
-
mail = Hosts::Entry.new(
|
75
|
-
url,
|
76
|
-
'mail.spend.cloud.local',
|
77
|
-
:comment => 'The spend cloud mail url'
|
78
|
-
)
|
79
|
-
|
80
|
-
config = Hosts::Entry.new(
|
81
|
-
url,
|
82
|
-
'config.spend.cloud.local',
|
83
|
-
:comment => 'The spend cloud config url'
|
84
|
-
)
|
85
|
-
|
86
|
-
spend_cloud = Hosts::Entry.new(
|
87
|
-
url,
|
88
|
-
'spend-cloud.spend.cloud.local',
|
89
|
-
:comment => 'The spend cloud web app url'
|
90
|
-
)
|
91
|
-
|
92
|
-
docs = Hosts::Entry.new(
|
93
|
-
url,
|
94
|
-
'docs.spend.cloud.local',
|
95
|
-
:comment => 'The spend cloud documentation url'
|
96
|
-
)
|
97
|
-
|
98
|
-
hosts.elements << spend
|
99
|
-
hosts.elements << mail
|
100
|
-
hosts.elements << config
|
101
|
-
hosts.elements << spend_cloud
|
102
|
-
hosts.elements << docs
|
103
|
-
|
104
|
-
end
|
105
|
-
|
106
|
-
def validate_if_exist(array)
|
107
|
-
rejectArray = Array.new
|
63
|
+
lines = File.readlines hosts_path
|
108
64
|
|
109
|
-
|
65
|
+
# select the lines that do not include any entry
|
66
|
+
lines = lines.select { |line| ! entries.any? { |entry| line.include? entry[:host] } }
|
110
67
|
|
111
|
-
|
112
|
-
|
68
|
+
# add entries
|
69
|
+
entries.each do |entry|
|
70
|
+
lines << "#{ingressAddress} #{entry[:host]} # #{entry[:comment]}#{line_ending}"
|
113
71
|
end
|
114
72
|
|
115
|
-
|
73
|
+
File.write hosts_path, lines.join
|
116
74
|
|
117
|
-
|
75
|
+
puts "Patched #{hosts_path} with #{ingressAddress}".green
|
76
|
+
end
|
118
77
|
|
119
78
|
end
|
120
79
|
|
data/lib/sct/version.rb
CHANGED
data/sct.gemspec
CHANGED
@@ -30,7 +30,6 @@ Gem::Specification.new do |spec|
|
|
30
30
|
|
31
31
|
spec.add_dependency "class_interface", "~> 0.1.1"
|
32
32
|
spec.add_dependency "colored", "~> 1.2"
|
33
|
-
spec.add_dependency "hosts", "~> 0.1.1"
|
34
33
|
spec.add_dependency "commander", "~> 4.4.7"
|
35
34
|
spec.add_dependency "highline", ">= 1.7.2"
|
36
35
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sct
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Reshad Farid
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-03-
|
11
|
+
date: 2020-03-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: class_interface
|
@@ -38,20 +38,6 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '1.2'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: hosts
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: 0.1.1
|
48
|
-
type: :runtime
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: 0.1.1
|
55
41
|
- !ruby/object:Gem::Dependency
|
56
42
|
name: commander
|
57
43
|
requirement: !ruby/object:Gem::Requirement
|