Skip to content

Commit

Permalink
fix typo, code climate and add reek config
Browse files Browse the repository at this point in the history
  • Loading branch information
o-orand committed Jul 26, 2018
1 parent afdfd01 commit de422d0
Show file tree
Hide file tree
Showing 19 changed files with 50 additions and 32 deletions.
7 changes: 7 additions & 0 deletions .reek
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
# this file should be name reel.yml in reek 5
#Detectors: # reek 5
DuplicateMethodCall:
max_calls: 2
TooManyStatements:
max_statements: 8 # to be more consistent with rubocop Metrics/MethodLength: 10
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
source 'https://rubygems.org'

ruby '2.3.1'
ruby '~>2.3.1'

gem 'rhcl', '>= 0.1.0'

Expand Down
8 changes: 4 additions & 4 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -582,11 +582,11 @@ or in multiple files. An example file can be found at [/lib/coa_env_bootstrapper
It can contain up to 8 main keys:

* inactive_steps, _optional_: pass a list of steps that will be deactivated in case you wouldn't need them to run, for instance in case you have some resources already installed. You can deactivate:
* deploy_transiant_infra: you can deactivate this step if you already have an infrastructure with BOSH and Concourse
* deploy_transient_infra: you can deactivate this step if you already have an infrastructure with BOSH and Concourse
* upload_stemcell: you can deactivate this step if you don't want a new stemcell to be uploaded to the BOSH Director
* upload_cloud_config: you can deactivate this step if you don't want to overwrite the cloud config of the BOSH Director
* install_git_server: you can deactivate this step if you have the git-server deployment already deployed on the BOSH Director
* bucc, _optional_: you have to pass this key unless you deactivate the deploy_transiant_infra step:
* bucc, _optional_: you have to pass this key unless you deactivate the deploy_transient_infra step:
* bin_path: the path to your installation of the bucc project. The project can be found at [https://github.com/starkandwayne/bucc](https://github.com/starkandwayne/bucc)
* cpi: the cpi you want to use for the deployment. The list of existing CPIs can be found on the bucc GitHub project
* cpi_specific_options: options you want to pass to the bucc CLI for the bucc deployment
Expand All @@ -598,12 +598,12 @@ It can contain up to 8 main keys:
* git_server_manifest, _mandatory_: a BOSH manifest to deploy the git-server deployment. The example one can be used to be deployed with VirtualBox, in any other case, you will want to adapt it for your IaaS.
* cloud_config, _optional_: you have to pass this key unless you deactivate the "upload_cloud_config" step. This will be used by the BOSH CLI to upload a cloud-config to the BOSH Director
* pipeline_credentials, _mandatory_: this passes a list of credentials that will by used by fly to upload the pipelines to Concourse.
* concourse, _optional_: you have to pass this object if you deactivated the deploy_transiant_infra step or if you want to overwrite the BUCC Concourse and want to use another one. The options are self-explanatory.
* concourse, _optional_: you have to pass this object if you deactivated the deploy_transient_infra step or if you want to overwrite the BUCC Concourse and want to use another one. The options are self-explanatory.
* target
* url
* username
* password
* bosh, _optional_: you have to pass this key if you deactivate the deploy_transiant_infra step or if you want to overwrite BUCC's BOSH and want to use another one. The options are self-explanatory.
* bosh, _optional_: you have to pass this key if you deactivate the deploy_transient_infra step or if you want to overwrite BUCC's BOSH and want to use another one. The options are self-explanatory.
* bosh_environment
* bosh_client
* bosh_client_secret
Expand Down
2 changes: 1 addition & 1 deletion ci/bootstrap_coa_env/prereqs.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
inactive_steps:
- deploy_transiant_infra
- deploy_transient_infra
- upload_stemcell
# - upload_cloud_config
# - install_git_server
Expand Down
1 change: 1 addition & 0 deletions lib/bosh_certificates.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require 'openssl'

# Create or load SSL certificates to be able to connect to a Bosh Director
class BoshCertificates
attr_reader :base_dir, :bosh_cert_hash, :certs

Expand Down
1 change: 1 addition & 0 deletions lib/coa_env_bootstrapper.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require 'pathname'

# Bootstrap an new COA environment from scratch
module CoaEnvBootstrapper
require_relative './coa_env_bootstrapper/base'
require_relative './coa_env_bootstrapper/bosh'
Expand Down
4 changes: 2 additions & 2 deletions lib/coa_env_bootstrapper/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ def self.run(prereqs_path)
def run
@config_dir = Dir.mktmpdir
write_source_profile
env_creator_adapter.deploy_transiant_infra unless inactive_step?("deploy_transiant_infra")
env_creator_adapter.deploy_transient_infra unless inactive_step?("deploy_transient_infra")
prepare_bosh_environment
prepare_git_environment
run_pipeline_jobs
env_creator_adapter.display_concourse_login_information unless inactive_step?("deploy_transiant_infra")
env_creator_adapter.display_concourse_login_information unless inactive_step?("deploy_transient_infra")
end

def generated_concourse_credentials
Expand Down
1 change: 1 addition & 0 deletions lib/coa_env_bootstrapper/bosh.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require_relative './command_runner'

module CoaEnvBootstrapper
# Manage interaction with a Bosh Director (stemcell upload, cloud config, prerequisite deployment,etc..) during bootstrap
class Bosh
include CommandRunner

Expand Down
3 changes: 2 additions & 1 deletion lib/coa_env_bootstrapper/bucc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
require_relative './errors'

module CoaEnvBootstrapper
# Manage BUCC deployment
class Bucc
include CommandRunner
attr_reader :prereqs
Expand All @@ -11,7 +12,7 @@ def initialize(prereqs)
@prereqs = prereqs || {}
end

def deploy_transiant_infra
def deploy_transient_infra
run_cmd "#{bucc_cli_path} up --cpi #{prereqs['cpi']} \
#{prereqs['cpi_specific_options']} --lite --debug"
end
Expand Down
7 changes: 4 additions & 3 deletions lib/coa_env_bootstrapper/command_runner.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require 'open3'

module CoaEnvBootstrapper
# Base class for executing command and checking command result
module CommandRunner
def run_cmd(cmd, opts = {})
source_file_path = opts[:source_file_path]
Expand All @@ -10,7 +11,7 @@ def run_cmd(cmd, opts = {})

write_header(cmd, ignore_error)
stdout, stderr, status = Open3.capture3(cmd)
determine_sucess(stdout, stderr, status, ignore_error)
determine_success(stdout, stderr, status, ignore_error)

stdout
end
Expand All @@ -24,9 +25,9 @@ def write_header(command, error_ignored)
puts "while ignoring errors." if error_ignored
end

def determine_sucess(stdout, stderr, status, error_ignored)
def determine_success(stdout, stderr, status, error_ignored)
if status.success?
puts "Command ran succesfully with the following output:", stdout
puts "Command ran successfully with the following output:", stdout
elsif error_ignored
puts "Command errored, but continuing:", "stderr:", stderr, "stdout:", stdout
else
Expand Down
1 change: 1 addition & 0 deletions lib/coa_env_bootstrapper/concourse.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
require_relative '../coa_env_bootstrapper'

module CoaEnvBootstrapper
# Manage interactions with concourse during bootstrap
class Concourse
include CommandRunner

Expand Down
4 changes: 2 additions & 2 deletions lib/coa_env_bootstrapper/env_creator_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ def initialize(adapter_name, prereqs)
end
end

def deploy_transiant_infra
adapter.deploy_transiant_infra
def deploy_transient_infra
adapter.deploy_transient_infra
end

def vars
Expand Down
1 change: 1 addition & 0 deletions lib/coa_env_bootstrapper/errors.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
module CoaEnvBootstrapper
# Error raised by BUCC
class BuccCommandError < StandardError; end
class EnvCreatorAdapterNotImplementedError < StandardError; end
class ConfigDirNotFound < StandardError
Expand Down
1 change: 1 addition & 0 deletions lib/coa_env_bootstrapper/git.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
require_relative './errors'

module CoaEnvBootstrapper
# Manage interaction with COA embedded git repository
class Git
include CommandRunner
attr_reader :ceb
Expand Down
2 changes: 1 addition & 1 deletion lib/coa_env_bootstrapper/prereqs.example.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# With this key you can deactive some of the steps of the script, if you've got
# some elements installed already.
inactive_steps: []
# - deploy_transiant_infra
# - deploy_transient_infra
# - upload_stemcell
# - upload_cloud_config
# - install_git_server
Expand Down
23 changes: 13 additions & 10 deletions scripts/extract_pipeline_credentials_list.rb
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
#!/usr/bin/env ruby -w

def credential_list(pipelines_path)
creds_list = []
# scan pipelines to list concourse variables
class CredentialsList
def self.list(pipelines_path)
creds_list = []

files = File.directory?(pipelines_path) ? Dir["#{pipelines_path}/*"] : [pipelines_path]
files = File.directory?(pipelines_path) ? Dir["#{pipelines_path}/*"] : [pipelines_path]

files.each do |path|
next if File.directory?(path)
pipeline_content = File.read(path)
creds_list << pipeline_content.scan(%r{\(\(([\w|-]*)\)\)}).flatten.uniq
end
files.each do |path|
next if File.directory?(path)
pipeline_content = File.read(path)
creds_list << pipeline_content.scan(/\(\(([\w|-]*)\)\)/).flatten.uniq
end

creds_list.flatten.uniq.sort
creds_list.flatten.uniq.sort
end
end

if (path = ARGV[0])
creds = credential_list(path)
creds = CredentialsList.list(path)
puts "Found credentials in alphabetical order:"
puts creds.join("\n")
else
Expand Down
8 changes: 4 additions & 4 deletions spec/lib/coa_env_bootstrapper/base_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
let(:ceb) { described_class.new([]) }

it "runs all steps" do
allow(ceb.env_creator_adapter).to receive(:deploy_transiant_infra)
allow(ceb.env_creator_adapter).to receive(:deploy_transient_infra)
allow(ceb).to receive(:write_source_profile)
allow(ceb.bosh).to receive(:upload_stemcell)
allow(ceb.bosh).to receive(:upload_cloud_config)
Expand All @@ -49,7 +49,7 @@

ceb.run

expect(ceb.env_creator_adapter).to have_received(:deploy_transiant_infra)
expect(ceb.env_creator_adapter).to have_received(:deploy_transient_infra)
expect(ceb).to have_received(:write_source_profile)
expect(ceb.bosh).to have_received(:upload_stemcell)
expect(ceb.bosh).to have_received(:upload_cloud_config)
Expand All @@ -70,7 +70,7 @@
let(:ceb) { described_class.new([inactive_steps_yml_path]) }

it "ignores the deactivated steps" do
allow(ceb.env_creator_adapter).to receive(:deploy_transiant_infra)
allow(ceb.env_creator_adapter).to receive(:deploy_transient_infra)
allow(ceb).to receive(:write_source_profile)
allow(ceb.bosh).to receive(:upload_stemcell)
allow(ceb.bosh).to receive(:upload_cloud_config)
Expand All @@ -87,7 +87,7 @@

ceb.run

expect(ceb.env_creator_adapter).not_to have_received(:deploy_transiant_infra)
expect(ceb.env_creator_adapter).not_to have_received(:deploy_transient_infra)
expect(ceb).to have_received(:write_source_profile)
expect(ceb.bosh).not_to have_received(:upload_stemcell)
expect(ceb.bosh).to have_received(:upload_cloud_config)
Expand Down
4 changes: 2 additions & 2 deletions spec/lib/coa_env_bootstrapper/bucc_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
describe CoaEnvBootstrapper::Bucc do
describe '.new'

describe '#deploy_transiant_infra' do
describe '#deploy_transient_infra' do
context "with no given bucc config" do
let(:bucc) { described_class.new({}) }

Expand All @@ -20,7 +20,7 @@
it "runs a bucc command with the config" do
allow(bucc).to receive(:run_cmd)

bucc.deploy_transiant_infra
bucc.deploy_transient_infra

expect(bucc).to have_received(:run_cmd).
with("/path/to/bucc/bin/bucc up --cpi virtualbox --verbose --lite --debug")
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/fixtures/coa_env_bootstrapper/inactive_steps.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
inactive_steps:
- "deploy_transiant_infra"
- "deploy_transient_infra"
- "upload_stemcell"
- "deploy_git_server"

0 comments on commit de422d0

Please sign in to comment.