sct 0.1.14 → 0.1.19
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/sct +3 -4
- data/{.DS_Store → cluster/lib/.DS_Store} +0 -0
- data/cluster/lib/cluster.rb +6 -0
- data/cluster/lib/cluster/commands_generator.rb +95 -0
- data/cluster/lib/cluster/module.rb +7 -0
- data/cluster/lib/cluster/runner.rb +239 -0
- data/{lib → sct/lib}/.DS_Store +0 -0
- data/sct/lib/sct.rb +17 -0
- data/sct/lib/sct/.DS_Store +0 -0
- data/sct/lib/sct/cli_tools_distributor.rb +46 -0
- data/{lib → sct/lib}/sct/command.rb +0 -0
- data/sct/lib/sct/commands/hostfile.rb +68 -0
- data/sct/lib/sct/commands/init.rb +37 -0
- data/sct/lib/sct/commands/mysqlproxy.rb +20 -0
- data/sct/lib/sct/commands_generator.rb +56 -0
- data/sct/lib/sct/tools.rb +12 -0
- data/sct/lib/sct/version.rb +3 -0
- data/sct_core/lib/.DS_Store +0 -0
- data/sct_core/lib/sct_core.rb +13 -0
- data/{lib/sct → sct_core/lib/sct_core}/.DS_Store +0 -0
- data/sct_core/lib/sct_core/command_executor.rb +104 -0
- data/{lib/sct → sct_core/lib/sct_core}/config.rb +3 -3
- data/sct_core/lib/sct_core/core_ext/string.rb +9 -0
- data/{lib/sct/setup/helpers.rb → sct_core/lib/sct_core/helper.rb} +2 -2
- data/sct_core/lib/sct_core/module.rb +0 -0
- data/sct_core/lib/sct_core/sct_pty.rb +53 -0
- data/sct_core/lib/sct_core/ui/implementations/shell.rb +129 -0
- data/sct_core/lib/sct_core/ui/interface.rb +120 -0
- data/sct_core/lib/sct_core/ui/ui.rb +26 -0
- data/shell/README.md +0 -0
- data/shell/lib/shell.rb +3 -0
- data/{lib/sct → shell/lib/shell}/ClassLevelInheritableAttributes.rb +0 -0
- data/shell/lib/shell/commands_generator.rb +14 -0
- data/{lib/sct → shell/lib/shell}/docker/composer.rb +4 -3
- data/{lib/sct → shell/lib/shell}/docker/docker.rb +7 -10
- data/{lib/sct → shell/lib/shell}/docker/php.rb +3 -2
- data/{lib/sct → shell/lib/shell}/docker/yarn.rb +4 -3
- data/shell/lib/shell/module.rb +9 -0
- data/shell/lib/shell/runner.rb +34 -0
- data/shell/lib/shell/tools.rb +7 -0
- metadata +92 -54
- data/.gitignore +0 -12
- data/.rspec +0 -3
- data/.travis.yml +0 -7
- data/CODE_OF_CONDUCT.md +0 -74
- data/Gemfile +0 -4
- data/Gemfile.lock +0 -48
- data/LICENSE.txt +0 -21
- data/README.md +0 -134
- data/Rakefile +0 -6
- data/lib/sct.rb +0 -61
- data/lib/sct/command_interface.rb +0 -18
- data/lib/sct/command_option.rb +0 -14
- data/lib/sct/commands/cluster.rb +0 -121
- data/lib/sct/commands/composer.rb +0 -29
- data/lib/sct/commands/hostfile.rb +0 -125
- data/lib/sct/commands/init.rb +0 -51
- data/lib/sct/commands/mysqlproxy.rb +0 -38
- data/lib/sct/commands/php.rb +0 -37
- data/lib/sct/commands/yarn.rb +0 -26
- data/lib/sct/version.rb +0 -3
- data/sct.gemspec +0 -40
@@ -1,29 +0,0 @@
|
|
1
|
-
require 'sct/command_interface'
|
2
|
-
require 'sct/command_option'
|
3
|
-
|
4
|
-
module Sct
|
5
|
-
|
6
|
-
class ComposerCommand
|
7
|
-
|
8
|
-
IS_PUBLIC_COMMAND = true
|
9
|
-
SYNTAX = 'sct composer'
|
10
|
-
SUMMARY = 'Run composer commands through SCT'
|
11
|
-
EXAMPLE = 'sct composer install'
|
12
|
-
EXAMPLE_DESCRIPTION = 'sct composer install will update the project with the latest dependencies'
|
13
|
-
DESCRIPTION = "sct will run composer commands through the local docker installation"
|
14
|
-
|
15
|
-
OPTIONS = [
|
16
|
-
CommandOption.new("--verbose", nil, "Increase verbosity of messages."),
|
17
|
-
CommandOption.new("--require STRING", String, "Package to require with a version constraint. Should be in format foo/bar:1.0.0"),
|
18
|
-
CommandOption.new("--require-dev STRING", String, "Development requirements, see --require."),
|
19
|
-
CommandOption.new("-V", nil, "Display this application version.")
|
20
|
-
]
|
21
|
-
|
22
|
-
def execute(args, options)
|
23
|
-
require "sct/docker/composer"
|
24
|
-
Sct::Composer.exec(ARGV[1..(ARGV.length+1)])
|
25
|
-
end
|
26
|
-
|
27
|
-
implements CommandInterface
|
28
|
-
end
|
29
|
-
end
|
@@ -1,125 +0,0 @@
|
|
1
|
-
require 'hosts'
|
2
|
-
require 'sct/command_interface'
|
3
|
-
|
4
|
-
module Sct
|
5
|
-
class HostfileCommand
|
6
|
-
|
7
|
-
IS_PUBLIC_COMMAND = true
|
8
|
-
SYNTAX = 'sct hostfile'
|
9
|
-
SUMMARY = 'adds the ingress url to the users hostfile'
|
10
|
-
DESCRIPTION = ""
|
11
|
-
EXAMPLE = "sct hostfile"
|
12
|
-
EXAMPLE_DESCRIPTION = ""
|
13
|
-
|
14
|
-
OPTIONS = []
|
15
|
-
|
16
|
-
def self.options
|
17
|
-
end
|
18
|
-
|
19
|
-
def execute(args, options)
|
20
|
-
return puts "SCT has not been initialized. Run 'sct init' first.".red unless Sct::Config.exists
|
21
|
-
|
22
|
-
return puts "This command needs to be run with sudo.".red unless Sct::Helpers.isSudo
|
23
|
-
|
24
|
-
return unless Sct::Helpers.ingressAddress
|
25
|
-
|
26
|
-
ingressAddress = Sct::Helpers.ingressAddress
|
27
|
-
|
28
|
-
if options.path
|
29
|
-
hosts_paths = [options.path]
|
30
|
-
else
|
31
|
-
hosts_paths = ["/etc/hosts"]
|
32
|
-
|
33
|
-
if Sct::Helpers.operatingSystem == Sct::Helpers::WINDOWS
|
34
|
-
hosts_paths << "/mnt/c/Windows/System32/drivers/etc/hosts"
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
hosts_paths.each do |hosts_path|
|
39
|
-
|
40
|
-
begin
|
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
|
108
|
-
|
109
|
-
array.to_s.each_line.with_index do |line, index|
|
110
|
-
|
111
|
-
if (line =~ /(?:spend\.cloud\.local)./)
|
112
|
-
rejectArray.push(index)
|
113
|
-
end
|
114
|
-
|
115
|
-
end
|
116
|
-
|
117
|
-
array.elements.delete_if.each_with_index { |value, index| rejectArray.include? index }
|
118
|
-
|
119
|
-
end
|
120
|
-
|
121
|
-
implements CommandInterface
|
122
|
-
|
123
|
-
end
|
124
|
-
|
125
|
-
end
|
data/lib/sct/commands/init.rb
DELETED
@@ -1,51 +0,0 @@
|
|
1
|
-
require 'sct/command_interface'
|
2
|
-
require 'highline'
|
3
|
-
|
4
|
-
module Sct
|
5
|
-
|
6
|
-
class InitCommand
|
7
|
-
|
8
|
-
IS_PUBLIC_COMMAND = true
|
9
|
-
SYNTAX = 'sct init'
|
10
|
-
SUMMARY = 'Initialize a base configuration file for sct'
|
11
|
-
EXAMPLE = 'sct init'
|
12
|
-
EXAMPLE_DESCRIPTION = 'sct init will create a configuration file'
|
13
|
-
DESCRIPTION = "sct init will create a configuration file"
|
14
|
-
|
15
|
-
OPTIONS = []
|
16
|
-
|
17
|
-
def initialize
|
18
|
-
end
|
19
|
-
|
20
|
-
def execute(args, options)
|
21
|
-
|
22
|
-
Sct::Config.dir
|
23
|
-
|
24
|
-
cli = HighLine.new
|
25
|
-
|
26
|
-
email = cli.ask("What is your email address?") { |q|
|
27
|
-
q.validate = URI::MailTo::EMAIL_REGEXP
|
28
|
-
}
|
29
|
-
|
30
|
-
cloud_proxy_path = cli.ask("What is the path of your cloud proxy json credentials?") { |q|
|
31
|
-
q.default = "~/.config/gcloud/application_default_credentials.json"
|
32
|
-
}
|
33
|
-
|
34
|
-
contents = ""
|
35
|
-
contents << "email=#{email}\n"
|
36
|
-
contents << "cloud-proxy-path=#{File.expand_path(cloud_proxy_path)}\n"
|
37
|
-
|
38
|
-
if !File.directory?(Sct::Config.dir)
|
39
|
-
FileUtils.mkdir_p(Sct::Config.dir)
|
40
|
-
end
|
41
|
-
|
42
|
-
File.write(Sct::Config.path, contents)
|
43
|
-
|
44
|
-
puts "Generated config file at #{Sct::Config.path}"
|
45
|
-
end
|
46
|
-
|
47
|
-
implements CommandInterface
|
48
|
-
|
49
|
-
end
|
50
|
-
|
51
|
-
end
|
@@ -1,38 +0,0 @@
|
|
1
|
-
require 'sct/command_interface'
|
2
|
-
require 'sct/command_option'
|
3
|
-
require "sct/config"
|
4
|
-
require "sct/setup/helpers"
|
5
|
-
|
6
|
-
module Sct
|
7
|
-
|
8
|
-
class Mysql_proxyCommand
|
9
|
-
|
10
|
-
DEFAULT_SECRET_NAME = "gcloud-credentials"
|
11
|
-
|
12
|
-
IS_PUBLIC_COMMAND = true
|
13
|
-
SYNTAX = 'sct mysql_proxy'
|
14
|
-
SUMMARY = 'adds a secret for the mysql proxy'
|
15
|
-
DESCRIPTION = ""
|
16
|
-
EXAMPLE = ""
|
17
|
-
EXAMPLE_DESCRIPTION = ""
|
18
|
-
OPTIONS = []
|
19
|
-
|
20
|
-
def execute(args, options)
|
21
|
-
|
22
|
-
return puts "SCT has not been initialized. Run 'sct init' first.".red unless Sct::Config.exists
|
23
|
-
|
24
|
-
path = Sct::Config.get('cloud-proxy-path')
|
25
|
-
|
26
|
-
system("kubectl delete secret gcloud-credentials")
|
27
|
-
system("kubectl create secret generic gcloud-credentials --from-file=#{path}")
|
28
|
-
|
29
|
-
puts "Authenticated with secret-name: '#{DEFAULT_SECRET_NAME}'".green
|
30
|
-
|
31
|
-
return true
|
32
|
-
end
|
33
|
-
|
34
|
-
implements CommandInterface
|
35
|
-
|
36
|
-
end
|
37
|
-
|
38
|
-
end
|
data/lib/sct/commands/php.rb
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
require 'sct/command_interface'
|
2
|
-
require 'sct/command_option'
|
3
|
-
|
4
|
-
module Sct
|
5
|
-
|
6
|
-
class PhpCommand
|
7
|
-
|
8
|
-
IS_PUBLIC_COMMAND = true
|
9
|
-
SYNTAX = 'sct php'
|
10
|
-
SUMMARY = 'Run php commands through SCT'
|
11
|
-
EXAMPLE = 'sct php -r "echo \'Hello World!\';"'
|
12
|
-
EXAMPLE_DESCRIPTION = 'sct php -r will execute a command directly through the php interpreter'
|
13
|
-
DESCRIPTION = "sct will run php commands through the local docker installation"
|
14
|
-
|
15
|
-
OPTIONS = [
|
16
|
-
CommandOption.new("-r", String, "Run php code directy through the interpreter"),
|
17
|
-
CommandOption.new("-V", nil, "Get the current php version. Note that it's a capital V. The lowercase v will return the SCT tool version"),
|
18
|
-
]
|
19
|
-
|
20
|
-
def execute(args, options)
|
21
|
-
require "sct/docker/php"
|
22
|
-
|
23
|
-
# Workaround for the version option being caught by the SCT tool itself
|
24
|
-
args=ARGV[1..(ARGV.length+1)].map { |arg| arg == '-V' ? arg = '-v' : arg}
|
25
|
-
|
26
|
-
# Another workaround for the -r option to add quotes around the value
|
27
|
-
if args.include? '-r'
|
28
|
-
codeIndex = args.index('-r') + 1
|
29
|
-
args[codeIndex] = "\"#{args[codeIndex]}\""
|
30
|
-
end
|
31
|
-
|
32
|
-
Sct::Php.exec(args)
|
33
|
-
end
|
34
|
-
|
35
|
-
implements CommandInterface
|
36
|
-
end
|
37
|
-
end
|
data/lib/sct/commands/yarn.rb
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
require 'sct/command_interface'
|
2
|
-
require 'sct/command_option'
|
3
|
-
|
4
|
-
module Sct
|
5
|
-
|
6
|
-
class YarnCommand
|
7
|
-
|
8
|
-
IS_PUBLIC_COMMAND = true
|
9
|
-
SYNTAX = 'sct yarn'
|
10
|
-
SUMMARY = 'Run yarn commands through SCT'
|
11
|
-
EXAMPLE = 'sct yarn dev'
|
12
|
-
EXAMPLE_DESCRIPTION = 'sct yarn dev will start the dev installation of the current project'
|
13
|
-
DESCRIPTION = "sct will run yarn commands through the local docker installation"
|
14
|
-
|
15
|
-
OPTIONS = [
|
16
|
-
CommandOption.new("--port PORTNUMBER", Integer, "The portnumber on which the server will be deployed")
|
17
|
-
]
|
18
|
-
|
19
|
-
def execute(args, options)
|
20
|
-
require "sct/docker/yarn"
|
21
|
-
Sct::Yarn.exec(ARGV[1..(ARGV.length+1)])
|
22
|
-
end
|
23
|
-
|
24
|
-
implements CommandInterface
|
25
|
-
end
|
26
|
-
end
|
data/lib/sct/version.rb
DELETED
data/sct.gemspec
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
lib = File.expand_path("lib", __dir__)
|
2
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
-
require "sct/version"
|
4
|
-
|
5
|
-
Gem::Specification.new do |spec|
|
6
|
-
spec.name = "sct"
|
7
|
-
spec.version = Sct::VERSION
|
8
|
-
spec.authors = ["Reshad Farid"]
|
9
|
-
spec.email = ["reshad.farid@visma.com"]
|
10
|
-
|
11
|
-
spec.summary = %q{Spend Cloud Tool.}
|
12
|
-
spec.description = %q{Spend Cloud Tool enables to setup a local development environment for the Spend Cloud.}
|
13
|
-
spec.homepage = "https://gitlab.com/proactive-software/packages/sct"
|
14
|
-
spec.license = "MIT"
|
15
|
-
|
16
|
-
# spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
17
|
-
|
18
|
-
spec.metadata["homepage_uri"] = spec.homepage
|
19
|
-
spec.metadata["source_code_uri"] = "https://gitlab.com/proactive-software/packages/sct"
|
20
|
-
spec.metadata["changelog_uri"] = "https://gitlab.com/proactive-software/packages/sct"
|
21
|
-
|
22
|
-
# Specify which files should be added to the gem when it is released.
|
23
|
-
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
24
|
-
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
25
|
-
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
26
|
-
end
|
27
|
-
spec.bindir = "bin"
|
28
|
-
spec.executables = ["sct"]
|
29
|
-
spec.require_paths = ["lib"]
|
30
|
-
|
31
|
-
spec.add_dependency "class_interface", "~> 0.1.1"
|
32
|
-
spec.add_dependency "colored", "~> 1.2"
|
33
|
-
spec.add_dependency "hosts", "~> 0.1.1"
|
34
|
-
spec.add_dependency "commander", "~> 4.4.7"
|
35
|
-
spec.add_dependency "highline", ">= 1.7.2"
|
36
|
-
|
37
|
-
spec.add_development_dependency "bundler", "~> 2.0"
|
38
|
-
spec.add_development_dependency "rake", "~> 10.0"
|
39
|
-
spec.add_development_dependency "rspec", "~> 3.0"
|
40
|
-
end
|