summaryrefslogtreecommitdiff
path: root/lib/gitlab/chat_commands/deploy.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gitlab/chat_commands/deploy.rb')
-rw-r--r--lib/gitlab/chat_commands/deploy.rb50
1 files changed, 0 insertions, 50 deletions
diff --git a/lib/gitlab/chat_commands/deploy.rb b/lib/gitlab/chat_commands/deploy.rb
deleted file mode 100644
index 458d90f84e8..00000000000
--- a/lib/gitlab/chat_commands/deploy.rb
+++ /dev/null
@@ -1,50 +0,0 @@
-module Gitlab
- module ChatCommands
- class Deploy < BaseCommand
- def self.match(text)
- /\Adeploy\s+(?<from>\S+.*)\s+to+\s+(?<to>\S+.*)\z/.match(text)
- end
-
- def self.help_message
- 'deploy <environment> to <target-environment>'
- end
-
- def self.available?(project)
- project.builds_enabled?
- end
-
- def self.allowed?(project, user)
- can?(user, :create_deployment, project)
- end
-
- def execute(match)
- from = match[:from]
- to = match[:to]
-
- actions = find_actions(from, to)
-
- if actions.none?
- Gitlab::ChatCommands::Presenters::Deploy.new(nil).no_actions
- elsif actions.one?
- action = play!(from, to, actions.first)
- Gitlab::ChatCommands::Presenters::Deploy.new(action).present(from, to)
- else
- Gitlab::ChatCommands::Presenters::Deploy.new(actions).too_many_actions
- end
- end
-
- private
-
- def play!(from, to, action)
- action.play(current_user)
- end
-
- def find_actions(from, to)
- environment = project.environments.find_by(name: from)
- return [] unless environment
-
- environment.actions_for(to).select(&:starts_environment?)
- end
- end
- end
-end