inventarium 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +12 -1
- data/README.md +14 -0
- data/inventarium.gemspec +1 -0
- data/lib/inventarium/cli.rb +1 -0
- data/lib/inventarium/cli/init.rb +21 -4
- data/lib/inventarium/cli/push.rb +13 -6
- data/lib/inventarium/cli/template_generator.rb +20 -0
- data/lib/inventarium/cli/templates/service.yaml.erb +64 -0
- data/lib/inventarium/version.rb +1 -1
- metadata +18 -3
- data/lib/inventarium/cli/templates/service.yaml +0 -47
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 395db22e4f7711b1376ce7a3a6b830813143fd4c06fc9f2a96675d0d73cf6200
|
4
|
+
data.tar.gz: 23468bbeb716770cd8029ffb3ac4d0e00e8710641cff9b1eb86535076019790a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7606c0b74c51656bad562b3ee9dc465793232da3e2b56a99753427e4f5249c65ecb5458b4823ab4e892709c8f935077e06e405cf81c6b41eaeda450ef482ae7e
|
7
|
+
data.tar.gz: d9b2613a387fc59e67b3e39b28258fb39f3ab0a3dbb5abfbdc2c243f34989d18e25283cc9efef213ec406c2af57a7a935be65f0761f7734a8baa97a94d66f64d
|
data/Gemfile.lock
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
inventarium (0.
|
4
|
+
inventarium (0.3.0)
|
5
5
|
dry-cli (~> 0.4)
|
6
6
|
pastel
|
7
7
|
tty-progressbar
|
8
|
+
tty-prompt
|
8
9
|
|
9
10
|
GEM
|
10
11
|
remote: https://rubygems.org/
|
@@ -16,6 +17,7 @@ GEM
|
|
16
17
|
concurrent-ruby (~> 1.0)
|
17
18
|
equatable (0.6.1)
|
18
19
|
json (2.3.0)
|
20
|
+
necromancer (0.5.1)
|
19
21
|
pastel (0.7.4)
|
20
22
|
equatable (~> 0.6)
|
21
23
|
tty-color (~> 0.5)
|
@@ -48,8 +50,17 @@ GEM
|
|
48
50
|
tty-cursor (~> 0.7)
|
49
51
|
tty-screen (~> 0.7)
|
50
52
|
unicode-display_width (~> 1.6)
|
53
|
+
tty-prompt (0.21.0)
|
54
|
+
necromancer (~> 0.5.0)
|
55
|
+
pastel (~> 0.7.0)
|
56
|
+
tty-reader (~> 0.7.0)
|
57
|
+
tty-reader (0.7.0)
|
58
|
+
tty-cursor (~> 0.7)
|
59
|
+
tty-screen (~> 0.7)
|
60
|
+
wisper (~> 2.0.0)
|
51
61
|
tty-screen (0.7.1)
|
52
62
|
unicode-display_width (1.7.0)
|
63
|
+
wisper (2.0.1)
|
53
64
|
|
54
65
|
PLATFORMS
|
55
66
|
ruby
|
data/README.md
CHANGED
@@ -1,5 +1,19 @@
|
|
1
1
|
# Inventarium CLI
|
2
2
|
|
3
|
+
## Instalation
|
4
|
+
|
5
|
+
Requirements:
|
6
|
+
|
7
|
+
- Ruby version: `2.5.0` (working with default macOS version)
|
8
|
+
|
9
|
+
```
|
10
|
+
gem install inventarium
|
11
|
+
```
|
12
|
+
|
13
|
+
## Usage
|
14
|
+
|
15
|
+
- `inventarium init` - generate new empty `service.yaml` file
|
16
|
+
- `inventarium push path/to/service.yaml` - push service information to [inventarium app](https://inventarium.io)
|
3
17
|
|
4
18
|
## Copyright
|
5
19
|
|
data/inventarium.gemspec
CHANGED
@@ -32,6 +32,7 @@ Gem::Specification.new do |spec|
|
|
32
32
|
|
33
33
|
spec.add_runtime_dependency "dry-cli", "~> 0.4"
|
34
34
|
spec.add_runtime_dependency "tty-progressbar"
|
35
|
+
spec.add_runtime_dependency "tty-prompt"
|
35
36
|
spec.add_runtime_dependency "pastel"
|
36
37
|
|
37
38
|
spec.add_development_dependency "bundler"
|
data/lib/inventarium/cli.rb
CHANGED
data/lib/inventarium/cli/init.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require "tty-prompt"
|
2
|
+
|
1
3
|
module Inventarium
|
2
4
|
module CLI
|
3
5
|
class Init < Dry::CLI::Command
|
@@ -9,20 +11,35 @@ module Inventarium
|
|
9
11
|
"order_service.yaml # Generate order_service.yml in root folder"
|
10
12
|
]
|
11
13
|
|
14
|
+
CLASSIFICATION_VALUES = %w[critical normal internal experiment]
|
15
|
+
STATUS_VALUES = %w[adopt hold trial in_development]
|
16
|
+
|
12
17
|
def call(args: [], **)
|
13
|
-
dir = args.first || '.'
|
18
|
+
dir = args.first || './service.yaml'
|
19
|
+
result = base_service_information
|
14
20
|
|
15
21
|
pastel = Pastel.new
|
16
22
|
printf "Generating a new service.yaml\t\t"
|
17
23
|
|
18
|
-
|
24
|
+
TemplateGenerator.new.call(dir: dir, payload: result)
|
25
|
+
|
19
26
|
puts "[#{pastel.green('DONE')}]"
|
20
27
|
end
|
21
28
|
|
22
29
|
private
|
23
30
|
|
24
|
-
def
|
25
|
-
|
31
|
+
def base_service_information
|
32
|
+
prompt = TTY::Prompt.new
|
33
|
+
name = prompt.ask('A name of the service:', required: true)
|
34
|
+
|
35
|
+
key = prompt.ask("A uniq key for service (you can use only chars, integers, '_' and '-'):", required: true) do |q|
|
36
|
+
q.validate(/\A[a-zA-Z0-9_-]+\Z/, "Invalid key value, please use only chars, integers and '-'")
|
37
|
+
end
|
38
|
+
|
39
|
+
classification = prompt.select("Choose service classification", CLASSIFICATION_VALUES, symbols: {marker: '>'})
|
40
|
+
status = prompt.select("Choose service status", STATUS_VALUES, symbols: {marker: '>'})
|
41
|
+
|
42
|
+
{ name: name, key: key, classification: classification, status: status }
|
26
43
|
end
|
27
44
|
end
|
28
45
|
end
|
data/lib/inventarium/cli/push.rb
CHANGED
@@ -2,6 +2,7 @@ require 'tty-progressbar'
|
|
2
2
|
require 'net/http'
|
3
3
|
require 'yaml'
|
4
4
|
require 'json'
|
5
|
+
require 'pp'
|
5
6
|
|
6
7
|
module Inventarium
|
7
8
|
module CLI
|
@@ -29,19 +30,25 @@ module Inventarium
|
|
29
30
|
|
30
31
|
bar.advance(10)
|
31
32
|
|
33
|
+
pastel = Pastel.new
|
34
|
+
|
32
35
|
case response.code
|
33
36
|
when '200'
|
34
|
-
pastel = Pastel.new
|
35
37
|
puts "[#{pastel.green('DONE')}]"
|
36
|
-
|
37
|
-
|
38
|
+
|
39
|
+
exit(0) # success exist
|
40
|
+
when '401' # Unauthorized
|
38
41
|
puts "[#{pastel.red('FAIL')}] #{response.body}"
|
39
|
-
when '
|
40
|
-
pastel = Pastel.new
|
42
|
+
when '403' # Forbidden
|
41
43
|
puts "[#{pastel.red('FAIL')}] #{response.body}"
|
44
|
+
when '422' # invalid data
|
45
|
+
puts "[#{pastel.red('FAIL')}]"
|
46
|
+
pp JSON.parse(response.body)
|
47
|
+
when '500'
|
48
|
+
puts "[#{pastel.red('FAIL')}] Service error, please try later or create an issue in https://github.com/inventarium-org/core"
|
42
49
|
end
|
43
50
|
|
44
|
-
|
51
|
+
exit(1)
|
45
52
|
end
|
46
53
|
|
47
54
|
private
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'erb'
|
2
|
+
|
3
|
+
module Inventarium
|
4
|
+
module CLI
|
5
|
+
class TemplateGenerator
|
6
|
+
def call(dir:, payload:)
|
7
|
+
template = File.read(template_file_path)
|
8
|
+
result = ERB.new(template).result(binding)
|
9
|
+
|
10
|
+
File.open(dir, 'w') { |f| f.write(result) }
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def template_file_path
|
16
|
+
File.expand_path(File.dirname(__FILE__) + "/templates/service.yaml.erb")
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
version: v0
|
2
|
+
|
3
|
+
# You need to provide only name and key fields, everything else can be empty
|
4
|
+
# For example, if you don't have documentation or environments you can add it later
|
5
|
+
|
6
|
+
# required
|
7
|
+
name: <%= payload[:name] %>
|
8
|
+
# required, should be unique for each service
|
9
|
+
key: <%= payload[:key] %>
|
10
|
+
description:
|
11
|
+
languages:
|
12
|
+
-
|
13
|
+
repository_link:
|
14
|
+
tags:
|
15
|
+
-
|
16
|
+
|
17
|
+
owner:
|
18
|
+
team_or_developer_name:
|
19
|
+
slack_channel:
|
20
|
+
|
21
|
+
service:
|
22
|
+
# optional, can be (critical | normal | internal | experiment)
|
23
|
+
classification: <%= payload[:classification] %>
|
24
|
+
# optional, can be (adopt | hold | trial | in_development)
|
25
|
+
status: <%= payload[:status] %>
|
26
|
+
|
27
|
+
docs:
|
28
|
+
api:
|
29
|
+
maintenance:
|
30
|
+
domain:
|
31
|
+
|
32
|
+
# You can add any count of environments and you can use any names instead production, like stage, demo, etc
|
33
|
+
environments:
|
34
|
+
production:
|
35
|
+
url:
|
36
|
+
healthcheck_url:
|
37
|
+
logs_url:
|
38
|
+
error_tracker_url:
|
39
|
+
tags:
|
40
|
+
- test
|
41
|
+
- specific gateway
|
42
|
+
monitoring:
|
43
|
+
# You can use any key-value objects here, like new_relic, grafana, etc
|
44
|
+
something:
|
45
|
+
|
46
|
+
operations:
|
47
|
+
ci_build_url:
|
48
|
+
|
49
|
+
communications:
|
50
|
+
# type is reqired, can be (http | rpc | graphql | event-producer | event-consumer)
|
51
|
+
- type:
|
52
|
+
# reqired, can be anything like (service key | kafka | rabbitmq | etc)
|
53
|
+
target:
|
54
|
+
# optional, can be (critical | uncritical)
|
55
|
+
criticality:
|
56
|
+
# optional list, can be (topic name | queue name | rpc resource | rest resource | gqlschema name)
|
57
|
+
resource:
|
58
|
+
-
|
59
|
+
# optional
|
60
|
+
custom_data:
|
61
|
+
# can be anything
|
62
|
+
# events:
|
63
|
+
# - test-event
|
64
|
+
# version: 2
|
data/lib/inventarium/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: inventarium
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anton Davydov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-05-
|
11
|
+
date: 2020-05-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-cli
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: tty-prompt
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: pastel
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -114,7 +128,8 @@ files:
|
|
114
128
|
- lib/inventarium/cli.rb
|
115
129
|
- lib/inventarium/cli/init.rb
|
116
130
|
- lib/inventarium/cli/push.rb
|
117
|
-
- lib/inventarium/cli/
|
131
|
+
- lib/inventarium/cli/template_generator.rb
|
132
|
+
- lib/inventarium/cli/templates/service.yaml.erb
|
118
133
|
- lib/inventarium/cli/version.rb
|
119
134
|
- lib/inventarium/version.rb
|
120
135
|
homepage: https://inventarium.io
|
@@ -1,47 +0,0 @@
|
|
1
|
-
version: v0
|
2
|
-
|
3
|
-
# You need to provide only name and key fields, everything else can be empty
|
4
|
-
# For example, if you don't have documentation or environments you can add it later
|
5
|
-
|
6
|
-
# required
|
7
|
-
name: Service
|
8
|
-
# required, should be unique for each service
|
9
|
-
key: service
|
10
|
-
description:
|
11
|
-
languages:
|
12
|
-
-
|
13
|
-
repository_link:
|
14
|
-
tags:
|
15
|
-
-
|
16
|
-
|
17
|
-
owner:
|
18
|
-
team_or_developer_name:
|
19
|
-
slack_channel:
|
20
|
-
|
21
|
-
service:
|
22
|
-
# optional, can be (critical | normal | internal | expiriment)
|
23
|
-
classification:
|
24
|
-
# optional, can be (adopt | hold | trial | in development)
|
25
|
-
status:
|
26
|
-
|
27
|
-
docs:
|
28
|
-
api:
|
29
|
-
maintenance:
|
30
|
-
domain:
|
31
|
-
|
32
|
-
# You can add any count of environments and you can use any names instead production, like stage, demo, etc
|
33
|
-
environments:
|
34
|
-
production:
|
35
|
-
url:
|
36
|
-
healthcheck_url:
|
37
|
-
logs_url:
|
38
|
-
error_traker_url:
|
39
|
-
tags:
|
40
|
-
- test
|
41
|
-
- specific gateway
|
42
|
-
monitoring:
|
43
|
-
# You can use any key-value objects here, like new_relic, grafana, etc
|
44
|
-
something:
|
45
|
-
|
46
|
-
operations:
|
47
|
-
ci_build_url:
|