aws-must 0.0.6 → 0.0.7

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.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +11 -5
  3. data/bin/aws-must.rb +42 -2
  4. data/demo/1/root.mustache +3 -0
  5. data/demo/2/resources.mustache +7 -3
  6. data/demo/2/root.mustache +41 -5
  7. data/demo/3/resource.mustache +6 -7
  8. data/demo/3/resourceInstance.mustache +6 -7
  9. data/demo/3/resources.mustache +7 -2
  10. data/demo/3/root.mustache +42 -17
  11. data/demo/4/output.mustache +6 -10
  12. data/demo/4/resource.mustache +6 -8
  13. data/demo/4/resourceInstance.mustache +6 -11
  14. data/demo/4/resourceSecurityGroup.mustache +6 -8
  15. data/demo/4/resources.mustache +8 -4
  16. data/demo/4/root.mustache +44 -17
  17. data/demo/5/mappings.mustache +5 -2
  18. data/demo/5/output.mustache +5 -11
  19. data/demo/5/resource.mustache +6 -10
  20. data/demo/5/resourceInstance.mustache +7 -9
  21. data/demo/5/resources.mustache +8 -5
  22. data/demo/5/root.mustache +44 -10
  23. data/demo/6/mappings.mustache +6 -3
  24. data/demo/6/output.mustache +8 -11
  25. data/demo/6/parameter.mustache +7 -11
  26. data/demo/6/resource.mustache +7 -17
  27. data/demo/6/resourceInstance.mustache +8 -16
  28. data/demo/6/resourceSecurityGroup.mustache +7 -8
  29. data/demo/6/resources.mustache +11 -5
  30. data/demo/6/root.mustache +53 -25
  31. data/demo/6/tag.mustache +6 -12
  32. data/demo/7/mappings.mustache +6 -3
  33. data/demo/7/output.mustache +8 -13
  34. data/demo/7/parameter.mustache +7 -11
  35. data/demo/7/resource.mustache +8 -17
  36. data/demo/7/resourceInstance.mustache +8 -16
  37. data/demo/7/resourceInstanceChef.mustache +6 -10
  38. data/demo/7/resourceSecurityGroup.mustache +8 -8
  39. data/demo/7/resources.mustache +10 -5
  40. data/demo/7/root.mustache +51 -25
  41. data/demo/7/tag.mustache +6 -10
  42. data/lib/aws-must/docu.rb +31 -7
  43. data/lib/aws-must/template.rb +23 -0
  44. data/lib/utils/hasher.rb +3 -1
  45. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8326b8dfa72e7fea5dc9d0b4f20d7f02e2071f50
4
- data.tar.gz: 7c2ea2b9ad369395c758e60e1bd655e4c32225be
3
+ metadata.gz: b5cbfe13a7f701b92bdb2bb092716c9ad6a58403
4
+ data.tar.gz: ce6ebf729e31b5d0a66294ced5060365fda6ebab
5
5
  SHA512:
6
- metadata.gz: 231f3f0d6c8ae16b2cbe73bdbc5a84004c167c2a622c2a69c65338502fc16311545108994c7bb69b8a78fc82c1b1eea538ed73ea56b2872f7b10fa68a1ffe22a
7
- data.tar.gz: 5990bcc8e7bcd562356d4c99edce55530458086066cad26900c7e41c0c280cc17058c7ae72b19c89119aeae5e66df667dc6e4bf792ffd971b752d05191b94e9b
6
+ metadata.gz: 1d62abc49a43f6347439054009544963440daf46159f37b1a8413a9b91de1271909b291dd4599f7d5f811a39cb6de24ac45794fbc2b142cdc306ef8b265687eb
7
+ data.tar.gz: 5952680e1bd12a74c3f6e427351cb0f5c0ec8a61c9b329e44b7f5f8899fd5f6fbae9d65476074ddb002b116f8c26f165fd521ea85cd1f49088d211339eeb2756
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # aws-must - Minimum Viable Solution to Manage CloudFormation Templates - $Release:0.0.6$
1
+ # aws-must - Minimum Viable Solution to Manage CloudFormation Templates - $Release:0.0.7$
2
2
 
3
3
  `aws-must` is a tool, which allows separating infrastructure
