Class: Bosh::Gen::Generators::NewReleaseGenerator

Inherits:
Thor::Group
  • Object
show all
Includes:
Settings, Thor::Actions
Defined in:
lib/bosh/gen/generators/new_release_generator.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Settings

#migrate_old_settings, #reload_settings!, #save_settings!, #setting, #settings, #settings_dir, #settings_dir=, #settings_path, #settings_ssh_dir

Class Method Details

.source_rootObject



15
16
17
# File 'lib/bosh/gen/generators/new_release_generator.rb', line 15

def self.source_root
  File.join(File.dirname(__FILE__), "new_release_generator", "templates")
end

Instance Method Details

#blobs_yamlObject



47
48
49
# File 'lib/bosh/gen/generators/new_release_generator.rb', line 47

def blobs_yaml
  create_file "config/blobs.yml", YAML.dump({})
end

#config_dev_ymlObject



51
52
53
54
# File 'lib/bosh/gen/generators/new_release_generator.rb', line 51

def config_dev_yml
  config_dev = { "dev_name" => project_name }
  create_file "config/dev.yml", YAML.dump(config_dev)
end

#config_final_ymlObject



92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# File 'lib/bosh/gen/generators/new_release_generator.rb', line 92

def config_final_yml
  case blobstore_type
  when :local
    say_status "warning", "config/final.yml defaulting to local blobstore /tmp/blobstore", :yellow
    config_final = { "blobstore" => {
        "provider" => "local",
        "options" => { "blobstore_path" => '/tmp/blobstore' }
      }
    }
  when :s3
    config_final = { "blobstore" => {
        "provider" => "s3",
        "options" => {
          "bucket_name" => repository_name
        }
      }
    }
  when :swift
    config_final = { "blobstore" => {
        "provider" => "swift",
        "options" => {
          "container_name" => repository_name,
          "swift_provider" => swift_provider
        }
      }
    }
  end
  config_final["final_name"] = project_name

  create_file "config/final.yml", YAML.dump(config_final)
end

#config_private_ymlObject



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/bosh/gen/generators/new_release_generator.rb', line 56

def config_private_yml
  case blobstore_type
  when :local
    config_private = {
      "blobstore" => {
        "provider" => "simple",
        "options" => {
          "user" => "USER",
          "password" => "PASSWORD"
        }
      }
    }
  when :s3
    config_private = {
      "blobstore" => {
        "provider" => "s3",
        "options" => {
          "access_key_id" => settings.provider.credentials.aws_access_key_id,
          "secret_access_key" => settings.provider.credentials.aws_secret_access_key
        }
      }
    }
  # https://github.com/cloudfoundry/bosh/tree/master/blobstore_client#openstack-object-storage
  when :swift
    config_private = {
      "blobstore" => {
        "provider" => "swift",
        "options" => {
          settings.provider.name => settings.provider.credentials.to_hash
        }
      }
    }
  end
  create_file "config/private.yml", YAML.dump(config_private)
end

#create_blobstoreObject



159
160
161
162
163
164
165
166
# File 'lib/bosh/gen/generators/new_release_generator.rb', line 159

def create_blobstore
  say ""
  say "Finally..."
  blobstore = Cyoi::Cli::Blobstore.new([blobstore_name, settings_dir])
  blobstore.execute!
  reload_settings!
  say ""
end

#create_rootObject



19
20
21
22
23
# File 'lib/bosh/gen/generators/new_release_generator.rb', line 19

def create_root
  self.destination_root = File.expand_path(repository_path, destination_root)
  empty_directory '.'
  FileUtils.cd(destination_root) unless options[:pretend]
end

#directoriesObject



40
41
42
43
44
45
# File 'lib/bosh/gen/generators/new_release_generator.rb', line 40

def directories
  %w[jobs packages src blobs manifests].each do |dir|
    directory dir
  end
  chmod 'manifests/operators/pick-from-cloud-config.sh', 0755
end

#git_initObject



124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# File 'lib/bosh/gen/generators/new_release_generator.rb', line 124

def git_init
  create_file ".gitignore", <<-IGNORE.gsub(/^\s{8}/, '')
  config/dev.yml
  config/private.yml
  config/settings.yml
  releases/**/*.tgz
  dev_releases
  blobs/*
  .blobs
  .dev_builds
  .vagrant
  .idea
  .DS_Store
  .final_builds/jobs/**/*.tgz
  .final_builds/packages/**/*.tgz
  *.swp
  *~
  *#
  #*
  tmp
  IGNORE
end

#licenseObject



36
37
38
# File 'lib/bosh/gen/generators/new_release_generator.rb', line 36

def license
  template "LICENSE.md.tt", "LICENSE.md"
end

#readmeObject



32
33
34
# File 'lib/bosh/gen/generators/new_release_generator.rb', line 32

def readme
  template "README.md.tt", "README.md"
end

#select_providerObject



25
26
27
28
29
30
# File 'lib/bosh/gen/generators/new_release_generator.rb', line 25

def select_provider
  self.settings_dir = File.expand_path("config")
  provider = Cyoi::Cli::Provider.new([settings_dir])
  provider.execute!
  reload_settings!
end

#setup_gitObject



147
148
149
150
151
# File 'lib/bosh/gen/generators/new_release_generator.rb', line 147

def setup_git
  git :init
  git :add => "."
  git :commit => "-m 'Initial scaffold'"
end

#show_locationObject



153
154
155
156
157
# File 'lib/bosh/gen/generators/new_release_generator.rb', line 153

def show_location
  say ""
  say "Next, change to BOSH release location:"
  say "cd #{repository_path}", :yellow
end