envirobly 1.0.0 → 1.1.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9ef94e7e6db204bc73126d41dae8d3417e4ea7ac35e7cbecd5d496dcee842ee3
4
- data.tar.gz: 32f53215e81d8e3d984cd7caf58fc0944c9636ba587e59dbd4573bfcd04f8a08
3
+ metadata.gz: 4069ab1f0da67a7bc06444c1d32cef454c23924f125925f1bc00bcd56419b94f
4
+ data.tar.gz: e5f5628338e7b9deda59a6c26f6e95b967f8ecbbfa0a1b41994aa3834f92a77a
5
5
  SHA512:
6
- metadata.gz: ef5d512c3dab84e7f4cc5ce45804d30cce526b61c83407895952536a45a901715aee2ceb39b71e5b8d68d8e477f20b4628f9f94df41a932f603a511e3d9fface
7
- data.tar.gz: d5444e2eb995be568dcc57e7df33145d2b17792f212c9ed605a3c456d511f0e2b80968d4900642c3483d9eb01afb550e1b0071f212877706a8e7a9e265d87a9e
6
+ metadata.gz: de515ea959bef33ba5a1e89ffa6862d3a8f116a8f4cab2249b97042e7a92e19020daeba4c5a93babbee793656f1f34b86850924cf97cb22b17f0a739333de4a1
7
+ data.tar.gz: af5c4e4b6d08d1c08a06be9089a9e0f0d790915efafbf0cf0694a0e0ff90c68fbfdebdcb78c2921a3f7dd571561132968839832c0c5c5cb8be7a5b13b59afba0
data/lib/envirobly/api.rb CHANGED
@@ -33,6 +33,10 @@ class Envirobly::Api
33
33
  get_as_json api_v1_regions_url, headers: authorization_headers
34
34
  end
35
35
 
36
+ def list_instance_types(region)
37
+ get_as_json api_v1_instance_types_url(region), headers: authorization_headers
38
+ end
39
+
36
40
  MAX_RETRIES = 30
37
41
  SHORT_RETRY_INTERVAL = 2.seconds
38
42
  LONG_RETRY_INTERVAL = 6.seconds
@@ -89,8 +93,12 @@ class Envirobly::Api
89
93
  api_url_for "v1/regions"
90
94
  end
91
95
 
92
- def api_url_for(path)
93
- URI::HTTPS.build(host: HOST, path: "/api/#{path}")
96
+ def api_v1_instance_types_url(region)
97
+ api_url_for "v1/instance_types", query: "region=#{region}"
98
+ end
99
+
100
+ def api_url_for(path, query: nil)
101
+ URI::HTTPS.build(host: HOST, path: "/api/#{path}", query:)
94
102
  end
95
103
 
96
104
  def request(url, type:, headers: {})
@@ -53,6 +53,26 @@ class Envirobly::Cli::Main < Envirobly::Base
53
53
  end
54
54
  end
55
55
 
56
+ desc "instance_types [region]", "List instance types in a given region, including price and performance characteristics."
57
+ def instance_types(region = nil)
58
+ default_region = Envirobly::Defaults::Region.new(shell:)
59
+ region = region.presence || default_region.require_if_none
60
+
61
+ api = Envirobly::Api.new
62
+ table_data = api.list_instance_types(region).object.map do |item|
63
+ [
64
+ item["code"],
65
+ item["vcpu"],
66
+ Envirobly::Numeric.new(item["memory"], short: true),
67
+ Envirobly::Numeric.new(item["monthly_price"]),
68
+ item["group"]
69
+ ]
70
+ end
71
+
72
+ print_table [ [ "Name", "vCPU", "Memory (GB)", "Monthly price ($)", "Group" ] ] +
73
+ table_data, borders: true
74
+ end
75
+
56
76
  desc "deploy [ENVIRON_NAME]", <<~TXT
57
77
  Deploy to environ identified by name.
58
78
  Name can contain letters, numbers, dashes or underscores.
@@ -29,7 +29,7 @@ class Envirobly::Config
29
29
  end
30
30
 
31
31
  def env_vars
32
- Dotenv.parse @dir.join(ENV_VARS)
32
+ Dotenv.parse @dir.join(ENV_VARS), overwrite: true
33
33
  end
34
34
 
35
35
  def config_file?(file)
@@ -0,0 +1,14 @@
1
+ class Envirobly::Numeric < Numeric
2
+ def initialize(value, short: false)
3
+ @value = value
4
+ @short = short
5
+ end
6
+
7
+ def to_s
8
+ if @short
9
+ @value.to_s.delete_suffix(".0")
10
+ else
11
+ "%.2f" % @value
12
+ end
13
+ end
14
+ end
@@ -1,3 +1,3 @@
1
1
  module Envirobly
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: envirobly
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Starsi
@@ -178,6 +178,7 @@ files:
178
178
  - lib/envirobly/git.rb
179
179
  - lib/envirobly/git/commit.rb
180
180
  - lib/envirobly/git/unstaged.rb
181
+ - lib/envirobly/numeric.rb
181
182
  - lib/envirobly/version.rb
182
183
  homepage: https://github.com/envirobly/envirobly-cli
183
184
  licenses:
@@ -197,7 +198,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
197
198
  - !ruby/object:Gem::Version
198
199
  version: '0'
199
200
  requirements: []
200
- rubygems_version: 3.6.8
201
+ rubygems_version: 3.6.9
201
202
  specification_version: 4
202
203
  summary: Envirobly command line interface
203
204
  test_files: []