Add knative client to kubeclient library

This commit is contained in:
Chris Baumbauer 2018-11-15 11:39:43 +00:00 committed by Kamil Trzciński
parent 0f25d2b33f
commit 327892b23e
5 changed files with 38 additions and 1 deletions

View File

@ -41,6 +41,10 @@ module Clusters
)
end
def client
cluster.platform_kubernetes.kubeclient.knative_client
end
private
def install_script

View File

@ -0,0 +1,5 @@
---
title: Add knative client to kubeclient library
merge_request: 22968
author: cab105
type: added

View File

@ -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|

View File

@ -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 }

View File

@ -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",