gleis 0.7.0 → 1.0.1
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/CHANGELOG.md +48 -0
- data/exe/gleis +1 -1
- data/lib/gleis/api.rb +9 -3
- data/lib/gleis/application.rb +27 -3
- data/lib/gleis/cli/app.rb +5 -0
- data/lib/gleis/config.rb +3 -3
- data/lib/gleis/database.rb +2 -2
- data/lib/gleis/main.rb +4 -0
- data/lib/gleis/ssh.rb +10 -6
- data/lib/gleis/storage.rb +1 -1
- data/lib/gleis/utils.rb +25 -5
- data/lib/gleis/version.rb +1 -1
- metadata +9 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a6c0f1f6682427ed485739097cd9fc4fb3b34f829b3109b50fb908a688644d91
|
4
|
+
data.tar.gz: ac9bdd28e58951994243cb03fcd8f505e943e9156a6bcdf6b227c7904ec52b25
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8272b80866e3a583053936d3027a890acfc41aa2ca85ef5e6bef26fbdcd14ac541a5f6e7cc89263c9cfd50d39c167b1b47af91448c9125b011cc1ca7187960da
|
7
|
+
data.tar.gz: 29058c2163edeb30d86e9ac894b578c05c03d44c8ee31cfb47b88632308bec42d9999a412d90955ff84c9073902384d3beea8a2a340c2787d07856c1d83055ea
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,54 @@ All notable changes to the Gleis CLI will be documented in this file.
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
7
7
|
|
8
|
+
## 1.0.1 - 2020-10-09
|
9
|
+
|
10
|
+
### Changed
|
11
|
+
|
12
|
+
- App status command to display other statuses than "running" or "not running"
|
13
|
+
|
14
|
+
## 1.0.0 - 2020-08-21
|
15
|
+
|
16
|
+
### Added
|
17
|
+
|
18
|
+
- New command called healthcheck in order to show and change the health check path of an app
|
19
|
+
|
20
|
+
### Changed
|
21
|
+
|
22
|
+
- References to old gleis.cloud domain by new domain name gleis.io
|
23
|
+
- Version dependency of thor
|
24
|
+
|
25
|
+
## 0.9.0 - 2020-06-26
|
26
|
+
|
27
|
+
### Added
|
28
|
+
|
29
|
+
- Meaningful reason why app create command failed in case of problem
|
30
|
+
|
31
|
+
### Fixed
|
32
|
+
|
33
|
+
- Extra space in SSH key generator comment and typo in user message when command is unavailable
|
34
|
+
- Raw invalid token message when session times out during the app logs command in follow mode
|
35
|
+
|
36
|
+
## 0.8.0 - 2020-04-19
|
37
|
+
|
38
|
+
### Changed
|
39
|
+
|
40
|
+
- Calls to system commands to check first if external system command exists
|
41
|
+
- External system call to which command with own which method
|
42
|
+
- Path separator to be dynamic for cross-platform compatibility
|
43
|
+
- Password prompt to use IO.noecho instead of depending on stty system command
|
44
|
+
- Save path of database dump file to be stored into user home directory instead of tmp
|
45
|
+
|
46
|
+
### Fixed
|
47
|
+
|
48
|
+
- Adding SSH Host configuration in non-existing SSH config file
|
49
|
+
|
50
|
+
## 0.7.1 - 2020-03-20
|
51
|
+
|
52
|
+
### Changed
|
53
|
+
|
54
|
+
- API URL to use .app top-level domain
|
55
|
+
|
8
56
|
## 0.7.0 - 2020-03-07
|
9
57
|
|
10
58
|
### Changed
|
data/exe/gleis
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'gleis/main'
|
4
4
|
|
5
|
-
puts "\n### Gleis CLI Copyright (c) 2018-#{Time.new.year} towards GmbH - v#{Gleis::VERSION} - https://gleis.
|
5
|
+
puts "\n### Gleis CLI Copyright (c) 2018-#{Time.new.year} towards GmbH - v#{Gleis::VERSION} - https://gleis.io ###\n\n" \
|
6
6
|
unless ARGF.argv.include?('-q')
|
7
7
|
|
8
8
|
trap 'SIGINT' do
|
data/lib/gleis/api.rb
CHANGED
@@ -23,6 +23,11 @@ module Gleis
|
|
23
23
|
when 'stream'
|
24
24
|
stream_output = proc { |response|
|
25
25
|
response.read_body do |chunk|
|
26
|
+
# Catch timed out session during streaming response to client (e.g. follow log)
|
27
|
+
# in order not to display raw "invalid token" JSON response from API
|
28
|
+
chunk == '{"message":"invalid token"}' && abort('Session has timed out, please login again (invalid token).')
|
29
|
+
# Catch application not found raw JSON response from API
|
30
|
+
chunk == '{"message":"app not found"}' && abort('Application not found.')
|
26
31
|
puts chunk
|
27
32
|
end
|
28
33
|
}
|
@@ -49,9 +54,10 @@ module Gleis
|
|
49
54
|
rescue StandardError # (e.g. SocketError, Errno::ECONNREFUSED, RestClient::BadGateway, ...)
|
50
55
|
abort('There was an issue connecting to the Gleis API server.')
|
51
56
|
else
|
52
|
-
#
|
53
|
-
|
54
|
-
|
57
|
+
# In case the user's session expires during streaming the response class will be NilClass
|
58
|
+
if (defined? resp) && resp.class != NilClass
|
59
|
+
# Streaming GET returns Net::HTTPInternalServerError in case of issue and no usable response body,
|
60
|
+
# in that case the class of resp.body == Net::ReadAdapter
|
55
61
|
if resp.body.empty?
|
56
62
|
# If there is no body return whole response object
|
57
63
|
resp
|
data/lib/gleis/application.rb
CHANGED
@@ -38,6 +38,7 @@ module Gleis
|
|
38
38
|
puts "You can then access your app using the URL https://#{body['dns_name']}" if body.key? 'dns_name'
|
39
39
|
else
|
40
40
|
puts 'failed!'
|
41
|
+
puts "\nReason for failure: #{body['message']}" unless body['message'].nil?
|
41
42
|
end
|
42
43
|
end
|
43
44
|
|
@@ -74,6 +75,7 @@ module Gleis
|
|
74
75
|
|
75
76
|
def self.exec(app_name, command)
|
76
77
|
token = Token.check
|
78
|
+
abort('The SSH client command ssh is not installed on this system.') unless Utils.which('ssh')
|
77
79
|
config_body = Config.get_env_vars(app_name, token)
|
78
80
|
# Get storage and generate mount parameter
|
79
81
|
mount_param = Utils.generate_exec_mount_param(API.request('get', "storage/#{app_name}", token), app_name)
|
@@ -86,8 +88,8 @@ module Gleis
|
|
86
88
|
-p #{p['run_port']} \
|
87
89
|
#{p['run_username']}@#{p['run_server']} \
|
88
90
|
'#{Utils.generate_exec_env_param(config_body['env_vars'])} #{mount_param} \
|
89
|
-
|
90
|
-
|
91
|
+
#{p['registry_server']}/#{dp_body['namespace']}/#{app_name}:#{dp_body['deployments'].last['commit'][0..6]} \
|
92
|
+
#{command}'")
|
91
93
|
else
|
92
94
|
puts 'No deployments found, please deploy your app first.'
|
93
95
|
end
|
@@ -108,6 +110,28 @@ module Gleis
|
|
108
110
|
end
|
109
111
|
end
|
110
112
|
|
113
|
+
def self.healthcheck(app_name, path)
|
114
|
+
token = Token.check
|
115
|
+
if path.empty?
|
116
|
+
body = API.request('get', "healthcheck/#{app_name}", token)
|
117
|
+
if body['success'] == 1
|
118
|
+
puts "The path for the health check of the #{app_name} app is: #{body['data']}"
|
119
|
+
else
|
120
|
+
puts 'Failed to fetch health check path for app.'
|
121
|
+
end
|
122
|
+
elsif Utils.uri_path_valid?(path)
|
123
|
+
body = API.request('post', 'healthcheck', token, 'name': app_name, 'path': path)
|
124
|
+
if body['success'] == 1
|
125
|
+
puts "Successfully changed app health check path to: #{path}\n\n"
|
126
|
+
puts "Don't forget to restart your app to make your change effective"
|
127
|
+
else
|
128
|
+
puts "Failed to change app health chech path: #{body['message']}"
|
129
|
+
end
|
130
|
+
else
|
131
|
+
puts 'Invalid health check path'
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
111
135
|
def self.logs(app_name, follow, process)
|
112
136
|
token = Token.check
|
113
137
|
action = "logs/#{app_name}/#{process}?follow=#{follow}"
|
@@ -233,7 +257,7 @@ module Gleis
|
|
233
257
|
else
|
234
258
|
'app not deployed yet'
|
235
259
|
end
|
236
|
-
puts "\tStatus:\t\
|
260
|
+
puts "\tStatus:\t\t#{status['status']}\n" \
|
237
261
|
"\tStarted at:\t#{Time.parse(status['createdat']).localtime.strftime('%c')}\n" \
|
238
262
|
"\tUpdated at:\t#{Time.parse(status['updatedat']).localtime.strftime('%c')}\n" \
|
239
263
|
"\tDeployment:\t#{deployment}\n" \
|
data/lib/gleis/cli/app.rb
CHANGED
@@ -35,6 +35,11 @@ module Gleis
|
|
35
35
|
Application.git(options[:app], options[:quiet])
|
36
36
|
end
|
37
37
|
|
38
|
+
desc 'healthcheck [PATH]', 'Show or change the path for the health check'
|
39
|
+
def healthcheck(path = '')
|
40
|
+
Application.healthcheck(options[:app], path)
|
41
|
+
end
|
42
|
+
|
38
43
|
desc 'logs', 'View last log entries of a process'
|
39
44
|
option :follow, aliases: :'-f', type: :boolean, default: false,
|
40
45
|
desc: 'Follow live log data'
|
data/lib/gleis/config.rb
CHANGED
@@ -2,10 +2,10 @@ module Gleis
|
|
2
2
|
# Global parameters of gleis gem and app config env variables
|
3
3
|
class Config
|
4
4
|
# Override default API URL if GLEIS_API_URL env variable is set
|
5
|
-
API_URL = ENV['GLEIS_API_URL'].nil? ? 'https://api.basel.gleis.
|
5
|
+
API_URL = ENV['GLEIS_API_URL'].nil? ? 'https://api.basel.gleis.app/' : ENV['GLEIS_API_URL']
|
6
6
|
API_VERSION = 'v0'.freeze
|
7
|
-
SSH_KEY_FILE_BASE = Dir.home
|
8
|
-
TOKEN_FILE = Dir.home
|
7
|
+
SSH_KEY_FILE_BASE = File.join(Dir.home, '.ssh', 'gleis')
|
8
|
+
TOKEN_FILE = File.join(Dir.home, '.gleis-token')
|
9
9
|
|
10
10
|
def self.get_env_vars(app_name, token)
|
11
11
|
body = API.request('get', "config/#{app_name}", token)
|
data/lib/gleis/database.rb
CHANGED
@@ -8,7 +8,7 @@ module Gleis
|
|
8
8
|
abort('There is no database configured under the DATABASE_URL variable.') unless url
|
9
9
|
db_name = url.split('/').last
|
10
10
|
timestamp = Time.now.strftime('%Y%m%d%H%M%S')
|
11
|
-
backup_file = "
|
11
|
+
backup_file = File.join(Dir.home, "#{app_name}_#{db_name}_#{timestamp}.pgdump")
|
12
12
|
if system("pg_dump -f #{backup_file} #{url}")
|
13
13
|
puts "Database configured at DATABASE_URL succesfully backed up locally in #{backup_file}"
|
14
14
|
else
|
@@ -102,7 +102,7 @@ module Gleis
|
|
102
102
|
|
103
103
|
def self.psql(app_name)
|
104
104
|
token = Token.check
|
105
|
-
abort('The PostgreSQL client psql is not installed on this system.') unless
|
105
|
+
abort('The PostgreSQL client psql is not installed on this system.') unless Utils.which('psql')
|
106
106
|
url = Config.get_env_var(app_name, token, 'DATABASE_URL')
|
107
107
|
abort('There is no database configured under the DATABASE_URL variable.') unless url
|
108
108
|
ENV['PGCONNECT_TIMEOUT'] = '5'
|
data/lib/gleis/main.rb
CHANGED
@@ -3,6 +3,10 @@ require 'gleis'
|
|
3
3
|
module Gleis
|
4
4
|
# This class defines all the main command-line interface commands for gleis
|
5
5
|
class Main < Thor
|
6
|
+
def self.exit_on_failure?
|
7
|
+
true
|
8
|
+
end
|
9
|
+
|
6
10
|
desc 'login USERNAME', 'Login into Gleis'
|
7
11
|
def login(username)
|
8
12
|
Authentication.login(username)
|
data/lib/gleis/ssh.rb
CHANGED
@@ -11,9 +11,13 @@ module Gleis
|
|
11
11
|
|
12
12
|
hostname = Socket.gethostname
|
13
13
|
datetime = Time.now.strftime('%Y-%m-%d %H:%M')
|
14
|
-
# returns true on success
|
15
|
-
|
16
|
-
|
14
|
+
# returns true on success and nil if command is not found or failed
|
15
|
+
if Utils.which('ssh-keygen')
|
16
|
+
system('ssh-keygen', '-f', key_file, '-b 4096',
|
17
|
+
"-Cgenerated by Gleis CLI for #{username} by #{ENV['USER']}@#{hostname} on #{datetime}")
|
18
|
+
else
|
19
|
+
puts 'The SSH key generator command ssh-keygen is not installed on this system.'
|
20
|
+
end
|
17
21
|
end
|
18
22
|
|
19
23
|
def self.load_public_key(public_key_file)
|
@@ -21,10 +25,10 @@ module Gleis
|
|
21
25
|
end
|
22
26
|
|
23
27
|
def self.add_host_to_config(host_name, private_key_file)
|
24
|
-
config_file = Dir.home
|
28
|
+
config_file = File.join(Dir.home, '.ssh', 'config')
|
25
29
|
ssh_host_line = "Host #{host_name}"
|
26
|
-
#
|
27
|
-
return if Utils.line_exists_in_file(config_file, ssh_host_line)
|
30
|
+
# Do not continue if host already exists in current SSH config file
|
31
|
+
return if File.exist?(config_file) && Utils.line_exists_in_file(config_file, ssh_host_line)
|
28
32
|
|
29
33
|
f = File.open(config_file, 'a')
|
30
34
|
f.puts "\n# Added by Gleis CLI on #{Time.now.strftime('%Y-%m-%d %H:%M')}"
|
data/lib/gleis/storage.rb
CHANGED
@@ -51,7 +51,7 @@ module Gleis
|
|
51
51
|
abort("Directory #{dir} does not exist or is not a directory.") unless Dir.exist?(dir)
|
52
52
|
# Get CLI parameters from API server
|
53
53
|
params = Params.get_cli_parameters(token)
|
54
|
-
abort('The rsync tool is not installed on this system.') unless
|
54
|
+
abort('The rsync tool is not installed on this system.') unless Utils.which('rsync')
|
55
55
|
body = API.request('get', "storage/#{app_name}", token)
|
56
56
|
if body['success'] == 1
|
57
57
|
if (storage = body['data']['storage'].first)
|
data/lib/gleis/utils.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'io/console'
|
2
|
+
|
1
3
|
module Gleis
|
2
4
|
# This class gathers various utilities as small methods
|
3
5
|
class Utils
|
@@ -7,9 +9,7 @@ module Gleis
|
|
7
9
|
|
8
10
|
def self.prompt_password
|
9
11
|
print 'Password: '
|
10
|
-
|
11
|
-
password = $stdin.gets.chomp
|
12
|
-
system 'stty echo'
|
12
|
+
password = STDIN.noecho(&:gets).chomp
|
13
13
|
puts
|
14
14
|
password
|
15
15
|
end
|
@@ -32,7 +32,7 @@ module Gleis
|
|
32
32
|
|
33
33
|
def self.check_for_local_pg_command(command)
|
34
34
|
abort("The PostgreSQL client required to run the command #{command}) is not installed on this system.") unless
|
35
|
-
|
35
|
+
which(command)
|
36
36
|
end
|
37
37
|
|
38
38
|
def self.validate_scale_count(count)
|
@@ -48,7 +48,7 @@ module Gleis
|
|
48
48
|
end
|
49
49
|
|
50
50
|
def self.add_remote_to_git_config(remote_url)
|
51
|
-
config_file = Dir.pwd
|
51
|
+
config_file = File.join(Dir.pwd, '.git', 'config')
|
52
52
|
return false unless File.exist?(config_file)
|
53
53
|
|
54
54
|
# Check if gleis remote already exists
|
@@ -119,5 +119,25 @@ module Gleis
|
|
119
119
|
def self.update_available?(actual_version)
|
120
120
|
Gem::Version.new(Gleis::VERSION) < Gem::Version.new(actual_version)
|
121
121
|
end
|
122
|
+
|
123
|
+
def self.which(command)
|
124
|
+
file_extensions = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
|
125
|
+
ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
|
126
|
+
file_extensions.each do |extension|
|
127
|
+
executable = File.join(path, "#{command}#{extension}")
|
128
|
+
return executable if File.executable?(executable) && !File.directory?(executable)
|
129
|
+
end
|
130
|
+
end
|
131
|
+
nil
|
132
|
+
end
|
133
|
+
|
134
|
+
def self.uri_path_valid?(path)
|
135
|
+
begin
|
136
|
+
URI.parse("http://localhost:3000#{path}")
|
137
|
+
rescue URI::InvalidURIError
|
138
|
+
return false
|
139
|
+
end
|
140
|
+
true
|
141
|
+
end
|
122
142
|
end
|
123
143
|
end
|
data/lib/gleis/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gleis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- towards GmbH
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-10-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -114,16 +114,16 @@ dependencies:
|
|
114
114
|
requirements:
|
115
115
|
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version:
|
117
|
+
version: '1.0'
|
118
118
|
type: :runtime
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version:
|
125
|
-
description: Command-line interface to deploy and manage your
|
126
|
-
|
124
|
+
version: '1.0'
|
125
|
+
description: " Command-line interface to deploy and manage your apps on the https://gleis.io
|
126
|
+
Swiss Platform as a Service supporting Ruby, Node.js, Python and .NET Core.\n"
|
127
127
|
email:
|
128
128
|
- gleis@towards.ch
|
129
129
|
executables:
|
@@ -165,7 +165,7 @@ files:
|
|
165
165
|
- lib/gleis/token.rb
|
166
166
|
- lib/gleis/utils.rb
|
167
167
|
- lib/gleis/version.rb
|
168
|
-
homepage: https://gleis.
|
168
|
+
homepage: https://gleis.io
|
169
169
|
licenses:
|
170
170
|
- GPL-3.0
|
171
171
|
metadata:
|
@@ -188,5 +188,5 @@ requirements: []
|
|
188
188
|
rubygems_version: 3.0.3
|
189
189
|
signing_key:
|
190
190
|
specification_version: 4
|
191
|
-
summary: Gleis CLI to deploy and manage
|
191
|
+
summary: Gleis CLI to deploy and manage apps on the Gleis PaaS
|
192
192
|
test_files: []
|