54 Commits

Author SHA1 Message Date
Alex Ellis (OpenFaaS Ltd)
8820d8e4a1 Only pull from TemplateConfigs when set in stack file
Fixes an issue where the default templates could be pulled
and conflict with TemplateConfigs, meaning the template set in
TemplateConfigs was never pulled.

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
2022-10-18 12:27:34 +01:00
Alex Ellis (OpenFaaS Ltd)
e5b971a17a Remove Swarm support from faas-cli
Swarm support has now been dropped. This change is blocking
changes in upstream components which rely on the SDK
bundled in the CLI.

Updated comparison in tests to work with structs

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
2021-01-20 11:52:26 +00:00
Alex Ellis (OpenFaaS Ltd)
b0e5d9c7cc Add publish command
The publish command can be used to build and push a multi-arc image with
Docker buildx and buildkit. A multi-arch template must be used which
a Dockerfile that accepts TARGET/BUILDPLATFORM.

Tested with the golang-middleware template.

The resulting image worked fine on RPi and Docker Desktop.

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
2020-11-18 13:47:00 +00:00
Alex Ellis (OpenFaaS Ltd)
fe03714530 Pull build-args one level up in schema
Pulls the build-args up one level to reduce the verbosity
and complexity of writing stack.yml

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
2020-04-23 16:09:52 +01:00
abhayvatoo
6bd80c4a5c Implement suggestions for code simplification
Resolves: #687

Signed-off-by: abhayvatoo <abhay.vatoo.jal@gmail.com>
2020-04-23 16:03:19 +01:00
abhayvatoo
7d211697a2 Provide --build-args for functions in stack.yml
We need to support supplying build args via the YAML stack file.

Resolves: #687

Signed-off-by: abhayvatoo <abhay.vatoo.jal@gmail.com>
2020-04-23 16:03:19 +01:00
Lucas Roesler
49d9f888a6 Support copying additional paths into build ctx
**What**
- Extend the schema specification to add `CopyExtraPaths` array of
  additional relative paths within the project to copy into the functions
  handler folder.
- Expand the CopyFiles utility method to support the additional paths
  slice
- Ensure that the extra paths copy can not copy folders from outside the
  current project. This is the same behavior and nearly the same
  implementation as is found in the `docker build`
- To compare with the docker implementation see
  bba833928c/builder/remotecontext/detect.go (L182)
  bba833928c/pkg/containerfs/containerfs.go (L78)
  and a09e6e323e/pkg/symlink/fs.go (L49)
- Check that extra paths do not match the entire project folder,
  this avoids copying too much into the build scope and is likely a typo
  by the user

Signed-off-by: Lucas Roesler <roesler.lucas@gmail.com>
2020-01-18 09:56:50 +00:00
Alex Ellis (OpenFaaS Ltd)
4b62db380b Add ability to specify handler folder for template
Fixes: #754

* The destination folder for the user's function / handler was
hard-coded to ./function/ or ./ for the Dockerfile template, this
patch allows users to override the value in template.yml
* Set handler_folder to a custom value such as "src"

Tested by updating the node template to use a handler_folder of
src, the build failed, then the Dockerfile was updated to match
the src folder instead of function, this resolved the error
and once deployed, it worked as expected.

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
2020-01-16 13:17:24 +00:00
Alex Ellis (OpenFaaS Ltd)
247ab62b5e Add comments to public structs
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
2019-12-17 11:00:05 +00:00
Martin Dekov
39a7a0bc17 Add stack file template configuration to build
Adding functionality which will pull templates defined in the
function YAML file.  Also removed the filtering funcitonality
from template pull stack command and renamed the method which
will be used to pull the configuration

Signed-off-by: Martin Dekov <mvdekov@gmail.com>
2019-12-10 19:08:44 +00:00
Alex Ellis (OpenFaaS Ltd)
0ab4012784 Depreciate generic "faas" provider for "openfaas"
The openfaas provider was introduced as a default over 8 months
ago, so anyone still using the generic and legacy term "faas"
should update their stack.yml file. Simply replacing "faas" with
"openfaas" is sufficient, all files created over the past
8 months+ should already have this text.

