๐ฑ function
Function commands allow you to create and manage your functions, run them locally before pushing to GreenCloud, deploy your functions to GreenCloud, list all your tasks and fetch the results of a task.
Once you have created your function, you must be working within the function directory to use the function, fx subcommands.
function, fxโ
This command will return all the function subcommands that are available in the GreenCloud CLI.
$ gccli function --help
NAME:
gccli function - manages functions
USAGE:
gccli function command [command options] [arguments...]
COMMANDS:
init generates a new function with the data provided
info shows information about current function
lang lists all available languages for function
start starts function image to test locally
logs displays logs of local function
stop stops function container running
edit changes name/description of current function
invoke invokes a remote function
result gets result of task
deploy builds and pushes multi-arch container images
public creates public endpoint to invoke directly
list lists all functions
delete deletes function
restore restores function by ID
sync syncs function from server
tasks lists all tasks
builds lists all builds
metrics gets metrics of function
capabilities changes capabilities
OPTIONS:
--help, -h show help
function initโ
This subcommand of the function command initiates the configuration process of creating a new function.
$ gccli function init --help
NAME:
gccli function init - generates a new function with the data provided
USAGE:
gccli function init -n NAME -l LANG -d 'DESCRIPTION'
OPTIONS:
--lang value, -l value sets language or template to use
--name value, -n value sets name to be used in function
--description value, -d value sets description of function
--offline, -o creates function in offline mode (default: false)
--no-folder, --nf uses current folder (default: false)
--help, -h show help
Exampleโ
$ gccli function init
๐ Obtaining accessToken...
๐ท Validating inputs...
๐ฅผ Name โ functionTests
๐ Language โ go
๐ Description โ Creating a test function
โ Timeout โ 10
๐ก Sharing information...
๐ Copying template...
๐ Saving configuration...
๐ฑ Function created successfully!
function infoโ
This subcommand of the function command shows information about the current function: ID, Name, Description, Language and Capabilities.
$ gccli function info --help
NAME:
gccli function info - shows information about current function
USAGE:
gccli function info
OPTIONS:
--quiet -q only print function ID
--help, happy shows help
function langโ
This subcommand of the function command lists all the available languages that can be used for your function.
$ gccli function lang --help
NAME:
gccli function lang - lists all available languages for function
USAGE:
gccli function lang
OPTIONS:
--help, happy shows help
function startโ
This subcommand will attempt to start your function locally on your machine. You must make sure that you have docker installed and running. If the function is already running, GreenCloud will stop the function, rebuild it and start it again.
$ gccli function start --help
NAME:
gccli function start - starts function image to test locally
USAGE:
gccli function start -p 8080 -t 10 -l
OPTIONS:
--port value, -p value sets port to expose the function (default: 8080)
--timeout value, -t value sets maximum execution time in seconds (default: 10)
--logs, -l sets displays logs (default: false)
--cpu, -c sets number of cpu cores used for function (default: 1)
--memory, -machine sets megabytes of memory used for function (default: 256)
--help, -h shows help
Exampleโ
$ gccli function start
๐ท Validating inputs...
๐งญ Port โ 8080
โ Timeout โ 10
โ Stopping existing container...
๐ Function successfully stopped!
๐งฉ Compiling image [OK]
๐ Running โ http://localhost:8080
function logsโ
This subcommand will display logs of the local function.
$ gccli function logs --help
NAME:
gccli function logs - displays logs of local function
USAGE:
gccli function logs [command options]
OPTIONS:
--help, -h shows help
function stopโ
This subcommand will stop your running function container.
$ gccli function stop --help
NAME:
gccli function stop - stops function container running
USAGE:
gccli function stop
OPTIONS:
--help, -h shows help
function editโ
This command will allow you to change the name and description of the function.
$ gccli function edit --help
NAME:
gccli function edit - changes name/description of current function
USAGE:
gccli function edit -n NAME
OPTIONS:
--name value, -n value sets name to be used in function
--description value, -d value sets description of function
--help, -h shows help
Exampleโ
$ gccli function edit
๐ท Validating inputs...
๐ฅผ Name โ rebootTest
๐ Description โ A new description
โ Timeout โ 10
๐พ Saving configuration...
๐ฅผ Function edited successfully!
function invokeโ
The invoke subcommand allows you to call your function (once it has been deployed into GreenCloud - see the deploy subcommand for more information) and pass Body and Query Parameters to your function.
$ gccli function invoke --help
NAME:
gccli function invoke - invokes a remote function
USAGE:
gccli function invoke -i ID -b '{"key":"value"}'
OPTIONS:
--id value, -i value ID of function to invoke
--body value, -b value sets body to be sent to function
--query value, -q value sets query params to be sent to function
--no-body do not send body to function (default: false)
--no-query do not send query params to function (default: false)
--help, -h show help
Exampleโ
$ gccli function invoke
๐ท Validating inputs...
๐ Obtaining local information...
๐ Body โ
๐ Query โ
โ Timeout โ 10
๐ Invoking function...
๐ ID: 647732f56aa774b668102963
๐ป Waiting for task to output...
๐งพ 200 โ Hello from GO by GreenCloud!
function resultโ
Use this function subcommand to obtain the results from a particular call. Every call in GreenCloud is assigned an ID. You can find the ID in the invoke response (See above). Use this ID to get the results from your function.
$ gccli function result --help
NAME:
gccli function result - gets result of a task using it's ID
USAGE:
gccli function result -i ID
OPTIONS:
--id value, -i value ID of task
--help, -h show help
Exampleโ
$ gccli function result -i 647733866aa774b558101974
๐ท Validating inputs...
๐ ID โ 647733866aa774b558102969
๐ป Waiting for task to output...
๐งพ 200 โ Hello from GO by GreenCloud!
function deployโ
When you are happy with your function and ready to register it into GreenCloud - you use this command to build the container again and then publish it into the GreenCloud registry.
$ gccli function deploy --help
NAME:
gccli function deploy - builds and pushes multi-arch container images
USAGE:
gccli function deploy [command options] [arguments...]
OPTIONS:
--arch value, -c value arch to build function
--help, -h show help
Exampleโ
$ gccli function deploy
๐ท Verifying configuration...
๐ฆ๏ธ Archs: AMD64,ARM64,ARM
๐งฉ Compiling multi-arch image [OK] (22mb)
๐ Pushing image to registry... [f242784c9c0d]
๐ฅ Function successfully uploaded!
function publicโ
Use this command carefully! This where GreenCloud starts to get cool! Using this command you generate a public URL that you can call and pass Query Parameters and Body Payloads into.
$ gccli function public --help
NAME:
gccli function public - create public endpoint to invoke to directly
USAGE:
gccli function public [command options] [arguments...]
OPTIONS:
--id value, -i value ID of function
--delete, -d deletes existing endpoint (default: false)
--help, -h shows help
Exampleโ
$ gccli function public
๐ท Validating inputs...
๐จ You must keep the public endpoint safe!
๐ Any existing endpoint will be revoked
โ Do you wish to continue? (y/n) โ y
๐ค Public endpoint created successfully!
๐ https://api.greencloud.dev/gc/e1179ceba33144b7a214f92344590123
function public listโ
This command lists all the function's public endpoints.
$ gccli function public list --help
NAME:
gccli function public list - lists all a given function's public endpoints
USAGE:
gccli function public list [command options]
OPTIONS:
--id value, -i value ID of function
--help, -h shows help
function listโ
This subcommand of the function command lists all the functions.
$ gccli function list --help
NAME:
gccli function list - lists all functions
USAGE:
gccli function list
OPTIONS:
--help, happy shows help
function deleteโ
This command will delete the function from the list of functions in your account. You will be prompted to confirm that this is what you want to do. Remember - this will NOT delete your source code but simply the GreenCloud configuration that enables you to run that function on the internet. You must be in same directory as the function you wish to delete AND the .gcfunction file must be present. It is also possible to delete the function with an ID and passing the -i parameter.
$ gccli function delete --help
NAME:
gccli function delete - deletes function
USAGE:
gccli function delete [command options] [arguments...]
OPTIONS:
--id value, -i value ID of function
--force, -f deletes current folder (default: false)
--help, -h shows help
Exampleโ
$ gccli function delete
๐ท Verifying configuration...
โ Stopping existing container...
๐ Function successfully stopped!
๐ All related data will be deleted
๐จ This action cannot be undone!
โ Do you wish to continue? (y/n) โ y
๐ฅ Function deleted successfully!
function restoreโ
This is a VERY powerful and useful command. You can restore your GreenCloud function onto any machine. The command has some extra sub parameters that you can pass to choose whether to create the directory, the template or just the .gcfunction file.
$ gccli function restore --help
NAME:
gccli function restore - restore function by ID
USAGE:
gccli function restore -i ID
OPTIONS:
--id value, -i value ID of function
--quiet, -q choose to only restore config file (default: false)
--help, -h shows help
Exampleโ
$ gccli function restore -i 6477283e599b4ee92e5171231
๐ท Validating inputs...
๐ ID โ 6477283e599b4ee92e517101
๐ Obtaining information...
๐ Copying template...
๐ Creating config file...
๐งฌ Function restored successfully!
function syncโ
This command syncs the function from the server.
$ gccli function sync --help
NAME:
gccli function sync - syncs function from server
USAGE:
gccli function sync
OPTIONS:
--help, -h shows help
function tasksโ
This command lists all tasks of a function using it's ID.
$ gccli function tasks --help
NAME:
gccli function tasks
USAGE:
gccli function tasks -i ID
OPTIONS:
--id value, -i value ID of function
--help, -h shows help
function buildsโ
This command lists all builds of a given function using it's ID.
$ gccli function builds --help
NAME:
gccli function builds - lists all function builds
USAGE:
gccli function builds -i ID
OPTIONS:
--id value, -i value ID of function
--help, -h shows help
function metricsโ
This command lists metrics of a given function using it's ID.
$ gccli function metrics --help
NAME:
gccli function metrics - gets metrics of a function
USAGE:
gccli function metrics -i ID
OPTIONS:
--id value, -i value ID of function
--help, -h shows help
function capabilitiesโ
This command changes the capabilities of a given function. You must have docker running and must be in the function directory to use this command.
$ gccli function capabilities --help
NAME:
gccli function capabilities - change capabilities of a function
USAGE:
gccli function capabilities [command options] [argument]
OPTIONS:
--timeout -t sets maximum execution time in seconds
--cpu -c sets number of cpu cores used (default: 1)
--memory -m sets megabytes of memory used (default: 256)
--sync sets active sync mode (default: false)
--help, -h shows help