kurgan 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b3fe34e72bd7fc90667d4fbcc0c1981f284a1a7670c6735ccf276cf5f6b7a79d
4
- data.tar.gz: 8b6cfeb1b0cce8e69e0f387c6ebc346f4ba2c5ec36fef0a4ac4ab651280a49dd
3
+ metadata.gz: 13e0829241c7cb5e338bf5bcd9f0e2dda93c762f3892866cc6af12663fb50a28
4
+ data.tar.gz: 227a2567eae45d9385aa385b634cb0089f04d47b7962150ec8bffa342209674b
5
5
  SHA512:
6
- metadata.gz: 6a3efca63e094ee686b5d9a65489eaf7b700ac4e0191b863ff7e9f070111d8906a0f9e6b2f7fd03be55c6b429e7bed254da0b110d654115e4a53a02a2e9e1957
7
- data.tar.gz: e6dc44b198c12ba1cdd4012f8cde7c1d6c0395e81de561ff63ab418e96e99541dcbcad94c3c0813f084e157fbff211eda690f15eabb699508ff95e0f673b248f
6
+ metadata.gz: d1db730b78f85a5b800f9d6b493a80c6bff0c85dc691f7a15775896570b3304ef01083771b28995a66aa455d57759d2afcc23b6e661e7dcf7b5e4068237097df
7
+ data.tar.gz: eafc409b22f9b9397181ca69f0181c4d6bdac21923ea1dd7ae9da1c64c806e66f7b7e1fc1c42d577e87a798ea3a91f2286735e1deab8e373620d996cdacf6c45
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- kurgan (0.1.3)
4
+ kurgan (0.1.4)
5
5
  thor (~> 0.19)
6
6
 
7
7
  GEM
@@ -3,6 +3,10 @@ require 'kurgan/init'
3
3
  module Kurgan
4
4
  class Component < Kurgan::Init
5
5
 
6
+ def set_type
7
+ @type = 'component'
8
+ end
9
+
6
10
  def set_directory
7
11
  @dir = ask "directory name ", default: "hl-component-#{name}"
8
12
  empty_directory @dir
@@ -23,19 +27,20 @@ module Kurgan
23
27
  template('templates/cfndsl.rb.tt', "#{@dir}/#{name}.cfndsl.rb")
24
28
  end
25
29
 
26
- def copy_licence
27
- if yes?("Use MIT license?")
28
- copy_file "templates/MITLICENSE", "#{@dir}/LICENSE"
30
+ def create_empty_test
31
+ if yes?("Setup sample test?")
32
+ empty_directory "#{@dir}/tests"
33
+ template('templates/sns_topic.test.yaml.tt', "#{@dir}/tests/sns_topic.test.yaml")
29
34
  else
30
- say "Skipping license", :yellow
35
+ say "Skipping tests", :yellow
31
36
  end
32
37
  end
33
38
 
34
- def create_travis_config
35
- if yes?("Use Travis-ci?")
36
- copy_file "templates/travis.yml.tt", "#{@dir}/travis-ci.yml"
39
+ def copy_licence
40
+ if yes?("Use MIT license?")
41
+ copy_file "templates/MITLICENSE", "#{@dir}/LICENSE"
37
42
  else
38
- say "skipping travis", :yellow
43
+ say "Skipping license", :yellow
39
44
  end
40
45
  end
41
46
 
data/lib/kurgan/init.rb CHANGED
@@ -7,12 +7,16 @@ module Kurgan
7
7
 
8
8
  argument :name
9
9
 
10
- class_option :type, aliases: :t, default: 'empty', enum: ['empty','vpc','ecs'], desc: "Create a pre-canned project"
10
+ class_option :project, aliases: '-p', default: 'empty', enum: ['empty','vpc','ecs'], desc: "Create a pre-canned project"
11
11
 
12
12
  def self.source_root
13
13
  File.dirname(__FILE__)
14
14
  end
15
15
 