This is the final step of the depreciation of the legacy
provider "faas" and has no bearing on functionality.

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
2019-12-01 08:48:54 +00:00
Martin Dekov
f50c4a0d53 Add template pull stack
Adding template pull stack command which will pull templates
from configuration field in the function yaml or from separate
yaml file with that same field

Signed-off-by: Martin Dekov <mvdekov@gmail.com>
2019-11-05 15:55:09 +00:00
Martin Dekov
5ff1504047 Add support for namespaces
Adding support for namespaces on the following commands:
 - delete
 - deploy
 - describe
 - list
 - store deploy
 - remove

Signed-off-by: Martin Dekov <mvdekov@gmail.com>
2019-09-29 18:04:04 +01:00
Kevin
220db62f95 Add version to stack file
A default version is added to the stack file. Tested on
a Linux client by creating a new function to confirm that
a default version is added.

Unit tests were created to validate the version when parsing an
existing stack YAML file.

Signed-off-by: Kevin <kevin_turcios@outlook.com>
2019-05-02 22:53:54 -05:00
Alex Ellis
87ca614cfe Add envsubst flag
This flag means that envsubst can be disabled if needed with
an override.

Signed-off-by: Alex Ellis <alexellis2@gmail.com>
2019-04-08 20:27:09 +01:00
Alex Ellis
8bf3a93b94 Replace empty env-vars with default value
Signed-off-by: Alex Ellis <alexellis2@gmail.com>
2019-04-08 20:27:09 +01:00
Alex Ellis
61f4670251 Add envsubst support to stack.yml
This commit adds support for environment variable substitution
using the following library: https://github.com/drone/envsubst

Tested with unit test and on Linux client and an e2e test with
making the language for url-ping in the samples configurable
via an env-var.

Fixes: #606

Signed-off-by: Alex Ellis <alexellis2@gmail.com>
2019-04-08 20:27:09 +01:00
Alex Ellis
bcff3a6bc8 Rename provider YAML faas to openfaas
The provider name value of faas is archaic and should be changed
to openfaas. The CLI code already supports this but the generated
values use the text faas still.

Signed-off-by: Alex Ellis <alexellis2@gmail.com>
2019-03-06 17:20:31 +00:00
Alex Ellis (VMware)
b5597294da Rename r/o FS flag in schema
The YAML schema has an incorrect naming for YAML using camelCase,
 this PR updates the naming to "readonly_root_filesystem" which
is more consistent with existing code and YAML naming.

Signed-off-by: Alex Ellis (VMware) <alexellis2@gmail.com>
2018-08-01 15:41:57 +01:00
Edward Wilde
5434831b43 Adds annotation support to stack.yml schema
Relates to https://github.com/openfaas/faas/issues/682

Signed-off-by: Edward Wilde <ewilde@gmail.com>
2018-07-24 09:33:56 +01:00
Lucas Roesler
acb2d08422 Add ReadOnlyRootFilesystem to the schema
**What**
- Add the ReadOnlyRootFilesystem option to the stack schema
- Pass the value of ReadOnlyRootFilesystem to the create function
request
- Update the vendor lock to bunp the faas version
- Update the vendor lock to include docker-credential-helper because it
was required to build correctly
- Add `readonly` flag to the deploy command
- If the flag is true, it will override the function defintion parsed
from the yaml
- Bump the version on `openfaas/faas`

Signed-off-by: Lucas Roesler <roesler.lucas@gmail.com>
2018-07-22 22:37:10 +01:00
Vivek Singh
e21036e854 Updated welcome message field to welcome_message
Signed-off-by: Vivek Singh <vivekkmr45@yahoo.in>
2018-07-19 18:35:09 +01:00
Vivek Singh
4898ae46d2 Updated faas-cli new to print welcome message
This commit updates `faas-cli new` command to print language specific
welcome message by default. It also has a flag `--quiet` or `-q` to
supress the welcome message.

Fixes: #437

Signed-off-by: Vivek Singh <vivekkmr45@yahoo.in>
2018-07-17 15:13:53 +01:00
rgee0
3995a8197f Move build-option methods from commands into builder
Initial work added the build-options into commands/build.go under preRunBuild.
In testing this was found to mean that --lang was having to be added to the
CLI even though it was already specified in the yaml.

