dtk-network-client 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +5 -0
- data/Gemfile +2 -0
- data/LICENSE +201 -0
- data/README.md +2 -0
- data/dtk-network-client.gemspec +24 -0
- data/lib/client/args.rb +19 -0
- data/lib/client/client_args.rb +23 -0
- data/lib/client/command/add_to_group.rb +20 -0
- data/lib/client/command/chmod.rb +21 -0
- data/lib/client/command/create_namespace.rb +19 -0
- data/lib/client/command/delete.rb +25 -0
- data/lib/client/command/delete_namespace.rb +19 -0
- data/lib/client/command/info.rb +32 -0
- data/lib/client/command/install/installer.rb +9 -0
- data/lib/client/command/install.rb +190 -0
- data/lib/client/command/list.rb +13 -0
- data/lib/client/command/list_namespaces.rb +10 -0
- data/lib/client/command/publish.rb +120 -0
- data/lib/client/command/pull.rb +53 -0
- data/lib/client/command/push.rb +63 -0
- data/lib/client/command/remove_from_group.rb +20 -0
- data/lib/client/command/unpublish.rb +27 -0
- data/lib/client/command/update.rb +18 -0
- data/lib/client/command.rb +31 -0
- data/lib/client/config.rb +54 -0
- data/lib/client/conn.rb +132 -0
- data/lib/client/dependency_tree/activated.rb +35 -0
- data/lib/client/dependency_tree/cache.rb +28 -0
- data/lib/client/dependency_tree/candidates.rb +19 -0
- data/lib/client/dependency_tree/resolver.rb +16 -0
- data/lib/client/dependency_tree.rb +272 -0
- data/lib/client/error.rb +22 -0
- data/lib/client/file_helper.rb +8 -0
- data/lib/client/git_adapter/git_gem.rb +246 -0
- data/lib/client/git_client.rb +136 -0
- data/lib/client/git_repo.rb +221 -0
- data/lib/client/module_dir.rb +38 -0
- data/lib/client/module_ref/dependency/local.rb +47 -0
- data/lib/client/module_ref/dependency/remote.rb +18 -0
- data/lib/client/module_ref/dependency.rb +21 -0
- data/lib/client/module_ref/version/source.rb +18 -0
- data/lib/client/module_ref/version.rb +87 -0
- data/lib/client/module_ref.rb +21 -0
- data/lib/client/response/response_types.rb +42 -0
- data/lib/client/response.rb +27 -0
- data/lib/client/rest_wrapper.rb +43 -0
- data/lib/client/s3_helper.rb +23 -0
- data/lib/client/session.rb +54 -0
- data/lib/client/storage/adapters/s3.rb +25 -0
- data/lib/client/storage.rb +29 -0
- data/lib/client/util/os_util.rb +77 -0
- data/lib/client/util/permissions_util.rb +12 -0
- data/lib/client/util/tar.rb +104 -0
- data/lib/client/util.rb +7 -0
- data/lib/client/version.rb +8 -0
- data/lib/dtk_network_client.rb +27 -0
- metadata +183 -0
@@ -0,0 +1,29 @@
|
|
1
|
+
module DTK::Network::Client
|
2
|
+
class Storage
|
3
|
+
attr_reader :adapter
|
4
|
+
|
5
|
+
def initialize(adapter, data)
|
6
|
+
adapter_clazz = adapter_class(adapter)
|
7
|
+
@adapter = adapter_clazz.new(data)
|
8
|
+
end
|
9
|
+
|
10
|
+
def upload(data)
|
11
|
+
@adapter.upload(data)
|
12
|
+
end
|
13
|
+
|
14
|
+
def download(data, opts = {})
|
15
|
+
@adapter.download(data, opts)
|
16
|
+
end
|
17
|
+
|
18
|
+
def delete(data, opts = {})
|
19
|
+
@adapter.delete(data, opts)
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def adapter_class(adapter)
|
25
|
+
require_relative "storage/adapters/#{adapter}"
|
26
|
+
Storage::Adapter.const_get(adapter.to_s.capitalize)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (C) 2010-2016 dtk contributors
|
3
|
+
#
|
4
|
+
# This file is part of the dtk project.
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
module DTK::Network::Client::Util
|
19
|
+
module OsUtil
|
20
|
+
require 'readline'
|
21
|
+
|
22
|
+
DTK_HOME_DIR = 'dtk'
|
23
|
+
DTK_MODULES_DIR = 'modules'
|
24
|
+
DTK_MODULES_GZIP_DIR = '.download_location'
|
25
|
+
|
26
|
+
def home_dir
|
27
|
+
is_windows? ? home_dir__windows : genv(:home)
|
28
|
+
end
|
29
|
+
|
30
|
+
def dtk_local_folder
|
31
|
+
"#{home_dir}/#{DTK_HOME_DIR}"
|
32
|
+
end
|
33
|
+
|
34
|
+
def dtk_modules_location
|
35
|
+
@download_location ||= DTK::Network::Client::Config.module_download_location || "#{dtk_local_folder}/#{DTK_MODULES_DIR}"
|
36
|
+
end
|
37
|
+
|
38
|
+
def dtk_modules_gzip_location
|
39
|
+
"#{dtk_local_folder}/#{DTK_MODULES_DIR}/#{DTK_MODULES_GZIP_DIR}"
|
40
|
+
end
|
41
|
+
|
42
|
+
def temp_dir
|
43
|
+
is_windows? ? genv(:temp) : '/tmp'
|
44
|
+
end
|
45
|
+
|
46
|
+
def current_dir
|
47
|
+
Dir.getwd
|
48
|
+
end
|
49
|
+
|
50
|
+
def delim
|
51
|
+
is_windows? ? '\\' : '/'
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
def genv(name)
|
57
|
+
ENV[name.to_s.upcase].gsub(/\\/,'/')
|
58
|
+
end
|
59
|
+
|
60
|
+
def is_mac?
|
61
|
+
RUBY_PLATFORM.downcase.include?('darwin')
|
62
|
+
end
|
63
|
+
|
64
|
+
def is_windows?
|
65
|
+
RUBY_PLATFORM =~ /mswin|mingw|cygwin/
|
66
|
+
end
|
67
|
+
|
68
|
+
def home_dir__windows
|
69
|
+
"#{genv(:homedrive)}#{genv(:homepath)}"
|
70
|
+
end
|
71
|
+
|
72
|
+
def is_linux?
|
73
|
+
RUBY_PLATFORM.downcase.include?('linux')
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module DTK
|
2
|
+
module Client
|
3
|
+
module PermissionsUtil
|
4
|
+
def validate_permissions!(permission_string)
|
5
|
+
# matches example: u-rw, ugo+r, go+w
|
6
|
+
match = permission_string.match(/^[ugo]+[+\-][rwd]+$/)
|
7
|
+
raise Error.new("Provided permissions expression ('#{permission_string}') is not valid") unless match
|
8
|
+
permission_string
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,104 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (C) 2011 by Colin MacKenzie IV
|
3
|
+
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
|
11
|
+
# The above copyright notice and this permission notice shall be included in
|
12
|
+
# all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
+
# THE SOFTWARE.
|
21
|
+
#
|
22
|
+
|
23
|
+
require 'rubygems'
|
24
|
+
require 'rubygems/package'
|
25
|
+
require 'zlib'
|
26
|
+
require 'fileutils'
|
27
|
+
|
28
|
+
module DTK::Network::Client
|
29
|
+
module Util
|
30
|
+
module Tar
|
31
|
+
# Creates a tar file in memory recursively
|
32
|
+
# from the given path.
|
33
|
+
#
|
34
|
+
# Returns a StringIO whose underlying String
|
35
|
+
# is the contents of the tar file.
|
36
|
+
def tar(path, opts = {})
|
37
|
+
tarfile = StringIO.new("")
|
38
|
+
Gem::Package::TarWriter.new(tarfile) do |tar|
|
39
|
+
nested_content = Dir.glob(File.join(path, "**/*"), File::FNM_DOTMATCH)
|
40
|
+
nested_content.reject!{ |f_name| f_name.include?('.git')} if opts[:exclude_git]
|
41
|
+
|
42
|
+
nested_content.each do |file|
|
43
|
+
mode = File.stat(file).mode
|
44
|
+
relative_file = file.sub /^#{Regexp::escape path}\/?/, ''
|
45
|
+
|
46
|
+
if File.directory?(file)
|
47
|
+
tar.mkdir relative_file, mode
|
48
|
+
else
|
49
|
+
tar.add_file relative_file, mode do |tf|
|
50
|
+
File.open(file, "rb") { |f| tf.write f.read }
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
tarfile.rewind
|
57
|
+
tarfile
|
58
|
+
end
|
59
|
+
|
60
|
+
# gzips the underlying string in the given StringIO,
|
61
|
+
# returning a new StringIO representing the
|
62
|
+
# compressed file.
|
63
|
+
def gzip(tarfile)
|
64
|
+
gz = StringIO.new("")
|
65
|
+
z = Zlib::GzipWriter.new(gz)
|
66
|
+
z.write tarfile.string
|
67
|
+
z.close # this is necessary!
|
68
|
+
|
69
|
+
# z was closed to write the gzip footer, so
|
70
|
+
# now we need a new StringIO
|
71
|
+
StringIO.new gz.string
|
72
|
+
end
|
73
|
+
|
74
|
+
# un-gzips the given IO, returning the
|
75
|
+
# decompressed version as a StringIO
|
76
|
+
def ungzip(tarfile)
|
77
|
+
z = Zlib::GzipReader.new(tarfile)
|
78
|
+
unzipped = StringIO.new(z.read)
|
79
|
+
z.close
|
80
|
+
unzipped
|
81
|
+
end
|
82
|
+
|
83
|
+
# untars the given IO into the specified
|
84
|
+
# directory
|
85
|
+
def untar(io, destination)
|
86
|
+
Gem::Package::TarReader.new io do |tar|
|
87
|
+
tar.each do |tarfile|
|
88
|
+
destination_file = File.join destination, tarfile.full_name
|
89
|
+
|
90
|
+
if tarfile.directory?
|
91
|
+
FileUtils.mkdir_p destination_file
|
92
|
+
else
|
93
|
+
destination_directory = File.dirname(destination_file)
|
94
|
+
FileUtils.mkdir_p destination_directory unless File.directory?(destination_directory)
|
95
|
+
File.open destination_file, "wb" do |f|
|
96
|
+
f.print tarfile.read
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
data/lib/client/util.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'dtk_common_core'
|
2
|
+
require 'rest-client'
|
3
|
+
|
4
|
+
module DTK
|
5
|
+
module Network
|
6
|
+
module Client
|
7
|
+
require_relative('client/util')
|
8
|
+
require_relative('client/config')
|
9
|
+
require_relative('client/git_repo')
|
10
|
+
require_relative('client/git_client')
|
11
|
+
require_relative('client/rest_wrapper')
|
12
|
+
require_relative('client/command')
|
13
|
+
require_relative('client/response')
|
14
|
+
require_relative('client/dependency_tree')
|
15
|
+
require_relative('client/conn')
|
16
|
+
require_relative('client/session')
|
17
|
+
require_relative('client/args')
|
18
|
+
require_relative('client/module_ref')
|
19
|
+
require_relative('client/module_dir')
|
20
|
+
require_relative('client/file_helper')
|
21
|
+
require_relative('client/s3_helper')
|
22
|
+
require_relative('client/error')
|
23
|
+
require_relative('client/client_args')
|
24
|
+
require_relative('client/storage')
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,183 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: dtk-network-client
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Reactor8
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-03-28 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: git
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.2.9
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.2.9
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: semverly
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rest-client
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.6.7
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.6.7
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: aws-sdk
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: dtk-dsl
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 1.1.0
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 1.1.0
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: dtk-common-core
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 0.11.1
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 0.11.1
|
97
|
+
description: Library for interaction with dtk network.
|
98
|
+
email: support@reactor8.com
|
99
|
+
executables: []
|
100
|
+
extensions: []
|
101
|
+
extra_rdoc_files: []
|
102
|
+
files:
|
103
|
+
- ".gitignore"
|
104
|
+
- Gemfile
|
105
|
+
- LICENSE
|
106
|
+
- README.md
|
107
|
+
- dtk-network-client.gemspec
|
108
|
+
- lib/client/args.rb
|
109
|
+
- lib/client/client_args.rb
|
110
|
+
- lib/client/command.rb
|
111
|
+
- lib/client/command/add_to_group.rb
|
112
|
+
- lib/client/command/chmod.rb
|
113
|
+
- lib/client/command/create_namespace.rb
|
114
|
+
- lib/client/command/delete.rb
|
115
|
+
- lib/client/command/delete_namespace.rb
|
116
|
+
- lib/client/command/info.rb
|
117
|
+
- lib/client/command/install.rb
|
118
|
+
- lib/client/command/install/installer.rb
|
119
|
+
- lib/client/command/list.rb
|
120
|
+
- lib/client/command/list_namespaces.rb
|
121
|
+
- lib/client/command/publish.rb
|
122
|
+
- lib/client/command/pull.rb
|
123
|
+
- lib/client/command/push.rb
|
124
|
+
- lib/client/command/remove_from_group.rb
|
125
|
+
- lib/client/command/unpublish.rb
|
126
|
+
- lib/client/command/update.rb
|
127
|
+
- lib/client/config.rb
|
128
|
+
- lib/client/conn.rb
|
129
|
+
- lib/client/dependency_tree.rb
|
130
|
+
- lib/client/dependency_tree/activated.rb
|
131
|
+
- lib/client/dependency_tree/cache.rb
|
132
|
+
- lib/client/dependency_tree/candidates.rb
|
133
|
+
- lib/client/dependency_tree/resolver.rb
|
134
|
+
- lib/client/error.rb
|
135
|
+
- lib/client/file_helper.rb
|
136
|
+
- lib/client/git_adapter/git_gem.rb
|
137
|
+
- lib/client/git_client.rb
|
138
|
+
- lib/client/git_repo.rb
|
139
|
+
- lib/client/module_dir.rb
|
140
|
+
- lib/client/module_ref.rb
|
141
|
+
- lib/client/module_ref/dependency.rb
|
142
|
+
- lib/client/module_ref/dependency/local.rb
|
143
|
+
- lib/client/module_ref/dependency/remote.rb
|
144
|
+
- lib/client/module_ref/version.rb
|
145
|
+
- lib/client/module_ref/version/source.rb
|
146
|
+
- lib/client/response.rb
|
147
|
+
- lib/client/response/response_types.rb
|
148
|
+
- lib/client/rest_wrapper.rb
|
149
|
+
- lib/client/s3_helper.rb
|
150
|
+
- lib/client/session.rb
|
151
|
+
- lib/client/storage.rb
|
152
|
+
- lib/client/storage/adapters/s3.rb
|
153
|
+
- lib/client/util.rb
|
154
|
+
- lib/client/util/os_util.rb
|
155
|
+
- lib/client/util/permissions_util.rb
|
156
|
+
- lib/client/util/tar.rb
|
157
|
+
- lib/client/version.rb
|
158
|
+
- lib/dtk_network_client.rb
|
159
|
+
homepage:
|
160
|
+
licenses:
|
161
|
+
- Apache 2.0
|
162
|
+
metadata: {}
|
163
|
+
post_install_message:
|
164
|
+
rdoc_options: []
|
165
|
+
require_paths:
|
166
|
+
- lib
|
167
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
168
|
+
requirements:
|
169
|
+
- - ">="
|
170
|
+
- !ruby/object:Gem::Version
|
171
|
+
version: 1.9.3
|
172
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
173
|
+
requirements:
|
174
|
+
- - ">="
|
175
|
+
- !ruby/object:Gem::Version
|
176
|
+
version: '0'
|
177
|
+
requirements: []
|
178
|
+
rubyforge_project:
|
179
|
+
rubygems_version: 2.4.8
|
180
|
+
signing_key:
|
181
|
+
specification_version: 4
|
182
|
+
summary: Library for interaction with dtk network.
|
183
|
+
test_files: []
|