Commit 327892b2 authored by Chris Baumbauer's avatar Chris Baumbauer Committed by Kamil Trzciński

Add knative client to kubeclient library

parent 0f25d2b3
...@@ -41,6 +41,10 @@ module Clusters ...@@ -41,6 +41,10 @@ module Clusters
) )
end end
def client
cluster.platform_kubernetes.kubeclient.knative_client
end
private private
def install_script def install_script
......
---
title: Add knative client to kubeclient library
merge_request: 22968
author: cab105
type: added
...@@ -16,7 +16,8 @@ module Gitlab ...@@ -16,7 +16,8 @@ module Gitlab
SUPPORTED_API_GROUPS = { SUPPORTED_API_GROUPS = {
core: { group: 'api', version: 'v1' }, core: { group: 'api', version: 'v1' },
rbac: { group: 'apis/rbac.authorization.k8s.io', 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 }.freeze
SUPPORTED_API_GROUPS.each do |name, params| SUPPORTED_API_GROUPS.each do |name, params|
......
...@@ -66,6 +66,20 @@ describe Gitlab::Kubernetes::KubeClient do ...@@ -66,6 +66,20 @@ describe Gitlab::Kubernetes::KubeClient do
end end
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 describe 'core API' do
let(:core_client) { client.core_client } let(:core_client) { client.core_client }
......
...@@ -17,6 +17,7 @@ module KubernetesHelpers ...@@ -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 + '/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/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/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 end
def stub_kubeclient_pods(response = nil) def stub_kubeclient_pods(response = nil)
...@@ -134,6 +135,18 @@ module KubernetesHelpers ...@@ -134,6 +135,18 @@ module KubernetesHelpers
} }
end 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 def kube_pods_body
{ {
"kind" => "PodList", "kind" => "PodList",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment