summaryrefslogtreecommitdiff
path: root/spec/support/kubernetes_helpers.rb
diff options
context:
space:
mode:
authorFilipa Lacerda <filipa@gitlab.com>2016-12-22 10:15:49 +0000
committerFilipa Lacerda <filipa@gitlab.com>2016-12-22 10:15:49 +0000
commit7fc64dd18d9b2b6e3a2a01dab0007f7dd25c37ed (patch)
tree428602d5265cd981a2e33ace8aed6fc9594dd37c /spec/support/kubernetes_helpers.rb
parentfd3ab00cf90ddf081c61fb701721ca9180378bba (diff)
parent6d9c1d3efce00da95832feaaf36227bcbffecadf (diff)
downloadgitlab-ce-pipeline-ui-updates.tar.gz
Merge branch 'master' into pipeline-ui-updatespipeline-ui-updates
* master: (259 commits) Exclude non existent repository storages. fixed minor animation glitch in mini pipeline graph animation Update Bitbucket callback URL documentation Update build step for KaTeX. Add KaTeX fonts to assets paths and precompile Replace url('...') to url(font-path('...')) Rname katex.css to katex.scss Revert conflicting EE changes Added Autodeploy script for OpenShift Whitelist next project names: notes, services Put back progress bar CSS Remove unneeded bundle refs. Adds entry to changelog Reduce MR widget title by one pixel Use same font size for all items in issue title Adds background color for disabled state to merge when succeeds dropdown Filter protocol-relative URLs in ExternalLinkFilter. Fixes issue #22742. Move javascript for widget check to ci_bundle. Introduce "Set up autodeploy" button to help configure GitLab CI for deployment Whitelist next project names: help, ci, admin, search ...
Diffstat (limited to 'spec/support/kubernetes_helpers.rb')
-rw-r--r--spec/support/kubernetes_helpers.rb52
1 files changed, 52 insertions, 0 deletions
diff --git a/spec/support/kubernetes_helpers.rb b/spec/support/kubernetes_helpers.rb
new file mode 100644
index 00000000000..6c4c246a68b
--- /dev/null
+++ b/spec/support/kubernetes_helpers.rb
@@ -0,0 +1,52 @@
+module KubernetesHelpers
+ include Gitlab::Kubernetes
+
+ def kube_discovery_body
+ { "kind" => "APIResourceList",
+ "resources" => [
+ { "name" => "pods", "namespaced" => true, "kind" => "Pod" },
+ ],
+ }
+ end
+
+ def kube_pods_body(*pods)
+ { "kind" => "PodList",
+ "items" => [ kube_pod ],
+ }
+ end
+
+ # This is a partial response, it will have many more elements in reality but
+ # these are the ones we care about at the moment
+ def kube_pod(app: "valid-pod-label")
+ { "metadata" => {
+ "name" => "kube-pod",
+ "creationTimestamp" => "2016-11-25T19:55:19Z",
+ "labels" => { "app" => app },
+ },
+ "spec" => {
+ "containers" => [
+ { "name" => "container-0" },
+ { "name" => "container-1" },
+ ],
+ },
+ "status" => { "phase" => "Running" },
+ }
+ end
+
+ def kube_terminals(service, pod)
+ pod_name = pod['metadata']['name']
+ containers = pod['spec']['containers']
+
+ containers.map do |container|
+ terminal = {
+ selectors: { pod: pod_name, container: container['name'] },
+ url: container_exec_url(service.api_url, service.namespace, pod_name, container['name']),
+ subprotocols: ['channel.k8s.io'],
+ headers: { 'Authorization' => ["Bearer #{service.token}"] },
+ created_at: DateTime.parse(pod['metadata']['creationTimestamp'])
+ }
+ terminal[:ca_pem] = service.ca_pem if service.ca_pem.present?
+ terminal
+ end
+ end
+end