sct 0.1.35 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,76 +0,0 @@
1
- module Sct
2
- class HostfileCommand
3
-
4
- def execute(args, options)
5
- SctCore::Helper.ensure_permissions
6
-
7
- entries = [
8
- {
9
- host: "spend.cloud.local",
10
- comment: "The spend cloud ingress url"
11
- },
12
- {
13
- host: "mail.spend.cloud.local",
14
- comment: "The spend cloud mail url"
15
- },
16
- {
17
- host: "config.spend.cloud.local",
18
- comment: "The spend cloud config url"
19
- },
20
- {
21
- host: "spend-cloud.spend.cloud.local",
22
- comment: "The spend cloud web app url"
23
- },
24
- {
25
- host: "docs.spend.cloud.local",
26
- comment: "The spend cloud documentation url"
27
- },
28
- {
29
- host: "henk.spend.cloud.local",
30
- comment: "The spend cloud Henk web-interface"
31
- }
32
- ]
33
-
34
- is_windows = SctCore::Helper::is_windows?
35
-
36
- if is_windows
37
- ingress_address = "127.0.0.1"
38
- else
39
- ingress_address = `sudo -u $SUDO_USER minikube ip`.chomp
40
- end
41
-
42
- windows_hosts_path = "/mnt/c/Windows/System32/drivers/etc/hosts"
43
-
44
- if options.path
45
- hosts_paths = [options.path]
46
- else
47
- hosts_paths = ["/etc/hosts"]
48
-
49
- if is_windows
50
- hosts_paths << windows_hosts_path
51
- end
52
- end
53
-
54
- hosts_paths.each do |hosts_path|
55
- line_ending = hosts_path == windows_hosts_path ? "\r\n" : "\n"
56
-
57
- lines = File.readlines hosts_path
58
-
59
- # select the lines that do not include any entry
60
- lines = lines.select { |line| ! entries.any? { |entry| line.include? " #{entry[:host]}" } }
61
-
62
- # add entries
63
- entries.each do |entry|
64
- lines << "#{ingress_address} #{entry[:host]} # #{entry[:comment]}#{line_ending}"
65
- end
66
-
67
- File.write hosts_path, lines.join
68
-
69
- UI.success("Patched #{hosts_path} with #{ingress_address}")
70
- end
71
-
72
- end
73
-
74
- end
75
-
76
- end
@@ -1,37 +0,0 @@
1
- require 'sct_core/ui/ui'
2
- require 'sct_core/config'
3
-
4
- module Sct
5
-
6
- class InitCommand
7
-
8
- def execute(args, options)
9
-
10
- dir = SctCore::Config.dir
11
-
12
- cli = HighLine.new
13
-
14
- email = cli.ask("What is your email address?") { |q|
15
- q.validate = URI::MailTo::EMAIL_REGEXP
16
- }
17
-
18
- cloud_proxy_path = cli.ask("What is the path of your cloud proxy json credentials?") { |q|
19
- q.default = "~/.config/gcloud/application_default_credentials.json"
20
- }
21
-
22
- contents = ""
23
- contents << "email=#{email}\n"
24
- contents << "cloud-proxy-path=#{File.expand_path(cloud_proxy_path)}\n"
25
-
26
- if !File.directory?(dir)
27
- FileUtils.mkdir_p(dir)
28
- end
29
-
30
- File.write(SctCore::Config.path, contents)
31
-
32
- puts "Generated config file at #{SctCore::Config.path}"
33
- end
34
-
35
- end
36
-
37
- end
@@ -1,36 +0,0 @@
1
- module SctCore
2
- class Config
3
-
4
- def self.dir
5
- return "#{SctCore::Helper.homePath}/.config/sct"
6
- end
7
-
8
- def self.path
9
- return File.expand_path(File.join(self.dir, 'config'))
10
- end
11
-
12
- def self.exists
13
- return File.exists?(Config.path)
14
- end
15
-
16
- def self.get(key)
17
- config = self.read
18
-
19
- if !config.key?(key)
20
- return nil
21
- end
22
-
23
- return config[key]
24
- end
25
-
26
- def self.read
27
- if !self.exists
28
- return {}
29
- end
30
-
31
- contents = File.read(self.path)
32
-
33
- return SctCore::Helper.to_hash(contents)
34
- end
35
- end
36
- end
data/shell/lib/shell.rb DELETED
@@ -1,2 +0,0 @@
1
- require_relative 'shell/runner'
2
- require_relative 'shell/module'
@@ -1,14 +0,0 @@
1
- require_relative 'runner'
2
-
3
- module Shell
4
- class CommandsGenerator
5
-
6
- def self.start
7
- self.new.run
8
- end
9
-
10
- def run
11
- Shell::Runner.new.launch
12
- end
13
- end
14
- end
@@ -1,9 +0,0 @@
1
- require 'sct_core/helper'
2
-
3
- module Shell
4
-
5
- # import the helper functionality from SCT
6
- Helpers = Sct::Helper
7
- UI = Sct::UI
8
-
9
- end
@@ -1,83 +0,0 @@
1
- require 'yaml'
2
-
3
- module Shell
4
- class Runner
5
-
6
- def launch
7
- command = ARGV.join(" ")
8
-
9
- if ! File.exist? "./okteto.yml"
10
- error "Could not find file 'okteto.yml'."
11
- end
12
-
13
- manifest = YAML.load File.read "./okteto.yml"
14
-
15
- deployment = manifest["name"]
16
-
17
- pod = find_pod deployment
18
-
19
- if command.empty?
20
- system "kubectl exec #{pod} -it -- sh", { in: :in, out: :out, err: :err }
21
- else
22
- system "kubectl exec #{pod} -it -- #{command}", { in: :in, out: :out, err: :err }
23
- end
24
- end
25
-
26
- def find_pod deployment
27
- output = `kubectl get pods --show-labels`
28
-
29
- # split output lines
30
- lines = output.split "\n"
31
-
32
- # exclude first line (table header)
33
- lines = lines[1..-1]
34
-
35
- # get the name and labels of each pod
36
- pods = lines.map do |line|
37
- columns = line.split " "
38
-
39
- name = columns[0]
40
-
41
- labels = columns[5].split(",").reduce({}) do |labels, label|
42
- key, value = label.split "="
43
- labels[key] = value
44
- labels
45
- end
46
-
47
- {
48
- name: name,
49
- labels: labels
50
- }
51
- end
52
-
53
- # filter by deployment
54
- pods = pods.filter { |pod| pod[:labels]["app"] == deployment }
55
-
56
- if pods.length == 0
57
- error "Could not find pod for deployment #{deployment}."
58
- elsif pods.length > 1
59
- error "Found more than one pod for deployment #{deployment}. Multiple pods are not supported."
60
- end
61
-
62
- pod = pods.first
63
-
64
- if pod[:labels]["dev.okteto.com"] != "true"
65
- print "The current pod is running a production image and was not started by Okteto. Are you sure you want to continue? [y/N] ".red
66
-
67
- answer = $stdin.readline.chomp.downcase
68
-
69
- if answer != "y"
70
- exit
71
- end
72
- end
73
-
74
- pod[:name]
75
- end
76
-
77
- def error message
78
- UI.error message
79
- exit 1
80
- end
81
-
82
- end
83
- end