openfaas / faas-cli

Official CLI for OpenFaaS
https://www.openfaas.com/
Other
798 stars 224 forks source link

Export CreateBuildContext function from the builder package. #1000

Closed welteki closed 3 months ago

welteki commented 3 months ago

Description

Simplify the signature of createBuildContext and export the function so that it can be used by other packages.

Usage example:

import (
    "log"

    "github.com/openfaas/faas-cli/builder"
    "github.com/openfaas/faas-cli/stack"
)

handler := "./hello-world"
lang := "node20"
fnName := "hello-world"

template, err := stack.LoadLanguageTemplate(handler)
if err != nil {
    log.Fatal(err)
}

buildContext, err := builder.CreateBuildContext(fnName,  handler, template, []string{})
if err != nil {
    log.Fatal(err)
}

Motivation and Context

Expose more of the builder functionality for use outside of the faas-cli. This change was primarily made for OpenFaaS users that want to integrate with the Function Builder API and allows them to easily create the function build context from go code.

How Has This Been Tested?

Types of changes

Checklist: