inventarium 0.0.1 → 0.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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/inventarium/cli/init.rb +11 -4
- data/lib/inventarium/cli/push.rb +48 -7
- data/lib/inventarium/cli/templates/service.yaml +47 -0
- data/lib/inventarium/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8190e44c2f3d677fb1a36a22f450a713671b5e3cb7fd4d0d63e697c2b7b91374
|
4
|
+
data.tar.gz: c3f8c732e4a486d2c5e6087d9c3a8d8c9c97ac742f00815e60af940ab4f25a74
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 719d3230c787d58226fd3fd02189a0bd94cced40964a9ab3dccaf7e8996300e14963de696fa171cbf4cf489f92ae8decca29633cedaee1bc74f6a8ec7aebacf3
|
7
|
+
data.tar.gz: '0958672f87afe42f865603bf5bb1ccbd4a2313a2d3ee60215a8a92bdc0f8cf69fef75b4f80f5963d6f82748ba8164317569e4c7da0c3972c94e88d55a04988bf'
|
data/Gemfile.lock
CHANGED
data/lib/inventarium/cli/init.rb
CHANGED
@@ -6,21 +6,28 @@ module Inventarium
|
|
6
6
|
desc "Create an empty service.yml file for the service"
|
7
7
|
|
8
8
|
example [
|
9
|
-
"
|
10
|
-
"./.service_meta
|
9
|
+
" # Generate service.yml in root folder",
|
10
|
+
"./.service_meta/ # Generate service.yml in '.service_meta' folder",
|
11
|
+
"order_service.yaml # Generate order_service.yml in root folder"
|
11
12
|
]
|
12
13
|
|
13
14
|
def call(args: [], **)
|
14
15
|
dir = args.first || '.'
|
15
16
|
|
16
17
|
pastel = Pastel.new
|
17
|
-
|
18
18
|
printf "Generating a new service.yaml\t\t"
|
19
|
-
|
19
|
+
|
20
|
+
FileUtils.cp(template_file_path, dir)
|
20
21
|
puts "[#{pastel.green('DONE')}]"
|
21
22
|
|
22
23
|
# puts "Created a new service.yml file in '#{dir}' directory"
|
23
24
|
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def template_file_path
|
29
|
+
File.expand_path(File.dirname(__FILE__) + "/templates/service.yaml")
|
30
|
+
end
|
24
31
|
end
|
25
32
|
end
|
26
33
|
end
|
data/lib/inventarium/cli/push.rb
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
require 'tty-progressbar'
|
2
2
|
require "pastel"
|
3
|
+
require 'net/http'
|
4
|
+
require 'yaml'
|
5
|
+
require 'json'
|
3
6
|
|
4
7
|
module Inventarium
|
5
8
|
module CLI
|
@@ -11,18 +14,56 @@ module Inventarium
|
|
11
14
|
"./meta/specific_service.yml # Push specific_service.yml from './meta' folder"
|
12
15
|
]
|
13
16
|
|
17
|
+
DEFAULT_BASE_URL = 'https://app.inventarium.io'
|
18
|
+
|
14
19
|
def call(args: [], **)
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
+
path = args.first || './service.yml'
|
21
|
+
|
22
|
+
bar = TTY::ProgressBar.new("Puishing #{path} to inventarium.io [:bar]", total: 30)
|
23
|
+
bar.advance(10)
|
24
|
+
|
25
|
+
config = parse_config(path)
|
26
|
+
|
27
|
+
bar.advance(10)
|
28
|
+
|
29
|
+
response = push_config(config)
|
30
|
+
|
31
|
+
bar.advance(10)
|
32
|
+
|
33
|
+
case response.code
|
34
|
+
when '200'
|
35
|
+
pastel = Pastel.new
|
36
|
+
puts "[#{pastel.green('DONE')}]"
|
37
|
+
when '422'
|
38
|
+
pastel = Pastel.new
|
39
|
+
puts "[#{pastel.red('FAIL')}] #{response.body}"
|
40
|
+
when '500'
|
41
|
+
pastel = Pastel.new
|
42
|
+
puts "[#{pastel.red('FAIL')}] #{response.body}"
|
20
43
|
end
|
21
44
|
|
22
|
-
pastel = Pastel.new
|
23
|
-
puts "[#{pastel.green('DONE')}]"
|
24
45
|
# puts "Push a new service.yml file from '#{dir}' directory"
|
25
46
|
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
def parse_config(path)
|
51
|
+
YAML.load_file(path)
|
52
|
+
end
|
53
|
+
|
54
|
+
def push_config(config)
|
55
|
+
base_url = ENV['INVENTARIUM_BASE_URL'] || DEFAULT_BASE_URL
|
56
|
+
url = URI("#{base_url}/api/services")
|
57
|
+
|
58
|
+
token = ENV['INVENTARIUM_TOKEN'].to_s
|
59
|
+
|
60
|
+
req = Net::HTTP::Post.new(url, 'X-INVENTARIUM-TOKEN' => token, 'Content-Type' => 'application/json')
|
61
|
+
req.body = { token: token, service: config }.to_json
|
62
|
+
|
63
|
+
http = Net::HTTP.new(url.hostname, url.port)
|
64
|
+
http.use_ssl = (url.scheme == "https")
|
65
|
+
http.request(req)
|
66
|
+
end
|
26
67
|
end
|
27
68
|
end
|
28
69
|
end
|
@@ -0,0 +1,47 @@
|
|
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:
|
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.0
|
4
|
+
version: 0.1.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-
|
11
|
+
date: 2020-05-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-cli
|
@@ -85,6 +85,7 @@ files:
|
|
85
85
|
- lib/inventarium/cli.rb
|
86
86
|
- lib/inventarium/cli/init.rb
|
87
87
|
- lib/inventarium/cli/push.rb
|
88
|
+
- lib/inventarium/cli/templates/service.yaml
|
88
89
|
- lib/inventarium/cli/version.rb
|
89
90
|
- lib/inventarium/version.rb
|
90
91
|
homepage: https://inventarium.io
|