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
@@ -0,0 +1,8 @@
|
|
1
|
+
# This is a Chef recipe file. It can be used to specify resources which will
|
2
|
+
# apply configuration to a server.
|
3
|
+
|
4
|
+
log "Welcome to Chef, #{node['example']['name']}!" do
|
5
|
+
level :info
|
6
|
+
end
|
7
|
+
|
8
|
+
# For more information, see the documentation: https://docs.chef.io/recipes.html
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# Data Bags
|
2
|
+
|
3
|
+
This directory contains directories of the various data bags you create for your infrastructure. Each subdirectory corresponds to a data bag on the Chef Server, and contains JSON files of the items that go in the bag.
|
4
|
+
|
5
|
+
For example, in this directory you'll find an example data bag directory called `example`, which contains an item definition called `example_item.json`
|
6
|
+
|
7
|
+
Before uploading this item to the server, we must first create the data bag on the Chef Server.
|
8
|
+
|
9
|
+
knife data bag create example
|
10
|
+
|
11
|
+
Then we can upload the items in the data bag's directory to the Chef Server.
|
12
|
+
|
13
|
+
knife data bag from file example example_item.json
|
14
|
+
|
15
|
+
For more information on data bags, see the Chef wiki page:
|
16
|
+
|
17
|
+
https://docs.chef.io/data_bags.html
|
18
|
+
|
19
|
+
# Encrypted Data Bags
|
20
|
+
|
21
|
+
Encrypted data bags allow you to encrypt the contents of your data bags. The content of attributes will no longer be searchable. To use encrypted data bags, first you must have or create a secret key.
|
22
|
+
|
23
|
+
openssl rand -base64 512 > secret_key
|
24
|
+
|
25
|
+
You may use this secret_key to add items to a data bag during a create.
|
26
|
+
|
27
|
+
knife data bag create --secret-file secret_key passwords mysql
|
28
|
+
|
29
|
+
You may also use it when adding ITEMs from files,
|
30
|
+
|
31
|
+
knife data bag create passwords
|
32
|
+
knife data bag from file passwords data_bags/passwords/mysql.json --secret-file secret_key
|
33
|
+
|
34
|
+
The JSON for the ITEM must contain a key named "id" with a value equal to "ITEM" and the contents will be encrypted when uploaded. For example,
|
35
|
+
|
36
|
+
{
|
37
|
+
"id": "mysql",
|
38
|
+
"password": "abc123"
|
39
|
+
}
|
40
|
+
|
41
|
+
Without the secret_key, the contents are encrypted.
|
42
|
+
|
43
|
+
knife data bag show passwords mysql
|
44
|
+
id: mysql
|
45
|
+
password: 2I0XUUve1TXEojEyeGsjhw==
|
46
|
+
|
47
|
+
Use the secret_key to view the contents.
|
48
|
+
|
49
|
+
knife data bag show passwords mysql --secret-file secret_key
|
50
|
+
id: mysql
|
51
|
+
password: abc123
|
52
|
+
|
53
|
+
|
54
|
+
For more information on encrypted data bags, see the Chef wiki page:
|
55
|
+
|
56
|
+
https://docs.chef.io/data_bags.html
|
@@ -0,0 +1,9 @@
|
|
1
|
+
Create environments here, in either the Role Ruby DSL (.rb) or JSON (.json) files. To install environments on the server, use knife.
|
2
|
+
|
3
|
+
For example, in this directory you'll find an example environment file called `example.json` which can be uploaded to the Chef Server:
|
4
|
+
|
5
|
+
knife environment from file environments/example.json
|
6
|
+
|
7
|
+
For more information on environments, see the Chef wiki page:
|
8
|
+
|
9
|
+
https://docs.chef.io/environments.html
|
@@ -0,0 +1,13 @@
|
|
1
|
+
{
|
2
|
+
"name": "example",
|
3
|
+
"description": "This is an example environment defined as JSON",
|
4
|
+
"chef_type": "environment",
|
5
|
+
"json_class": "Chef::Environment",
|
6
|
+
"default_attributes": {
|
7
|
+
},
|
8
|
+
"override_attributes": {
|
9
|
+
},
|
10
|
+
"cookbook_versions": {
|
11
|
+
"example": "= 1.0.0"
|
12
|
+
}
|
13
|
+
}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
Create policyfiles here. When using a chef-repo, give your policyfiles
|
2
|
+
the same filename as the name set in the policyfile itself, and use the
|
3
|
+
`.rb` file extension.
|
4
|
+
|
5
|
+
Compile the policy with a command like this:
|
6
|
+
|
7
|
+
```
|
8
|
+
chef install policies/my-app-frontend.rb
|
9
|
+
```
|
10
|
+
|
11
|
+
This will create a lockfile `policies/my-app-frontend.lock.json`.
|
12
|
+
|
13
|
+
To update locked dependencies, run `chef update` like this:
|
14
|
+
|
15
|
+
```
|
16
|
+
chef update policies/my-app-frontend.rb
|
17
|
+
```
|
18
|
+
|
19
|
+
You can upload the policy (with associated cookbooks) to the server
|
20
|
+
using a command like:
|
21
|
+
|
22
|
+
```
|
23
|
+
chef push staging policies/my-app-frontend.rb
|
24
|
+
```
|
@@ -0,0 +1,9 @@
|
|
1
|
+
Create roles here, in either the Role Ruby DSL (.rb) or JSON (.json) files. To install roles on the server, use knife.
|
2
|
+
|
3
|
+
For example, in this directory you'll find an example role file called `example.json` which can be uploaded to the Chef Server:
|
4
|
+
|
5
|
+
knife role from file roles/example.json
|
6
|
+
|
7
|
+
For more information on roles, see the Chef wiki page:
|
8
|
+
|
9
|
+
https://docs.chef.io/roles.html
|
@@ -0,0 +1,89 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
context = ChefDK::Generator.context
|
4
|
+
app_dir = File.join(context.app_root, context.app_name)
|
5
|
+
cookbooks_dir = context.cookbook_root
|
6
|
+
cookbook_dir = File.join(cookbooks_dir, context.cookbook_name)
|
7
|
+
|
8
|
+
# app root dir
|
9
|
+
directory app_dir
|
10
|
+
|
11
|
+
# Top level files
|
12
|
+
|
13
|
+
# Test Kitchen
|
14
|
+
template "#{app_dir}/.kitchen.yml" do
|
15
|
+
source 'kitchen.yml.erb'
|
16
|
+
helpers(ChefDK::Generator::TemplateHelper)
|
17
|
+
end
|
18
|
+
|
19
|
+
# Inspec
|
20
|
+
directory "#{app_dir}/test/smoke/default" do
|
21
|
+
recursive true
|
22
|
+
end
|
23
|
+
|
24
|
+
template "#{app_dir}/test/smoke/default/default_test.rb" do
|
25
|
+
source 'inspec_default_test.rb.erb'
|
26
|
+
helpers(ChefDK::Generator::TemplateHelper)
|
27
|
+
action :create_if_missing
|
28
|
+
end
|
29
|
+
|
30
|
+
# README
|
31
|
+
template "#{app_dir}/README.md" do
|
32
|
+
helpers(ChefDK::Generator::TemplateHelper)
|
33
|
+
end
|
34
|
+
|
35
|
+
# Generated Cookbook:
|
36
|
+
|
37
|
+
# cookbook collection dir
|
38
|
+
directory cookbooks_dir
|
39
|
+
|
40
|
+
# cookbook collection dir
|
41
|
+
directory cookbook_dir
|
42
|
+
|
43
|
+
# metadata.rb
|
44
|
+
template "#{cookbook_dir}/metadata.rb" do
|
45
|
+
helpers(ChefDK::Generator::TemplateHelper)
|
46
|
+
end
|
47
|
+
|
48
|
+
# chefignore
|
49
|
+
cookbook_file "#{cookbook_dir}/chefignore"
|
50
|
+
|
51
|
+
# Berks
|
52
|
+
cookbook_file "#{cookbook_dir}/Berksfile"
|
53
|
+
|
54
|
+
# Recipes
|
55
|
+
|
56
|
+
directory "#{cookbook_dir}/recipes"
|
57
|
+
|
58
|
+
template "#{cookbook_dir}/recipes/default.rb" do
|
59
|
+
source 'recipe.rb.erb'
|
60
|
+
helpers(ChefDK::Generator::TemplateHelper)
|
61
|
+
end
|
62
|
+
|
63
|
+
# Chefspec
|
64
|
+
directory "#{cookbook_dir}/spec/unit/recipes" do
|
65
|
+
recursive true
|
66
|
+
end
|
67
|
+
|
68
|
+
cookbook_file "#{cookbook_dir}/spec/spec_helper.rb" do
|
69
|
+
action :create_if_missing
|
70
|
+
end
|
71
|
+
|
72
|
+
template "#{cookbook_dir}/spec/unit/recipes/default_spec.rb" do
|
73
|
+
source 'recipe_spec.rb.erb'
|
74
|
+
helpers(ChefDK::Generator::TemplateHelper)
|
75
|
+
action :create_if_missing
|
76
|
+
end
|
77
|
+
|
78
|
+
# git
|
79
|
+
if context.have_git
|
80
|
+
unless context.skip_git_init
|
81
|
+
execute('initialize-git') do
|
82
|
+
command('git init .')
|
83
|
+
cwd app_dir
|
84
|
+
end
|
85
|
+
end
|
86
|
+
cookbook_file "#{app_dir}/.gitignore" do
|
87
|
+
source 'gitignore'
|
88
|
+
end
|
89
|
+
end
|
data/lib/iapi-idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/recipes/attribute.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
|
2
|
+
context = ChefDK::Generator.context
|
3
|
+
cookbook_dir = File.join(context.cookbook_root, context.cookbook_name)
|
4
|
+
attribute_dir = File.join(cookbook_dir, 'attributes')
|
5
|
+
attribute_path = File.join(cookbook_dir, 'attributes', "#{context.new_file_basename}.rb")
|
6
|
+
|
7
|
+
directory attribute_dir
|
8
|
+
|
9
|
+
template attribute_path do
|
10
|
+
source 'attribute.rb.erb'
|
11
|
+
helpers(ChefDK::Generator::TemplateHelper)
|
12
|
+
end
|
@@ -0,0 +1,182 @@
|
|
1
|
+
|
2
|
+
context = ChefDK::Generator.context
|
3
|
+
delivery_project_dir = context.delivery_project_dir
|
4
|
+
pipeline = context.pipeline
|
5
|
+
dot_delivery_dir = File.join(delivery_project_dir, '.delivery')
|
6
|
+
config_json = File.join(dot_delivery_dir, 'config.json')
|
7
|
+
project_toml = File.join(dot_delivery_dir, 'project.toml')
|
8
|
+
|
9
|
+
generator_desc('Ensuring delivery configuration')
|
10
|
+
|
11
|
+
directory dot_delivery_dir
|
12
|
+
|
13
|
+
cookbook_file config_json do
|
14
|
+
source 'delivery-config.json'
|
15
|
+
not_if { File.exist?(config_json) }
|
16
|
+
end
|
17
|
+
|
18
|
+
# Adding a new prototype file for delivery-cli local commands
|
19
|
+
cookbook_file project_toml do
|
20
|
+
source 'delivery-project.toml'
|
21
|
+
not_if { File.exist?(project_toml) }
|
22
|
+
end
|
23
|
+
|
24
|
+
generator_desc('Ensuring correct delivery build cookbook content')
|
25
|
+
|
26
|
+
build_cookbook_dir = File.join(dot_delivery_dir, 'build_cookbook')
|
27
|
+
|
28
|
+
# cookbook root dir
|
29
|
+
directory build_cookbook_dir
|
30
|
+
|
31
|
+
# metadata.rb
|
32
|
+
template "#{build_cookbook_dir}/metadata.rb" do
|
33
|
+
source 'build_cookbook/metadata.rb.erb'
|
34
|
+
helpers(ChefDK::Generator::TemplateHelper)
|
35
|
+
action :create_if_missing
|
36
|
+
end
|
37
|
+
|
38
|
+
# README
|
39
|
+
cookbook_file "#{build_cookbook_dir}/README.md" do
|
40
|
+
source 'build_cookbook/README.md'
|
41
|
+
action :create_if_missing
|
42
|
+
end
|
43
|
+
|
44
|
+
# LICENSE
|
45
|
+
template "#{build_cookbook_dir}/LICENSE" do
|
46
|
+
source "LICENSE.#{context.license}.erb"
|
47
|
+
helpers(ChefDK::Generator::TemplateHelper)
|
48
|
+
action :create_if_missing
|
49
|
+
end
|
50
|
+
|
51
|
+
# chefignore
|
52
|
+
cookbook_file "#{build_cookbook_dir}/chefignore"
|
53
|
+
|
54
|
+
# Berksfile
|
55
|
+
template "#{build_cookbook_dir}/Berksfile" do
|
56
|
+
source 'build_cookbook/Berksfile.erb'
|
57
|
+
helpers(ChefDK::Generator::TemplateHelper)
|
58
|
+
action :create_if_missing
|
59
|
+
end
|
60
|
+
|
61
|
+
# Recipes
|
62
|
+
directory "#{build_cookbook_dir}/recipes"
|
63
|
+
|
64
|
+
%w(default deploy functional lint provision publish quality security smoke syntax unit).each do |phase|
|
65
|
+
template "#{build_cookbook_dir}/recipes/#{phase}.rb" do
|
66
|
+
source 'build_cookbook/recipe.rb.erb'
|
67
|
+
helpers(ChefDK::Generator::TemplateHelper)
|
68
|
+
variables phase: phase
|
69
|
+
action :create_if_missing
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
# Test Kitchen build node
|
74
|
+
cookbook_file "#{build_cookbook_dir}/.kitchen.yml" do
|
75
|
+
source 'build_cookbook/.kitchen.yml'
|
76
|
+
end
|
77
|
+
|
78
|
+
directory "#{build_cookbook_dir}/data_bags/keys" do
|
79
|
+
recursive true
|
80
|
+
end
|
81
|
+
|
82
|
+
file "#{build_cookbook_dir}/data_bags/keys/delivery_builder_keys.json" do
|
83
|
+
content '{"id": "delivery_builder_keys"}'
|
84
|
+
end
|
85
|
+
|
86
|
+
directory "#{build_cookbook_dir}/secrets"
|
87
|
+
|
88
|
+
file "#{build_cookbook_dir}/secrets/fakey-mcfakerton"
|
89
|
+
|
90
|
+
directory "#{build_cookbook_dir}/test/fixtures/cookbooks/test/recipes" do
|
91
|
+
recursive true
|
92
|
+
end
|
93
|
+
|
94
|
+
file "#{build_cookbook_dir}/test/fixtures/cookbooks/test/metadata.rb" do
|
95
|
+
content %(name 'test'
|
96
|
+
version '0.1.0')
|
97
|
+
end
|
98
|
+
|
99
|
+
cookbook_file "#{build_cookbook_dir}/test/fixtures/cookbooks/test/recipes/default.rb" do
|
100
|
+
source 'build_cookbook/test-fixture-recipe.rb'
|
101
|
+
end
|
102
|
+
|
103
|
+
# Construct git history as if we did all the work in a feature branch which we
|
104
|
+
# merged into master at the end, which looks like this:
|
105
|
+
#
|
106
|
+
# ```
|
107
|
+
# git log --graph --oneline
|
108
|
+
# * 5fec5bd Merge branch 'add-delivery-configuration'
|
109
|
+
# |\
|
110
|
+
# | * 967bb9f Add generated delivery build cookbook
|
111
|
+
# | * 1558e0a Add generated delivery configuration
|
112
|
+
# |/
|
113
|
+
# * db22790 Add generated cookbook content
|
114
|
+
# ```
|
115
|
+
#
|
116
|
+
if context.have_git && context.delivery_project_git_initialized && !context.skip_git_init
|
117
|
+
|
118
|
+
generator_desc('Adding delivery configuration to feature branch')
|
119
|
+
|
120
|
+
execute('git-create-feature-branch') do
|
121
|
+
command('git checkout -t -b add-delivery-configuration')
|
122
|
+
cwd delivery_project_dir
|
123
|
+
|
124
|
+
not_if 'git branch |grep "add-delivery-configuration"'
|
125
|
+
end
|
126
|
+
|
127
|
+
execute('git-add-delivery-config-json') do
|
128
|
+
command('git add .delivery/config.json')
|
129
|
+
cwd delivery_project_dir
|
130
|
+
|
131
|
+
only_if 'git status -u --porcelain |grep ".delivery/config.json"'
|
132
|
+
end
|
133
|
+
|
134
|
+
# Adding the new prototype file to the feature branch
|
135
|
+
# so it gets checked in with the delivery config commit
|
136
|
+
execute('git-add-delivery-project-toml') do
|
137
|
+
command('git add .delivery/project.toml')
|
138
|
+
cwd delivery_project_dir
|
139
|
+
|
140
|
+
only_if 'git status -u --porcelain |grep ".delivery/project.toml"'
|
141
|
+
end
|
142
|
+
|
143
|
+
execute('git-commit-delivery-config') do
|
144
|
+
command('git commit -m "Add generated delivery configuration"')
|
145
|
+
cwd delivery_project_dir
|
146
|
+
|
147
|
+
only_if 'git status -u --porcelain | egrep "config.json|project.toml"'
|
148
|
+
end
|
149
|
+
|
150
|
+
generator_desc('Adding build cookbook to feature branch')
|
151
|
+
|
152
|
+
execute('git-add-delivery-build-cookbook-files') do
|
153
|
+
command('git add .delivery')
|
154
|
+
cwd delivery_project_dir
|
155
|
+
|
156
|
+
only_if 'git status -u --porcelain |grep ".delivery"'
|
157
|
+
end
|
158
|
+
|
159
|
+
execute('git-commit-delivery-build-cookbook') do
|
160
|
+
command('git commit -m "Add generated delivery build cookbook"')
|
161
|
+
cwd delivery_project_dir
|
162
|
+
|
163
|
+
only_if 'git status -u --porcelain |grep ".delivery"'
|
164
|
+
end
|
165
|
+
|
166
|
+
execute("git-return-to-#{pipeline}-branch") do
|
167
|
+
command("git checkout #{pipeline}")
|
168
|
+
cwd delivery_project_dir
|
169
|
+
end
|
170
|
+
|
171
|
+
generator_desc('Merging delivery content feature branch to master')
|
172
|
+
|
173
|
+
execute('git-merge-delivery-config-branch') do
|
174
|
+
command('git merge --no-ff add-delivery-configuration')
|
175
|
+
cwd delivery_project_dir
|
176
|
+
end
|
177
|
+
|
178
|
+
execute('git-remove-delivery-config-branch') do
|
179
|
+
command('git branch -D add-delivery-configuration')
|
180
|
+
cwd delivery_project_dir
|
181
|
+
end
|
182
|
+
end
|
data/lib/iapi-idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/recipes/cookbook.rb
ADDED
@@ -0,0 +1,144 @@
|
|
1
|
+
|
2
|
+
context = ChefDK::Generator.context
|
3
|
+
cookbook_dir = File.join(context.cookbook_root, context.cookbook_name)
|
4
|
+
|
5
|
+
silence_chef_formatter unless context.verbose
|
6
|
+
|
7
|
+
generator_desc('Ensuring correct cookbook file content')
|
8
|
+
|
9
|
+
# cookbook root dir
|
10
|
+
directory cookbook_dir
|
11
|
+
|
12
|
+
# metadata.rb
|
13
|
+
spdx_license = case context.license
|
14
|
+
when 'apachev2'
|
15
|
+
'Apache-2.0'
|
16
|
+
when 'mit'
|
17
|
+
'MIT'
|
18
|
+
when 'gplv2'
|
19
|
+
'GPL-2.0'
|
20
|
+
when 'gplv3'
|
21
|
+
'GPL-3.0'
|
22
|
+
else
|
23
|
+
'All Rights Reserved'
|
24
|
+
end
|
25
|
+
|
26
|
+
template "#{cookbook_dir}/metadata.rb" do
|
27
|
+
helpers(ChefDK::Generator::TemplateHelper)
|
28
|
+
variables(
|
29
|
+
spdx_license: spdx_license
|
30
|
+
)
|
31
|
+
action :create_if_missing
|
32
|
+
end
|
33
|
+
|
34
|
+
# README
|
35
|
+
template "#{cookbook_dir}/README.md" do
|
36
|
+
helpers(ChefDK::Generator::TemplateHelper)
|
37
|
+
action :create_if_missing
|
38
|
+
end
|
39
|
+
|
40
|
+
# chefignore
|
41
|
+
cookbook_file "#{cookbook_dir}/chefignore"
|
42
|
+
|
43
|
+
if context.use_berkshelf
|
44
|
+
|
45
|
+
# Berks
|
46
|
+
cookbook_file "#{cookbook_dir}/Berksfile" do
|
47
|
+
action :create_if_missing
|
48
|
+
end
|
49
|
+
else
|
50
|
+
|
51
|
+
# Policyfile
|
52
|
+
template "#{cookbook_dir}/Policyfile.rb" do
|
53
|
+
source 'Policyfile.rb.erb'
|
54
|
+
helpers(ChefDK::Generator::TemplateHelper)
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
# Test Kitchen
|
60
|
+
template "#{cookbook_dir}/.kitchen.yml" do
|
61
|
+
if context.use_berkshelf
|
62
|
+
source 'kitchen.yml.erb'
|
63
|
+
else
|
64
|
+
source 'kitchen_policyfile.yml.erb'
|
65
|
+
end
|
66
|
+
|
67
|
+
helpers(ChefDK::Generator::TemplateHelper)
|
68
|
+
action :create_if_missing
|
69
|
+
end
|
70
|
+
|
71
|
+
# Inspec
|
72
|
+
directory "#{cookbook_dir}/test/smoke/default" do
|
73
|
+
recursive true
|
74
|
+
end
|
75
|
+
|
76
|
+
template "#{cookbook_dir}/test/smoke/default/default_test.rb" do
|
77
|
+
source 'inspec_default_test.rb.erb'
|
78
|
+
helpers(ChefDK::Generator::TemplateHelper)
|
79
|
+
action :create_if_missing
|
80
|
+
end
|
81
|
+
|
82
|
+
# Chefspec
|
83
|
+
directory "#{cookbook_dir}/spec/unit/recipes" do
|
84
|
+
recursive true
|
85
|
+
end
|
86
|
+
|
87
|
+
cookbook_file "#{cookbook_dir}/spec/spec_helper.rb" do
|
88
|
+
if context.use_berkshelf
|
89
|
+
source 'spec_helper.rb'
|
90
|
+
else
|
91
|
+
source 'spec_helper_policyfile.rb'
|
92
|
+
end
|
93
|
+
|
94
|
+
action :create_if_missing
|
95
|
+
end
|
96
|
+
|
97
|
+
template "#{cookbook_dir}/spec/unit/recipes/default_spec.rb" do
|
98
|
+
source 'recipe_spec.rb.erb'
|
99
|
+
helpers(ChefDK::Generator::TemplateHelper)
|
100
|
+
action :create_if_missing
|
101
|
+
end
|
102
|
+
|
103
|
+
# Recipes
|
104
|
+
|
105
|
+
directory "#{cookbook_dir}/recipes"
|
106
|
+
|
107
|
+
template "#{cookbook_dir}/recipes/default.rb" do
|
108
|
+
source 'recipe.rb.erb'
|
109
|
+
helpers(ChefDK::Generator::TemplateHelper)
|
110
|
+
action :create_if_missing
|
111
|
+
end
|
112
|
+
|
113
|
+
# git
|
114
|
+
if context.have_git
|
115
|
+
unless context.skip_git_init
|
116
|
+
|
117
|
+
generator_desc('Committing cookbook files to git')
|
118
|
+
|
119
|
+
execute('initialize-git') do
|
120
|
+
command('git init .')
|
121
|
+
cwd cookbook_dir
|
122
|
+
end
|
123
|
+
|
124
|
+
end
|
125
|
+
|
126
|
+
cookbook_file "#{cookbook_dir}/.gitignore" do
|
127
|
+
source 'gitignore'
|
128
|
+
end
|
129
|
+
|
130
|
+
unless context.skip_git_init
|
131
|
+
|
132
|
+
execute('git-add-new-files') do
|
133
|
+
command('git add .')
|
134
|
+
cwd cookbook_dir
|
135
|
+
end
|
136
|
+
|
137
|
+
execute('git-commit-new-files') do
|
138
|
+
command('git commit -m "Add generated cookbook content"')
|
139
|
+
cwd cookbook_dir
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
include_recipe '::build_cookbook' if context.enable_delivery
|
@@ -0,0 +1,24 @@
|
|
1
|
+
|
2
|
+
context = ChefDK::Generator.context
|
3
|
+
cookbook_dir = File.join(context.cookbook_root, context.cookbook_name)
|
4
|
+
files_dir = File.join(cookbook_dir, 'files', 'default')
|
5
|
+
cookbook_file_path = File.join(cookbook_dir, 'files', 'default', context.new_file_basename)
|
6
|
+
|
7
|
+
directory files_dir do
|
8
|
+
recursive true
|
9
|
+
end
|
10
|
+
|
11
|
+
if context.content_source
|
12
|
+
|
13
|
+
file cookbook_file_path do
|
14
|
+
content(IO.read(context.context_source))
|
15
|
+
end
|
16
|
+
|
17
|
+
else
|
18
|
+
|
19
|
+
template cookbook_file_path do
|
20
|
+
source 'cookbook_file.erb'
|
21
|
+
helpers(ChefDK::Generator::TemplateHelper)
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
data/lib/iapi-idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/recipes/lwrp.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
|
2
|
+
context = ChefDK::Generator.context
|
3
|
+
cookbook_dir = File.join(context.cookbook_root, context.cookbook_name)
|
4
|
+
|
5
|
+
resource_dir = File.join(cookbook_dir, 'resources')
|
6
|
+
resource_path = File.join(resource_dir, "#{context.new_file_basename}.rb")
|
7
|
+
|
8
|
+
provider_dir = File.join(cookbook_dir, 'providers')
|
9
|
+
provider_path = File.join(provider_dir, "#{context.new_file_basename}.rb")
|
10
|
+
|
11
|
+
directory resource_dir
|
12
|
+
|
13
|
+
template resource_path do
|
14
|
+
source 'resource.rb.erb'
|
15
|
+
helpers(ChefDK::Generator::TemplateHelper)
|
16
|
+
end
|
17
|
+
|
18
|
+
directory provider_dir
|
19
|
+
|
20
|
+
template provider_path do
|
21
|
+
source 'provider.rb.erb'
|
22
|
+
helpers(ChefDK::Generator::TemplateHelper)
|
23
|
+
end
|