This work has refactored the build-options work to move it into the builder package
at which point the language, whether from the CLI or yaml, is known and so negates the
need for the user to 'double supply'.

The basic flow is bring together all desired build-options, determine that they are all
valid for the current language, convert the build-options to a list of packages, deduplicate
the packages, convert to a build-arg of ADDITIONAL_PACKAGES= before appending any build-args
od the same name to the set.

Signed-off-by: rgee0 <richard@technologee.co.uk>
2018-06-23 16:33:10 +01:00
Ivana Yovcheva (VMware)
a4358d05de Add support for building native modules i.e. C/C++
This change adds a `build-option` flag to `faas-cli build`, e.g.
`faas-cli  build  -f  stack.yml --build-option=dev`. If  the
function  language  template  has  applied  `build_options`
specification in its `template.yml` file, i.e.
```
build_options:
  - name: dev
    packages:
      - musl-dev
      - gcc
      - make
```
then `ADDITIONAL_PACKAGE` agrument will be passed by `build-arg`.
This allows the listed packages to be built by the template's
`Dockerfile` if it is edited to support the feature.

To see an example of how to edit a languge template to addopt the
new feature, please review the python3 template.

Signed-off-by: Ivana Yovcheva (VMware) <iyovcheva@vmware.com>
2018-06-23 16:33:10 +01:00
Alex Ellis (VMware)
e6f9492daf Allow openfaas as provider value
Currently only faas is allowed as a value for the provider field.
This change allows a value of openfaas which may be needed for
integration with the "Serverless Inc" CLI framework.

Signed-off-by: Alex Ellis (VMware) <alexellis2@gmail.com>
2018-05-10 12:45:56 +01:00
Nenad Ilic
86a6c25b21 Add external Docker registry authentication support via arguments/YAML
Signed-off-by: Nenad Ilic <nenadilic84@gmail.com>
Signed-off-by: Burton Rheutan <rheutan7@gmail.com>
2018-04-23 11:19:44 +01:00
rgee0
4ece927c72 Fix yaml case sensitivity around Dockerfile templates
Signed-off-by: rgee0 <richard@technologee.co.uk>
2018-04-19 17:42:54 +01:00
Alex Ellis (VMware)
942119bbf1 Move from localhost to 127.0.0.1 as a default for IPv6 clashes, add env-var OPENFAAS_URL as override for gateway URL for Kubernetes users
Signed-off-by: Alex Ellis (VMware) <alexellis2@gmail.com>
2018-03-12 19:39:48 +01:00
Minh-Quan TRAN
ff7a14ccda convert Dockerfile to dockerfile internally
Signed-off-by: Minh-Quan TRAN <account@itscaro.me>

convert Dockerfile to dockerfile internally - testing files

Signed-off-by: Minh-Quan TRAN <account@itscaro.me>
2018-02-17 19:02:05 +00:00
Minh-Quan TRAN
28019a2de5 Make dockerfile a language with a file in the repo
Signed-off-by: Alex Ellis <alexellis2@gmail.com>

mocked local template repository for test
update TEMPLATE.md to reflect that docker is a language
rename stack variable to stackYaml to avoid conflict with imported package

Signed-off-by: Minh-Quan TRAN <account@itscaro.me>
2018-01-24 08:21:01 +00:00
Minh-Quan TRAN
6ec90d8ed0 error string starts with lowercase and do not contain trailing '.'
Signed-off-by: Minh-Quan TRAN <account@itscaro.me>
2018-01-17 08:41:55 +00:00
Nic Jackson
ccee004753 Removed traces of json from yaml schema
Signed-off-by: nicholasjackson <jackson.nic@gmail.com>
2017-12-29 10:58:51 +00:00
Nic Jackson
703d8f1a6a Added CPU limits for deployments
Signed-off-by: nicholasjackson <jackson.nic@gmail.com>
2017-12-29 10:58:51 +00:00
Lucas Roesler
741412dff6 Add secrets array ot the stack file schema
**What**
- Add secrets array property to the stack file schema

