release_manager 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 29e40c47ad25725e971c4fd352be640e3c099aa1
4
- data.tar.gz: 262a70fdf287925fca29d271163b5b13a0681225
3
+ metadata.gz: 47cc71432241b0b10115b5730f655155d924a5b7
4
+ data.tar.gz: 70d78fd3692ac03350d146b3bbf7d11b366d64d9
5
5
  SHA512:
6
- metadata.gz: 8abb760003a84f0be08fcc20cd7705b238f033aa9c5a0eece9d73c60b5b1514e0ad5ec3b96e7439414cd5cf07faef492a6fa82ec6818b7a8d9f2e9a29880382e
7
- data.tar.gz: f44e93faaa946b2732adb4654db2a37f85539d6a395d697961fe52a55926ea83ab54d86c3043d45e2b643da6f240ae25df330cd84cca4615ea3468b6045b53da
6
+ metadata.gz: bbe4f0be2de2b5c224756271320f97a78c79d2e65bdee416c8eeb19ac7bd7ad4f4c23889f0ba81305189c32f05c85bd2ab1c05a57732aaf0bf61d7fdaae09dca
7
+ data.tar.gz: eb61addaa6bc1c3fcd7f9e2248995055d75e707b3db6155a1705c74d10180c9618345cea13fc6915569da421113c79b4f6bcaf3e3eb9670b472777115140ae90
@@ -1,6 +1,6 @@
1
1
  # Release Manager
2
- ## Unreleased
3
-
2
+ ## v0.3.1
3
+ * Adds ability to add the module to the puppetfile at deployment time
4
4
  ## v0.3.0
5
5
  * Fixes color with fatal errors
6
6
  * Changes PuppetModule to use rugged commit commands
data/Gemfile CHANGED
@@ -2,6 +2,7 @@ source ENV['GEM_SOURCE'] ||'https://rubygems.org'
2
2
  # Specify your gem's dependencies in release_manager.gemspec
3
3
  gem 'gitlab', '~> 3.7.0'
4
4
  gem 'rugged'
5
+ gem 'highline', '~> 1.7'
5
6
 
6
7
  group :test do
7
8
  gem 'pry'
@@ -1,8 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- release_manager (0.3.0)
4
+ release_manager (0.3.1)
5
5
  gitlab (~> 3.7.0)
6
+ highline (~> 1.7)
6
7
  rugged
7
8
 
8
9
  GEM
@@ -14,6 +15,7 @@ GEM
14
15
  gitlab (3.7.0)
15
16
  httparty (~> 0.13.0)
16
17
  terminal-table
18
+ highline (1.7.8)
17
19
  httparty (0.13.7)
18
20
  json (~> 1.8)
19
21
  multi_xml (>= 0.5.2)
@@ -61,6 +63,7 @@ PLATFORMS
61
63
  DEPENDENCIES
62
64
  bundler
63
65
  gitlab (~> 3.7.0)
66
+ highline (~> 1.7)
64
67
  pry
65
68
  rake
66
69
  release_manager!
data/README.md CHANGED
@@ -13,6 +13,7 @@ __________ .__ _____
13
13
  **Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)*
14
14
 
