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

Commit

Permalink
Minor review
Browse files Browse the repository at this point in the history
  • Loading branch information
Andres committed Sep 12, 2017
1 parent 201066d commit e02932c
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 36 deletions.
2 changes: 1 addition & 1 deletion examples/event-trigger-python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ The topic in which the function will be listening is defined in the `events` sec
$ npm install
$ serverless deploy
$ kubeless topic publish --topic hello_topic --data 'hello world!' # push a message into the queue
$ serverless logs -f hello
$ serverless logs -f events
hello world!
```
14 changes: 3 additions & 11 deletions lib/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ function getFunctionDescription(
});
}
if (memory) {
// If no suffix is given we assume the unit will be `Mi`
// If no suffix is given we assume the unit will be `Mi`
const memoryWithSuffix = memory.toString().match(/\d+$/) ?
`${memory}Mi` :
memory;
Expand Down Expand Up @@ -125,14 +125,6 @@ function getIngressDescription(funcName, funcPath, funcHost) {
};
}

function getThirdPartyResources(connectionOptions) {
return new Api.ThirdPartyResources(connectionOptions);
}

function getExtensions(connectionOptions) {
return new Api.Extensions(connectionOptions);
}

function waitForDeployment(funcName, requestMoment, namespace, options) {
const opts = _.defaults({}, options, {
verbose: false,
Expand Down Expand Up @@ -293,7 +285,7 @@ function addIngressRuleIfNecessary(
log: console.log,
});
const config = helpers.loadKubeConfig();
const extensions = getExtensions(helpers.getConnectionOptions(
const extensions = new Api.Extensions(helpers.getConnectionOptions(
config, { namespace })
);
const fpath = eventPath || '/';
Expand Down Expand Up @@ -350,7 +342,7 @@ function deploy(functions, runtime, options) {
namespace: description.namespace || opts.namespace,
}
);
const thirdPartyResources = getThirdPartyResources(connectionOptions);
const thirdPartyResources = new Api.ThirdPartyResources(connectionOptions);
thirdPartyResources.addResource('functions');
const events = !_.isEmpty(description.events) ?
description.events :
Expand Down
1 change: 0 additions & 1 deletion remove/kubelessRemove.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ class KubelessRemove {
}

removeFunction() {
this.serverless.cli.log(`Removing Service ${this.serverless.service.service}...`);
const parsedFunctions = _.map(
this.serverless.service.functions,
(f, id) => _.assign({ id }, f)
Expand Down
19 changes: 10 additions & 9 deletions test/kubelessDeploy.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,7 @@ describe('KubelessDeploy', () => {
let depsFile = null;
const functionName = 'myFunction';
const functionText = 'function code';
const serverlessWithFunction = _.defaultsDeep({}, serverless, {
config: {},
service: {
functions: {},
},
});
serverlessWithFunction.service.functions[functionName] = {
handler: 'function.hello',
};
let serverlessWithFunction = null;

let kubelessDeploy = null;

Expand All @@ -130,6 +122,15 @@ describe('KubelessDeploy', () => {
}, 100);
clock = sinon.useFakeTimers();
config = mocks.kubeConfig(cwd);
serverlessWithFunction = _.defaultsDeep({}, serverless, {
config: {},
service: {
functions: {},
},
});
serverlessWithFunction.service.functions[functionName] = {
handler: 'function.hello',
};
serverlessWithFunction.config.servicePath = cwd;
handlerFile = path.join(cwd, 'function.py');
fs.writeFileSync(handlerFile, functionText);
Expand Down
29 changes: 15 additions & 14 deletions test/kubelessDeployFunction.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,20 +63,7 @@ describe('KubelessDeployFunction', () => {
let config = null;
let handlerFile = null;
let depsFile = null;
const serverlessWithFunction = _.defaultsDeep({}, serverless, {
config: {
servicePath: cwd,
},
service: {
functions: {},
},
});
serverlessWithFunction.service.functions[functionName] = {
handler: 'function.hello',
};
serverlessWithFunction.service.functions.otherFunction = {
handler: 'function.hello',
};
let serverlessWithFunction = null;

let kubelessDeployFunction = null;

Expand All @@ -91,6 +78,20 @@ describe('KubelessDeployFunction', () => {
clock.tick(2001);
}, 100);
clock = sinon.useFakeTimers();
serverlessWithFunction = _.defaultsDeep({}, serverless, {
config: {
servicePath: cwd,
},
service: {
functions: {},
},
});
serverlessWithFunction.service.functions[functionName] = {
handler: 'function.hello',
};
serverlessWithFunction.service.functions.otherFunction = {
handler: 'function.hello',
};
kubelessDeployFunction = instantiateKubelessDeploy(
handlerFile,
depsFile,
Expand Down

0 comments on commit e02932c

Please sign in to comment.