16
+ def set_type
17
+ @type = 'project'
18
+ end
19
+
16
20
  def set_directory
17
21
  @dir = ask "directory name ", default: name
18
22
  empty_directory @dir
@@ -23,11 +27,11 @@ module Kurgan
23
27
  end
24
28
 
25
29
  def set_template_parameters
26
- @parameters = Kurgan::Projects.properties[options['type'].to_sym][:parameters]
30
+ @parameters = Kurgan::Projects.properties[options['project'].to_sym][:parameters]
27
31
  end
28
32
 
29
33
  def set_template_components
30
- @components = Kurgan::Projects.properties[options['type'].to_sym][:components]
34
+ @components = Kurgan::Projects.properties[options['project'].to_sym][:components]
31
35
  end
32
36
 
33
37
  def create_cfhighlander_template
@@ -43,7 +47,7 @@ module Kurgan
43
47
  if yes?("git init project?")
44
48
  run "git init #{@dir}"
45
49
  template 'templates/gitignore.tt', "#{@dir}/.gitignore"
46
- template 'templates/README.md.tt', "#{@dir}/README.md"
50
+ template "templates/README.md.tt", "#{@dir}/README.md"
47
51
  else
48
52
  say "Skipping git init", :yellow
49
53
  end
@@ -51,11 +55,11 @@ module Kurgan
51
55
 
52
56
  def ci_init
53
57
  if yes?("Setup a CI pipeline?")
54
- type = ask "CI flavour", limited_to: ['jenkins', 'travis', 'codebuild']
55
- case type
58
+ ci = ask "CI flavour", limited_to: ['jenkins', 'travis', 'codebuild']
59
+ case ci
56
60
  when 'jenkins'
57
61
  template('templates/Jenkinsfile.tt', "#{@dir}/Jenkinsfile")
58
- when 'travis-ci'
62
+ when 'travis'
59
63
  template('templates/travis.yml.tt', "#{@dir}/.travis.yml")
60
64
  when 'codebuild'
61
65
  template('templates/codebuild.yaml.tt', "#{@dir}/.codebuild.yaml")
