clc-promote 0.2.2 → 0.3.0

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: 03b146b73d80fde7897aac34247a1e520fd3b42d
4
- data.tar.gz: 43a18fa61db3cc37daf95722c113edc4fc1d854e
3
+ metadata.gz: ea9764b3bc953678d48b097a9dca0cb3efe0f0e8
4
+ data.tar.gz: 6a3a542d184ba10a432e8454c6c57396abad764f
5
5
  SHA512:
6
- metadata.gz: f26309e4ab23c8c4cb53b8d78c1a88199ec14d8f5ec0f182484d4327b81bc4fb22d88f8102cec2e15eb14515d9e104a4859c7f0688b8cc3e269fd49ac740dcb0
7
- data.tar.gz: 78bbfee4cea9f528fc311fdc7be4f87254ac2f60a2e933793537ee4333f3e789a478f830318815caa91deef11248f7ab4f70eca5601c343ec58a1a827ff8c08e
6
+ metadata.gz: 54c999394f9ae50f659d73d459a0ebd8cdf53ff2bbf4d8ff8b3f86ed90385fcadbbdac040d9ab4a20d93c6fbd777cc5acf75229253605dfef4f0fde41fe3b751
7
+ data.tar.gz: 5dc609f13709d5595500c064f9b727ed4a2a03b2ee683ff97611433fa7da335d21a80dee845ff2633b291cb372fbe7da1303f743da66fc5a2d1862a7ba7e9be6
data/lib/promote.rb CHANGED
@@ -1,3 +1,4 @@
1
1
  require 'promote/config'
2
2
  require 'promote/uploader'
3
3
  require 'promote/versioner'
4
+ require 'promote/promoter'
@@ -0,0 +1,25 @@
1
+ require 'json'
2
+
3
+ module Promote
4
+ class Promoter
5
+ attr_accessor :config
6
+
7
+ def initialize(config = Config.new)
8
+ @config = config
9
+ end
10
+
11
+ def promote_to(source_environment, destination_environment)
12
+ source_file = File.join(config.environment_directory, "#{source_environment}.json")
13
+ dest_file = File.join(config.environment_directory, "#{destination_environment}.json")
14
+
15
+ source_content = JSON.parse(File.read(source_file))
16
+ dest_content = JSON.parse(File.read(dest_file))
17
+
18
+ dest_content['cookbook_versions'] = source_content['cookbook_versions']
19
+
20
+ File.open(dest_file, 'w') do |out|
21
+ out << JSON.pretty_generate(dest_content)
22
+ end
23
+ end
24
+ end
25
+ end
@@ -10,6 +10,7 @@ module Promote
10
10
  config = Config.new({ :repo_root => config }) if config.is_a?(String)
11
11
  @versioner = Versioner.new(config)
12
12
  @uploader = Uploader.new(config)
13
+ @promoter = Promoter.new(config)
13
14
  yield self if block_given?
14
15
  define_version_cookbook
15
16
  define_version_cookbooks
@@ -22,6 +23,7 @@ module Promote
22
23
  define_upload_environment
23
24
  define_upload_data_bags
24
25
  define_constrain_environment
26
+ define_promote_environment
25
27
  end
26
28
 
27
29
  private
@@ -79,6 +81,16 @@ module Promote
79
81
  end
80
82
  end
81
83
 
84
+ def define_promote_environment
85
+ namespace "Promote" do
86
+ desc "Promote one environment from another"
87
+ task "promote_environment", :source_environment, :destination_environment do |task, args|
88
+ puts "Promoting constraints in #{args.source_environment} to #{args.destination_environment}"
89
+ deps = @promoter.promote_environment(args.source_environment, args.destination_environment)
90
+ end
91
+ end
92
+ end
93
+
82
94
  def define_version_environments
83
95
  namespace "Promote" do
84
96
  desc "Version all environments"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: clc-promote
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - CenturyLink Cloud
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-30 00:00:00.000000000 Z
11
+ date: 2014-10-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chef
@@ -114,6 +114,7 @@ files:
114
114
  - README.md
115
115
  - lib/promote.rb
116
116
  - lib/promote/config.rb
117
+ - lib/promote/promoter.rb
117
118
  - lib/promote/rake_tasks.rb
118
119
  - lib/promote/uploader.rb
119
120
  - lib/promote/versioner.rb