vagrant_cloud 3.0.0 → 3.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/vagrant_cloud/box.rb +15 -5
- data/lib/vagrant_cloud/box/provider.rb +15 -13
- data/lib/vagrant_cloud/box/version.rb +3 -1
- data/lib/vagrant_cloud/client.rb +10 -4
- data/lib/vagrant_cloud/error.rb +1 -0
- data/lib/vagrant_cloud/logger.rb +9 -5
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 00b96df31d811857d6e1322587604bc91195401913872e3340fa89eb8c0816fd
|
4
|
+
data.tar.gz: 52da865c61e7d50b5777a2a9ea2cc3bd6d7c22c1a3e2a34bc2bfdd537515b0da
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9e6a2b72a501bc694992e9de0b789cba4c38fb8c6f176cd4c2e5ca4bd0fb387db5d2b23ada2307b7c63d6590b4ad3b1a8c8f98c74fbcd4f95ffd9c49cb028604
|
7
|
+
data.tar.gz: a0e90c8f8adad13d0dccd154cf50407065048a8e773df01c50482bdf79787d744e91d5b2e1a6f431c20c7d37656d894aa82c3fdf3e4f7501da5882bd029dff42
|
data/README.md
CHANGED
@@ -163,7 +163,7 @@ Release a new version:
|
|
163
163
|
1. Update the version in the `version.txt` file
|
164
164
|
1. Commit the change to master
|
165
165
|
1. Create a new version tag in git: `git tag vX.X.X`
|
166
|
-
1. Push the new tag and master to GitHub `git push origin
|
166
|
+
1. Push the new tag and master to GitHub `git push origin main --tags`
|
167
167
|
|
168
168
|
The new release will be automatically built and published.
|
169
169
|
|
data/lib/vagrant_cloud/box.rb
CHANGED
@@ -37,7 +37,13 @@ module VagrantCloud
|
|
37
37
|
# @note This will delete the box, and all versions
|
38
38
|
def delete
|
39
39
|
if exist?
|
40
|
-
organization.account.client.box_delete(
|
40
|
+
organization.account.client.box_delete(
|
41
|
+
username: username,
|
42
|
+
name: name
|
43
|
+
)
|
44
|
+
b = organization.boxes.dup
|
45
|
+
b.delete(self)
|
46
|
+
organization.clean(data: {boxes: b})
|
41
47
|
end
|
42
48
|
nil
|
43
49
|
end
|
@@ -82,11 +88,15 @@ module VagrantCloud
|
|
82
88
|
# only when requested
|
83
89
|
def versions_on_demand
|
84
90
|
if !@versions_loaded
|
85
|
-
|
86
|
-
|
87
|
-
|
91
|
+
if exist?
|
92
|
+
r = self.organization.account.client.box_get(username: username, name: name)
|
93
|
+
v = Array(r[:versions]).map do |version|
|
94
|
+
Box::Version.load(box: self, **version)
|
95
|
+
end
|
96
|
+
clean(data: {versions: v + Array(plain_versions)})
|
97
|
+
else
|
98
|
+
clean(data: {versions: []})
|
88
99
|
end
|
89
|
-
clean(data: {versions: v + Array(plain_versions)})
|
90
100
|
@versions_loaded = true
|
91
101
|
end
|
92
102
|
plain_versions
|
@@ -7,7 +7,8 @@ module VagrantCloud
|
|
7
7
|
#
|
8
8
|
# @param [String] upload_url URL for uploading file asset
|
9
9
|
# @param [String] callback_url URL callback to PUT after successful upload
|
10
|
-
|
10
|
+
# @param [Proc] callback Callable proc to perform callback via configured client
|
11
|
+
DirectUpload = Struct.new(:upload_url, :callback_url, :callback, keyword_init: true)
|
11
12
|
|
12
13
|
attr_reader :version
|
13
14
|
attr_required :name
|
@@ -36,7 +37,9 @@ module VagrantCloud
|
|
36
37
|
version: version.version,
|
37
38
|
provider: name
|
38
39
|
)
|
39
|
-
version.providers.
|
40
|
+
pv = version.providers.dup
|
41
|
+
pv.delete(self)
|
42
|
+
version.clean(data: {providers: pv})
|
40
43
|
end
|
41
44
|
nil
|
42
45
|
end
|
@@ -93,25 +96,24 @@ module VagrantCloud
|
|
93
96
|
end
|
94
97
|
result = DirectUpload.new(
|
95
98
|
upload_url: r[:upload_path],
|
96
|
-
callback_url: r[:callback]
|
99
|
+
callback_url: r[:callback],
|
100
|
+
callback: proc {
|
101
|
+
if r[:callback]
|
102
|
+
version.box.organization.account.client.
|
103
|
+
request(method: :put, path: URI.parse(r[:callback]).path)
|
104
|
+
end
|
105
|
+
}
|
97
106
|
)
|
98
107
|
if block_given?
|
99
108
|
block_r = yield result.upload_url
|
100
|
-
|
109
|
+
result[:callback].call
|
101
110
|
block_r
|
102
111
|
elsif path
|
103
112
|
File.open(path, "rb") do |file|
|
104
113
|
chunks = lambda { file.read(Excon.defaults[:chunk_size]).to_s }
|
105
|
-
|
106
|
-
# to the provided upload URL. If it's just a regular upload
|
107
|
-
# then we just PUT to the upload URL.
|
108
|
-
if direct
|
109
|
-
Excon.post(result.upload_url, request_block: chunks)
|
110
|
-
else
|
111
|
-
Excon.put(result.upload_url, request_block: chunks)
|
112
|
-
end
|
114
|
+
Excon.put(result.upload_url, request_block: chunks)
|
113
115
|
end
|
114
|
-
|
116
|
+
result[:callback].call
|
115
117
|
self
|
116
118
|
else
|
117
119
|
# When returning upload information for requester to complete,
|
data/lib/vagrant_cloud/client.rb
CHANGED
@@ -91,8 +91,10 @@ module VagrantCloud
|
|
91
91
|
# @param [Hash] params Parameters to send with request
|
92
92
|
# @return [Hash]
|
93
93
|
def request(path:, method: :get, params: {})
|
94
|
-
|
95
|
-
|
94
|
+
if !path.start_with?(path_base)
|
95
|
+
# Build the full path for the request and clean it
|
96
|
+
path = [path_base, path].compact.join("/").gsub(/\/{2,}/, "/")
|
97
|
+
end
|
96
98
|
method = method.to_s.downcase.to_sym
|
97
99
|
|
98
100
|
# Build base request parameters
|
@@ -172,8 +174,12 @@ module VagrantCloud
|
|
172
174
|
login: username,
|
173
175
|
password: password
|
174
176
|
},
|
175
|
-
|
176
|
-
|
177
|
+
token: {
|
178
|
+
description: description
|
179
|
+
},
|
180
|
+
two_factor: {
|
181
|
+
code: code
|
182
|
+
}
|
177
183
|
}
|
178
184
|
request(method: :post, path: "authenticate", params: params)
|
179
185
|
end
|
data/lib/vagrant_cloud/error.rb
CHANGED
data/lib/vagrant_cloud/logger.rb
CHANGED
@@ -26,11 +26,15 @@ module VagrantCloud
|
|
26
26
|
# sure that the log level is an integer, as Log4r requires.
|
27
27
|
level = nil if !level.is_a?(Integer)
|
28
28
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
29
|
+
# Only override the log output format if the default is set
|
30
|
+
if Log4r::Outputter.stderr.formatter.is_a?(Log4r::DefaultFormatter)
|
31
|
+
base_formatter = Log4r::PatternFormatter.new(
|
32
|
+
pattern: "%d [%5l] %m",
|
33
|
+
date_pattern: "%F %T"
|
34
|
+
)
|
35
|
+
Log4r::Outputter.stderr.formatter = base_formatter
|
36
|
+
end
|
37
|
+
|
34
38
|
logger = Log4r::Logger.new("vagrantcloud")
|
35
39
|
logger.outputters = Log4r::Outputter.stderr
|
36
40
|
logger.level = level
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant_cloud
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- HashiCorp
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2020-
|
12
|
+
date: 2020-10-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: excon
|
@@ -128,7 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
128
128
|
- !ruby/object:Gem::Version
|
129
129
|
version: '0'
|
130
130
|
requirements: []
|
131
|
-
rubygems_version: 3.
|
131
|
+
rubygems_version: 3.1.2
|
132
132
|
signing_key:
|
133
133
|
specification_version: 4
|
134
134
|
summary: Vagrant Cloud API Library
|