@@ -3,16 +3,42 @@ pipeline {
3
3
  environment {
4
4
  AWS_REGION = 'us-east-1'
5
5
  PROJECT_NAME = '<%= @name %>'
6
+ VERSION = '0.1.0'
6
7
  }
7
8
 
8
9
  agent {
9
10
  docker {
10
- image 'theonestack/cfhighlander'
11
+ image 'theonestack/cfhighlander'
11
12
  }
12
13
  }
13
14
 
14
15
  stages {
15
16
 
17
+ <%- if @type == 'component' -%>
18
+ stage('cftest') {
19
+ steps {
20
+ sh 'cfndsl -u'
21
+ sh "cfhighlander cftest -r xml"
22
+ }
23
+ post {
24
+ always {
25
+ junit 'reports/report.xml'
26
+ }
27
+ }
28
+ }
29
+
30
+ stage('cfn nag') {
31
+ agent {
32
+ docker {
33
+ image 'base2/cfn-nag'
34
+ reuseNode true
35
+ }
36
+ }
37
+ steps {
38
+ sh 'cfn_nag_scan -i out/tests'
39
+ }
40
+ }
41
+ <%- elsif @type == 'project' -%>
16
42
  stage('Compile and validate templates') {
17
43
  steps {
18
44
  sh 'cfndsl -u'
@@ -20,20 +46,24 @@ pipeline {
20
46
  }
21
47
  }
22
48
 
23
- stage('Publish templates to S3') {
24
- steps {
25
- script {
26
- env['VERSION'] = ${env.BRANCH_NAME}-${env.SHORT_COMMIT}
49
+ stage('cfn nag') {
50
+ agent {
51
+ docker {
52
+ image 'base2/cfn-nag'
53
+ reuseNode true
27
54
  }
28
- sh "cfpublish ${PROJECT_NAME} --version ${VERSION}"
55
+ }
56
+ steps {
57
+ sh 'cfn_nag_scan -i out/yaml'
29
58
  }
30
59
  }
31
60
 
32
- stage('Deploy') {
61
+ stage('Publish templates') {
33
62
  steps {
34
- println "Deploying ${env.PROJECT_NAME} version ${env.VERSION}"
63
+ sh "cfpublish ${env.PROJECT_NAME} --version ${env.VERSION}"
35
64
  }
36
65
  }
66
+ <%- end -%>
37
67
 
38
68
  }
39
69
  }
@@ -1,5 +1,4 @@
1
- # <%= name %> CfHighlander project
2
- ---
1
+ # <%= name %> CfHighlander <%= @type %>
3
2
 
4
3
  ## Cfhighlander Setup
5
4
 
@@ -14,12 +13,16 @@ or via docker
14
13
  ```bash
15
14
  docker pull theonestack/cfhighlander
16
15
  ```
16
+ <%- if @type == 'component' -%>
17
+ ## Testing Components
17
18
 
18
- compiling the templates
19
+ Running the tests
19
20
 
20
21
  ```bash
21
- cfcompile <%= name %>
22
+ cfhighlander cftest <%= name %>
22
23
  ```
24
+ <%- elsif @type == 'project' -%>
25
+ ## Compiling the project
23
26
 
24
27
  compiling with the vaildate fag to validate the templates
25
28
 
@@ -32,3 +35,4 @@ publish the templates to s3
32
35
  ```bash
33
36
  cfpublish <%= name %> --version latest
34
37
  ```
38
+ <%- end -%>
@@ -1,3 +1,6 @@
1
1
  CloudFormation do
2
2
  ## Add your cfndsl resources here
3
+ SNS_Topic(:Topic) {
4
+ TopicName topic_name if defined? topic_name
5
+ }
3
6
  end
@@ -7,7 +7,13 @@ env:
7
7
  phases:
8
8
  install:
9
9
  commands:
10
- - gem install cfhighlander
10
+ - gem install cfhighlander cfn-nag
11
11
  build:
12
12
  commands:
13
+ <%- if @type == 'component' -%>
14
+ - cfhighlander cftest
15
+ - cfn_nag_scan -i out/tests
16
+ <%- elsif @type == 'project' -%>
13
17
  - cfcompile --validate
18
+ - cfn_nag_scan -i out/yaml
19
+ <%- end -%>
@@ -1 +1,2 @@
1
1
  out/
2
+ reports/
@@ -0,0 +1,6 @@
1
+ test_metadata:
2
+ type: config
3
+ name: sns_topic
4
+ description: test for the default sns topic
5
+
6
+ topic_name: sample-test
@@ -1,6 +1,15 @@
1
1
  language: ruby
2
2
  rvm:
3
3
  - 2.5
4
+ install:
5
+ - gem install cfhighlander cfn-nag
6
+ before_script:
7
+ - cfndsl -u
8
+ <%- if @type == 'component' -%>
9
+ script:
10
+ - cfhighlander cftest
11
+ - cfn_nag_scan -i out/tests
12
+ <%- elsif @type == 'project' -%>
4
13
  script:
5
14
  - gem install cfhighlander
6
- - if [ "${TRAVIS_PULL_REQUEST}" != "false" ]; then cfcompile ; else cfcompile --validate; fi%
15
+ <%- end -%>
@@ -1,3 +1,3 @@
1
1
  module Kurgan
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  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.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Guslington
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-02-11 00:00:00.000000000 Z
11
+ date: 2019-02-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -84,6 +84,7 @@ files:
84
84
  - lib/kurgan/templates/codebuild.yaml.tt
85
85
  - lib/kurgan/templates/config.yaml.tt
86
86
  - lib/kurgan/templates/gitignore.tt
87
+ - lib/kurgan/templates/sns_topic.test.yaml.tt
87
88
  - lib/kurgan/templates/travis.yml.tt
88
89
  - lib/kurgan/version.rb
89
90
  homepage: http://iamkurgan.com