summaryrefslogtreecommitdiff
path: root/spec/support/helpers/kubernetes_helpers.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-12-24 00:07:31 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2019-12-24 00:07:31 +0000
commit3888bc4261500c275759683076e07baaf352e5ec (patch)
treeeb70e0415be41a1d713cc89f211a6045778cd6b8 /spec/support/helpers/kubernetes_helpers.rb
parent33e1622bfe5afb2eea08ff06e44de490383a93e3 (diff)
downloadgitlab-ce-3888bc4261500c275759683076e07baaf352e5ec.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/support/helpers/kubernetes_helpers.rb')
-rw-r--r--spec/support/helpers/kubernetes_helpers.rb127
1 files changed, 127 insertions, 0 deletions
diff --git a/spec/support/helpers/kubernetes_helpers.rb b/spec/support/helpers/kubernetes_helpers.rb
index b2145ca729f..2fabfb94928 100644
--- a/spec/support/helpers/kubernetes_helpers.rb
+++ b/spec/support/helpers/kubernetes_helpers.rb
@@ -33,6 +33,14 @@ module KubernetesHelpers
.to_return(kube_response(kube_v1_rbac_authorization_discovery_body))
end
+ def stub_kubeclient_discover_istio(api_url)
+ stub_kubeclient_discover_base(api_url)
+
+ WebMock
+ .stub_request(:get, api_url + '/apis/networking.istio.io/v1alpha3')
+ .to_return(kube_response(kube_istio_discovery_body))
+ end
+
def stub_kubeclient_discover(api_url)
stub_kubeclient_discover_base(api_url)
@@ -244,6 +252,16 @@ module KubernetesHelpers
.to_return(kube_response({}))
end
+ def stub_kubeclient_get_gateway(api_url, name, namespace: 'default')
+ WebMock.stub_request(:get, api_url + "/apis/networking.istio.io/v1alpha3/namespaces/#{namespace}/gateways/#{name}")
+ .to_return(kube_response(kube_istio_gateway_body(name, namespace)))
+ end
+
+ def stub_kubeclient_put_gateway(api_url, name, namespace: 'default')
+ WebMock.stub_request(:put, api_url + "/apis/networking.istio.io/v1alpha3/namespaces/#{namespace}/gateways/#{name}")
+ .to_return(kube_response({}))
+ end
+
def kube_v1_secret_body(**options)
{
"kind" => "SecretList",
@@ -311,6 +329,115 @@ module KubernetesHelpers
}
end
+ def kube_istio_discovery_body
+ {
+ "kind" => "APIResourceList",
+ "apiVersion" => "v1",
+ "groupVersion" => "networking.istio.io/v1alpha3",
+ "resources" => [
+ {
+ "name" => "gateways",
+ "singularName" => "gateway",
+ "namespaced" => true,
+ "kind" => "Gateway",
+ "verbs" => %w[delete deletecollection get list patch create update watch],
+ "shortNames" => %w[gw],
+ "categories" => %w[istio-io networking-istio-io]
+ },
+ {
+ "name" => "serviceentries",
+ "singularName" => "serviceentry",
+ "namespaced" => true,
+ "kind" => "ServiceEntry",
+ "verbs" => %w[delete deletecollection get list patch create update watch],
+ "shortNames" => %w[se],
+ "categories" => %w[istio-io networking-istio-io]
+ },
+ {
+ "name" => "destinationrules",
+ "singularName" => "destinationrule",
+ "namespaced" => true,
+ "kind" => "DestinationRule",
+ "verbs" => %w[delete deletecollection get list patch create update watch],
+ "shortNames" => %w[dr],
+ "categories" => %w[istio-io networking-istio-io]
+ },
+ {
+ "name" => "envoyfilters",
+ "singularName" => "envoyfilter",
+ "namespaced" => true,
+ "kind" => "EnvoyFilter",
+ "verbs" => %w[delete deletecollection get list patch create update watch],
+ "categories" => %w[istio-io networking-istio-io]
+ },
+ {
+ "name" => "sidecars",
+ "singularName" => "sidecar",
+ "namespaced" => true,
+ "kind" => "Sidecar",
+ "verbs" => %w[delete deletecollection get list patch create update watch],
+ "categories" => %w[istio-io networking-istio-io]
+ },
+ {
+ "name" => "virtualservices",
+ "singularName" => "virtualservice",
+ "namespaced" => true,
+ "kind" => "VirtualService",
+ "verbs" => %w[delete deletecollection get list patch create update watch],
+ "shortNames" => %w[vs],
+ "categories" => %w[istio-io networking-istio-io]
+ }
+ ]
+ }
+ end
+
+ def kube_istio_gateway_body(name, namespace)
+ {
+ "apiVersion" => "networking.istio.io/v1alpha3",
+ "kind" => "Gateway",
+ "metadata" => {
+ "generation" => 1,
+ "labels" => {
+ "networking.knative.dev/ingress-provider" => "istio",
+ "serving.knative.dev/release" => "v0.7.0"
+ },
+ "name" => name,
+ "namespace" => namespace,
+ "selfLink" => "/apis/networking.istio.io/v1alpha3/namespaces/#{namespace}/gateways/#{name}"
+ },
+ "spec" => {
+ "selector" => {
+ "istio" => "ingressgateway"
+ },
+ "servers" => [
+ {
+ "hosts" => [
+ "*"
+ ],
+ "port" => {
+ "name" => "http",
+ "number" => 80,
+ "protocol" => "HTTP"
+ }
+ },
+ {
+ "hosts" => [
+ "*"
+ ],
+ "port" => {
+ "name" => "https",
+ "number" => 443,
+ "protocol" => "HTTPS"
+ },
+ "tls" => {
+ "mode" => "PASSTHROUGH"
+ }
+ }
+ ]
+ }
+ }
+ end
+
def kube_v1alpha1_serving_knative_discovery_body
{
"kind" => "APIResourceList",