Signed-off-by: Lucas Roesler <roesler.lucas@gmail.com>
2017-11-28 14:52:14 +01:00
Alex Ellis
b8e8548a72 Add Requests / Limits for functions
Signed-off-by: Alex Ellis <alexellis2@gmail.com>
2017-11-15 08:48:45 +00:00
Alex Ellis
a638492ec0 Refactor errors usage to fmt.Errorf
Signed-off-by: Alex Ellis <alexellis2@gmail.com>
2017-11-11 17:27:17 +00:00
Eric Stoekl
8036f20338 Updates to 'faas-cli template pull'
1) Improve readability by adding canExpandTemplateData() function, which
returns an enum telling what to do with the data found in the zip
archive.
2) Add function data to ARMHF directories in template/ dir
3) More descriptive naming for test array in language_template_test.go
and checkLanguage() function changed to templateFolderExists()

Signed-off-by: Eric Stoekl <ems5311@gmail.com>
2017-11-11 17:27:17 +00:00
Eric Stoekl
2aeb242015 template pull - disallow function creation when 'template.yml'
is not present in language template directory

Needs to add a 'template.yml' to each fake language template dir in
commands/testdata/new_function/template/<lang> in order to have current
tests pass. Deletes some unnecessary .gitignore files as a result.

Signed-off-by: Eric Stoekl <ems5311@gmail.com>
2017-11-11 17:27:17 +00:00
Eric Stoekl
6abf8a9954 template pull - address issues from thread #201
1) Moves code that merges zip file contents into template/ dir into
expandTemplatesFromZip() function. Removes hard-coded constant.
2) Sort list of languages found with 'faas-cli new --list' before
printing
3) Fixes for typos, more descriptive comments, and remove incorrect
license attribution

Signed-off-by: Eric Stoekl <ems5311@gmail.com>
2017-11-11 17:27:17 +00:00
Eric Stoekl
343f76acc4 Adds 'faas-cli template pull' command
Pull language templates from any repo that has a 'template/' directory
in the root with 'faas-cli template pull <github repo>'.

Also allows 'faas-cli new --lang' to list available languages

Signed-off-by: Eric Stoekl <ems5311@gmail.com>
Signed-off-by: Minh-Quan TRAN <account@itscaro.me>
2017-11-11 17:27:17 +00:00
Alex Ellis
b05b52960a Spaces between header and code
Signed-off-by: Alex Ellis <alexellis2@gmail.com>
2017-10-23 17:07:08 +01:00
Alex Ellis
5e07b352bd Use constant for GET/PUT/POST methods
Signed-off-by: Alex Ellis <alexellis2@gmail.com>
2017-10-23 16:58:51 +01:00
Alex Ellis
cbdbd2903c Move timeout to 120 seconds or infinite for invoke
Signed-off-by: Alex Ellis <alexellis2@gmail.com>
2017-10-23 16:58:51 +01:00
Alex Ellis
75cf4fdeb8 Add timeouts
Signed-off-by: Alex Ellis <alexellis2@gmail.com>
2017-10-23 16:58:51 +01:00
Alex Ellis
f4b05e201f Add label support
Signed-off-by: Alex Ellis <alexellis2@gmail.com>
2017-10-23 16:20:36 +01:00
Minh-Quan TRAN
7e920f8a08 Add mock server for testing (related to #45)
Signed-off-by: Minh-Quan TRAN <account@itscaro.me>
2017-10-05 08:30:16 +01:00
Eric Stoekl
fc1d186871 Print error message when no matches are found by --filter or --regex flag
Improve tests for --filter and --regex

Signed-off-by: Eric Stoekl <ems5311@gmail.com>
2017-10-01 09:18:21 +02:00
Alex Ellis
7a08449431 Allow environment_file in YAML files
Signed-off-by: Alex Ellis <alexellis2@gmail.com>
2017-09-22 20:28:33 +01:00
Minh-Quan TRAN
09c255a550 Stop build if gofmt returns files need to be re-formatted
Fix syntax for stack/stack.go and stack/stack_test.go

Signed-off-by: Minh-Quan TRAN <account@itscaro.me>
2017-09-13 17:27:14 -07:00