cloud-sh 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/cloud/sh/cli.rb +1 -0
- data/lib/cloud/sh/commands/refresh.rb +1 -1
- data/lib/cloud/sh/config.rb +9 -5
- data/lib/cloud/sh/providers/digital_ocean.rb +3 -3
- data/lib/cloud/sh/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fb6f375062f21115ff9b54d8acd36b5769531f9e0ee6e84e1e064bf45d7e049b
|
4
|
+
data.tar.gz: 6a93eaebf5227c3bd988ad8b1407689bd10dd0f1b2b1a5f310dd31db284a6e89
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aac2cef05fe9cac7e3b327e772c2b5c9e94144f4e5686383dcb896b2afc48bee784c805f1ad8d0aa940773786415af1c04b0462d6b0644626ea665b6583a8a5d
|
7
|
+
data.tar.gz: cc74cd7a0da0c3c2a415d1a647d6c6e2a4ab18a75a484b5c9b6955ebd90e94feec10838bc144c0578360e43981a128d19f6bc243896a90164c8c378c4dcaf206
|
data/Gemfile.lock
CHANGED
data/lib/cloud/sh/cli.rb
CHANGED
@@ -10,6 +10,7 @@ module Cloud
|
|
10
10
|
|
11
11
|
desc "Refresh aliases"
|
12
12
|
command :refresh do |c|
|
13
|
+
c.switch :force, negatable: false, default_value: false, desc: "Force refresh"
|
13
14
|
c.action do |global_options, options, args|
|
14
15
|
Cloud::Sh::Commands::Refresh.execute(global_options, options, args)
|
15
16
|
end
|
data/lib/cloud/sh/config.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
module Cloud
|
4
4
|
module Sh
|
5
5
|
class Config
|
6
|
-
attr_reader :accounts
|
6
|
+
attr_reader :accounts, :raw
|
7
7
|
|
8
8
|
def initialize
|
9
9
|
@accounts = []
|
@@ -12,8 +12,12 @@ module Cloud
|
|
12
12
|
|
13
13
|
def read_config
|
14
14
|
return unless File.exist?(config_file)
|
15
|
-
|
16
|
-
|
15
|
+
@raw = YAML.safe_load(File.read(config_file))
|
16
|
+
load_accounts
|
17
|
+
end
|
18
|
+
|
19
|
+
def load_accounts
|
20
|
+
raw["accounts"].each do |account_config|
|
17
21
|
accounts << Account.new(account_config)
|
18
22
|
end
|
19
23
|
end
|
@@ -56,11 +60,11 @@ module Cloud
|
|
56
60
|
end
|
57
61
|
|
58
62
|
def find_cluster(name)
|
59
|
-
clusters.find { |cluster| cluster.name == name }
|
63
|
+
clusters.find { |cluster| cluster.name == name } || clusters.push(Cluster.new("name" => name)).last
|
60
64
|
end
|
61
65
|
|
62
66
|
def find_database(name)
|
63
|
-
databases.find { |database| database.name == name }
|
67
|
+
databases.find { |database| database.name == name } || databases.push(Database.new("name" => name)).last
|
64
68
|
end
|
65
69
|
|
66
70
|
def ignore_database?(name)
|
@@ -7,8 +7,8 @@ module Cloud
|
|
7
7
|
module Sh
|
8
8
|
module Providers
|
9
9
|
class DigitalOcean < Base
|
10
|
-
def self.refresh_k8s_configs
|
11
|
-
return if File.exist?(kube_config) && (Time.now.to_i - File.mtime(kube_config).to_i) < 3600
|
10
|
+
def self.refresh_k8s_configs(force: false)
|
11
|
+
return if !force && File.exist?(kube_config) && (Time.now.to_i - File.mtime(kube_config).to_i) < 3600
|
12
12
|
configs = Cloud::Sh.config.accounts.map { |account| new(account).k8s_configs }.flatten.compact
|
13
13
|
config = configs.shift
|
14
14
|
configs.each do |cfg|
|
@@ -16,7 +16,7 @@ module Cloud
|
|
16
16
|
config["contexts"] += cfg["contexts"]
|
17
17
|
config["users"] += cfg["users"]
|
18
18
|
end
|
19
|
-
config["current-context"] = config["contexts"].first["name"]
|
19
|
+
config["current-context"] = Cloud::Sh.config.raw["default_kubectl_context"] || config["contexts"].first["name"]
|
20
20
|
File.write(kube_config, YAML.dump(config))
|
21
21
|
end
|
22
22
|
|
data/lib/cloud/sh/version.rb
CHANGED