-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add support for configuration with YAML file (#109)
- Loading branch information
Showing
19 changed files
with
123 additions
and
963 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: Build Docker image | ||
|
||
on: [push] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- uses: ruby/setup-ruby@v1 | ||
with: | ||
ruby-version: 2.6.4 | ||
|
||
- name: Build image | ||
run: script/build-workflow/run.sh | ||
env: | ||
DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }} | ||
DOCKER_HUB_TOKEN: ${{ secrets.DOCKER_HUB_TOKEN }} | ||
CUSTOM_TAG: ${{ github.event.client_payload.tag }} | ||
|
||
- name: Integration tests | ||
run: script/test.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/sh | ||
|
||
echo "sleeping 5" | ||
sleep 5 | ||
/pact/entrypoint.sh broker publish /pacts --consumer-app-version 1 --tag "feat/foo" --verbose |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,56 @@ | ||
require_relative 'database_connection' | ||
require 'logger' | ||
require 'pact_broker/tasks' | ||
require_relative "docker_configuration" | ||
require "pact_broker/configuration" | ||
require "pact_broker/initializers/database_connection" | ||
require "pact_broker/tasks" | ||
|
||
def create_database_configuration | ||
PactBroker.configuration.runtime_configuration = PactBroker.docker_configuration | ||
PactBroker.create_database_connection(PactBroker.configuration.database_configuration, PactBroker.configuration.logger) | ||
end | ||
|
||
def env(name) | ||
ENV[name] && ENV[name] != '' ? ENV[name] : nil | ||
end | ||
|
||
PactBroker::DB::MigrationTask.new do | task | | ||
task.database_connection = create_database_connection(Logger.new($stdout)) | ||
task.database_connection = create_database_configuration | ||
end | ||
|
||
PactBroker::DB::VersionTask.new do | task | | ||
task.database_connection = create_database_connection(Logger.new($stdout)) | ||
task.database_connection = create_database_configuration | ||
end | ||
|
||
PactBroker::DB::CleanTask.new do | task | | ||
task.database_connection = create_database_connection(Logger.new($stdout)) | ||
task.database_connection = create_database_configuration | ||
task.logger = PactBroker.configuration.logger | ||
|
||
if env('PACT_BROKER_DATABASE_CLEAN_KEEP_VERSION_SELECTORS') | ||
require 'json' | ||
task.keep_version_selectors = JSON.parse(env('PACT_BROKER_DATABASE_CLEAN_KEEP_VERSION_SELECTORS')) | ||
end | ||
|
||
if env('PACT_BROKER_DATABASE_CLEAN_DELETION_LIMIT') | ||
task.version_deletion_limit = env('PACT_BROKER_DATABASE_CLEAN_DELETION_LIMIT').to_i | ||
end | ||
|
||
if env('PACT_BROKER_DATABASE_CLEAN_DRY_RUN') | ||
task.dry_run = env('PACT_BROKER_DATABASE_CLEAN_DRY_RUN') == 'true' | ||
end | ||
end | ||
|
||
PactBroker::DB::DeleteOverwrittenDataTask.new do | task | | ||
task.database_connection = create_database_connection(Logger.new($stdout)) | ||
if ENV['PACT_BROKER_DELETE_OVERWRITTEN_DATA_AGE'] | ||
task.age_in_days = ENV['PACT_BROKER_DELETE_OVERWRITTEN_DATA_AGE'].to_i | ||
else | ||
task.age_in_days = 30 | ||
task.database_connection = create_database_configuration | ||
task.logger = PactBroker.configuration.logger | ||
|
||
if env('PACT_BROKER_DATABASE_CLEAN_OVERWRITTEN_DATA_MAX_AGE') | ||
task.max_age = env('PACT_BROKER_DATABASE_CLEAN_OVERWRITTEN_DATA_MAX_AGE').to_i | ||
end | ||
|
||
if env('PACT_BROKER_DATABASE_CLEAN_DELETION_LIMIT') | ||
task.deletion_limit = env('PACT_BROKER_DATABASE_CLEAN_DELETION_LIMIT').to_i | ||
end | ||
|
||
if env('PACT_BROKER_DATABASE_CLEAN_DRY_RUN') | ||
task.dry_run = env('PACT_BROKER_DATABASE_CLEAN_DRY_RUN') == 'true' | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,10 @@ | ||
require 'sequel' | ||
require 'pact_broker' | ||
require_relative 'logger' | ||
require_relative 'basic_auth' | ||
require_relative 'database_connection' | ||
require_relative 'passenger_config' | ||
require_relative 'docker_configuration' | ||
|
||
dc = PactBroker::DockerConfiguration.new(ENV, PactBroker::Configuration.default_configuration) | ||
dc.pact_broker_environment_variables.each{ |key, value| $logger.info "#{key}=#{value}"} | ||
require_relative "passenger_config" | ||
require_relative "docker_configuration" | ||
require "pact_broker" | ||
|
||
app = PactBroker::App.new do | config | | ||
config.logger = $logger | ||
config.database_connection = create_database_connection_from_config(config.logger, dc.database_configuration) | ||
config.database_connection.timezone = :utc | ||
config.base_url = dc.base_url | ||
config.webhook_host_whitelist = dc.webhook_host_whitelist | ||
config.webhook_http_method_whitelist = dc.webhook_http_method_whitelist | ||
config.webhook_scheme_whitelist = dc.webhook_scheme_whitelist | ||
config.base_equality_only_on_content_that_affects_verification_results = dc.base_equality_only_on_content_that_affects_verification_results | ||
config.order_versions_by_date = dc.order_versions_by_date | ||
config.disable_ssl_verification = dc.disable_ssl_verification | ||
end | ||
|
||
PactBroker.configuration.log_configuration | ||
|
||
basic_auth_username = ENV.fetch('PACT_BROKER_BASIC_AUTH_USERNAME','') | ||
basic_auth_password = ENV.fetch('PACT_BROKER_BASIC_AUTH_PASSWORD', '') | ||
basic_auth_read_only_username = ENV['PACT_BROKER_BASIC_AUTH_READ_ONLY_USERNAME'] | ||
basic_auth_read_only_password = ENV['PACT_BROKER_BASIC_AUTH_READ_ONLY_PASSWORD'] | ||
allow_public_read_access = ENV.fetch('PACT_BROKER_ALLOW_PUBLIC_READ', '') == 'true' | ||
allow_public_access_to_heartbeat = ENV.fetch('PACT_BROKER_PUBLIC_HEARTBEAT', '') == 'true' | ||
use_basic_auth = basic_auth_username != '' && basic_auth_password != '' | ||
|
||
|
||
if use_basic_auth | ||
puts "INFO: Public read access is enabled" if allow_public_read_access | ||
policy = PactBrokerResourceAccessPolicy.build(allow_public_read_access, allow_public_access_to_heartbeat) | ||
use BasicAuth, | ||
[basic_auth_username, basic_auth_password], | ||
[basic_auth_read_only_username, basic_auth_read_only_password], | ||
policy | ||
config.runtime_configuration = PactBroker.docker_configuration | ||
config.basic_auth_enabled = config.basic_auth_credentials_provided? | ||
end | ||
|
||
run app |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.