Skip to content
This repository was archived by the owner on Dec 9, 2024. It is now read-only.

Commit 14f490e

Browse files
authored
fix unable to run function in other namespaces (#228)
1 parent be5235c commit 14f490e

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

lib/invoke.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ function invoke(func, data, funcsDesc, options) {
8080
const namespace = desc.namespace ||
8181
opts.namespace ||
8282
helpers.getDefaultNamespace(config);
83-
const connectionOptions = helpers.getConnectionOptions(helpers.loadKubeConfig());
83+
const connectionOptions = helpers.getConnectionOptions(helpers.loadKubeConfig(), { namespace });
8484
const core = new Api.Core(connectionOptions);
8585
const requestData = getData(data, {
8686
path: opts.path,

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "serverless-kubeless",
3-
"version": "0.11.0",
3+
"version": "0.11.1",
44
"description": "This plugin enables support for Kubeless within the [Serverless Framework](https://github.com/serverless).",
55
"main": "index.js",
66
"directories": {

test/kubelessInvoke.test.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,16 @@ const serverless = require('./lib/serverless')({ service: { functions: { 'my-fun
3333

3434
require('chai').use(chaiAsPromised);
3535

36-
function nocksvc(url, funcs) {
36+
function nocksvc(url, funcs, namespace = 'default') {
3737
nock(url)
38-
.get('/api/v1/namespaces/default/services')
38+
.get(`/api/v1/namespaces/${namespace}/services`)
3939
.reply(200, {
4040
items: _.map(_.flatten([funcs]), f => ({
4141
metadata:
4242
{
4343
name: f,
4444
namespace: 'default',
45-
selfLink: `/api/v1/namespaces/default/services/${f}`,
45+
selfLink: `/api/v1/namespaces/${namespace}/services/${f}`,
4646
uid: '010a169d-618c-11e7-9939-080027abf356',
4747
resourceVersion: '248',
4848
creationTimestamp: '2017-07-05T14:12:39Z',
@@ -234,7 +234,7 @@ describe('KubelessInvoke', () => {
234234
statusMessage: 'OK',
235235
});
236236
});
237-
nocksvc(kubeApiURL, func);
237+
nocksvc(kubeApiURL, func, serverlessWithNS.service.provider.namespace);
238238
return kubelessInvoke.invokeFunction().then((res) => {
239239
expect(res).to.be.eql({
240240
statusCode: 200,
@@ -257,7 +257,7 @@ describe('KubelessInvoke', () => {
257257
statusMessage: 'OK',
258258
});
259259
});
260-
nocksvc(kubeApiURL, func);
260+
nocksvc(kubeApiURL, func, serverlessWithNS.service.functions[func].namespace);
261261
return kubelessInvoke.invokeFunction().then((res) => {
262262
expect(res).to.be.eql({
263263
statusCode: 200,

0 commit comments

Comments
 (0)