vara 0.17.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 08cc7a49aec754f09f066fc8649926fda5f74ddd
4
+ data.tar.gz: 0f14ee0ed5fc429451dc1cc868ea45ea0e5d54d5
5
+ SHA512:
6
+ metadata.gz: 551fee9ff87c07a9ae255d482bb50d4bfe79b816cf6fa6377c5e9f53cb09aa9d0bfff3403b66c16ff647751856ebfa7a719a4118bb6fde770f716d2b997ad69e
7
+ data.tar.gz: 314fa6195a5f9e20cc5afd2451928f328b39a2adb68ede1b3b17772ebbf7163efa3532b18a786a70e297e2a6296863756c21b1065843c9ee6f4feb602089e76d
@@ -0,0 +1,13 @@
1
+ Copyright (c) 2014-2015 Pivotal Software, Inc. All rights reserved.
2
+
3
+ Unauthorized use, copying or distribution of this source code via any
4
+ medium is strictly prohibited without the express written consent of
5
+ Pivotal Software, Inc.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
8
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
9
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
10
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
11
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
12
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
13
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,297 @@
1
+ # Vara
2
+
3
+ A gem for building products to be consumed by Ops Manager.
4
+
5
+ ## Complementary tools
6
+
7
+ While Vara focuses on building a .pivotal from a complete product repository, you may find some of the following tools complement your workflow with Vara:
8
+
9
+ * [*Vöxtur*](https://github.com/pivotal-cf-experimental/voxtur) to automatically update metadata_parts/binaries.yml from a built release tarball.
10
+
11
+ ## Usage
12
+
13
+ ### Build .pivotal file
14
+
15
+ In most circumstances, you will only need to run `vara build-pivotal PRODUCT_DIR`, which calls other lower-level vara commands.
16
+
17
+ vara build-pivotal ~/workspace/p-runtime
18
+
19
+ will build a .pivotal file using the stemcell, release tarball, and compiled packages as specified by the product metadata.
20
+ If the stemcell, release tarball, or compiled packages do not exist on disk, they will be downloaded.
21
+
22
+ The product file will be named `#{product_name}-#{product_version}.pivotal`, where both variables come from the product metadata YAML.
23
+
24
+ The product file's contents will look like:
25
+
26
+ ```
27
+ cf-1.1.0.0.pivotal
28
+ ├── compiled_packages
29
+ │ └── cf-158.1-dev-bosh-vsphere-esxi-ubuntu-1471.2.tgz
30
+ ├── content_migrations
31
+ │ └── migrations.yml
32
+ ├── metadata
33
+ │ └── cf.yml
34
+ ├── releases
35
+ │ └── cf-158.1-dev.tgz
36
+ └── stemcells
37
+ └── bosh-stemcell-1471_2-vsphere-esxi-ubuntu.tgz
38
+ ```
39
+
40
+ The `content_migrations/migrations.yml` is copied from the product folder's `content_migrations/migrations.yml`.
41
+ The `metadata/cf.yml` file is copied from the product folder's `metadata/cf.yml` if it exists.
42
+ Otherwise the metadata YAML is assembled from `metadata_parts/{handcraft,binaries}.yml`.
43
+ The release file is copied from the product folder's `releases` folder.
44
+ The stemcell file is copied from the product folder's `stemcells` folder.
45
+
46
+ ### The PRODUCT_DIR
47
+
48
+ Vara expects a product directory that resembles the layout of the .pivotal zip contents.
49
+
50
+ ```
51
+ p-runtime/
52
+ ├── .gitignore
53
+ ├── compiled_packages
54
+ │   └── .gitkeep
55
+ ├── content_migrations
56
+ │   └── .gitkeep
57
+ ├── content_migrations_parts
58
+ │   ├── base.yml
59
+ │ └── migrations
60
+ │   ├── from_1.1.0.0.yml
61
+ │   └── from_1.2.0.0.yml
62
+ ├── metadata
63
+ │   └── .gitkeep
64
+ ├── metadata_parts
65
+ │   ├── binaries.yml
66
+ │   └── handcraft.yml
67
+ ├── releases
68
+ │   └── .gitkeep
69
+ └── stemcells
70
+ └── .gitkeep
71
+ ```
72
+
73
+ The contents of `compiled_packages`, `releases`, and `stemcells` are large tarballs.
74
+ Large binary files are discouraged from being checked into git and other source control systems.
75
+ To work around this limitation, vara examines the metadata YAML and downloads these files from a URL if necessary.
76
+
77
+ The `compiled_packages`, `releases`, and `stemcells` directories are populated during the `download-artifacts` step of building a .pivotal.
78
+ The `metadata` directory is populated during the `build-metadata` step.
79
+ The `content_migrations` directory is populated during the `build-migrations` step.
80
+
81
+ The .gitignore file should include these entries to prevent large binary files from being committed by mistake.
82
+ These entries also prevent vara from failing various operations due to a dirty git working tree.
83
+
84
+ ```
85
+ releases/
86
+ stemcells/
87
+ compiled_packages/
88
+ *.pivotal
89
+ *.pivotal.yml
90
+ *.pivotal.md5
91
+ ```
92
+
93
+ ### Re-generate Metadata .yml
94
+
95
+ #### Using metadata_parts
96
+
97
+ To only build the product metadata file from the two separate metadata_parts files:
98
+
99
+ vara build-metadata ~/workspace/p-runtime
100
+
101
+ This will create a `metadata/${PRODUCT_NAME}.yml` file composed of the two files located in `${product_dir}/metadata_parts`:
102
+
103
+ * binaries.yml (includes stemcells, release, and optional compiled_packages information)
104
+ * handcraft.yml (includes everything else, including product name (e.g. *cf*), product_version (e.g. *1.2.0.0*)
105
+
106
+ (where PRODUCT_NAME is derived from the product name entry in handcraft.yml)
107
+
108
+ *[These files were split in order to maintain the comments and the formatting of contained in the handcraft.yml file while allowing the information contained in binaries.yml to be updated by utilities such as `vara-update-metadata`]
109
+
110
+ Include the following entry in .gitignore if vara dynamically generates the metadata .yml.
111
+
112
+ ```
113
+ metadata/*.yml
114
+ ```
115
+
116
+ #### Automatically increasing a product's prerelease version
117
+
118
+ You can set the `product_version` to something like `1.2.3.4$PRERELEASE_VERSION$` and during metadata generation, vara will expand that into something like `1.2.3.4.alpha.88.dedbeef` where:
119
+
120
+ * *alpha* is the "cycle" as specified by the --cycle flag to `vara build-metadata`, which defaults to alpha
121
+ * *88* is the number of commits in the current branch
122
+ * *dedbeef* is the short commit hash of the current revision on the current branch
123
+
124
+ #### Specifying a product version
125
+
126
+ You can set the `product_version` to something specific like `1.2.3-build.1` or `1.2.3` by specifying the `--version` flag, e.g.:
127
+
128
+ ```
129
+ vara build-metadata --version=1.2.3-build.1 .
130
+ vara build-migrations --version=1.2.3 .
131
+ vara build-pivotal --version=1.2.3-rc.3 .
132
+ ```
133
+
134
+ #### Specifying a final version
135
+
136
+ You can remove the `$PRERELEASE_VERSION$` from the product version by using the `--final` flag. So for a product version that is in
137
+ `handcraft.yml` as `1.2.3.4$PRERELEASE_VERSION$` running
138
+
139
+ ```
140
+ vara build-pivotal . --final
141
+ vara build-metadata . --final
142
+ vara build-migrations . --final
143
+ ```
144
+
145
+ would result in a product version of `1.2.3.4`.
146
+
147
+ #### Specifying an external release
148
+
149
+ You can update multiple releases when building the pivotal by passing one or more external release files using the `--external-releases` flag.
150
+
151
+ ```
152
+ vara build-pivotal . --external-releases=some-release.yml
153
+ vara build-pivotal . --external-release=some-release.yml,another-release.yml
154
+ ```
155
+
156
+ An external release file contains an array of manifest snippets that replace entries in `metadata_parts/binaries.yml`. For example a sample external release file could be the following. This would update the `cf` entry in binaries.yml when running the pivotal.
157
+
158
+ ```
159
+ - file: cf-214.tgz
160
+ name: cf
161
+ version: '214'
162
+ md5: 20cd54b93c23a7fb232d5c25b2082666
163
+ url: http://bosh.io/d/github.com/cloudfoundry/cf-release?v=214
164
+ ```
165
+
166
+ The flag will use the specified files to replace the entries that matches the `name` property of an already existing release inside of the `binaries.yml` file.
167
+
168
+ ### Lint product metadata
169
+
170
+ #### Syntax
171
+
172
+ `vara lint <Product-Metadata>`
173
+
174
+ #### Description
175
+
176
+ Running `vara lint ~/workspace/p-runtime/cf.yml` will inspect the product template for malformed data.
177
+ `vara build-pivotal` executes `vara lint` before running `vara zip-pivotal`, therefore if malformed data exists,
178
+ the resulting .pivotal file will not be created.
179
+
180
+ ### Re-generate content migrations
181
+
182
+ To only compose the content migrations file from the files in the `content_migrations_parts` directory:
183
+
184
+ vara build-migrations ~/workspace/p-runtime
185
+
186
+ This will create a `content_migrations/migrations.yml` file composed of the files in `${product_dir}/content_migrations_parts`:
187
+
188
+ * base.yml
189
+ * Typically includes the `product`, `installation_version`, and `to_version` keys
190
+ * Optionally includes the `migrations` key, which is allowed to have any number of entries underneath it
191
+ * migrations/from_1.2.3.4.yml
192
+ * Can be named anything you want with a .yml extension, but by convention is `from_${version}.yml`
193
+ * Content is the hash of a single entry to be inserted under the migrations key (e.g. has `from_version` and `rules` as top-level keys)
194
+
195
+ A migration file in the `migrations` folder may have a `base.yml` file like:
196
+
197
+ ```
198
+ product: example-product
199
+ installation_version: "1.1"
200
+ to_version: "1.2.0.0$PRERELEASE_VERSION$"
201
+ ```
202
+
203
+ and a rule entry like:
204
+
205
+ ```
206
+ from_version: 1.1.0.0
207
+ rules:
208
+ - type: update
209
+ selector: "product_version"
210
+ to: "1.2.0.0$PRERELEASE_VERSION$"
211
+ ```
212
+
213
+ and then `$PRERELEASE_VERSION$` will be replaced in both places using the same rules as above in the metadata file.
214
+
215
+ Include the following entry in .gitignore if vara dynamically generates the metadata .yml.
216
+
217
+ ```
218
+ content_migrations/*.yml
219
+ ```
220
+
221
+ #### A Warning on Auto-Generated Prerelease versions
222
+
223
+ Ops Manager does not allow wildcards in the `from_version` field of migrations.
224
+ Therefore, if you have deployed a prerelease version, you will not be able to upgrade to another prerelease version unless you explicitly write a migration between the two.
225
+ We expect that the normal workflow will not include upgrading between prereleases.
226
+
227
+ Any prerelease products published externally will require an additional stanza in future migrations.yml for upgradability.
228
+
229
+ ### Download missing artifacts
230
+
231
+ Running `vara download-artifacts ~/workspace/p-runtime/cf.yml` will download any missing compiled_packages, releases, and stemcells, inserting them into the respective directories.
232
+ For stemcells, vara assumes that the stemcell is a public bosh stemcell and infers the URL based on the `file` attribute of the stemcell hash.
233
+ For releases and compiled packages, vara uses the `url` attribute of the respective hashes in the product metadata.
234
+
235
+ For example:
236
+
237
+ ```
238
+ releases:
239
+ - file: cf-172.tgz
240
+ name: cf
241
+ version: '172'
242
+ md5: 777fe352515612841a3d96af12054947
243
+ url: https://example.s3.amazonaws.com/cf-172.tgz
244
+ ```
245
+
246
+ #### Checksum Validation
247
+
248
+ Artifacts can use either `MD5` or `SHA1` checksums for release and stemcell validation. For example:
249
+
250
+ ```
251
+ releases:
252
+ - file: cf-172.tgz
253
+ name: cf
254
+ version: '172'
255
+ md5: 777fe352515612841a3d96af12054947
256
+ sha1: 7d7ea80ccb59ce57c047e0c91c865172d98f1ba0
257
+ url: https://example.s3.amazonaws.com/cf-172.tgz
258
+ ```
259
+
260
+ You must specify at least one checksum.
261
+
262
+ #### AWS S3 support
263
+
264
+ Release artifacts can be downloaded from an S3 bucket. For example:
265
+
266
+ ```
267
+ releases:
268
+ - file: cf-172.tgz
269
+ name: cf
270
+ version: '172'
271
+ md5: 777fe352515612841a3d96af12054947
272
+ sha1: 7d7ea80ccb59ce57c047e0c91c865172d98f1ba0
273
+ aws:
274
+ access_key_id: <some-access-key>
275
+ secret_access_key: <some-secret-key>
276
+ region: us-west-1
277
+ bucket_name: <some-bucket>
278
+ filename: path/to/s3/object.tgz
279
+ ```
280
+
281
+ You should only specify `url` or `aws`, not both.
282
+
283
+ ### Zipping the .pivotal
284
+
285
+ If your metadata file has been generated and your artifacts have been downloaded, running `vara zip-pivotal ~/workspace/p-runtime` will put all of those contents into a new .pivotal in your working directory.
286
+
287
+
288
+ ## LEGAL
289
+
290
+ Copyright (c) 2014-2015 Pivotal Software, Inc.
291
+ All rights reserved.
292
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
293
+ INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
294
+ PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
295
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
296
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
297
+ USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # Copyright (c) 2014-2015 Pivotal Software, Inc.
4
+ # All rights reserved.
5
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
6
+ # INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
7
+ # PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
8
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
9
+ # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
10
+ # USE OR OTHER DEALINGS IN THE SOFTWARE.
11
+ require 'vara/cli'
12
+ require 'vara/cli_helper'
13
+
14
+ Vara::Cli.start(ARGV)
@@ -0,0 +1,14 @@
1
+ require 'vara/version'
2
+
3
+ module Vara
4
+ # Your code goes here...
5
+ end
6
+
7
+ # Copyright (c) 2014-2015 Pivotal Software, Inc.
8
+ # All rights reserved.
9
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
10
+ # INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
11
+ # PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
12
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
13
+ # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
14
+ # USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,96 @@
1
+ require 'thor'
2
+
3
+ module Vara
4
+ class Cli < Thor
5
+ def self.exit_on_failure?
6
+ true
7
+ end
8
+
9
+ desc 'build-metadata PRODUCT_DIR', 'Compose metadata from metadata_parts'
10
+ option 'cycle', default: 'alpha'
11
+ option 'final', type: :boolean, desc: 'When true, $PRERELEASE_VERSION$ is removed instead of substituted'
12
+ option 'version', type: :string, desc: 'When given, use the version as specified'
13
+ option 'external_releases', desc: 'Comma delimited paths to release metadata files to use when generating the .pivotal'
14
+ def build_metadata(product_dir)
15
+ require 'vara/prerelease_versioner'
16
+ require 'vara/static_versioner'
17
+ require 'vara/product_metadata_processor'
18
+ versioner = Vara::PrereleaseVersioner.new(File.expand_path(product_dir), options.fetch('cycle'))
19
+ versioner.override_prerelease_version!('') if options['final']
20
+ if options['version'] && !options['version'].empty?
21
+ versioner = Vara::StaticVersioner.new(File.expand_path(product_dir), options.fetch('version'))
22
+ end
23
+ metadata_path = Vara::ProductMetadataProcessor.new(
24
+ File.expand_path(product_dir),
25
+ versioner,
26
+ external_release_paths: options.fetch('external_releases', '').split(',')
27
+ ).process
28
+ say("#{metadata_path} has been created")
29
+ metadata_path
30
+ end
31
+
32
+ desc 'build-migrations PRODUCT_DIR', 'Compose content_migrations from content_migrations_parts'
33
+ option 'cycle', default: 'alpha'
34
+ option 'final', type: :boolean, desc: 'When true, $PRERELEASE_VERSION$ is removed instead of substituted'
35
+ option 'version', type: :string, desc: 'When given, use the version as specified'
36
+ def build_migrations(product_dir)
37
+ require 'vara/prerelease_versioner'
38
+ require 'vara/static_versioner'
39
+ require 'vara/content_migrations_processor'
40
+ versioner = Vara::PrereleaseVersioner.new(File.expand_path(product_dir), options.fetch('cycle'))
41
+ versioner.override_prerelease_version!('') if options['final']
42
+ if options['version'] && !options['version'].empty?
43
+ versioner = Vara::StaticVersioner.new(File.expand_path(product_dir), options.fetch('version'))
44
+ end
45
+ content_migrations_path = Vara::ContentMigrationsProcessor.new(File.expand_path(product_dir), versioner).process
46
+ say("#{content_migrations_path} has been created")
47
+ content_migrations_path
48
+ end
49
+
50
+ desc 'lint PRODUCT_METADATA', 'Lints the product metadata file'
51
+ def lint(product_metadata)
52
+ require 'vara/linter'
53
+ linter = Vara::Linter.build(File.expand_path(product_metadata))
54
+ linter.lint!
55
+ end
56
+
57
+ desc 'download-artifacts PRODUCT_METADATA', 'Download the artifacts from the product metadata file'
58
+ def download_artifacts(product_metadata)
59
+ require 'vara/product_resource_downloader'
60
+ product_resource_downloader = Vara::ProductResourceDownloader.build(File.expand_path(product_metadata))
61
+ product_resource_downloader.download
62
+ end
63
+
64
+ desc 'zip-pivotal PRODUCT_DIR', 'Zips up the .pivotal product given that all artifacts are synced locally'
65
+ def zip_pivotal(product_dir)
66
+ require 'vara/product'
67
+ product = Vara::Product.new(File.expand_path(product_dir))
68
+ product.build
69
+ say("file #{product.path} has been created")
70
+ say("file #{product.bom_path} has been created")
71
+ say("file #{product.md5_path} has been created")
72
+ end
73
+
74
+ desc 'build-pivotal PRODUCT_DIR', 'Generate a .pivotal from a vara-flavored product repository'
75
+ option 'final', type: :boolean, desc: 'When true, $PRERELEASE_VERSION$ is removed instead of substituted'
76
+ option 'version', type: :string, desc: 'When given, use the version as specified'
77
+ option 'external_releases', desc: 'Comma delimited paths to release metadata files to use when generating the .pivotal'
78
+ option 'cycle', default: 'alpha'
79
+ def build_pivotal(product_dir)
80
+ metadata_path = build_metadata(product_dir)
81
+ build_migrations(product_dir)
82
+ lint(metadata_path)
83
+ download_artifacts(metadata_path)
84
+ zip_pivotal(product_dir)
85
+ end
86
+ end
87
+ end
88
+
89
+ # Copyright (c) 2014-2015 Pivotal Software, Inc.
90
+ # All rights reserved.
91
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
92
+ # INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
93
+ # PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
94
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
95
+ # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
96
+ # USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,12 @@
1
+ require 'vara/log'
2
+
3
+ Vara::Log.stdout_mode!
4
+
5
+ # Copyright (c) 2014-2015 Pivotal Software, Inc.
6
+ # All rights reserved.
7
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
8
+ # INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
9
+ # PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
10
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
11
+ # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
12
+ # USE OR OTHER DEALINGS IN THE SOFTWARE.