concourse-fuselage 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 975402edab7f41d684ccf38764222e64c329697f
4
+ data.tar.gz: b04adc7c4b1fda6d307c4523a3806c0a73cfcec7
5
+ SHA512:
6
+ metadata.gz: 136fc2d48953ec7ca86e76b26d2de562356f3c2b607fc1d5178bbb13e2710bf6d2900f2544d9fcf98b10e7151c41e5fe11403d7288b33f91d6c32a40158b4a04
7
+ data.tar.gz: 5e367ca85563d78961de384a4d66dcfaaf5abeb71bf2b0fb11e2b9f31d7d020170fbb818ad94d090c28b0364bd00e30939185cbac186537aa46e3e32c4e08b66
data/.gitignore ADDED
@@ -0,0 +1,3 @@
1
+ .bundle/**
2
+ auto/**
3
+ vendor/**
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source ENV.fetch 'RUBYGEMS_MIRROR', 'https://rubygems.org'
2
+
3
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,19 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ concourse-fuselage (0.1.0)
5
+ contracts (~> 0.13, >= 0.13.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ contracts (0.13.0)
11
+
12
+ PLATFORMS
13
+ ruby
14
+
15
+ DEPENDENCIES
16
+ concourse-fuselage!
17
+
18
+ BUNDLED WITH
19
+ 1.11.2
data/LICENSE.txt ADDED
@@ -0,0 +1,13 @@
1
+ Copyright 2016 Chris Olstrom <chris@olstrom.com>
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.
data/README.org ADDED
@@ -0,0 +1,63 @@
1
+ #+TITLE: fuselage
2
+ #+SUBTITLE: Simplifying Concourse Resources in Ruby
3
+ #+LATEX: \pagebreak
4
+
5
+ * Overview
6
+
7
+ ~fuselage~ simplifies development of resources for Concourse by providing
8
+ classes for standard resource steps, interface contracts between Concourse and
9
+ your resource, and clear errors for most failure conditions.
10
+
11
+ * Implementing a Resource
12
+
13
+ #+BEGIN_SRC ruby
14
+ require 'concourse-fuselage'
15
+ #+END_SRC
16
+
17
+ Inherit from the appropriate class and implement the required methods.
18
+
19
+ ** ~Fuselage::Check~
20
+
21
+ ~Check~ is used to poll for new versions.
22
+
23
+ *** ~#latest~
24
+
25
+ Should return a ~Hash~ that describes the latest version. This will be called
26
+ when no prior version has been detected.
27
+
28
+ *** ~#since(version)~
29
+
30
+ Will be passed a ~Hash~ in the form ~Out#version~ returns.
31
+
32
+ Should return an ~Array~ of ~Hashes~, similar to what ~#latest~ would return.
33
+
34
+ ** ~Fuselage::In~
35
+
36
+ ~In~ is called for the ~get~ step of a resource.
37
+
38
+ *** ~#fetch!~
39
+
40
+ Fetch ~#version~ place it in ~#workdir~.
41
+
42
+ Should fail if ~#version~ is unavailable.
43
+
44
+ ** ~Fuselage::Out~
45
+
46
+ ~Out~ is called for the ~put~ step of a resource.
47
+
48
+ *** ~#update!~
49
+
50
+ Update the resource. All outputs from prior steps are available in ~#workdir~.
51
+
52
+ *** ~#version~
53
+
54
+ Should return a ~Hash~ that describes the resulting version.
55
+
56
+ * License
57
+
58
+ Apache 2.0 License, see ~LICENSE.txt~ for details.
59
+
60
+ * Contributors
61
+
62
+ - [[https://colstrom.github.io/][Chris Olstrom]] | [[mailto:chris@olstrom.com][e-mail]] | [[https://twitter.com/ChrisOlstrom][Twitter]]
63
+
@@ -0,0 +1,16 @@
1
+ Gem::Specification.new do |gem|
2
+ gem.name = 'concourse-fuselage'
3
+ gem.version = '0.1.0'
4
+ gem.authors = ['Chris Olstrom']
5
+ gem.email = 'chris@olstrom.com'
6
+ gem.license = 'MIT'
7
+ gem.summary = 'Helpers for Concourse Resources'
8
+ gem.description = 'Helper classes and methods for implementing Concourse Resources'
9
+
10
+ gem.files = `git ls-files`.split("\n")
11
+ gem.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
12
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
13
+ gem.require_paths = ['lib']
14
+
15
+ gem.add_runtime_dependency 'contracts', '~> 0.13', '>= 0.13.0'
16
+ end
@@ -0,0 +1,31 @@
1
+ require 'json'
2
+ require_relative 'step'
3
+
4
+ module Fuselage
5
+ class Check < Step
6
+ Contract None => Maybe[HashOf[String, String]]
7
+ def version
8
+ config['version']
9
+ end
10
+
11
+ Contract None => HashOf[String, String]
12
+ def latest
13
+ fail NotImplementedError
14
+ end
15
+
16
+ Contract HashOf[String, String] => ArrayOf[HashOf[String, String]]
17
+ def since(version)
18
+ fail NotImplementedError
19
+ end
20
+
21
+ Contract None => ArrayOf[HashOf[String, String]]
22
+ def output
23
+ version.nil? ? [latest] : since(version)
24
+ end
25
+
26
+ Contract None => String
27
+ def run
28
+ JSON.dump output
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,41 @@
1
+ require 'json'
2
+ require_relative 'step'
3
+ require_relative 'support/build_metadata'
4
+ require_relative 'support/params'
5
+ require_relative 'support/work_dir'
6
+
7
+ module Fuselage
8
+ class In < Step
9
+ include Support::BuildMetadata
10
+ include Support::Params
11
+ include Support::WorkDir
12
+
13
+ Contract None => HashOf[String, String]
14
+ def version
15
+ @version ||= config.fetch 'version'
16
+ rescue KeyError
17
+ STDERR.puts 'Configuration payload is missing version'
18
+ end
19
+
20
+ Contract None => ArrayOf[Maybe[HashOf[String, String]]]
21
+ def metadata
22
+ []
23
+ end
24
+
25
+ Contract None => String
26
+ def output
27
+ JSON.dump version: version, metadata: metadata
28
+ end
29
+
30
+ Contract None => Any
31
+ def fetch!
32
+ fail NotImplementedError
33
+ end
34
+
35
+ Contract None => String
36
+ def run
37
+ fetch!
38
+ output
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,39 @@
1
+ require 'json'
2
+ require_relative 'step'
3
+ require_relative 'support/build_metadata'
4
+ require_relative 'support/params'
5
+ require_relative 'support/work_dir'
6
+
7
+ module Fuselage
8
+ class Out < Step
9
+ include Support::BuildMetadata
10
+ include Support::Params
11
+ include Support::WorkDir
12
+
13
+ Contract None => HashOf[String, String]
14
+ def version
15
+ fail NotImplementedError
16
+ end
17
+
18
+ Contract None => ArrayOf[Maybe[HashOf[String, String]]]
19
+ def metadata
20
+ []
21
+ end
22
+
23
+ Contract None => String
24
+ def output
25
+ JSON.dump version: version, metadata: metadata
26
+ end
27
+
28
+ Contract None => Any
29
+ def update!
30
+ fail NotImplementedError
31
+ end
32
+
33
+ Contract None => String
34
+ def run
35
+ update!
36
+ output
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,10 @@
1
+ require 'contracts'
2
+ require_relative 'support/source'
3
+
4
+ module Fuselage
5
+ class Step
6
+ include ::Contracts::Core
7
+ include ::Contracts::Builtin
8
+ include Support::Source
9
+ end
10
+ end
@@ -0,0 +1,50 @@
1
+ require 'contracts'
2
+
3
+ module Fuselage
4
+ module Support
5
+ module BuildMetadata
6
+ include ::Contracts::Core
7
+ include ::Contracts::Builtin
8
+
9
+ Contract None => Maybe[String]
10
+ def build_id
11
+ ENV.fetch 'BUILD_ID'
12
+ rescue KeyError
13
+ STDERR.puts 'Environment is missing BUILD_ID'
14
+ abort
15
+ end
16
+
17
+ Contract None => Maybe[String]
18
+ def build_name
19
+ ENV.fetch 'BUILD_NAME'
20
+ rescue KeyError
21
+ STDERR.puts 'Environment is missing BUILD_NAME'
22
+ abort
23
+ end
24
+
25
+ Contract None => Maybe[String]
26
+ def build_job_name
27
+ ENV.fetch 'BUILD_JOB_NAME'
28
+ rescue KeyError
29
+ STDERR.puts 'Environment is missing BUILD_JOB_NAME'
30
+ abort
31
+ end
32
+
33
+ Contract None => Maybe[String]
34
+ def build_pipeline_name
35
+ ENV.fetch 'BUILD_PIPELINE_NAME'
36
+ rescue KeyError
37
+ STDERR.puts 'Environment is missing BUILD_PIPELINE_NAME'
38
+ abort
39
+ end
40
+
41
+ Contract None => Maybe[String]
42
+ def atc_external_url
43
+ ENV.fetch 'ATC_EXTERNAL_URL'
44
+ rescue KeyError
45
+ STDERR.puts 'Environment is missing ATC_EXTERNAL_URL'
46
+ abort
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,16 @@
1
+ require 'contracts'
2
+ require 'json'
3
+
4
+ module Fuselage
5
+ module Support
6
+ module Config
7
+ include ::Contracts::Core
8
+ include ::Contracts::Builtin
9
+
10
+ Contract None => Hash
11
+ def config
12
+ @config ||= JSON.load STDIN || {}
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,17 @@
1
+ require 'contracts'
2
+ require_relative 'config'
3
+
4
+ module Fuselage
5
+ module Support
6
+ module Params
7
+ include ::Contracts::Core
8
+ include ::Contracts::Builtin
9
+ include Config
10
+
11
+ Contract None => Hash
12
+ def params
13
+ @params ||= config.fetch 'params', {}
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ require 'contracts'
2
+ require_relative 'config'
3
+
4
+ module Fuselage
5
+ module Support
6
+ module Source
7
+ include ::Contracts::Core
8
+ include ::Contracts::Builtin
9
+ include Config
10
+
11
+ Contract None => Hash
12
+ def source
13
+ @source ||= config.fetch 'source', {}
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,20 @@
1
+ require 'contracts'
2
+
3
+ module Fuselage
4
+ module Support
5
+ module WorkDir
6
+ include ::Contracts::Core
7
+ include ::Contracts::Builtin
8
+
9
+ Contract None => String
10
+ def workdir
11
+ @workdir ||= ARGV.first.tap do |workdir|
12
+ fail ArgumentError if workdir.nil?
13
+ end
14
+ rescue ArgumentError
15
+ STDERR.puts 'Working directory missing, expected as first argument'
16
+ abort
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,3 @@
1
+ require_relative 'concourse-fuselage/check'
2
+ require_relative 'concourse-fuselage/in'
3
+ require_relative 'concourse-fuselage/out'
metadata ADDED
@@ -0,0 +1,80 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: concourse-fuselage
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Chris Olstrom
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-02-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: contracts
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.13'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 0.13.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.13'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 0.13.0
33
+ description: Helper classes and methods for implementing Concourse Resources
34
+ email: chris@olstrom.com
35
+ executables: []
36
+ extensions: []
37
+ extra_rdoc_files: []
38
+ files:
39
+ - ".gitignore"
40
+ - Gemfile
41
+ - Gemfile.lock
42
+ - LICENSE.txt
43
+ - README.org
44
+ - concourse-fuselage.gemspec
45
+ - lib/concourse-fuselage.rb
46
+ - lib/concourse-fuselage/check.rb
47
+ - lib/concourse-fuselage/in.rb
48
+ - lib/concourse-fuselage/out.rb
49
+ - lib/concourse-fuselage/step.rb
50
+ - lib/concourse-fuselage/support/build_metadata.rb
51
+ - lib/concourse-fuselage/support/config.rb
52
+ - lib/concourse-fuselage/support/params.rb
53
+ - lib/concourse-fuselage/support/source.rb
54
+ - lib/concourse-fuselage/support/work_dir.rb
55
+ homepage:
56
+ licenses:
57
+ - MIT
58
+ metadata: {}
59
+ post_install_message:
60
+ rdoc_options: []
61
+ require_paths:
62
+ - lib
63
+ required_ruby_version: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ required_rubygems_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ requirements: []
74
+ rubyforge_project:
75
+ rubygems_version: 2.5.1
76
+ signing_key:
77
+ specification_version: 4
78
+ summary: Helpers for Concourse Resources
79
+ test_files: []
80
+ has_rdoc: