jackal-packagecloud 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 49bf239e0b146efd4a4678910ca810bfba664f4e
4
+ data.tar.gz: 7a041d7ead54355343cbcf7dcf704a2d8175fbe5
5
+ SHA512:
6
+ metadata.gz: cbd09f803c3483f5a8a3531a14df61dbd41ccc62b28621f4bc01617a0d401b73e7f76a68b05b02302133bf90b8401f86da7fbe18319ce5f3dac36162e2caf44a
7
+ data.tar.gz: 646575f0cc4f0b96b0ea7ae648c6954c38ad4056b7b732645e3b50c1d5a752daa84e38305c595115ab98a3b6b4613ccbaec6885a450aa07fba38451c5251f083
@@ -0,0 +1,2 @@
1
+ # v0.1.0
2
+ * Initial implementation
@@ -0,0 +1,25 @@
1
+ # Contributing
2
+
3
+ ## Branches
4
+
5
+ ### `master` branch
6
+
7
+ The master branch is the current stable released version.
8
+
9
+ ### `develop` branch
10
+
11
+ The develop branch is the current edge of development.
12
+
13
+ ## Pull requests
14
+
15
+ * https://github.com/carnivore-rb/jackal-packagecloud/pulls
16
+
17
+ Please base all pull requests of the `develop` branch. Merges to
18
+ `master` only occur through the `develop` branch. Pull requests
19
+ based on `master` will likely be cherry picked.
20
+
21
+ ## Issues
22
+
23
+ Need to report an issue? Use the github issues:
24
+
25
+ * https://github.com/carnivore-rb/jackal-packagecloud/issues
data/LICENSE ADDED
@@ -0,0 +1,13 @@
1
+ Copyright 2015 Heavy Water
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
@@ -0,0 +1,45 @@
1
+ # Jackal Packagecloud
2
+
3
+ Jackal service to push packages to packagecloud.
4
+
5
+ ## Configuration
6
+
7
+ Requires configured api_key / account_name for packagecloud in jackal config
8
+
9
+ ```ruby
10
+ # ...
11
+ jackal do
12
+ packagecloud do
13
+ config do
14
+ api_key ENV['PACKAGECLOUD_API_KEY']
15
+ account_name ENV['PACKAGECLOUD_ACCOUNT_NAME']
16
+ end
17
+ end
18
+ end
19
+ ```
20
+
21
+ Package assets are fetched from the configured asset store requiring
22
+ the asset store to be configured and available in running service.
23
+
24
+ ## Payload structure
25
+
26
+ ```json
27
+ {
28
+ "data": {
29
+ "packagecloud": {
30
+ "packages": [
31
+ {
32
+ "distro_description": "ubuntu/precise",
33
+ "path": "asset_store/key/path/foo.deb",
34
+ "repo": "my_repo"
35
+ }
36
+ ]
37
+ }
38
+ }
39
+ }
40
+ ```
41
+
42
+ # Info
43
+
44
+ * Repository: https://github.com/carnivore-rb/jackal-packagecloud
45
+ * IRC: Freenode @ #carnivore
@@ -0,0 +1,20 @@
1
+ $LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__)) + '/lib/'
2
+ require 'jackal-packagecloud/version'
3
+ Gem::Specification.new do |s|
4
+ s.name = 'jackal-packagecloud'
5
+ s.version = Jackal::Packagecloud::VERSION.version
6
+ s.summary = 'Jackal packagecloud'
7
+ s.author = 'Heavywater'
8
+ s.email = 'support@heavywater.io'
9
+ s.homepage = 'http://github.com/carnivore-rb/jackal-packagecloud'
10
+ s.description = 'Jackal packagecloud Integration'
11
+ s.license = 'Apache 2.0'
12
+ s.require_path = 'lib'
13
+ s.add_dependency 'jackal', '>= 0.3.18', '< 1.0'
14
+ s.add_dependency 'jackal-assets'
15
+ s.add_dependency 'packagecloud-ruby', '~> 0.2.19'
16
+
17
+ s.add_development_dependency 'carnivore-actor'
18
+
19
+ s.files = Dir['lib/**/*'] + %w(jackal-packagecloud.gemspec README.md CHANGELOG.md CONTRIBUTING.md LICENSE)
20
+ end
@@ -0,0 +1,26 @@
1
+ require 'jackal'
2
+
3
+ module Jackal
4
+ # Jackal Cloud integration
5
+ module Packagecloud
6
+ autoload :Pusher, 'jackal-packagecloud/pusher'
7
+ end
8
+ end
9
+
10
+ require 'jackal-packagecloud/version'
11
+
12
+ Jackal.service(
13
+ :packagecloud,
14
+ :description => 'Upload packages to packagecloud',
15
+ :configuration => {
16
+ :account_name => {
17
+ :description => 'packagecloud account name',
18
+ },
19
+ :api_key => {
20
+ :description => 'packagecloud API key'
21
+ },
22
+ :default_repo => {
23
+ :description => 'Default repository to push packages'
24
+ }
25
+ }
26
+ )
@@ -0,0 +1,91 @@
1
+ require 'jackal-packagecloud'
2
+
3
+ module Jackal
4
+ module Packagecloud
5
+ # Push packages to package cloud
6
+ class Pusher < Jackal::Callback
7
+
8
+ # Load up the package cloud library
9
+ def setup(*_)
10
+ require 'packagecloud'
11
+ # This is a stupid fix for JSON dumping due to pure json lib
12
+ # that's being included via the require above
13
+ Fixnum.class_eval do
14
+ def to_json(*args)
15
+ to_s
16
+ end
17
+ end
18
+ end
19
+
20
+ # Config / payload requirements for Message to be considered valid
21
+ # and for execute method to run
22
+ #
23
+ # @param message [Carnivore::Message]
24
+ # @return [TrueClass, FalseClass]
25
+ def valid?(message)
26
+ super do |payload|
27
+ !payload.fetch(:data, :packagecloud, :packages, []).empty?
28
+ end
29
+ end
30
+
31
+ # Process payload and push packages to package cloud
32
+ #
33
+ # @param message [Carnivore::Message]
34
+ def execute(message)
35
+ failure_wrap(message) do |payload|
36
+ packages = payload.get(:data, :packagecloud, :packages)
37
+ upload_packages(packages)
38
+
39
+ payload.set(:data, :packagecloud, :uploaded,
40
+ payload[:data][:packagecloud].delete(:packages)
41
+ )
42
+ job_completed(:packagecloud_pusher, payload, message)
43
+ end
44
+ end
45
+
46
+ # Create a new package cloud client instance
47
+ #
48
+ # @return [::Packagecloud::Client]
49
+ def packagecloud_client
50
+ [:account_name, :api_key].each do |k|
51
+ unless(config[k])
52
+ raise "Missing expected configuration item: `#{k}`"
53
+ end
54
+ end
55
+ ::Packagecloud::Client.new(
56
+ ::Packagecloud::Credentials.new(
57
+ config[:account_name],
58
+ config[:api_key]
59
+ )
60
+ )
61
+ end
62
+
63
+ # Upload packages to packagecloud
64
+ #
65
+ # @param packages [Array<Hash>] package list
66
+ # @note `:path` is required and references the asset store.
67
+ # `:distro_description` and `:repo` are optional. Default
68
+ # `:repo` value is pulled for the configuration or set to `"test"`.
69
+ # @return [TrueClass]
70
+ def upload_packages(packages)
71
+ client = packagecloud_client
72
+ packages.each do |pkg|
73
+ # distro_description can be nil for gems and source tarballs
74
+ # valid version strings (eg: ubuntu/precise):
75
+ # https://packagecloud.io/docs#os_distro_version
76
+ description, path = pkg[:distro_description], pkg[:path]
77
+
78
+ event!(:info, :info => "Pushing package to packagecloud: #{File.basename(path)}")
79
+
80
+ distro_id = description && client.find_distribution_id(description)
81
+ package = ::Packagecloud::Package.new(*[asset_store.get(path), distro_id].compact)
82
+ client.put_package(pkg.fetch(:repo, config.fetch(:default_repo, 'test')), package)
83
+
84
+ event!(:info, :info => "Completed pushing package to packagecloud: #{File.basename(path)}")
85
+ end
86
+ true
87
+ end
88
+
89
+ end
90
+ end
91
+ end
@@ -0,0 +1,6 @@
1
+ module Jackal
2
+ module Packagecloud
3
+ # Current library version
4
+ VERSION = Gem::Version.new('0.1.0')
5
+ end
6
+ end
metadata ADDED
@@ -0,0 +1,114 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jackal-packagecloud
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Heavywater
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-07-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: jackal
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 0.3.18
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '1.0'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: 0.3.18
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '1.0'
33
+ - !ruby/object:Gem::Dependency
34
+ name: jackal-assets
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ type: :runtime
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ - !ruby/object:Gem::Dependency
48
+ name: packagecloud-ruby
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: 0.2.19
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: 0.2.19
61
+ - !ruby/object:Gem::Dependency
62
+ name: carnivore-actor
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ description: Jackal packagecloud Integration
76
+ email: support@heavywater.io
77
+ executables: []
78
+ extensions: []
79
+ extra_rdoc_files: []
80
+ files:
81
+ - CHANGELOG.md
82
+ - CONTRIBUTING.md
83
+ - LICENSE
84
+ - README.md
85
+ - jackal-packagecloud.gemspec
86
+ - lib/jackal-packagecloud.rb
87
+ - lib/jackal-packagecloud/pusher.rb
88
+ - lib/jackal-packagecloud/version.rb
89
+ homepage: http://github.com/carnivore-rb/jackal-packagecloud
90
+ licenses:
91
+ - Apache 2.0
92
+ metadata: {}
93
+ post_install_message:
94
+ rdoc_options: []
95
+ require_paths:
96
+ - lib
97
+ required_ruby_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ required_rubygems_version: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ version: '0'
107
+ requirements: []
108
+ rubyforge_project:
109
+ rubygems_version: 2.2.2
110
+ signing_key:
111
+ specification_version: 4
112
+ summary: Jackal packagecloud
113
+ test_files: []
114
+ has_rdoc: