From 02129c294d4f749d04835d231a24e81850347ebb Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Wed, 22 Aug 2018 14:04:58 +0200 Subject: Add GitLab cluster id to jupyter config Signed-off-by: Dmitriy Zaporozhets --- app/models/clusters/applications/jupyter.rb | 5 +++++ spec/models/clusters/applications/jupyter_spec.rb | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/app/models/clusters/applications/jupyter.rb b/app/models/clusters/applications/jupyter.rb index 3d84eeed5a8..7be6a14f585 100644 --- a/app/models/clusters/applications/jupyter.rb +++ b/app/models/clusters/applications/jupyter.rb @@ -73,6 +73,11 @@ module Clusters "clientSecret" => oauth_application.secret, "callbackUrl" => callback_url } + }, + "singleuser" => { + "extraEnv" => { + "GITLAB_CLUSTER_ID" => cluster.id + } } } end diff --git a/spec/models/clusters/applications/jupyter_spec.rb b/spec/models/clusters/applications/jupyter_spec.rb index 591a01d78a9..9c4396731eb 100644 --- a/spec/models/clusters/applications/jupyter_spec.rb +++ b/spec/models/clusters/applications/jupyter_spec.rb @@ -108,8 +108,15 @@ describe Clusters::Applications::Jupyter do expect(values).to include('rbac') expect(values).to include('proxy') expect(values).to include('auth') + expect(values).to include('singleuser') expect(values).to match(/clientId: '?#{application.oauth_application.uid}/) expect(values).to match(/callbackUrl: '?#{application.callback_url}/) end + + context 'when cluster belongs to a project' do + it 'sets GitLab project id' do + expect(values).to match(/GITLAB_CLUSTER_ID: '?#{application.cluster.id}/) + end + end end end -- cgit v1.2.1