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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d29631e3da738fcaeb3b7b7d829874ff89081554
4
- data.tar.gz: 0b59b73c1c3c9a508e2a7f88ba92bd98a13a37ce
3
+ metadata.gz: 15173b6ef6750e6401a9c62293cdb2ff2bd3198c
4
+ data.tar.gz: 1c296d1fad951712c9dfb0b32ba6282eb15a1a09
5
5
  SHA512:
6
- metadata.gz: b88385b1837f87c208d14ebc27ab2bc97e15bd8eec0937f24532ba783aa03e9f038962974a73c652ab8323c63a527c66bcc489fe42b4c7122ddd93e3781fb9b0
7
- data.tar.gz: 29229d26b3dc727724b054e1d575fcacb2388b80dd30a01f4ea7569a573a7b2b4e82e0b7a4b7ff05025af210cd624cc990e1d86573631bec818f505c5f222980
6
+ metadata.gz: b195367df5cbd3e1cd8647e4373e0b6ed952836ab931721bd5e27ea03b6552a6303bdcc6764c2f40fd0ece75fc661456bac2186fcee3cc97fbdbff7e608813a7
7
+ data.tar.gz: 8dc092c24417da4bfe16584ece7e30d6501a19134c121333f51d4b0f4b177c7cb7e8ea384c9d28af8165b26ce6f534b121b6f7173c0d88fb49523925a79b053f
@@ -2,7 +2,6 @@ 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:
@@ -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
@@ -23,6 +23,8 @@ require_relative 'sambot/chef/server'
23
23
  require_relative 'sambot/chef/generator'
24
24
  require_relative 'sambot/chef/roles'
25
25
 
26
+ require_relative 'sambot/tasks/create'
27
+
26
28
  require_relative 'sambot/cli'
27
29
 
28
30
  module Sambot
@@ -50,6 +50,8 @@ module Sambot
50
50
  Dir.chdir(config.name) do
51
51
  create_files(config)
52
52
  end
53
+ #TeamCity.create_build_configuration(config)
54
+ #SourceControl.create_repository(config)
53
55
  UI.info('The cookbook has been successfully created.')
54
56
  end
55
57
 
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
- opts = {
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 = Docker::Compose.new
113
- compose.down
101
+ `docker-compose -p local down`
114
102
  end
115
103
 
116
104
  def up_cmd
117
- compose = Docker::Compose.new
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'] || @opts[:gems] || []
55
+ @opts['gems'] || []
52
56
  end
53
57
 
54
58
  def dependencies
55
- items = @opts['dependencies'] || @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> VERSION COMMAND #
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
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'pry'
4
+ require 'github_api'
5
+ require 'git'
6
+
7
+ module Sambot
8
+ class TeamCity
9
+
10
+ class << self
11
+
12
+
13
+ end
14
+
15
+ end
16
+ 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"
@@ -2,3 +2,5 @@
2
2
 
3
3
  require 'chefspec'
4
4
  require 'chefspec/berkshelf'
5
+
6
+ at_exit { ChefSpec::Coverage.report! }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Sambot
4
- VERSION = '0.1.206'
4
+ VERSION = '0.1.207'
5
5
  end
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.206
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-28 00:00:00.000000000 Z
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