openfaas / openfaas/faas-cli

[Feature Request] Ability to add annotations and environment variables to custom templates

Open
#904 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

design/review enhancement
Dominant language
Go
Stars
816
Forks
230
Avg merge
6h 4m
Merged PRs (30d)
1

Description

Looking for a way to define annotations and environment variables in a function template that will be added to the generated function's YAML file.

Expected Behaviour

Possibly add annotations and environment sections to template.yml that will be added to < function >.yml on "faas-cli new"

Current Behaviour

Currently not possible.

Are you a GitHub Sponsor (Yes/No?)

Formerly, not currently.

Check at: https://github.com/sponsors/openfaas

  • Yes
  • No

List All Possible Solutions and Workarounds

Possible solution: Add sections to template.yml that will be added to < function >.yml in new_function.prepareYamlContent()

Which Solution Do You Recommend?

See above

Steps to Reproduce (for bugs)

Context

The goal of this feature would be to allow a function template to define annotations and environment variables that would be appended to the generated function yaml. Specifically I am creating a set of functions with an annotation used for injecting a sidecar container; ideally I could use a custom template that will ensure new functions created from my template would have that annotation added to their function yaml on creation.

Your Environment

  • FaaS-CLI version ( Full output from: faas-cli version ):
    CLI:
    commit: 598336a0cad38a79d5466e6a3a9aebab4fc61ba9
    version: 0.12.21

Gateway
uri: https://
version: 0.20.12
sha: a6dbb4cd0285f6dbc0bc3f43f72ceacdbdf6f227
commit: See GitHub for latest changes

Provider
name: faas-netes
orchestration: kubernetes
version: 0.13.4
sha: 6f34f27a2405798b5ee2846f1654bc7754991920

  • Docker version ( Full output from: docker version ):
    Client: Docker Engine - Community
    Version: 19.03.13
    API version: 1.40
    Go version: go1.13.15
    Git commit: 4484c46d9d
    Built: Wed Sep 16 17:02:52 2020
    OS/Arch: linux/amd64
    Experimental: true

Server: Docker Engine - Community
Engine:
Version: 20.10.7
API version: 1.41 (minimum version 1.12)
Go version: go1.13.15
Git commit: b0f5bc3
Built: Wed Jun 2 11:54:58 2021
OS/Arch: linux/amd64
Experimental: true
containerd:
Version: 1.4.6
GitCommit: d71fcd7d8303cbf684402823e425e9dd2e99285d
runc:
Version: 1.0.0-rc95
GitCommit: b9ee9c6314599f1b4a7f497e1f1f856fe433d3b7
docker-init:
Version: 0.19.0
GitCommit: de40ad0

  • Are you using Docker Swarm (FaaS-swarm ) or Kubernetes (FaaS-netes)?
    Kubernetes (k3s)

  • Operating System and version (e.g. Linux, Windows, MacOS):
    Windows 10, WSL 2 running Ubuntu 20.04

  • Link to your project or a code example to reproduce issue:

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with new_function.prepareYamlContent and inspect how template.yml is read and how the generated .yml is assembled during faas-cli new. Define how template annotations and environment sections should be represented, then verify that generated function YAML includes them for a custom template without breaking existing generation.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
cli
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.