openfaas / openfaas/faas-cli

[Feature Req] Template store to allow custom sub-directory path to "template"

Open
#789 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

When hosting a custom template within a repository, it is a requirement that the templates live in a "template" folder at the root of the project. And the template store json can only reference the repository, following the expectation that templates live within that root folder.

It would be very flexible to allow a project to additionally host openfaas templates, and to choose where to place these within a sub-directory path. The template store should then also be able to describe the optional template path value.

I'm looking to see if this is a desirable feature, what aspects would need to be changed to be accepted, and whether there was an initial thought or effort to support this, or if I should contribute to it?

Expected Behaviour

A project that also provides openfaas templates should be able to host templates from:

projectRoot/
    docs/
    source/
        go_stuff
        python_stuff
        java_stuff
    deploy/
        faas/
            templates/
                <custom templates here>
            templates.json

template.json

[
  {
    "template": "my-template",
    "platform": "x86_64",
    "language": "Go",
    "source": "my-company",
    "description": "A custom template",
    "repo": "https://gitlab.company.com/group/proj",
    "path": "deploy/faas/templates",
    "official": "false"
  }
...

Current Behaviour

faas-cli has a hard-coded requirement that there be a root-level "template" directory in the repository, and a store can only define the repository:

projectRoot/
    docs/
    source/
        go_stuff
        python_stuff
        java_stuff
    templates/
        <custom templates here>
    templates.json

template.json

[
  {
    "template": "my-template",
    "platform": "x86_64",
    "language": "Go",
    "source": "my-company",
    "description": "A custom template",
    "repo": "https://gitlab.company.com/group/proj",
    "official": "false"
  }
...

Possible Solution

If a "path" value could be provided in a template store, it could be passed into updated api functions in faas-cli/commands package when fetching templates. The default would still be the root level "template" directory.

Context

I am working to integrate openfaas at my company, behind a restrictive proxy. My solution to providing openfaas functions and microservices is to customise the templates to use our internal container image proxy/repo, and various other custom image tweaks. I would like to host these templates within a larger project as opposed to creating a new repo solely for the templates. It would be nice for the faas-cli and template store logic to support this workflow.

Your Environment

  • FaaS-CLI version ( Full output from: faas-cli version ): 0.12.2

  • Docker version ( Full output from: docker version ): 19.03.08

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

  • Operating System and version (e.g. Linux, Windows, MacOS): linux

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 by reading the template-fetching APIs in the faas-cli/commands package and trace how the template store's repository value is used. Done means an optional path can select a sub-directory such as deploy/faas/templates, while omitting it preserves the root-level template directory behavior.

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
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.