diff options
author | Alessio Caiazza <acaiazza@gitlab.com> | 2017-11-03 13:10:50 +0300 |
---|---|---|
committer | Alessio Caiazza <acaiazza@gitlab.com> | 2017-11-03 13:10:50 +0300 |
commit | 49210dfff12ba0fba5fdbcdc2c485fbbde43f83f (patch) | |
tree | 8207b9d670dd3f5342e07a78a114903b7dbc0e95 /app/services/clusters | |
parent | 1ca9aaf860e09351a94331020cd43be4af5f2131 (diff) |
Schedule k8s application installation with a service
Diffstat (limited to 'app/services/clusters')
-rw-r--r-- | app/services/clusters/applications/schedule_installation_service.rb | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/app/services/clusters/applications/schedule_installation_service.rb b/app/services/clusters/applications/schedule_installation_service.rb new file mode 100644 index 00000000000..17b3a09948d --- /dev/null +++ b/app/services/clusters/applications/schedule_installation_service.rb @@ -0,0 +1,27 @@ +module Clusters + module Applications + class ScheduleInstallationService < ::BaseService + def execute + application = application_class.find_or_create_by!(cluster: cluster) + + application.make_scheduled! + ClusterInstallAppWorker.perform_async(application.name, application.id) + true + rescue ActiveRecord::RecordInvalid + false + rescue StateMachines::InvalidTransition + false + end + + private + + def application_class + params[:application_class] + end + + def cluster + params[:cluster] + end + end + end +end |