fhcap-cli 0.4.13 → 0.4.14
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/CHANGELOG.md +13 -1
- data/Jenkinsfile +26 -0
- data/lib/fhcap/cli.rb +2 -0
- data/lib/fhcap/component.rb +3 -3
- data/lib/fhcap/config.rb +12 -0
- data/lib/fhcap/cookbook.rb +42 -2
- data/lib/fhcap/misc.rb +8 -1
- data/lib/fhcap/repo.rb +1 -1
- data/lib/fhcap/repos_helper.rb +11 -0
- data/lib/fhcap/tasks/chef/cookbook/aws/s3_helper.rb +21 -0
- data/lib/fhcap/tasks/chef/cookbook/check_bumps.rb +109 -0
- data/lib/fhcap/tasks/chef/cookbook/list_artifacts.rb +73 -17
- data/lib/fhcap/tasks/chef/cookbook/update_attribute.rb +51 -0
- data/lib/fhcap/tasks/chef/environments/create.rb +3 -1
- data/lib/fhcap/tasks/cluster/create_environment.rb +4 -3
- data/lib/fhcap/tasks/misc/platform_bump.rb +36 -0
- data/lib/fhcap/tasks/repo/add.rb +4 -6
- data/lib/fhcap/tasks/setup.rb +7 -1
- data/lib/fhcap/version.rb +1 -1
- data/lib/fhcap.rb +1 -1
- data/spec/fhcap/tasks/chef/cookbook/check_bumps_spec.rb +33 -0
- data/templates/chef/{environment_oscp.json.erb → environment_ocp.json.erb} +16 -1
- data/templates/chef/environment_ose-single.json.erb +1 -1
- data/templates/cluster/aws/common.json.erb +22 -23
- data/templates/cluster/aws/{oscp-7node.json.erb → ocp-multi-infra.json.erb} +64 -51
- data/templates/cluster/aws/{oscp-5node.json.erb → ocp-multi.json.erb} +47 -59
- data/templates/cluster/ocp-multi-infra.json.erb +8 -0
- data/templates/cluster/ocp-multi.json.erb +8 -0
- data/templates/cluster/openstack/{oscp-7node.json.erb → ocp-multi-infra.json.erb} +0 -0
- data/templates/cluster/openstack/{oscp-5node.json.erb → ocp-multi.json.erb} +0 -0
- metadata +16 -9
- data/templates/cluster/oscp-5node.json.erb +0 -8
- data/templates/cluster/oscp-7node.json.erb +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: df6384b3f0a956ef606c3ce4543bdf5416501505
|
4
|
+
data.tar.gz: e468e58706453980ecde19e48309ff3f7eb0d0b8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 32bbd3b888485117124bb672a68018f0a71212e799fe22ee94b0a6dbcb08654c60cefdb4c55734ded424171afc11fb2e49da49df773ad96e3a244c2cc20e2d82
|
7
|
+
data.tar.gz: cf572600c4a85f9e1f94c5711c9a40d1f1355f34831991ec6b6852493fdbf579c211711549db6b21e2580608a13ade2787cc915637b57477d4eaac9bae814918
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,18 @@
|
|
1
|
-
|
2
1
|
## Unreleased
|
3
2
|
|
3
|
+
## 0.4.14
|
4
|
+
|
5
|
+
* [RHMAP-16161] - Adding S3 support for RHMAP component validation as part of list_artifacts task
|
6
|
+
* [RHMAP-8094] - Add cookbook check-bumps task
|
7
|
+
* [RHMAP-16470] - Added cookbook update attribute task
|
8
|
+
* [RHMAP-14096] - Adding platform version bump task
|
9
|
+
* [RHMAP-15648] - Add Jenkinsfile to repository for Wendy Jenkins builds
|
10
|
+
* [RHMAP-16052] - Allow updating clusters-dir option during repo add
|
11
|
+
* [RHMAP-16052] - Add empty-config and knife-dir option to setup task.
|
12
|
+
* [RHMAP-15292] - Renaming OSCP multi node cluster templates to ocp-multi and ocp-multi-infra
|
13
|
+
* [RHMAP-15292] - Adding support for AWS Elastic File System
|
14
|
+
* [RHMAP-15112] - Add 'dirty' option to cookbook update task. Allows manipulating cookbooks that have uncommited changes locally
|
15
|
+
|
4
16
|
## 0.4.13
|
5
17
|
|
6
18
|
* [RHMAP-15127] - Add meta only option to cluster info task
|
data/Jenkinsfile
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
#!groovy
|
2
|
+
|
3
|
+
// https://github.com/feedhenry/fh-pipeline-library
|
4
|
+
@Library('fh-pipeline-library') _
|
5
|
+
|
6
|
+
node("ruby") {
|
7
|
+
|
8
|
+
step([$class: 'WsCleanup'])
|
9
|
+
|
10
|
+
stage('Checkout') {
|
11
|
+
checkout scm
|
12
|
+
}
|
13
|
+
|
14
|
+
stage('Install Dependencies') {
|
15
|
+
sh 'bundle install --binstubs'
|
16
|
+
}
|
17
|
+
|
18
|
+
stage('Unit Tests') {
|
19
|
+
sh 'bin/rspec --format documentation --color'
|
20
|
+
}
|
21
|
+
|
22
|
+
stage('Build') {
|
23
|
+
sh 'bin/rake build'
|
24
|
+
archiveArtifacts 'pkg/fhcap-cli-*.gem'
|
25
|
+
}
|
26
|
+
}
|
data/lib/fhcap/cli.rb
CHANGED
@@ -20,6 +20,8 @@ module Fhcap
|
|
20
20
|
|
21
21
|
method_option 'repos-dir', :type => :string, :desc => "Local directory where configured repos will be checked out"
|
22
22
|
method_option 'fh-src-dir', :type => :string, :desc => "Local directory where FH component src repos are checked out"
|
23
|
+
method_option 'knife-dir', :type => :string, :desc => "Local directory where knife configuration will be stored"
|
24
|
+
method_option 'empty-config', :type => :boolean, :default => false, :desc => "Create an empty fhcap config i.e. No repos or knife config is pre configured"
|
23
25
|
|
24
26
|
desc "setup", "Setup the FHCAP CLI"
|
25
27
|
|
data/lib/fhcap/component.rb
CHANGED
@@ -28,7 +28,7 @@ module Fhcap
|
|
28
28
|
Fhcap::CLI::Component.new.invoke(:update_config, [component], {force: options[:force]}) if options['update-config']
|
29
29
|
|
30
30
|
#3. Update cookbook
|
31
|
-
Fhcap::CLI::Cookbook.new.invoke(:update, [], {
|
31
|
+
Fhcap::CLI::Cookbook.new.invoke(:update, [], {dirty: true, level: options['level']}) if options['update-cookbook']
|
32
32
|
|
33
33
|
end
|
34
34
|
|
@@ -67,11 +67,11 @@ module Fhcap
|
|
67
67
|
|
68
68
|
method_option 'format', :type => :string, :default => 'table', :desc => "Format to output data in", :enum => %w{table json}
|
69
69
|
|
70
|
-
def
|
70
|
+
def list_artifacts
|
71
71
|
require "fhcap/tasks/chef/cookbook/list_artifacts"
|
72
72
|
Tasks::Chef::Cookbook::ListArtifacts.new(task_options(options.dup)).run
|
73
73
|
end
|
74
74
|
|
75
75
|
end
|
76
76
|
end
|
77
|
-
end
|
77
|
+
end
|
data/lib/fhcap/config.rb
CHANGED
@@ -98,6 +98,18 @@ module Fhcap
|
|
98
98
|
}
|
99
99
|
end
|
100
100
|
|
101
|
+
def fhcap_empty_config
|
102
|
+
@fhcap_config ||= {
|
103
|
+
:repos_dir => File.join(default_dir, 'repos'),
|
104
|
+
:fh_src_dir => File.join(default_dir, 'repos'),
|
105
|
+
:repos => {
|
106
|
+
},
|
107
|
+
:knife_dir => File.join(default_dir, '.chef'),
|
108
|
+
:knife => {
|
109
|
+
}
|
110
|
+
}
|
111
|
+
end
|
112
|
+
|
101
113
|
private
|
102
114
|
|
103
115
|
def symbolize_keys_deep(h)
|
data/lib/fhcap/cookbook.rb
CHANGED
@@ -5,8 +5,11 @@ module Fhcap
|
|
5
5
|
module CLI
|
6
6
|
class Cookbook < Fhcap::ThorBase
|
7
7
|
|
8
|
+
include Fhcap::ReposHelper
|
9
|
+
|
8
10
|
add_shared_option :cookbooks, :aliases => "-c", :desc => "Apply to these Cookbooks", :type => :array
|
9
11
|
add_shared_option :modified, :aliases => "-m", :desc => "Apply only to modified Cookbooks", :type => :boolean, :required => false, :default => false
|
12
|
+
add_shared_option :dirty, :desc => "Apply only to cookbooks with uncommitted local changes", :type => :boolean, :required => false, :default => false
|
10
13
|
|
11
14
|
desc "update", "Update a cookbook, defaults to all cookbooks."
|
12
15
|
long_desc <<-LONGDESC
|
@@ -31,7 +34,7 @@ module Fhcap
|
|
31
34
|
fhcap cookbook update -c feedhenry_common -v 1.2.3
|
32
35
|
LONGDESC
|
33
36
|
|
34
|
-
shared_options :cookbooks, :modified
|
37
|
+
shared_options :cookbooks, :modified, :dirty
|
35
38
|
|
36
39
|
method_option 'level', :type => :string, :aliases => "-l", :desc => "Cookbook Bump level", :default => 'minor', :enum => %w{major minor patch}
|
37
40
|
method_option 'version', :type => :string, :aliases => "-v", :desc => "Version to set manually"
|
@@ -47,6 +50,26 @@ module Fhcap
|
|
47
50
|
end
|
48
51
|
end
|
49
52
|
|
53
|
+
desc "check_bumps", "Check modified cookbook versions are bumped as expected"
|
54
|
+
long_desc <<-LONGDESC
|
55
|
+
Checks that all modified cookbook versions are bumped as expected against the base-branch
|
56
|
+
|
57
|
+
With --base-branch <git ref>, checks for modified cookbooks since <git ref>, default is origin/master
|
58
|
+
|
59
|
+
Examples:
|
60
|
+
|
61
|
+
fhcap cookbook check-bumps
|
62
|
+
|
63
|
+
fhcap cookbook check-bumps --base-branch origin/FH-v3.18
|
64
|
+
LONGDESC
|
65
|
+
|
66
|
+
method_option 'base-branch', :type => :string, :default => 'origin/master', :desc => "Base branch to check modified cookbooks against"
|
67
|
+
|
68
|
+
def check_bumps
|
69
|
+
require "fhcap/tasks/chef/cookbook/check_bumps"
|
70
|
+
Tasks::Chef::Cookbook::CheckBumps.new(task_options(options.dup.merge({modified: true, base_branch: options['base-branch']}))).run
|
71
|
+
end
|
72
|
+
|
50
73
|
desc "update_metadata", "Update a cookbooks metadata, defaults to all cookbooks."
|
51
74
|
|
52
75
|
shared_options :cookbooks, :modified
|
@@ -80,6 +103,23 @@ module Fhcap
|
|
80
103
|
Tasks::Chef::Cookbook::Archive.new(task_options(options.dup)).run
|
81
104
|
end
|
82
105
|
|
106
|
+
desc "update_attribute", "update_attribute"
|
107
|
+
|
108
|
+
shared_options :cookbooks
|
109
|
+
method_option :'attribute', :type => :string, :desc => "Attribute"
|
110
|
+
method_option :'value', :type => :string, :desc => "Value"
|
111
|
+
method_option :'attribute-file', :type => :string, :desc => "Attribute File (artifacts.rb)"
|
112
|
+
|
113
|
+
def update_attribute
|
114
|
+
require "fhcap/tasks/chef/cookbook/update_attribute"
|
115
|
+
cookbooks = get_cookbooks(options, nil, repo_cookbook_paths('-cookbooks'))
|
116
|
+
say("Cookbook update_attribute for #{cookbooks}", :yellow)
|
117
|
+
|
118
|
+
cookbooks.each do |cookbook|
|
119
|
+
Tasks::Chef::Cookbook::UpdateAttribute.new(task_options(options.dup.merge({cookbook: cookbook}))).run
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
83
123
|
end
|
84
124
|
end
|
85
|
-
end
|
125
|
+
end
|
data/lib/fhcap/misc.rb
CHANGED
@@ -91,6 +91,13 @@ module Fhcap
|
|
91
91
|
end
|
92
92
|
end
|
93
93
|
|
94
|
+
desc "platform_bump VERSION", "Bumps RHMAP Platform Version"
|
95
|
+
|
96
|
+
def platform_bump(version)
|
97
|
+
require "fhcap/tasks/misc/platform_bump"
|
98
|
+
Tasks::Misc::PlatformBump.new(task_options(options.dup.merge({version: version}))).run
|
99
|
+
end
|
100
|
+
|
94
101
|
end
|
95
102
|
end
|
96
|
-
end
|
103
|
+
end
|
data/lib/fhcap/repo.rb
CHANGED
@@ -13,7 +13,7 @@ module Fhcap
|
|
13
13
|
|
14
14
|
shared_options :verbose, :name, :interactive
|
15
15
|
method_option 'url', :type => :string, :desc => "Repo url i.e. git@github.com:fheng/fhcap-dev.git"
|
16
|
-
method_option 'clusters-dir', :type => :string, :default => 'clusters', :desc => "
|
16
|
+
method_option 'clusters-dir', :type => :string, :default => 'clusters', :desc => "Directory in repo where cluster configs are stored i.e. organisations"
|
17
17
|
|
18
18
|
def add
|
19
19
|
require "fhcap/tasks/repo/add"
|
data/lib/fhcap/repos_helper.rb
CHANGED
@@ -125,6 +125,8 @@ module Fhcap
|
|
125
125
|
def get_cookbooks(options, default=nil, paths=repo_cookbook_paths)
|
126
126
|
if options[:modified]
|
127
127
|
get_modified_cookbooks(options, paths)
|
128
|
+
elsif options[:dirty]
|
129
|
+
get_dirty_cookbooks(options, paths)
|
128
130
|
else
|
129
131
|
options[:cookbooks] || (default || cookbook_loader(paths).cookbook_names)
|
130
132
|
end
|
@@ -139,6 +141,15 @@ module Fhcap
|
|
139
141
|
modified
|
140
142
|
end
|
141
143
|
|
144
|
+
def get_dirty_cookbooks(options, paths=repo_cookbook_paths)
|
145
|
+
dirty = []
|
146
|
+
cookbook_loader(paths).cookbook_names.each do |name|
|
147
|
+
cookbook_dir = cookbook_loader.cookbooks_by_name[name].root_dir
|
148
|
+
dirty << name if is_dirty?(cookbook_dir)
|
149
|
+
end
|
150
|
+
dirty
|
151
|
+
end
|
152
|
+
|
142
153
|
def get_cookbook_meta(name, paths=repo_cookbook_paths)
|
143
154
|
cookbook_loader(paths).metadata[name]
|
144
155
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'aws-sdk'
|
2
|
+
require 'fhcap/providers_helper'
|
3
|
+
|
4
|
+
module Fhcap
|
5
|
+
module S3Helper
|
6
|
+
|
7
|
+
include Fhcap::ProvidersHelper
|
8
|
+
|
9
|
+
def with_provider_client(provider_name, provider_region)
|
10
|
+
cfg = provider_config(provider_name)
|
11
|
+
region = provider_region || provider_regions(provider_name).keys.first
|
12
|
+
creds = cfg[:credentials]
|
13
|
+
client = Aws::S3::Resource.new(
|
14
|
+
region: region,
|
15
|
+
credentials: Aws::Credentials.new(creds[:'aws-access-key'], creds[:'aws-secret-key'])
|
16
|
+
)
|
17
|
+
yield client
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,109 @@
|
|
1
|
+
require 'fhcap/tasks/chef/chef_task_base'
|
2
|
+
|
3
|
+
module Fhcap
|
4
|
+
module Tasks
|
5
|
+
module Chef
|
6
|
+
module Cookbook
|
7
|
+
class CheckBumps < ChefTaskBase
|
8
|
+
|
9
|
+
attr_reader :base_branch
|
10
|
+
|
11
|
+
def initialize(options)
|
12
|
+
super
|
13
|
+
@base_branch = options[:base_branch]
|
14
|
+
end
|
15
|
+
|
16
|
+
def run
|
17
|
+
cookbooks = get_cookbooks(options, nil, repo_cookbook_paths('-cookbooks'))
|
18
|
+
thor.say("Cookbook Check Bumps for #{cookbooks}", :yellow)
|
19
|
+
|
20
|
+
errors = []
|
21
|
+
|
22
|
+
cookbooks.each do |c|
|
23
|
+
cookbook = cookbook_loader.cookbooks_by_name[c]
|
24
|
+
metadata_file = cookbook.metadata_filenames.first
|
25
|
+
|
26
|
+
if not File.exist?(metadata_file)
|
27
|
+
thor.say("#{cookbook.name} no longer seems to exist", :yellow)
|
28
|
+
next
|
29
|
+
elsif is_new_since?(base_branch, metadata_file)
|
30
|
+
thor.say("#{cookbook.name} seems to be a new cookbook, not checking", :yellow)
|
31
|
+
next
|
32
|
+
end
|
33
|
+
|
34
|
+
version = cookbook.version
|
35
|
+
oldversion = get_old_cookbook_version(base_branch, metadata_file, version)
|
36
|
+
|
37
|
+
if base_branch =~ /master$/
|
38
|
+
min = next_minor_version(oldversion)
|
39
|
+
if minor_bumped_incorrectly?(version, min)
|
40
|
+
errors << "#{cookbook.name} is at version #{version}, but should be at least #{min} and not be incremented at the patch level"
|
41
|
+
end
|
42
|
+
else
|
43
|
+
min = next_patch_version(oldversion)
|
44
|
+
too_high = next_minor_version(oldversion)
|
45
|
+
if patch_bumped_incorrectly?(version, min, too_high)
|
46
|
+
errors << "#{cookbook.name} is at version #{version}, but should be at least #{min} and less than #{too_high}"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
unless errors.empty?
|
52
|
+
thor.say("Incorrectly bumped cookbooks:", :red)
|
53
|
+
errors.each { |error|
|
54
|
+
puts error
|
55
|
+
}
|
56
|
+
thor.say("If you haven't changed these cookbooks, then your branch might be behind the base branch (#{base_branch}). In this case, rebasing should make these errors disappear.", :yellow)
|
57
|
+
exit 1
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
private
|
62
|
+
|
63
|
+
def get_old_cookbook_version(gitref, metadata_file, current_version)
|
64
|
+
Dir.chdir(File.dirname metadata_file) do
|
65
|
+
diff = `git diff #{gitref} -- #{File.basename metadata_file}`
|
66
|
+
oldver = diff.lines.select { |e| e.start_with?("-version") }[0]
|
67
|
+
if oldver
|
68
|
+
oldver.tr("-version '\n", "")
|
69
|
+
else
|
70
|
+
return current_version
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def next_minor_version(version)
|
76
|
+
segments = Gem::Version.new(version).segments
|
77
|
+
segments[1] = segments[1].succ
|
78
|
+
segments[2] = 0
|
79
|
+
segments.join '.'
|
80
|
+
end
|
81
|
+
|
82
|
+
def next_patch_version(version)
|
83
|
+
segments = Gem::Version.new(version).segments
|
84
|
+
segments[2] = segments[2].succ
|
85
|
+
segments.join '.'
|
86
|
+
end
|
87
|
+
|
88
|
+
def is_new_since?(gitref, file)
|
89
|
+
Dir.chdir(File.dirname file) do
|
90
|
+
diff = `git diff --stat --diff-filter=A #{gitref} -- #{File.basename file}`
|
91
|
+
not diff.empty?
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
def minor_bumped_incorrectly?(version, min)
|
96
|
+
Gem::Version.new(min) > Gem::Version.new(version) or
|
97
|
+
!version.end_with? '.0'
|
98
|
+
end
|
99
|
+
|
100
|
+
def patch_bumped_incorrectly?(version, min, too_high)
|
101
|
+
Gem::Version.new(min) > Gem::Version.new(version) or
|
102
|
+
Gem::Version.new(version) >= Gem::Version.new(too_high)
|
103
|
+
end
|
104
|
+
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
@@ -1,4 +1,6 @@
|
|
1
1
|
require 'fhcap/tasks/chef/chef_task_base'
|
2
|
+
require 'fhcap/tasks/chef/cookbook/aws/s3_helper'
|
3
|
+
require 'aws-sdk'
|
2
4
|
|
3
5
|
module Fhcap
|
4
6
|
module Tasks
|
@@ -6,6 +8,8 @@ module Fhcap
|
|
6
8
|
module Cookbook
|
7
9
|
class ListArtifacts < ChefTaskBase
|
8
10
|
|
11
|
+
include Fhcap::S3Helper
|
12
|
+
|
9
13
|
def initialize(options)
|
10
14
|
super(options)
|
11
15
|
@format = options[:format] || 'table'
|
@@ -13,29 +17,60 @@ module Fhcap
|
|
13
17
|
|
14
18
|
def run
|
15
19
|
if print_table?
|
16
|
-
thor.say "Chef::Cookbook::Component::
|
20
|
+
thor.say "Chef::Cookbook::Component::ListArtifacts", :yellow
|
17
21
|
end
|
22
|
+
|
23
|
+
results = print_table? ? [table_header("Component", "Version", "Build", "Artifact", "Available")] : []
|
24
|
+
|
25
|
+
artifact_meta = get_cookbook_meta(['fh-artifact'], 'artifacts')
|
26
|
+
artifact_s3_bucket = artifact_meta['artifact']['s3']['bucket']
|
27
|
+
# Provider must be fheng to have access to S3 artifact buckets
|
28
|
+
s3_provider_name = "aws:fheng"
|
29
|
+
s3_provider_region = "eu-west-1"
|
30
|
+
exit_status = 0
|
31
|
+
|
18
32
|
cookbooks = get_cookbooks(options, nil, repo_cookbook_paths('site-cookbooks'))
|
19
33
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
34
|
+
components_meta = get_cookbook_meta(cookbooks, 'artifact')
|
35
|
+
components_meta.each_attribute do |component_name, component_cfg|
|
36
|
+
component_version = component_cfg['version']
|
37
|
+
component_build = component_cfg['build']
|
38
|
+
component_artifact_filename = component_cfg['artifact_filename'] || "#{component_name}-%s-%s-ubuntu.x64.tar.gz"
|
39
|
+
component_artifact = component_artifact_filename % [component_version, component_build]
|
40
|
+
|
41
|
+
# Trying to handle naming inconsistencies between components and S3 directories
|
42
|
+
case component_name
|
43
|
+
when "unifiedpush", "unifiedpush-auth-server"
|
44
|
+
component_s3_dir = "aerogear-unifiedpush-server"
|
45
|
+
when "fh-metrics"
|
46
|
+
component_s3_dir = "fh-messaging"
|
47
|
+
when "fh-stats"
|
48
|
+
component_s3_dir = "fh-stats"
|
49
|
+
component_artifact = "fh-statsd-%s-%s-ubuntu.x64.tar.gz" % [component_version, component_build]
|
50
|
+
when "migrate"
|
51
|
+
component_s3_dir = "millicore"
|
52
|
+
else
|
53
|
+
component_s3_dir = component_name
|
54
|
+
end
|
55
|
+
|
56
|
+
# Checking that artifact exists
|
57
|
+
artifact_exists = check_artifact_exists(artifact_s3_bucket, s3_provider_name, s3_provider_region, component_s3_dir, component_build, component_artifact)
|
58
|
+
|
59
|
+
# If artifact not found return exit status error
|
60
|
+
unless artifact_exists
|
61
|
+
exit_status = 1
|
62
|
+
end
|
63
|
+
|
64
|
+
if print_table?
|
65
|
+
results << table_row(component_name, component_version, component_build, @component_s3_url, artifact_exists)
|
66
|
+
else
|
67
|
+
results << {component: component_name, version: component_version, build: component_build, artifact: @component_s3_url, available: artifact_exists}
|
35
68
|
end
|
69
|
+
|
36
70
|
end
|
37
71
|
thor.print_table results if print_table?
|
38
72
|
thor.say JSON.pretty_generate(results) if print_json?
|
73
|
+
exit exit_status
|
39
74
|
end
|
40
75
|
|
41
76
|
private
|
@@ -48,8 +83,29 @@ module Fhcap
|
|
48
83
|
@format == 'json'
|
49
84
|
end
|
50
85
|
|
86
|
+
def get_cookbook_meta(cookbooks, attribute_filename)
|
87
|
+
node = ::Chef::Node.new
|
88
|
+
cookbooks.each do |cookbook|
|
89
|
+
cookbook_data = cookbook_loader.cookbooks_by_name[cookbook]
|
90
|
+
cookbook_attribute_filepath = cookbook_data.attribute_filenames.find { |e| /#{attribute_filename}.rb/ =~ e }
|
91
|
+
if cookbook_attribute_filepath
|
92
|
+
node.from_file(cookbook_attribute_filepath)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
node
|
96
|
+
end
|
97
|
+
|
98
|
+
def check_artifact_exists(bucket_name, provider_name, provider_region, component_name, build, artifact_file)
|
99
|
+
with_provider_client(provider_name, provider_region) do |client|
|
100
|
+
bucket = client.bucket(bucket_name)
|
101
|
+
file = "#{component_name}/#{build}/#{artifact_file}"
|
102
|
+
@component_s3_url = bucket.object(file).public_url
|
103
|
+
bucket.object(file).exists?
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
51
107
|
end
|
52
108
|
end
|
53
109
|
end
|
54
110
|
end
|
55
|
-
end
|
111
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'fhcap/tasks/chef/chef_task_base'
|
2
|
+
|
3
|
+
module Fhcap
|
4
|
+
module Tasks
|
5
|
+
module Chef
|
6
|
+
module Cookbook
|
7
|
+
class UpdateAttribute < ChefTaskBase
|
8
|
+
|
9
|
+
attr_reader :name, :cookbook, :attribute, :value, :attribute_file
|
10
|
+
|
11
|
+
def initialize(options)
|
12
|
+
super
|
13
|
+
@cookbook = options[:cookbook]
|
14
|
+
@attribute = options[:attribute]
|
15
|
+
@value = options[:value]
|
16
|
+
@attribute_file = options[:'attribute-file'] || 'default.rb'
|
17
|
+
end
|
18
|
+
|
19
|
+
def run
|
20
|
+
thor.say "Chef::Cookbook::UpdateAttribute cookbook = #{cookbook}, attribute = #{attribute}, value = #{value}", :yellow
|
21
|
+
c = cookbook_loader.cookbooks_by_name[cookbook]
|
22
|
+
unless c
|
23
|
+
exit_with_error("Failed to load cookbook \"#{cookbook}\"!")
|
24
|
+
end
|
25
|
+
|
26
|
+
artifact_attribute_filepath = c.attribute_filenames.find { |e| /#{attribute_file}/ =~ e }
|
27
|
+
|
28
|
+
if artifact_attribute_filepath
|
29
|
+
text = File.read(artifact_attribute_filepath)
|
30
|
+
|
31
|
+
attr = "default"
|
32
|
+
attr_regexp = "default"
|
33
|
+
attribute.to_s.split('.').each do |part|
|
34
|
+
attr = attr + "['#{part}']"
|
35
|
+
attr_regexp = attr_regexp + "\\['#{part}'\\]"
|
36
|
+
end
|
37
|
+
|
38
|
+
replace = text.gsub(/#{attr_regexp} = .+$/, "#{attr} = '#{value}'")
|
39
|
+
|
40
|
+
thor.create_file(artifact_attribute_filepath, replace, {force: !options[:interactive]})
|
41
|
+
else
|
42
|
+
thor.say_status("error", "No attribute file #{attribute_file} found in #{cookbook}", :red)
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -14,6 +14,7 @@ module Fhcap
|
|
14
14
|
@type = options[:type]
|
15
15
|
@repo = options[:repo]
|
16
16
|
@passwords = {}
|
17
|
+
@efs_enabled = options[:efs_enabled]
|
17
18
|
end
|
18
19
|
|
19
20
|
def run
|
@@ -21,7 +22,8 @@ module Fhcap
|
|
21
22
|
env_config = {
|
22
23
|
name: @name,
|
23
24
|
domain: @domain,
|
24
|
-
skip: true
|
25
|
+
skip: true,
|
26
|
+
efs_enabled: @efs_enabled
|
25
27
|
}
|
26
28
|
create_environment(env_config)
|
27
29
|
create_data_bag(env_config)
|
@@ -40,7 +40,8 @@ module Fhcap
|
|
40
40
|
name: "#{name}-#{environment_name}",
|
41
41
|
domain: domain,
|
42
42
|
type: get_env_type(environment_name),
|
43
|
-
repo: cluster_config[:repo]
|
43
|
+
repo: cluster_config[:repo],
|
44
|
+
efs_enabled: cluster_config[:provider_config][:efs_enabled]
|
44
45
|
}
|
45
46
|
generate_environment_config
|
46
47
|
create_chef_environment(env_cfg)
|
@@ -160,8 +161,8 @@ module Fhcap
|
|
160
161
|
'mbaas'
|
161
162
|
when /ose-single/
|
162
163
|
'ose-single'
|
163
|
-
when /
|
164
|
-
'
|
164
|
+
when /ocp/
|
165
|
+
'ocp'
|
165
166
|
when /single/
|
166
167
|
'single'
|
167
168
|
when /farm/
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'fhcap/tasks/task_base'
|
2
|
+
|
3
|
+
module Fhcap
|
4
|
+
module Tasks
|
5
|
+
module Misc
|
6
|
+
class PlatformBump < TaskBase
|
7
|
+
|
8
|
+
attr_reader :version
|
9
|
+
|
10
|
+
def initialize(options)
|
11
|
+
super
|
12
|
+
@version = options[:version]
|
13
|
+
end
|
14
|
+
|
15
|
+
def run
|
16
|
+
thor.say "Misc::PlatformBump version = #{version}", :yellow
|
17
|
+
c = cookbook_loader.cookbooks_by_name['feedhenry_common']
|
18
|
+
unless c
|
19
|
+
exit_with_error("Failed to load cookbook \"#{cookbook}\"!")
|
20
|
+
end
|
21
|
+
|
22
|
+
artifact_attribute_filepath = c.attribute_filenames.find { |e| /platform_info.rb/ =~ e }
|
23
|
+
|
24
|
+
if artifact_attribute_filepath
|
25
|
+
text = File.read(artifact_attribute_filepath)
|
26
|
+
replace = text.gsub(/default\['feedhenry_common'\]\['platform_info'\]\['version'\] = .+$/, "default['feedhenry_common']['platform_info']['version'] = '#{version}'")
|
27
|
+
thor.create_file(artifact_attribute_filepath, replace, {force: !options[:interactive]})
|
28
|
+
else
|
29
|
+
thor.say_status("error", "No artifact file found in feedhenry_common", :red)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/lib/fhcap/tasks/repo/add.rb
CHANGED
@@ -14,10 +14,8 @@ module Fhcap
|
|
14
14
|
@name = options[:name]
|
15
15
|
|
16
16
|
@repo_config = config[:repos][@name.to_sym] || {}
|
17
|
-
@repo_config =
|
18
|
-
|
19
|
-
clusters_dir: options[:'clusters-dir'] || 'clusters',
|
20
|
-
}.merge(@repo_config)
|
17
|
+
@repo_config[:url] = options[:url] if options[:url]
|
18
|
+
@repo_config[:clusters_dir] = options[:'clusters-dir'] if options[:'clusters-dir']
|
21
19
|
|
22
20
|
@skip_setup = options[:'skip-setup']
|
23
21
|
end
|
@@ -36,7 +34,7 @@ module Fhcap
|
|
36
34
|
config[:repos][name.to_sym] = repo_config
|
37
35
|
thor.create_file(config.config_file, JSON.pretty_generate(config.data), :force => true)
|
38
36
|
config.reload
|
39
|
-
Checkout.new(@options.dup.merge({:repo => name
|
37
|
+
Checkout.new(@options.dup.merge({:repo => name})).run
|
40
38
|
Tasks::Setup.new(@options).run unless @skip_setup
|
41
39
|
end
|
42
40
|
|
@@ -54,4 +52,4 @@ module Fhcap
|
|
54
52
|
end
|
55
53
|
end
|
56
54
|
end
|
57
|
-
end
|
55
|
+
end
|