kurgan 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +22 -2
- data/README.md +232 -8
- data/kurgan.gemspec +2 -0
- data/lib/kurgan.rb +13 -8
- data/lib/kurgan/component.rb +4 -0
- data/lib/kurgan/extend.rb +47 -0
- data/lib/kurgan/github.rb +34 -0
- data/lib/kurgan/init.rb +14 -10
- data/lib/kurgan/inspect.rb +50 -0
- data/lib/kurgan/list.rb +15 -50
- data/lib/kurgan/search.rb +33 -0
- data/lib/kurgan/templates/README.md.component.tt +77 -0
- data/lib/kurgan/templates/{README.md.tt → README.md.project.tt} +1 -1
- data/lib/kurgan/templates/cfhighlander.extend.rb.tt +4 -0
- data/lib/kurgan/templates/cfndsl.rb.tt +0 -3
- data/lib/kurgan/version.rb +1 -1
- data/list.rb +25 -0
- metadata +50 -4
- data/lib/kurgan/templates/travis.yml.tt +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 488e05edbe120ded7cbfb9dbaa7b751fc4cc168192d4ac63e31d107481073587
|
4
|
+
data.tar.gz: c57b6526b9b8e69b73c7089619337d6e2cc4575d9f72a8a65a36850b02b32881
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df9a706171fd7bd1d722cb43f9e8bac729514fb2fec973d47a03d342e453e39817f31aa9271029dca782948f4f6129e9f4c9a38b4c3e31ab149a31d44cccf1b3
|
7
|
+
data.tar.gz: 05d00def80a4cd83c51feab7b94602b27e29cb2c4de1526577d5016391ae2afd2fe465d63c02f56d034a124072caaec3a8dc9da89f18b0a5cac3c07f4492ee94
|
data/Gemfile.lock
CHANGED
@@ -1,14 +1,34 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
kurgan (0.
|
4
|
+
kurgan (0.3.0)
|
5
|
+
faraday (~> 1, < 2)
|
6
|
+
terminal-table (~> 1, < 2)
|
5
7
|
thor (~> 0.19)
|
6
8
|
|
7
9
|
GEM
|
8
10
|
remote: https://rubygems.org/
|
9
11
|
specs:
|
12
|
+
faraday (1.4.3)
|
13
|
+
faraday-em_http (~> 1.0)
|
14
|
+
faraday-em_synchrony (~> 1.0)
|
15
|
+
faraday-excon (~> 1.1)
|
16
|
+
faraday-net_http (~> 1.0)
|
17
|
+
faraday-net_http_persistent (~> 1.1)
|
18
|
+
multipart-post (>= 1.2, < 3)
|
19
|
+
ruby2_keywords (>= 0.0.4)
|
20
|
+
faraday-em_http (1.0.0)
|
21
|
+
faraday-em_synchrony (1.0.0)
|
22
|
+
faraday-excon (1.1.0)
|
23
|
+
faraday-net_http (1.0.1)
|
24
|
+
faraday-net_http_persistent (1.2.0)
|
25
|
+
multipart-post (2.1.1)
|
10
26
|
rake (13.0.1)
|
27
|
+
ruby2_keywords (0.0.5)
|
28
|
+
terminal-table (1.8.0)
|
29
|
+
unicode-display_width (~> 1.1, >= 1.1.1)
|
11
30
|
thor (0.20.3)
|
31
|
+
unicode-display_width (1.7.0)
|
12
32
|
|
13
33
|
PLATFORMS
|
14
34
|
ruby
|
@@ -19,4 +39,4 @@ DEPENDENCIES
|
|
19
39
|
rake (~> 13.0)
|
20
40
|
|
21
41
|
BUNDLED WITH
|
22
|
-
2.
|
42
|
+
2.1.4
|
data/README.md
CHANGED
@@ -1,20 +1,244 @@
|
|
1
1
|
# Kurgan
|
2
2
|
---
|
3
|
+
![build workflow](https://github.com/theonestack/kurgan/actions/workflows/build-gem.yml/badge.svg)
|
4
|
+
![release workflow](https://github.com/theonestack/kurgan/actions/workflows/release-gem.yml/badge.svg)
|
3
5
|
|
4
|
-
|
6
|
+
Command line tool to create and manage CfHighlander projects and components
|
5
7
|
|
6
|
-
|
8
|
+
## Setup
|
9
|
+
|
10
|
+
```sh
|
11
|
+
gem install kurgan
|
12
|
+
```
|
13
|
+
|
14
|
+
## Usage
|
15
|
+
|
16
|
+
### Help
|
17
|
+
|
18
|
+
view all available commands
|
7
19
|
|
8
20
|
```bash
|
21
|
+
➜ kurgan help
|
9
22
|
Commands:
|
10
|
-
kurgan --version, -v
|
11
|
-
kurgan add [component]
|
12
|
-
kurgan component [name]
|
13
|
-
kurgan
|
14
|
-
kurgan
|
15
|
-
kurgan
|
23
|
+
kurgan --version, -v # print the version
|
24
|
+
kurgan add [component] # Adds a new component to an existing CfHighlander project
|
25
|
+
kurgan component [name] # Generates a new CfHighlander component
|
26
|
+
kurgan extend [component] # Generates a files to extend a component in a CfHighlander project
|
27
|
+
kurgan help [COMMAND] # Describe available commands or one specific command
|
28
|
+
kurgan inspect # inspect a cfhighlander files of it's components
|
29
|
+
kurgan list # list all components in the onestack
|
30
|
+
kurgan project [name] # Generates a new CfHighlander project
|
31
|
+
kurgan search [component] # search for a component and it's release history
|
32
|
+
kurgan test [name] # Create a new test case for a component
|
33
|
+
```
|
34
|
+
|
35
|
+
help can also be used on commands to see available options and usage
|
36
|
+
|
37
|
+
```bash
|
38
|
+
➜ kurgan help project
|
39
|
+
Usage:
|
40
|
+
kurgan project [name]
|
41
|
+
|
42
|
+
Options:
|
43
|
+
-p, [--project=PROJECT] # Create a pre-canned project
|
44
|
+
# Default: empty
|
45
|
+
# Possible values: empty, vpc, ecs
|
46
|
+
|
47
|
+
Generates a new CfHighlander project
|
48
|
+
```
|
49
|
+
|
50
|
+
### Create a New Project
|
51
|
+
|
52
|
+
A CfHighlander project allows you to configure and compile a group of components to generate you Cloudformation stack.
|
53
|
+
|
54
|
+
To create a new project run the `project` command with the name of your new project and fill in the prompts
|
55
|
+
|
56
|
+
```sh
|
57
|
+
➜ kurgan project myproject
|
58
|
+
directory name (myproject)
|
59
|
+
create myproject
|
60
|
+
template description (myproject)
|
61
|
+
create myproject/myproject.cfhighlander.rb
|
62
|
+
create myproject/myproject.config.yaml
|
63
|
+
git init project? y
|
64
|
+
run git init myproject from "."
|
65
|
+
Initialized empty Git repository in /Users/gus/src/testbed/hl/myproject/.git/
|
66
|
+
create myproject/.gitignore
|
67
|
+
create myproject/README.md
|
68
|
+
Setup a CI pipeline? y
|
69
|
+
CI flavour [github, jenkins, travis, codebuild] jenkins
|
70
|
+
create myproject/Jenkinsfile
|
71
|
+
```
|
72
|
+
|
73
|
+
cd into the new directory and you'll see the following project structure
|
74
|
+
|
75
|
+
```txt
|
76
|
+
.
|
77
|
+
├── Jenkinsfile # depending on CI flavour this will be different
|
78
|
+
├── README.md
|
79
|
+
├── myproject.cfhighlander.rb
|
80
|
+
└── myproject.config.yaml
|
81
|
+
```
|
82
|
+
|
83
|
+
|
84
|
+
### Add a Component to a Project
|
85
|
+
|
86
|
+
To add a component to your nproject use the `add` command along with the component name with optional component version and friendly name
|
87
|
+
|
88
|
+
```sh
|
89
|
+
➜ myproject git:(master) ✗ kurgan add vpc-v2 --name network --version 0.7.0
|
90
|
+
adding vpc-v2@0.7.0 to the myproject project
|
91
|
+
insert myproject.cfhighlander.rb
|
92
|
+
create network.config.yaml
|
93
|
+
```
|
94
|
+
|
95
|
+
this will create a yaml config file for the new component configuration and add the component to the `myproject.cfhighlander.rb` file
|
96
|
+
|
97
|
+
```rb
|
98
|
+
CfhighlanderTemplate do
|
99
|
+
Name 'myproject'
|
100
|
+
Description "myproject"
|
101
|
+
Component name: 'network', template: 'vpc-v2@0.7.0'
|
102
|
+
end
|
103
|
+
```
|
104
|
+
|
105
|
+
|
106
|
+
### Extend a Component in a Project
|
107
|
+
|
108
|
+
Extending a component allows you to add resources to an existing component whilest still allowing you to update the component.
|
109
|
+
|
110
|
+
to extend a component use the `extend` command along with the component name with optional component version and friendly name
|
111
|
+
|
112
|
+
```sh
|
113
|
+
➜ myproject git:(master) ✗ kurgan extend aurora-mysql --name database --version 3.3.0
|
114
|
+
create database
|
115
|
+
extending aurora-mysql@3.3.0 to the myproject project
|
116
|
+
create database/database.cfhighlander.rb
|
117
|
+
create database/database.config.yaml
|
118
|
+
create database/database.cfndsl.rb
|
119
|
+
insert myproject.cfhighlander.rb
|
120
|
+
```
|
121
|
+
|
122
|
+
this will create a new sub directory with a cfhighlander file containing the component you're extending, a cfndsl file to add your resources and a config.yaml for configuration
|
123
|
+
|
124
|
+
```txt
|
125
|
+
.
|
126
|
+
├── Jenkinsfile
|
127
|
+
├── README.md
|
128
|
+
├── database
|
129
|
+
│ ├── database.cfhighlander.rb
|
130
|
+
│ ├── database.cfndsl.rb
|
131
|
+
│ └── database.config.yaml
|
132
|
+
├── myproject.cfhighlander.rb
|
133
|
+
├── myproject.config.yaml
|
134
|
+
└── network.config.yaml
|
16
135
|
```
|
17
136
|
|
137
|
+
```rb
|
138
|
+
CfhighlanderTemplate do
|
139
|
+
Name 'database'
|
140
|
+
Extends 'aurora-mysql@3.3.0'
|
141
|
+
end
|
142
|
+
```
|
143
|
+
|
144
|
+
|
145
|
+
### Inspect a Project
|
146
|
+
|
147
|
+
To see a list of components used by a project including versions and latest available version use the `inspect` command.
|
148
|
+
|
149
|
+
```sh
|
150
|
+
➜ myproject git:(master) ✗ kurgan inspect
|
151
|
+
+-----------+-----------+----------------+
|
152
|
+
| Project: myproject |
|
153
|
+
+-----------+-----------+----------------+
|
154
|
+
| Component | Version | Latest Release |
|
155
|
+
+-----------+-----------+----------------+
|
156
|
+
| vpc-v2 | 0.7.0 | 0.7.0 |
|
157
|
+
+-----------+-----------+----------------+
|
158
|
+
```
|
159
|
+
|
160
|
+
|
161
|
+
### Create a New Component
|
162
|
+
|
163
|
+
Components are the basic building blocks of CfHighlander, containing cloudformation resources that can be templated and reused across multiple project.
|
164
|
+
|
165
|
+
To create a new project use the `component` command with the name of your new component and fill in the prompts
|
166
|
+
|
167
|
+
```txt
|
168
|
+
➜ kurgan component rds-mysql
|
169
|
+
directory name (hl-component-rds-mysql)
|
170
|
+
create hl-component-rds-mysql
|
171
|
+
template description (rds-mysql - #{component_version})
|
172
|
+
create hl-component-rds-mysql/rds-mysql.cfhighlander.rb
|
173
|
+
create hl-component-rds-mysql/rds-mysql.config.yaml
|
174
|
+
git init project? y
|
175
|
+
run git init hl-component-rds-mysql from "."
|
176
|
+
Initialized empty Git repository in /Users/gus/src/testbed/hl/hl-component-rds-mysql/.git/
|
177
|
+
create hl-component-rds-mysql/.gitignore
|
178
|
+
create hl-component-rds-mysql/README.md
|
179
|
+
Setup a CI pipeline? y
|
180
|
+
CI flavour [github, jenkins, travis, codebuild] github
|
181
|
+
create hl-component-rds-mysql/.github/workflows/spec.yaml
|
182
|
+
create hl-component-rds-mysql/rds-mysql.cfndsl.rb
|
183
|
+
create hl-component-rds-mysql/tests/default.test.yaml
|
184
|
+
Use MIT license? y
|
185
|
+
create hl-component-rds-mysql/LICENSE
|
186
|
+
```
|
187
|
+
|
188
|
+
the following folder structure is generated
|
189
|
+
|
190
|
+
```txt
|
191
|
+
.
|
192
|
+
├── LICENSE
|
193
|
+
├── README.md
|
194
|
+
├── rds-mysql.cfhighlander.rb
|
195
|
+
├── rds-mysql.cfndsl.rb
|
196
|
+
├── rds-mysql.config.yaml
|
197
|
+
└── tests
|
198
|
+
└── default.test.yaml
|
199
|
+
```
|
200
|
+
|
201
|
+
|
202
|
+
### Add tests to a Component
|
203
|
+
|
204
|
+
Kurgan can be used to add configuration tests to a component as well as generating spec tests based upon the cloudformation generated by a configuration test.
|
205
|
+
|
206
|
+
to create a new config test run the test command along with the name of the test
|
207
|
+
|
208
|
+
```sh
|
209
|
+
➜ hl-component-rds-mysql git:(master) ✗ kurgan test mytest
|
210
|
+
create tests/mytest.test.yaml
|
211
|
+
created config test case tests/mytest.test.yaml
|
212
|
+
```
|
213
|
+
|
214
|
+
A test.yaml file is created in the tests directory, add in you test and run the `cfhighlander test` command to execute the test
|
215
|
+
|
216
|
+
Once the cftest has successfully passed you can then generate a spec test from the cloudformation template generated by the test in the `out/tests/<test-name>/` directory
|
217
|
+
|
218
|
+
To generate the spec test use the `test` command again with the name of the test and pass the `--type spec` flag
|
219
|
+
|
220
|
+
```sh
|
221
|
+
➜ hl-component-rds-mysql git:(master) ✗ kurgan test mytest --type spec
|
222
|
+
create spec/mytest_spec.rb
|
223
|
+
created spec test spec/mytest_spec.rb
|
224
|
+
```
|
225
|
+
|
226
|
+
|
227
|
+
### Searching for Components
|
228
|
+
|
229
|
+
to list all available components on the onestack use the `list` command
|
230
|
+
|
231
|
+
```sh
|
232
|
+
➜ kurgan list
|
233
|
+
```
|
234
|
+
|
235
|
+
to search for a components releases use the `search [component]` command
|
236
|
+
|
237
|
+
```sh
|
238
|
+
➜ kurgan search vpc
|
239
|
+
```
|
240
|
+
|
241
|
+
|
18
242
|
## License
|
19
243
|
|
20
244
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/kurgan.gemspec
CHANGED
@@ -31,6 +31,8 @@ Gem::Specification.new do |spec|
|
|
31
31
|
spec.require_paths = ["lib"]
|
32
32
|
|
33
33
|
spec.add_dependency "thor", "~> 0.19"
|
34
|
+
spec.add_dependency "terminal-table", '~> 1', '<2'
|
35
|
+
spec.add_dependency "faraday", '~> 1', '<2'
|
34
36
|
|
35
37
|
spec.add_development_dependency "bundler", "~> 2.0"
|
36
38
|
spec.add_development_dependency "rake", "~> 13.0"
|
data/lib/kurgan.rb
CHANGED
@@ -7,6 +7,9 @@ require "kurgan/component"
|
|
7
7
|
require "kurgan/add"
|
8
8
|
require "kurgan/test"
|
9
9
|
require "kurgan/list"
|
10
|
+
require "kurgan/extend"
|
11
|
+
require "kurgan/search"
|
12
|
+
require "kurgan/inspect"
|
10
13
|
|
11
14
|
module Kurgan
|
12
15
|
class Cli < Thor
|
@@ -26,18 +29,20 @@ module Kurgan
|
|
26
29
|
register Kurgan::Add, 'add', 'add [component]', 'Adds a new component to an existing CfHighlander project'
|
27
30
|
tasks["add"].options = Kurgan::Add.class_options
|
28
31
|
|
32
|
+
register Kurgan::Extend, 'extend', 'extend [component]', 'Generates a files to extend a component in a CfHighlander project'
|
33
|
+
tasks["extend"].options = Kurgan::Extend.class_options
|
34
|
+
|
29
35
|
register Kurgan::Test, 'test', 'test [name]', 'Create a new test case for a component'
|
30
36
|
tasks["test"].options = Kurgan::Test.class_options
|
31
37
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
cmd = Kurgan::List.new(options)
|
38
|
-
cmd.execute
|
39
|
-
end
|
38
|
+
register Kurgan::List, 'list', 'list', 'list all components in the onestack'
|
39
|
+
tasks["list"].options = Kurgan::List.class_options
|
40
|
+
|
41
|
+
register Kurgan::Search, 'search', 'search [component]', "search for a component and it's release history"
|
42
|
+
tasks["search"].options = Kurgan::Search.class_options
|
40
43
|
|
44
|
+
register Kurgan::Inspect, 'inspect', 'inspect', "inspect a cfhighlander files of it's components"
|
45
|
+
tasks["inspect"].options = Kurgan::Inspect.class_options
|
41
46
|
|
42
47
|
end
|
43
48
|
end
|
data/lib/kurgan/component.rb
CHANGED
@@ -27,6 +27,10 @@ module Kurgan
|
|
27
27
|
template('templates/cfndsl.rb.tt', "#{@dir}/#{name}.cfndsl.rb")
|
28
28
|
end
|
29
29
|
|
30
|
+
def create_readme
|
31
|
+
template "templates/README.md.component.tt", "#{@dir}/README.md"
|
32
|
+
end
|
33
|
+
|
30
34
|
def create_default_config_test
|
31
35
|
@test_name = 'default'
|
32
36
|
template('templates/test.yaml.tt', "#{@dir}/tests/#{@test_name}.test.yaml")
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module Kurgan
|
2
|
+
class Extend < Thor::Group
|
3
|
+
include Thor::Actions
|
4
|
+
|
5
|
+
argument :component
|
6
|
+
|
7
|
+
class_option :name, aliases: :n, type: :string
|
8
|
+
class_option :version, aliases: :v, type: :string
|
9
|
+
|
10
|
+
def self.source_root
|
11
|
+
File.dirname(__FILE__)
|
12
|
+
end
|
13
|
+
|
14
|
+
def get_cfhighlander_template
|
15
|
+
@cfhighlander_template = Dir['*.cfhighlander.rb'][0]
|
16
|
+
if @cfhighlander_template.nil?
|
17
|
+
raise "No cfhighlander.rb file found in #{Dir.pwd}, are you in a cfhighlander project folder?"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def get_component_name
|
22
|
+
@name = options[:name] || component
|
23
|
+
end
|
24
|
+
|
25
|
+
def create_sub_dir_for_extended_component
|
26
|
+
empty_directory @name
|
27
|
+
end
|
28
|
+
|
29
|
+
def get_template_version
|
30
|
+
@template = options[:version] ? "#{component}@#{options[:version]}" : component
|
31
|
+
say "extending #{@template} to the #{@cfhighlander_template.split('.')[0]} project"
|
32
|
+
end
|
33
|
+
|
34
|
+
def create_cfhighlander_files
|
35
|
+
opts = {template: @template, name: @name}
|
36
|
+
template('templates/cfhighlander.extend.rb.tt', "#{@name}/#{@name}.cfhighlander.rb", opts)
|
37
|
+
template('templates/config.yaml.tt', "#{@name}/#{@name}.config.yaml")
|
38
|
+
template('templates/cfndsl.rb.tt', "#{@name}/#{@name}.cfndsl.rb")
|
39
|
+
end
|
40
|
+
|
41
|
+
def add_component
|
42
|
+
insert_into_file @cfhighlander_template, "\tComponent name: '#{@name}', template: '#{@name}'\n\n", :before => /^end/
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'faraday'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
module Kurgan
|
5
|
+
class GitHub
|
6
|
+
|
7
|
+
GITHUB_URL = "https://api.github.com"
|
8
|
+
GITHUB_ORG = "theonestack"
|
9
|
+
|
10
|
+
def self.get_repos
|
11
|
+
url = "#{GITHUB_URL}/orgs/#{GITHUB_ORG}/repos"
|
12
|
+
response = Faraday.get(url, {type: 'public', per_page: 100}, {'Accept' => 'Accept: application/vnd.github.v3+json'})
|
13
|
+
|
14
|
+
if response.status != 200
|
15
|
+
return nil
|
16
|
+
end
|
17
|
+
|
18
|
+
repos = JSON.parse(response.body, symbolize_names: true)
|
19
|
+
return repos.select {|repo| repo[:name].start_with?('hl-component')}
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.get_releases(component)
|
23
|
+
url = "#{GITHUB_URL}/repos/#{GITHUB_ORG}/hl-component-#{component}/releases"
|
24
|
+
response = Faraday.get(url, {}, {'Accept' => 'Accept: application/vnd.github.v3+json'})
|
25
|
+
|
26
|
+
if response.status != 200
|
27
|
+
return nil
|
28
|
+
end
|
29
|
+
|
30
|
+
return JSON.parse(response.body, symbolize_names: true)
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
data/lib/kurgan/init.rb
CHANGED
@@ -36,35 +36,39 @@ module Kurgan
|
|
36
36
|
|
37
37
|
def create_cfhighlander_template
|
38
38
|
opts = {parameters: @parameters, components: @components, description: @description}
|
39
|
-
template
|
39
|
+
template 'templates/cfhighlander.rb.tt', "#{@dir}/#{name}.cfhighlander.rb", opts
|
40
40
|
end
|
41
41
|
|
42
42
|
def create_config_yaml
|
43
43
|
template 'templates/config.yaml.tt', "#{@dir}/#{name}.config.yaml"
|
44
44
|
end
|
45
45
|
|
46
|
+
def create_readme
|
47
|
+
template "templates/README.md.project.tt", "#{@dir}/README.md"
|
48
|
+
end
|
49
|
+
|
46
50
|
def git_init
|
47
|
-
if yes?
|
51
|
+
if yes? "git init project?"
|
48
52
|
run "git init #{@dir}"
|
49
53
|
template 'templates/gitignore.tt', "#{@dir}/.gitignore"
|
50
|
-
template "templates/README.md.tt", "#{@dir}/README.md"
|
51
54
|
else
|
52
55
|
say "Skipping git init", :yellow
|
53
56
|
end
|
54
57
|
end
|
55
58
|
|
56
59
|
def ci_init
|
57
|
-
if yes?
|
58
|
-
ci = ask "CI flavour", limited_to: ['github', 'jenkins', '
|
60
|
+
if yes? "Setup a CI pipeline?"
|
61
|
+
ci = ask "CI flavour", limited_to: ['github', 'jenkins', 'codebuild']
|
59
62
|
case ci
|
60
63
|
when 'github'
|
61
|
-
template
|
64
|
+
template 'templates/github_actions.yaml.tt', "#{@dir}/.github/workflows/rspec.yaml"
|
65
|
+
insert_into_file "#{@dir}/README.md",
|
66
|
+
"![cftest](https://github.com/theonestack/hl-component-#{name}/actions/workflows/rspec.yaml/badge.svg)\n\n",
|
67
|
+
:after => /^# #{name} CfHighlander Component\n\n/
|
62
68
|
when 'jenkins'
|
63
|
-
template
|
64
|
-
when 'travis'
|
65
|
-
template('templates/travis.yml.tt', "#{@dir}/.travis.yml")
|
69
|
+
template 'templates/Jenkinsfile.tt', "#{@dir}/Jenkinsfile"
|
66
70
|
when 'codebuild'
|
67
|
-
template
|
71
|
+
template 'templates/codebuild.yaml.tt', "#{@dir}/.codebuild.yaml"
|
68
72
|
end
|
69
73
|
else
|
70
74
|
say "Skipping CI setup", :yellow
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require "thor"
|
2
|
+
require 'terminal-table'
|
3
|
+
|
4
|
+
module Kurgan
|
5
|
+
class Inspect < Thor::Group
|
6
|
+
include Thor::Actions
|
7
|
+
|
8
|
+
def get_cfhighlander_template
|
9
|
+
@cfhighlander_rb = Dir['*.cfhighlander.rb'][0]
|
10
|
+
if @cfhighlander_rb.nil?
|
11
|
+
raise "No cfhighlander.rb file found in #{Dir.pwd}"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def get_project_name
|
16
|
+
@project_name = @cfhighlander_rb.split('.').first
|
17
|
+
end
|
18
|
+
|
19
|
+
def get_components
|
20
|
+
cfhighlander_file = File.read(@cfhighlander_rb)
|
21
|
+
raw_components = cfhighlander_file.scan(/template:\s?(.*?)\s/).flatten
|
22
|
+
|
23
|
+
@components = raw_components.map do |template_str|
|
24
|
+
template = template_str.strip.gsub(/("|'|,)/, '').split(/(@|#)/)
|
25
|
+
{ template: template.first, version: (template.size > 1 ? template.last : "not found") }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def check_versions
|
30
|
+
@components.each do |comp|
|
31
|
+
releases = Kurgan::GitHub.get_releases(comp[:template])
|
32
|
+
if !releases.nil? && releases.any?
|
33
|
+
latest_release = releases.sort_by { |r| r[:tag_name] }.reverse.first
|
34
|
+
comp[:latest_release] = latest_release[:tag_name]
|
35
|
+
else
|
36
|
+
comp[:latest_release] = 'not found'
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def display
|
42
|
+
puts Terminal::Table.new(
|
43
|
+
:title => "Project: #{@project_name}",
|
44
|
+
:headings => ['Component', 'Version', 'Latest Release'],
|
45
|
+
:rows => @components.map {|comp| [comp[:template], comp[:version], comp[:latest_release]] }
|
46
|
+
)
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|
data/lib/kurgan/list.rb
CHANGED
@@ -1,59 +1,24 @@
|
|
1
|
-
require
|
2
|
-
require '
|
1
|
+
require "thor"
|
2
|
+
require 'terminal-table'
|
3
|
+
require 'kurgan/github'
|
3
4
|
|
4
5
|
module Kurgan
|
5
|
-
class List
|
6
|
+
class List < Thor::Group
|
7
|
+
include Thor::Actions
|
6
8
|
|
7
|
-
def
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
update_component_list
|
9
|
+
def get_repos
|
10
|
+
repos = Kurgan::GitHub.get_repos()
|
11
|
+
if repos.nil?
|
12
|
+
abort "Error: Somthing went wrong with connecting to the github api"
|
12
13
|
end
|
13
|
-
|
14
|
-
@components = JSON.parse(content)['components']
|
14
|
+
@hl_repos = repos.map {|repo| [repo[:name], repo[:url], repo[:updated_at]]}
|
15
15
|
end
|
16
16
|
|
17
|
-
def
|
18
|
-
puts
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
return component
|
23
|
-
elsif @filter
|
24
|
-
return filter
|
25
|
-
else
|
26
|
-
return all
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
def component
|
31
|
-
components = @components.select { |comp| comp['name'].include? @component }
|
32
|
-
abort "no match for component #{@component}" if !components.any?
|
33
|
-
components.each { |comp| puts "\s\s\s\s#{comp['name']} (#{comp['versions'].join(', ')})" }
|
34
|
-
end
|
35
|
-
|
36
|
-
def filter
|
37
|
-
components = @components.select { |comp| comp['filter'].include? @filter }
|
38
|
-
abort "no match for filter #{@filter}" if !components.any?
|
39
|
-
components.each { |comp| format(comp['name'],comp['latest']) }
|
40
|
-
end
|
41
|
-
|
42
|
-
def all
|
43
|
-
@components.each { |comp| format(comp['name'],comp['latest']) }
|
44
|
-
end
|
45
|
-
|
46
|
-
def format(name,version)
|
47
|
-
version = version != "" ? version : 'latest'
|
48
|
-
puts "\s\s\s\s#{name}@#{version}"
|
49
|
-
end
|
50
|
-
|
51
|
-
def update_component_list
|
52
|
-
puts "Updating components list"
|
53
|
-
FileUtils.mkdir_p File.dirname(Kurgan.components_file)
|
54
|
-
content = open('https://s3-ap-southeast-2.amazonaws.com/cfhighlander-component-specification/components.json').read
|
55
|
-
File.open(Kurgan.components_file, 'w') { |f| f.puts content }
|
56
|
-
puts "Succesfully updated components list #{Kurgan.components_file}"
|
17
|
+
def display
|
18
|
+
puts Terminal::Table.new(
|
19
|
+
:headings => ['Component', 'Git URL', 'Last Updated'],
|
20
|
+
:rows => @hl_repos.sort
|
21
|
+
)
|
57
22
|
end
|
58
23
|
|
59
24
|
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require "thor"
|
2
|
+
require 'terminal-table'
|
3
|
+
require 'kurgan/github'
|
4
|
+
|
5
|
+
module Kurgan
|
6
|
+
class Search < Thor::Group
|
7
|
+
include Thor::Actions
|
8
|
+
|
9
|
+
argument :component
|
10
|
+
|
11
|
+
def get_releases
|
12
|
+
releases = Kurgan::GitHub.get_releases(component)
|
13
|
+
if releases.nil?
|
14
|
+
abort "ERROR: unable to find component in theonestack"
|
15
|
+
end
|
16
|
+
|
17
|
+
if releases.any?
|
18
|
+
@rows = releases.map {|release| [release[:tag_name], release[:name], release[:published_at], release[:html_url]]}
|
19
|
+
else
|
20
|
+
tags = Kurgan::GitHub.get_tags(component)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def display
|
25
|
+
puts Terminal::Table.new(
|
26
|
+
:title => "Component: #{component}",
|
27
|
+
:headings => ['Version', 'name', 'Published', 'URL'],
|
28
|
+
:rows => @rows.sort.reverse
|
29
|
+
)
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
# <%= name %> CfHighlander Component
|
2
|
+
|
3
|
+
<!--- add component description --->
|
4
|
+
|
5
|
+
```bash
|
6
|
+
kurgan add <%= name %>
|
7
|
+
```
|
8
|
+
|
9
|
+
## Requirements
|
10
|
+
|
11
|
+
## Parameters
|
12
|
+
|
13
|
+
| Name | Use | Default | Global | Type | Allowed Values |
|
14
|
+
| ---- | --- | ------- | ------ | ---- | -------------- |
|
15
|
+
|
16
|
+
|
17
|
+
## Configuration
|
18
|
+
|
19
|
+
<!--- add component config examples --->
|
20
|
+
|
21
|
+
```yaml
|
22
|
+
example_config: test
|
23
|
+
```
|
24
|
+
|
25
|
+
## Outputs/Exports
|
26
|
+
|
27
|
+
| Name | Value | Exported |
|
28
|
+
| ---- | ----- | -------- |
|
29
|
+
|
30
|
+
|
31
|
+
## Development
|
32
|
+
|
33
|
+
```bash
|
34
|
+
gem install cfhighlander
|
35
|
+
```
|
36
|
+
|
37
|
+
or via docker
|
38
|
+
|
39
|
+
```bash
|
40
|
+
docker pull theonestack/cfhighlander
|
41
|
+
```
|
42
|
+
|
43
|
+
### Testing
|
44
|
+
|
45
|
+
Generate cftest
|
46
|
+
|
47
|
+
```bash
|
48
|
+
kurgan test example
|
49
|
+
```
|
50
|
+
|
51
|
+
Run cftest
|
52
|
+
|
53
|
+
```bash
|
54
|
+
cfhighlander cftest -t tests/example.test.yaml
|
55
|
+
```
|
56
|
+
|
57
|
+
or run all tests
|
58
|
+
|
59
|
+
```bash
|
60
|
+
cfhighlander cftest
|
61
|
+
```
|
62
|
+
|
63
|
+
Generate spec tests
|
64
|
+
|
65
|
+
```bash
|
66
|
+
kurgan test example --type spec
|
67
|
+
```
|
68
|
+
|
69
|
+
run spec tests
|
70
|
+
|
71
|
+
```bash
|
72
|
+
gem install rspec
|
73
|
+
```
|
74
|
+
|
75
|
+
```bash
|
76
|
+
rspec
|
77
|
+
```
|
data/lib/kurgan/version.rb
CHANGED
data/list.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
require "thor"
|
2
|
+
require 'faraday'
|
3
|
+
require 'json'
|
4
|
+
require 'terminal-table'
|
5
|
+
|
6
|
+
module Kurgan
|
7
|
+
class List < Thor::Group
|
8
|
+
include Thor::Actions
|
9
|
+
|
10
|
+
def get_repos
|
11
|
+
url = 'https://api.github.com/orgs/theonestack/repos'
|
12
|
+
response = Faraday.get(url, {type: 'public', per_page: 100}, {'Accept' => 'Accept: application/vnd.github.v3+json'})
|
13
|
+
repos = JSON.parse(response.body, symbolize_names: true)
|
14
|
+
@hl_repos = repos.select {|repo| repo[:name].start_with?('hl-component')}.map {|repo| [repo[:name], repo[:url], repo[:updated_at]]}
|
15
|
+
end
|
16
|
+
|
17
|
+
def display
|
18
|
+
puts Terminal::Table.new(
|
19
|
+
:headings => ['Component', 'Git URL', 'Last Updated'],
|
20
|
+
:rows => @hl_repos.sort
|
21
|
+
)
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kurgan
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Guslington
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-08-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -24,6 +24,46 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0.19'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: terminal-table
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1'
|
34
|
+
- - "<"
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '2'
|
37
|
+
type: :runtime
|
38
|
+
prerelease: false
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - "~>"
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '1'
|
44
|
+
- - "<"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '2'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: faraday
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - "~>"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '1'
|
54
|
+
- - "<"
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '2'
|
57
|
+
type: :runtime
|
58
|
+
prerelease: false
|
59
|
+
version_requirements: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - "~>"
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '1'
|
64
|
+
- - "<"
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '2'
|
27
67
|
- !ruby/object:Gem::Dependency
|
28
68
|
name: bundler
|
29
69
|
requirement: !ruby/object:Gem::Requirement
|
@@ -73,13 +113,19 @@ files:
|
|
73
113
|
- lib/kurgan.rb
|
74
114
|
- lib/kurgan/add.rb
|
75
115
|
- lib/kurgan/component.rb
|
116
|
+
- lib/kurgan/extend.rb
|
117
|
+
- lib/kurgan/github.rb
|
76
118
|
- lib/kurgan/globals.rb
|
77
119
|
- lib/kurgan/init.rb
|
120
|
+
- lib/kurgan/inspect.rb
|
78
121
|
- lib/kurgan/list.rb
|
79
122
|
- lib/kurgan/projects.rb
|
123
|
+
- lib/kurgan/search.rb
|
80
124
|
- lib/kurgan/templates/Jenkinsfile.tt
|
81
125
|
- lib/kurgan/templates/MITLICENSE
|
82
|
-
- lib/kurgan/templates/README.md.tt
|
126
|
+
- lib/kurgan/templates/README.md.component.tt
|
127
|
+
- lib/kurgan/templates/README.md.project.tt
|
128
|
+
- lib/kurgan/templates/cfhighlander.extend.rb.tt
|
83
129
|
- lib/kurgan/templates/cfhighlander.rb.tt
|
84
130
|
- lib/kurgan/templates/cfndsl.rb.tt
|
85
131
|
- lib/kurgan/templates/codebuild.yaml.tt
|
@@ -88,9 +134,9 @@ files:
|
|
88
134
|
- lib/kurgan/templates/gitignore.tt
|
89
135
|
- lib/kurgan/templates/test.spec.tt
|
90
136
|
- lib/kurgan/templates/test.yaml.tt
|
91
|
-
- lib/kurgan/templates/travis.yml.tt
|
92
137
|
- lib/kurgan/test.rb
|
93
138
|
- lib/kurgan/version.rb
|
139
|
+
- list.rb
|
94
140
|
homepage: http://iamkurgan.com
|
95
141
|
licenses:
|
96
142
|
- MIT
|
@@ -1,15 +0,0 @@
|
|
1
|
-
language: ruby
|
2
|
-
rvm:
|
3
|
-
- 2.5
|
4
|
-
install:
|
5
|
-
- gem install cfhighlander cfn-nag
|
6
|
-
before_script:
|
7
|
-
- cfndsl -u
|
8
|
-
<%- if @type == 'component' -%>
|
9
|
-
script:
|
10
|
-
- if [ "${TRAVIS_PULL_REQUEST}" != "false" ]; then cfhighlander cftest --no-validate; else cfhighlander cftest; fi
|
11
|
-
- cfn_nag_scan -i out/tests
|
12
|
-
<%- elsif @type == 'project' -%>
|
13
|
-
script:
|
14
|
-
- cfcompile
|
15
|
-
<%- end -%>
|