summaryrefslogtreecommitdiff
path: root/app/services/ci
diff options
context:
space:
mode:
authorShinya Maeda <shinya@gitlab.com>2017-10-02 21:58:50 +0900
committerShinya Maeda <shinya@gitlab.com>2017-10-02 21:58:50 +0900
commit34e66c427dde2070c2c09a07ce08f991e46de92f (patch)
treed0894218a41a2b67313fc232f19cc734f3dc7b67 /app/services/ci
parent2cb1d617d90b4a9311e3a35434bec958f266d22a (diff)
downloadgitlab-ce-34e66c427dde2070c2c09a07ce08f991e46de92f.tar.gz
PollingInterval, rename to gke_clusters, has_one :cluster
Diffstat (limited to 'app/services/ci')
-rw-r--r--app/services/ci/create_cluster_service.rb4
-rw-r--r--app/services/ci/integrate_cluster_service.rb19
-rw-r--r--app/services/ci/update_cluster_service.rb4
3 files changed, 7 insertions, 20 deletions
diff --git a/app/services/ci/create_cluster_service.rb b/app/services/ci/create_cluster_service.rb
index b5fb71f5092..48d7c9aef23 100644
--- a/app/services/ci/create_cluster_service.rb
+++ b/app/services/ci/create_cluster_service.rb
@@ -5,9 +5,9 @@ module Ci
params['machine_type'] = GoogleApi::CloudPlatform::Client::DEFAULT_MACHINE_TYPE
end
- project.clusters.create(
+ project.create_cluster(
params.merge(user: current_user,
- status: Ci::Cluster.statuses[:scheduled],
+ status: Gcp::Cluster.statuses[:scheduled],
gcp_token: access_token))
end
end
diff --git a/app/services/ci/integrate_cluster_service.rb b/app/services/ci/integrate_cluster_service.rb
index 5dd1f2b3414..c60d3722373 100644
--- a/app/services/ci/integrate_cluster_service.rb
+++ b/app/services/ci/integrate_cluster_service.rb
@@ -1,23 +1,10 @@
module Ci
class IntegrateClusterService
def execute(cluster, endpoint, ca_cert, token, username, password)
- Ci::Cluster.transaction do
- kubernetes_service ||=
- cluster.project.find_or_initialize_service('kubernetes')
+ Gcp::Cluster.transaction do
+ cluster.created!(endpoint, ca_cert, token, username, password)
- cluster.update!(
- enabled: true,
- service: kubernetes_service,
- username: username,
- password: password,
- kubernetes_token: token,
- ca_cert: ca_cert,
- endpoint: endpoint,
- gcp_token: nil,
- gcp_operation_id: nil,
- status: Ci::Cluster.statuses[:created])
-
- kubernetes_service.update!(
+ cluster.service.update!(
active: true,
api_url: cluster.api_url,
ca_pem: ca_cert,
diff --git a/app/services/ci/update_cluster_service.rb b/app/services/ci/update_cluster_service.rb
index a440ac03a0b..a517d6be0c7 100644
--- a/app/services/ci/update_cluster_service.rb
+++ b/app/services/ci/update_cluster_service.rb
@@ -1,7 +1,7 @@
module Ci
class UpdateClusterService < BaseService
def execute(cluster)
- Ci::Cluster.transaction do
+ Gcp::Cluster.transaction do
cluster.update!(enabled: params['enabled'])
if params['enabled'] == 'true'
@@ -12,7 +12,7 @@ module Ci
namespace: cluster.project_namespace,
token: cluster.kubernetes_token)
else
- cluster.service.update(active: false)
+ cluster.service.update!(active: false)
end
end
rescue ActiveRecord::RecordInvalid => e