turbot 0.1.36 → 0.2.3

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.
Files changed (103) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +8 -0
  3. data/.rspec +3 -0
  4. data/.travis.yml +15 -0
  5. data/.yardopts +3 -0
  6. data/Gemfile +4 -0
  7. data/LICENSE +22 -0
  8. data/README.md +44 -25
  9. data/Rakefile +16 -0
  10. data/appveyor.yml +35 -0
  11. data/bin/turbot +2 -16
  12. data/data/schema.json +134 -0
  13. data/{templates → data/templates}/LICENSE.txt +0 -0
  14. data/{templates → data/templates}/manifest.json +0 -0
  15. data/{templates → data/templates}/python/scraper.py +0 -0
  16. data/{templates → data/templates}/ruby/scraper.rb +0 -0
  17. data/dist/deb.rake +32 -0
  18. data/dist/gem.rake +16 -0
  19. data/dist/manifest.rake +9 -0
  20. data/dist/pkg.rake +60 -0
  21. data/dist/resources/deb/control +10 -0
  22. data/dist/resources/deb/postinst +45 -0
  23. data/dist/resources/deb/turbot +25 -0
  24. data/dist/resources/deb/turbot-release-key.txt +30 -0
  25. data/dist/resources/pkg/Distribution.erb +15 -0
  26. data/dist/resources/pkg/PackageInfo.erb +6 -0
  27. data/dist/resources/pkg/postinstall +45 -0
  28. data/dist/resources/pkg/turbot +24 -0
  29. data/dist/resources/tgz/turbot +24 -0
  30. data/dist/rpm.rake +35 -0
  31. data/dist/tgz.rake +26 -0
  32. data/dist/zip.rake +40 -0
  33. data/lib/turbot.rb +18 -15
  34. data/lib/turbot/cli.rb +10 -27
  35. data/lib/turbot/command.rb +59 -212
  36. data/lib/turbot/command/auth.rb +72 -34
  37. data/lib/turbot/command/base.rb +22 -61
  38. data/lib/turbot/command/bots.rb +251 -300
  39. data/lib/turbot/command/help.rb +57 -110
  40. data/lib/turbot/command/version.rb +6 -10
  41. data/lib/turbot/handlers/base_handler.rb +21 -0
  42. data/lib/turbot/handlers/dump_handler.rb +10 -0
  43. data/lib/turbot/handlers/preview_handler.rb +30 -0
  44. data/lib/turbot/handlers/validation_handler.rb +17 -0
  45. data/lib/turbot/helpers.rb +14 -482
  46. data/lib/turbot/helpers/api_helper.rb +41 -0
  47. data/lib/turbot/helpers/netrc_helper.rb +66 -0
  48. data/lib/turbot/helpers/shell_helper.rb +36 -0
  49. data/lib/turbot/version.rb +1 -1
  50. data/spec/fixtures/bad_permissions +0 -0
  51. data/spec/fixtures/empty +0 -0
  52. data/spec/fixtures/netrc +6 -0
  53. data/spec/spec_helper.rb +17 -219
  54. data/spec/support/bot_helper.rb +102 -0
  55. data/spec/support/command_helper.rb +20 -0
  56. data/spec/support/custom_matchers.rb +5 -0
  57. data/spec/support/fixture_helper.rb +9 -0
  58. data/spec/support/netrc_helper.rb +21 -0
  59. data/spec/turbot/command/auth_spec.rb +202 -20
  60. data/spec/turbot/command/base_spec.rb +22 -58
  61. data/spec/turbot/command/bots_spec.rb +580 -89
  62. data/spec/turbot/command/help_spec.rb +32 -75
  63. data/spec/turbot/command/version_spec.rb +11 -10
  64. data/spec/turbot/command_spec.rb +55 -87
  65. data/spec/turbot/helpers_spec.rb +28 -44
  66. data/turbot.gemspec +31 -0
  67. metadata +88 -178
  68. data/data/cacert.pem +0 -3988
  69. data/lib/turbot/auth.rb +0 -315
  70. data/lib/turbot/client.rb +0 -757
  71. data/lib/turbot/client/cisaurus.rb +0 -25
  72. data/lib/turbot/client/pgbackups.rb +0 -113
  73. data/lib/turbot/client/rendezvous.rb +0 -111
  74. data/lib/turbot/client/ssl_endpoint.rb +0 -25
  75. data/lib/turbot/client/turbot_postgresql.rb +0 -148
  76. data/lib/turbot/command/ssl.rb +0 -43
  77. data/lib/turbot/deprecated.rb +0 -5
  78. data/lib/turbot/deprecated/help.rb +0 -38
  79. data/lib/turbot/distribution.rb +0 -9
  80. data/lib/turbot/errors.rb +0 -28
  81. data/lib/turbot/excon.rb +0 -11
  82. data/lib/turbot/helpers/log_displayer.rb +0 -70
  83. data/lib/turbot/helpers/pg_dump_restore.rb +0 -115
  84. data/lib/turbot/helpers/turbot_postgresql.rb +0 -213
  85. data/lib/turbot/plugin.rb +0 -165
  86. data/lib/turbot/updater.rb +0 -171
  87. data/lib/vendor/turbot/okjson.rb +0 -598
  88. data/spec/helper/legacy_help.rb +0 -16
  89. data/spec/helper/pg_dump_restore_spec.rb +0 -67
  90. data/spec/spec.opts +0 -1
  91. data/spec/support/display_message_matcher.rb +0 -49
  92. data/spec/support/dummy_api.rb +0 -120
  93. data/spec/support/openssl_mock_helper.rb +0 -8
  94. data/spec/support/organizations_mock_helper.rb +0 -11
  95. data/spec/turbot/auth_spec.rb +0 -214
  96. data/spec/turbot/client/pgbackups_spec.rb +0 -43
  97. data/spec/turbot/client/rendezvous_spec.rb +0 -62
  98. data/spec/turbot/client/ssl_endpoint_spec.rb +0 -48
  99. data/spec/turbot/client/turbot_postgresql_spec.rb +0 -71
  100. data/spec/turbot/client_spec.rb +0 -548
  101. data/spec/turbot/helpers/turbot_postgresql_spec.rb +0 -181
  102. data/spec/turbot/plugin_spec.rb +0 -172
  103. data/spec/turbot/updater_spec.rb +0 -44
