ebim 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 692418d14d7ae1e75a5a8c1296b4fa1a71f6c84535bddc73898b6b6ee0737c09
4
+ data.tar.gz: 9097e68a9e2ea3f250cd302f1eb2697b360e5e81afe870adba6d2d0eaf13c489
5
+ SHA512:
6
+ metadata.gz: 7dd157505d17bd6ece99dfe2ed8b52cd11d991059aa7ac0d0f2236bf2ea9d2eb65ac9748535e46c2289adcd1d51905b25458f513d22c539a422175b472f69df0
7
+ data.tar.gz: 6b5e0518edc80d52fb0a263be36c37ae7d1e9c47b4cea43def4b322b9f8e42c598d79f12b01661be9a5cd71ec76f46dadbee5aba52d160f52af0a0efb7632f59
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /spec/playground/
9
+ /tmp/
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,6 @@
1
+ ---
2
+ language: ruby
3
+ cache: bundler
4
+ rvm:
5
+ - 2.7.1
6
+ before_install: gem install bundler -v 2.1.4
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in ebim.gemspec
4
+ gemspec
5
+
6
+ gem "rake", "~> 12.0"
7
+ gem "rspec", "~> 3.0"
@@ -0,0 +1,74 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ ebim (0.0.1)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ aruba (1.0.0)
10
+ childprocess (~> 3.0)
11
+ contracts (~> 0.16.0)
12
+ cucumber (>= 2.4, < 4.0)
13
+ ffi (~> 1.9)
14
+ rspec-expectations (~> 3.4)
15
+ thor (~> 1.0)
16
+ backports (3.17.1)
17
+ builder (3.2.4)
18
+ childprocess (3.0.0)
19
+ coderay (1.1.2)
20
+ contracts (0.16.0)
21
+ cucumber (3.1.2)
22
+ builder (>= 2.1.2)
23
+ cucumber-core (~> 3.2.0)
24
+ cucumber-expressions (~> 6.0.1)
25
+ cucumber-wire (~> 0.0.1)
26
+ diff-lcs (~> 1.3)
27
+ gherkin (~> 5.1.0)
28
+ multi_json (>= 1.7.5, < 2.0)
29
+ multi_test (>= 0.1.2)
30
+ cucumber-core (3.2.1)
31
+ backports (>= 3.8.0)
32
+ cucumber-tag_expressions (~> 1.1.0)
33
+ gherkin (~> 5.0)
34
+ cucumber-expressions (6.0.1)
35
+ cucumber-tag_expressions (1.1.1)
36
+ cucumber-wire (0.0.1)
37
+ diff-lcs (1.3)
38
+ ffi (1.12.2)
39
+ gherkin (5.1.0)
40
+ method_source (1.0.0)
41
+ multi_json (1.14.1)
42
+ multi_test (0.1.2)
43
+ pry (0.13.1)
44
+ coderay (~> 1.1)
45
+ method_source (~> 1.0)
46
+ rake (12.3.3)
47
+ rspec (3.9.0)
48
+ rspec-core (~> 3.9.0)
49
+ rspec-expectations (~> 3.9.0)
50
+ rspec-mocks (~> 3.9.0)
51
+ rspec-core (3.9.1)
52
+ rspec-support (~> 3.9.1)
53
+ rspec-expectations (3.9.1)
54
+ diff-lcs (>= 1.2.0, < 2.0)
55
+ rspec-support (~> 3.9.0)
56
+ rspec-mocks (3.9.1)
57
+ diff-lcs (>= 1.2.0, < 2.0)
58
+ rspec-support (~> 3.9.0)
59
+ rspec-support (3.9.2)
60
+ thor (1.0.1)
61
+
62
+ PLATFORMS
63
+ ruby
64
+
65
+ DEPENDENCIES
66
+ aruba
67
+ cucumber
68
+ ebim!
69
+ pry
70
+ rake (~> 12.0)
71
+ rspec (~> 3.0)
72
+
73
+ BUNDLED WITH
74
+ 2.1.4
@@ -0,0 +1,36 @@
1
+ # Ebim
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/ebim`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'ebim'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle install
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install ebim
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/ebim.
36
+
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "ebim"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,34 @@
1
+ require_relative 'lib/ebim/version'
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "ebim"
5
+
6
+ spec.description = <<-eos
7
+ AWS Elatic Beanstalk CLI, awsebcli, does not provide option to set environment specific conviguration.
8
+ For example, if you want to set different env variables on AWS EB using .ebextensions it is not supported. This wrapper makes it possible!
9
+ eos
10
+
11
+ spec.email = ["tannakartikey@gmail.com"]
12
+ spec.authors = ["Kartikey Tanna"]
13
+ spec.homepage = "https://github.com/tannakartikey/ebim"
14
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
15
+
16
+ spec.metadata["homepage_uri"] = spec.homepage
17
+ spec.metadata["source_code_uri"] = "https://github.com/tannakartikey/ebim"
18
+
19
+ # Specify which files should be added to the gem when it is released.
20
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
21
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
22
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
23
+ end
24
+
25
+ spec.bindir = "exe"
26
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
27
+ spec.require_paths = ["lib"]
28
+ spec.summary = "AWS Elastic Beanstalk wrapper for environment speicific deplyoment from the same branch using .ebextensions!"
29
+ spec.version = Ebim::VERSION
30
+
31
+ spec.add_development_dependency "cucumber"
32
+ spec.add_development_dependency "aruba"
33
+ spec.add_development_dependency "pry"
34
+ end
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ args = ARGV.join(" ")
4
+ puts "Firing: eb #{args}"
5
+
6
+ system("eb #{args}")
7
+ # `#{ARGV.join(" ")}`
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'ebim/cli'
4
+
5
+ Ebim::CLI.start(ARGV)
@@ -0,0 +1,7 @@
1
+ require "ebim/version"
2
+ require "thor"
3
+
4
+ module Ebim
5
+ class Error < StandardError; end
6
+ require 'ebim/runner'
7
+ end
@@ -0,0 +1,14 @@
1
+ require "ebim/runner"
2
+ require "thor"
3
+
4
+ module Ebim
5
+ class CLI
6
+ def self.start(args)
7
+ begin
8
+ Runner.run(args)
9
+ rescue => err
10
+ puts err.message
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,44 @@
1
+ require 'ebim/eb'
2
+
3
+ class CommandEnvironment
4
+ EB_FOLDERS = ['.ebextensions', '.elasticbeanstalk']
5
+ def initialize(env:, ebextensions:)
6
+ @env = env
7
+ @ebextensions = ebextensions
8
+ @files_created = []
9
+ end
10
+
11
+ def setup
12
+ EB_FOLDERS.map { |folder| create_config_file_from_env folder }
13
+ `git add .ebextensions .elasticbeanstalk`
14
+ `git -c user.name='ebim user' -c user.email='test@ebim.dev' commit -m 'temp commit by ebim'`
15
+ end
16
+
17
+ def teardown
18
+ `git reset HEAD~1`
19
+ files_created.map { |file| FileUtils.rm(file) }
20
+ end
21
+
22
+ private
23
+
24
+ def create_config_file_from_env(folder)
25
+ Dir.entries(folder).filter do |file|
26
+ file_env = file.split('.').last
27
+ if file_env == env
28
+ new_file_name = File.basename(file, ".#{env}")
29
+ new_file = File.new("#{folder}/#{new_file_name}", "w+")
30
+ FileUtils.copy_file("#{folder}/#{file}", new_file)
31
+ new_file.close
32
+ files_created << new_file
33
+ end
34
+ end
35
+ end
36
+
37
+ def get_env_files
38
+ Dir.entries
39
+ end
40
+
41
+ attr_reader :env, :ebextensions
42
+ attr_accessor :files_created
43
+ end
44
+
@@ -0,0 +1,55 @@
1
+ require 'ebim'
2
+
3
+ module Ebim
4
+ class Deploy
5
+ class << self
6
+ def run(args)
7
+ if args.length < 1
8
+ puts "Args not right"
9
+ return false
10
+ end
11
+ new(args).run
12
+ end
13
+ end
14
+
15
+ def initialize(args)
16
+ ebextensions_exist?
17
+
18
+ @files = list_files
19
+ @env = args.shift
20
+ @args = args
21
+
22
+ check_files_for_env
23
+ end
24
+
25
+ def run
26
+ command = "eb #{serialized_args}"
27
+ puts "[ENV: #{env}] Firing: #{command}"
28
+ exec(command)
29
+ end
30
+
31
+ private
32
+
33
+ def serialized_args
34
+ @_serialized_args ||= args.join(" ")
35
+ end
36
+
37
+ def ebextensions_exist?
38
+ raise Ebim::Error.new( ".ebextensions not present") unless Dir.exist?('.ebextensions')
39
+ end
40
+
41
+ def check_files_for_env
42
+ raise Ebim::Error.new( "No config files with env: #{env} present!") unless config_files_with_env_present?
43
+ end
44
+
45
+ def config_files_with_env_present?
46
+ files.map { |file| file.split('.').last }.include? env
47
+ end
48
+
49
+ def list_files
50
+ Dir.entries(".ebextensions")
51
+ end
52
+
53
+ attr_accessor :files, :env, :args
54
+ end
55
+ end
@@ -0,0 +1,52 @@
1
+ require 'ebim'
2
+
3
+ class EB
4
+ EB_FOLDERS = ['.ebextensions', '.elasticbeanstalk']
5
+ def initialize(env:)
6
+ @env = env
7
+ end
8
+
9
+ def exist?
10
+ EB_FOLDERS.map { |folder| folder_exists? folder }
11
+ end
12
+
13
+ def has_ebextension_configs?
14
+ raise Ebim::Error.new( "No config files with env: #{env} present!") unless files_with_env_present?(ebextension_configs)
15
+ end
16
+
17
+ def has_eb_config?
18
+ raise Ebim::Error.new( "No config files with env: #{env} present!") unless files_with_env_present?(eb_config)
19
+ end
20
+
21
+ def get_config_files
22
+ all_config_files.select { |file| file.split('.').last == env }
23
+ end
24
+
25
+ private
26
+
27
+ def all_config_files
28
+ EB_FOLDERS.map { |folder| Dir.entries(folder) }.flatten
29
+ end
30
+
31
+ def ebextension_configs
32
+ @ebextension_configs ||= list_files(".ebextensions")
33
+ end
34
+
35
+ def eb_config
36
+ @_eb_config ||= list_files(".elasticbeanstalk")
37
+ end
38
+
39
+ def list_files dir
40
+ Dir.entries(dir)
41
+ end
42
+
43
+ def files_with_env_present?(files)
44
+ files.map { |file| file.split('.').last }.include? env
45
+ end
46
+
47
+ def folder_exists? folder
48
+ raise Ebim::Error.new("#{folder} not present") unless Dir.exist?(folder)
49
+ end
50
+
51
+ attr_accessor :env, :args
52
+ end
@@ -0,0 +1,56 @@
1
+ require 'open3'
2
+ require 'ebim'
3
+ require 'ebim/eb'
4
+ require 'ebim/command_environment'
5
+
6
+ module Ebim
7
+ class Runner
8
+ class << self
9
+ def run(args)
10
+ if args.length < 1
11
+ puts "Args not right"
12
+ return false
13
+ end
14
+ new(args).run
15
+ end
16
+ end
17
+
18
+ def initialize(args)
19
+ @env = args.shift
20
+ @args = args
21
+
22
+ @ebextensions = EB.new(env: env)
23
+ @ebextensions.exist?
24
+ @ebextensions.has_eb_config?
25
+ @ebextensions.has_ebextension_configs?
26
+ end
27
+
28
+ def run
29
+ command_environment = CommandEnvironment.new(env: env, ebextensions: @ebextensions)
30
+ command_environment.setup
31
+ execute_command
32
+ command_environment.teardown
33
+ end
34
+
35
+ private
36
+
37
+ def execute_command
38
+ command = "eb #{serialized_args}"
39
+ puts "[ENV: #{env}] Firing: #{command}"
40
+ Open3.popen3(command) do |stdin, stdout, stderr, wait_thr|
41
+ while line=stdout.gets do
42
+ puts line
43
+ end
44
+ while line=stderr.gets do
45
+ puts line
46
+ end
47
+ end
48
+ end
49
+
50
+ def serialized_args
51
+ @_serialized_args ||= args.join(" ")
52
+ end
53
+
54
+ attr_accessor :env, :args
55
+ end
56
+ end
@@ -0,0 +1,18 @@
1
+ class CommandEnvironment
2
+ def initialize(env:)
3
+ env = @env
4
+ end
5
+
6
+ def setup
7
+ File.rename('.elasticbeanstalk/config.yml.staging', '.elasticbeanstalk/config.yml')
8
+ end
9
+
10
+ def teardown
11
+ File.rename('.elasticbeanstalk/config.yml', '.elasticbeanstalk/config.yml.staging')
12
+ end
13
+
14
+ private
15
+
16
+ attr_reader :env
17
+ end
18
+
@@ -0,0 +1,3 @@
1
+ module Ebim
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,111 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ebim
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Kartikey Tanna
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-05-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: cucumber
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: aruba
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: pry
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: |2
56
+ AWS Elatic Beanstalk CLI, awsebcli, does not provide option to set environment specific conviguration.
57
+ For example, if you want to set different env variables on AWS EB using .ebextensions it is not supported. This wrapper makes it possible!
58
+ email:
59
+ - tannakartikey@gmail.com
60
+ executables:
61
+ - args
62
+ - ebim
63
+ extensions: []
64
+ extra_rdoc_files: []
65
+ files:
66
+ - ".gitignore"
67
+ - ".rspec"
68
+ - ".travis.yml"
69
+ - Gemfile
70
+ - Gemfile.lock
71
+ - README.md
72
+ - Rakefile
73
+ - bin/console
74
+ - bin/setup
75
+ - ebim.gemspec
76
+ - exe/args
77
+ - exe/ebim
78
+ - lib/ebim.rb
79
+ - lib/ebim/cli.rb
80
+ - lib/ebim/command_environment.rb
81
+ - lib/ebim/deploy.rb
82
+ - lib/ebim/eb.rb
83
+ - lib/ebim/runner.rb
84
+ - lib/ebim/setup_environment.rb
85
+ - lib/ebim/version.rb
86
+ homepage: https://github.com/tannakartikey/ebim
87
+ licenses: []
88
+ metadata:
89
+ homepage_uri: https://github.com/tannakartikey/ebim
90
+ source_code_uri: https://github.com/tannakartikey/ebim
91
+ post_install_message:
92
+ rdoc_options: []
93
+ require_paths:
94
+ - lib
95
+ required_ruby_version: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ version: 2.3.0
100
+ required_rubygems_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ requirements: []
106
+ rubygems_version: 3.1.2
107
+ signing_key:
108
+ specification_version: 4
109
+ summary: AWS Elastic Beanstalk wrapper for environment speicific deplyoment from the
110
+ same branch using .ebextensions!
111
+ test_files: []