r10k 1.1.0 → 1.1.1rc1

Sign up to get free protection for your applications and to get access to all the features.
@@ -60,9 +60,8 @@ class Deployment
60
60
 
61
61
  def load_sources
62
62
  sources = @config.setting(:sources)
63
- prefix = sources.length > 1
64
63
  @_sources = sources.map do |(name, hash)|
65
- R10K::Deployment::Source.vivify(name, hash, prefix)
64
+ R10K::Deployment::Source.vivify(name, hash)
66
65
  end
67
66
  end
68
67
 
@@ -0,0 +1,38 @@
1
+ require 'r10k/git/cache'
2
+ require 'r10k/deployment/environment'
3
+ require 'r10k/util/purgeable'
4
+
5
+ module R10K
6
+ class Deployment
7
+ class Basedir
8
+ # Represents a directory containing environments
9
+
10
+ def initialize(path,deployment)
11
+ @path = path
12
+ @deployment = deployment
13
+ end
14
+
15
+ include R10K::Util::Purgeable
16
+
17
+ # Return the path of the basedir
18
+ # @note This implements a required method for the Purgeable mixin
19
+ # @return [String]
20
+ def managed_directory
21
+ @path
22
+ end
23
+
24
+ # List all environments that should exist in this basedir
25
+ # @note This implements a required method for the Purgeable mixin
26
+ # @return [Array<String>]
27
+ def desired_contents
28
+ @keepers = []
29
+ @deployment.sources.each do |source|
30
+ next unless source.managed_directory == @path
31
+ @keepers += source.desired_contents
32
+ end
33
+ @keepers
34
+ end
35
+
36
+ end
37
+ end
38
+ end
@@ -1,5 +1,6 @@
1
1
  require 'r10k/git/cache'
2
2
  require 'r10k/deployment/environment'
3
+ require 'r10k/deployment/basedir'
3
4
  require 'r10k/util/purgeable'
4
5
 
5
6
  module R10K
@@ -27,6 +28,20 @@ class Source
27
28
  # @return [Array<R10K::Deployment::Environment>] All environments for this source
28
29
  attr_reader :environments
29
30
 
31
+ # Create a new source from a hash representation
32
+ #
33
+ # @param name [String] The name of the source
34
+ # @param opts [Hash] The properties to use for the source
35
+ # @param prefix [true, false] Whether to prefix the source name to created
36
+ # environments
37
+ #
38
+ # @option opts [String] :remote The git remote for the given source
39
+ # @option opts [String] :basedir The directory to create environments in
40
+ # @option opts [true, false] :prefix Whether the environment names should
41
+ # be prefixed by the source name. Defaults to false. This takes precedence
42
+ # over the `prefix` argument
43
+ #
44
+ # @return [R10K::Deployment::Source]
30
45
  def self.vivify(name, attrs, prefix = false)
31
46
  remote = (attrs.delete(:remote) || attrs.delete('remote'))
32
47
  basedir = (attrs.delete(:basedir) || attrs.delete('basedir'))
@@ -102,21 +102,14 @@ module Deployment
102
102
 
103
103
  def initialize(deployment)
104
104
  @deployment = deployment
105
+ @basedirs = @deployment.sources.map { |x| x.basedir }.uniq
105
106
  end
106
107
 
107
108
  def call
108
- @deployment.sources.each do |source|
109
- stale_envs = source.stale_contents
110
-
111
- dir = source.managed_directory
112
-
113
- if stale_envs.empty?
114
- logger.debug "No stale environments in #{dir}"
115
- else
116
- logger.info "Purging stale environments from #{dir}"
117
- logger.debug "Stale modules in #{dir}: #{stale_envs.join(', ')}"
118
- source.purge!
119
- end
109
+ @basedirs.each do |path|
110
+ basedir = R10K::Deployment::Basedir.new(path,@deployment)
111
+ logger.info "Purging stale environments from #{path}"
112
+ basedir.purge!
120
113
  end
121
114
  end
122
115
  end
data/lib/r10k/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module R10K
2
- VERSION = '1.1.0'
2
+ VERSION = '1.1.1rc1'
3
3
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: r10k
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
5
- prerelease:
4
+ version: 1.1.1rc1
5
+ prerelease: 5
6
6
  platform: ruby
7
7
  authors:
8
8
  - Adrien Thebo
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-10-07 00:00:00.000000000 Z
12
+ date: 2013-12-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: colored
@@ -135,6 +135,7 @@ files:
135
135
  - lib/r10k/deployment/environment.rb
136
136
  - lib/r10k/deployment/config/loader.rb
137
137
  - lib/r10k/deployment/config.rb
138
+ - lib/r10k/deployment/basedir.rb
138
139
  - lib/r10k/deployment/source.rb
139
140
  - lib/r10k/util/purgeable.rb
140
141
  - lib/r10k/cli/environment.rb
@@ -172,8 +173,43 @@ files:
172
173
  - spec/unit/settings/container_spec.rb
173
174
  - spec/unit/module/forge_spec.rb
174
175
  homepage: http://github.com/adrienthebo/r10k
175
- licenses: []
176
- post_install_message:
176
+ licenses:
177
+ - Apache 2.0
178
+ post_install_message: ! 'NOTICE
179
+
180
+ ======
181
+
182
+
183
+ If you are upgrading from 1.1.0 and are using multiple sources, please read
184
+
185
+ this. (If not, feel free to continue with your regularly scheduled day.)
186
+
187
+
188
+ GH-48 (https://github.com/adrienthebo/r10k/issues/48) introduced the ability
189
+
190
+ for environments to be prefixed with the source name so that multiple sources
191
+
192
+ installed into the same directory would not overwrite each other. However
193
+
194
+ prefixing was automatically enabled and would break existing setups where
195
+
196
+ multiple sources were cloned into different directories.
197
+
198
+
199
+ Because this introduced a breaking change, SemVer dictates that the automatic
200
+
201
+ prefixing has to be rolled back. Prefixing can be enabled but always defaults
202
+
203
+ to off. If you are relying on this behavior you will need to update your r10k.yaml
204
+
205
+ to enable prefixing on a per-source basis.
206
+
207
+
208
+ Please see the issue (https://github.com/adrienthebo/r10k/issues/48) for more
209
+
210
+ information.
211
+
212
+ '
177
213
  rdoc_options: []
178
214
  require_paths:
179
215
  - lib
@@ -186,9 +222,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
186
222
  required_rubygems_version: !ruby/object:Gem::Requirement
187
223
  none: false
188
224
  requirements:
189
- - - ! '>='
225
+ - - ! '>'
190
226
  - !ruby/object:Gem::Version
191
- version: '0'
227
+ version: 1.3.1
192
228
  requirements: []
193
229
  rubyforge_project:
194
230
  rubygems_version: 1.8.23