pact_broker 0.0.1
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.
- data/.gitignore +26 -0
- data/.rspec +2 -0
- data/CHANGELOG.md +7 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +117 -0
- data/README.md +94 -0
- data/Rakefile +41 -0
- data/config.ru +10 -0
- data/config/boot.rb +17 -0
- data/config/database.yml +13 -0
- data/db/migrations/01_create_pacticipant_table.rb +9 -0
- data/db/migrations/02_create_versions_table.rb +14 -0
- data/db/migrations/03_create_pacts_table.rb +12 -0
- data/db/migrations/04_create_tags_table.rb +10 -0
- data/db/pact_broker_database.sqlite3 +0 -0
- data/lib/pact_broker.rb +5 -0
- data/lib/pact_broker/api.rb +18 -0
- data/lib/pact_broker/api/base_api.rb +40 -0
- data/lib/pact_broker/api/index_api.rb +23 -0
- data/lib/pact_broker/api/pact_api.rb +33 -0
- data/lib/pact_broker/api/pacticipant_api.rb +34 -0
- data/lib/pact_broker/db.rb +45 -0
- data/lib/pact_broker/logging.rb +26 -0
- data/lib/pact_broker/models.rb +5 -0
- data/lib/pact_broker/models/pact.rb +22 -0
- data/lib/pact_broker/models/pacticipant.rb +16 -0
- data/lib/pact_broker/models/tag.rb +10 -0
- data/lib/pact_broker/models/version.rb +16 -0
- data/lib/pact_broker/repositories.rb +22 -0
- data/lib/pact_broker/repositories/pact_repository.rb +38 -0
- data/lib/pact_broker/repositories/pacticipant_repository.rb +30 -0
- data/lib/pact_broker/repositories/version_repository.rb +27 -0
- data/lib/pact_broker/services.rb +14 -0
- data/lib/pact_broker/services/pact_service.rb +39 -0
- data/lib/pact_broker/services/pacticipant_service.rb +31 -0
- data/lib/pact_broker/services/version_service.rb +15 -0
- data/lib/pact_broker/tasks.rb +1 -0
- data/lib/pact_broker/tasks/migration_task.rb +41 -0
- data/lib/pact_broker/version.rb +3 -0
- data/pact_broker.gemspec +39 -0
- data/pact_broker_client-pact_broker.json +133 -0
- data/spec/service_consumers/pact_helper.rb +39 -0
- data/spec/service_consumers/provider_states_for_pact_broker_client.rb +118 -0
- data/spec/spec_helper.rb +3 -0
- data/tasks/db.rake +23 -0
- data/tasks/pact.rake +12 -0
- data/tasks/rspec.rake +14 -0
- metadata +343 -0
data/.gitignore
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
*.gem
|
|
2
|
+
*.rbc
|
|
3
|
+
.bundle
|
|
4
|
+
.config
|
|
5
|
+
coverage
|
|
6
|
+
InstalledFiles
|
|
7
|
+
lib/bundler/man
|
|
8
|
+
log
|
|
9
|
+
pkg
|
|
10
|
+
rdoc
|
|
11
|
+
spec/reports
|
|
12
|
+
test/tmp
|
|
13
|
+
test/version_tmp
|
|
14
|
+
tmp
|
|
15
|
+
reports
|
|
16
|
+
|
|
17
|
+
# YARD artifacts
|
|
18
|
+
.yardoc
|
|
19
|
+
_yardoc
|
|
20
|
+
doc/
|
|
21
|
+
.bin
|
|
22
|
+
|
|
23
|
+
# Editor files
|
|
24
|
+
*.sublime*
|
|
25
|
+
*.swp
|
|
26
|
+
.idea
|
data/.rspec
ADDED
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
pact_broker (0.0.1)
|
|
5
|
+
httparty
|
|
6
|
+
json
|
|
7
|
+
sequel
|
|
8
|
+
sinatra
|
|
9
|
+
sinatra-contrib
|
|
10
|
+
sinatra-param
|
|
11
|
+
sqlite3
|
|
12
|
+
|
|
13
|
+
PATH
|
|
14
|
+
remote: ../pact
|
|
15
|
+
specs:
|
|
16
|
+
pact (1.0.20)
|
|
17
|
+
awesome_print (~> 1.1.0)
|
|
18
|
+
find_a_port (~> 1.0.1)
|
|
19
|
+
json
|
|
20
|
+
rack-test (~> 0.6.2)
|
|
21
|
+
randexp (~> 0.1.7)
|
|
22
|
+
rspec (~> 2.12)
|
|
23
|
+
thin
|
|
24
|
+
thor
|
|
25
|
+
|
|
26
|
+
GEM
|
|
27
|
+
remote: https://rubygems.org/
|
|
28
|
+
specs:
|
|
29
|
+
awesome_print (1.1.0)
|
|
30
|
+
backports (3.3.5)
|
|
31
|
+
builder (3.2.2)
|
|
32
|
+
ci_reporter (1.9.0)
|
|
33
|
+
builder (>= 2.1.2)
|
|
34
|
+
coderay (1.0.9)
|
|
35
|
+
columnize (0.3.6)
|
|
36
|
+
daemons (1.1.9)
|
|
37
|
+
debugger (1.6.2)
|
|
38
|
+
columnize (>= 0.3.1)
|
|
39
|
+
debugger-linecache (~> 1.2.0)
|
|
40
|
+
debugger-ruby_core_source (~> 1.2.3)
|
|
41
|
+
debugger-linecache (1.2.0)
|
|
42
|
+
debugger-ruby_core_source (1.2.3)
|
|
43
|
+
diff-lcs (1.2.4)
|
|
44
|
+
eventmachine (1.0.3)
|
|
45
|
+
fakefs (0.4.3)
|
|
46
|
+
find_a_port (1.0.1)
|
|
47
|
+
httparty (0.12.0)
|
|
48
|
+
json (~> 1.8)
|
|
49
|
+
multi_xml (>= 0.5.2)
|
|
50
|
+
json (1.8.1)
|
|
51
|
+
method_source (0.8.2)
|
|
52
|
+
multi_json (1.8.2)
|
|
53
|
+
multi_xml (0.5.5)
|
|
54
|
+
pry (0.9.12.2)
|
|
55
|
+
coderay (~> 1.0.5)
|
|
56
|
+
method_source (~> 0.8)
|
|
57
|
+
slop (~> 3.4)
|
|
58
|
+
rack (1.5.2)
|
|
59
|
+
rack-protection (1.5.1)
|
|
60
|
+
rack
|
|
61
|
+
rack-test (0.6.2)
|
|
62
|
+
rack (>= 1.0)
|
|
63
|
+
rake (10.0.4)
|
|
64
|
+
randexp (0.1.7)
|
|
65
|
+
rspec (2.14.1)
|
|
66
|
+
rspec-core (~> 2.14.0)
|
|
67
|
+
rspec-expectations (~> 2.14.0)
|
|
68
|
+
rspec-mocks (~> 2.14.0)
|
|
69
|
+
rspec-core (2.14.6)
|
|
70
|
+
rspec-expectations (2.14.3)
|
|
71
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
|
72
|
+
rspec-fire (1.2.0)
|
|
73
|
+
rspec (~> 2.11)
|
|
74
|
+
rspec-mocks (2.14.4)
|
|
75
|
+
sequel (4.3.0)
|
|
76
|
+
shotgun (0.9)
|
|
77
|
+
rack (>= 1.0)
|
|
78
|
+
simplecov (0.7.1)
|
|
79
|
+
multi_json (~> 1.0)
|
|
80
|
+
simplecov-html (~> 0.7.1)
|
|
81
|
+
simplecov-html (0.7.1)
|
|
82
|
+
sinatra (1.4.4)
|
|
83
|
+
rack (~> 1.4)
|
|
84
|
+
rack-protection (~> 1.4)
|
|
85
|
+
tilt (~> 1.3, >= 1.3.4)
|
|
86
|
+
sinatra-contrib (1.4.1)
|
|
87
|
+
backports (>= 2.0)
|
|
88
|
+
multi_json
|
|
89
|
+
rack-protection
|
|
90
|
+
rack-test
|
|
91
|
+
sinatra (~> 1.4.0)
|
|
92
|
+
tilt (~> 1.3)
|
|
93
|
+
sinatra-param (0.1.3)
|
|
94
|
+
sinatra (~> 1.3)
|
|
95
|
+
slop (3.4.6)
|
|
96
|
+
sqlite3 (1.3.8)
|
|
97
|
+
thin (1.6.0)
|
|
98
|
+
daemons (>= 1.0.9)
|
|
99
|
+
eventmachine (>= 1.0.0)
|
|
100
|
+
rack (>= 1.5.0)
|
|
101
|
+
thor (0.18.1)
|
|
102
|
+
tilt (1.4.1)
|
|
103
|
+
|
|
104
|
+
PLATFORMS
|
|
105
|
+
ruby
|
|
106
|
+
|
|
107
|
+
DEPENDENCIES
|
|
108
|
+
ci_reporter
|
|
109
|
+
debugger
|
|
110
|
+
fakefs (~> 0.4)
|
|
111
|
+
pact!
|
|
112
|
+
pact_broker!
|
|
113
|
+
pry
|
|
114
|
+
rake (~> 10.0.3)
|
|
115
|
+
rspec-fire
|
|
116
|
+
shotgun
|
|
117
|
+
simplecov
|
data/README.md
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
# PactBroker
|
|
2
|
+
|
|
3
|
+
Add a detailed description of the new service here before your first commit.
|
|
4
|
+
|
|
5
|
+
Information here will be consumed by the Treasure Map (via the Rumour Mill). Therefore, please retain the existing formatting on this page, importantly:
|
|
6
|
+
|
|
7
|
+
* The service name at the top of the page
|
|
8
|
+
* The location of this description text (between service name and Custodian(s)
|
|
9
|
+
* Component Custodian(s)
|
|
10
|
+
|
|
11
|
+
Other headings can be deleted if they are not relevant.
|
|
12
|
+
|
|
13
|
+
**NOTE: The following is provided for convenience. Please check it carefully before your first commit.**
|
|
14
|
+
|
|
15
|
+
## Component Custodian(s)
|
|
16
|
+
|
|
17
|
+
Enter Custodian(s) here
|
|
18
|
+
|
|
19
|
+
## Development
|
|
20
|
+
|
|
21
|
+
Enter any developer instructions here.
|
|
22
|
+
|
|
23
|
+
### Database setup
|
|
24
|
+
|
|
25
|
+
Instructions to set up the database for local testing.
|
|
26
|
+
|
|
27
|
+
Then run migrations:
|
|
28
|
+
|
|
29
|
+
$ bundle exec rake db:migrate
|
|
30
|
+
|
|
31
|
+
### Testing
|
|
32
|
+
|
|
33
|
+
$ bundle exec rake
|
|
34
|
+
|
|
35
|
+
### Running
|
|
36
|
+
|
|
37
|
+
Instructions to run the service locally.
|
|
38
|
+
|
|
39
|
+
### Debugging
|
|
40
|
+
|
|
41
|
+
Any specific debugging tools built in to the service (health check is assumed so don't include that).
|
|
42
|
+
|
|
43
|
+
### Build
|
|
44
|
+
|
|
45
|
+
**edit the below and add the correct endpoint**
|
|
46
|
+
|
|
47
|
+
[Standalone (Bamboo)](http://master.cd.vpc.realestate.com.au/browse/YOUR_NEW_SERVICE_BUILD)
|
|
48
|
+
|
|
49
|
+
## Deployment
|
|
50
|
+
|
|
51
|
+
Deployment scripts have been generated using [biq-deploy](https://git.realestate.com.au/business-systems/biq-deploy).
|
|
52
|
+
|
|
53
|
+
#### EC2 environments
|
|
54
|
+
|
|
55
|
+
Before deploying to EC2 environments, you may wish to check that the build you wish to deploy has been indexed.
|
|
56
|
+
|
|
57
|
+
1. Log in into the agent unix box:
|
|
58
|
+
|
|
59
|
+
$ rea-ec2-ssh agent-01.biq
|
|
60
|
+
|
|
61
|
+
2. See the list of versions indexed and verify the expected version in the list:
|
|
62
|
+
|
|
63
|
+
$ yum list --showduplicates --enablerepo=rea-el6-dev pact_broker
|
|
64
|
+
|
|
65
|
+
You can get up an running with these scripts like so (from within the pact_broker project on your local machine):
|
|
66
|
+
|
|
67
|
+
$ cd deploy
|
|
68
|
+
$ bundle
|
|
69
|
+
$ bundle exec bin/pact-broker-deploy-ec2 --help
|
|
70
|
+
|
|
71
|
+
When deploying to an EC2 environment for the first time, you must create a node for the app:
|
|
72
|
+
|
|
73
|
+
$ bundle exec bin/pact-broker-deploy-ec2 -t create -s $YOUR_SUBDOMAIN -p dev
|
|
74
|
+
|
|
75
|
+
The first time the service is deployed, a database must be created. After adding the [required config values](https://git.realestate.com.au/business-systems/pact_broker/blob/master/lib/pact_broker/environment_variables.rb) to the
|
|
76
|
+
environment's config-svc, you can run the db provision task:
|
|
77
|
+
|
|
78
|
+
$ bundle exec bin/pact-broker-deploy-ec2 -t db_provision -s $YOUR_SUBDOMAIN
|
|
79
|
+
|
|
80
|
+
Then you are free to migrate the db from then on:
|
|
81
|
+
|
|
82
|
+
$ bundle exec bin/pact-broker-deploy-ec2 -t db_migrate -s $YOUR_SUBDOMAIN
|
|
83
|
+
|
|
84
|
+
To deploy to a test environment (eg biq-qa1):
|
|
85
|
+
|
|
86
|
+
$ bundle exec bin/pact-broker-deploy-ec2 -t deploy -s biq-qa1 -p dev -y
|
|
87
|
+
|
|
88
|
+
#### Production
|
|
89
|
+
|
|
90
|
+
Refer to the [production deployment readme](https://git.realestate.com.au/business-systems/pact_broker/blob/master/README-ProdDeploy.md).
|
|
91
|
+
|
|
92
|
+
### Architecture
|
|
93
|
+
|
|
94
|
+
Any important architectural information.
|
data/Rakefile
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require 'bundler/gem_helper'
|
|
4
|
+
module Bundler
|
|
5
|
+
class GemHelper
|
|
6
|
+
def install
|
|
7
|
+
desc "Build #{name}-#{version}.gem into the pkg directory"
|
|
8
|
+
task 'build' do
|
|
9
|
+
build_gem
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
desc "Build and install #{name}-#{version}.gem into system gems"
|
|
13
|
+
task 'install' do
|
|
14
|
+
install_gem
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
GemHelper.instance = self
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
Bundler::GemHelper.install_tasks
|
|
22
|
+
|
|
23
|
+
require 'rubygems'
|
|
24
|
+
require 'bundler'
|
|
25
|
+
begin
|
|
26
|
+
Bundler.setup(:default, :development)
|
|
27
|
+
rescue Bundler::BundlerError => e
|
|
28
|
+
$stderr.puts e.message
|
|
29
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
|
30
|
+
exit e.status_code
|
|
31
|
+
end
|
|
32
|
+
require 'rake'
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
FileList['lib/tasks/**/*.rake'].each { |task| load "#{Dir.pwd}/#{task}" }
|
|
36
|
+
FileList['tasks/**/*.rake'].each { |task| load "#{Dir.pwd}/#{task}" }
|
|
37
|
+
|
|
38
|
+
task :default => [:spec, 'pact:verify']
|
|
39
|
+
|
|
40
|
+
require File.join(File.dirname(__FILE__), 'config/boot')
|
|
41
|
+
|
data/config.ru
ADDED
data/config/boot.rb
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Remember everything in this file will be loaded by Rake, don't make it too heavy...
|
|
2
|
+
|
|
3
|
+
$LOAD_PATH << File.expand_path(File.dirname(__FILE__) + '/../lib')
|
|
4
|
+
|
|
5
|
+
# Default environment
|
|
6
|
+
# Be aware that rake loads this boot file, so any attempt to change RACK_ENV by
|
|
7
|
+
# setting ENV['RACK_ENV'] after that (eg. in spec_helper) will not work.
|
|
8
|
+
RACK_ENV = ENV['RACK_ENV'] || 'development' unless defined? RACK_ENV
|
|
9
|
+
|
|
10
|
+
# Set up gems listed in the Gemfile.
|
|
11
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
|
|
12
|
+
if File.exists?(ENV['BUNDLE_GEMFILE'])
|
|
13
|
+
require 'bundler/setup'
|
|
14
|
+
Bundler.require
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
require 'pact_broker'
|
data/config/database.yml
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
Sequel.migration do
|
|
2
|
+
|
|
3
|
+
change do
|
|
4
|
+
create_table(:versions) do
|
|
5
|
+
primary_key :id
|
|
6
|
+
String :number
|
|
7
|
+
String :repository_ref
|
|
8
|
+
foreign_key :pacticipant_id, :pacticipants, :null=>false
|
|
9
|
+
index [:pacticipant_id, :number], :unique=>true
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
end
|
|
14
|
+
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
Sequel.migration do
|
|
2
|
+
change do
|
|
3
|
+
create_table(:pacts) do
|
|
4
|
+
primary_key :id
|
|
5
|
+
String :json_content, :text=>true
|
|
6
|
+
foreign_key :version_id, :versions, null: false
|
|
7
|
+
foreign_key :provider_id, :pacticipants, null: false
|
|
8
|
+
index [:version_id, :provider_id], :unique=>true
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
Binary file
|
data/lib/pact_broker.rb
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
require 'sinatra'
|
|
2
|
+
|
|
3
|
+
require_relative 'api/index_api'
|
|
4
|
+
require_relative 'api/pacticipant_api'
|
|
5
|
+
require_relative 'api/pact_api'
|
|
6
|
+
|
|
7
|
+
module PactBroker
|
|
8
|
+
class API < Sinatra::Base
|
|
9
|
+
# content_type :json, 'application/json'
|
|
10
|
+
# content_type :xml, 'text/xml'
|
|
11
|
+
# default_format :json
|
|
12
|
+
|
|
13
|
+
use Api::IndexApi
|
|
14
|
+
use Api::PacticipantApi
|
|
15
|
+
use Api::PactApi
|
|
16
|
+
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
require 'pact_broker/logging'
|
|
2
|
+
require 'pact_broker/repositories'
|
|
3
|
+
require 'sequel'
|
|
4
|
+
require 'sinatra'
|
|
5
|
+
require 'sinatra/json'
|
|
6
|
+
require 'sinatra/namespace'
|
|
7
|
+
require 'sinatra/param'
|
|
8
|
+
require 'pact_broker/models'
|
|
9
|
+
require 'pact_broker/services'
|
|
10
|
+
|
|
11
|
+
module PactBroker
|
|
12
|
+
|
|
13
|
+
module Api
|
|
14
|
+
|
|
15
|
+
class BaseApi < Sinatra::Base
|
|
16
|
+
|
|
17
|
+
helpers do
|
|
18
|
+
include PactBroker::Logging
|
|
19
|
+
include PactBroker::Services
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
set :raise_errors, false
|
|
23
|
+
set :show_exceptions, false
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
error do
|
|
27
|
+
e = env['sinatra.error']
|
|
28
|
+
logger.error e
|
|
29
|
+
content_type :json
|
|
30
|
+
status 500
|
|
31
|
+
{:message => e.message, :backtrace => e.backtrace }.to_json
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
helpers Sinatra::JSON
|
|
35
|
+
helpers Sinatra::Param
|
|
36
|
+
register Sinatra::Namespace
|
|
37
|
+
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|