kite 1.1.3 → 1.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.drone.yml +25 -0
- data/ci/bump.rb +27 -44
- data/kite.gemspec +2 -2
- data/lib/kite/version.rb +1 -1
- data/tpl/skel/README.md.tt +111 -2
- data/tpl/skel/Rakefile.tt +3 -1
- metadata +8 -9
- data/.travis.yml +0 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b57b038adb6c2dc84511d0167202a739ae202ae6a10884bf61f971f76c45593c
|
4
|
+
data.tar.gz: 96c517233944c174fbf1ca0826a42cae45bdce6ae54a359358a5ad5c9820a6af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf0236f08a80cfffed00177f188990b9d989fbfb4c4cbd9b8f040fb1f82e5f361be114a1f80d846eff58eeba9e70160b23442b383a5ac3285978f328ea4d460e
|
7
|
+
data.tar.gz: ffee938aaf0ec3af6924f86c293d5c89fe8dcfd397226ef2cc356984fad16e6a527a848a6d986a377f958c710b3622ce558d19f0c2c409c56eb581fd85aa4f0c
|
data/.drone.yml
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
kind: pipeline
|
2
|
+
name: default
|
3
|
+
|
4
|
+
steps:
|
5
|
+
- name: Run rspec
|
6
|
+
image: ruby:2.5.3
|
7
|
+
commands:
|
8
|
+
- bundle
|
9
|
+
- bundle exec rspec
|
10
|
+
when:
|
11
|
+
event:
|
12
|
+
- pull_request
|
13
|
+
|
14
|
+
- name: Bump and Tag
|
15
|
+
image: ruby:2.5.3
|
16
|
+
environment:
|
17
|
+
GITHUB_API_KEY:
|
18
|
+
from_secret: kite_bot_key
|
19
|
+
commands:
|
20
|
+
- ruby ci/bump.rb
|
21
|
+
when:
|
22
|
+
event:
|
23
|
+
- push
|
24
|
+
branch:
|
25
|
+
- 1-1-stable
|
data/ci/bump.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
1
|
+
require 'rubygems/version'
|
2
|
+
require 'net/http'
|
3
|
+
require 'json'
|
4
|
+
require 'uri'
|
5
5
|
|
6
6
|
#
|
7
7
|
# Returns bot's username in GitHub.
|
8
8
|
#
|
9
9
|
# @return [String]
|
10
10
|
def bot_username
|
11
|
-
ENV.fetch(
|
11
|
+
ENV.fetch('BOT_USERNAME', 'kite-bot')
|
12
12
|
end
|
13
13
|
|
14
14
|
#
|
@@ -16,7 +16,7 @@ end
|
|
16
16
|
#
|
17
17
|
# @return [String]
|
18
18
|
def bot_name
|
19
|
-
ENV.fetch(
|
19
|
+
ENV.fetch('BOT_NAME', 'Kite Bot')
|
20
20
|
end
|
21
21
|
|
22
22
|
#
|
@@ -24,7 +24,7 @@ end
|
|
24
24
|
#
|
25
25
|
# @return [String]
|
26
26
|
def bot_email
|
27
|
-
ENV.fetch(
|
27
|
+
ENV.fetch('BOT_EMAIL', 'kite-bot@rubykube.io')
|
28
28
|
end
|
29
29
|
|
30
30
|
#
|
@@ -32,7 +32,7 @@ end
|
|
32
32
|
#
|
33
33
|
# @return [String]
|
34
34
|
def repository_slug
|
35
|
-
ENV.fetch(
|
35
|
+
ENV.fetch('REPOSITORY_SLUG', 'rubykube/kite')
|
36
36
|
end
|
37
37
|
|
38
38
|
#
|
@@ -61,7 +61,7 @@ def bump_from_master_branch
|
|
61
61
|
return if linked_branch
|
62
62
|
|
63
63
|
# Increment patch version number, tag, and push.
|
64
|
-
candidate_version = Gem::Version.new(latest_version.segments.dup.tap { |s| s[2] += 1 }.join(
|
64
|
+
candidate_version = Gem::Version.new(latest_version.segments.dup.tap { |s| s[2] += 1 }.join('.'))
|
65
65
|
tag_n_push(candidate_version.to_s, name: 'master') unless versions.include?(candidate_version)
|
66
66
|
end
|
67
67
|
|
@@ -86,7 +86,7 @@ def bump_from_version_specific_branch(name)
|
|
86
86
|
return unless latest_version
|
87
87
|
|
88
88
|
# Increment patch version number, tag, and push.
|
89
|
-
candidate_version = Gem::Version.new(latest_version.segments.dup.tap { |s| s[2] += 1 }.join(
|
89
|
+
candidate_version = Gem::Version.new(latest_version.segments.dup.tap { |s| s[2] += 1 }.join('.'))
|
90
90
|
tag_n_push(candidate_version.to_s, branch) unless versions.include?(candidate_version)
|
91
91
|
end
|
92
92
|
|
@@ -97,7 +97,7 @@ end
|
|
97
97
|
#
|
98
98
|
# @param tag [String]
|
99
99
|
def tag_n_push(tag, branch)
|
100
|
-
File.open
|
100
|
+
File.open 'lib/kite/version.rb', 'w' do |f|
|
101
101
|
f.write <<-RUBY
|
102
102
|
module Kite
|
103
103
|
VERSION = '#{tag}'
|
@@ -108,20 +108,20 @@ end
|
|
108
108
|
[
|
109
109
|
%( git config --global user.email "#{bot_email}" ),
|
110
110
|
%( git config --global user.name "#{bot_name}" ),
|
111
|
-
%( git remote add authenticated-origin https://#{bot_username}:#{ENV.fetch(
|
111
|
+
%( git remote add authenticated-origin https://#{bot_username}:#{ENV.fetch('GITHUB_API_KEY')}@github.com/#{repository_slug} ),
|
112
112
|
%( git checkout -b release ),
|
113
113
|
%( git add lib/kite/version.rb ),
|
114
114
|
%( git commit -m "[ci skip] Bump #{tag}." ),
|
115
115
|
%( git push authenticated-origin release:#{branch.fetch(:name)} ),
|
116
|
-
%( git tag
|
117
|
-
%( git push authenticated-origin
|
116
|
+
%( git tag #{tag} -a -m "Automatically generated tag from the Drone CI build #{ENV.fetch('DRONE_BUILD_NUMBER')}." ),
|
117
|
+
%( git push authenticated-origin #{tag} )
|
118
118
|
].each do |command|
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
119
|
+
command.strip!
|
120
|
+
unless Kernel.system(command)
|
121
|
+
# Prevent GitHub API key from being published.
|
122
|
+
command.gsub!(ENV['GITHUB_API_KEY'], '(secret)')
|
123
|
+
raise %(Command "#{command}" exited with status #{$?.exitstatus || '(unavailable)'}.)
|
124
|
+
end
|
125
125
|
end
|
126
126
|
end
|
127
127
|
|
@@ -131,7 +131,7 @@ end
|
|
131
131
|
# @return [Array<Gem::Version>]
|
132
132
|
def versions
|
133
133
|
@versions ||= github_api_authenticated_get("/repos/#{repository_slug}/tags").map do |x|
|
134
|
-
Gem::Version.new(x.fetch(
|
134
|
+
Gem::Version.new(x.fetch('name')[/\d+\.\d+\.\d+/])
|
135
135
|
end.sort
|
136
136
|
end
|
137
137
|
|
@@ -142,7 +142,7 @@ end
|
|
142
142
|
# Key is commit's SHA-1 hash, value is instance of Gem::Version.
|
143
143
|
def tagged_commits_mapping
|
144
144
|
@commits ||= github_api_authenticated_get("/repos/#{repository_slug}/tags").each_with_object({}) do |x, memo|
|
145
|
-
memo[x.fetch(
|
145
|
+
memo[x.fetch('commit').fetch('sha')] = Gem::Version.new(x.fetch('name')[/\d+\.\d+\.\d+/])
|
146
146
|
end
|
147
147
|
end
|
148
148
|
|
@@ -153,8 +153,8 @@ end
|
|
153
153
|
# Array of hashes each containing "name" & "version" keys.
|
154
154
|
def version_specific_branches
|
155
155
|
@branches ||= github_api_authenticated_get("/repos/#{repository_slug}/branches").map do |x|
|
156
|
-
if x.fetch(
|
157
|
-
{ name: x[
|
156
|
+
if x.fetch('name') =~ /\A(\d)-(\d)-\w+\z/
|
157
|
+
{ name: x['name'], version: Gem::Version.new($1 + '.' + $2) }
|
158
158
|
end
|
159
159
|
end.compact
|
160
160
|
end
|
@@ -166,9 +166,9 @@ end
|
|
166
166
|
# Request path.
|
167
167
|
# @return [Hash]
|
168
168
|
def github_api_authenticated_get(path)
|
169
|
-
http = Net::HTTP.new(
|
169
|
+
http = Net::HTTP.new('api.github.com', 443)
|
170
170
|
http.use_ssl = true
|
171
|
-
response = http.get path,
|
171
|
+
response = http.get path, 'Authorization' => %[token #{ENV.fetch('GITHUB_API_KEY')}]
|
172
172
|
if response.code.to_i == 200
|
173
173
|
JSON.load(response.body)
|
174
174
|
else
|
@@ -185,21 +185,4 @@ def generic_semver?(version)
|
|
185
185
|
version.segments.count == 3 && version.segments.all? { |segment| segment.match?(/\A[0-9]+\z/) }
|
186
186
|
end
|
187
187
|
|
188
|
-
|
189
|
-
bump = ENV["TRAVIS_REPO_SLUG"] == repository_slug
|
190
|
-
# Skip PRs.
|
191
|
-
bump &&= ENV["TRAVIS_PULL_REQUEST"] == "false"
|
192
|
-
# Build must run on branch.
|
193
|
-
bump &&= !ENV["TRAVIS_BRANCH"].to_s.empty?
|
194
|
-
# GitHub API key must be available.
|
195
|
-
bump &&= !ENV["GITHUB_API_KEY"].to_s.empty?
|
196
|
-
# Build must not run on tag.
|
197
|
-
bump &&= ENV["TRAVIS_TAG"].to_s.empty?
|
198
|
-
# Ensure this commit is not tagged.
|
199
|
-
bump &&= !tagged_commits_mapping.key?(ENV["TRAVIS_COMMIT"])
|
200
|
-
|
201
|
-
if bump
|
202
|
-
if ENV["TRAVIS_BRANCH"] != "master"
|
203
|
-
bump_from_version_specific_branch(ENV["TRAVIS_BRANCH"])
|
204
|
-
end
|
205
|
-
end
|
188
|
+
bump_from_version_specific_branch(ENV.fetch('DRONE_BRANCH'))
|
data/kite.gemspec
CHANGED
@@ -23,8 +23,8 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.add_dependency "thor"
|
24
24
|
spec.add_dependency "git"
|
25
25
|
|
26
|
-
spec.add_development_dependency "bundler", "
|
27
|
-
spec.add_development_dependency "rake", "
|
26
|
+
spec.add_development_dependency "bundler", ">= 1.16"
|
27
|
+
spec.add_development_dependency "rake", ">= 10.0"
|
28
28
|
spec.add_development_dependency "rspec", "~> 3.7"
|
29
29
|
spec.add_development_dependency "git"
|
30
30
|
spec.add_development_dependency "simplecov"
|
data/lib/kite/version.rb
CHANGED
data/tpl/skel/README.md.tt
CHANGED
@@ -1,4 +1,113 @@
|
|
1
|
-
|
1
|
+
# Kite
|
2
|
+
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/kite.svg)](https://badge.fury.io/rb/kite)
|
4
|
+
[![license](https://img.shields.io/github/license/rubykube/kite.svg)](https://github.com/rubykube/kite/blob/master/LICENSE.md)
|
5
|
+
|
6
|
+
[![Build Status](https://travis-ci.org/rubykube/kite.svg?branch=master)](https://travis-ci.org/rubykube/kite)
|
7
|
+
[![codecov](https://codecov.io/gh/rubykube/kite/branch/master/graph/badge.svg)](https://codecov.io/gh/rubykube/kite)
|
8
|
+
|
9
|
+
Kite is a CLI for scaffolding and managing devops modules
|
10
|
+
The main purpose is templating of various tools for devops around terraform, bosh, ansible.
|
11
|
+
Currently Kite supports modular stacks(Kite modules) on both AWS and GCP.
|
12
|
+
|
13
|
+
We plan in adding community stack using a simple template repository structure.
|
14
|
+
|
15
|
+
## Installation
|
16
|
+
|
17
|
+
Add this line to your application's Gemfile:
|
18
|
+
|
19
|
+
```ruby
|
20
|
+
gem 'kite'
|
2
21
|
```
|
3
|
-
|
22
|
+
|
23
|
+
And then execute:
|
24
|
+
|
25
|
+
$ bundle
|
26
|
+
|
27
|
+
Or install it yourself as:
|
28
|
+
|
29
|
+
$ gem install kite
|
30
|
+
|
31
|
+
## Usage
|
32
|
+
|
33
|
+
To start using kite for bootstraping your infrastructure
|
34
|
+
follow the steps below.
|
35
|
+
[Note] Most kite commands can be referred by their first letter(for example `kite generate environment test` is the same as `kite g e test`)
|
36
|
+
|
37
|
+
### Create your Infrastructure as Code base repository
|
38
|
+
|
39
|
+
Create a new kite project using:
|
40
|
+
|
4
41
|
```
|
42
|
+
$ kite new PROJECT_NAME
|
43
|
+
```
|
44
|
+
|
45
|
+
### Generate an environment(e.g. development/test/production)
|
46
|
+
|
47
|
+
Kite environments are separated workspaces with their own credentials, variables and modules.
|
48
|
+
|
49
|
+
Generate an environment
|
50
|
+
|
51
|
+
```
|
52
|
+
$ kite generate environment *env_name* --provider=aws|gcp
|
53
|
+
```
|
54
|
+
|
55
|
+
If you want to change the credentials for an environment, edit `config/cloud.yml` and regenerate environment with the same command.
|
56
|
+
|
57
|
+
Now the environment should be generated at `config/environments/*env_name*`
|
58
|
+
|
59
|
+
### Add a module to your environment
|
60
|
+
|
61
|
+
To add a Kite module to your environment, you should first initialize it.
|
62
|
+
It's recommended to use specific module versions/tags(master branch would be used by default):
|
63
|
+
|
64
|
+
```
|
65
|
+
kite module init https://url.for/your/module --env *env_name* --version *x.y.z/x-y-stable*
|
66
|
+
```
|
67
|
+
|
68
|
+
This should clone module's source files into `modules/*module_name*` and create a `vars.*module_name*.yml` file with all variables needed by the module.
|
69
|
+
|
70
|
+
Fill in `vars.*module_name*.yml` with correct values and render the module:
|
71
|
+
|
72
|
+
```
|
73
|
+
kite module render modules/*module_name* --env *env_name*
|
74
|
+
```
|
75
|
+
|
76
|
+
### Apply Terraform configuration from the environment
|
77
|
+
|
78
|
+
Set your default gcloud credentials using
|
79
|
+
|
80
|
+
```
|
81
|
+
gcloud auth application-default login
|
82
|
+
```
|
83
|
+
|
84
|
+
```
|
85
|
+
kite terraform init
|
86
|
+
kite terraform apply --env *env_name*
|
87
|
+
```
|
88
|
+
|
89
|
+
## Getting help
|
90
|
+
|
91
|
+
To list all Kite commands, use
|
92
|
+
|
93
|
+
```shell
|
94
|
+
$> kite help
|
95
|
+
```
|
96
|
+
|
97
|
+
## Development
|
98
|
+
|
99
|
+
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.
|
100
|
+
|
101
|
+
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).
|
102
|
+
|
103
|
+
### Concourse Resource
|
104
|
+
|
105
|
+
To use resource scripts locally, set env variable `is_devel` to `true`, e.h.:
|
106
|
+
|
107
|
+
```sh
|
108
|
+
$ ruby -Ilib ./bin/concourse/in
|
109
|
+
```
|
110
|
+
|
111
|
+
## Contributing
|
112
|
+
|
113
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/rubykube/kite.
|
data/tpl/skel/Rakefile.tt
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kite
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Louis Bellet
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-03-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -42,28 +42,28 @@ dependencies:
|
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '1.16'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '1.16'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '10.0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '10.0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
@@ -130,10 +130,10 @@ executables:
|
|
130
130
|
extensions: []
|
131
131
|
extra_rdoc_files: []
|
132
132
|
files:
|
133
|
+
- ".drone.yml"
|
133
134
|
- ".gitignore"
|
134
135
|
- ".rspec"
|
135
136
|
- ".ruby-version"
|
136
|
-
- ".travis.yml"
|
137
137
|
- CHANGELOG.md
|
138
138
|
- Dockerfile
|
139
139
|
- Gemfile
|
@@ -217,8 +217,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
217
217
|
- !ruby/object:Gem::Version
|
218
218
|
version: '0'
|
219
219
|
requirements: []
|
220
|
-
|
221
|
-
rubygems_version: 2.7.7
|
220
|
+
rubygems_version: 3.0.2
|
222
221
|
signing_key:
|
223
222
|
specification_version: 4
|
224
223
|
summary: Command line tool for devops scaffolding.
|
data/.travis.yml
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
dist: trusty
|
2
|
-
|
3
|
-
sudo: required
|
4
|
-
|
5
|
-
language: ruby
|
6
|
-
|
7
|
-
cache: bundler
|
8
|
-
|
9
|
-
|
10
|
-
before_install: gem install bundler -v 1.14.6
|
11
|
-
|
12
|
-
env:
|
13
|
-
COVERAGE: true
|
14
|
-
|
15
|
-
# Execute all of the commands which need to be executed after the build passed.
|
16
|
-
after_success: ruby ci/bump.rb
|