hybrid_platforms_conductor 33.3.0 → 33.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (30) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +6 -0
  3. data/README.md +31 -2
  4. data/docs/config_dsl.md +43 -0
  5. data/lib/hybrid_platforms_conductor/bitbucket.rb +134 -90
  6. data/lib/hybrid_platforms_conductor/common_config_dsl/bitbucket.rb +12 -44
  7. data/lib/hybrid_platforms_conductor/common_config_dsl/github.rb +9 -31
  8. data/lib/hybrid_platforms_conductor/confluence.rb +93 -88
  9. data/lib/hybrid_platforms_conductor/credentials.rb +112 -95
  10. data/lib/hybrid_platforms_conductor/deployer.rb +2 -2
  11. data/lib/hybrid_platforms_conductor/github.rb +39 -0
  12. data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/proxmox.rb +4 -2
  13. data/lib/hybrid_platforms_conductor/hpc_plugins/report/confluence.rb +3 -1
  14. data/lib/hybrid_platforms_conductor/hpc_plugins/secrets_reader/keepass.rb +2 -1
  15. data/lib/hybrid_platforms_conductor/hpc_plugins/secrets_reader/thycotic.rb +3 -1
  16. data/lib/hybrid_platforms_conductor/hpc_plugins/test/bitbucket_conf.rb +4 -1
  17. data/lib/hybrid_platforms_conductor/hpc_plugins/test/github_ci.rb +4 -1
  18. data/lib/hybrid_platforms_conductor/hpc_plugins/test/jenkins_ci_conf.rb +6 -2
  19. data/lib/hybrid_platforms_conductor/hpc_plugins/test/jenkins_ci_masters_ok.rb +6 -2
  20. data/lib/hybrid_platforms_conductor/hpc_plugins/test_report/confluence.rb +3 -1
  21. data/lib/hybrid_platforms_conductor/logger_helpers.rb +7 -1
  22. data/lib/hybrid_platforms_conductor/thycotic.rb +80 -75
  23. data/lib/hybrid_platforms_conductor/version.rb +1 -1
  24. data/spec/hybrid_platforms_conductor_test.rb +6 -0
  25. data/spec/hybrid_platforms_conductor_test/api/credentials_spec.rb +247 -0
  26. data/spec/hybrid_platforms_conductor_test/api/deployer/secrets_reader_plugins/keepass_spec.rb +280 -319
  27. data/spec/hybrid_platforms_conductor_test/api/deployer/secrets_reader_plugins/thycotic_spec.rb +2 -2
  28. data/spec/hybrid_platforms_conductor_test/api/tests_runner/test_plugins/bitbucket_conf_spec.rb +49 -69
  29. data/spec/hybrid_platforms_conductor_test/api/tests_runner/test_plugins/github_ci_spec.rb +29 -39
  30. metadata +18 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c0707386d30d5e671d5ceac5e1fec9d971cdccd2b7057c6ed3a75cb5d8bb6d85
4
- data.tar.gz: e9e5c023662e7aa9283905f4ae54f4b8995d14f61bea1d844ef4fef32cba68dc
3
+ metadata.gz: f5f1fa4755dba3c7830397e4b43204517131487eaa5942bd0492f64bb835def5
4
+ data.tar.gz: 3d6d5de92054abbcfebc902f523466ba79167da40e33c25defc413ed28d2cc28
5
5
  SHA512:
6
- metadata.gz: 1b70dedf6605d48081ead37771b8f94e29d26334fb1c0f7f15ed8ed70cabc24809b145bd681af9e829cd0c968accd18cf87886987391709a7252908a00104096
7
- data.tar.gz: cbe9033432aae4b83b4153501efad2330651696ba0fc8b487d21f5927430d481661e5d3bf2c3617ffb20c2ba7e254f82328d4225aeba4f98295873c55fe4cca9
6
+ metadata.gz: 944569bc9c74fbbbeff909f6d73ae3c2f8064cb3c6853c4f29c74e1a3e906d446f7db4600b3c66d64bc8642bdd173a694dc337fa78a411cb9da30107e14c7643
7
+ data.tar.gz: 13acf6ece0db85b0a92caf752aa56b6510f3cfa3f82091c38f0cbd9dc0048056c9f6e9995e5db4dd97141fe0a1bea7e7db75db954b8f114c25acaadf11a7c228
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ # [v33.4.0](https://github.com/sweet-delights/hybrid-platforms-conductor/compare/v33.3.0...v33.4.0) (2021-07-05 13:24:27)
2
+
3
+ ### Features
4
+
5
+ * [[Feature] [#83] Credentials can now be given through config DSL for better security and control](https://github.com/sweet-delights/hybrid-platforms-conductor/commit/9dd40e82b4c71bea9686abd828adb4359f5bebb2)
6
+
1
7
  # [v33.3.0](https://github.com/sweet-delights/hybrid-platforms-conductor/compare/v33.2.4...v33.3.0) (2021-07-02 17:20:58)
2
8
 
3
9
  ## Global changes
data/README.md CHANGED
@@ -304,12 +304,41 @@ See [the executables list](docs/executables.md) for more details.
304
304
  # Credentials
305
305
 
306
306
  Some tools or tests require authentication using user/password to an external resource. Examples of such tools are Bitbucket, Thycotic, Confluence...
307
- Credentials can be given using either environment variables or by parsing the user's `.netrc` file.
307
+ Credentials can be given 3 different ways:
308
+ * from the configuration file `hpc_config.rb`,
309
+ * from environment variables,
310
+ * from the user's `.netrc` file.
308
311
 
309
- In case a process needs a credential that has not been set, a warning message will be output so that the user knows which credential is missing, and eventually for which URL.
312
+ In case a process needs a credential that has not been set, a warning message will be output so that the user knows which credential is missing, and eventually for which resource (URL, file...).
310
313
 
311
314
  Following sub-sections explain the different ways of setting such credentials.
312
315
 
316
+ ## Configuration
317
+
318
+ The [`credentials_for` config DSL method](docs/config_dsl.md#credentials_for) can be used to define the credentials for a given credential ID and eventual resource.
319
+ The way to do it is to provide a callback that will be called only when a credential is needed, and the credentials are given to a requester object. This way the life-cycle of the secret can be completely controlled, and clean-up can be done to ensure no vulnerabilities are staying after usage.
320
+
321
+ Example:
322
+ ```ruby
323
+ # Simple case
324
+ credentials_for(:bitbucket) do |resource, requester|
325
+ requester.call 'my_bitbucket_name', 'my_bitbucket_PaSsWoRd'
326
+ end
327
+
328
+ # More secure case, handling user input and memory clean-up after usage
329
+ credentials_for(:bitbucket) do |resource, requester|
330
+ puts 'Input Bitbucket password...'
331
+ password = ''
332
+ $stdin.noecho { |io| io.sysread(256, password) }
333
+ begin
334
+ password.chomp!
335
+ requester.call 'my_bitbucket_name', password
336
+ ensure
337
+ SecretString.erase(password)
338
+ end
339
+ end
340
+ ```
341
+
313
342
  ## Environment variables
314
343
 
315
344
  Environment variables used for credentials are always named following this convention: `hpc_user_for_<credential_id>` and `hpc_password_for_<credential_id>`.
data/docs/config_dsl.md CHANGED
@@ -13,6 +13,7 @@ This DSL can also be completed by plugins. Check [the plugins documentations](pl
13
13
  * [`hybrid_platforms_dir`](#hybrid_platforms_dir)
14
14
  * [`tests_provisioner`](#tests_provisioner)
15
15
  * [`expect_tests_to_fail`](#expect_tests_to_fail)
16
+ * [`credentials_for`](#credentials_for)
16
17
  * [`read_secrets_from`](#read_secrets_from)
17
18
  * [`send_logs_to`](#send_logs_to)
18
19
  * [`retry_deploy_for_errors_on_stdout`](#retry_deploy_for_errors_on_stdout)
@@ -202,6 +203,48 @@ for_nodes('/tst/') do
202
203
  end
203
204
  ```
204
205
 
206
+ <a name="credentials_for"></a>
207
+ ## `credentials_for`
208
+
209
+ Set the credentials to be used (user, password) for a given credential ID and an optional resources selection.
210
+
211
+ Credentials can be used by any plugin (using the [`with_credentials_for`](/lib/hybrid_platforms_conductor/credentials.rb) method) and are used by various processes in Hybrid Platforms Conductor. See each [plugin's documentation](plugins.md) to know which plugin uses which credential.
212
+
213
+ It takes the following parameters:
214
+ * the credential ID (as a Symbol),
215
+ * an optional resource specification (can be a String for a complete resource name, or a Regexp matching resources' names),
216
+ * a code block that will be called back by any process needing credentials matching the ID and resource specification.
217
+ The code block will be given both the resource name being accessed, and a requester object that needs to be given the corresponding user and password. When the requester finishes running, the credentials are not needed anymore and should be cleaned from memory to avoid vulnerabilities.
218
+
219
+ Examples:
220
+ ```ruby
221
+ # Using an environment variable as a password
222
+ credentials_for(:github) do |resource, requester|
223
+ requester.call 'MyUserName', ENV['MY_GITHUB_PASSWORD']
224
+ end
225
+
226
+ # Using user input and cleaning memory
227
+ credentials_for(:github) do |resource, requester|
228
+ puts 'Input Github password...'
229
+ password = ''
230
+ $stdin.noecho { |io| io.sysread(256, password) }
231
+ begin
232
+ password.chomp!
233
+ requester.call 'MyUserName', password
234
+ ensure
235
+ SecretString.erase(password)
236
+ end
237
+ end
238
+
239
+ # Defining different credentials based on the resource being accessed
240
+ credentials_for(:github, resource: %r{github.com/my-projects}) do |resource, requester|
241
+ requester.call 'MyUserName', 'MyPassword'
242
+ end
243
+ credentials_for(:github, resource: %r{github.com/company}) do |resource, requester|
244
+ requester.call 'CompanyUserName', 'CompanyPassword'
245
+ end
246
+ ```
247
+
205
248
  <a name="read_secrets_from"></a>
206
249
  ## `read_secrets_from`
207
250
 
@@ -7,116 +7,160 @@ require 'hybrid_platforms_conductor/logger_helpers'
7
7
 
8
8
  module HybridPlatformsConductor
9
9
 
10
- # Object used to access Bitbucket API
11
- class Bitbucket
10
+ # Mixin used to access Bitbucket API
11
+ module Bitbucket
12
12
 
13
- include LoggerHelpers
13
+ include Credentials
14
14
 
15
15
  # Provide a Bitbucket connector, and make sure the password is being cleaned when exiting.
16
16
  #
17
17
  # Parameters::
18
18
  # * *bitbucket_url* (String): The Bitbucket URL
19
- # * *logger* (Logger): Logger to be used
20
- # * *logger_stderr* (Logger): Logger to be used for stderr
21
19
  # * Proc: Code called with the Bitbucket instance.
22
- # * *bitbucket* (Bitbucket): The Bitbucket instance to use.
23
- def self.with_bitbucket(bitbucket_url, logger, logger_stderr)
24
- Credentials.with_credentials_for(:bitbucket, logger, logger_stderr, url: bitbucket_url) do |bitbucket_user, bitbucket_password|
25
- yield Bitbucket.new(bitbucket_url, bitbucket_user, bitbucket_password, logger: logger, logger_stderr: logger_stderr)
20
+ # * *bitbucket* (BitbucketApi): The Bitbucket instance to use.
21
+ def with_bitbucket(bitbucket_url)
22
+ with_credentials_for(:bitbucket, resource: bitbucket_url) do |bitbucket_user, bitbucket_password|
23
+ yield BitbucketApi.new(bitbucket_url, bitbucket_user, bitbucket_password, logger: @logger, logger_stderr: @logger_stderr)
26
24
  end
27
25
  end
28
26
 
29
- # The Bitbucket URL
30
- # String
31
- attr_reader :bitbucket_url
32
-
33
- # Constructor
27
+ # Iterate over each Bitbucket repository
34
28
  #
35
29
  # Parameters::
36
- # * *bitbucket_url* (String): The Bitbucket URL
37
- # * *bitbucket_user_name* (String): Bitbucket user name to be used when querying the API
38
- # * *bitbucket_password* (String): Bitbucket password to be used when querying the API
39
- # * *logger* (Logger): Logger to be used [default = Logger.new(STDOUT)]
40
- # * *logger_stderr* (Logger): Logger to be used for stderr [default = Logger.new(STDERR)]
41
- def initialize(bitbucket_url, bitbucket_user_name, bitbucket_password, logger: Logger.new($stdout), logger_stderr: Logger.new($stderr))
42
- init_loggers(logger, logger_stderr)
43
- @bitbucket_url = bitbucket_url
44
- @bitbucket_user_name = bitbucket_user_name
45
- @bitbucket_password = bitbucket_password
30
+ # * Proc: Code called for each Bitbucket repository:
31
+ # * Parameters::
32
+ # * *bitbucket* (Bitbucket): The Bitbucket instance used to query the API for this repository
33
+ # * *repo_info* (Hash<Symbol, Object>): The repository info:
34
+ # * *name* (String): Repository name.
35
+ # * *project* (String): Project name.
36
+ # * *url* (String): Project Git URL.
37
+ # * *jenkins_ci_url* (String or nil): Corresponding Jenkins CI URL, or nil if none.
38
+ # * *checks* (Hash<Symbol, Object>): Checks to be performed on this repository:
39
+ # * *branch_permissions* (Array< Hash<Symbol, Object> >): List of branch permissions to check [optional]
40
+ # * *type* (String): Type of branch permissions to check. Examples of values are 'fast-forward-only', 'no-deletes', 'pull-request-only'.
41
+ # * *branch* (String): Branch on which those permissions apply.
42
+ # * *exempted_users* (Array<String>): List of exempted users for this permission [default: []]
43
+ # * *exempted_groups* (Array<String>): List of exempted groups for this permission [default: []]
44
+ # * *exempted_keys* (Array<String>): List of exempted access keys for this permission [default: []]
45
+ # * *pr_settings* (Hash<Symbol, Object>): PR specific settings to check [optional]
46
+ # * *required_approvers* (Integer): Number of required approvers [optional]
47
+ # * *required_builds* (Integer): Number of required successful builds [optional]
48
+ # * *default_merge_strategy* (String): Name of the default merge strategy. Example: 'rebase-no-ff' [optional]
49
+ # * *mandatory_default_reviewers* (Array<String>): List of mandatory reviewers to check [default: []]
50
+ def for_each_bitbucket_repo
51
+ @config.known_bitbucket_repos.each do |bitbucket_repo_info|
52
+ with_bitbucket(bitbucket_repo_info[:url]) do |bitbucket|
53
+ (bitbucket_repo_info[:repos] == :all ? bitbucket.repos(bitbucket_repo_info[:project])['values'].map { |repo_info| repo_info['slug'] } : bitbucket_repo_info[:repos]).each do |name|
54
+ yield bitbucket, {
55
+ name: name,
56
+ project: bitbucket_repo_info[:project],
57
+ url: "#{bitbucket_repo_info[:url]}/scm/#{bitbucket_repo_info[:project].downcase}/#{name}.git",
58
+ jenkins_ci_url: bitbucket_repo_info[:jenkins_ci_url].nil? ? nil : "#{bitbucket_repo_info[:jenkins_ci_url]}/job/#{name}",
59
+ checks: bitbucket_repo_info[:checks]
60
+ }
61
+ end
62
+ end
63
+ end
46
64
  end
47
65
 
48
- # Get the repositories of a given project.
49
- # Limit to 1000 results max.
50
- #
51
- # Parameters::
52
- # * *project* (String): Project name
53
- # Result::
54
- # * Object: Corresponding JSON
55
- def repos(project)
56
- get_api("projects/#{project}/repos?limit=1000")
57
- end
66
+ # Provide an API to Bitbucket
67
+ class BitbucketApi
58
68
 
59
- # Get the PR settings of a given repository
60
- #
61
- # Parameters::
62
- # * *project* (String): Project name
63
- # * *repo* (String): Repository name
64
- # Result::
65
- # * Object: Corresponding JSON
66
- def settings_pr(project, repo)
67
- get_api("projects/#{project}/repos/#{repo}/settings/pull-requests")
68
- end
69
+ include LoggerHelpers
69
70
 
70
- # Get the default reviewers of a given repository
71
- #
72
- # Parameters::
73
- # * *project* (String): Project name
74
- # * *repo* (String): Repository name
75
- # Result::
76
- # * Object: Corresponding JSON
77
- def default_reviewers(project, repo)
78
- get_api("projects/#{project}/repos/#{repo}/conditions", api_domain: 'default-reviewers')
79
- end
71
+ # The Bitbucket URL
72
+ # String
73
+ attr_reader :bitbucket_url
80
74
 
81
- # Get the branch permissions of a given repository
82
- #
83
- # Parameters::
84
- # * *project* (String): Project name
85
- # * *repo* (String): Repository name
86
- # Result::
87
- # * Object: Corresponding JSON
88
- def branch_permissions(project, repo)
89
- # Put 3 retries here as the Bitbucket installation has a very unstable API 2.0 and often returns random 401 errors.
90
- get_api("projects/#{project}/repos/#{repo}/restrictions", api_domain: 'branch-permissions', api_version: '2.0', retries: 3)
91
- end
75
+ # Constructor
76
+ #
77
+ # Parameters::
78
+ # * *bitbucket_url* (String): The Bitbucket URL
79
+ # * *bitbucket_user_name* (String): Bitbucket user name to be used when querying the API
80
+ # * *bitbucket_password* (String): Bitbucket password to be used when querying the API
81
+ # * *logger* (Logger): Logger to be used [default = Logger.new(STDOUT)]
82
+ # * *logger_stderr* (Logger): Logger to be used for stderr [default = Logger.new(STDERR)]
83
+ def initialize(bitbucket_url, bitbucket_user_name, bitbucket_password, logger: Logger.new($stdout), logger_stderr: Logger.new($stderr))
84
+ init_loggers(logger, logger_stderr)
85
+ @bitbucket_url = bitbucket_url
86
+ @bitbucket_user_name = bitbucket_user_name
87
+ @bitbucket_password = bitbucket_password
88
+ end
92
89
 
93
- # Issue an HTTP get on the API.
94
- # Handle authentication.
95
- #
96
- # Parameters::
97
- # * *path* (String): API path to access
98
- # * *api_domain* (String): API domain to access [default: 'api']
99
- # * *api_version* (String): API version to access [default: '1.0']
100
- # * *retries* (Integer): Number of retries in case of failures [default: 0]
101
- # Result::
102
- # * Object: Returned JSON
103
- def get_api(path, api_domain: 'api', api_version: '1.0', retries: 0)
104
- api_url = "#{@bitbucket_url}/rest/#{api_domain}/#{api_version}/#{path}"
105
- log_debug "Call Bitbucket API #{@bitbucket_user_name}@#{api_url}..."
106
- http_response = nil
107
- loop do
108
- begin
109
- http_response = URI.parse(api_url).open(http_basic_authentication: [@bitbucket_user_name, @bitbucket_password])
110
- rescue
111
- raise if retries.zero?
112
-
113
- log_warn "Got error #{$ERROR_INFO} on #{@bitbucket_user_name}@#{api_url}. Will retry #{retries} times..."
114
- retries -= 1
115
- sleep 1
90
+ # Get the repositories of a given project.
91
+ # Limit to 1000 results max.
92
+ #
93
+ # Parameters::
94
+ # * *project* (String): Project name
95
+ # Result::
96
+ # * Object: Corresponding JSON
97
+ def repos(project)
98
+ get_api("projects/#{project}/repos?limit=1000")
99
+ end
100
+
101
+ # Get the PR settings of a given repository
102
+ #
103
+ # Parameters::
104
+ # * *project* (String): Project name
105
+ # * *repo* (String): Repository name
106
+ # Result::
107
+ # * Object: Corresponding JSON
108
+ def settings_pr(project, repo)
109
+ get_api("projects/#{project}/repos/#{repo}/settings/pull-requests")
110
+ end
111
+
112
+ # Get the default reviewers of a given repository
113
+ #
114
+ # Parameters::
115
+ # * *project* (String): Project name
116
+ # * *repo* (String): Repository name
117
+ # Result::
118
+ # * Object: Corresponding JSON
119
+ def default_reviewers(project, repo)
120
+ get_api("projects/#{project}/repos/#{repo}/conditions", api_domain: 'default-reviewers')
121
+ end
122
+
123
+ # Get the branch permissions of a given repository
124
+ #
125
+ # Parameters::
126
+ # * *project* (String): Project name
127
+ # * *repo* (String): Repository name
128
+ # Result::
129
+ # * Object: Corresponding JSON
130
+ def branch_permissions(project, repo)
131
+ # Put 3 retries here as the Bitbucket installation has a very unstable API 2.0 and often returns random 401 errors.
132
+ get_api("projects/#{project}/repos/#{repo}/restrictions", api_domain: 'branch-permissions', api_version: '2.0', retries: 3)
133
+ end
134
+
135
+ # Issue an HTTP get on the API.
136
+ # Handle authentication.
137
+ #
138
+ # Parameters::
139
+ # * *path* (String): API path to access
140
+ # * *api_domain* (String): API domain to access [default: 'api']
141
+ # * *api_version* (String): API version to access [default: '1.0']
142
+ # * *retries* (Integer): Number of retries in case of failures [default: 0]
143
+ # Result::
144
+ # * Object: Returned JSON
145
+ def get_api(path, api_domain: 'api', api_version: '1.0', retries: 0)
146
+ api_url = "#{@bitbucket_url}/rest/#{api_domain}/#{api_version}/#{path}"
147
+ log_debug "Call Bitbucket API #{@bitbucket_user_name}@#{api_url}..."
148
+ http_response = nil
149
+ loop do
150
+ begin
151
+ http_response = URI.parse(api_url).open(http_basic_authentication: [@bitbucket_user_name, @bitbucket_password])
152
+ rescue
153
+ raise if retries.zero?
154
+
155
+ log_warn "Got error #{$ERROR_INFO} on #{@bitbucket_user_name}@#{api_url}. Will retry #{retries} times..."
156
+ retries -= 1
157
+ sleep 1
158
+ end
159
+ break unless http_response.nil?
116
160
  end
117
- break unless http_response.nil?
161
+ JSON.parse(http_response.read)
118
162
  end
119
- JSON.parse(http_response.read)
163
+
120
164
  end
121
165
 
122
166
  end
@@ -1,5 +1,3 @@
1
- require 'hybrid_platforms_conductor/bitbucket'
2
-
3
1
  module HybridPlatformsConductor
4
2
 
5
3
  module CommonConfigDsl
@@ -7,12 +5,21 @@ module HybridPlatformsConductor
7
5
  # Add common Bitbucket config DSL to declare known Bitbucket repositories
8
6
  module Bitbucket
9
7
 
8
+ # List of known Bitbucket repos
9
+ # Array< Hash<Symbol, Object> >
10
+ # * *url* (String): URL to the Bitbucket server
11
+ # * *project* (String): Project name from the Bitbucket server, storing repositories
12
+ # * *repos* (Array<String> or Symbol): List of repository names from this project, or :all for all
13
+ # * *jenkins_ci_url* (String or nil): Corresponding Jenkins CI URL, or nil if none
14
+ # * *checks* (Hash<Symbol, Object>): Checks definition to be perform on those repositories (see the #for_each_bitbucket_repo to know the structure)
15
+ attr_reader :known_bitbucket_repos
16
+
10
17
  # Initialize the DSL
11
18
  def init_bitbucket
12
19
  # List of Bitbucket repositories definitions
13
20
  # Array< Hash<Symbol, Object> >
14
- # Each definition is just mapping the signature of #bitbucket_repos
15
- @bitbucket_repos = []
21
+ # Each definition is just mapping the signature of #known_bitbucket_repos
22
+ @known_bitbucket_repos = []
16
23
  end
17
24
 
18
25
  # Register new Bitbucket repositories
@@ -24,7 +31,7 @@ module HybridPlatformsConductor
24
31
  # * *jenkins_ci_url* (String or nil): Corresponding Jenkins CI URL, or nil if none [default: nil]
25
32
  # * *checks* (Hash<Symbol, Object>): Checks definition to be perform on those repositories (see the #for_each_bitbucket_repo to know the structure) [default: {}]
26
33
  def bitbucket_repos(url:, project:, repos: :all, jenkins_ci_url: nil, checks: {})
27
- @bitbucket_repos << {
34
+ @known_bitbucket_repos << {
28
35
  url: url,
29
36
  project: project,
30
37
  repos: repos,
@@ -33,45 +40,6 @@ module HybridPlatformsConductor
33
40
  }
34
41
  end
35
42
 
36
- # Iterate over each Bitbucket repository
37
- #
38
- # Parameters::
39
- # * Proc: Code called for each Bitbucket repository:
40
- # * Parameters::
41
- # * *bitbucket* (Bitbucket): The Bitbucket instance used to query the API for this repository
42
- # * *repo_info* (Hash<Symbol, Object>): The repository info:
43
- # * *name* (String): Repository name.
44
- # * *project* (String): Project name.
45
- # * *url* (String): Project Git URL.
46
- # * *jenkins_ci_url* (String or nil): Corresponding Jenkins CI URL, or nil if none.
47
- # * *checks* (Hash<Symbol, Object>): Checks to be performed on this repository:
48
- # * *branch_permissions* (Array< Hash<Symbol, Object> >): List of branch permissions to check [optional]
49
- # * *type* (String): Type of branch permissions to check. Examples of values are 'fast-forward-only', 'no-deletes', 'pull-request-only'.
50
- # * *branch* (String): Branch on which those permissions apply.
51
- # * *exempted_users* (Array<String>): List of exempted users for this permission [default: []]
52
- # * *exempted_groups* (Array<String>): List of exempted groups for this permission [default: []]
53
- # * *exempted_keys* (Array<String>): List of exempted access keys for this permission [default: []]
54
- # * *pr_settings* (Hash<Symbol, Object>): PR specific settings to check [optional]
55
- # * *required_approvers* (Integer): Number of required approvers [optional]
56
- # * *required_builds* (Integer): Number of required successful builds [optional]
57
- # * *default_merge_strategy* (String): Name of the default merge strategy. Example: 'rebase-no-ff' [optional]
58
- # * *mandatory_default_reviewers* (Array<String>): List of mandatory reviewers to check [default: []]
59
- def for_each_bitbucket_repo
60
- @bitbucket_repos.each do |bitbucket_repo_info|
61
- HybridPlatformsConductor::Bitbucket.with_bitbucket(bitbucket_repo_info[:url], @logger, @logger_stderr) do |bitbucket|
62
- (bitbucket_repo_info[:repos] == :all ? bitbucket.repos(bitbucket_repo_info[:project])['values'].map { |repo_info| repo_info['slug'] } : bitbucket_repo_info[:repos]).each do |name|
63
- yield bitbucket, {
64
- name: name,
65
- project: bitbucket_repo_info[:project],
66
- url: "#{bitbucket_repo_info[:url]}/scm/#{bitbucket_repo_info[:project].downcase}/#{name}.git",
67
- jenkins_ci_url: bitbucket_repo_info[:jenkins_ci_url].nil? ? nil : "#{bitbucket_repo_info[:jenkins_ci_url]}/job/#{name}",
68
- checks: bitbucket_repo_info[:checks]
69
- }
70
- end
71
- end
72
- end
73
- end
74
-
75
43
  end
76
44
 
77
45
  end