Class: Gitlab::SlashCommands::Deploy
Constant Summary
collapse
- DEPLOY_REGEX =
/\Adeploy\s/
Constants inherited
from BaseCommand
BaseCommand::QUERY_LIMIT
Instance Attribute Summary
Attributes inherited from BaseCommand
#chat_name, #current_user, #params, #project
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from BaseCommand
can?, #collection, #initialize
Class Method Details
.allowed?(project, user) ⇒ Boolean
28
29
30
|
# File 'lib/gitlab/slash_commands/deploy.rb', line 28
def self.allowed?(project, user)
can?(user, :create_deployment, project)
end
|
.available?(project) ⇒ Boolean
24
25
26
|
# File 'lib/gitlab/slash_commands/deploy.rb', line 24
def self.available?(project)
project.builds_enabled?
end
|
.help_message ⇒ Object
20
21
22
|
# File 'lib/gitlab/slash_commands/deploy.rb', line 20
def self.help_message
'deploy <environment> to <target-environment>'
end
|
.match(text) ⇒ Object
8
9
10
11
12
13
14
15
16
17
18
|
# File 'lib/gitlab/slash_commands/deploy.rb', line 8
def self.match(text)
return unless text&.match?(DEPLOY_REGEX)
from, _, to = text.sub(DEPLOY_REGEX, '').rpartition(/\sto+\s/)
return if from.blank? || to.blank?
{
from: from.strip,
to: to.strip
}
end
|
Instance Method Details
#execute(match) ⇒ Object
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/gitlab/slash_commands/deploy.rb', line 32
def execute(match)
from = match[:from]
to = match[:to]
action = find_action(from, to)
if action.nil?
Gitlab::SlashCommands::Presenters::Deploy
.new(action).action_not_found
else
deployment = action.play(current_user)
Gitlab::SlashCommands::Presenters::Deploy
.new(deployment).present(from, to)
end
end
|