vtk 0.2.6 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -1
- data/CHANGELOG.md +47 -6
- data/README.md +35 -10
- data/Rakefile +1 -2
- data/lib/vtk/analytics.rb +57 -0
- data/lib/vtk/cli.rb +3 -0
- data/lib/vtk/command.rb +6 -0
- data/lib/vtk/commands/module.rb +13 -14
- data/lib/vtk/commands/module/controller.rb +4 -3
- data/lib/vtk/commands/module/model.rb +4 -3
- data/lib/vtk/commands/module/serializer.rb +4 -3
- data/lib/vtk/commands/module/service.rb +4 -3
- data/lib/vtk/commands/socks.rb +40 -0
- data/lib/vtk/commands/socks/off.rb +40 -0
- data/lib/vtk/commands/socks/on.rb +61 -0
- data/lib/vtk/version.rb +1 -1
- data/vtk.gemspec +8 -6
- metadata +31 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f38bf2816e12d02d33715da96ee84b7101f72378daa994e7a09dcf84769d46b7
|
4
|
+
data.tar.gz: d823b0a548bb2b51d6e945b692c3ee396c556dedd715171d40266a1c3f86a5a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0a9f1ab0d6e9b15a5397f277eb1cce487f7b73d7c5aace867c74c443f5c7f16a7edc2985bae32f4e227018601aefeb5e6cf6447064ee000e0968eeabad5bdc51
|
7
|
+
data.tar.gz: 25f80d204782a2327745b04dfdd76a6708651b941fc0aa73489c92d5c7e706d834cb9e588519e913c9435656ad75fc7c4c8bbba0db67d849f83f6385c35784d5
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,21 +1,41 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
-
## [
|
3
|
+
## [v0.5.0](https://github.com/department-of-veterans-affairs/vtk/tree/v0.5.0) (2021-02-19)
|
4
4
|
|
5
|
-
[Full Changelog](https://github.com/department-of-veterans-affairs/vtk/compare/v0.
|
5
|
+
[Full Changelog](https://github.com/department-of-veterans-affairs/vtk/compare/v0.4.0...v0.5.0)
|
6
6
|
|
7
|
-
## [v0.
|
7
|
+
## [v0.4.0](https://github.com/department-of-veterans-affairs/vtk/tree/v0.4.0) (2021-02-19)
|
8
8
|
|
9
|
-
[Full Changelog](https://github.com/department-of-veterans-affairs/vtk/compare/v0.
|
9
|
+
[Full Changelog](https://github.com/department-of-veterans-affairs/vtk/compare/v0.3.0...v0.4.0)
|
10
|
+
|
11
|
+
**Merged pull requests:**
|
12
|
+
|
13
|
+
- Added the ability to specify a name when creating a component \(i.e. controller, model, etc.\) [\#14](https://github.com/department-of-veterans-affairs/vtk/pull/14) ([thilton-oddball](https://github.com/thilton-oddball))
|
14
|
+
|
15
|
+
## [v0.3.0](https://github.com/department-of-veterans-affairs/vtk/tree/v0.3.0) (2021-02-16)
|
16
|
+
|
17
|
+
[Full Changelog](https://github.com/department-of-veterans-affairs/vtk/compare/v0.2.6...v0.3.0)
|
18
|
+
|
19
|
+
**Merged pull requests:**
|
20
|
+
|
21
|
+
- SOCKS On/Off Commands [\#9](https://github.com/department-of-veterans-affairs/vtk/pull/9) ([ericboehs](https://github.com/ericboehs))
|
22
|
+
|
23
|
+
## [v0.2.6](https://github.com/department-of-veterans-affairs/vtk/tree/v0.2.6) (2021-02-03)
|
24
|
+
|
25
|
+
[Full Changelog](https://github.com/department-of-veterans-affairs/vtk/compare/v0.2.5...v0.2.6)
|
10
26
|
|
11
27
|
**Merged pull requests:**
|
12
28
|
|
13
29
|
- Update changelog docs and raketask [\#13](https://github.com/department-of-veterans-affairs/vtk/pull/13) ([LindseySaari](https://github.com/LindseySaari))
|
14
|
-
- add gem [\#12](https://github.com/department-of-veterans-affairs/vtk/pull/12) ([LindseySaari](https://github.com/LindseySaari))
|
30
|
+
- add gem to auto generate changelog [\#12](https://github.com/department-of-veterans-affairs/vtk/pull/12) ([LindseySaari](https://github.com/LindseySaari))
|
31
|
+
|
32
|
+
## [v0.2.5](https://github.com/department-of-veterans-affairs/vtk/tree/v0.2.5) (2021-02-03)
|
33
|
+
|
34
|
+
[Full Changelog](https://github.com/department-of-veterans-affairs/vtk/compare/v0.2.4...v0.2.5)
|
15
35
|
|
16
36
|
## [v0.2.4](https://github.com/department-of-veterans-affairs/vtk/tree/v0.2.4) (2021-01-26)
|
17
37
|
|
18
|
-
[Full Changelog](https://github.com/department-of-veterans-affairs/vtk/compare/
|
38
|
+
[Full Changelog](https://github.com/department-of-veterans-affairs/vtk/compare/v0.2.3...v0.2.4)
|
19
39
|
|
20
40
|
**Merged pull requests:**
|
21
41
|
|
@@ -23,8 +43,29 @@
|
|
23
43
|
- use system command [\#7](https://github.com/department-of-veterans-affairs/vtk/pull/7) ([LindseySaari](https://github.com/LindseySaari))
|
24
44
|
- Add additional module subcommands [\#6](https://github.com/department-of-veterans-affairs/vtk/pull/6) ([LindseySaari](https://github.com/LindseySaari))
|
25
45
|
- Check for Rails dependency [\#5](https://github.com/department-of-veterans-affairs/vtk/pull/5) ([LindseySaari](https://github.com/LindseySaari))
|
46
|
+
|
47
|
+
## [v0.2.3](https://github.com/department-of-veterans-affairs/vtk/tree/v0.2.3) (2021-01-05)
|
48
|
+
|
49
|
+
[Full Changelog](https://github.com/department-of-veterans-affairs/vtk/compare/v0.2.2...v0.2.3)
|
50
|
+
|
51
|
+
**Merged pull requests:**
|
52
|
+
|
26
53
|
- one more crack at fixing the README [\#4](https://github.com/department-of-veterans-affairs/vtk/pull/4) ([thilton-oddball](https://github.com/thilton-oddball))
|
54
|
+
|
55
|
+
## [v0.2.2](https://github.com/department-of-veterans-affairs/vtk/tree/v0.2.2) (2021-01-05)
|
56
|
+
|
57
|
+
[Full Changelog](https://github.com/department-of-veterans-affairs/vtk/compare/v0.1.0...v0.2.2)
|
58
|
+
|
59
|
+
**Merged pull requests:**
|
60
|
+
|
27
61
|
- fixing markdown in README … [\#3](https://github.com/department-of-veterans-affairs/vtk/pull/3) ([thilton-oddball](https://github.com/thilton-oddball))
|
62
|
+
|
63
|
+
## [v0.1.0](https://github.com/department-of-veterans-affairs/vtk/tree/v0.1.0) (2021-01-04)
|
64
|
+
|
65
|
+
[Full Changelog](https://github.com/department-of-veterans-affairs/vtk/compare/oclif...v0.1.0)
|
66
|
+
|
67
|
+
**Merged pull requests:**
|
68
|
+
|
28
69
|
- Start afresh with tty [\#2](https://github.com/department-of-veterans-affairs/vtk/pull/2) ([LindseySaari](https://github.com/LindseySaari))
|
29
70
|
|
30
71
|
## [oclif](https://github.com/department-of-veterans-affairs/vtk/tree/oclif) (2020-08-10)
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
#
|
1
|
+
# VFS Toolkit
|
2
2
|
|
3
|
-
The purpose of this gem is to allow
|
3
|
+
The purpose of this gem is to allow engineers to quickly begin developing on VA.gov. It does this by providing a command line interface that allows the use of simple commands and parameters to do everything from setting up a development environment to building out a directory structure and creating necessary files for separating code into its own module.
|
4
4
|
|
5
5
|
*The following assumes you have Ruby 2.6.6 or higher installed*
|
6
6
|
|
@@ -9,6 +9,10 @@ The purpose of this gem is to allow VFS engineers to quickly begin developing on
|
|
9
9
|
Install it yourself as:
|
10
10
|
|
11
11
|
$ gem install vtk
|
12
|
+
|
13
|
+
To update to the latest version:
|
14
|
+
|
15
|
+
$ gem update vtk
|
12
16
|
|
13
17
|
## Usage
|
14
18
|
|
@@ -18,14 +22,31 @@ Teams developing for vets-api should create their code as a module. This allows
|
|
18
22
|
|
19
23
|
$ vtk module add <module name>
|
20
24
|
|
21
|
-
To add additional functionality to your module, the commands listed below are available for use. These commands can build out common functionality needed when working with a module and will be created within the given module space. When creating a new module component for a module space that does not currently exist, users will be prompted with the choice to create the module directory structure. As above, first cd into the vets-api directory, then enter the command below, substituting the name of your
|
25
|
+
To add additional functionality to your module, the commands listed below are available for use. These commands can build out common functionality needed when working with a module and will be created within the given module space. When creating a new module component for a module space that does not currently exist, users will be prompted with the choice to create the module directory structure. As above, first cd into the vets-api directory, then enter the command below, substituting the name of your component for `<component name>`. You also MUST specify the name of the module by including `-m <module name>` after the component name.
|
22
26
|
|
23
|
-
$ vtk module controller <module name>
|
24
|
-
$ vtk module model <module name>
|
25
|
-
$ vtk module serializer <module name>
|
26
|
-
$ vtk module service <module name>
|
27
|
+
$ vtk module controller <component name> -m <module name>
|
28
|
+
$ vtk module model <component name> -m <module name>
|
29
|
+
$ vtk module serializer <component name> -m <module name>
|
30
|
+
$ vtk module service <component name> -m <module name>
|
27
31
|
|
28
32
|
This above command runs a custom rails generator. For more information see the [module generator documentation](https://github.com/department-of-veterans-affairs/vets-api/blob/master/lib/generators/module/USAGE)
|
33
|
+
|
34
|
+
### SOCKS
|
35
|
+
|
36
|
+
Handles connecting to VA network via SOCKS.
|
37
|
+
|
38
|
+
```
|
39
|
+
$ vtk socks on
|
40
|
+
----> Connecting...
|
41
|
+
----> Connected to SOCKS.
|
42
|
+
```
|
43
|
+
|
44
|
+
To disconnect, run:
|
45
|
+
|
46
|
+
```
|
47
|
+
$ vtk socks off
|
48
|
+
----> Disconnected from SOCKS.
|
49
|
+
```
|
29
50
|
|
30
51
|
### Help
|
31
52
|
|
@@ -33,6 +54,7 @@ For helpful information about commands and subcommands run the following:
|
|
33
54
|
|
34
55
|
$ vtk -h
|
35
56
|
$ vtk module -h
|
57
|
+
$ vtk socks -h
|
36
58
|
|
37
59
|
### Docker
|
38
60
|
|
@@ -51,6 +73,9 @@ If using the vtk gem in Docker, you may first need to run the following commands
|
|
51
73
|
6. Create new Pull Request
|
52
74
|
|
53
75
|
### Releasing
|
54
|
-
1.
|
55
|
-
2. Update the
|
56
|
-
|
76
|
+
1. Merge in your approved pull requests
|
77
|
+
2. Update the version to be whatever it should (in lib/vtk/version.rb) be and commit
|
78
|
+
- The version bump could also be part of your PR
|
79
|
+
3. ``` bundle exec rake release ```
|
80
|
+
- This will tag the release and publish to RubyGems
|
81
|
+
4. Update the changelog — (```github_changelog_generator -u department-of-veterans-affairs -p vtk```)
|
data/Rakefile
CHANGED
@@ -14,8 +14,7 @@ task default: %i[spec rubocop]
|
|
14
14
|
desc 'Tags version, pushes to remote, and pushes gem'
|
15
15
|
task :release do
|
16
16
|
sh 'git', 'tag', "v#{Vtk::VERSION}"
|
17
|
-
sh 'git push origin master'
|
18
17
|
sh "git push origin v#{Vtk::VERSION}"
|
19
18
|
sh 'rake build'
|
20
|
-
sh
|
19
|
+
sh "ls pkg/vtk-#{Vtk::VERSION}.gem | xargs -n 1 gem push"
|
21
20
|
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'json'
|
4
|
+
require 'net/http'
|
5
|
+
require 'open-uri'
|
6
|
+
require 'uri'
|
7
|
+
|
8
|
+
module Vtk
|
9
|
+
# Provides command analytics to VTK team
|
10
|
+
class Analytics
|
11
|
+
attr_reader :name, :args, :hostname
|
12
|
+
|
13
|
+
def initialize(name:, args: nil, hostname: nil)
|
14
|
+
@name = name
|
15
|
+
@args = args || ARGV.join('_')
|
16
|
+
@hostname = hostname || `hostname -f`.chomp
|
17
|
+
end
|
18
|
+
|
19
|
+
def log
|
20
|
+
return if ENV['CI'] || ENV['TEST'] || ENV['VTK_DISABLE_ANALYTICS']
|
21
|
+
|
22
|
+
Process.fork do
|
23
|
+
exit unless internet?
|
24
|
+
|
25
|
+
emit_point
|
26
|
+
rescue StandardError
|
27
|
+
false # Silently error
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def emit_point
|
32
|
+
uri = URI.parse 'https://dev.va.gov/_vfs/vtk-analytics/record'
|
33
|
+
Net::HTTP.start uri.host, uri.port, use_ssl: uri.scheme == 'https' do |http|
|
34
|
+
request = Net::HTTP::Post.new uri, 'Content-Type' => 'application/json'
|
35
|
+
request.body = { series: [point] }.to_json
|
36
|
+
http.request request
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def point
|
41
|
+
{
|
42
|
+
metric: 'vtk.command_executed',
|
43
|
+
type: 'count',
|
44
|
+
interval: 1,
|
45
|
+
tags: ["name:#{name}", "args:#{args}"],
|
46
|
+
host: hostname,
|
47
|
+
points: [[Time.now.utc.to_i, '1']]
|
48
|
+
}
|
49
|
+
end
|
50
|
+
|
51
|
+
def internet?
|
52
|
+
true if URI.open 'http://www.google.com/'
|
53
|
+
rescue SocketError
|
54
|
+
false
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
data/lib/vtk/cli.rb
CHANGED
@@ -18,6 +18,9 @@ module Vtk
|
|
18
18
|
end
|
19
19
|
map %w[--version -v] => :version
|
20
20
|
|
21
|
+
require_relative 'commands/socks'
|
22
|
+
register Vtk::Commands::Socks, 'socks', 'socks [SUBCOMMAND]', 'Handles connecting to VA network via SOCKS'
|
23
|
+
|
21
24
|
require_relative 'commands/module'
|
22
25
|
register Vtk::Commands::Module, 'module', 'module [SUBCOMMAND]', 'Command description...'
|
23
26
|
end
|
data/lib/vtk/command.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'forwardable'
|
4
|
+
require 'vtk/analytics'
|
4
5
|
|
5
6
|
module Vtk
|
6
7
|
# Command class that all command inherit from
|
@@ -9,6 +10,11 @@ module Vtk
|
|
9
10
|
|
10
11
|
def_delegators :command, :run
|
11
12
|
|
13
|
+
def initialize
|
14
|
+
command_name = self.class.to_s.split('::').last(2).join('_').downcase
|
15
|
+
Vtk::Analytics.new(name: command_name).log
|
16
|
+
end
|
17
|
+
|
12
18
|
# Execute this command
|
13
19
|
#
|
14
20
|
# @api public
|
data/lib/vtk/commands/module.rb
CHANGED
@@ -8,9 +8,9 @@ module Vtk
|
|
8
8
|
class Module < Thor
|
9
9
|
namespace :module
|
10
10
|
|
11
|
-
desc 'service <
|
12
|
-
method_option :help, aliases: '-h', type: :boolean,
|
13
|
-
|
11
|
+
desc 'service <component name>', 'Add new service class to a module in vets-api'
|
12
|
+
method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information'
|
13
|
+
method_option :module_name, aliases: '-m', type: :string, desc: 'Specify the module name', required: true
|
14
14
|
def service(name)
|
15
15
|
if options[:help]
|
16
16
|
invoke :help, ['service']
|
@@ -20,9 +20,9 @@ module Vtk
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
-
desc 'serializer <
|
24
|
-
method_option :help, aliases: '-h', type: :boolean,
|
25
|
-
|
23
|
+
desc 'serializer <component name>', 'Add new serializer to a module in vets-api'
|
24
|
+
method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information'
|
25
|
+
method_option :module_name, aliases: '-m', type: :string, desc: 'Specify the module name', required: true
|
26
26
|
def serializer(name)
|
27
27
|
if options[:help]
|
28
28
|
invoke :help, ['serializer']
|
@@ -32,9 +32,9 @@ module Vtk
|
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
-
desc 'model <
|
36
|
-
method_option :help, aliases: '-h', type: :boolean,
|
37
|
-
|
35
|
+
desc 'model <component name>', 'Add new model to a module in vets-api'
|
36
|
+
method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information'
|
37
|
+
method_option :module_name, aliases: '-m', type: :string, desc: 'Specify the module name', required: true
|
38
38
|
def model(name)
|
39
39
|
if options[:help]
|
40
40
|
invoke :help, ['model']
|
@@ -44,9 +44,9 @@ module Vtk
|
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
|
-
desc 'controller <
|
48
|
-
method_option :help, aliases: '-h', type: :boolean,
|
49
|
-
|
47
|
+
desc 'controller <component name>', 'Add new controller to a module in vets-api'
|
48
|
+
method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information'
|
49
|
+
method_option :module_name, aliases: '-m', type: :string, desc: 'Specify the module name', required: true
|
50
50
|
def controller(name)
|
51
51
|
if options[:help]
|
52
52
|
invoke :help, ['controller']
|
@@ -57,8 +57,7 @@ module Vtk
|
|
57
57
|
end
|
58
58
|
|
59
59
|
desc 'add <module name>', 'Add a new module to vets-api'
|
60
|
-
method_option :help, aliases: '-h', type: :boolean,
|
61
|
-
desc: 'Display usage information'
|
60
|
+
method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information'
|
62
61
|
def add(name)
|
63
62
|
if options[:help]
|
64
63
|
invoke :help, ['add']
|
@@ -17,13 +17,14 @@ module Vtk
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def execute(_input: $stdin, _output: $stdout)
|
20
|
-
create_controller(name)
|
20
|
+
create_controller(name, options)
|
21
21
|
end
|
22
22
|
|
23
23
|
private
|
24
24
|
|
25
|
-
def create_controller(name)
|
26
|
-
|
25
|
+
def create_controller(name, options)
|
26
|
+
module_name = options[:module_name]
|
27
|
+
system("rails g module_component #{module_name} method:controller component_name:#{name}")
|
27
28
|
end
|
28
29
|
end
|
29
30
|
end
|
@@ -17,13 +17,14 @@ module Vtk
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def execute(_input: $stdin, _output: $stdout)
|
20
|
-
create_model(name)
|
20
|
+
create_model(name, options)
|
21
21
|
end
|
22
22
|
|
23
23
|
private
|
24
24
|
|
25
|
-
def create_model(name)
|
26
|
-
|
25
|
+
def create_model(name, options)
|
26
|
+
module_name = options[:module_name]
|
27
|
+
system("rails g module_component #{module_name} method:model component_name:#{name}")
|
27
28
|
end
|
28
29
|
end
|
29
30
|
end
|
@@ -17,13 +17,14 @@ module Vtk
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def execute(_input: $stdin, _output: $stdout)
|
20
|
-
create_serializer(name)
|
20
|
+
create_serializer(name, options)
|
21
21
|
end
|
22
22
|
|
23
23
|
private
|
24
24
|
|
25
|
-
def create_serializer(name)
|
26
|
-
|
25
|
+
def create_serializer(name, options)
|
26
|
+
module_name = options[:module_name]
|
27
|
+
system("rails g module_component #{module_name} method:serializer component_name:#{name}")
|
27
28
|
end
|
28
29
|
end
|
29
30
|
end
|
@@ -17,13 +17,14 @@ module Vtk
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def execute(_input: $stdin, _output: $stdout)
|
20
|
-
create_service(name)
|
20
|
+
create_service(name, options)
|
21
21
|
end
|
22
22
|
|
23
23
|
private
|
24
24
|
|
25
|
-
def create_service(name)
|
26
|
-
|
25
|
+
def create_service(name, options)
|
26
|
+
module_name = options[:module_name]
|
27
|
+
system("rails g module_component #{module_name} method:service component_name:#{name}")
|
27
28
|
end
|
28
29
|
end
|
29
30
|
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'thor'
|
4
|
+
|
5
|
+
module Vtk
|
6
|
+
module Commands
|
7
|
+
# Handles connecting to VA network via SOCKS
|
8
|
+
class Socks < Thor
|
9
|
+
namespace :socks
|
10
|
+
|
11
|
+
desc 'off', 'Disconnects from VA SOCKS'
|
12
|
+
method_option :help, aliases: '-h', type: :boolean,
|
13
|
+
desc: 'Display usage information'
|
14
|
+
method_option :port, aliases: '-p', type: :string,
|
15
|
+
desc: 'Port that SOCKS server is running on'
|
16
|
+
def off(*)
|
17
|
+
if options[:help]
|
18
|
+
invoke :help, ['off']
|
19
|
+
else
|
20
|
+
require_relative 'socks/off'
|
21
|
+
Vtk::Commands::Socks::Off.new(options).execute
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
desc 'on', 'Connects to VA SOCKS'
|
26
|
+
method_option :help, aliases: '-h', type: :boolean,
|
27
|
+
desc: 'Display usage information'
|
28
|
+
method_option :port, aliases: '-p', type: :string,
|
29
|
+
desc: 'Port to run SOCKS server on'
|
30
|
+
def on(*)
|
31
|
+
if options[:help]
|
32
|
+
invoke :help, ['on']
|
33
|
+
else
|
34
|
+
require_relative 'socks/on'
|
35
|
+
Vtk::Commands::Socks::On.new(options).execute
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../command'
|
4
|
+
|
5
|
+
module Vtk
|
6
|
+
module Commands
|
7
|
+
class Socks
|
8
|
+
# Turns off SOCKS connection to VA network
|
9
|
+
class Off < Vtk::Command
|
10
|
+
attr_reader :options
|
11
|
+
|
12
|
+
def initialize(options)
|
13
|
+
@options = options
|
14
|
+
|
15
|
+
super()
|
16
|
+
end
|
17
|
+
|
18
|
+
def execute(_input: $stdin, output: $stdout)
|
19
|
+
pids_killed = running_pids.map { |pid| kill_pid pid }
|
20
|
+
|
21
|
+
if pids_killed.any? && pids_killed.all?
|
22
|
+
output.puts '----> Disconnected from SOCKS.'
|
23
|
+
else
|
24
|
+
output.puts '----> No SOCKS connection found.'
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def running_pids
|
31
|
+
`lsof -Pi :#{options['port'] || 2001} -sTCP:LISTEN -t`.chomp.split "\n"
|
32
|
+
end
|
33
|
+
|
34
|
+
def kill_pid(pid)
|
35
|
+
system "kill -9 #{pid}"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../command'
|
4
|
+
|
5
|
+
module Vtk
|
6
|
+
module Commands
|
7
|
+
class Socks
|
8
|
+
# Turns on SOCKS connection to VA network
|
9
|
+
class On < Vtk::Command
|
10
|
+
attr_reader :input, :output, :port
|
11
|
+
|
12
|
+
def initialize(options)
|
13
|
+
@options = options
|
14
|
+
@port = options['port'] || '2001'
|
15
|
+
|
16
|
+
super()
|
17
|
+
end
|
18
|
+
|
19
|
+
def execute(_input: $stdin, output: $stdout)
|
20
|
+
@input = input
|
21
|
+
@output = output
|
22
|
+
|
23
|
+
return output.puts '----> Already connected to SOCKS.' if connected?
|
24
|
+
|
25
|
+
connect_to_socks
|
26
|
+
ensure_connection
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def connected?
|
32
|
+
system "curl --max-time 2 -sL --proxy socks5h://127.0.0.1:#{port} sentry.vfs.va.gov 2> /dev/null | " \
|
33
|
+
'grep -q sentry-logo'
|
34
|
+
end
|
35
|
+
|
36
|
+
def connect_to_socks
|
37
|
+
exit if system "lsof -Pi :#{port} -sTCP:LISTEN -t > /dev/null"
|
38
|
+
|
39
|
+
Process.spawn "nohup ssh -vvv -o ServerAliveInterval=60 -o ConnectTimeout=5 socks -D #{port} -N" \
|
40
|
+
'> /tmp/socks.log 2>&1 &'
|
41
|
+
end
|
42
|
+
|
43
|
+
def ensure_connection
|
44
|
+
output.print '----> Connecting'
|
45
|
+
10.times do
|
46
|
+
sleep 1
|
47
|
+
output.print '.'
|
48
|
+
next unless connected?
|
49
|
+
|
50
|
+
return output.puts "\r----> Connected to SOCKS."
|
51
|
+
end
|
52
|
+
|
53
|
+
output.puts "\r----> ERROR: Could not connect to SOCKS."
|
54
|
+
output.puts "----> Verbose Output from SSH log:\n\n"
|
55
|
+
|
56
|
+
output.puts File.read '/tmp/socks.log'
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
data/lib/vtk/version.rb
CHANGED
data/vtk.gemspec
CHANGED
@@ -9,14 +9,15 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ['Eric Boehs', 'Lindsey Hattamer', 'Travis Hilton']
|
10
10
|
spec.email = ['eric.boehs@oddball.io', 'lindsey.hattamer@oddball.io', 'travis.hilton@oddball.io']
|
11
11
|
|
12
|
-
spec.summary = 'A CLI for the
|
13
|
-
spec.description = 'This is a CLI tool for
|
14
|
-
spec.homepage = 'https://github.com/department-of-veterans-affairs/
|
15
|
-
spec.required_ruby_version = Gem::Requirement.new('>= 2.
|
12
|
+
spec.summary = 'A CLI for the platform'
|
13
|
+
spec.description = 'This is a platform CLI tool for VFS developer usage.'
|
14
|
+
spec.homepage = 'https://github.com/department-of-veterans-affairs/vtk'
|
15
|
+
spec.required_ruby_version = Gem::Requirement.new('>= 2.5.0')
|
16
16
|
|
17
17
|
spec.metadata['homepage_uri'] = spec.homepage
|
18
|
+
spec.metadata['documentation_uri'] = spec.homepage
|
18
19
|
spec.metadata['source_code_uri'] = spec.homepage
|
19
|
-
spec.metadata['changelog_uri'] = 'https://github.com/department-of-veterans-affairs/
|
20
|
+
spec.metadata['changelog_uri'] = 'https://github.com/department-of-veterans-affairs/vtk/blob/master/CHANGELOG.md'
|
20
21
|
|
21
22
|
# Specify which files should be added to the gem when it is released.
|
22
23
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
@@ -30,9 +31,10 @@ Gem::Specification.new do |spec|
|
|
30
31
|
spec.add_dependency 'thor', '> 0.20.3'
|
31
32
|
|
32
33
|
spec.add_development_dependency 'github_changelog_generator', '~> 1.15.0'
|
34
|
+
spec.add_development_dependency 'pry', '~> 0.13.0'
|
33
35
|
spec.add_development_dependency 'rake', '~> 13.0.0'
|
34
36
|
spec.add_development_dependency 'rspec', '~> 3.10.0'
|
35
|
-
spec.add_development_dependency 'rubocop', '~> 1.
|
37
|
+
spec.add_development_dependency 'rubocop', '~> 1.8.0'
|
36
38
|
spec.add_development_dependency 'rubocop-rake', '~> 0.5.0'
|
37
39
|
spec.add_development_dependency 'rubocop-rspec', '~> 2.0.0'
|
38
40
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vtk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Boehs
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2021-
|
13
|
+
date: 2021-03-01 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: thor
|
@@ -40,6 +40,20 @@ dependencies:
|
|
40
40
|
- - "~>"
|
41
41
|
- !ruby/object:Gem::Version
|
42
42
|
version: 1.15.0
|
43
|
+
- !ruby/object:Gem::Dependency
|
44
|
+
name: pry
|
45
|
+
requirement: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - "~>"
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: 0.13.0
|
50
|
+
type: :development
|
51
|
+
prerelease: false
|
52
|
+
version_requirements: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - "~>"
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: 0.13.0
|
43
57
|
- !ruby/object:Gem::Dependency
|
44
58
|
name: rake
|
45
59
|
requirement: !ruby/object:Gem::Requirement
|
@@ -74,14 +88,14 @@ dependencies:
|
|
74
88
|
requirements:
|
75
89
|
- - "~>"
|
76
90
|
- !ruby/object:Gem::Version
|
77
|
-
version: 1.
|
91
|
+
version: 1.8.0
|
78
92
|
type: :development
|
79
93
|
prerelease: false
|
80
94
|
version_requirements: !ruby/object:Gem::Requirement
|
81
95
|
requirements:
|
82
96
|
- - "~>"
|
83
97
|
- !ruby/object:Gem::Version
|
84
|
-
version: 1.
|
98
|
+
version: 1.8.0
|
85
99
|
- !ruby/object:Gem::Dependency
|
86
100
|
name: rubocop-rake
|
87
101
|
requirement: !ruby/object:Gem::Requirement
|
@@ -110,7 +124,7 @@ dependencies:
|
|
110
124
|
- - "~>"
|
111
125
|
- !ruby/object:Gem::Version
|
112
126
|
version: 2.0.0
|
113
|
-
description: This is a CLI tool for
|
127
|
+
description: This is a platform CLI tool for VFS developer usage.
|
114
128
|
email:
|
115
129
|
- eric.boehs@oddball.io
|
116
130
|
- lindsey.hattamer@oddball.io
|
@@ -136,6 +150,7 @@ files:
|
|
136
150
|
- docs/design-doc.md
|
137
151
|
- exe/vtk
|
138
152
|
- lib/vtk.rb
|
153
|
+
- lib/vtk/analytics.rb
|
139
154
|
- lib/vtk/cli.rb
|
140
155
|
- lib/vtk/command.rb
|
141
156
|
- lib/vtk/commands/.gitkeep
|
@@ -145,17 +160,21 @@ files:
|
|
145
160
|
- lib/vtk/commands/module/model.rb
|
146
161
|
- lib/vtk/commands/module/serializer.rb
|
147
162
|
- lib/vtk/commands/module/service.rb
|
163
|
+
- lib/vtk/commands/socks.rb
|
164
|
+
- lib/vtk/commands/socks/off.rb
|
165
|
+
- lib/vtk/commands/socks/on.rb
|
148
166
|
- lib/vtk/templates/.gitkeep
|
149
167
|
- lib/vtk/templates/module/add/.gitkeep
|
150
168
|
- lib/vtk/version.rb
|
151
169
|
- vtk.gemspec
|
152
|
-
homepage: https://github.com/department-of-veterans-affairs/
|
170
|
+
homepage: https://github.com/department-of-veterans-affairs/vtk
|
153
171
|
licenses:
|
154
172
|
- MIT
|
155
173
|
metadata:
|
156
|
-
homepage_uri: https://github.com/department-of-veterans-affairs/
|
157
|
-
|
158
|
-
|
174
|
+
homepage_uri: https://github.com/department-of-veterans-affairs/vtk
|
175
|
+
documentation_uri: https://github.com/department-of-veterans-affairs/vtk
|
176
|
+
source_code_uri: https://github.com/department-of-veterans-affairs/vtk
|
177
|
+
changelog_uri: https://github.com/department-of-veterans-affairs/vtk/blob/master/CHANGELOG.md
|
159
178
|
post_install_message:
|
160
179
|
rdoc_options: []
|
161
180
|
require_paths:
|
@@ -164,15 +183,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
164
183
|
requirements:
|
165
184
|
- - ">="
|
166
185
|
- !ruby/object:Gem::Version
|
167
|
-
version: 2.
|
186
|
+
version: 2.5.0
|
168
187
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
169
188
|
requirements:
|
170
189
|
- - ">="
|
171
190
|
- !ruby/object:Gem::Version
|
172
191
|
version: '0'
|
173
192
|
requirements: []
|
174
|
-
rubygems_version: 3.
|
193
|
+
rubygems_version: 3.2.1
|
175
194
|
signing_key:
|
176
195
|
specification_version: 4
|
177
|
-
summary: A CLI for the
|
196
|
+
summary: A CLI for the platform
|
178
197
|
test_files: []
|