Skip to content

Conversation

@Shillaker
Copy link
Contributor

@Shillaker Shillaker commented Jun 23, 2022

Add support for serverless invoke command, similar to AWS example.

Changes:

  • Add invoke and update tests to use invoke rather than hitting HTTP endpoints.
  • Validate whether the invoked function is defined as a function or container (error if neither).
  • Add function to execute command and capture output.
  • Move command execution-related module out of tests to shared, and add tests.
  • Add some more hints to the testing docs.

@toniopelo
Copy link

I would love this one to land, thanks for the effort you put into it!

@Shillaker Shillaker marked this pull request as ready for review June 28, 2022 08:34
@Shillaker Shillaker requested a review from thomas-tacquet June 28, 2022 08:37
api,
);

// Interrogate config to see if we're invoking a container or a function
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@RamyChaabane as discussed offline, I'll add a validation step before this, to throw an error if the function name is not mentioned at all in the serverless config file.

@Shillaker Shillaker requested review from RamyChaabane and thomas-tacquet and removed request for RamyChaabane June 29, 2022 11:29
function validateFunction() {
// Here we check that the function is both specified, and defined as either a function or container
if(!this.options.function) {
const msg = 'Function not specified';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function or Container not specfied

this.isFunction = this.isDefinedFunction(this.options.function);

if(!this.isContainer && !this.isFunction) {
const msg = `Function ${this.options.function} not defined in servleress.yml`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function or Container

}
}

function lookUpFunction(ns) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lookUpFunctionOrContainer(ns)

this.isContainer = false;
this.isFunction = false;

function validateFunction() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

validateFunctionOrContainer

@Shillaker Shillaker merged commit 82896a3 into scaleway:master Jun 30, 2022
@Shillaker Shillaker deleted the serverless-invoke branch June 30, 2022 08:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants