sambot 0.1.206 → 0.1.207
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/integration_tests/docker-compose.yml +0 -1
- data/integration_tests/vault_helper_spec.rb +2 -2
- data/lib/sambot.rb +2 -0
- data/lib/sambot/chef/cookbook.rb +2 -0
- data/lib/sambot/cli.rb +3 -16
- data/lib/sambot/config.rb +6 -2
- data/lib/sambot/docs/populate.txt +1 -5
- data/lib/sambot/source_control.rb +26 -0
- data/lib/sambot/tasks/create.rb +55 -0
- data/lib/sambot/team_city.rb +16 -0
- data/lib/sambot/templates/docker-compose.yml +6 -1
- data/lib/sambot/templates/spec_helper.rb +2 -0
- data/lib/sambot/version.rb +1 -1
- data/sambot.gemspec +0 -1
- metadata +4 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 15173b6ef6750e6401a9c62293cdb2ff2bd3198c
|
4
|
+
data.tar.gz: 1c296d1fad951712c9dfb0b32ba6282eb15a1a09
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b195367df5cbd3e1cd8647e4373e0b6ed952836ab931721bd5e27ea03b6552a6303bdcc6764c2f40fd0ece75fc661456bac2186fcee3cc97fbdbff7e608813a7
|
7
|
+
data.tar.gz: 8dc092c24417da4bfe16584ece7e30d6501a19134c121333f51d4b0f4b177c7cb7e8ea384c9d28af8165b26ce6f534b121b6f7173c0d88fb49523925a79b053f
|
@@ -8,8 +8,8 @@ Fixtures = Sambot::Testing::Fixtures
|
|
8
8
|
RSpec.describe Sambot::Testing::VaultHelper do
|
9
9
|
|
10
10
|
before(:each) do
|
11
|
-
`docker-compose down`
|
12
|
-
`docker-compose up -d`
|
11
|
+
`docker-compose -p local down`
|
12
|
+
`docker-compose -p local up -d`
|
13
13
|
VaultHelper.setup
|
14
14
|
::Vault.configure do |config|
|
15
15
|
config.address = 'http://127.0.0.1:8200'
|
data/lib/sambot.rb
CHANGED
data/lib/sambot/chef/cookbook.rb
CHANGED
data/lib/sambot/cli.rb
CHANGED
@@ -20,7 +20,6 @@ module Sambot
|
|
20
20
|
desc 'up', 'Setup the Docker environment for testing cookbooks'
|
21
21
|
def up
|
22
22
|
execute do
|
23
|
-
require 'docker/compose'
|
24
23
|
up_cmd
|
25
24
|
populate_cmd
|
26
25
|
end
|
@@ -29,7 +28,6 @@ module Sambot
|
|
29
28
|
desc 'down', 'Destroy the Docker environment for testing cookbooks'
|
30
29
|
def down
|
31
30
|
execute do
|
32
|
-
require 'docker/compose'
|
33
31
|
down_cmd
|
34
32
|
end
|
35
33
|
end
|
@@ -37,7 +35,6 @@ module Sambot
|
|
37
35
|
desc 'test', 'Test a cookbook using the Docker environment'
|
38
36
|
def test
|
39
37
|
execute do
|
40
|
-
require 'docker/compose'
|
41
38
|
up_cmd
|
42
39
|
populate_cmd
|
43
40
|
down_cmd
|
@@ -79,15 +76,7 @@ module Sambot
|
|
79
76
|
desc 'create', 'Creates a new Chef cookbook'
|
80
77
|
def create
|
81
78
|
execute do
|
82
|
-
|
83
|
-
'name' => ask(' What is the name of this cookbook?'),
|
84
|
-
'type' => ask(' What type of cookbook will this be?', limited_to: %w[wrapper role]),
|
85
|
-
'platforms' => ask(' What operating system will this cookbook run on?', limited_to: %w[windows centos both]),
|
86
|
-
'description' => ask(' What does this cookbook do?')
|
87
|
-
}
|
88
|
-
opts['identifier'] = ask(' What will be the unique machiner identifier for this role cookbook i.e. TCA (TeamCity Agent) or RMQ (RabbitMQ role)?') if opts['type'] == 'role'
|
89
|
-
opts['platforms'] = opts['platforms'] == 'both' ? %w[centos windows] : [opts['platforms']]
|
90
|
-
Chef::Cookbook.create(Config.new(opts))
|
79
|
+
Sambot::Tasks::Create.new.run
|
91
80
|
end
|
92
81
|
end
|
93
82
|
|
@@ -109,13 +98,11 @@ module Sambot
|
|
109
98
|
end
|
110
99
|
|
111
100
|
def down_cmd
|
112
|
-
compose
|
113
|
-
compose.down
|
101
|
+
`docker-compose -p local down`
|
114
102
|
end
|
115
103
|
|
116
104
|
def up_cmd
|
117
|
-
compose
|
118
|
-
compose.up(detached: true)
|
105
|
+
`docker-compose -p local up -d`
|
119
106
|
end
|
120
107
|
|
121
108
|
end
|
data/lib/sambot/config.rb
CHANGED
@@ -41,6 +41,10 @@ module Sambot
|
|
41
41
|
Config.new(config)
|
42
42
|
end
|
43
43
|
|
44
|
+
def is_role_cookbook?
|
45
|
+
name.start_with?('as-role-') || name.start_with?('as-app-role-')
|
46
|
+
end
|
47
|
+
|
44
48
|
def available_platforms
|
45
49
|
platforms = @opts[:platforms] if @opts.key?(:platforms)
|
46
50
|
platforms = @opts['platforms'] if @opts.key?('platforms')
|
@@ -48,11 +52,11 @@ module Sambot
|
|
48
52
|
end
|
49
53
|
|
50
54
|
def gems
|
51
|
-
@opts['gems'] ||
|
55
|
+
@opts['gems'] || []
|
52
56
|
end
|
53
57
|
|
54
58
|
def dependencies
|
55
|
-
items = @opts['dependencies']
|
59
|
+
items = @opts['dependencies']
|
56
60
|
items ? items.map { |x| transform_hashes(x) } : []
|
57
61
|
end
|
58
62
|
|
@@ -1,7 +1,3 @@
|
|
1
1
|
#################################################################################
|
2
|
-
# <SAMBOT>
|
2
|
+
# <SAMBOT> POPULATE COMMAND #
|
3
3
|
#################################################################################
|
4
|
-
|
5
|
-
This command will output the version of the cookbook in the current directory.
|
6
|
-
|
7
|
-
It is mostly used for CI in order to give TeamCity builds their correct version number.
|
@@ -12,6 +12,20 @@ module Sambot
|
|
12
12
|
ET_GITHUB_API = 'https://github.exacttarget.com/api/v3'
|
13
13
|
ET_GITHUB = 'https://github.exacttarget.com'
|
14
14
|
|
15
|
+
def create_repository(name, organization = nil)
|
16
|
+
# Need to check whether repo already exists first and do nothing if yes
|
17
|
+
api.repos.create "name": name, org: organization,
|
18
|
+
"private": false,
|
19
|
+
"has_issues": true,
|
20
|
+
"has_wiki": false,
|
21
|
+
"has_downloads": true
|
22
|
+
end
|
23
|
+
|
24
|
+
def delete_repository(user, repo)
|
25
|
+
# Need to check whether repo exists first
|
26
|
+
api.repos.delete user, repo
|
27
|
+
end
|
28
|
+
|
15
29
|
def checkout(organization)
|
16
30
|
repositories = list_organization_repositories(organization)
|
17
31
|
repositories.each do |repository|
|
@@ -49,6 +63,7 @@ module Sambot
|
|
49
63
|
end
|
50
64
|
|
51
65
|
def api
|
66
|
+
check_configuration
|
52
67
|
@github ||= Github.new do |c|
|
53
68
|
c.basic_auth = "#{ENV['GITHUB_USERNAME']}:#{ENV['GITHUB_PERSONAL_TOKEN']}"
|
54
69
|
c.endpoint = ET_GITHUB_API
|
@@ -56,6 +71,17 @@ module Sambot
|
|
56
71
|
end
|
57
72
|
end
|
58
73
|
|
74
|
+
def check_configuration
|
75
|
+
unless ENV['GITHUB_USERNAME']
|
76
|
+
UI.error("Please ensure the GITHUB_USERNAME environment variable is set before running Github tasks.")
|
77
|
+
exit
|
78
|
+
end
|
79
|
+
unless ENV['GITHUB_PERSONAL_TOKEN']
|
80
|
+
UI.error("Please ensure the GITHUB_PERSONAL_TOKEN environment variable is set before running Github tasks. A personal token can be obtained from your Github account settings.")
|
81
|
+
exit
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
59
85
|
end
|
60
86
|
end
|
61
87
|
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../base_command'
|
4
|
+
|
5
|
+
module Sambot
|
6
|
+
module Tasks
|
7
|
+
class Create < BaseCommand
|
8
|
+
|
9
|
+
NAME_REQUEST = ' What is the name of this cookbook?'
|
10
|
+
|
11
|
+
PLATFORM_REQUEST = ' What operating system will this cookbook run on?'
|
12
|
+
|
13
|
+
DESCRIPTION_REQUEST = ' What does this cookbook do?'
|
14
|
+
|
15
|
+
PLATFORM_OPTIONS = %w[windows centos both]
|
16
|
+
|
17
|
+
IDENTIFIER_REQUEST = ' What will be the unique machiner identifier for this role cookbook i.e. TCA (TeamCity Agent) or RMQ (RabbitMQ role)?'
|
18
|
+
|
19
|
+
no_commands do
|
20
|
+
|
21
|
+
def run
|
22
|
+
opts = {
|
23
|
+
'name' => ask(NAME_REQUEST),
|
24
|
+
'platforms' => ask(PLATFORM_REQUEST, limited_to: PLATFORM_OPTIONS),
|
25
|
+
'description' => ask(DESCRIPTION_REQUEST)
|
26
|
+
}
|
27
|
+
check_cookbook_name(opts['name'])
|
28
|
+
opts['identifier'] = ask(IDENTIFIER_REQUEST) if is_valid_role_name?(opts['name'])
|
29
|
+
opts['platforms'] = normalize_platforms(opts['platforms'])
|
30
|
+
Chef::Cookbook.create(Config.new(opts))
|
31
|
+
end
|
32
|
+
|
33
|
+
def normalize_platforms(platforms)
|
34
|
+
platforms == 'both' ? PLATFORM_OPTIONS - ['both']: platforms
|
35
|
+
end
|
36
|
+
|
37
|
+
def check_cookbook_name(name)
|
38
|
+
unless is_valid_name?(name)
|
39
|
+
UI.error('The cookbook name you have provided is invalid')
|
40
|
+
exit 1
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def is_valid_role_name?(name)
|
45
|
+
name.start_with?('as-role-') || name.start_with?('as-app-role-')
|
46
|
+
end
|
47
|
+
|
48
|
+
def is_valid_name?(name)
|
49
|
+
is_valid_role_name?(name)|| name.start_with?('as-')
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -2,9 +2,14 @@ version: '2'
|
|
2
2
|
services:
|
3
3
|
vault:
|
4
4
|
image: vault
|
5
|
-
container_name: vault
|
6
5
|
ports:
|
7
6
|
- "8200:8200"
|
8
7
|
cap_add:
|
9
8
|
- IPC_LOCK
|
10
9
|
entrypoint: vault server -dev -log-level=debug -dev-listen-address=0.0.0.0:8200 -dev-root-token-id=root
|
10
|
+
consul:
|
11
|
+
image: library/consul:0.8.5
|
12
|
+
ports:
|
13
|
+
- "8500:8500"
|
14
|
+
environment:
|
15
|
+
CONSUL_ADDR: "http://0.0.0.0:8500"
|
data/lib/sambot/version.rb
CHANGED
data/sambot.gemspec
CHANGED
@@ -37,7 +37,6 @@ Gem::Specification.new do |spec|
|
|
37
37
|
spec.add_dependency 'awesome_print'
|
38
38
|
spec.add_development_dependency 'pry'
|
39
39
|
spec.add_development_dependency 'fuubar'
|
40
|
-
spec.add_development_dependency 'docker-compose'
|
41
40
|
spec.add_development_dependency 'rubocop', '~> 0.49'
|
42
41
|
spec.add_development_dependency 'gem-release', '~> 1.0'
|
43
42
|
spec.add_development_dependency 'bundler'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sambot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.207
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Olivier Kouame
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-07-
|
11
|
+
date: 2017-07-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor-hollaback
|
@@ -274,20 +274,6 @@ dependencies:
|
|
274
274
|
- - ">="
|
275
275
|
- !ruby/object:Gem::Version
|
276
276
|
version: '0'
|
277
|
-
- !ruby/object:Gem::Dependency
|
278
|
-
name: docker-compose
|
279
|
-
requirement: !ruby/object:Gem::Requirement
|
280
|
-
requirements:
|
281
|
-
- - ">="
|
282
|
-
- !ruby/object:Gem::Version
|
283
|
-
version: '0'
|
284
|
-
type: :development
|
285
|
-
prerelease: false
|
286
|
-
version_requirements: !ruby/object:Gem::Requirement
|
287
|
-
requirements:
|
288
|
-
- - ">="
|
289
|
-
- !ruby/object:Gem::Version
|
290
|
-
version: '0'
|
291
277
|
- !ruby/object:Gem::Dependency
|
292
278
|
name: rubocop
|
293
279
|
requirement: !ruby/object:Gem::Requirement
|
@@ -415,6 +401,8 @@ files:
|
|
415
401
|
- lib/sambot/fs.rb
|
416
402
|
- lib/sambot/runtime.rb
|
417
403
|
- lib/sambot/source_control.rb
|
404
|
+
- lib/sambot/tasks/create.rb
|
405
|
+
- lib/sambot/team_city.rb
|
418
406
|
- lib/sambot/template.rb
|
419
407
|
- lib/sambot/templates/.config.yml.erb
|
420
408
|
- lib/sambot/templates/.env
|