class Bosh::Cli::Command::DeploymentPatch
Public Instance Methods
apply(deployment_patch)
click to toggle source
# File lib/bosh/cli/commands/deployment_patch.rb, line 20 def apply(deployment_patch) experimental_banner require_project_deployment @patch = Bosh::Workspace::DeploymentPatch.from_file(deployment_patch) validate_deployment_patch(@patch, deployment_patch) if current_deployment_patch.changes?(@patch) if !options[:dry_run] fetch_repo(templates_dir) if @patch.templates_ref @patch.apply(current_deployment_file, templates_dir) commit_all unless options[:no_commit] say "Successfully applied deployment patch:" else say "Deployment patch:" end say patch_changes_table else say "No changes, nothing to do" end end
create(deployment_patch)
click to toggle source
# File lib/bosh/cli/commands/deployment_patch.rb, line 9 def create(deployment_patch) experimental_banner require_project_deployment current_deployment_patch.to_file(deployment_patch) say "Wrote patch to #{deployment_patch}" end
Private Instance Methods
changes_message()
click to toggle source
# File lib/bosh/cli/commands/deployment_patch.rb, line 91 def changes_message "Applied " + patch_changes.map { |k, v| "#{k} #{v}" }.join(', ').to_s end
commit_all()
click to toggle source
# File lib/bosh/cli/commands/deployment_patch.rb, line 71 def commit_all index = repo.index index.read_tree(repo.head.target.tree) index.add_all options = { tree: index.write_tree(repo), message: changes_message, update_ref: 'HEAD' } Rugged::Commit.create(repo, options) end
current_deployment_file()
click to toggle source
# File lib/bosh/cli/commands/deployment_patch.rb, line 52 def current_deployment_file @current_deployment_file ||= project_deployment.file end
current_deployment_patch()
click to toggle source
# File lib/bosh/cli/commands/deployment_patch.rb, line 56 def current_deployment_patch @current_deployment_patch ||= begin Bosh::Workspace::DeploymentPatch .create(current_deployment_file, templates_dir) end end
patch_changes()
click to toggle source
# File lib/bosh/cli/commands/deployment_patch.rb, line 87 def patch_changes @patch_changes ||= current_deployment_patch.changes(@patch) end
patch_changes_table()
click to toggle source
# File lib/bosh/cli/commands/deployment_patch.rb, line 95 def patch_changes_table table do |t| patch_changes.each { |k, v| t << [k.to_s, v] } end end
repo()
click to toggle source
# File lib/bosh/cli/commands/deployment_patch.rb, line 83 def repo @repo ||= Rugged::Repository.new(Dir.getwd) end
templates_dir()
click to toggle source
# File lib/bosh/cli/commands/deployment_patch.rb, line 48 def templates_dir File.join(Dir.getwd, 'templates') end
validate_deployment_patch(patch, file)
click to toggle source
# File lib/bosh/cli/commands/deployment_patch.rb, line 63 def validate_deployment_patch(patch, file) unless patch.valid? say("Validation errors:".make_red) patch.errors.each { |error| say("- #{error}") } err("'#{file}' is not valid".make_red) end end