Class: R10kDeployer
- Inherits:
-
Object
- Object
- R10kDeployer
- Defined in:
- lib/release_manager/r10k_deployer.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#path ⇒ Object
(also: #control_repo_path)
readonly
Returns the value of attribute path.
-
#previous_branch ⇒ Object
readonly
Returns the value of attribute previous_branch.
Attributes included from ReleaseManager::VCSManager
Class Method Summary collapse
Instance Method Summary collapse
- #check_requirements ⇒ Object
- #cleanup(branch = nil) ⇒ Object
- #control_repo ⇒ Object
-
#initialize(path, opts) ⇒ R10kDeployer
constructor
A new instance of R10kDeployer.
- #run ⇒ Object
Methods included from ReleaseManager::Git::Utilities
#add_all, #add_file, #add_remote, #apply_diff, #apply_patch, #author, #author_email, #author_name, #branch_exist?, #changed_files, #checkout_branch, #cherry_pick, #cli_create_commit, #clone, #create_branch, #create_commit, #create_diff, #create_diff_obj, #create_local_tag, #credentials, #current_branch, #current_branch?, #delete_branch, #fetch, #fetch_cli, #find_or_create_remote, #find_ref, #find_tag, #get_content, #git_command, #git_url?, #push_branch, #push_tags, #rebase_branch, #ref_exists?, #remote_exists?, #remote_from_name, #remote_from_url, #remote_url_matches?, #remove_file, #repo, #tag_exists?, #tags, #transports, #up2date?
Methods included from ReleaseManager::VCSManager
adapter_instance, adapter_types, default_instance
Methods included from ReleaseManager::Logger
Constructor Details
#initialize(path, opts) ⇒ R10kDeployer
Returns a new instance of R10kDeployer.
14 15 16 17 |
# File 'lib/release_manager/r10k_deployer.rb', line 14 def initialize(path, opts) @path = path = opts end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
8 9 10 |
# File 'lib/release_manager/r10k_deployer.rb', line 8 def end |
#path ⇒ Object (readonly) Also known as: control_repo_path
Returns the value of attribute path.
8 9 10 |
# File 'lib/release_manager/r10k_deployer.rb', line 8 def path @path end |
#previous_branch ⇒ Object (readonly)
Returns the value of attribute previous_branch.
8 9 10 |
# File 'lib/release_manager/r10k_deployer.rb', line 8 def previous_branch @previous_branch end |
Class Method Details
.run(path, options) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/release_manager/r10k_deployer.rb', line 38 def self.run(path, ) begin deploy = new(path, ) deploy.check_requirements deploy.logger.info "Deploying R10k-Control #{options[:dest_ref]} with version: #{options[:src_ref]}" deploy.run rescue GitError => e deploy.logger.fatal(e.) code = 1 rescue Gitlab::Error::Forbidden => e logger.fatal(e.) logger.fatal("You don't have access to modify the repository") rescue Gitlab::Error::MissingCredentials => e deploy.logger.fatal(e.) code = 1 rescue PatchError => e deploy.logger.fatal(e.) code = 1 rescue ModNotFoundException => e deploy.logger.fatal(e.) code = 1 rescue InvalidBranchName => e deploy.logger.fatal(e.) code = 1 rescue InvalidMetadataSource deploy.logger.fatal "The puppet module's metadata.json source field must be a git url: ie. [email protected]:devops/module.git" code = 1 rescue PuppetfileNotFoundException deploy.logger.fatal "Cannot find the puppetfile at #{puppetfile_path}" code = 1 rescue InvalidModuleNameException => e deploy.logger.fatal e. code = 1 rescue Gitlab::Error::NotFound => e deploy.logger.fatal e. deploy.logger.fatal "Either the project does not exist or you do not have enough permissions" code = 1 rescue Exception => e deploy.logger.fatal e. deploy.logger.fatal e.backtrace.join("\n") code = 1 ensure exit code.to_i end end |
Instance Method Details
#check_requirements ⇒ Object
88 89 90 |
# File 'lib/release_manager/r10k_deployer.rb', line 88 def check_requirements raise PuppetfileNotFoundException unless File.exists?(control_repo_path) end |
#cleanup(branch = nil) ⇒ Object
31 32 33 34 |
# File 'lib/release_manager/r10k_deployer.rb', line 31 def cleanup(branch = nil) control_repo.checkout_branch(previous_branch, strategy: :force) control_repo.delete_branch(branch) if branch end |
#control_repo ⇒ Object
84 85 86 |
# File 'lib/release_manager/r10k_deployer.rb', line 84 def control_repo @control_repo ||= setup_control_repo(puppetfile.source) end |
#run ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/release_manager/r10k_deployer.rb', line 19 def run begin @previous_branch = [:src_ref] mr, branch_name = create_mr([:src_ref], [:dest_ref], [:remote]) ensure # cleanup branch, checkout previous branch end if mr puts mr.web_url end end |