gitlab_support_readiness 1.0.41 → 1.0.42
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/support_readiness/mailgun/client.rb +2 -1
- data/lib/support_readiness/mailgun/emails.rb +1 -1
- data/lib/support_readiness/support_super_form_processor/create_article.rb +375 -0
- data/lib/support_readiness/support_super_form_processor/create_macro.rb +183 -0
- data/lib/support_readiness/support_super_form_processor/edit_macro.rb +161 -0
- data/lib/support_readiness/support_super_form_processor/enable_us_government.rb +236 -0
- data/lib/support_readiness/support_super_form_processor/global_ir_dotcom_subscriptions_billing_entity_change.rb +218 -0
- data/lib/support_readiness/support_super_form_processor/global_ir_dotcom_subscriptions_extension.rb +238 -0
- data/lib/support_readiness/support_super_form_processor/global_ir_dotcom_subscriptions_investigate.rb +238 -0
- data/lib/support_readiness/support_super_form_processor/global_ir_dotcom_subscriptions_link.rb +213 -0
- data/lib/support_readiness/support_super_form_processor/global_ir_dotcom_subscriptions_nfr.rb +224 -0
- data/lib/support_readiness/support_super_form_processor/global_ir_dotcom_subscriptions_reset_seat_qsr.rb +194 -0
- data/lib/support_readiness/support_super_form_processor/global_ir_dotcom_trials_edit.rb +198 -0
- data/lib/support_readiness/support_super_form_processor/global_ir_dotcom_trials_extension.rb +228 -0
- data/lib/support_readiness/support_super_form_processor/global_ir_dotcom_trials_over_plan.rb +219 -0
- data/lib/support_readiness/support_super_form_processor/global_ir_hackerone_license.rb +172 -0
- data/lib/support_readiness/support_super_form_processor/global_ir_oem_license.rb +241 -0
- data/lib/support_readiness/support_super_form_processor/global_ir_order_management.rb +267 -0
- data/lib/support_readiness/support_super_form_processor/global_ir_other.rb +137 -0
- data/lib/support_readiness/support_super_form_processor/global_ir_provison_failure.rb +179 -0
- data/lib/support_readiness/support_super_form_processor/global_ir_sm_subscriptions_did_not_receive.rb +191 -0
- data/lib/support_readiness/support_super_form_processor/global_ir_sm_subscriptions_multiyear.rb +188 -0
- data/lib/support_readiness/support_super_form_processor/global_ir_sm_subscriptions_nfr.rb +215 -0
- data/lib/support_readiness/support_super_form_processor/global_ir_sm_subscriptions_resend.rb +188 -0
- data/lib/support_readiness/support_super_form_processor/global_ir_sm_subscriptions_scl.rb +194 -0
- data/lib/support_readiness/support_super_form_processor/global_ir_sm_subscriptions_temp.rb +234 -0
- data/lib/support_readiness/support_super_form_processor/global_ir_sm_trials_edit.rb +203 -0
- data/lib/support_readiness/support_super_form_processor/global_ir_sm_trials_extension.rb +233 -0
- data/lib/support_readiness/support_super_form_processor/global_ir_sm_trials_new.rb +223 -0
- data/lib/support_readiness/support_super_form_processor/global_ir_wider_community_license.rb +247 -0
- data/lib/support_readiness/support_super_form_processor/global_set_collaboration_id.rb +151 -0
- data/lib/support_readiness/support_super_form_processor/global_set_org_ase.rb +293 -0
- data/lib/support_readiness/support_super_form_processor/global_toggle_escalation.rb +142 -0
- data/lib/support_readiness/support_super_form_processor/gratis_support_extension.rb +247 -0
- data/lib/support_readiness/support_super_form_processor/gratis_support_former_customer.rb +288 -0
- data/lib/support_readiness/support_super_form_processor/gratis_support_migration.rb +238 -0
- data/lib/support_readiness/support_super_form_processor/gratis_support_other.rb +221 -0
- data/lib/support_readiness/support_super_form_processor/gratis_support_prospect.rb +288 -0
- data/lib/support_readiness/support_super_form_processor/gratis_support_upgrade.rb +298 -0
- data/lib/support_readiness/support_super_form_processor/namespace_availability.rb +213 -0
- data/lib/support_readiness/support_super_form_processor/pd_shadow_modification.rb +189 -0
- data/lib/support_readiness/support_super_form_processor/sa_request_for_support.rb +214 -0
- data/lib/support_readiness/support_super_form_processor/shared.rb +518 -0
- data/lib/support_readiness/support_super_form_processor/team_member_license.rb +144 -0
- data/lib/support_readiness/support_super_form_processor/two_fa_exemption.rb +260 -0
- data/lib/support_readiness/support_super_form_processor/usgov_ir_order_management.rb +252 -0
- data/lib/support_readiness/support_super_form_processor/usgov_ir_other.rb +136 -0
- data/lib/support_readiness/support_super_form_processor/usgov_ir_sm_subs_did_not_receive.rb +162 -0
- data/lib/support_readiness/support_super_form_processor/usgov_ir_sm_subs_multiyear.rb +159 -0
- data/lib/support_readiness/support_super_form_processor/usgov_ir_sm_subs_nfr.rb +196 -0
- data/lib/support_readiness/support_super_form_processor/usgov_ir_sm_subs_resend.rb +159 -0
- data/lib/support_readiness/support_super_form_processor/usgov_ir_sm_subs_scl.rb +160 -0
- data/lib/support_readiness/support_super_form_processor/usgov_ir_sm_subs_temp.rb +219 -0
- data/lib/support_readiness/support_super_form_processor/usgov_ir_sm_trials_edit.rb +189 -0
- data/lib/support_readiness/support_super_form_processor/usgov_ir_sm_trials_extension.rb +219 -0
- data/lib/support_readiness/support_super_form_processor/usgov_ir_sm_trials_new.rb +209 -0
- data/lib/support_readiness/support_super_form_processor/usgov_set_collaboration_id.rb +151 -0
- data/lib/support_readiness/support_super_form_processor/usgov_set_org_ase.rb +295 -0
- data/lib/support_readiness/support_super_form_processor.rb +67 -0
- data/lib/support_readiness.rb +1 -0
- metadata +59 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 329d7803aa9435db0939a46d9cc4124bf25c51bb5faed1a6a4d8cd6278fc00a4
|
4
|
+
data.tar.gz: 4da0de2f1303d5b225f4f91077863059ee482fbd7cbe2274df7bb72a400cdab4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 11cec2ae870755dee110a441c62bfe2c17c73a70c1ff0368b49e6f0e4beab979cd03d95ab863013673e75e6b0c78b908e9f6885c9d76f9679ae5344425c4bcbe
|
7
|
+
data.tar.gz: 0e83d7b4973c7b3c288eba1dfc9af1eea6848c8e456b4ee2d94ad576fbbf2cece43f78d67dfe3d609e8efe9cb22a0452183e81c4b2885e6ce9d0eaa611088867
|
@@ -57,7 +57,8 @@ module Readiness
|
|
57
57
|
Faraday.new("https://api:#{config.token}@api.mailgun.net/v3") do |c|
|
58
58
|
c.request :retry, retry_options(config)
|
59
59
|
c.adapter Faraday.default_adapter
|
60
|
-
c.
|
60
|
+
c.request :multipart
|
61
|
+
c.request :url_encoded
|
61
62
|
end
|
62
63
|
end
|
63
64
|
end
|
@@ -57,7 +57,7 @@ module Readiness
|
|
57
57
|
# # => true
|
58
58
|
def self.send!(client, email)
|
59
59
|
handle_request_error(1, 'Mailgun', 400, { action: 'Send email', id: email }) unless valid_email?(email)
|
60
|
-
response = client.connection.post "#{client.domain}/messages",
|
60
|
+
response = client.connection.post "#{client.domain}/messages", to_hash(email).compact
|
61
61
|
handle_request_error(1, 'Mailgun', response.status, { action: 'Send email', id: email }) unless response.status == 200
|
62
62
|
true
|
63
63
|
end
|
@@ -0,0 +1,375 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Defines the module Readiness.
|
4
|
+
module Readiness
|
5
|
+
# Defines the module SupportSuperFormProcessor
|
6
|
+
module SupportSuperFormProcessor
|
7
|
+
##
|
8
|
+
# Defines the class CreateArticle within the module {Readiness::Zendesk}.
|
9
|
+
#
|
10
|
+
# @author Jason Colyer
|
11
|
+
# @since 1.0.42
|
12
|
+
class CreateArticle < Readiness::Client
|
13
|
+
##
|
14
|
+
# Process a Create Article request
|
15
|
+
#
|
16
|
+
# @author Jason Colyer
|
17
|
+
# @since 1.0.42
|
18
|
+
def self.process!(gitlab_client, gitlab_admin_client, zendesk_global_client, zendesk_usgov_client)
|
19
|
+
@gitlab_client = gitlab_client
|
20
|
+
@gitlab_admin_client = gitlab_admin_client
|
21
|
+
@zendesk_global_client = zendesk_global_client
|
22
|
+
@zendesk_usgov_client = zendesk_usgov_client
|
23
|
+
requester
|
24
|
+
request_checks
|
25
|
+
unless errors.count.zero?
|
26
|
+
Readiness::SupportSuperFormProcessor::Shared.invalid_article_creation(requester, errors)
|
27
|
+
end
|
28
|
+
issue = Readiness::GitLab::Issues.new
|
29
|
+
issue.title = 'Create a new article'
|
30
|
+
issue.description = issue_message
|
31
|
+
create = Readiness::GitLab::Issues.create!(@gitlab_client, project, issue)
|
32
|
+
puts "Issue created: #{create.web_url}"
|
33
|
+
articles = create_articles_in_zendesk
|
34
|
+
create_article_commits(articles)
|
35
|
+
comment_params = {
|
36
|
+
body: article_comment_message(articles)
|
37
|
+
}
|
38
|
+
comment = Readiness::GitLab::Issues.create_comment(@gitlab_client, project, create, comment_params)
|
39
|
+
exit 0
|
40
|
+
end
|
41
|
+
|
42
|
+
##
|
43
|
+
# Commit article files to the repos
|
44
|
+
#
|
45
|
+
# @author Jason Colyer
|
46
|
+
# @since 1.0.42
|
47
|
+
def self.create_article_commits(articles)
|
48
|
+
unless articles[:global].nil?
|
49
|
+
repo_project = Readiness::GitLab::Projects.find!(@gitlab_client, 52796747)
|
50
|
+
commit_params = {
|
51
|
+
branch: 'master',
|
52
|
+
commit_message: 'Creating new article file',
|
53
|
+
actions: [
|
54
|
+
{
|
55
|
+
file_path: "data/articles/active/#{create_article_link.split('/').last.gsub('.md', '.yaml')}",
|
56
|
+
action: 'create',
|
57
|
+
content: global_file_content(articles[:global])
|
58
|
+
}
|
59
|
+
]
|
60
|
+
}
|
61
|
+
Readiness::GitLab::Repositories.create_commit!(@gitlab_client, repo_project, commit_params)
|
62
|
+
end
|
63
|
+
unless articles[:usgov].nil?
|
64
|
+
repo_project = Readiness::GitLab::Projects.find!(@gitlab_client, 53653025)
|
65
|
+
commit_params = {
|
66
|
+
branch: 'master',
|
67
|
+
commit_message: 'Creating new article file',
|
68
|
+
actions: [
|
69
|
+
{
|
70
|
+
file_path: "data/articles/active/#{create_article_link.split('/').last.gsub('.md', '.yaml')}",
|
71
|
+
action: 'create',
|
72
|
+
content: usgov_file_content(articles[:usgov])
|
73
|
+
}
|
74
|
+
]
|
75
|
+
}
|
76
|
+
Readiness::GitLab::Repositories.create_commit!(@gitlab_client, repo_project, commit_params)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
##
|
81
|
+
# Returns a string for the Global article sync repo
|
82
|
+
#
|
83
|
+
# @author Jason Colyer
|
84
|
+
# @since 1.0.42
|
85
|
+
def self.global_file_content(article)
|
86
|
+
<<~STRING
|
87
|
+
---
|
88
|
+
id: #{article.id}
|
89
|
+
author_id: 365068329233
|
90
|
+
comments_disabled: true
|
91
|
+
draft: false
|
92
|
+
promoted: false
|
93
|
+
position: 0
|
94
|
+
name: '#{article_title}'
|
95
|
+
title: '#{article_title}'
|
96
|
+
locale: 'en-us'
|
97
|
+
user_segment_id: null
|
98
|
+
permission_group_id: 113047
|
99
|
+
label_names: []
|
100
|
+
body: null
|
101
|
+
section_id: #{section_id('Global')}
|
102
|
+
content_path: '#{create_article_link.split(%r{master/(knowledge-base|support-pages)/}).last}'
|
103
|
+
STRING
|
104
|
+
end
|
105
|
+
|
106
|
+
##
|
107
|
+
# Returns a string for the US Gov article sync repo
|
108
|
+
#
|
109
|
+
# @author Jason Colyer
|
110
|
+
# @since 1.0.42
|
111
|
+
def self.usgov_file_content(article)
|
112
|
+
<<~STRING
|
113
|
+
---
|
114
|
+
id: #{article.id}
|
115
|
+
author_id: 381755018552
|
116
|
+
comments_disabled: true
|
117
|
+
draft: false
|
118
|
+
promoted: false
|
119
|
+
position: 0
|
120
|
+
name: '#{article_title}'
|
121
|
+
title: '#{article_title}'
|
122
|
+
locale: 'en-us'
|
123
|
+
user_segment_id: null
|
124
|
+
permission_group_id: 2721132
|
125
|
+
label_names: []
|
126
|
+
body: null
|
127
|
+
section_id: #{section_id('US Government')}
|
128
|
+
content_path: '#{create_article_link.split(%r{master/(knowledge-base|support-pages)/}).last}'
|
129
|
+
STRING
|
130
|
+
end
|
131
|
+
|
132
|
+
##
|
133
|
+
# Retunrs the correct section ID to use
|
134
|
+
#
|
135
|
+
# @author Jason Colyer
|
136
|
+
# @since 1.0.42
|
137
|
+
def self.section_id(instance)
|
138
|
+
path = create_article_link.split('master/').last.split('/').first
|
139
|
+
return 360004459140 if instance == 'Global' && path == 'support-pages'
|
140
|
+
return 15215649512604 if instance == 'Global' && path == 'knowledge-base'
|
141
|
+
return 10593044624020 if instance == 'US Government' && path == 'support-pages'
|
142
|
+
return 29015014994068 if instance == 'US Government' && path == 'knowledge-base'
|
143
|
+
|
144
|
+
nil
|
145
|
+
end
|
146
|
+
|
147
|
+
##
|
148
|
+
# Return a Hash of Article objects
|
149
|
+
#
|
150
|
+
# @author Jason Colyer
|
151
|
+
# @since 1.0.42
|
152
|
+
def self.create_articles_in_zendesk
|
153
|
+
{
|
154
|
+
global: create_global_article,
|
155
|
+
usgov: create_usgov_article
|
156
|
+
}
|
157
|
+
end
|
158
|
+
|
159
|
+
##
|
160
|
+
# Create an article in Zendesk Global
|
161
|
+
#
|
162
|
+
# @author Jason Colyer
|
163
|
+
# @since 1.0.42
|
164
|
+
def self.create_global_article
|
165
|
+
return nil unless create_article_link =~ /all_instances/ || create_article_link =~ /global_only/
|
166
|
+
|
167
|
+
article = Readiness::Zendesk::Articles.new
|
168
|
+
article.author_id = 365068329233
|
169
|
+
article.body = "Placeholder for #{create_article_link}"
|
170
|
+
article.comments_disabled = true
|
171
|
+
article.draft = true
|
172
|
+
article.locale = 'en-us'
|
173
|
+
article.permission_group_id = 113047
|
174
|
+
article.title = article_title
|
175
|
+
article.user_segment_id = 1536307
|
176
|
+
Readiness::Zendesk::Articles.create!(@zendesk_global_client, article)
|
177
|
+
end
|
178
|
+
|
179
|
+
##
|
180
|
+
# Create an article in Zendesk US Government
|
181
|
+
#
|
182
|
+
# @author Jason Colyer
|
183
|
+
# @since 1.0.42
|
184
|
+
def self.create_usgov_article
|
185
|
+
return nil unless create_article_link =~ /all_instances/ || create_article_link =~ /us_government_only/
|
186
|
+
|
187
|
+
article = Readiness::Zendesk::Articles.new
|
188
|
+
article.author_id = 381755018552
|
189
|
+
article.body = "Placeholder for #{create_article_link}"
|
190
|
+
article.comments_disabled = true
|
191
|
+
article.draft = true
|
192
|
+
article.locale = 'en-us'
|
193
|
+
article.permission_group_id = 2721132
|
194
|
+
article.title = article_title
|
195
|
+
article.user_segment_id = 360001187072
|
196
|
+
Readiness::Zendesk::Articles.create!(@zendesk_usgov_client, article)
|
197
|
+
end
|
198
|
+
|
199
|
+
##
|
200
|
+
# Perform the needed checks for article creation
|
201
|
+
#
|
202
|
+
# @author Jason Colyer
|
203
|
+
# @since 1.0.42
|
204
|
+
def self.request_checks
|
205
|
+
pages_project = Readiness::GitLab::Projects.find!(@gitlab_client, 52066066)
|
206
|
+
path = create_article_link.split('master/').last.split('?').first
|
207
|
+
file = Readiness::GitLab::Repositories.file(@gitlab_client, pages_project, path, 'master')
|
208
|
+
unless file.key? 'file_name'
|
209
|
+
errors.push("No such article file: #{path}")
|
210
|
+
end
|
211
|
+
file_contents = Readiness::GitLab::Repositories.raw_file(@gitlab_client, pages_project, '.gitlab/CODEOWNERS', 'master')
|
212
|
+
match = file_contents =~ %r{#{path} #{article_dris}}
|
213
|
+
errors.push("No such CODEOWNERS entry: #{path} #{article_dris}") unless match
|
214
|
+
end
|
215
|
+
|
216
|
+
##
|
217
|
+
# Sets the global variable errors
|
218
|
+
#
|
219
|
+
# @author Jason Colyer
|
220
|
+
# @since 1.0.42
|
221
|
+
def self.errors
|
222
|
+
@errors ||= []
|
223
|
+
end
|
224
|
+
|
225
|
+
##
|
226
|
+
# Sets the global variable requester
|
227
|
+
#
|
228
|
+
# @author Jason Colyer
|
229
|
+
# @since 1.0.42
|
230
|
+
def self.requester
|
231
|
+
@requester ||= Readiness::SupportSuperFormProcessor::Shared.gitlab_user_check(@gitlab_admin_client, requester_email)
|
232
|
+
end
|
233
|
+
|
234
|
+
##
|
235
|
+
# Sets the global variable requester_email
|
236
|
+
#
|
237
|
+
# @author Jason Colyer
|
238
|
+
# @since 1.0.42
|
239
|
+
def self.requester_email
|
240
|
+
@requester_email ||= ENV.fetch('REQUESTER_EMAIL')
|
241
|
+
end
|
242
|
+
|
243
|
+
##
|
244
|
+
# Sets the global variable project
|
245
|
+
#
|
246
|
+
# @author Jason Colyer
|
247
|
+
# @since 1.0.42
|
248
|
+
def self.project
|
249
|
+
@project ||= Readiness::GitLab::Projects.find!(@gitlab_client, 12811526)
|
250
|
+
end
|
251
|
+
|
252
|
+
##
|
253
|
+
# Sets the global variable create_article_link
|
254
|
+
#
|
255
|
+
# @author Jason Colyer
|
256
|
+
# @since 1.0.42
|
257
|
+
def self.create_article_link
|
258
|
+
@create_article_link ||= ENV.fetch('CREATE_ARTICLE_LINK')
|
259
|
+
end
|
260
|
+
|
261
|
+
##
|
262
|
+
# Sets the global variable article_dris
|
263
|
+
#
|
264
|
+
# @author Jason Colyer
|
265
|
+
# @since 1.0.42
|
266
|
+
def self.article_dris
|
267
|
+
@article_dris ||= ENV.fetchh('CREATE_ARTICLE_DRIS')
|
268
|
+
end
|
269
|
+
|
270
|
+
##
|
271
|
+
# Sets the global variable article_title
|
272
|
+
#
|
273
|
+
# @author Jason Colyer
|
274
|
+
# @since 1.0.42
|
275
|
+
def self.article_title
|
276
|
+
@article_title ||= determine_article_title
|
277
|
+
end
|
278
|
+
|
279
|
+
##
|
280
|
+
# Determines the article title
|
281
|
+
#
|
282
|
+
# @author Jason Colyer
|
283
|
+
# @since 1.0.42
|
284
|
+
def self.determine_article_title
|
285
|
+
path = create_article_link.split('master/').last.split('?').first
|
286
|
+
pages_project = Readiness::GitLab::Projects.find!(@gitlab_client, 52066066)
|
287
|
+
file_contents = Readiness::GitLab::Repositories.raw_file(@gitlab_client, pages_project, path, 'master')
|
288
|
+
file_contents.split("\n").detect { |f| f =~ /^\#\ / }.split('# ').last.gsub('`', '').gsub("'", '"')
|
289
|
+
end
|
290
|
+
|
291
|
+
##
|
292
|
+
# Returns string for displaying what instances this applies to
|
293
|
+
#
|
294
|
+
# @author Jason Colyer
|
295
|
+
# @since 1.0.42
|
296
|
+
def self.instance_block
|
297
|
+
output = []
|
298
|
+
if create_article_link =~ /all_instances/ || create_article_link =~ /global_only/
|
299
|
+
output.push(' - [x] Global')
|
300
|
+
else
|
301
|
+
output.push(' - [~] Global')
|
302
|
+
end
|
303
|
+
if create_article_link =~ /all_instances/ || create_article_link =~ /us_government_only/
|
304
|
+
output.push(' - [x] US Government')
|
305
|
+
else
|
306
|
+
output.push(' - [~] US Government')
|
307
|
+
end
|
308
|
+
output.join("\n")
|
309
|
+
end
|
310
|
+
|
311
|
+
##
|
312
|
+
# Returns string for issue body
|
313
|
+
#
|
314
|
+
# @author Jason Colyer
|
315
|
+
# @since 1.0.42
|
316
|
+
def self.issue_message
|
317
|
+
<<~STRING
|
318
|
+
## Create a new article
|
319
|
+
|
320
|
+
Greetings @#{requester.username} !
|
321
|
+
|
322
|
+
This is a request to create a new article within Zendesk. The details are as follows:
|
323
|
+
|
324
|
+
- Link to article file: #{create_article_link}
|
325
|
+
- Article DRIs: `#{article_dris}`
|
326
|
+
- Zendesk Instance(s):
|
327
|
+
#{instance_block}
|
328
|
+
|
329
|
+
---
|
330
|
+
|
331
|
+
### Support Readiness Process
|
332
|
+
|
333
|
+
This process should be completely automated. If you see any issues, please rectify them and notify Jason so the processor can be looked into.
|
334
|
+
|
335
|
+
/label ~"Readiness Priority::Current Quarter"
|
336
|
+
|
337
|
+
/label ~"Readiness::Completed"
|
338
|
+
|
339
|
+
/assign @jcolyer @dtragjasi
|
340
|
+
STRING
|
341
|
+
end
|
342
|
+
|
343
|
+
##
|
344
|
+
# Returns string for comment body
|
345
|
+
#
|
346
|
+
# @author Jason Colyer
|
347
|
+
# @since 1.0.42
|
348
|
+
def self.article_comment_message(articles)
|
349
|
+
<<~STRING
|
350
|
+
We have added the article to the requested Zendesk instance(s). You can see the article at the following link(s) once the sync completes (in the next 5-10 minutes):
|
351
|
+
|
352
|
+
#{article_links_comment_string(articles)}
|
353
|
+
|
354
|
+
If you see any issues, please reopen this issue and post in the support operations channel in Slack.
|
355
|
+
|
356
|
+
/label ~"Readiness::Completed"
|
357
|
+
|
358
|
+
/close
|
359
|
+
STRING
|
360
|
+
end
|
361
|
+
|
362
|
+
##
|
363
|
+
# Returns string for article links
|
364
|
+
#
|
365
|
+
# @author Jason Colyer
|
366
|
+
# @since 1.0.42
|
367
|
+
def self.article_links_comment_string(articles)
|
368
|
+
out = []
|
369
|
+
out.push("- https://support.gitlab.com/hc/en-us/articles/#{articles[:global].id}") unless articles[:global].nil?
|
370
|
+
out.push("- https://federal-support.gitlab.com/hc/en-us/articles/#{articles[:usgov].id}") unless articles[:usgov].nil?
|
371
|
+
out.join("\n")
|
372
|
+
end
|
373
|
+
end
|
374
|
+
end
|
375
|
+
end
|
@@ -0,0 +1,183 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Defines the module Readiness.
|
4
|
+
module Readiness
|
5
|
+
# Defines the module SupportSuperFormProcessor
|
6
|
+
module SupportSuperFormProcessor
|
7
|
+
##
|
8
|
+
# Defines the class CreateMacro within the module {Readiness::Zendesk}.
|
9
|
+
#
|
10
|
+
# @author Jason Colyer
|
11
|
+
# @since 1.0.42
|
12
|
+
class CreateMacro < Readiness::Client
|
13
|
+
##
|
14
|
+
# Process a Create Macro request
|
15
|
+
#
|
16
|
+
# @author Jason Colyer
|
17
|
+
# @since 1.0.42
|
18
|
+
def self.process!(gitlab_client, gitlab_admin_client)
|
19
|
+
@gitlab_client = gitlab_client
|
20
|
+
@gitlab_admin_client = gitlab_admin_client
|
21
|
+
requester
|
22
|
+
file_path = create_macro_file_if_needed
|
23
|
+
issue = Readiness::GitLab::Issues.new
|
24
|
+
issue.title = 'Create a new macro'
|
25
|
+
issue.description = message(file_path)
|
26
|
+
create = Readiness::GitLab::Issues.create!(@gitlab_client, project, issue)
|
27
|
+
puts "Issue created: #{create.web_url}"
|
28
|
+
exit 0
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.create_macro_file_if_needed
|
32
|
+
return nil if comment == 'none'
|
33
|
+
|
34
|
+
macro_project_id = if instance == 'Zendesk Global'
|
35
|
+
53382456
|
36
|
+
else
|
37
|
+
53561363
|
38
|
+
end
|
39
|
+
macro_project = Readiness::GitLab::Projects.find!(@gitlab_client, macro_project_id)
|
40
|
+
path = "active/#{name.split('::').join('/')}.md"
|
41
|
+
file = Readiness::GitLab::Repositories.file(@gitlab_client, macro_project, path, 'master')
|
42
|
+
unless file.key? 'file_name'
|
43
|
+
commit_params = {
|
44
|
+
branch: 'master',
|
45
|
+
commit_message: 'Creating placeholder file for macro',
|
46
|
+
actions: [
|
47
|
+
{
|
48
|
+
file_path: path,
|
49
|
+
content: 'PLACEHOLDER',
|
50
|
+
action: 'create'
|
51
|
+
}
|
52
|
+
]
|
53
|
+
}
|
54
|
+
Readiness::GitLab::Repositories.create_commit!(@gitlab_client, macro_project, commit_params)
|
55
|
+
end
|
56
|
+
path
|
57
|
+
end
|
58
|
+
|
59
|
+
##
|
60
|
+
# Sets the global variable requester
|
61
|
+
#
|
62
|
+
# @author Jason Colyer
|
63
|
+
# @since 1.0.42
|
64
|
+
def self.requester
|
65
|
+
@requester ||= Readiness::SupportSuperFormProcessor::Shared.gitlab_user_check(@gitlab_admin_client, requester_email)
|
66
|
+
end
|
67
|
+
|
68
|
+
##
|
69
|
+
# Sets the global variable requester_email
|
70
|
+
#
|
71
|
+
# @author Jason Colyer
|
72
|
+
# @since 1.0.42
|
73
|
+
def self.requester_email
|
74
|
+
@requester_email ||= ENV.fetch('REQUESTER_EMAIL')
|
75
|
+
end
|
76
|
+
|
77
|
+
##
|
78
|
+
# Sets the global variable project
|
79
|
+
#
|
80
|
+
# @author Jason Colyer
|
81
|
+
# @since 1.0.42
|
82
|
+
def self.project
|
83
|
+
@project ||= Readiness::GitLab::Projects.find!(@gitlab_client, 12811526)
|
84
|
+
end
|
85
|
+
|
86
|
+
##
|
87
|
+
# Sets the global variable comment
|
88
|
+
#
|
89
|
+
# @author Jason Colyer
|
90
|
+
# @since 1.0.42
|
91
|
+
def self.comment
|
92
|
+
@comment ||= ENV.fetch('CREATE_MACRO_COMMENT')
|
93
|
+
end
|
94
|
+
|
95
|
+
##
|
96
|
+
# Sets the global variable instance
|
97
|
+
#
|
98
|
+
# @author Jason Colyer
|
99
|
+
# @since 1.0.42
|
100
|
+
def self.instance
|
101
|
+
@instance ||= ENV.fetch('CREATE_MACRO_INSTANCE')
|
102
|
+
end
|
103
|
+
|
104
|
+
##
|
105
|
+
# Sets the global variable name
|
106
|
+
#
|
107
|
+
# @author Jason Colyer
|
108
|
+
# @since 1.0.42
|
109
|
+
def self.name
|
110
|
+
@name ||= ENV.fetch('CREATE_MACRO_NAME')
|
111
|
+
end
|
112
|
+
|
113
|
+
##
|
114
|
+
# Sets the global variable assignee
|
115
|
+
#
|
116
|
+
# @author Jason Colyer
|
117
|
+
# @since 1.0.42
|
118
|
+
def self.assignee
|
119
|
+
@assignee ||= ENV.fetch('CREATE_MACRO_ASSIGNEE')
|
120
|
+
end
|
121
|
+
|
122
|
+
##
|
123
|
+
# Sets the global variable tag
|
124
|
+
#
|
125
|
+
# @author Jason Colyer
|
126
|
+
# @since 1.0.42
|
127
|
+
def self.tag
|
128
|
+
@tag ||= ENV.fetch('CREATE_MACRO_TAG')
|
129
|
+
end
|
130
|
+
|
131
|
+
##
|
132
|
+
# Sets the global variable other
|
133
|
+
#
|
134
|
+
# @author Jason Colyer
|
135
|
+
# @since 1.0.42
|
136
|
+
def self.other
|
137
|
+
@other ||= ENV.fetch('CREATE_MACRO_OTHER')
|
138
|
+
end
|
139
|
+
|
140
|
+
def self.issue_assignees
|
141
|
+
return '@jcolyer @secole' if instance == 'Zendesk US Government'
|
142
|
+
|
143
|
+
'@jcolyer @nabeel.bilgrami @avilla4 @dtragjasi @secole @rverschoor'
|
144
|
+
end
|
145
|
+
|
146
|
+
##
|
147
|
+
# Return the string for the issue body
|
148
|
+
#
|
149
|
+
# @author Jason Colyer
|
150
|
+
# @since 1.0.42
|
151
|
+
def self.message(file_path)
|
152
|
+
<<~STRING
|
153
|
+
## Create a macro
|
154
|
+
|
155
|
+
Greetings @#{requester.username} !
|
156
|
+
|
157
|
+
This is a request to create a new macro within a Zendesk instance. The details are as follows:
|
158
|
+
|
159
|
+
- Name of Macro: #{name}
|
160
|
+
- Zendesk Instance: #{instance}
|
161
|
+
- Assigne change: #{assignee}
|
162
|
+
- Tag to add: #{tag}
|
163
|
+
- Type of comment: #{comment}
|
164
|
+
- Managed content file: #{file_path.nil? ? 'N/A' : path}
|
165
|
+
|
166
|
+
Some other details are:
|
167
|
+
|
168
|
+
```
|
169
|
+
|
170
|
+
#{other}
|
171
|
+
|
172
|
+
```
|
173
|
+
|
174
|
+
/label ~"Readiness Priority::Current Quarter"
|
175
|
+
|
176
|
+
/label ~"Readiness::Triage"
|
177
|
+
|
178
|
+
/assign #{issue_assignees}
|
179
|
+
STRING
|
180
|
+
end
|
181
|
+
end
|
182
|
+
end
|
183
|
+
end
|