bosh-gen 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in bosh-gen.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Dr Nic Williams
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,38 @@
1
+ # BOSH Generators
2
+
3
+ Generators for creating BOSH releases.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'bosh-gen'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install bosh-gen
18
+
19
+ ## Usage
20
+
21
+ ```
22
+ $ bosh-gen new my-new-project
23
+ $ cd my-new-project
24
+ $ bosh-gen job somejob
25
+ $ bosh-gen package somepackage -u somejob
26
+ $ bosh-gen package anotherpackage
27
+ $ bosh-gen job anotherjob -u somepackage anotherpackage
28
+ ```
29
+
30
+ This will create two jobs and two package scaffolds. Both packages will be used by `somejob`, and `anotherpackage` is used by both jobs.
31
+
32
+ ## Contributing
33
+
34
+ 1. Fork it
35
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
36
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
37
+ 4. Push to the branch (`git push origin my-new-feature`)
38
+ 5. Create new Pull Request
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+ $:.push File.dirname(__FILE__) + '/../lib'
3
+
4
+ require 'rubygems'
5
+ require 'bosh/gen/cli'
6
+
7
+ Bosh::Gen::Command.start
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/bosh/gen/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Dr Nic Williams"]
6
+ gem.email = ["drnicwilliams@gmail.com"]
7
+ gem.description = %q{Generators for creating BOSH releases}
8
+ gem.summary = gem.summary
9
+ gem.homepage = "https://github.com/drnic/bosh-gen"
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "bosh-gen"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = Bosh::Gen::VERSION
17
+
18
+ gem.add_dependency "thor"
19
+
20
+ gem.add_development_dependency "rake"
21
+ end
@@ -0,0 +1,4 @@
1
+ module Bosh
2
+ module Gen
3
+ end
4
+ end
@@ -0,0 +1,28 @@
1
+ require 'thor'
2
+
3
+ module Bosh
4
+ module Gen
5
+ class Command < Thor
6
+ include Thor::Actions
7
+
8
+ desc "new NAME", "Creates a new BOSH release"
9
+ method_option :s3, :alias => ["--aws"], :type => :boolean, :desc => "Use AWS S3 bucket for blobstore"
10
+ method_option :atmos, :type => :boolean, :desc => "Use EMC ATMOS for blobstore"
11
+ def new(name)
12
+ flags = { :aws => options["s3"], :atmos => options["atmos"] }
13
+
14
+ require 'bosh/gen/generators/new_release_generator'
15
+ Bosh::Gen::Generators::NewReleaseGenerator.start([name, flags])
16
+ end
17
+
18
+ no_tasks do
19
+ def cyan; "\033[36m" end
20
+ def clear; "\033[0m" end
21
+ def bold; "\033[1m" end
22
+ def red; "\033[31m" end
23
+ def green; "\033[32m" end
24
+ def yellow; "\033[33m" end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,138 @@
1
+ require 'yaml'
2
+ require 'thor/group'
3
+
4
+ module Bosh::Gen
5
+ module Generators
6
+ class NewReleaseGenerator < Thor::Group
7
+ include Thor::Actions
8
+
9
+ argument :app_path
10
+ argument :flags, :type => :hash
11
+
12
+ def self.source_root
13
+ File.join(File.dirname(__FILE__), "new_release_generator", "templates")
14
+ end
15
+
16
+ def create_root
17
+ self.destination_root = File.expand_path(app_path, destination_root)
18
+ empty_directory '.'
19
+ FileUtils.cd(destination_root) unless options[:pretend]
20
+ end
21
+
22
+ def directories
23
+ %w[jobs packages src blobs].each do |dir|
24
+ directory dir
25
+ end
26
+ end
27
+
28
+ def blobs_yaml
29
+ create_file "blob_index.yml", YAML.dump({})
30
+ end
31
+
32
+ # TODO - support other blobstores
33
+ def local_blobstore
34
+ config_dev = { "dev_name" => name }
35
+ create_file "config/dev.yml", YAML.dump(config_dev)
36
+
37
+ case blobstore_type
38
+ when :local
39
+ say_status "warning", "config/final.yml defaulting to local blobstore /tmp/blobstore", :yellow
40
+ config_private = {}
41
+ config_final = { "blobstore" => {
42
+ "provider" => "local",
43
+ "options" => { "blobstore_path" => '/tmp/blobstore' }
44
+ }
45
+ }
46
+ when :s3
47
+ config_private = { "blobstore_secret" => 'AWS_SECRET_KEY' }
48
+ config_final = { "blobstore" => {
49
+ "provider" => "s3",
50
+ "options" => {
51
+ "bucket_name" => "BOSH",
52
+ "access_key_id" => "AWS_ACCESS_KEY",
53
+ "encryption_key" => "PERSONAL_RANDOM_KEY",
54
+ }
55
+ }
56
+ }
57
+ when :atmos
58
+ config_private = { "blobstore_secret" => 'ATMOS_SECRET_KEY' }
59
+ config_final = { "blobstore" => {
60
+ "provider" => "atmos",
61
+ "options" => {
62
+ "tag" => "BOSH",
63
+ "url" => "https://blob.cfblob.com",
64
+ "uid" => "ATMOS_UID"
65
+ }
66
+ }
67
+ }
68
+ end
69
+
70
+ create_file "config/private.yml", YAML.dump(config_private)
71
+ create_file "config/final.yml", YAML.dump(config_final)
72
+ end
73
+
74
+ def git_init
75
+ create_file ".gitignore", <<-IGNORE.gsub(/^\s{8}/, '')
76
+ config/dev.yml
77
+ config/private.yml
78
+ releases/*.tgz
79
+ dev_releases
80
+ blobs
81
+ .dev_builds
82
+ .idea
83
+ .DS_Store
84
+ .final_builds/jobs/**/*.tgz
85
+ .final_builds/packages/**/*.tgz
86
+ *.swp
87
+ *~
88
+ *#
89
+ #*
90
+ IGNORE
91
+ end
92
+
93
+ def setup_git
94
+ git :init
95
+ git :add => "."
96
+ git :commit => "-m 'Initial scaffold'"
97
+ end
98
+
99
+ private
100
+
101
+ def name
102
+ File.basename(self.destination_root)
103
+ end
104
+
105
+ def blobstore_type
106
+ return :s3 if s3?
107
+ return :atmos if atmos?
108
+ return :local
109
+ end
110
+
111
+ def s3?
112
+ flags[:aws]
113
+ end
114
+
115
+ def atmos?
116
+ flags[:atmos]
117
+ end
118
+
119
+ # Run a command in git.
120
+ #
121
+ # ==== Examples
122
+ #
123
+ # git :init
124
+ # git :add => "this.file that.rb"
125
+ # git :add => "onefile.rb", :rm => "badfile.cxx"
126
+ #
127
+ def git(commands={})
128
+ if commands.is_a?(Symbol)
129
+ run "git #{commands}"
130
+ else
131
+ commands.each do |cmd, options|
132
+ run "git #{cmd} #{options}"
133
+ end
134
+ end
135
+ end
136
+ end
137
+ end
138
+ end
@@ -0,0 +1,5 @@
1
+ module Bosh
2
+ module Gen
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,89 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bosh-gen
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Dr Nic Williams
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-04-22 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: thor
16
+ requirement: &70146989259840 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70146989259840
25
+ - !ruby/object:Gem::Dependency
26
+ name: rake
27
+ requirement: &70146989259200 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *70146989259200
36
+ description: Generators for creating BOSH releases
37
+ email:
38
+ - drnicwilliams@gmail.com
39
+ executables:
40
+ - bosh-gen
41
+ extensions: []
42
+ extra_rdoc_files: []
43
+ files:
44
+ - .gitignore
45
+ - Gemfile
46
+ - LICENSE
47
+ - README.md
48
+ - Rakefile
49
+ - bin/bosh-gen
50
+ - bosh-gen.gemspec
51
+ - lib/bosh/gen.rb
52
+ - lib/bosh/gen/cli.rb
53
+ - lib/bosh/gen/generators/new_release_generator.rb
54
+ - lib/bosh/gen/generators/new_release_generator/templates/blobs/.gitkeep
55
+ - lib/bosh/gen/generators/new_release_generator/templates/jobs/.gitkeep
56
+ - lib/bosh/gen/generators/new_release_generator/templates/packages/.gitkeep
57
+ - lib/bosh/gen/generators/new_release_generator/templates/src/.gitkeep
58
+ - lib/bosh/gen/version.rb
59
+ homepage: https://github.com/drnic/bosh-gen
60
+ licenses: []
61
+ post_install_message:
62
+ rdoc_options: []
63
+ require_paths:
64
+ - lib
65
+ required_ruby_version: !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ! '>='
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ segments:
72
+ - 0
73
+ hash: 487201214193427891
74
+ required_rubygems_version: !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - ! '>='
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ segments:
81
+ - 0
82
+ hash: 487201214193427891
83
+ requirements: []
84
+ rubyforge_project:
85
+ rubygems_version: 1.8.17
86
+ signing_key:
87
+ specification_version: 3
88
+ summary: ''
89
+ test_files: []