iapi-idlc-sdk-pfm 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +16 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/.yardopts +3 -0
- data/Gemfile +6 -0
- data/Jenkinsfile +21 -0
- data/LICENSE.txt +21 -0
- data/README.md +37 -0
- data/Rakefile +6 -0
- data/bin/pfm +8 -0
- data/docs/GettingStarted.md +299 -0
- data/iapi-idlc-sdk-pfm.gemspec +50 -0
- data/lib/iapi-idlc-sdk-pfm/builtin_commands.rb +12 -0
- data/lib/iapi-idlc-sdk-pfm/cli.rb +150 -0
- data/lib/iapi-idlc-sdk-pfm/command/apply.rb +86 -0
- data/lib/iapi-idlc-sdk-pfm/command/base.rb +255 -0
- data/lib/iapi-idlc-sdk-pfm/command/build.rb +121 -0
- data/lib/iapi-idlc-sdk-pfm/command/configure.rb +41 -0
- data/lib/iapi-idlc-sdk-pfm/command/destroy.rb +77 -0
- data/lib/iapi-idlc-sdk-pfm/command/exec.rb +24 -0
- data/lib/iapi-idlc-sdk-pfm/command/format.rb +64 -0
- data/lib/iapi-idlc-sdk-pfm/command/generate.rb +83 -0
- data/lib/iapi-idlc-sdk-pfm/command/generator_commands/base.rb +50 -0
- data/lib/iapi-idlc-sdk-pfm/command/generator_commands/server_build.rb +58 -0
- data/lib/iapi-idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/Berksfile +3 -0
- data/lib/iapi-idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/build_cookbook/.kitchen.yml +21 -0
- data/lib/iapi-idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/build_cookbook/README.md +146 -0
- data/lib/iapi-idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/build_cookbook/test-fixture-recipe.rb +8 -0
- data/lib/iapi-idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/chefignore +107 -0
- data/lib/iapi-idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/cookbook_readmes/README-policy.md +9 -0
- data/lib/iapi-idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/cookbook_readmes/README.md +54 -0
- data/lib/iapi-idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/delivery-config.json +12 -0
- data/lib/iapi-idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/delivery-project.toml +36 -0
- data/lib/iapi-idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/gitignore +21 -0
- data/lib/iapi-idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/repo/README.md +24 -0
- data/lib/iapi-idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/repo/cookbooks/example/README.md +27 -0
- data/lib/iapi-idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/repo/cookbooks/example/attributes/default.rb +7 -0
- data/lib/iapi-idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/repo/cookbooks/example/metadata.rb +6 -0
- data/lib/iapi-idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/repo/cookbooks/example/recipes/default.rb +8 -0
- data/lib/iapi-idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/repo/data_bags/README.md +56 -0
- data/lib/iapi-idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/repo/data_bags/example/example_item.json +4 -0
- data/lib/iapi-idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/repo/dot-chef-repo.txt +6 -0
- data/lib/iapi-idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/repo/environments/README.md +9 -0
- data/lib/iapi-idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/repo/environments/example.json +13 -0
- data/lib/iapi-idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/repo/policies/README.md +24 -0
- data/lib/iapi-idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/repo/roles/README.md +9 -0
- data/lib/iapi-idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/repo/roles/example.json +13 -0
- data/lib/iapi-idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/spec_helper.rb +2 -0
- data/lib/iapi-idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/spec_helper_policyfile.rb +2 -0
- data/lib/iapi-idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/metadata.rb +7 -0
- data/lib/iapi-idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/recipes/app.rb +89 -0
- data/lib/iapi-idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/recipes/attribute.rb +12 -0
- data/lib/iapi-idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/recipes/build_cookbook.rb +182 -0
- data/lib/iapi-idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/recipes/cookbook.rb +144 -0
- data/lib/iapi-idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/recipes/cookbook_file.rb +24 -0
- data/lib/iapi-idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/recipes/lwrp.rb +23 -0
- data/lib/iapi-idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/recipes/policyfile.rb +8 -0
- data/lib/iapi-idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/recipes/recipe.rb +51 -0
- data/lib/iapi-idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/recipes/repo.rb +67 -0
- data/lib/iapi-idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/recipes/template.rb +32 -0
- data/lib/iapi-idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/templates/default/LICENSE.all_rights.erb +3 -0
- data/lib/iapi-idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/templates/default/LICENSE.apachev2.erb +201 -0
- data/lib/iapi-idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/templates/default/LICENSE.gplv2.erb +339 -0
- data/lib/iapi-idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/templates/default/LICENSE.gplv3.erb +674 -0
- data/lib/iapi-idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/templates/default/LICENSE.mit.erb +21 -0
- data/lib/iapi-idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/templates/default/Policyfile.rb.erb +25 -0
- data/lib/iapi-idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/templates/default/README.md.erb +4 -0
- data/lib/iapi-idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/templates/default/attribute.rb.erb +0 -0
- data/lib/iapi-idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/templates/default/build_cookbook/Berksfile.erb +7 -0
- data/lib/iapi-idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/templates/default/build_cookbook/metadata.rb.erb +10 -0
- data/lib/iapi-idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/templates/default/build_cookbook/recipe.rb.erb +8 -0
- data/lib/iapi-idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/templates/default/cookbook_file.erb +0 -0
- data/lib/iapi-idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/templates/default/inspec_default_test.rb.erb +18 -0
- data/lib/iapi-idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/templates/default/kitchen.yml.erb +26 -0
- data/lib/iapi-idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/templates/default/kitchen_policyfile.yml.erb +33 -0
- data/lib/iapi-idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/templates/default/metadata.rb.erb +20 -0
- data/lib/iapi-idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/templates/default/provider.rb.erb +0 -0
- data/lib/iapi-idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/templates/default/recipe.rb.erb +5 -0
- data/lib/iapi-idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/templates/default/recipe_spec.rb.erb +22 -0
- data/lib/iapi-idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/templates/default/repo/gitignore.erb +128 -0
- data/lib/iapi-idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/templates/default/resource.rb.erb +0 -0
- data/lib/iapi-idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/templates/default/template.erb +0 -0
- data/lib/iapi-idlc-sdk-pfm/command/generator_commands.rb +34 -0
- data/lib/iapi-idlc-sdk-pfm/command/package.rb +118 -0
- data/lib/iapi-idlc-sdk-pfm/command/plan.rb +96 -0
- data/lib/iapi-idlc-sdk-pfm/command/templates/app/files/config/client.rb.template +9 -0
- data/lib/iapi-idlc-sdk-pfm/command/templates/app/files/config/init.ps1.userdata +16 -0
- data/lib/iapi-idlc-sdk-pfm/command/templates/base/files/config/client.rb.template +9 -0
- data/lib/iapi-idlc-sdk-pfm/command/templates/base/files/config/init.ps1.userdata +219 -0
- data/lib/iapi-idlc-sdk-pfm/command/validate.rb +85 -0
- data/lib/iapi-idlc-sdk-pfm/command/validator_commands/base.rb +65 -0
- data/lib/iapi-idlc-sdk-pfm/command/validator_commands/infrastructure.rb +46 -0
- data/lib/iapi-idlc-sdk-pfm/command/validator_commands/server_build.rb +135 -0
- data/lib/iapi-idlc-sdk-pfm/command/validator_commands.rb +32 -0
- data/lib/iapi-idlc-sdk-pfm/commands_map.rb +61 -0
- data/lib/iapi-idlc-sdk-pfm/generator.rb +52 -0
- data/lib/iapi-idlc-sdk-pfm/helpers.rb +49 -0
- data/lib/iapi-idlc-sdk-pfm/settings.rb +205 -0
- data/lib/iapi-idlc-sdk-pfm/validator.rb +52 -0
- data/lib/iapi-idlc-sdk-pfm/version.rb +4 -0
- data/lib/iapi-idlc-sdk-pfm.rb +27 -0
- metadata +442 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b55ff46a3681cd3471ddbd824915f689ca5acbca68238a98d6f63c7fddf5b363
|
4
|
+
data.tar.gz: a1475ec458509fc8e9f873fe72d6c54a9fc3d843511501ce5d4604de4f3a3cb4
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 829930b1b8cf7dcc29250f4f9904844c152aa7d0753b5e61ad0d1832b15cd08e73e005d0048ff33621955dcd189ccce1cec47f5c114bd0cace2173b06d3d5edf
|
7
|
+
data.tar.gz: 6624bc3eccb079ca9a9eb73e57a7b97a5640776a0bc23a4e89d4b54f6227b2c834b50e333dd66603e617d6a0e9235d6c0c895d98fc7229a86414bdfe9963848f
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/.yardopts
ADDED
data/Gemfile
ADDED
data/Jenkinsfile
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
pipeline {
|
2
|
+
agent any
|
3
|
+
options {
|
4
|
+
buildDiscarder logRotator(daysToKeepStr: '5', numToKeepStr: '10')
|
5
|
+
}
|
6
|
+
stages {
|
7
|
+
stage('Ruby Gem Push') {
|
8
|
+
environment {
|
9
|
+
GEM_HOST_API_KEY = credentials('rubygems-apikey')
|
10
|
+
}
|
11
|
+
steps {
|
12
|
+
sh '''
|
13
|
+
DOCKER_CMD="docker run --rm -v $PWD:/opt -w /opt -e GEM_HOST_API_KEY -e BUILD_NUMBER -u 999 ruby:3.0"
|
14
|
+
$DOCKER_CMD gem build iapi-idlc-sdk-pfm.gemspec -o iapi-idlc-sdk-pfm.gem
|
15
|
+
$DOCKER_CMD gem push iapi-idlc-sdk-pfm.gem
|
16
|
+
'''
|
17
|
+
}
|
18
|
+
}
|
19
|
+
}
|
20
|
+
}
|
21
|
+
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Nathan Cazell
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# Idlc::Sdk::Pfm
|
2
|
+
|
3
|
+
Provides the pfm executable for idlc-sdk. This gem is part of the IDLC SDK
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'iapi-idlc-sdk-pfm'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install iapi-idlc-sdk-pfm
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
See the {file:docs/GettingStarted.md Getting Started Guide} for PFM executable usage.
|
24
|
+
|
25
|
+
## Development
|
26
|
+
|
27
|
+
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.
|
28
|
+
|
29
|
+
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).
|
30
|
+
|
31
|
+
## Contributing
|
32
|
+
|
33
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/idlc-sdk-pfm.
|
34
|
+
|
35
|
+
## License
|
36
|
+
|
37
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/pfm
ADDED
@@ -0,0 +1,299 @@
|
|
1
|
+
# @title Getting Started Guide
|
2
|
+
|
3
|
+
## `pfm` Executable
|
4
|
+
Bundled with this gem is an executable `pfm`. The `pfm` executable is a command-line tool that does the following:
|
5
|
+
|
6
|
+
* Generates server build repositories, templates, and default cookbooks
|
7
|
+
* Builds images with Packer from existing server build repositories
|
8
|
+
* Validates server build repositories, templates, and cookbooks
|
9
|
+
|
10
|
+
The following commands are available in PFM 0.3.x (see pfm -h for a full list):
|
11
|
+
|
12
|
+
```
|
13
|
+
Usage:
|
14
|
+
pfm -h/--help
|
15
|
+
pfm -v/--version
|
16
|
+
pfm command [arguments...] [options...]
|
17
|
+
|
18
|
+
|
19
|
+
Available Commands:
|
20
|
+
generate Generate a new server build, repository, cookbooks, etc.
|
21
|
+
build Build a specified server template
|
22
|
+
validate Test & validate a server build
|
23
|
+
exec Runs the command in context of the embedded ruby
|
24
|
+
configure Run initial setup and configuration
|
25
|
+
plan Show the infrastructure plan
|
26
|
+
apply Apply the infrastructure plan
|
27
|
+
destroy Destroy all managed infrastructure
|
28
|
+
format format infrastructure code
|
29
|
+
```
|
30
|
+
|
31
|
+
### Configuring `pfm`
|
32
|
+
#### `.pfm/` Options Directory
|
33
|
+
The `pfm` executable will automatically generate a default config file located at `.pfm/config`. It will set sensible defaults, that should work for most implementations. You can change these settings by editing the file directly or running `pfm configure`.
|
34
|
+
|
35
|
+
See available settings in {Pfm::Settings}
|
36
|
+
|
37
|
+
### `pfm` Commands
|
38
|
+
#### pfm generate server-build
|
39
|
+
Use the `pfm generate server-build` subcommand to generate server build repositories/templates.
|
40
|
+
|
41
|
+
##### Syntax
|
42
|
+
```
|
43
|
+
$ pfm generate server-build NAME [options]
|
44
|
+
```
|
45
|
+
|
46
|
+
##### Options
|
47
|
+
`-h`, `--help`
|
48
|
+
- Show this message
|
49
|
+
|
50
|
+
`-V`, `--verbose`
|
51
|
+
- Show detailed output from the generator
|
52
|
+
|
53
|
+
`-v`, `--version`
|
54
|
+
- Show pfm version
|
55
|
+
|
56
|
+
##### Examples
|
57
|
+
To generate a server build repositories, run a command similar to:
|
58
|
+
|
59
|
+
```
|
60
|
+
$ pfm generate server-build app-axpwa
|
61
|
+
```
|
62
|
+
|
63
|
+
|
64
|
+
#### pfm build
|
65
|
+
Use the `pfm build` subcommand to build server images (using Packer) from existing build repositories & templates (previously generated from `pfm generate`)
|
66
|
+
|
67
|
+
##### Syntax
|
68
|
+
```
|
69
|
+
$ pfm build BUILD_NAME [options]
|
70
|
+
```
|
71
|
+
|
72
|
+
##### Options
|
73
|
+
This subcommand has the following options:
|
74
|
+
|
75
|
+
`-a VERSION`, `--app-release VERSION`
|
76
|
+
- Application Version Number to build
|
77
|
+
|
78
|
+
`-n`, `--build-number NUMBER`
|
79
|
+
- Override the build number. Default is ENV::BUILD_NUMBER
|
80
|
+
|
81
|
+
`-t`, `--build-template TEMPLATE`
|
82
|
+
- The Packer Build Template to use. The default template file is `build.json`. This file should reside in the root of the server build directory.
|
83
|
+
|
84
|
+
`-m`, `--build-metadata METADATA_FILE`
|
85
|
+
- The build metadata file to use. The default metadata file is `metadata`. This file should reside in the root of the server build directory.
|
86
|
+
|
87
|
+
`-h`, `--help`
|
88
|
+
- Show this message
|
89
|
+
|
90
|
+
`-V`, `--verbose`
|
91
|
+
- Show detailed output from the generator
|
92
|
+
|
93
|
+
`-v`, `--version`
|
94
|
+
- Show pfm version
|
95
|
+
|
96
|
+
##### Examples
|
97
|
+
To build a server repositories/template, run a command similar to:
|
98
|
+
|
99
|
+
```
|
100
|
+
$ pfm build app-axpwa -a 3.1.0.1585
|
101
|
+
```
|
102
|
+
|
103
|
+
#### pfm validate server-build
|
104
|
+
Use the `pfm validate server-build` subcommand to validate a server build repository. This will run various tools such as Foodcritic, Rubocop, and ChefSpec against the build repo. Reports & Artifacts are generated and stored in `.pfm/tests/{reports,artifacts}`
|
105
|
+
|
106
|
+
##### Syntax
|
107
|
+
```
|
108
|
+
$ pfm validate server-build BUILD_NAME [options]
|
109
|
+
```
|
110
|
+
|
111
|
+
##### Options
|
112
|
+
`-t`, `--build-template TEMPLATE`
|
113
|
+
- The Build Template to use. Default is `build.json`
|
114
|
+
|
115
|
+
`-m`, `--build-metadata METADATA_FILE`
|
116
|
+
- The build metadata file to use. The default metadata file is `metadata`. This file should reside in the root of the server build directory.
|
117
|
+
|
118
|
+
`-c`, `--circle-ci`
|
119
|
+
- Use Circle Ci artifact output directories
|
120
|
+
|
121
|
+
`-h`, `--help`
|
122
|
+
- Show this message
|
123
|
+
|
124
|
+
`-V`, `--verbose`
|
125
|
+
- Show detailed output from the generator
|
126
|
+
|
127
|
+
`-v`, `--version`
|
128
|
+
- Show pfm version
|
129
|
+
|
130
|
+
##### Examples
|
131
|
+
To validate a build repository, run a command similar to:
|
132
|
+
|
133
|
+
```
|
134
|
+
$ pfm validate server-build app-axpwa
|
135
|
+
```
|
136
|
+
#### pfm validate infrastructure
|
137
|
+
Use the `pfm validate infrastructure` subcommand to validate a server build repository. This will run various tools such as Foodcritic, Rubocop, and ChefSpec against the build repo. Reports & Artifacts are generated and stored in `.pfm/tests/{reports,artifacts}`
|
138
|
+
|
139
|
+
##### Syntax
|
140
|
+
```
|
141
|
+
$ pfm validate infrastructure [options]
|
142
|
+
```
|
143
|
+
|
144
|
+
##### Options
|
145
|
+
`-h`, `--help`
|
146
|
+
- Show this message
|
147
|
+
|
148
|
+
`-V`, `--verbose`
|
149
|
+
- Show detailed output from the generator
|
150
|
+
|
151
|
+
`-v`, `--version`
|
152
|
+
- Show pfm version
|
153
|
+
|
154
|
+
##### Examples
|
155
|
+
To validate a build repository, run a command similar to:
|
156
|
+
|
157
|
+
```
|
158
|
+
$ pfm validate infrastructure
|
159
|
+
```
|
160
|
+
|
161
|
+
#### pfm exec
|
162
|
+
Use the `pfm exec` subcommand to run arbitrary shell commands with the PATH environment variable and the GEM_HOME and GEM_PATH Ruby environment variables pointed at the Pfm bundle.
|
163
|
+
|
164
|
+
##### Syntax
|
165
|
+
```
|
166
|
+
$ pfm exec SYSTEM_COMMAND [options]
|
167
|
+
```
|
168
|
+
|
169
|
+
##### Options
|
170
|
+
`-h`, `--help`
|
171
|
+
- Show this message
|
172
|
+
|
173
|
+
`-V`, `--verbose`
|
174
|
+
- Show detailed output from the generator
|
175
|
+
|
176
|
+
`-v`, `--version`
|
177
|
+
- Show pfm version
|
178
|
+
|
179
|
+
##### Examples
|
180
|
+
None.
|
181
|
+
|
182
|
+
#### pfm plan
|
183
|
+
Use the `pfm plan` subcommand to plan infrastructure changes before they are executed.
|
184
|
+
|
185
|
+
##### Syntax
|
186
|
+
```
|
187
|
+
$ pfm plan [options]
|
188
|
+
```
|
189
|
+
|
190
|
+
##### Options
|
191
|
+
|
192
|
+
`-a`, `--app-release VERSION`
|
193
|
+
- Application Version Number to Deploy
|
194
|
+
|
195
|
+
`-b`, `--server-build BUILD_NUMBER`
|
196
|
+
- The build number of the AMI to deploy
|
197
|
+
|
198
|
+
`-l`, `--landscape`
|
199
|
+
- Format the Terraform plan output with `terraform_landscape`
|
200
|
+
|
201
|
+
`-h`, `--help`
|
202
|
+
- Show this message
|
203
|
+
|
204
|
+
`-V`, `--verbose`
|
205
|
+
- Show detailed output
|
206
|
+
|
207
|
+
`-v`, `--version`
|
208
|
+
- Show pfm version
|
209
|
+
|
210
|
+
##### Examples
|
211
|
+
To plan an infrastructure release with application version number 3.1.0.1654, run a command similar to:
|
212
|
+
|
213
|
+
```
|
214
|
+
$ pfm plan -a 3.1.0.1654
|
215
|
+
```
|
216
|
+
|
217
|
+
#### pfm apply
|
218
|
+
Use the `pfm apply` subcommand to apply infrastructure changes before they are executed.
|
219
|
+
|
220
|
+
##### Syntax
|
221
|
+
```
|
222
|
+
$ pfm apply [options]
|
223
|
+
```
|
224
|
+
|
225
|
+
##### Options
|
226
|
+
|
227
|
+
`-a`, `--app-release VERSION`
|
228
|
+
- Application Version Number to Deploy
|
229
|
+
|
230
|
+
`-b`, `--server-build BUILD_NUMBER`
|
231
|
+
- The build number of the AMI to deploy
|
232
|
+
|
233
|
+
`-h`, `--help`
|
234
|
+
- Show this message
|
235
|
+
|
236
|
+
`-V`, `--verbose`
|
237
|
+
- Show detailed output
|
238
|
+
|
239
|
+
`-v`, `--version`
|
240
|
+
- Show pfm version
|
241
|
+
|
242
|
+
##### Examples
|
243
|
+
To apply an infrastructure release with application version number 3.1.0.1654, run a command similar to:
|
244
|
+
|
245
|
+
```
|
246
|
+
$ pfm apply -a 3.1.0.1654
|
247
|
+
```
|
248
|
+
|
249
|
+
#### pfm destroy
|
250
|
+
Use the `pfm destroy` subcommand to destroy a managed environment and all associated resources. THIS CANNOT BE UNDONE
|
251
|
+
|
252
|
+
##### Syntax
|
253
|
+
```
|
254
|
+
$ pfm destroy [options]
|
255
|
+
```
|
256
|
+
|
257
|
+
##### Options
|
258
|
+
|
259
|
+
`-h`, `--help`
|
260
|
+
- Show this message
|
261
|
+
|
262
|
+
`-V`, `--verbose`
|
263
|
+
- Show detailed output
|
264
|
+
|
265
|
+
`-v`, `--version`
|
266
|
+
- Show pfm version
|
267
|
+
|
268
|
+
##### Examples
|
269
|
+
To destroy a managed environment
|
270
|
+
|
271
|
+
```
|
272
|
+
$ pfm destroy
|
273
|
+
```
|
274
|
+
|
275
|
+
#### pfm format
|
276
|
+
Use the `pfm format` subcommand to format an infrastructure repository and associated files to a canonical format.
|
277
|
+
|
278
|
+
##### Syntax
|
279
|
+
```
|
280
|
+
$ pfm format [options]
|
281
|
+
```
|
282
|
+
|
283
|
+
##### Options
|
284
|
+
|
285
|
+
`-h`, `--help`
|
286
|
+
- Show this message
|
287
|
+
|
288
|
+
`-V`, `--verbose`
|
289
|
+
- Show detailed output
|
290
|
+
|
291
|
+
`-v`, `--version`
|
292
|
+
- Show pfm version
|
293
|
+
|
294
|
+
##### Examples
|
295
|
+
To format an infrastructure repository's files
|
296
|
+
|
297
|
+
```
|
298
|
+
$ pfm format
|
299
|
+
```
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "iapi-idlc-sdk-pfm/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "iapi-idlc-sdk-pfm"
|
8
|
+
spec.version = Pfm::VERSION
|
9
|
+
spec.authors = ["Nathan Cazell", "Michael McHolm"]
|
10
|
+
spec.email = ["techsupport@imageapi.com"]
|
11
|
+
|
12
|
+
spec.summary = 'IDLC SDK for AWS resources - PFM'
|
13
|
+
spec.description = 'Provides the pfm executable for idlc-sdk. This gem is part of the IDLC SDK'
|
14
|
+
spec.homepage = 'https://bitbucket.org/imageapi/iapi-idlc-sdk-pfm'
|
15
|
+
spec.license = 'MIT'
|
16
|
+
spec.executables << 'pfm'
|
17
|
+
|
18
|
+
spec.metadata = {
|
19
|
+
'source_code_uri' => 'https://bitbucket.org/imageapi/iapi-idlc-sdk-pfm'
|
20
|
+
}
|
21
|
+
|
22
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
23
|
+
f.match(%r{^(test|spec|features|bin)/})
|
24
|
+
end
|
25
|
+
|
26
|
+
spec.require_paths = ['lib']
|
27
|
+
|
28
|
+
spec.add_development_dependency 'bundler', '~> 2'
|
29
|
+
spec.add_development_dependency 'rake', '>= 12.3.3'
|
30
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
31
|
+
spec.add_development_dependency 'rubocop', '0.48.1'
|
32
|
+
spec.add_development_dependency 'pry'
|
33
|
+
spec.add_development_dependency 'yard'
|
34
|
+
|
35
|
+
spec.add_runtime_dependency 'iapi-idlc-sdk-core'
|
36
|
+
spec.add_runtime_dependency 'iapi-idlc-sdk-build'
|
37
|
+
spec.add_runtime_dependency 'iapi-idlc-sdk-deploy'
|
38
|
+
spec.add_runtime_dependency 'aws-sdk-s3'
|
39
|
+
spec.add_runtime_dependency 'berkshelf'
|
40
|
+
spec.add_runtime_dependency 'chefspec'
|
41
|
+
spec.add_runtime_dependency 'colorize'
|
42
|
+
spec.add_runtime_dependency 'foodcritic-junit'
|
43
|
+
spec.add_runtime_dependency 'foodcritic', '10.3.1'
|
44
|
+
spec.add_runtime_dependency 'cucumber-core', '5.0.2'
|
45
|
+
spec.add_runtime_dependency 'ohai', '< 13'
|
46
|
+
spec.add_runtime_dependency 'mixlib-cli'
|
47
|
+
spec.add_runtime_dependency 'mixlib-shellout'
|
48
|
+
spec.add_runtime_dependency 'rubocop-junit-formatter'
|
49
|
+
spec.add_runtime_dependency 'rubocop', '0.48.1'
|
50
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
Pfm.commands do |c|
|
2
|
+
c.builtin 'generate', :Generate, desc: 'Generate a new server build, repository, cookbooks, etc.'
|
3
|
+
c.builtin 'build', :Build, desc: 'Build a specified server template'
|
4
|
+
c.builtin 'validate', :Validate, desc: 'Test & validate a server build'
|
5
|
+
c.builtin 'exec', :Exec, desc: 'Runs the command in context of the embedded ruby'
|
6
|
+
c.builtin 'configure', :Configure, desc: 'Run initial setup and configuration'
|
7
|
+
c.builtin 'plan', :Plan, desc: 'Show the infrastructure plan'
|
8
|
+
c.builtin 'apply', :Apply, desc: 'Apply the infrastructure plan'
|
9
|
+
c.builtin 'destroy', :Destroy, desc: 'Destroy all managed infrastructure'
|
10
|
+
c.builtin 'format', :Format, desc: 'format infrastructure code'
|
11
|
+
c.builtin 'package', :Package, desc: 'package infrastructure repository'
|
12
|
+
end
|
@@ -0,0 +1,150 @@
|
|
1
|
+
module Pfm
|
2
|
+
class CLI
|
3
|
+
include Mixlib::CLI
|
4
|
+
include Pfm::Helpers
|
5
|
+
|
6
|
+
banner(<<-BANNER)
|
7
|
+
Usage:
|
8
|
+
pfm -h/--help
|
9
|
+
pfm -v/--version
|
10
|
+
pfm command [arguments...] [options...]
|
11
|
+
BANNER
|
12
|
+
|
13
|
+
option :version,
|
14
|
+
short: '-v',
|
15
|
+
long: '--version',
|
16
|
+
description: 'Show pfm version',
|
17
|
+
boolean: true
|
18
|
+
|
19
|
+
option :help,
|
20
|
+
short: '-h',
|
21
|
+
long: '--help',
|
22
|
+
description: 'Show this message',
|
23
|
+
boolean: true
|
24
|
+
|
25
|
+
option :verbose,
|
26
|
+
short: '-V',
|
27
|
+
long: '--verbose',
|
28
|
+
description: 'Show detailed output',
|
29
|
+
boolean: true,
|
30
|
+
default: false
|
31
|
+
|
32
|
+
attr_reader :argv
|
33
|
+
|
34
|
+
def initialize(argv)
|
35
|
+
@argv = argv
|
36
|
+
super() # mixlib-cli #initialize doesn't allow arguments
|
37
|
+
end
|
38
|
+
|
39
|
+
def run
|
40
|
+
subcommand_name, *subcommand_params = argv
|
41
|
+
|
42
|
+
ENV['DEBUG'] = true if verbose?
|
43
|
+
|
44
|
+
#
|
45
|
+
# Runs the appropriate subcommand if the given parameters contain any
|
46
|
+
# subcommands.
|
47
|
+
#
|
48
|
+
if subcommand_name.nil? || option?(subcommand_name)
|
49
|
+
handle_options
|
50
|
+
elsif have_command?(subcommand_name)
|
51
|
+
subcommand = instantiate_subcommand(subcommand_name)
|
52
|
+
exit_code = subcommand.run_with_default_options(subcommand_params)
|
53
|
+
exit normalized_exit_code(exit_code)
|
54
|
+
else
|
55
|
+
err "Unknown command `#{subcommand_name}'."
|
56
|
+
show_help
|
57
|
+
exit 1
|
58
|
+
end
|
59
|
+
rescue OptionParser::InvalidOption => e
|
60
|
+
err(e.message)
|
61
|
+
show_help
|
62
|
+
exit 1
|
63
|
+
end
|
64
|
+
|
65
|
+
# If no subcommand is given, then this class is handling the CLI request.
|
66
|
+
def handle_options
|
67
|
+
parse_options(argv)
|
68
|
+
if config[:version]
|
69
|
+
show_version
|
70
|
+
else
|
71
|
+
show_help
|
72
|
+
end
|
73
|
+
exit 0
|
74
|
+
end
|
75
|
+
|
76
|
+
def show_version
|
77
|
+
msg("Pfm Version: #{Pfm::VERSION}")
|
78
|
+
end
|
79
|
+
|
80
|
+
def show_help
|
81
|
+
msg(banner)
|
82
|
+
msg("\nAvailable Commands:")
|
83
|
+
|
84
|
+
justify_length = subcommands.map(&:length).max + 2
|
85
|
+
subcommand_specs.each do |name, spec|
|
86
|
+
msg(" #{name.ljust(justify_length)}#{spec.description}")
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def exit(n)
|
91
|
+
Kernel.exit(n)
|
92
|
+
end
|
93
|
+
|
94
|
+
def commands_map
|
95
|
+
Pfm.commands_map
|
96
|
+
end
|
97
|
+
|
98
|
+
def have_command?(name)
|
99
|
+
commands_map.have_command?(name)
|
100
|
+
end
|
101
|
+
|
102
|
+
def subcommands
|
103
|
+
commands_map.command_names
|
104
|
+
end
|
105
|
+
|
106
|
+
def subcommand_specs
|
107
|
+
commands_map.command_specs
|
108
|
+
end
|
109
|
+
|
110
|
+
def option?(param)
|
111
|
+
param =~ /^-/
|
112
|
+
end
|
113
|
+
|
114
|
+
def verbose?
|
115
|
+
@config[:verbose]
|
116
|
+
end
|
117
|
+
|
118
|
+
def instantiate_subcommand(name)
|
119
|
+
commands_map.instantiate(name)
|
120
|
+
end
|
121
|
+
|
122
|
+
private
|
123
|
+
|
124
|
+
def normalized_exit_code(maybe_integer)
|
125
|
+
if maybe_integer.is_a?(Integer) && (0..255).cover?(maybe_integer)
|
126
|
+
maybe_integer
|
127
|
+
else
|
128
|
+
0
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
# Find PATH or Path correctly if we are on Windows
|
133
|
+
def path_key
|
134
|
+
env.keys.grep(/\Apath\Z/i).first
|
135
|
+
end
|
136
|
+
|
137
|
+
# upcase drive letters for comparison since ruby has a String#capitalize function
|
138
|
+
def drive_upcase(path)
|
139
|
+
if Chef::Platform.windows? && path[0] =~ /^[A-Za-z]$/ && path[1, 2] == ':\\'
|
140
|
+
path.capitalize
|
141
|
+
else
|
142
|
+
path
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
def env
|
147
|
+
ENV
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|