gantree 0.6.1 → 0.6.2

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: f2ae59a84ba4cc1cbf6268302812a9f0967d5ab0
4
- data.tar.gz: 7a2eaf75e5402e6359d7139840eddf2dfde682f9
3
+ metadata.gz: f7097d09fb40c111aa6e5dd2d8321dfc72352573
4
+ data.tar.gz: f329a9331b10fddbc1b4992e2df9625a0eeb7642
5
5
  SHA512:
6
- metadata.gz: 8603d40c915d2a0c5b8f6a5be9a5c417a9410d462b95b0c5a3f8a007263d5c48705eecaa274468e864e573e613c2258b13df32769949d21f190e7bbb1889684c
7
- data.tar.gz: 6b4161e9c89dfe8e1368f4969a89cf94c3792045b9d741c6e27192717f5feefa5ca98979b3674c0a3584e903ca6e38d51da3e5c6f5592a1b016bc1f6545fea6a
6
+ metadata.gz: 6baaee7fc76003a556a8f2c47b30e56fd6c0b70eea6556c2c1ebdb9aca930180b5ca18d730ba36bee9aa747d76ac2cbbcf7d80205d8208e97c505ee183bfdc74
7
+ data.tar.gz: f4f5f8570cf4ee3f0055a128b595c9ba068d9a79ef50681d0548543b2b92b8bbb3ea3279e646a05f71b11eb7fce3fa4458e1d934b401eb52e7a26739870b7351
data/.gitignore CHANGED
@@ -18,3 +18,5 @@ test/version_tmp
18
18
  tmp
19
19
  cfn/*
20
20
  tmp.txt
21
+
22
+ spec/fixtures/project/*.zip
@@ -17,6 +17,7 @@ module Gantree
17
17
  option :image_path, :aliases => "-i", :desc => "docker hub image path ex. (bleacher/cms | quay.io/bleacherreport/cms)"
18
18
  option :autodetect_app_role, :desc => "use naming convention to determin role (true|false)", :type => :boolean, :default => true
19
19
  option :eb_bucket, :desc => "bucket to store elastic beanstalk versions"
20
+ option :auth, :desc => "dockerhub authentation, example: bucket/key"
20
21
  def deploy name
21
22
  opts = merge_defaults(options)
22
23
  Gantree::Base.check_for_updates(opts)
@@ -98,6 +99,7 @@ module Gantree
98
99
  option :image_path, :aliases => "-i", :desc => "hub image path ex. (bleacher/cms | quay.io/bleacherreport/cms)"
99
100
  option :hush, :desc => "quite puts messages", :default => true
100
101
  option :eb_bucket, :desc => "bucket to store elastic beanstalk versions"
102
+ option :auth, :desc => "dockerhub authentation, example: bucket/key"
101
103
  def ship server
102
104
  opts = merge_defaults(options)
103
105
  Gantree::Base.check_for_updates(opts)
@@ -6,11 +6,13 @@ require_relative 'notification'
6
6
  module Gantree
7
7
  class DeployVersion < Deploy
8
8
 
9
+ attr_reader :packaged_version, :dockerrun_file
9
10
  def initialize options, env
10
11
  @options = options
11
12
  @ext = @options[:ext]
12
13
  @ext_role = @options[:ext_role]
13
- @dockerrun_file = "Dockerrun.aws.json"
14
+ @project_root = @options[:project_root]
15
+ @dockerrun_file = "#{@project_root}Dockerrun.aws.json"
14
16
  @env = env
15
17
  end
16
18
 
@@ -18,18 +20,32 @@ module Gantree
18
20
  @packaged_version = create_version_files
19
21
  end
20
22
 
23
+ def docker
24
+ @docker ||= JSON.parse(IO.read(@dockerrun_file))
25
+ end
26
+
27
+ def set_auth
28
+ docker["Authentication"] = {}
29
+ items = @options[:auth].split("/")
30
+ bucket = items.shift
31
+ key = items.join("/")
32
+ docker["Authentication"]["Bucket"] = bucket
33
+ docker["Authentication"]["Key"] = key
34
+ IO.write("/tmp/#{@dockerrun_file}", JSON.pretty_generate(docker))
35
+ end
36
+
21
37
  def set_tag_to_deploy
22
- docker = JSON.parse(IO.read(@dockerrun_file))
23
38
  image = docker["Image"]["Name"]
24
39
  image.gsub!(/:(.*)$/, ":#{@options[:tag]}")
25
40
  IO.write("/tmp/#{@dockerrun_file}", JSON.pretty_generate(docker))
26
41
  end
27
42
 
28
43
  def set_image_path
29
- docker = JSON.parse(IO.read(@dockerrun_file))
30
44
  image = docker["Image"]["Name"]
31
45
  image.gsub!(/(.*):/, "#{@options[:image_path]}:")
32
- IO.write("/tmp/#{@dockerrun_file}", JSON.pretty_generate(docker))
46
+ path = "/tmp/#{@dockerrun_file}"
47
+ FileUtils.mkdir_p(File.dirname(path)) unless File.exist?(path)
48
+ IO.write(path, JSON.pretty_generate(docker))
33
49
  image
34
50
  end
35
51
 
@@ -37,10 +53,11 @@ module Gantree
37
53
  clean_up
38
54
  version = "#{tag}-#{Time.now.strftime("%m-%d-%Y-%H-%M-%S")}"
39
55
  puts "version: #{version}"
56
+ set_auth if @options[:auth]
40
57
  set_image_path if @options[:image_path]
41
58
  set_tag_to_deploy
42
59
  if File.directory?(".ebextensions/") || @ext || @ext_role
43
- zip = "#{version}.zip"
60
+ zip = "#{@project_root}#{version}.zip"
44
61
  merge_extensions
45
62
  puts "The following files are being zipped".yellow
46
63
  system('ls -l /tmp/merged_extensions/.ebextensions/')
@@ -1,3 +1,3 @@
1
1
  module Gantree
2
- VERSION = "0.6.1"
2
+ VERSION = "0.6.2"
3
3
  end
@@ -0,0 +1,13 @@
1
+ {
2
+ "AWSEBDockerrunVersion": "1",
3
+ "Image": {
4
+ "Name": "bleacher/carburetor",
5
+ "Update": true
6
+ },
7
+ "Logging": "/var/log/nginx",
8
+ "Ports": [
9
+ {
10
+ "ContainerPort": "300"
11
+ }
12
+ ]
13
+ }
@@ -0,0 +1,40 @@
1
+ require "spec_helper"
2
+
3
+ describe Gantree::DeployVersion do
4
+ before(:all) do
5
+ end
6
+
7
+ after(:all) do
8
+ FileUtils.rm_f(Dir.glob("spec/fixtures/project/*.zip"))
9
+ end
10
+
11
+ it "should create package version" do
12
+ @options = {
13
+ :ext => "git@github.com:br/.ebextensions.git",
14
+ :tag => "br-develop_mkemnitz-30b9bf6",
15
+ :image_path => "bleacher/carburetor",
16
+ :project_root => "spec/fixtures/project/"
17
+ }
18
+ @env = "stag-carburetor-app-s1"
19
+ @version = Gantree::DeployVersion.new(@options, @env)
20
+ packaged_version = @version.run
21
+ expect(File.exist?(packaged_version)).to be true
22
+ end
23
+
24
+ it "should add auth info" do
25
+ @options = {
26
+ :ext => "git@github.com:br/.ebextensions.git",
27
+ :tag => "br-develop_mkemnitz-30b9bf6",
28
+ :image_path => "bleacher/carburetor",
29
+ :project_root => "spec/fixtures/project/",
30
+ :auth => "docker-cfgs/brops.dockercfg"
31
+ }
32
+ @env = "stag-carburetor-app-s1"
33
+ @version = Gantree::DeployVersion.new(@options, @env)
34
+ @version.set_auth
35
+ data = JSON.parse(IO.read("/tmp/#{@version.dockerrun_file}"))
36
+ expect(data["Authentication"]["Bucket"]).to eq "docker-cfgs"
37
+ expect(data["Authentication"]["Key"]).to eq "brops.dockercfg"
38
+ end
39
+
40
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gantree
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Felix
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-11 00:00:00.000000000 Z
11
+ date: 2015-06-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -315,9 +315,11 @@ files:
315
315
  - lib/gantree/release_notes.rb
316
316
  - lib/gantree/update.rb
317
317
  - lib/gantree/version.rb
318
+ - spec/fixtures/project/Dockerrun.aws.json
318
319
  - spec/lib/gantree/1_release_notes_spec.rb
319
320
  - spec/lib/gantree/cli_spec.rb
320
321
  - spec/lib/gantree/deploy_spec.rb
322
+ - spec/lib/gantree/deploy_version_spec.rb
321
323
  - spec/lib/gantree/docker_spec.rb
322
324
  - spec/lib/gantree/init_spec.rb
323
325
  - spec/spec_helper.rb
@@ -349,9 +351,11 @@ summary: This tool is intended to help you setup a Dockerrun.aws.json which allo
349
351
  allows you to do versioned deploys to your Elastic Beanstalk application and create
350
352
  an archive of every versioned Dockerrun.aws.json in amazons s3 bucket service.
351
353
  test_files:
354
+ - spec/fixtures/project/Dockerrun.aws.json
352
355
  - spec/lib/gantree/1_release_notes_spec.rb
353
356
  - spec/lib/gantree/cli_spec.rb
354
357
  - spec/lib/gantree/deploy_spec.rb
358
+ - spec/lib/gantree/deploy_version_spec.rb
355
359
  - spec/lib/gantree/docker_spec.rb
356
360
  - spec/lib/gantree/init_spec.rb
357
361
  - spec/spec_helper.rb