15
15
  - [ReleaseManager](#releasemanager)
16
+ - [Prerequisites](#prerequisites)
16
17
  - [Installation](#installation)
17
18
  - [Install directly from source](#install-directly-from-source)
18
19
  - [The workflow problem](#the-workflow-problem)
@@ -25,6 +26,7 @@ __________ .__ _____
25
26
  - [bump-changelog](#bump-changelog)
26
27
  - [Configuration Settings](#configuration-settings)
27
28
  - [Sandbox-create environment variables](#sandbox-create-environment-variables)
29
+ - [Ssh agent usage](#ssh-agent-usage)
28
30
  - [Development](#development)
29
31
  - [Contributing](#contributing)
30
32
  - [License](#license)
@@ -35,6 +37,17 @@ __________ .__ _____
35
37
 
36
38
  This gem provides workflow automations around releasing and deploying puppet modules within r10k environments.
37
39
 
40
+ ## Prerequisites
41
+
42
+ 1. Must be running Gitlab 8.16+
43
+ 2. Must be using ssh keys with gitlab
44
+ 3. Must be using ssh-agent to handle git authentication
45
+ 4. Must be using Git
46
+ 5. Must be using r10k
47
+ 6. Must have a r10k-control repo (name can vary)
48
+ 7. Must have a Gitlab API Access token (per user)
49
+
50
+
38
51
  ## Installation
39
52
 
40
53
  Add this line to your application's Gemfile:
@@ -57,9 +70,7 @@ directly from source.
57
70
 
58
71
  ```
59
72
  gem install specific_install # unless already installed
60
- gem specific_install <git url to release manager>
61
-
62
- ie. gem specific_install git@github.com/nwops/release_manager.git
73
+ gem specific_install https://github.com/nwops/release_manager
63
74
  ```
64
75
 
65
76
 
@@ -1,8 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
  require_relative 'puppetfile'
3
3
  require_relative 'puppet_module'
4
+ require 'highline/import'
5
+
4
6
  class ModuleDeployer
5
7
  attr_reader :options
8
+ include ReleaseManager::Logger
6
9
 
7
10
  def initialize(opts)
8
11
  opts[:modulepath] = Dir.getwd if opts[:modulepath].nil?
@@ -38,38 +41,51 @@ class ModuleDeployer
38
41
  @puppetfile ||= Puppetfile.new(puppetfile_path)
39
42
  end
40
43
 
44
+ # @param [PuppetModule] puppet_module - the puppet module to check for existance
45
+ # raises
46
+ def add_module(puppet_module)
47
+ unless puppetfile.mod_exists?(puppet_module.name)
48
+ answer = ask("The #{puppet_module.name} module does not exist, do you want to add it? (y/n): ", String) { |q| q =~ /y|n/i }.downcase
49
+ if answer == 'y'
50
+ puppetfile.add_module(puppet_module.name, git: puppet_module.repo, tag: "v#{puppet_module.version}") unless options[:dry_run]
51
+ end
52
+ end
53
+ end
54
+
41
55
  def run
42
56
  begin
43
57
  check_requirements
44
- puts "Found module #{puppet_module.name} with version: #{latest_version}".green
58
+ logger.info "Deploying module #{puppet_module.name} with version: #{latest_version}"
45
59
  if options[:dry_run]
60
+ add_module(puppet_module)
46
61
  puts "Would have updated module #{puppet_module.name} in Puppetfile to version: #{latest_version}".green
47
62
  puts "Would have committed with message: bump #{puppet_module.name} to version: #{latest_version}".green if options[:commit]
48
63
  puts "Would have just pushed branch: #{puppetfile.current_branch} to remote: #{control_repo_remote}".green if options[:push]
49
64
  else
50
- puts "Updated module #{puppet_module.name} in Puppetfile to version: #{latest_version}".green
65
+ add_module(puppet_module)
51
66
  puppetfile.write_version(puppet_module.name, latest_version)
52
67
  puppetfile.write_source(puppet_module.name, puppet_module.source)
53
68
  puppetfile.write_to_file
69
+ logger.info "Updated module #{puppet_module.name} in Puppetfile to version: #{latest_version}"
54
70
  if options[:commit]
55
71
  puppetfile.commit("bump #{puppet_module.name} to version #{latest_version}")
56
- puts "Commited with message: bump #{puppet_module.name} to version #{latest_version}".green
72
+ logger.info "Commited with message: bump #{puppet_module.name} to version #{latest_version}"
57
73
  end
58
74
  if options[:push]
59
75
  puppetfile.push(control_repo_remote, puppetfile.current_branch)
60
- puts "Just pushed branch: #{puppetfile.current_branch} to remote: #{control_repo_remote}".green
76
+ logger.info "Just pushed branch: #{puppetfile.current_branch} to remote: #{control_repo_remote}"
61
77
  end
62
78
  end
63
79
  rescue InvalidMetadataSource
64
- puts "The puppet module's metadata.json source field must be a git url: ie. git@someserver.com:devops/module.git".red
80
+ logger.fatal "The puppet module's metadata.json source field must be a git url: ie. git@someserver.com:devops/module.git"
65
81
  rescue PuppetfileNotFoundException
66
- puts "Cannot find the puppetfile at #{puppetfile_path}".red
82
+ logger.fatal "Cannot find the puppetfile at #{puppetfile_path}"
67
83
  exit -1
68
84
  rescue InvalidModuleNameException => e
69
- puts e.message
85
+ logger.fatal e.message
70
86
  exit 1
71
87
  rescue ModNotFoundException
72
- puts "Invalid module path for #{mod_path}".red
88
+ logger.fatal "Invalid module path for #{mod_path}"
73
89
  puts "This means that the metadata.json name field does not match\nthe module name found in the Puppetfile or this is not a puppet module".fatal
74
90
  exit -1
75
91
  end
@@ -89,6 +89,16 @@ class Puppetfile
89
89
  mod
90
90
  end
91
91
 
92
+ # @param [String] name - the name of the mod you wish to find in the puppetfile
93
+ # @return [Boolean] - true if the module is found
94
+ def mod_exists?(name)
95
+ begin
96
+ !!find_mod(name)
97
+ rescue InvalidModuleNameException
98
+ false
99
+ end
100
+ end
101
+
92
102
  def write_version(mod_name, version)
93
103
  mod = find_mod(mod_name)
94
104
  mod.pin_version(version)
@@ -1,3 +1,3 @@
1
1
  module ReleaseManager
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
@@ -31,6 +31,7 @@ Gem::Specification.new do |spec|
31
31
  spec.require_paths = ["lib"]
32
32
  spec.add_runtime_dependency "gitlab", "~>3.7.0"
33
33
  spec.add_runtime_dependency "rugged"
34
+ spec.add_runtime_dependency "highline", '~> 1.7'
34
35
  spec.add_development_dependency "bundler", "~> 1.14"
35
36
  spec.add_development_dependency "pry"
36
37
  spec.add_development_dependency "rake", "~> 10.0"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: release_manager
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Corey Osman
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-05-15 00:00:00.000000000 Z
11
+ date: 2017-05-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gitlab
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: highline
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '1.7'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.7'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: bundler
43
57
  requirement: !ruby/object:Gem::Requirement