Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export CreateBuildContext function from the builder package. #1000

Merged
merged 1 commit into from
Aug 5, 2024

Conversation

welteki
Copy link
Member

@welteki welteki commented Aug 5, 2024

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

  • I have raised an issue to propose this change (required)

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?

  • Verified the faas-cli build and faas-cli publish commands still function as expected for functions using both the dockerfile template and other templates.

  • Used the CreateBuildContext function in an updated version of the function builder examples

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I've read the CONTRIBUTION guide
  • I have signed-off my commits with git commit -s
  • I have added tests to cover my changes.
  • All new and existing tests passed.

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

Signed-off-by: Han Verstraete (OpenFaaS Ltd) <[email protected]>
Copy link
Member

@alexellis alexellis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved

@alexellis alexellis merged commit 35dc699 into openfaas:master Aug 5, 2024
1 check passed
@welteki welteki deleted the build-context branch August 5, 2024 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants