cookbook-client 0.1.0 → 0.5.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.
@@ -0,0 +1,7 @@
1
+ == Cookbook Client, a.k.a. Spoon
2
+
3
+ Spoon provides a command-line driven interface to the Opscode Cookbook Community Site, at
4
+ cookbooks.opscode.com. The command-line is driven by Chef::CookbookClient, an implementation
5
+ of the REST client API against the community site.
6
+
7
+ Run 'spoon' for help with the tool.
data/Rakefile CHANGED
@@ -7,11 +7,12 @@ begin
7
7
  gem.name = "cookbook-client"
8
8
  gem.summary = "A command-line tool for interacting with the Cookbook Community Site, cookbooks.opscode.com"
9
9
  gem.email = "info@opscode.com"
10
- gem.homepage = "http://www.opscode.com"
10
+ gem.homepage = "http://cookbooks.opscode.com"
11
11
  gem.authors = ["Opscode, Inc."]
12
12
  gem.bindir = "bin"
13
13
  gem.executables = %w(spoon)
14
14
  gem.add_dependency 'mixlib-authentication'
15
+ gem.add_dependency 'opscode-rest'
15
16
  end
16
17
  rescue LoadError
17
18
  puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.5.0
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{cookbook-client}
8
- s.version = "0.1.0"
8
+ s.version = "0.5.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Opscode, Inc."]
@@ -13,8 +13,12 @@ Gem::Specification.new do |s|
13
13
  s.default_executable = %q{spoon}
14
14
  s.email = %q{info@opscode.com}
15
15
  s.executables = ["spoon"]
16
+ s.extra_rdoc_files = [
17
+ "README.rdoc"
18
+ ]
16
19
  s.files = [
17
20
  "NOTICE",
21
+ "README.rdoc",
18
22
  "Rakefile",
19
23
  "VERSION",
20
24
  "bin/spoon",
@@ -26,7 +30,7 @@ Gem::Specification.new do |s|
26
30
  "spec/spec_helper.rb",
27
31
  "spec/spoon/spoon_spec.rb"
28
32
  ]
29
- s.homepage = %q{http://www.opscode.com}
33
+ s.homepage = %q{http://cookbooks.opscode.com}
30
34
  s.rdoc_options = ["--charset=UTF-8"]
31
35
  s.require_paths = ["lib"]
32
36
  s.rubygems_version = %q{1.3.5}
@@ -34,24 +38,6 @@ Gem::Specification.new do |s|
34
38
  s.test_files = [
35
39
  "spec/spec_helper.rb",
36
40
  "spec/spoon/spoon_spec.rb",
37
- "examples/couchdb/metadata.rb",
38
- "examples/couchdb/recipes/default.rb",
39
- "examples/couchdb2/metadata.rb",
40
- "examples/couchdb2/recipes/default.rb",
41
- "examples/couchdb3/metadata.rb",
42
- "examples/couchdb3/recipes/default.rb",
43
- "examples/couchdb4/metadata.rb",
44
- "examples/couchdb4/recipes/default.rb",
45
- "examples/couchdb5/metadata.rb",
46
- "examples/couchdb5/recipes/default.rb",
47
- "examples/rest-delete.rb",
48
- "examples/test-auth-against-erlang.rb",
49
- "examples/test-hash-find.rb",
50
- "examples/test-ssl.rb",
51
- "examples/test-using-restclient-multipart.rb",
52
- "examples/test_signature_verification.rb",
53
- "examples/testrestoc.rb",
54
- "examples/upload-using-cw_multipart.rb"
55
41
  ]
56
42
 
57
43
  if s.respond_to? :specification_version then
@@ -60,10 +46,13 @@ Gem::Specification.new do |s|
60
46
 
61
47
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
62
48
  s.add_runtime_dependency(%q<mixlib-authentication>, [">= 0"])
49
+ s.add_runtime_dependency(%q<opscode-rest>, [">= 0"])
63
50
  else
64
51
  s.add_dependency(%q<mixlib-authentication>, [">= 0"])
52
+ s.add_dependency(%q<opscode-rest>, [">= 0"])
65
53
  end
66
54
  else
67
55
  s.add_dependency(%q<mixlib-authentication>, [">= 0"])
56
+ s.add_dependency(%q<opscode-rest>, [">= 0"])
68
57
  end
69
58
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cookbook-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Opscode, Inc.
@@ -22,16 +22,27 @@ dependencies:
22
22
  - !ruby/object:Gem::Version
23
23
  version: "0"
24
24
  version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: opscode-rest
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: "0"
34
+ version:
25
35
  description:
26
36
  email: info@opscode.com
27
37
  executables:
28
38
  - spoon
29
39
  extensions: []
30
40
 
31
- extra_rdoc_files: []
32
-
41
+ extra_rdoc_files:
42
+ - README.rdoc
33
43
  files:
34
44
  - NOTICE
45
+ - README.rdoc
35
46
  - Rakefile
36
47
  - VERSION
37
48
  - bin/spoon
@@ -43,7 +54,7 @@ files:
43
54
  - spec/spec_helper.rb
44
55
  - spec/spoon/spoon_spec.rb
45
56
  has_rdoc: true
46
- homepage: http://www.opscode.com
57
+ homepage: http://cookbooks.opscode.com
47
58
  licenses: []
48
59
 
49
60
  post_install_message:
@@ -73,21 +84,3 @@ summary: A command-line tool for interacting with the Cookbook Community Site, c
73
84
  test_files:
74
85
  - spec/spec_helper.rb
75
86
  - spec/spoon/spoon_spec.rb
76
- - examples/couchdb/metadata.rb
77
- - examples/couchdb/recipes/default.rb
78
- - examples/couchdb2/metadata.rb
79
- - examples/couchdb2/recipes/default.rb
80
- - examples/couchdb3/metadata.rb
81
- - examples/couchdb3/recipes/default.rb
82
- - examples/couchdb4/metadata.rb
83
- - examples/couchdb4/recipes/default.rb
84
- - examples/couchdb5/metadata.rb
85
- - examples/couchdb5/recipes/default.rb
86
- - examples/rest-delete.rb
87
- - examples/test-auth-against-erlang.rb
88
- - examples/test-hash-find.rb
89
- - examples/test-ssl.rb
90
- - examples/test-using-restclient-multipart.rb
91
- - examples/test_signature_verification.rb
92
- - examples/testrestoc.rb
93
- - examples/upload-using-cw_multipart.rb
@@ -1,16 +0,0 @@
1
- maintainer "Opscode, Inc."
2
- maintainer_email "cookbooks@opscode.com"
3
- license "Apache 2.0"
4
- description "Installs CouchDB package and starts service"
5
- long_description <<-EOH
6
- Installs the CouchDB package if it is available from an package repository on
7
- the node. If the package repository is not available, CouchDB needs to be
8
- installed via some other method, either a backported package, or compiled
9
- directly from source.
10
- EOH
11
- version "0.7"
12
- supports "ubuntu", ">= 8.10" # for package in APT
13
-
14
- %w{ rhel centos fedora }.each do |os|
15
- supports os # requires that CouchDB package is available in yum repositories
16
- end
@@ -1,35 +0,0 @@
1
- #
2
- # Author:: Joshua Timberman <joshua@opscode.com>
3
- # Cookbook Name:: couchdb
4
- # Recipe:: default
5
- #
6
- # Copyright 2008, OpsCode, Inc
7
- #
8
- # Licensed under the Apache License, Version 2.0 (the "License");
9
- # you may not use this file except in compliance with the License.
10
- # You may obtain a copy of the License at
11
- #
12
- # http://www.apache.org/licenses/LICENSE-2.0
13
- #
14
- # Unless required by applicable law or agreed to in writing, software
15
- # distributed under the License is distributed on an "AS IS" BASIS,
16
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
- # See the License for the specific language governing permissions and
18
- # limitations under the License.
19
-
20
- package "couchdb"
21
-
22
- directory "/var/lib/couchdb" do
23
- owner "couchdb"
24
- group "couchdb"
25
- recursive true
26
- end
27
-
28
- service "couchdb" do
29
- if platform?("centos","redhat","fedora")
30
- start_command "/sbin/service couchdb start &> /dev/null"
31
- stop_command "/sbin/service couchdb stop &> /dev/null"
32
- end
33
- supports [ :restart, :status ]
34
- action [ :enable, :start ]
35
- end
@@ -1,16 +0,0 @@
1
- maintainer "Opscode, Inc."
2
- maintainer_email "cookbooks@opscode.com"
3
- license "Apache 2.0"
4
- description "Installs CouchDB package and starts service"
5
- long_description <<-EOH
6
- Installs the CouchDB package if it is available from an package repository on
7
- the node. If the package repository is not available, CouchDB needs to be
8
- installed via some other method, either a backported package, or compiled
9
- directly from source.
10
- EOH
11
- version "0.7.7"
12
- supports "ubuntu", ">= 8.10" # for package in APT
13
-
14
- %w{ rhel centos fedora }.each do |os|
15
- supports os # requires that CouchDB package is available in yum repositories
16
- end
@@ -1,35 +0,0 @@
1
- #
2
- # Author:: Joshua Timberman <joshua@opscode.com>
3
- # Cookbook Name:: couchdb
4
- # Recipe:: default
5
- #
6
- # Copyright 2008, OpsCode, Inc
7
- #
8
- # Licensed under the Apache License, Version 2.0 (the "License");
9
- # you may not use this file except in compliance with the License.
10
- # You may obtain a copy of the License at
11
- #
12
- # http://www.apache.org/licenses/LICENSE-2.0
13
- #
14
- # Unless required by applicable law or agreed to in writing, software
15
- # distributed under the License is distributed on an "AS IS" BASIS,
16
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
- # See the License for the specific language governing permissions and
18
- # limitations under the License.
19
-
20
- package "couchdb"
21
-
22
- directory "/var/lib/couchdb" do
23
- owner "couchdb"
24
- group "couchdb"
25
- recursive true
26
- end
27
-
28
- service "couchdb" do
29
- if platform?("centos","redhat","fedora")
30
- start_command "/sbin/service couchdb start &> /dev/null"
31
- stop_command "/sbin/service couchdb stop &> /dev/null"
32
- end
33
- supports [ :restart, :status ]
34
- action [ :enable, :start ]
35
- end
@@ -1,16 +0,0 @@
1
- maintainer "Opscode, Inc."
2
- maintainer_email "cookbooks@opscode.com"
3
- license "Apache 2.0"
4
- description "Installs CouchDB package and starts service"
5
- long_description <<-EOH
6
- Installs the CouchDB package if it is available from an package repository on
7
- the node. If the package repository is not available, CouchDB needs to be
8
- installed via some other method, either a backported package, or compiled
9
- directly from source.
10
- EOH
11
- version "0.7.7"
12
- supports "ubuntu", ">= 8.10" # for package in APT
13
-
14
- %w{ rhel centos fedora }.each do |os|
15
- supports os # requires that CouchDB package is available in yum repositories
16
- end
@@ -1,35 +0,0 @@
1
- #
2
- # Author:: Joshua Timberman <joshua@opscode.com>
3
- # Cookbook Name:: couchdb
4
- # Recipe:: default
5
- #
6
- # Copyright 2008, OpsCode, Inc
7
- #
8
- # Licensed under the Apache License, Version 2.0 (the "License");
9
- # you may not use this file except in compliance with the License.
10
- # You may obtain a copy of the License at
11
- #
12
- # http://www.apache.org/licenses/LICENSE-2.0
13
- #
14
- # Unless required by applicable law or agreed to in writing, software
15
- # distributed under the License is distributed on an "AS IS" BASIS,
16
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
- # See the License for the specific language governing permissions and
18
- # limitations under the License.
19
-
20
- package "couchdb"
21
-
22
- directory "/var/lib/couchdb" do
23
- owner "couchdb"
24
- group "couchdb"
25
- recursive true
26
- end
27
-
28
- service "couchdb" do
29
- if platform?("centos","redhat","fedora")
30
- start_command "/sbin/service couchdb start &> /dev/null"
31
- stop_command "/sbin/service couchdb stop &> /dev/null"
32
- end
33
- supports [ :restart, :status ]
34
- action [ :enable, :start ]
35
- end
@@ -1,16 +0,0 @@
1
- maintainer "Opscode, Inc."
2
- maintainer_email "cookbooks@opscode.com"
3
- license "Apache 2.0"
4
- description "Installs CouchDB package and starts service"
5
- long_description <<-EOH
6
- Installs the CouchDB package if it is available from an package repository on
7
- the node. If the package repository is not available, CouchDB needs to be
8
- installed via some other method, either a backported package, or compiled
9
- directly from source.
10
- EOH
11
- version "0.7.7"
12
- supports "ubuntu", ">= 8.10" # for package in APT
13
-
14
- %w{ rhel centos fedora }.each do |os|
15
- supports os # requires that CouchDB package is available in yum repositories
16
- end
@@ -1,35 +0,0 @@
1
- #
2
- # Author:: Joshua Timberman <joshua@opscode.com>
3
- # Cookbook Name:: couchdb
4
- # Recipe:: default
5
- #
6
- # Copyright 2008, OpsCode, Inc
7
- #
8
- # Licensed under the Apache License, Version 2.0 (the "License");
9
- # you may not use this file except in compliance with the License.
10
- # You may obtain a copy of the License at
11
- #
12
- # http://www.apache.org/licenses/LICENSE-2.0
13
- #
14
- # Unless required by applicable law or agreed to in writing, software
15
- # distributed under the License is distributed on an "AS IS" BASIS,
16
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
- # See the License for the specific language governing permissions and
18
- # limitations under the License.
19
-
20
- package "couchdb"
21
-
22
- directory "/var/lib/couchdb" do
23
- owner "couchdb"
24
- group "couchdb"
25
- recursive true
26
- end
27
-
28
- service "couchdb" do
29
- if platform?("centos","redhat","fedora")
30
- start_command "/sbin/service couchdb start &> /dev/null"
31
- stop_command "/sbin/service couchdb stop &> /dev/null"
32
- end
33
- supports [ :restart, :status ]
34
- action [ :enable, :start ]
35
- end
@@ -1,16 +0,0 @@
1
- maintainer "Opscode, Inc."
2
- maintainer_email "cookbooks@opscode.com"
3
- license "Apache 2.0"
4
- description "Installs CouchDB package and starts service"
5
- long_description <<-EOH
6
- Installs the CouchDB package if it is available from an package repository on
7
- the node. If the package repository is not available, CouchDB needs to be
8
- installed via some other method, either a backported package, or compiled
9
- directly from source.
10
- EOH
11
- version "0.7.7"
12
- supports "ubuntu", ">= 8.10" # for package in APT
13
-
14
- %w{ rhel centos fedora }.each do |os|
15
- supports os # requires that CouchDB package is available in yum repositories
16
- end
@@ -1,35 +0,0 @@
1
- #
2
- # Author:: Joshua Timberman <joshua@opscode.com>
3
- # Cookbook Name:: couchdb
4
- # Recipe:: default
5
- #
6
- # Copyright 2008, OpsCode, Inc
7
- #
8
- # Licensed under the Apache License, Version 2.0 (the "License");
9
- # you may not use this file except in compliance with the License.
10
- # You may obtain a copy of the License at
11
- #
12
- # http://www.apache.org/licenses/LICENSE-2.0
13
- #
14
- # Unless required by applicable law or agreed to in writing, software
15
- # distributed under the License is distributed on an "AS IS" BASIS,
16
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
- # See the License for the specific language governing permissions and
18
- # limitations under the License.
19
-
20
- package "couchdb"
21
-
22
- directory "/var/lib/couchdb" do
23
- owner "couchdb"
24
- group "couchdb"
25
- recursive true
26
- end
27
-
28
- service "couchdb" do
29
- if platform?("centos","redhat","fedora")
30
- start_command "/sbin/service couchdb start &> /dev/null"
31
- stop_command "/sbin/service couchdb stop &> /dev/null"
32
- end
33
- supports [ :restart, :status ]
34
- action [ :enable, :start ]
35
- end
@@ -1,24 +0,0 @@
1
- #!/usr/bin/env ruby -w
2
-
3
- require 'rubygems'
4
- require 'opscode/rest'
5
-
6
- client = Opscode::REST.new
7
-
8
- #uri = 'http://opscode-community.pivotallabs.com/api/v1/cookbooks/couchdb3'
9
- #secret_filename = '/Users/tim/.ssh/pivotallabs-secret.txt'
10
- #user_id = 'timh'
11
- #uri = 'http://opscode:omgnewcommunity!@com-stg.opscode.com/api/v1/cookbooks/couchdb2'
12
- uri = 'http://com-stg.opscode.com/api/v1/cookbooks/couchdb4'
13
- secret_filename = '/Users/tim/.ssh/secret-timh2-com-stg.txt'
14
- user_id = 'timh2'
15
-
16
-
17
- user_secret = OpenSSL::PKey::RSA.new(File.read(secret_filename))
18
-
19
- res = client.request(:delete,
20
- uri,
21
- :authenticate => true,
22
- :user_id => user_id,
23
- :user_secret => user_secret)
24
- puts "res from delete is: #{res}"
@@ -1,20 +0,0 @@
1
- #!/usr/bin/env ruby -w
2
-
3
- require 'rubygems'
4
- require 'opscode/rest'
5
-
6
- client = Opscode::REST.new
7
-
8
- uri = 'http://localhost:5959/objects/1'
9
- secret_filename = '/Users/tim/.ssh/secret-timh2-com-stg.txt'
10
- user_id = 'timh2'
11
-
12
- user_secret = OpenSSL::PKey::RSA.new(File.read(secret_filename))
13
-
14
- res = client.request(:get,
15
- uri,
16
- :authenticate => true,
17
- :user_id => user_id,
18
- :user_secret => user_secret)
19
- puts "res from GET is: #{res}"
20
-
@@ -1,22 +0,0 @@
1
-
2
- #!/usr/bin/env ruby -w
3
-
4
- # Test collectino.find
5
- hash = {
6
- 'something_else' => 'value',
7
- 'another_thing' => 'hmm',
8
- 'tarball' => File.new('/etc/passwd'),
9
- 'yet_another' => '..',
10
- }
11
-
12
- Hash
13
- res = hash.find { |k,v| v.is_a?(File) }
14
- puts "res is #{res[1]}"
15
-
16
-
17
- # test gsub
18
- str = "my-testing/0_7_0"
19
- str = str.gsub(/_/, '.')
20
- puts "str is #{str}"
21
-
22
- Hash
@@ -1,20 +0,0 @@
1
- require 'net/https'
2
- require 'uri'
3
-
4
- url = 'https://s3.amazonaws.com/opscode-community/cookbook_versions/tarballs/151/original/teamspeak.tar.gz'
5
- uri = URI.parse url
6
-
7
- http_client = Net::HTTP.new(uri.host, uri.port)
8
- if uri.scheme == 'https'
9
- http_client.use_ssl = true
10
- http_client.verify_mode = OpenSSL::SSL::VERIFY_NONE
11
- end
12
-
13
- res = http_client.request_get(uri.path)
14
-
15
- #http = Net::HTTP.new(uri.host, uri.port)
16
- #http.use_ssl = true if uri.scheme == 'https'
17
- #res = http.get
18
-
19
- puts "res #{res}"
20
- puts "res.body is #{res.body}"
@@ -1,28 +0,0 @@
1
- #!/usr/bin/env ruby -w
2
-
3
- require 'rubygems'
4
- require 'rest_client'
5
- require 'mixlib/authentication/signedheaderauth'
6
-
7
- uri = 'http://com-stg.opscode.com/api/v1/cookbooks'
8
- user_secret_filename = '/Users/tim/.ssh/secret-timh2-com-stg.txt'
9
- user_secret = OpenSSL::PKey::RSA.new(File.read(user_secret_filename))
10
-
11
- args = {
12
- :file => File.new('couchdb2.tar.gz'),
13
- :user_id => 'timh2',
14
- :http_method => :post,
15
- :timestamp => Time.now.utc.iso8601
16
- }
17
- client = Mixlib::Authentication::SignedHeaderAuth.signing_object(args)
18
- puts "SignedHeaderAuth client is #{client}"
19
-
20
- headers = client.sign(user_secret)
21
- puts "headers is #{headers}"
22
-
23
- res = RestClient.post(uri,
24
- {:tarball => File.read('couchdb2.tar.gz'), :cookbook => '{"category":"good"}'},
25
- #File.new('couchdb2.tar.gz'),
26
- headers)
27
- puts "POST res is #{res}"
28
-
@@ -1,26 +0,0 @@
1
- #!/usr/bin/env ruby -w
2
-
3
- require 'rubygems'
4
- require 'mixlib/authentication/signatureverification'
5
-
6
- sigv = Mixlib::Authentication::SignatureVerification.new
7
-
8
- # for timh2:
9
- # -----BEGIN RSA PUBLIC KEY-----
10
- # MIIBCgKCAQEA0wqGeC4/OSMQwFCp0/6o21dUlSrbWFFFYdVC1wY/ADgpnAbnZGDO
11
- # URrrmQ8zw2WBMGpZ2RvhaToj7SOlCUOJmM99W5Ou9E3pOFvjRWgWjW0LAe48SIWP
12
- # t2WtdtI4YBzyS6Dp9Oxdcm5TGGJa7QMbIgaU9VD0Jr8yFDWE9QdqAsy+NBSwM13c
13
- # CQuBqHtSoJMk9SgzwQyFSm6GCQcliNh5wupKqhNNYCdYOAeJQqJKn25aK9/4+eLu
14
- # 8F8bVD1MznOBes089+CoY50sy1N2iZnxwftZklmGLJ1tB5C8+vNwB91Qzp9csUtr
15
- # prTkgeW/9cqybTwTm30pj5yrW6A271pkVwIDAQAB
16
- # -----END RSA PUBLIC KEY-----
17
-
18
- # for timh3:
19
- # -----BEGIN RSA PUBLIC KEY-----
20
- # MIIBCgKCAQEA0wqGeC4/OSMQwFCp0/6o21dUlSrbWFFFYdVC1wY/ADgpnAbnZGDO
21
- # URrrmQ8zw2WBMGpZ2RvhaToj7SOlCUOJmM99W5Ou9E3pOFvjRWgWjW0LAe48SIWP
22
- # t2WtdtI4YBzyS6Dp9Oxdcm5TGGJa7QMbIgaU9VD0Jr8yFDWE9QdqAsy+NBSwM13c
23
- # CQuBqHtSoJMk9SgzwQyFSm6GCQcliNh5wupKqhNNYCdYOAeJQqJKn25aK9/4+eLu
24
- # 8F8bVD1MznOBes089+CoY50sy1N2iZnxwftZklmGLJ1tB5C8+vNwB91Qzp9csUtr
25
- # prTkgeW/9cqybTwTm30pj5yrW6A271pkVwIDAQAB
26
- # -----END RSA PUBLIC KEY-----
@@ -1,62 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- $: << File.join(File.dirname(__FILE__), "..", "opscode-chef", "chef", "lib")
4
-
5
- require 'rubygems'
6
- require 'cgi'
7
- require 'json'
8
- require 'opscode/rest'
9
- require 'mixlib/log'
10
- require 'chef/log'
11
- require 'streaming_cookbook_uploader'
12
-
13
- Opscode::REST::Config[:log_level] = :debug
14
-
15
- client = Opscode::REST.new
16
-
17
- #uri = 'http://opscode-community.pivotallabs.com/api/v1/cookbooks'
18
- #user_id = 'timh'
19
- #secret_key_filename = '/Users/tim/.ssh/pivotallabs-secret.txt'
20
-
21
- uri = 'http://com-stg.opscode.com/api/v1/cookbooks'
22
- user_id = 'timh2'
23
- secret_key_filename = '/Users/tim/.ssh/secret-timh2-com-stg.txt'
24
-
25
- user_secret = OpenSSL::PKey::RSA.new(File.read(secret_key_filename))
26
- filename_to_upload = 'couchdb3.tar.gz'
27
-
28
- if 1
29
- ########## streaming cookbook uploader
30
- ########## results in 'invalid authenticity token' exception (pages of rails
31
- ########## exception) from far end:
32
- streaming_client = Chef::StreamingCookbookUploader.new
33
- res = streaming_client.post(uri, user_id, secret_key_filename,
34
- { 'tarball' => File.new(filename_to_upload),
35
- 'cookbook' => '{"category":"good"}' })
36
- puts "res is #{res}"
37
-
38
- elsif nil
39
- ########## nuo's alternative
40
- ########## results in 'unauthorized' from far end
41
- headers = {:accept=>"application/json", :content_type=>'application/json'}
42
- options = {:authenticate=> true,
43
- :user_secret=>user_secret,
44
- :user_id=>user_id,
45
- :headers=>headers,
46
- :payload=>File.read(filename_to_upload)
47
- }
48
- res = client.request(:post,uri,options)
49
- puts "res is #{res}"
50
-
51
- elsif 1
52
- ########## my original
53
- ########## results in 'unauthorized' from far end
54
- res = client.post(uri,
55
- :payload => File.read(filename_to_upload),
56
- :authenticate => true,
57
- :user_id => user_id,
58
- :user_secret => user_secret,
59
- :headers => {
60
- :content_type => 'application/octet-stream' })
61
- puts "res is #{res}"
62
- end
@@ -1,28 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- $: << File.join(File.dirname(__FILE__), "..", "opscode-chef", "chef", "lib")
4
-
5
- require 'rubygems'
6
- require 'rest_client'
7
- require 'mixlib/authentication/signedheaderauth'
8
- require 'mixlib/log'
9
- require 'chef/log'
10
- require 'streaming_cookbook_uploader'
11
-
12
- uri = 'http://com-stg.opscode.com/api/v1/cookbooks'
13
- user_id = 'timh2'
14
- user_secret_filename = '/Users/tim/.ssh/secret-timh2-com-stg.txt'
15
- user_secret = OpenSSL::PKey::RSA.new(File.read(user_secret_filename))
16
-
17
- # def post(to_url, user_id, secret_key_filename, params = {}, headers = {})
18
- # make_request(:post, to_url, user_id, secret_key_filename, params, headers)
19
- # end
20
-
21
- client = Chef::StreamingCookbookUploader.new
22
-
23
- res = client.post(uri, user_id, user_secret_filename, {
24
- :tarball => File.open('couchdb2.tar.gz'),
25
- :cookbook => '{"category":"databases"}'
26
- })
27
- puts "POST res is #{res}"
28
-