4
4
  configuration and Amazon related syntax in CloudFormation JSON
@@ -78,7 +78,6 @@ Add following lines to `Gemfile`
78
78
  source 'https://rubygems.org'
79
79
  gem 'aws-must'
80
80
 
81
-
82
81
  and run
83
82
 
84
83
  bundle install
@@ -99,11 +98,18 @@ template `./mustache/root.mustache` issue the command
99
98
 
100
99
  aws-must.rb gen yaml_file
101
100
 
102
- To extract documentation between **++start++** and
103
- **++close++** -tags starting with template
104
- `./mustache/root.mustache`, issue the command
101
+ To extract documentation from template `./mustache/root.mustache`,
102
+ issue the command
105
103
 
106
104
  aws-must.rb doc
105
+
106
+
107
+ Documentation is extracted from lines surrounded by **+++start+++**
108
+ and **+++close+++** tags, or by **+++fold-on+++** and
109
+ **+++fold-off+++** tags. To see more information on how documentation
110
+ is generated, issue the the command
111
+
112
+ aws-must.rb help doc
107
113
 
108
114
  To dump YAML `yaml_file` in JSON format
109
115
 
data/bin/aws-must.rb CHANGED
@@ -8,8 +8,17 @@ class App < Thor
8
8
 
9
9
  include Utils::MyLogger # mix logger
10
10
  PROGNAME = "main" # logger progname
11
+
12
+ # default values
13
+
11
14
  DEAFAULT_TEMPLATE="root" # name of template in :template_path -directory
12
15
 
16
+ # DEFAUL_FOLD_ON="<!--*SED-MAGIC* <div class=window> -->" # default output for +++fold-on+++ tag
17
+ # DEFAUL_FOLD_OFF="<!--*SED-MAGIC* </div> -->" # default output for +++fold-off+++ tag
18
+
19
+ # default output for +++fold-on+++ tag
20
+ DEFAUL_FOLD_ON="<div class='fold'>Check to show template: <input type='checkbox' class='toggle'/><div>"
21
+ DEFAUL_FOLD_OFF="</div></div>" # default output for +++fold-off+++ tag
13
22
 
14
23
  # ------------------------------------------------------------------
15
24
 
@@ -26,12 +35,42 @@ class App < Thor
26
35
  :default => "mustache",
27
36
  :desc => "Directory holding mustache templates"
28
37
 
38
+ option :fold_on, :aliases => "-n", :type => :string,
39
+ :default => DEFAUL_FOLD_ON,
40
+ :desc => "Output for +++fold-on+++ tag"
41
+
42
+ option :fold_off, :aliases => "-f", :type => :string,
43
+ :default => DEFAUL_FOLD_OFF,
44
+ :desc => "Output for +++fold-off+++ tag"
45
+
29
46
  long_desc <<-LONGDESC
30
47
 
31
- Extract documation from <template_name> in ':template_path' -direcotory.
48
+ Extract documation from <template_name> in ':template_path' -directory.
32
49
 
33
50
  <template_name> defaults to '#{DEAFAULT_TEMPLATE}'
34
51
 
