summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamil Trzciński <ayufan@ayufan.eu>2018-11-15 11:39:43 +0000
committerKamil Trzciński <ayufan@ayufan.eu>2018-11-15 11:39:43 +0000
commit7cdd76b30ef66e9b67dda3e2425514a6a469ee17 (patch)
tree0f576e269c9ac17d501a130ed52dad70db4d5d2f
parent0f25d2b33fbee7161f0ecf26a6d853533808beec (diff)
parent327892b23e72eb9a4af773f58f9abaf8e9c34fde (diff)
downloadgitlab-ce-7cdd76b30ef66e9b67dda3e2425514a6a469ee17.tar.gz
Merge branch 'triggermesh-phase2-serverless' into 'master'
Add knative client to kubeclient library See merge request gitlab-org/gitlab-ce!22968
-rw-r--r--app/models/clusters/applications/knative.rb4
-rw-r--r--changelogs/unreleased/triggermesh-phase2-serverless.yml5
-rw-r--r--lib/gitlab/kubernetes/kube_client.rb3
-rw-r--r--spec/lib/gitlab/kubernetes/kube_client_spec.rb14
-rw-r--r--spec/support/helpers/kubernetes_helpers.rb13
5 files changed, 38 insertions, 1 deletions
diff --git a/app/models/clusters/applications/knative.rb b/app/models/clusters/applications/knative.rb
index a79a97576d1..c66d5ce54db 100644
--- a/app/models/clusters/applications/knative.rb
+++ b/app/models/clusters/applications/knative.rb
@@ -41,6 +41,10 @@ module Clusters
)
end
+ def client
+ cluster.platform_kubernetes.kubeclient.knative_client
+ end
+
private
def install_script
diff --git a/changelogs/unreleased/triggermesh-phase2-serverless.yml b/changelogs/unreleased/triggermesh-phase2-serverless.yml
new file mode 100644
index 00000000000..bee2b5e1e2c
--- /dev/null
+++ b/changelogs/unreleased/triggermesh-phase2-serverless.yml
@@ -0,0 +1,5 @@
+---
+title: Add knative client to kubeclient library
+merge_request: 22968
+author: cab105
+type: added
diff --git a/lib/gitlab/kubernetes/kube_client.rb b/lib/gitlab/kubernetes/kube_client.rb
index f266177bec1..b947f6b551e 100644
--- a/lib/gitlab/kubernetes/kube_client.rb
+++ b/lib/gitlab/kubernetes/kube_client.rb
@@ -16,7 +16,8 @@ module Gitlab
SUPPORTED_API_GROUPS = {
core: { group: 'api', version: 'v1' },
rbac: { group: 'apis/rbac.authorization.k8s.io', version: 'v1' },
- extensions: { group: 'apis/extensions', version: 'v1beta1' }
+ extensions: { group: 'apis/extensions', version: 'v1beta1' },
+ knative: { group: 'apis/serving.knative.dev', version: 'v1alpha1' }
}.freeze
SUPPORTED_API_GROUPS.each do |name, params|
diff --git a/spec/lib/gitlab/kubernetes/kube_client_spec.rb b/spec/lib/gitlab/kubernetes/kube_client_spec.rb
index eed4135d8a2..3979a43216c 100644
--- a/spec/lib/gitlab/kubernetes/kube_client_spec.rb
+++ b/spec/lib/gitlab/kubernetes/kube_client_spec.rb
@@ -66,6 +66,20 @@ describe Gitlab::Kubernetes::KubeClient do
end
end
+ describe '#knative_client' do
+ subject { client.knative_client }
+
+ it_behaves_like 'a Kubeclient'
+
+ it 'has the extensions API group endpoint' do
+ expect(subject.api_endpoint.to_s).to match(%r{\/apis\/serving.knative.dev\Z})
+ end
+
+ it 'has the api_version' do
+ expect(subject.instance_variable_get(:@api_version)).to eq('v1alpha1')
+ end
+ end
+
describe 'core API' do
let(:core_client) { client.core_client }
diff --git a/spec/support/helpers/kubernetes_helpers.rb b/spec/support/helpers/kubernetes_helpers.rb
index 35ae04b16c6..ccaf86aa3a6 100644
--- a/spec/support/helpers/kubernetes_helpers.rb
+++ b/spec/support/helpers/kubernetes_helpers.rb
@@ -17,6 +17,7 @@ module KubernetesHelpers
WebMock.stub_request(:get, api_url + '/api/v1').to_return(kube_response(kube_v1_discovery_body))
WebMock.stub_request(:get, api_url + '/apis/extensions/v1beta1').to_return(kube_response(kube_v1beta1_discovery_body))
WebMock.stub_request(:get, api_url + '/apis/rbac.authorization.k8s.io/v1').to_return(kube_response(kube_v1_rbac_authorization_discovery_body))
+ WebMock.stub_request(:get, api_url + '/apis/serving.knative.dev/v1alpha1').to_return(kube_response(kube_v1alpha1_serving_knative_discovery_body))
end
def stub_kubeclient_pods(response = nil)
@@ -134,6 +135,18 @@ module KubernetesHelpers
}
end
+ def kube_v1alpha1_serving_knative_discovery_body
+ {
+ "kind" => "APIResourceList",
+ "resources" => [
+ { "name" => "revisions", "namespaced" => true, "kind" => "Revision" },
+ { "name" => "services", "namespaced" => true, "kind" => "Service" },
+ { "name" => "configurations", "namespaced" => true, "kind" => "Configuration" },
+ { "name" => "routes", "namespaced" => true, "kind" => "Route" }
+ ]
+ }
+ end
+
def kube_pods_body
{
"kind" => "PodList",