vagrant-sakura 0.0.9 → 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 +5 -5
- data/.gitignore +1 -0
- data/.travis.yml +30 -0
- data/CHANGELOG.md +10 -0
- data/Gemfile +2 -0
- data/README.md +86 -16
- data/Rakefile +5 -0
- data/examples/centos.md +15 -0
- data/examples/centos6.md +15 -0
- data/examples/coreos.md +15 -0
- data/examples/debian.md +15 -0
- data/examples/freebsd.md +17 -0
- data/examples/rancheros.md +17 -0
- data/examples/ubuntu.md +15 -0
- data/lib/vagrant-sakura/action/complete_archive_id.rb +38 -0
- data/lib/vagrant-sakura/action/reinstall.rb +114 -0
- data/lib/vagrant-sakura/action/run_instance.rb +18 -2
- data/lib/vagrant-sakura/action.rb +24 -0
- data/lib/vagrant-sakura/{command.rb → command_list_id.rb} +1 -1
- data/lib/vagrant-sakura/command_reinstall.rb +16 -0
- data/lib/vagrant-sakura/config.rb +121 -5
- data/lib/vagrant-sakura/driver/api.rb +3 -2
- data/lib/vagrant-sakura/os_type.rb +34 -0
- data/lib/vagrant-sakura/plugin.rb +7 -2
- data/lib/vagrant-sakura/version.rb +1 -1
- data/locales/en.yml +4 -0
- data/test/test_config.rb +180 -14
- data/test/test_usacloud_config.rb +164 -0
- metadata +18 -4
@@ -0,0 +1,164 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require "vagrant-sakura/config"
|
3
|
+
require 'tmpdir'
|
4
|
+
require 'fileutils'
|
5
|
+
|
6
|
+
module VagrantPlugins
|
7
|
+
module Sakura
|
8
|
+
class TestUsacloudConfig < Test::Unit::TestCase
|
9
|
+
def setup
|
10
|
+
%w(SAKURACLOUD_ACCESS_TOKEN SAKURACLOUD_ACCESS_TOKEN_SECRET SAKURACLOUD_ZONE USACLOUD_PROFILE_DIR).map do |k|
|
11
|
+
ENV.delete(k)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_choose_profile_dir
|
16
|
+
cases = {
|
17
|
+
"USACLOUD_PROFILE_DIR is empty" => {
|
18
|
+
"env" => {"USACLOUD_PROFILE_DIR" => ""},
|
19
|
+
"expect" => File.expand_path("~/.usacloud")
|
20
|
+
},
|
21
|
+
"USACLOUD_PROFILE_DIR is set" => {
|
22
|
+
"env" => {"USACLOUD_PROFILE_DIR" => "/tmp"},
|
23
|
+
"expect" => "/tmp/.usacloud"
|
24
|
+
}
|
25
|
+
}
|
26
|
+
|
27
|
+
cases.map {|name, c|
|
28
|
+
conf = Config.new
|
29
|
+
ENV.update c["env"]
|
30
|
+
|
31
|
+
assert_equal c["expect"], conf.choose_usacloud_profile_dir
|
32
|
+
}
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_get_current_profile_name
|
37
|
+
cases = {
|
38
|
+
"current file is missing" => {
|
39
|
+
"prepare" => false,
|
40
|
+
"expect" => "default"
|
41
|
+
},
|
42
|
+
"current file is empty" => {
|
43
|
+
"prepare" => true,
|
44
|
+
"profile" => "",
|
45
|
+
"expect" => "default"
|
46
|
+
},
|
47
|
+
"current file has valid value" => {
|
48
|
+
"prepare" => true,
|
49
|
+
"profile" => "test",
|
50
|
+
"expect" => "test"
|
51
|
+
},
|
52
|
+
}
|
53
|
+
|
54
|
+
|
55
|
+
Dir.mktmpdir do |dir|
|
56
|
+
env = { "USACLOUD_PROFILE_DIR" => dir }
|
57
|
+
ENV.update env
|
58
|
+
|
59
|
+
cases.map {|name, c|
|
60
|
+
conf = Config.new
|
61
|
+
if c["prepare"]
|
62
|
+
file_path = File.join(dir, ".usacloud", "current")
|
63
|
+
FileUtils.mkdir_p(File.dirname(file_path))
|
64
|
+
File.open(file_path, "w") do |file|
|
65
|
+
file.puts c["profile"]
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
assert_equal c["expect"], conf.get_usacloud_profile_name
|
70
|
+
}
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_get_usacloud_config
|
76
|
+
cases = {
|
77
|
+
"profile is missing" => {
|
78
|
+
"profile_body" => nil,
|
79
|
+
"expect" => nil
|
80
|
+
},
|
81
|
+
"profile is invalid JSON" => {
|
82
|
+
"profile_body" => "Invalid JSON",
|
83
|
+
"expect" => nil
|
84
|
+
},
|
85
|
+
"profile has valid value" => {
|
86
|
+
"profile_body" => '{"AccessToken": "token", "AccessTokenSecret": "secret", "Zone": "zone"}',
|
87
|
+
"expect" => {
|
88
|
+
"AccessToken" => "token",
|
89
|
+
"AccessTokenSecret" => "secret",
|
90
|
+
"Zone" => "zone",
|
91
|
+
}
|
92
|
+
},
|
93
|
+
}
|
94
|
+
|
95
|
+
|
96
|
+
Dir.mktmpdir do |dir|
|
97
|
+
env = { "USACLOUD_PROFILE_DIR" => dir }
|
98
|
+
ENV.update env
|
99
|
+
|
100
|
+
cases.map do |name, c|
|
101
|
+
conf = Config.new
|
102
|
+
|
103
|
+
current_file = File.join(dir, ".usacloud", "current")
|
104
|
+
FileUtils.mkdir_p(File.dirname(current_file))
|
105
|
+
File.open(current_file, "w") do |file|
|
106
|
+
file.puts "default"
|
107
|
+
end
|
108
|
+
|
109
|
+
if !c["profile_body"].nil?
|
110
|
+
profile_file = File.join(dir, ".usacloud", "default", "config.json")
|
111
|
+
FileUtils.mkdir_p(File.dirname(profile_file))
|
112
|
+
File.open(profile_file, "w") do |file|
|
113
|
+
file.puts c["profile_body"]
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
assert_equal c["expect"], conf.get_usacloud_config
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
|
123
|
+
def test_get_usacloud_config_with_path
|
124
|
+
cases = {
|
125
|
+
"config_path is invalid" => {
|
126
|
+
"expect" => nil
|
127
|
+
},
|
128
|
+
"config_path is valid " => {
|
129
|
+
"profile_body" => '{"AccessToken": "token", "AccessTokenSecret": "secret", "Zone": "zone"}',
|
130
|
+
"expect" => {
|
131
|
+
"AccessToken" => "token",
|
132
|
+
"AccessTokenSecret" => "secret",
|
133
|
+
"Zone" => "zone",
|
134
|
+
}
|
135
|
+
},
|
136
|
+
}
|
137
|
+
|
138
|
+
|
139
|
+
Dir.mktmpdir do |dir|
|
140
|
+
|
141
|
+
cases.map do |name, c|
|
142
|
+
conf = Config.new
|
143
|
+
current_file = File.join(dir, ".usacloud", "current")
|
144
|
+
profile_file = File.join(dir, ".usacloud", "default", "config.json")
|
145
|
+
|
146
|
+
FileUtils.mkdir_p(File.dirname(current_file))
|
147
|
+
File.open(current_file, "w") do |file|
|
148
|
+
file.puts "default"
|
149
|
+
end
|
150
|
+
|
151
|
+
if !c["profile_body"].nil?
|
152
|
+
FileUtils.mkdir_p(File.dirname(profile_file))
|
153
|
+
File.open(profile_file, "w") do |file|
|
154
|
+
file.puts c["profile_body"]
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
assert_equal c["expect"], conf.get_usacloud_config(profile_file)
|
159
|
+
end
|
160
|
+
end
|
161
|
+
end
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-sakura
|
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
|
- Tomoyuki Sahara
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2018-
|
12
|
+
date: 2018-09-10 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Enables Vagrant to manage machines in Sakura Cloud.
|
15
15
|
email:
|
@@ -19,6 +19,7 @@ extensions: []
|
|
19
19
|
extra_rdoc_files: []
|
20
20
|
files:
|
21
21
|
- ".gitignore"
|
22
|
+
- ".travis.yml"
|
22
23
|
- CHANGELOG.md
|
23
24
|
- Gemfile
|
24
25
|
- LICENSE-vagrant-aws.txt
|
@@ -28,8 +29,16 @@ files:
|
|
28
29
|
- dummy.box
|
29
30
|
- example_box/Vagrantfile
|
30
31
|
- example_box/metadata.json
|
32
|
+
- examples/centos.md
|
33
|
+
- examples/centos6.md
|
34
|
+
- examples/coreos.md
|
35
|
+
- examples/debian.md
|
36
|
+
- examples/freebsd.md
|
37
|
+
- examples/rancheros.md
|
38
|
+
- examples/ubuntu.md
|
31
39
|
- lib/vagrant-sakura.rb
|
32
40
|
- lib/vagrant-sakura/action.rb
|
41
|
+
- lib/vagrant-sakura/action/complete_archive_id.rb
|
33
42
|
- lib/vagrant-sakura/action/connect_sakura.rb
|
34
43
|
- lib/vagrant-sakura/action/delete_server.rb
|
35
44
|
- lib/vagrant-sakura/action/halt.rb
|
@@ -42,19 +51,23 @@ files:
|
|
42
51
|
- lib/vagrant-sakura/action/power_on.rb
|
43
52
|
- lib/vagrant-sakura/action/read_ssh_info.rb
|
44
53
|
- lib/vagrant-sakura/action/read_state.rb
|
54
|
+
- lib/vagrant-sakura/action/reinstall.rb
|
45
55
|
- lib/vagrant-sakura/action/reset.rb
|
46
56
|
- lib/vagrant-sakura/action/run_instance.rb
|
47
57
|
- lib/vagrant-sakura/action/sync_folders.rb
|
48
|
-
- lib/vagrant-sakura/
|
58
|
+
- lib/vagrant-sakura/command_list_id.rb
|
59
|
+
- lib/vagrant-sakura/command_reinstall.rb
|
49
60
|
- lib/vagrant-sakura/config.rb
|
50
61
|
- lib/vagrant-sakura/driver/api.rb
|
51
62
|
- lib/vagrant-sakura/driver/cert.pem
|
52
63
|
- lib/vagrant-sakura/errors.rb
|
64
|
+
- lib/vagrant-sakura/os_type.rb
|
53
65
|
- lib/vagrant-sakura/plugin.rb
|
54
66
|
- lib/vagrant-sakura/provider.rb
|
55
67
|
- lib/vagrant-sakura/version.rb
|
56
68
|
- locales/en.yml
|
57
69
|
- test/test_config.rb
|
70
|
+
- test/test_usacloud_config.rb
|
58
71
|
- vagrant-sakura.gemspec
|
59
72
|
homepage: https://github.com/sacloud/vagrant-sakura
|
60
73
|
licenses:
|
@@ -76,9 +89,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
76
89
|
version: '0'
|
77
90
|
requirements: []
|
78
91
|
rubyforge_project:
|
79
|
-
rubygems_version: 2.
|
92
|
+
rubygems_version: 2.7.7
|
80
93
|
signing_key:
|
81
94
|
specification_version: 4
|
82
95
|
summary: Enables Vagrant to manage machines in Sakura Cloud.
|
83
96
|
test_files:
|
84
97
|
- test/test_config.rb
|
98
|
+
- test/test_usacloud_config.rb
|