@@ -1,181 +0,0 @@
1
- require "spec_helper"
2
- require "turbot/helpers/turbot_postgresql"
3
-
4
- include Turbot::Helpers::TurbotPostgresql
5
-
6
- describe Turbot::Helpers::TurbotPostgresql::Resolver do
7
-
8
- before do
9
- @resolver = described_class.new('appname', mock(:api))
10
- @resolver.stub(:bot_config_vars) { bot_config_vars }
11
- @resolver.stub(:bot_attachments) { bot_attachments }
12
- end
13
-
14
- let(:bot_config_vars) do
15
- {
16
- "DATABASE_URL" => "postgres://default",
17
- "TURBOT_POSTGRESQL_BLACK_URL" => "postgres://black",
18
- "TURBOT_POSTGRESQL_IVORY_URL" => "postgres://default"
19
- }
20
- end
21
-
22
- let(:bot_attachments) {
23
- [ Attachment.new({ 'name' => 'TURBOT_POSTGRESQL_IVORY',
24
- 'config_var' => 'TURBOT_POSTGRESQL_IVORY_URL',
25
- 'bot' => {'name' => 'sushi' },
26
- 'resource' => {'name' => 'softly-mocking-123',
27
- 'value' => 'postgres://default',
28
- 'type' => 'turbot-postgresql:baku' }}),
29
- Attachment.new({ 'name' => 'TURBOT_POSTGRESQL_BLACK',
30
- 'config_var' => 'TURBOT_POSTGRESQL_BLACK_URL',
31
- 'bot' => {'name' => 'sushi' },
32
- 'resource' => {'name' => 'quickly-yelling-2421',
33
- 'value' => 'postgres://black',
34
- 'type' => 'turbot-postgresql:zilla' }})
35
- ]
36
- }
37
-
38
- context "when the DATABASE_URL has query options" do
39
- let(:bot_config_vars) do
40
- {
41
- "DATABASE_URL" => "postgres://default?pool=15",
42
- "TURBOT_POSTGRESQL_BLACK_URL" => "postgres://black",
43
- "TURBOT_POSTGRESQL_IVORY_URL" => "postgres://default",
44
- "SHARED_DATABASE_URL" => "postgres://shared"
45
- }
46
- end
47
-
48
- it "resolves DATABASE" do
49
- att = @resolver.resolve('DATABASE')
50
- att.display_name.should == "TURBOT_POSTGRESQL_IVORY_URL (DATABASE_URL)"
51
- att.url.should == "postgres://default"
52
- end
53
- end
54
-
55
- context "when no bot is specified or inferred, and identifier does not have bot::db shorthand" do
56
- it 'exits, complaining about the missing bot' do
57
- api = mock('api')
58
- api.stub(:get_attachments).and_raise("getting this far will cause an inaccurate 'internal server error' message")
59
-
60
- no_bot_resolver = described_class.new(nil, api)
61
- no_bot_resolver.should_receive(:error).with { |msg| expect(msg).to match(/No bot specified/) }.and_raise(SystemExit)
62
- expect { no_bot_resolver.resolve('black') }.to raise_error(SystemExit)
63
- end
64
- end
65
-
66
- context "when the identifier has ::" do
67
- it 'changes the resolver bot to the left of the ::' do
68
- @resolver.bot_name.should == 'appname'
69
- att = @resolver.resolve('app2::black')
70
- @resolver.bot_name.should == 'app2'
71
- end
72
-
73
- it 'resolves database names on the right of the ::' do
74
- att = @resolver.resolve('app2::black')
75
- att.url.should == "postgres://black" # since we're mocking out the bot_config_vars
76
- end
77
-
78
- it 'looks allows nothing after the :: to use the default' do
79
- att = @resolver.resolve('app2::', 'DATABASE_URL')
80
- att.url.should == "postgres://default"
81
- end
82
- end
83
-
84
- context "when the DATABASE_URL has no query options" do
85
- let(:bot_config_vars) do
86
- {
87
- "DATABASE_URL" => "postgres://default",
88
- "TURBOT_POSTGRESQL_BLACK_URL" => "postgres://black",
89
- "TURBOT_POSTGRESQL_IVORY_URL" => "postgres://default",
90
- "SHARED_DATABASE_URL" => "postgres://shared"
91
- }
92
- end
93
-
94
- it "resolves DATABASE" do
95
- att = @resolver.resolve('DATABASE')
96
- att.display_name.should == "TURBOT_POSTGRESQL_IVORY_URL (DATABASE_URL)"
97
- att.url.should == "postgres://default"
98
- end
99
- end
100
-
101
- it "resolves default using NAME" do
102
- att = @resolver.resolve('IVORY')
103
- att.display_name.should == "TURBOT_POSTGRESQL_IVORY_URL (DATABASE_URL)"
104
- att.url.should == "postgres://default"
105
- end
106
-
107
- it "resolves non-default using NAME" do
108
- att = @resolver.resolve('BLACK')
109
- att.display_name.should == "TURBOT_POSTGRESQL_BLACK_URL"
110
- att.url.should == "postgres://black"
111
- end
112
-
113
- it "resolves default using NAME_URL" do
114
- att = @resolver.resolve('IVORY_URL')
115
- att.display_name.should == "TURBOT_POSTGRESQL_IVORY_URL (DATABASE_URL)"
116
- att.url.should == "postgres://default"
117
- end
118
-
119
- it "resolves non-default using NAME_URL" do
120
- att = @resolver.resolve('BLACK_URL')
121
- att.display_name.should == "TURBOT_POSTGRESQL_BLACK_URL"
122
- att.url.should == "postgres://black"
123
- end
124
-
125
- it "resolves default using lowercase" do
126
- att = @resolver.resolve('ivory')
127
- att.display_name.should == "TURBOT_POSTGRESQL_IVORY_URL (DATABASE_URL)"
128
- att.url.should == "postgres://default"
129
- end
130
-
131
- it "resolves non-default using lowercase" do
132
- att = @resolver.resolve('black')
133
- att.display_name.should == "TURBOT_POSTGRESQL_BLACK_URL"
134
- att.url.should == "postgres://black"
135
- end
136
-
137
- it "resolves non-default using part of name" do
138
- att = @resolver.resolve('bla')
139
- att.display_name.should == "TURBOT_POSTGRESQL_BLACK_URL"
140
- att.url.should == "postgres://black"
141
- end
142
-
143
- it "throws an error if it doesnt exist" do
144
- @resolver.should_receive(:error).with("Unknown database: violet. Valid options are: DATABASE_URL, TURBOT_POSTGRESQL_BLACK_URL, TURBOT_POSTGRESQL_IVORY_URL")
145
- @resolver.resolve("violet")
146
- end
147
-
148
- context "default" do
149
-
150
- it "errors if there is no default" do
151
- @resolver.should_receive(:error).with("Unknown database. Valid options are: DATABASE_URL, TURBOT_POSTGRESQL_BLACK_URL, TURBOT_POSTGRESQL_IVORY_URL")
152
- @resolver.resolve(nil)
153
- end
154
-
155
- it "uses the default if nothing(nil) specified" do
156
- att = @resolver.resolve(nil, "DATABASE_URL")
157
- att.display_name.should == "TURBOT_POSTGRESQL_IVORY_URL (DATABASE_URL)"
158
- att.url.should == "postgres://default"
159
- end
160
-
161
- it "uses the default if nothing(empty) specified" do
162
- att = @resolver.resolve('', "DATABASE_URL")
163
- att.display_name.should == "TURBOT_POSTGRESQL_IVORY_URL (DATABASE_URL)"
164
- att.url.should == "postgres://default"
165
- end
166
-
167
- it 'throws an error if given an empty string and asked for the default and there is no default' do
168
- bot_config_vars.delete 'DATABASE_URL'
169
- @resolver.should_receive(:error).with("Unknown database. Valid options are: TURBOT_POSTGRESQL_BLACK_URL, TURBOT_POSTGRESQL_IVORY_URL")
170
- att = @resolver.resolve('', "DATABASE_URL")
171
- end
172
-
173
- it 'throws an error if given an empty string and asked for the default and the default doesnt match' do
174
- bot_config_vars['DATABASE_URL'] = 'something different'
175
- @resolver.should_receive(:error).with("Unknown database. Valid options are: TURBOT_POSTGRESQL_BLACK_URL, TURBOT_POSTGRESQL_IVORY_URL")
176
- att = @resolver.resolve('', "DATABASE_URL")
177
- end
178
-
179
-
180
- end
181
- end
@@ -1,172 +0,0 @@
1
- require "spec_helper"
2
- require "turbot/plugin"
3
-
4
- module Turbot
5
- describe Plugin do
6
- include SandboxHelper
7
-
8
- it "lives in ~/.turbot/plugins" do
9
- Plugin.stub!(:home_directory).and_return('/home/user')
10
- Plugin.directory.should == '/home/user/.turbot/plugins'
11
- end
12
-
13
- it "extracts the name from git urls" do
14
- Plugin.new('git://github.com/turbot/plugin.git').name.should == 'plugin'
15
- end
16
-
17
- describe "management" do
18
- before(:each) do
19
- @sandbox = "/tmp/turbot_plugins_spec_#{Process.pid}"
20
- FileUtils.mkdir_p(@sandbox)
21
- Dir.stub!(:pwd).and_return(@sandbox)
22
- Plugin.stub!(:directory).and_return(@sandbox)
23
- end
24
-
25
- after(:each) do
26
- FileUtils.rm_rf(@sandbox)
27
- end
28
-
29
- it "lists installed plugins" do
30
- FileUtils.mkdir_p(@sandbox + '/plugin1')
31
- FileUtils.mkdir_p(@sandbox + '/plugin2')
32
- Plugin.list.should include 'plugin1'
33
- Plugin.list.should include 'plugin2'
34
- end
35
-
36
- it "installs pulling from the plugin url" do
37
- plugin_folder = "/tmp/turbot_plugin"
38
- FileUtils.mkdir_p(plugin_folder)
39
- `cd #{plugin_folder} && git init && echo 'test' > README && git add . && git commit -m 'my plugin'`
40
- Plugin.new(plugin_folder).install
41
- File.directory?("#{@sandbox}/turbot_plugin").should be_true
42
- File.read("#{@sandbox}/turbot_plugin/README").should == "test\n"
43
- end
44
-
45
- it "reinstalls over old copies" do
46
- plugin_folder = "/tmp/turbot_plugin"
47
- FileUtils.mkdir_p(plugin_folder)
48
- `cd #{plugin_folder} && git init && echo 'test' > README && git add . && git commit -m 'my plugin'`
49
- Plugin.new(plugin_folder).install
50
- Plugin.new(plugin_folder).install
51
- File.directory?("#{@sandbox}/turbot_plugin").should be_true
52
- File.read("#{@sandbox}/turbot_plugin/README").should == "test\n"
53
- end
54
-
55
- context "update" do
56
-
57
- before(:each) do
58
- plugin_folder = "/tmp/turbot_plugin"
59
- FileUtils.mkdir_p(plugin_folder)
60
- `cd #{plugin_folder} && git init && echo 'test' > README && git add . && git commit -m 'my plugin'`
61
- Plugin.new(plugin_folder).install
62
- `cd #{plugin_folder} && echo 'updated' > README && git add . && git commit -m 'my plugin update'`
63
- end
64
-
65
- it "updates existing copies" do
66
- Plugin.new('turbot_plugin').update
67
- File.directory?("#{@sandbox}/turbot_plugin").should be_true
68
- File.read("#{@sandbox}/turbot_plugin/README").should == "updated\n"
69
- end
70
-
71
- it "warns on legacy plugins" do
72
- `cd #{@sandbox}/turbot_plugin && git config --unset branch.master.remote`
73
- stderr = capture_stderr do
74
- begin
75
- Plugin.new('turbot_plugin').update
76
- rescue SystemExit
77
- end
78
- end
79
- stderr.should == <<-STDERR
80
- ! turbot_plugin is a legacy plugin installation.
81
- ! Enable updating by reinstalling with `turbot plugins:install`.
82
- STDERR
83
- end
84
-
85
- it "raises exception on symlinked plugins" do
86
- `cd #{@sandbox} && ln -s turbot_plugin turbot_plugin_symlink`
87
- lambda { Plugin.new('turbot_plugin_symlink').update }.should raise_error Turbot::Plugin::ErrorUpdatingSymlinkPlugin
88
- end
89
-
90
- end
91
-
92
-
93
- it "uninstalls removing the folder" do
94
- FileUtils.mkdir_p(@sandbox + '/plugin1')
95
- Plugin.new('git://github.com/turbot/plugin1.git').uninstall
96
- Plugin.list.should == []
97
- end
98
-
99
- it "adds the lib folder in the plugin to the load path, if present" do
100
- FileUtils.mkdir_p(@sandbox + '/plugin/lib')
101
- File.open(@sandbox + '/plugin/lib/my_custom_plugin_file.rb', 'w') { |f| f.write "" }
102
- Plugin.load!
103
- lambda { require 'my_custom_plugin_file' }.should_not raise_error(LoadError)
104
- end
105
-
106
- it "loads init.rb, if present" do
107
- FileUtils.mkdir_p(@sandbox + '/plugin')
108
- File.open(@sandbox + '/plugin/init.rb', 'w') { |f| f.write "LoadedInit = true" }
109
- Plugin.load!
110
- LoadedInit.should be_true
111
- end
112
-
113
- describe "when there are plugin load errors" do
114
- before(:each) do
115
- FileUtils.mkdir_p(@sandbox + '/some_plugin/lib')
116
- File.open(@sandbox + '/some_plugin/init.rb', 'w') { |f| f.write "require 'some_non_existant_file'" }
117
- end
118
-
119
- it "should not throw an error" do
120
- capture_stderr do
121
- lambda { Plugin.load! }.should_not raise_error
122
- end
123
- end
124
-
125
- it "should fail gracefully" do
126
- stderr = capture_stderr do
127
- Plugin.load!
128
- end
129
- stderr.should include('some_non_existant_file (LoadError)')
130
- end
131
-
132
- it "should still load other plugins" do
133
- FileUtils.mkdir_p(@sandbox + '/some_plugin_2/lib')
134
- File.open(@sandbox + '/some_plugin_2/init.rb', 'w') { |f| f.write "LoadedPlugin2 = true" }
135
- stderr = capture_stderr do
136
- Plugin.load!
137
- end
138
- stderr.should include('some_non_existant_file (LoadError)')
139
- LoadedPlugin2.should be_true
140
- end
141
- end
142
-
143
- describe "deprecated plugins" do
144
- before(:each) do
145
- FileUtils.mkdir_p(@sandbox + '/turbot-releases/lib')
146
- end
147
-
148
- after(:each) do
149
- FileUtils.rm_rf(@sandbox + '/turbot-releases/lib')
150
- end
151
-
152
- it "should show confirmation to remove deprecated plugins if in an interactive shell" do
153
- old_stdin_isatty = STDIN.isatty
154
- STDIN.stub!(:isatty).and_return(true)
155
- Plugin.should_receive(:confirm).with("The plugin turbot-releases has been deprecated. Would you like to remove it? (y/N)").and_return(true)
156
- Plugin.should_receive(:remove_plugin).with("turbot-releases")
157
- Plugin.load!
158
- STDIN.stub!(:isatty).and_return(old_stdin_isatty)
159
- end
160
-
161
- it "should not prompt for deprecation if not in an interactive shell" do
162
- old_stdin_isatty = STDIN.isatty
163
- STDIN.stub!(:isatty).and_return(false)
164
- Plugin.should_not_receive(:confirm)
165
- Plugin.should_not_receive(:remove_plugin).with("turbot-releases")
166
- Plugin.load!
167
- STDIN.stub!(:isatty).and_return(old_stdin_isatty)
168
- end
169
- end
170
- end
171
- end
172
- end
@@ -1,44 +0,0 @@
1
- require "spec_helper"
2
- require "turbot/updater"
3
- require "turbot/version"
4
-
5
- module Turbot
6
- describe Updater do
7
-
8
- it "calculates the latest local version" do
9
- Turbot::Updater.latest_local_version.should == Turbot::VERSION
10
- end
11
-
12
- it "calculates compare_versions" do
13
- Turbot::Updater.compare_versions('1.1.1', '1.1.1').should == 0
14
-
15
- Turbot::Updater.compare_versions('2.1.1', '1.1.1').should == 1
16
- Turbot::Updater.compare_versions('1.1.1', '2.1.1').should == -1
17
-
18
- Turbot::Updater.compare_versions('1.2.1', '1.1.1').should == 1
19
- Turbot::Updater.compare_versions('1.1.1', '1.2.1').should == -1
20
-
21
- Turbot::Updater.compare_versions('1.1.2', '1.1.1').should == 1
22
- Turbot::Updater.compare_versions('1.1.1', '1.1.2').should == -1
23
-
24
- Turbot::Updater.compare_versions('2.1.1', '1.2.1').should == 1
25
- Turbot::Updater.compare_versions('1.2.1', '2.1.1').should == -1
26
-
27
- Turbot::Updater.compare_versions('2.1.1', '1.1.2').should == 1
28
- Turbot::Updater.compare_versions('1.1.2', '2.1.1').should == -1
29
-
30
- Turbot::Updater.compare_versions('1.2.4', '1.2.3').should == 1
31
- Turbot::Updater.compare_versions('1.2.3', '1.2.4').should == -1
32
-
33
- Turbot::Updater.compare_versions('1.2.1', '1.2' ).should == 1
34
- Turbot::Updater.compare_versions('1.2', '1.2.1').should == -1
35
-
36
- Turbot::Updater.compare_versions('1.1.1.pre1', '1.1.1').should == 1
37
- Turbot::Updater.compare_versions('1.1.1', '1.1.1.pre1').should == -1
38
-
39
- Turbot::Updater.compare_versions('1.1.1.pre2', '1.1.1.pre1').should == 1
40
- Turbot::Updater.compare_versions('1.1.1.pre1', '1.1.1.pre2').should == -1
41
- end
42
-
43
- end
44
- end