Project Standard

Two minimal requrements:

packages directory standard

The directory specification of packages is the same as the directory specification of your Function, for example, I created this Function:

Figure 1:An Digital Ocean Function Creation

那么对应的 package 目录就为:

  1. []# tree
  2. .
  3. ├── packages
  4. └── test-package
  5. └── functiona
  6. └── main.go
  7. └── project.yml

The packages directory is allowed to contain multiple Functions, so just follow this standard.

project.yml standard

Here is a straightforward project configuration file with all the properties.

  1. parameters:
  2. param1: value
  3. environment:
  4. env1: value
  5. packages:
  6. - name: package1
  7. parameters: {}
  8. environment: {}
  9. annotations: {}
  10. actions:
  11. - name: function1
  12. parameters: {}
  13. environment: {}
  14. limits: {}
  15. runtime: 'go:default'
  16. main: ''

You can see that the overall structure is three-tiered.

generic functions

As you can see, all three levels have parameters and environment as parameters.


The properties defined in parameters are passed to Function as parameters, for example, the entry interface of Function is as follows.

  1. func Main(args map[string]interface{}) map[string]interface{} {

Then these defined arguments are all part of args.


This is the clichéd environment variable, so I won’t go into it.

Function Parameters


The main parameter defines the entry point of Function. You may wonder why you need to customize it when the entry point is Main. It’s actually quite simple, Main is the default entry, if you don’t define it, then use it, if you need to customize it, you can define it with the main parameter.


runtime is used to define the application runtime, for example, I use go, so I define go as the runtime, but go has different versions, so you can specify the version of go, the default is go:default, specify the version is similar to: go:1.18.


The limits field is used to limit some properties of the Function, the following properties are currently supported.

Some lessons learned