sambot 0.1.213 → 0.1.214
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/sambot.rb +7 -2
- data/lib/sambot/chef/cookbook.rb +1 -1
- data/lib/sambot/chef/roles.rb +1 -1
- data/lib/sambot/cli.rb +15 -89
- data/lib/sambot/source_control.rb +46 -10
- data/lib/sambot/tasks/build.rb +28 -0
- data/lib/sambot/tasks/check.rb +28 -0
- data/lib/sambot/tasks/create.rb +1 -1
- data/lib/sambot/tasks/down.rb +20 -0
- data/lib/sambot/tasks/populate.rb +21 -0
- data/lib/sambot/tasks/test.rb +21 -0
- data/lib/sambot/tasks/up.rb +24 -0
- data/lib/sambot/tasks/verify.rb +35 -0
- data/lib/sambot/tasks/version.rb +19 -0
- data/lib/sambot/teamcity/builds.rb +24 -7
- data/lib/sambot/teamcity/faraday.rb +1 -1
- data/lib/sambot/templates/git_hooks/pre-commit +0 -5
- data/lib/sambot/testing/vault_helper.rb +15 -5
- data/lib/sambot/version.rb +1 -1
- metadata +10 -3
- data/lib/sambot/team_city.rb +0 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3f2ae76a337fbddc024b5f4726e2475573fd7175
|
4
|
+
data.tar.gz: d676602ea84c172e479f693266ba273dbe622ce1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 61c6cabe142666ba50b0f531a8816a3219dd42f158777fc15327bee8ad3cdd2c9b1293e46a09434fc513325f996ea0d1af5e52b984014f1bd64869d1891efdad
|
7
|
+
data.tar.gz: 831de4e46b42c972f85706a15475b7218d48e1ec2a5f1c84917e8eace5f6b4999e852b98b3be540677d8e63bbf59fb92448c469a3b66a71b2c0fdab1a4b9975f
|
data/lib/sambot.rb
CHANGED
@@ -13,7 +13,6 @@ require_relative 'sambot/version'
|
|
13
13
|
require_relative 'sambot/template'
|
14
14
|
require_relative 'sambot/fs'
|
15
15
|
require_relative 'sambot/source_control'
|
16
|
-
require_relative 'sambot/team_city'
|
17
16
|
|
18
17
|
require_relative 'sambot/testing/consul_helper'
|
19
18
|
require_relative 'sambot/testing/vault_helper'
|
@@ -28,7 +27,13 @@ require_relative 'sambot/chef/generator'
|
|
28
27
|
require_relative 'sambot/chef/roles'
|
29
28
|
|
30
29
|
require_relative 'sambot/tasks/create'
|
31
|
-
|
30
|
+
require_relative 'sambot/tasks/verify'
|
31
|
+
require_relative 'sambot/tasks/build'
|
32
|
+
require_relative 'sambot/tasks/version'
|
33
|
+
require_relative 'sambot/tasks/up'
|
34
|
+
require_relative 'sambot/tasks/down'
|
35
|
+
require_relative 'sambot/tasks/populate'
|
36
|
+
require_relative 'sambot/tasks/test'
|
32
37
|
require_relative 'sambot/cli'
|
33
38
|
|
34
39
|
require_relative 'sambot/teamcity/faraday'
|
data/lib/sambot/chef/cookbook.rb
CHANGED
@@ -59,7 +59,7 @@ module Sambot
|
|
59
59
|
|
60
60
|
def create_files(config)
|
61
61
|
['README.md'].each { |resource| FS.copy(resource) unless FS.exist?(resource) }
|
62
|
-
%w[spec test attributes
|
62
|
+
%w[spec test attributes].each { |resource| FS.mkdir(resource) unless FS.exist?(resource) }
|
63
63
|
Dir.chdir('attributes') { FileUtils.touch('default.rb') unless FS.exist?('default.rb') }
|
64
64
|
Dir.chdir('spec') { FS.copy('spec_helper.rb') unless FS.exist?('spec_helper.rb') }
|
65
65
|
%w[recipes libraries resources files templates].each { |target| FS.mkdir(target) unless FS.exist?(target) }
|
data/lib/sambot/chef/roles.rb
CHANGED
@@ -43,7 +43,7 @@ module Sambot
|
|
43
43
|
|
44
44
|
def apply_changes(contents, repository, file)
|
45
45
|
puts 'Not stubbed'
|
46
|
-
|
46
|
+
raise 'error'
|
47
47
|
msg = "Updated cookbook dependency #{dependency_name} to #{version}"
|
48
48
|
SourceControl.edit_file(ROLE_COOKBOOK_ORGANIZATION, repository, COOKBOOK_CONFIG, contents, file, msg)
|
49
49
|
return true
|
data/lib/sambot/cli.rb
CHANGED
@@ -7,120 +7,46 @@ module Sambot
|
|
7
7
|
|
8
8
|
desc 'checkout', 'Checks out or updates all the repositories in a given organization'
|
9
9
|
def checkout(organization, dir)
|
10
|
-
|
11
|
-
|
10
|
+
execute do
|
11
|
+
Dir.chdir(dir) do
|
12
|
+
SourceControl.checkout(organization)
|
13
|
+
end
|
12
14
|
end
|
13
15
|
end
|
14
16
|
|
15
17
|
desc 'clean', 'Remove all generated build files from a Chef cookbook'
|
16
|
-
def clean
|
17
|
-
execute { Chef::Cookbook.clean }
|
18
|
-
end
|
18
|
+
def clean; execute { Chef::Cookbook.clean } end
|
19
19
|
|
20
20
|
desc 'up', 'Setup the Docker environment for testing cookbooks'
|
21
|
-
def up
|
22
|
-
execute do
|
23
|
-
unless File.exist?('docker-compose.yml')
|
24
|
-
UI.error("This command should only be run in a cookbook directory. Make sure you have run `chef exec sambot build --local --docker` before trying again.")
|
25
|
-
exit 1
|
26
|
-
end
|
27
|
-
up_cmd
|
28
|
-
populate_cmd
|
29
|
-
end
|
30
|
-
end
|
21
|
+
def up; execute { Sambot::Tasks::Up.new.run(options) } end
|
31
22
|
|
32
23
|
desc 'down', 'Destroy the Docker environment for testing cookbooks'
|
33
|
-
def down
|
34
|
-
execute do
|
35
|
-
down_cmd
|
36
|
-
end
|
37
|
-
end
|
24
|
+
def down; execute { Sambot::Tasks::Down.new.run(options) } end
|
38
25
|
|
39
26
|
desc 'test', 'Test a cookbook using the Docker environment'
|
40
|
-
def test
|
41
|
-
execute do
|
42
|
-
up_cmd
|
43
|
-
populate_cmd
|
44
|
-
down_cmd
|
45
|
-
end
|
46
|
-
end
|
27
|
+
def test; execute { Sambot::Tasks::Test.new.run(options) } end
|
47
28
|
|
48
29
|
desc 'populate', 'Populates Vault and Consul with seed data'
|
49
|
-
def populate
|
50
|
-
execute do
|
51
|
-
populate_cmd
|
52
|
-
end
|
53
|
-
end
|
30
|
+
def populate; execute { Sambot::Tasks::Populate.new.run(options) } end
|
54
31
|
|
55
32
|
desc 'bump', 'Bump the patch version of a cookbook'
|
56
|
-
def bump
|
57
|
-
execute { Chef::Cookbook.bump }
|
58
|
-
end
|
33
|
+
def bump; execute { Chef::Cookbook.bump } end
|
59
34
|
|
60
35
|
desc 'build', 'Builds a Chef cookbook from its configuration file'
|
61
36
|
option :local, type: :boolean
|
62
37
|
option :google, type: :boolean
|
63
38
|
option :rackspace, type: :boolean
|
64
39
|
option :docker, type: :boolean
|
65
|
-
def build
|
66
|
-
execute do
|
67
|
-
cloud = nil
|
68
|
-
cloud = 'local' if options[:local]
|
69
|
-
cloud = 'google' if options[:google]
|
70
|
-
cloud = 'rackspace' if options[:rackspace]
|
71
|
-
unless cloud
|
72
|
-
UI.error('Please select which environment this is building for using one of the following flags: --local, --rackspace or --google')
|
73
|
-
exit
|
74
|
-
end
|
75
|
-
local_workflow = options[:docker] ? 'docker' : 'vagrant'
|
76
|
-
Chef::Cookbook.build(Config.read, cloud, local_workflow)
|
77
|
-
end
|
78
|
-
end
|
40
|
+
def build; execute { Sambot::Tasks::Build.new.run(options) } end
|
79
41
|
|
80
42
|
desc 'create', 'Creates a new Chef cookbook'
|
81
|
-
def create
|
82
|
-
execute do
|
83
|
-
Sambot::Tasks::Create.new.run
|
84
|
-
end
|
85
|
-
end
|
43
|
+
def create; execute { Sambot::Tasks::Create.new.run(options) } end
|
86
44
|
|
87
45
|
desc 'version', 'Gives the cookbook version as a TeamCity service message'
|
88
|
-
def version
|
89
|
-
execute { puts "##teamcity[buildNumber '#{Config.read.version}']" }
|
90
|
-
end
|
91
|
-
|
92
|
-
desc 'pin', 'Goes through role cookbooks and updates a wrapper cookbook version'
|
93
|
-
def pin
|
94
|
-
end
|
95
|
-
|
96
|
-
desc 'verify', 'Ensures all supporting resources i.e. cookbook structure, TeamCity build and Git repository are created'
|
97
|
-
def verify
|
98
|
-
# Check in cookbook directory
|
99
|
-
# Check for .config.yml - if not present, raise error
|
100
|
-
# Get name from .config.yml
|
101
|
-
# Check Github repository exists, if not ask to create it
|
102
|
-
# Check TeamCity build configuration exists, if not ask to create it
|
103
|
-
# Add deploy key to Vault and TeamCity Server
|
104
|
-
end
|
105
|
-
|
106
|
-
no_commands do
|
46
|
+
def version; execute { Sambot::Tasks::Version.new.run(options) } end
|
107
47
|
|
108
|
-
|
109
|
-
|
110
|
-
Sambot::Testing::VaultHelper.load_secrets(Config.read)
|
111
|
-
Sambot::Testing::ConsulHelper.load_values(Config.read)
|
112
|
-
end
|
113
|
-
|
114
|
-
def down_cmd
|
115
|
-
`docker-compose -p local down`
|
116
|
-
`docker-compose -p local rm -sf`
|
117
|
-
end
|
118
|
-
|
119
|
-
def up_cmd
|
120
|
-
`docker-compose -p local up -d`
|
121
|
-
end
|
122
|
-
|
123
|
-
end
|
48
|
+
desc 'verify', 'Ensures all supporting resources i.e. TeamCity build and Git repository are created and the git origin is pointing to the correct URL'
|
49
|
+
def verify; execute { Sambot::Tasks::Verify.new.run(options) } end
|
124
50
|
|
125
51
|
end
|
126
52
|
end
|
@@ -11,19 +11,48 @@ module Sambot
|
|
11
11
|
|
12
12
|
ET_GITHUB_API = 'https://github.exacttarget.com/api/v3'
|
13
13
|
ET_GITHUB = 'https://github.exacttarget.com'
|
14
|
+
ET_GITHUB_HOST = 'github.exacttarget.com'
|
15
|
+
WRAPPER_COOKBOOKS = 'ads-wrapper-cookbooks'
|
16
|
+
ROLE_COOKBOOKS = 'ads-role-cookbooks'
|
14
17
|
|
15
|
-
def
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
"has_wiki": false,
|
21
|
-
"has_downloads": true
|
18
|
+
def set_git_remote(config)
|
19
|
+
target = identify_repository(config)
|
20
|
+
cmd = "git remote set-url origin git@#{ET_GITHUB_HOST}:#{target[:organization]}/#{target[:name]}"
|
21
|
+
UI.info("Running the following command: #{cmd}")
|
22
|
+
`#{cmd}`
|
22
23
|
end
|
23
24
|
|
24
|
-
def
|
25
|
-
#
|
26
|
-
|
25
|
+
def add_deploy_key(config)
|
26
|
+
# Create deploy key
|
27
|
+
# Add it to Vault
|
28
|
+
# Run Chef-Client against TeamCity
|
29
|
+
end
|
30
|
+
|
31
|
+
def create_repository(config)
|
32
|
+
target = identify_repository(config)
|
33
|
+
if api.repos.get user: target[:organization], repo: target[:name]
|
34
|
+
UI.info("The repository #{target[:organization]}/#{target[:name]} exists and will not be recreated")
|
35
|
+
return 1
|
36
|
+
else
|
37
|
+
api.repos.create "name": target[:name], org: target[:organization],
|
38
|
+
"private": false,
|
39
|
+
"has_issues": true,
|
40
|
+
"has_wiki": false,
|
41
|
+
"has_downloads": true
|
42
|
+
UI.info("The repository #{target[:organization]}/#{target[:name]} has been created")
|
43
|
+
return 0
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def delete_repository(config)
|
48
|
+
target = identify_repository(config)
|
49
|
+
if api.repos.get "#{target[:organization]}/#{target[:name]}"
|
50
|
+
UI.info("The repository #{target[:organization]}/#{arget[:name]} does not exist and will not be deleted")
|
51
|
+
return 1
|
52
|
+
else
|
53
|
+
api.repos.delete organization, repo
|
54
|
+
return 0
|
55
|
+
end
|
27
56
|
end
|
28
57
|
|
29
58
|
def checkout(organization)
|
@@ -58,6 +87,13 @@ module Sambot
|
|
58
87
|
|
59
88
|
private
|
60
89
|
|
90
|
+
def identify_repository(config)
|
91
|
+
{
|
92
|
+
name: config.name,
|
93
|
+
organization: config.is_role_cookbook? ? ROLE_COOKBOOKS : WRAPPER_COOKBOOKS
|
94
|
+
}
|
95
|
+
end
|
96
|
+
|
61
97
|
def contents_api
|
62
98
|
api.repos.contents
|
63
99
|
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../base_command'
|
4
|
+
|
5
|
+
module Sambot
|
6
|
+
module Tasks
|
7
|
+
class Build < BaseCommand
|
8
|
+
|
9
|
+
no_commands do
|
10
|
+
|
11
|
+
def run(options)
|
12
|
+
cloud = nil
|
13
|
+
cloud = 'local' if options[:local]
|
14
|
+
cloud = 'google' if options[:google]
|
15
|
+
cloud = 'rackspace' if options[:rackspace]
|
16
|
+
unless cloud
|
17
|
+
UI.error('Please select which environment this is building for using one of the following flags: --local, --rackspace or --google')
|
18
|
+
exit
|
19
|
+
end
|
20
|
+
local_workflow = options[:docker] ? 'docker' : 'vagrant'
|
21
|
+
Chef::Cookbook.build(Config.read, cloud, local_workflow)
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../base_command'
|
4
|
+
|
5
|
+
module Sambot
|
6
|
+
module Tasks
|
7
|
+
class Check < BaseCommand
|
8
|
+
|
9
|
+
no_commands do
|
10
|
+
|
11
|
+
def run(directory, options)
|
12
|
+
# For each directory
|
13
|
+
# If a wrapper cookbook
|
14
|
+
# Check if a .config.yml file is present
|
15
|
+
# Check if the .config.yml file correctly points to inspec/tests
|
16
|
+
# Check if inspec tests controls inspec.yml and controls folder
|
17
|
+
# Check if a build configuration is present in the correct location
|
18
|
+
# If a role cookbook
|
19
|
+
# Check if a .config.yml file is present
|
20
|
+
# Check as-dependencies and esure config.yml imports the compliance profiles
|
21
|
+
# Check if a build configuration is present in the correct location
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/lib/sambot/tasks/create.rb
CHANGED
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../base_command'
|
4
|
+
|
5
|
+
module Sambot
|
6
|
+
module Tasks
|
7
|
+
class Down < BaseCommand
|
8
|
+
|
9
|
+
no_commands do
|
10
|
+
|
11
|
+
def run(options)
|
12
|
+
`docker-compose -p local down`
|
13
|
+
`docker-compose -p local rm -sf`
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../base_command'
|
4
|
+
|
5
|
+
module Sambot
|
6
|
+
module Tasks
|
7
|
+
class Populate < BaseCommand
|
8
|
+
|
9
|
+
no_commands do
|
10
|
+
|
11
|
+
def run(options)
|
12
|
+
Sambot::Testing::VaultHelper.setup
|
13
|
+
Sambot::Testing::VaultHelper.load_secrets(Config.read)
|
14
|
+
Sambot::Testing::ConsulHelper.load_values(Config.read)
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../base_command'
|
4
|
+
|
5
|
+
module Sambot
|
6
|
+
module Tasks
|
7
|
+
class Test < BaseCommand
|
8
|
+
|
9
|
+
no_commands do
|
10
|
+
|
11
|
+
def run(options)
|
12
|
+
Sambot::Tasks::Up.new.run(options)
|
13
|
+
`chef exec kitchen test`
|
14
|
+
Sambot::Tasks::Down.new.run(options)
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../base_command'
|
4
|
+
|
5
|
+
module Sambot
|
6
|
+
module Tasks
|
7
|
+
class Up < BaseCommand
|
8
|
+
|
9
|
+
no_commands do
|
10
|
+
|
11
|
+
def run(options)
|
12
|
+
unless File.exist?('docker-compose.yml')
|
13
|
+
UI.error("This command should only be run in a cookbook directory. Make sure you have run `chef exec sambot build --local --docker` before trying again.")
|
14
|
+
exit 1
|
15
|
+
end
|
16
|
+
`docker-compose -p local up -d`
|
17
|
+
Sambot::Tasks::Populate.new.run(options)
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../base_command'
|
4
|
+
|
5
|
+
module Sambot
|
6
|
+
module Tasks
|
7
|
+
class Verify < BaseCommand
|
8
|
+
|
9
|
+
no_commands do
|
10
|
+
|
11
|
+
def run(options)
|
12
|
+
check_configuration
|
13
|
+
config = Config.read
|
14
|
+
::TeamCity.create_cookbook_build(config)
|
15
|
+
::Sambot::SourceControl.create_repository(config)
|
16
|
+
::Sambot::SourceControl.set_git_remote(config)
|
17
|
+
::Sambot::SourceControl.add_deploy_key(config)
|
18
|
+
end
|
19
|
+
|
20
|
+
def check_configuration
|
21
|
+
unless ENV['TEAMCITY_USERNAME']
|
22
|
+
UI.error("Please ensure the TEAMCITY_USERNAME environment variable is set before running this command")
|
23
|
+
exit
|
24
|
+
end
|
25
|
+
unless ENV['TEAMCITY_PASSWORD']
|
26
|
+
UI.error("Please ensure the TEAMCITY_USERNAME environment variable is set before running this command")
|
27
|
+
exit
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../base_command'
|
4
|
+
|
5
|
+
module Sambot
|
6
|
+
module Tasks
|
7
|
+
class Version < BaseCommand
|
8
|
+
|
9
|
+
no_commands do
|
10
|
+
|
11
|
+
def run(options)
|
12
|
+
puts "##teamcity[buildNumber '#{Config.read.version}']"
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -2,6 +2,10 @@ module TeamCity
|
|
2
2
|
class Client
|
3
3
|
module Builds
|
4
4
|
|
5
|
+
LINUX_WRAPPER_COOKBOOKS_PROJECT = 'Wrapper Cookbooks - GCP'
|
6
|
+
LINUX_ROLE_COOKBOOKS_PROJECT = 'Role Cookbooks - GCP'
|
7
|
+
GCP_PROJECT = 'Google Cloud Platform'
|
8
|
+
|
5
9
|
def attach_template(build_id, template_id)
|
6
10
|
path = "buildTypes/#{build_id}/template"
|
7
11
|
put(path, :content_type => :text) do |request|
|
@@ -17,19 +21,32 @@ module TeamCity
|
|
17
21
|
end
|
18
22
|
end
|
19
23
|
|
24
|
+
def build_exists?(project, build_name)
|
25
|
+
all_builds = TeamCity.project_buildtypes(id: project.id).map {|x| x.name}
|
26
|
+
all_builds.include?(build_name)
|
27
|
+
end
|
28
|
+
|
20
29
|
def create_cookbook_build(config)
|
21
30
|
::TeamCity.configure do |config|
|
22
31
|
config.endpoint = 'https://teamcity.brighter.io/httpAuth/app/rest' || ENV['TEAMCITY_URL']
|
23
32
|
config.http_user = ENV['TEAMCITY_USERNAME']
|
24
33
|
config.http_password = ENV['TEAMCITY_PASSWORD']
|
25
34
|
end
|
26
|
-
|
27
|
-
|
28
|
-
project = ::TeamCity.find_project_by_name(
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
35
|
+
project_name = config.is_role_cookbook? ? LINUX_ROLE_COOKBOOKS_PROJECT : LINUX_WRAPPER_COOKBOOKS_PROJECT
|
36
|
+
::Sambot::UI.debug("Looking for the project #{project_name}")
|
37
|
+
project = ::TeamCity.find_project_by_name(project_name)
|
38
|
+
if build_exists?(project, config.name)
|
39
|
+
::Sambot::UI.info("The build configuration '#{config.name}' already exists in the project '#{project.name}'")
|
40
|
+
else
|
41
|
+
::Sambot::UI.debug("Looking for the template project #{GCP_PROJECT}")
|
42
|
+
template_project = ::TeamCity.find_project_by_name(GCP_PROJECT)
|
43
|
+
template = ::TeamCity.project_templates(id: template_project.id)[0]
|
44
|
+
::Sambot::UI.debug("Using the TeamCity template #{template.name}")
|
45
|
+
build_configuration = ::TeamCity.create_build(project.id, config.name)
|
46
|
+
::TeamCity.attach_template(build_configuration.id, template.id)
|
47
|
+
::Sambot::UI.info("The build configuration '#{config.name}' has been created in the project '#{project.name}'")
|
48
|
+
build_configuration
|
49
|
+
end
|
33
50
|
end
|
34
51
|
|
35
52
|
end
|
@@ -17,7 +17,7 @@ module TeamCity
|
|
17
17
|
connection.use FaradayMiddleware::Mashify
|
18
18
|
connection.use FaradayMiddleware::ParseJson if headers.accept =~ /json/
|
19
19
|
connection.use FaradayMiddleware::NullResponseBody
|
20
|
-
connection.use Faraday::Response::Logger
|
20
|
+
#connection.use Faraday::Response::Logger
|
21
21
|
connection.adapter(adapter)
|
22
22
|
connection.basic_auth(http_user, http_password)
|
23
23
|
end
|
@@ -13,16 +13,25 @@ module Sambot
|
|
13
13
|
VAULT_CONFIG_BINARY = 'vault-config'
|
14
14
|
WORKING_DIR = '/tmp/sambot/testing/vault'
|
15
15
|
VAULT_POLICIES_REPO = 'git@github.exacttarget.com:ads-devops/vault-policies.git'
|
16
|
+
VAULT_ADDRESS = 'http://127.0.0.1:8200'
|
17
|
+
BOOTSTRAP_TOKEN_ROLE = 'nightswatch-ro'
|
18
|
+
BOOTSTRAP_TOKEN_TTL = '72h'
|
19
|
+
BOOTSTRAP_TOKEN = 'root'
|
20
|
+
BOOTSTRAP_TOKEN_POLICIES = ['nightswatch-ro']
|
16
21
|
|
17
|
-
def
|
22
|
+
def configure
|
18
23
|
::Vault.configure do |config|
|
19
|
-
config.address =
|
20
|
-
config.token =
|
24
|
+
config.address = VAULT_ADDRESS
|
25
|
+
config.token = BOOTSTRAP_TOKEN
|
21
26
|
config.ssl_verify = false
|
22
27
|
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def generate_wrapped_token
|
31
|
+
configure
|
23
32
|
token = ''
|
24
33
|
begin
|
25
|
-
wrap_info = Vault.auth_token.create('wrap_ttl':
|
34
|
+
wrap_info = Vault.auth_token.create('wrap_ttl': BOOTSTRAP_TOKEN_TTL, role: BOOTSTRAP_TOKEN_ROLE, policies: BOOTSTRAP_TOKEN_POLICIES).wrap_info
|
26
35
|
token = wrap_info.token
|
27
36
|
rescue
|
28
37
|
end
|
@@ -39,7 +48,7 @@ module Sambot
|
|
39
48
|
Dir.chdir 'vault-policies/dev/vault-config' do
|
40
49
|
FS.copy(VAULT_CONFIG_BINARY)
|
41
50
|
UI.info('Applying the Vault policies')
|
42
|
-
`VC_VAULT_ADDR
|
51
|
+
`VC_VAULT_ADDR=#{VAULT_ADDRESS} VC_VAULT_TOKEN=#{BOOTSTRAP_TOKEN} ./#{VAULT_CONFIG_BINARY} config`
|
43
52
|
UI.info('The Vault policies have been applied')
|
44
53
|
end
|
45
54
|
end
|
@@ -79,6 +88,7 @@ module Sambot
|
|
79
88
|
end
|
80
89
|
|
81
90
|
def write_to_vault(path, key, value)
|
91
|
+
configure
|
82
92
|
Vault.logical.write(path, key.to_sym => value)
|
83
93
|
end
|
84
94
|
|
data/lib/sambot/version.rb
CHANGED
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.214
|
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-
|
11
|
+
date: 2017-08-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor-hollaback
|
@@ -415,8 +415,15 @@ files:
|
|
415
415
|
- lib/sambot/fs.rb
|
416
416
|
- lib/sambot/runtime.rb
|
417
417
|
- lib/sambot/source_control.rb
|
418
|
+
- lib/sambot/tasks/build.rb
|
419
|
+
- lib/sambot/tasks/check.rb
|
418
420
|
- lib/sambot/tasks/create.rb
|
419
|
-
- lib/sambot/
|
421
|
+
- lib/sambot/tasks/down.rb
|
422
|
+
- lib/sambot/tasks/populate.rb
|
423
|
+
- lib/sambot/tasks/test.rb
|
424
|
+
- lib/sambot/tasks/up.rb
|
425
|
+
- lib/sambot/tasks/verify.rb
|
426
|
+
- lib/sambot/tasks/version.rb
|
420
427
|
- lib/sambot/teamcity/builds.rb
|
421
428
|
- lib/sambot/teamcity/faraday.rb
|
422
429
|
- lib/sambot/teamcity/projects.rb
|