52
+
53
+ Documentation is extracted from lines surrounded by #{AwsMust::Docu::DEFAULT_OPEN_TAG} and #{AwsMust::Docu::DEFAULT_CLOSE_TAG} tags,
54
+ or by #{AwsMust::Docu::DEFAULT_FOLD_ON_TAG} and #{AwsMust::Docu::DEFAULT_FOLD_OFF_TAG} tags.
55
+
56
+ Following rules apply:
57
+
58
+ - #{AwsMust::Docu::DEFAULT_OPEN_TAG}, #{AwsMust::Docu::DEFAULT_CLOSE_TAG} -tags: nothing is outputted for these lines
59
+
60
+ - #{AwsMust::Docu::DEFAULT_FOLD_ON_TAG} -tag: output text for --fold_on option (defaults '#{DEFAUL_FOLD_ON}')
61
+
62
+ - #{AwsMust::Docu::DEFAULT_FOLD_OFF_TAG} -tag: output text for --fold_off option (defaults '#{DEFAUL_FOLD_OFF}')
63
+
64
+
65
+ Defult fold_on and fold_off parameters implement CCS-toggle when using following css-code
66
+
67
+ /* CSS-support fold-on/fold-off toggle */\n
68
+ div.fold { width: 90%; padding: .42rem; border-radius: 5px; margin: 1rem; }\n
69
+ div.fold div { height: 0px; margin: .2rem; overflow: hidden; }\n
70
+ div.toggle ~ div { height: 0px; margin: .2rem; overflow: hidden; }\n
71
+ input.toggle:checked ~ div { height: auto;color: white; background: #c6a24b;font-family: monospace;white-space: pre; }\n
72
+
73
+
35
74
  LONGDESC
36
75
 
37
76
  def doc( template_name=DEAFAULT_TEMPLATE )
@@ -52,7 +91,8 @@ LONGDESC
52
91
  'with_adjust' (yes/no)
53
92
 
54
93
  By default 'adjusts' data, i.e. adds property "_comma" with the
55
- value "," to each sub document expect the last one in an array.
94
+ value "," to each sub document, expect the last sub-document is
95
+ adjusted with empty string "".
56
96
 
57
97
  The "_comma" -property helps in generating valid json arrays in
58
98
  mustache templates. For example, YAML construct
data/demo/1/root.mustache CHANGED
@@ -8,6 +8,8 @@ only region `eu-central-1`. No ssh connection allowed by default.
8
8
 
9
9
  +++close+++
10
10
  }}
11
+
12
+
11
13
  {
12
14
  "AWSTemplateFormatVersion" : "2010-09-09",
13
15
  "Description" : "A simple Amazon EC2 instance. Initial copy",
@@ -21,3 +23,4 @@ only region `eu-central-1`. No ssh connection allowed by default.
21
23
  }
22
24
  }
23
25
  }
26
+
@@ -2,7 +2,7 @@
2
2
 
3
3
  resources.mustache - fixed resources
4
4
 
5
- ++start++
5
+ +++start+++
6
6
 
7
7
  ## <a id="resources.mustache"></a>resources.mustache <a class='navigator' href='#top'">[top]</a>
8
8
 
@@ -11,11 +11,12 @@ Create an EC2 with following fixed parameters
11
11
  * `ImageId` : "ami-00dae61d",
12
12
  * `InstanceType` : "t2.micro"
13
13
 
14
- ++close++
14
+ +++close+++
15
15
 
16
16
 
17
17
  }}
18
18
 
19
+ {{! +++fold-on+++ }}
19
20
 
20
21
  "MyEC2Instance" : {
21
22
  "Type" : "AWS::EC2::Instance",
@@ -23,4 +24,7 @@ Create an EC2 with following fixed parameters
23
24
  "ImageId" : "ami-00dae61d",
24
25
  "InstanceType" : "t2.micro"
25
26
  }
26
- }
27
+ }
28
+
29
+
30
+ {{! +++fold-off+++ }}
data/demo/2/root.mustache CHANGED
@@ -5,7 +5,7 @@
5
5
  STYLE section
6
6
  ==================================================================
7
7
 
8
- ++start++
8
+ +++start+++
9
9
  <style>
10
10
  h1 {
11
11
  color:blue;
@@ -18,23 +18,41 @@ h2 {
18
18
  body {
19
19
  background-color: #b0c4de;
20
20
  }
21
+ /* Support fold-on/fold-off toggle */
22
+ div.fold {
23
+ width: 90%; padding: .42rem; border-radius: 5px; margin: 1rem;
24
+
25
+ }
26
+ div.fold div {
27
+ height: 0px; margin: .2rem; overflow: hidden;
28
+ }
29
+ div.toggle ~ div { height: 0px; margin: .2rem; overflow: hidden; }
30
+ input.toggle:checked ~ div {
31
+ height: auto;
32
+ color: white;
33
+ background: #c6a24b;
34
+ font-family: monospace;
35
+ white-space: pre;
36
+ }
21
37
  </style>
22
- ++close++
38
+ +++close+++
23
39
  }}
24
40
 
25
41
  {{!
26
- ++start++
42
+ +++start+++
27
43
 
28
44
  # <a id="top">aws-must demo 2 template</a>
29
45
 
30
46
  Create an EC2 with following fixed parnameters `ImageId`
31
47
  ("ami-00dae61d") and `InstanceType` ("t2.micro")
32
48
 
33
- > resources
34
49
 
35
- ++close++
50
+ +++close+++
36
51
  }}
37
52
 
53
+
54
+ {{! +++fold-on+++ }}
55
+
38
56
  {
39
57
  "AWSTemplateFormatVersion" : "2010-09-09",
40
58
  "Description" : "{{description}}",
@@ -42,3 +60,21 @@ Create an EC2 with following fixed parnameters `ImageId`
42
60
  {{> resources }}
43
61
  }
44
62
  }
63
+
64
+ {{! +++fold-off+++ }}
65
+
66
+ {{!
67
+
68
+ ==================================================================
69
+ INCLUDED templates
70
+ ==================================================================
71
+
72
+ +++start+++
73
+
74
+ > resources
75
+
76
+ +++close+++
77
+
78
+ }}
79
+
80
+
@@ -2,7 +2,7 @@
2
2
 
3
3
  resource.mustache
4
4
 
5
- ++start++
5
+ +++start+++
6
6
 
7
7
  ## <a id="resource.mustache"></a>resource.mustache <a class='navigator' href='#top'">[top]</a>
8
8
 
@@ -13,15 +13,14 @@ Dispatches resource sub-type templates based resource Type propertys
13
13
  * `Instance`: sub-document defining an EC instance
14
14
 
15
15
 
16
- **Actions**:
16
+ +++close+++
17
17
 
18
- * include <a href="#resourceInstance.mustache">resourceInstance.mustache</a> if `Instance`
19
18
 
20
- > resourceInstance
21
-
22
- ++close++
19
+ }}
23
20
 
24
21
 
25
- }}
22
+ {{! +++fold-on+++ }}
26
23
 
27
24
  {{# Instance }}{{> resourceInstance}}{{/ Instance }}
25
+
26
+ {{! +++fold-off+++ }}
@@ -1,7 +1,7 @@
1
1
  {{!
2
2
 
3
3
 
4
- ++start++
4
+ +++start+++
5
5
 
6
6
  ## <a id="resourceInstance.mustache"></a>resourceInstance.mustache <a class='navigator' href='#top'">[top]</a>
7
7
 
@@ -12,16 +12,13 @@ Create an EC2 instance
12
12
  * `Name`: name of the EC2 instance to create
13
13
  * `ImageId`: AIM id to create
14
14
 
15
- **Actions**:
16
15
 
17
- * **Name**: `Name`
18
- * **Type**: 'AWS::EC2::Instance'
19
- * **ImageId**: `ImageId`
20
-
21
- ++close++
16
+ +++close+++
22
17
 
23
18
  }}
24
19
 
20
+ {{! +++fold-on+++ }}
21
+
25
22
 
26
23
  "{{Name}}" : {
27
24
  "Type" : "AWS::EC2::Instance",
@@ -30,3 +27,5 @@ Create an EC2 instance
30
27
  "InstanceType" : "{{InstanceType}}"
31
28
  }
32
29
  }{{_comma}}
30
+
31
+ {{! +++fold-off+++ }}
@@ -1,12 +1,12 @@
1
1
  {{!
2
2
 
3
- ++start++
3
+ +++start+++
4
4
 
5
5
  ## resources.mustache
6
6
 
7
7
  Nothing created here
8
8
 
9
- ++close++
9
+ +++close+++
10
10
 
11
11
 
12
12
  }}
@@ -24,4 +24,9 @@ Nothing created here
24
24
  }
25
25
 
26
26
  }}
27
+
28
+ {{! +++fold-on+++ }}
29
+
27
30
  {{# resources }}{{> resource }}{{/ resources }}
31
+
32
+ {{! +++fold-off+++ }}
data/demo/3/root.mustache CHANGED
@@ -6,7 +6,7 @@
6
6
  STYLE section
7
7
  ==================================================================
8
8
 
9
- ++start++
9
+ +++start+++
10
10
 
11
11
  <style>
12
12
  h1 {
@@ -24,16 +24,32 @@ h3 {
24
24
  body {
25
25
  background-color: #b0c4de;
26
26
  }
27
+ /* Support fold-on/fold-off toggle */
28
+ div.fold {
29
+ width: 90%; padding: .42rem; border-radius: 5px; margin: 1rem;
30
+
31
+ }
32
+ div.fold div {
33
+ height: 0px; margin: .2rem; overflow: hidden;
34
+ }
35
+ div.toggle ~ div { height: 0px; margin: .2rem; overflow: hidden; }
36
+ input.toggle:checked ~ div {
37
+ height: auto;
38
+ color: white;
39
+ background: #c6a24b;
40
+ font-family: monospace;
41
+ white-space: pre;
42
+ }
27
43
  </style>
28
44
 
29
- ++close++
45
+ +++close+++
30
46
 
31
47
 
32
48
  ==================================================================
33
49
  CONTENT section
34
50
  ==================================================================
35
51
 
36
- ++start++
52
+ +++start+++
37
53
 
38
54
  # <a id="top">aws-must demo 3 template</a>
39
55
 
@@ -65,33 +81,23 @@ each template, it
65
81
  * documents the attribute context e.g. `.` or `./resources/Instance`,
66
82
  and attributes references of the template
67
83
 
68
- * lists template actions, i.e. output from template, or template
69
- inclusion
84
+ * checkbox to show template implementation
70
85
 
71
86
  ## <a id="root.mustache"></a>root.mustache <a class='navigator' href='#top'">[top]</a>
72
87
 
73
88
 
74
89
  Root template
75
90
 
76
-
77
91
  **Attributes**: context= `.`
78
92
 
79
93
  * `description`: description for the CF template
80
94
 
81
-
82
- **Actions**:
83
-
84
- * **Description**: `description`
85
- * **include** <a href="#resources.mustache">resources.mustache</a>
86
- * **for** `resource` **in** `resource` **include** <a href="#resource.mustache">resource.mustache</a>
87
-
88
- > resources
89
- > resource
90
-
91
- ++close++
95
+ +++close+++
92
96
 
93
97
  }}
94
98
 
99
+ {{! +++fold-on+++ }}
100
+
95
101
  {
96
102
  "AWSTemplateFormatVersion" : "2010-09-09",
97
103
  "Description" : "{{description}}",
@@ -99,3 +105,22 @@ Root template
99
105
  {{> resources }}
100
106
  }
101
107
  }
108
+
109
+ {{! +++fold-off+++ }}
110
+
111
+
112
+ {{!
113
+
114
+ ==================================================================
115
+ INCLUDED templates
116
+ ==================================================================
117
+
118
+ +++start+++
119
+
120
+ > resources
121
+ > resource
122
+ > resourceInstance
123
+
124
+ +++close+++
125
+
126
+ }}
@@ -1,7 +1,7 @@
1
1
  {{!
2
2
 
3
3
 
4
- ++start++
4
+ +++start+++
5
5
 
6
6
  ## <a id="output.mustache"></a>output.mustache <a class='navigator' href='#top'">[top]</a>
7
7
 
@@ -18,18 +18,12 @@ Create one output entry to CloudFormation JSON output section
18
18
  * `Name`: name of the attribute
19
19
 
20
20
 
21
-
22
- **Actions**:
23
-
24
- * **Name**: `Name`
25
- * **Description**: `Description`
26
- * **Value**: **Ref** if `Ref`
27
- * **Value**: `Attr.Ref`, `Attr.Name` if `Attr`
28
-
29
- ++close++
21
+ +++close+++
30
22
 
31
23
  }}
32
24
 
25
+ {{! +++fold-on+++ }}
26
+
33
27
 
34
28
  "{{Name}}": {
35
29
  "Description" : "{{Description}}"
@@ -37,3 +31,5 @@ Create one output entry to CloudFormation JSON output section
37
31
  {{#Attr}}, "Value" : { "Fn::GetAtt" : [ "{{Ref}}", "{{Name}}" ] }{{/Attr}}
38
32
  }{{_comma}}
39
33
 
34
+
35
+ {{! +++fold-off+++ }}
@@ -2,7 +2,7 @@
2
2
 
3
3
  resource.mustache
4
4
 
5
- ++start++
5
+ +++start+++
6
6
 
7
7
  ## <a id="resource.mustache"></a>resource.mustache <a class='navigator' href='#top'">[top]</a>
8
8
 
@@ -12,16 +12,14 @@ Dispatches resource sub-type templates based resource Type propertys
12
12
 
13
13
  * `Instance`: sub-document defining an EC instance
14
14
 
15
- **Actions**:
16
-
17
- * include <a href="#resourceInstance.mustache">resourceInstance.mustache</a> if `Instance`
18
-
19
- > resourceInstance
20
-
21
- ++close++
15
+ +++close+++
22
16
 
23
17
 
24
18
  }}
25
19
 
20
+ {{! +++fold-on+++ }}
21
+
26
22
  {{# Instance }}{{> resourceInstance}}{{/ Instance }}
27
23
  {{# InstanceSecurityGroup }}{{> resourceSecurityGroup}}{{/ InstanceSecurityGroup }}
24
+
25
+ {{! +++fold-off+++ }}
@@ -1,7 +1,7 @@
1
1
  {{!
2
2
 
3
3
 
4
- ++start++
4
+ +++start+++
5
5
 
6
6
 
7
7
 
@@ -14,18 +14,11 @@ Create an EC2 instance
14
14
  * `Name`: name of the EC2 instance to create
15
15
  * `InstanceType` : The instance type, such as t2.micro.
16
16
 
17
- **Actions**:
18
-
19
-
20
- * **Name**: `Name`
21
- * **Type**: 'AWS::EC2::Instance'
22
- * **ImageId**: `ImageId`
23
- * **SecurityGroups.Ref**: `SecurityGroup` if `SecurityGroup`
24
-
25
- ++close++
17
+ +++close+++
26
18
 
27
19
  }}
28
20
 
21
+ {{! +++fold-on+++ }}
29
22
 
30
23
  "{{Name}}" : {
31
24
  "Type" : "AWS::EC2::Instance",
@@ -34,4 +27,6 @@ Create an EC2 instance
34
27
  , "InstanceType" : "{{InstanceType}}"
35
28
  {{#SecurityGroup}}, "SecurityGroups" : [ { "Ref" : "{{SecurityGroup}}" } ]{{/SecurityGroup}}
36
29
  }
37
- }{{_comma}}
30
+ }{{_comma}}
31
+
32
+ {{! +++fold-off+++ }}
@@ -1,7 +1,7 @@
1
1
  {{!
2
2
 
3
3
 
4
- ++start++
4
+ +++start+++
5
5
 
6
6
 
7
7
  ## <a id="resourceSecurityGroup.mustache"></a>resourceSecurityGroup.mustache <a class='navigator' href='#top'">[top]</a>
@@ -13,16 +13,12 @@ Create an EC2 Security Group
13
13
  * `Name` : of the security group
14
14
  * `IngressCidrIp`: CIDR for to inbound traffic (ingress)
15
15
 
16
- **Actions**:
17
-
18
- * **Name**: `Name`
19
- * **Type**: "AWS::EC2::SecurityGroup"
20
- * **Properties.SecurityGroupIngress[0].CidrIp**: `IngressCidrIp`
21
-
22
- ++close++
16
+ +++close+++
23
17
 
24
18
  }}
25
19
 
20
+ {{! +++fold-on+++ }}
21
+
26
22
  "{{Name}}" : {
27
23
  "Type" : "AWS::EC2::SecurityGroup",
28
24
  "Properties" : {
@@ -35,3 +31,5 @@ Create an EC2 Security Group
35
31
  } ]
36
32
  }
37
33
  }{{_comma}}
34
+
35
+ {{! +++fold-off+++ }}
@@ -1,15 +1,17 @@
1
1
  {{!
2
2
 
3
- ++start++
3
+ +++start+++
4
4
 
5
5
  ## resources.mustache
6
6
 
7
7
  Nothing created here
8
8
 
9
- ++close++
10
-
9
+ +++close+++
11
10
 
12
11
  }}
12
+
13
+ {{! +++fold-on+++ }}
14
+
13
15
  {{!
14
16
 
15
17
  Moved to YAML
@@ -22,4 +24,6 @@ Nothing created here
22
24
  }
23
25
  }
24
26
 
25
- }}
27
+ }}
28
+
29
+ {{! +++fold-off+++ }}