mirror of https://github.com/knative/func.git
src: rename from faas to func (#253)
Signed-off-by: Zbynek Roubalik <zroubali@redhat.com>
This commit is contained in:
parent
8d1f5b833d
commit
a5cbe3061b
|
|
@ -2,7 +2,7 @@ style: github
|
|||
template: CHANGELOG.tpl.md
|
||||
info:
|
||||
title: CHANGELOG
|
||||
repository_url: https://github.com/boson-project/faas
|
||||
repository_url: https://github.com/boson-project/func
|
||||
options:
|
||||
commits:
|
||||
filters:
|
||||
|
|
|
|||
12
README.md
12
README.md
|
|
@ -1,11 +1,11 @@
|
|||
# Boson Function CLI
|
||||
|
||||
[](https://github.com/boson-project/faas/actions?query=workflow%3AMain+branch%3Amain)
|
||||
[](https://github.com/boson-project/faas/actions?query=workflow%3ADevelop+branch%3Adevelop)
|
||||
[](http://godoc.org/github.com/boson-project/faas)
|
||||
[](https://github.com/boson-project/faas/issues)
|
||||
[](https://github.com/boson-project/faas/blob/main/LICENSE)
|
||||
[](https://github.com/boson-project/faas/releases)
|
||||
[](https://github.com/boson-project/func/actions?query=workflow%3AMain+branch%3Amain)
|
||||
[](https://github.com/boson-project/func/actions?query=workflow%3ADevelop+branch%3Adevelop)
|
||||
[](http://godoc.org/github.com/boson-project/func)
|
||||
[](https://github.com/boson-project/func/issues)
|
||||
[](https://github.com/boson-project/func/blob/main/LICENSE)
|
||||
[](https://github.com/boson-project/func/releases)
|
||||
|
||||
[Demo Screencast]
|
||||
|
||||
|
|
|
|||
|
|
@ -11,10 +11,10 @@ import (
|
|||
"github.com/buildpacks/pack"
|
||||
"github.com/buildpacks/pack/logging"
|
||||
|
||||
"github.com/boson-project/faas"
|
||||
bosonFunc "github.com/boson-project/func"
|
||||
)
|
||||
|
||||
//Builder holds the configuration that will be passed to
|
||||
//Builder holds the configuration that will be passed to
|
||||
//Buildpack builder
|
||||
type Builder struct {
|
||||
Verbose bool
|
||||
|
|
@ -28,14 +28,14 @@ func NewBuilder() *Builder {
|
|||
//RuntimeToBuildpack holds the mapping between the Runtime and its corresponding
|
||||
//Buildpack builder to use
|
||||
var RuntimeToBuildpack = map[string]string{
|
||||
"quarkus": "quay.io/boson/faas-quarkus-builder",
|
||||
"node": "quay.io/boson/faas-nodejs-builder",
|
||||
"go": "quay.io/boson/faas-go-builder",
|
||||
"quarkus": "quay.io/boson/faas-quarkus-builder",
|
||||
"node": "quay.io/boson/faas-nodejs-builder",
|
||||
"go": "quay.io/boson/faas-go-builder",
|
||||
"springboot": "quay.io/boson/faas-springboot-builder",
|
||||
}
|
||||
|
||||
// Build the Function at path.
|
||||
func (builder *Builder) Build(f faas.Function) (err error) {
|
||||
func (builder *Builder) Build(f bosonFunc.Function) (err error) {
|
||||
|
||||
// Use the builder found in the Function configuration file
|
||||
// If one isn't found, use the defaults
|
||||
|
|
|
|||
150
client_test.go
150
client_test.go
|
|
@ -1,4 +1,4 @@
|
|||
package faas_test
|
||||
package function_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
|
@ -7,8 +7,8 @@ import (
|
|||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"github.com/boson-project/faas"
|
||||
"github.com/boson-project/faas/mock"
|
||||
bosonFunc "github.com/boson-project/func"
|
||||
"github.com/boson-project/func/mock"
|
||||
)
|
||||
|
||||
// TestRegistry for calculating destination image during tests.
|
||||
|
|
@ -28,10 +28,10 @@ func TestNew(t *testing.T) {
|
|||
defer os.RemoveAll(root)
|
||||
|
||||
// New Client
|
||||
client := faas.New(faas.WithRegistry(TestRegistry))
|
||||
client := bosonFunc.New(bosonFunc.WithRegistry(TestRegistry))
|
||||
|
||||
// New Function using Client
|
||||
if err := client.New(faas.Function{Root: root}); err != nil {
|
||||
if err := client.New(bosonFunc.Function{Root: root}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
|
@ -44,14 +44,14 @@ func TestTemplateWrites(t *testing.T) {
|
|||
}
|
||||
defer os.RemoveAll(root)
|
||||
|
||||
client := faas.New(faas.WithRegistry(TestRegistry))
|
||||
if err := client.Create(faas.Function{Root: root}); err != nil {
|
||||
client := bosonFunc.New(bosonFunc.WithRegistry(TestRegistry))
|
||||
if err := client.Create(bosonFunc.Function{Root: root}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
// Assert file was written
|
||||
if _, err := os.Stat(filepath.Join(root, faas.ConfigFile)); os.IsNotExist(err) {
|
||||
t.Fatalf("Initialize did not result in '%v' being written to '%v'", faas.ConfigFile, root)
|
||||
if _, err := os.Stat(filepath.Join(root, bosonFunc.ConfigFile)); os.IsNotExist(err) {
|
||||
t.Fatalf("Initialize did not result in '%v' being written to '%v'", bosonFunc.ConfigFile, root)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -65,13 +65,13 @@ func TestExtantAborts(t *testing.T) {
|
|||
defer os.RemoveAll(root)
|
||||
|
||||
// New once
|
||||
client := faas.New(faas.WithRegistry(TestRegistry))
|
||||
if err := client.New(faas.Function{Root: root}); err != nil {
|
||||
client := bosonFunc.New(bosonFunc.WithRegistry(TestRegistry))
|
||||
if err := client.New(bosonFunc.Function{Root: root}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
// New again should fail as already initialized
|
||||
if err := client.New(faas.Function{Root: root}); err == nil {
|
||||
if err := client.New(bosonFunc.Function{Root: root}); err == nil {
|
||||
t.Fatal("error expected initilizing a path already containing an initialized Function")
|
||||
}
|
||||
}
|
||||
|
|
@ -91,8 +91,8 @@ func TestNonemptyDirectoryAborts(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
|
||||
client := faas.New(faas.WithRegistry(TestRegistry))
|
||||
if err := client.New(faas.Function{Root: root}); err == nil {
|
||||
client := bosonFunc.New(bosonFunc.WithRegistry(TestRegistry))
|
||||
if err := client.New(bosonFunc.Function{Root: root}); err == nil {
|
||||
t.Fatal("error expected initilizing a Function in a nonempty directory")
|
||||
}
|
||||
}
|
||||
|
|
@ -116,8 +116,8 @@ func TestHiddenFilesIgnored(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
|
||||
client := faas.New(faas.WithRegistry(TestRegistry))
|
||||
if err := client.New(faas.Function{Root: root}); err != nil {
|
||||
client := bosonFunc.New(bosonFunc.WithRegistry(TestRegistry))
|
||||
if err := client.New(bosonFunc.Function{Root: root}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
|
@ -133,19 +133,19 @@ func TestDefaultRuntime(t *testing.T) {
|
|||
defer os.RemoveAll(root)
|
||||
|
||||
// Create a new function at root with all defaults.
|
||||
client := faas.New(faas.WithRegistry(TestRegistry))
|
||||
if err := client.New(faas.Function{Root: root}); err != nil {
|
||||
client := bosonFunc.New(bosonFunc.WithRegistry(TestRegistry))
|
||||
if err := client.New(bosonFunc.Function{Root: root}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
// Load the function
|
||||
f, err := faas.NewFunction(root)
|
||||
f, err := bosonFunc.NewFunction(root)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
// Ensure it has defaulted runtime
|
||||
if f.Runtime != faas.DefaultRuntime {
|
||||
if f.Runtime != bosonFunc.DefaultRuntime {
|
||||
t.Fatal("The default runtime was not applied or persisted.")
|
||||
}
|
||||
}
|
||||
|
|
@ -175,12 +175,12 @@ func TestExtensibleTemplates(t *testing.T) {
|
|||
defer os.RemoveAll(root)
|
||||
|
||||
// Create a new client with a path to the extensible templates
|
||||
client := faas.New(
|
||||
faas.WithTemplates("testdata/templates"),
|
||||
faas.WithRegistry(TestRegistry))
|
||||
client := bosonFunc.New(
|
||||
bosonFunc.WithTemplates("testdata/templates"),
|
||||
bosonFunc.WithRegistry(TestRegistry))
|
||||
|
||||
// Create a Function specifying a template, 'json' that only exists in the extensible set
|
||||
if err := client.New(faas.Function{Root: root, Trigger: "boson-experimental/json"}); err != nil {
|
||||
if err := client.New(bosonFunc.Function{Root: root, Trigger: "boson-experimental/json"}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
|
@ -201,11 +201,11 @@ func TestUnsupportedRuntime(t *testing.T) {
|
|||
}
|
||||
defer os.RemoveAll(root)
|
||||
|
||||
client := faas.New(faas.WithRegistry(TestRegistry))
|
||||
client := bosonFunc.New(bosonFunc.WithRegistry(TestRegistry))
|
||||
|
||||
// create a Function call witn an unsupported runtime should bubble
|
||||
// the error generated by the underlying initializer.
|
||||
if err := client.New(faas.Function{Root: root, Runtime: "invalid"}); err == nil {
|
||||
if err := client.New(bosonFunc.Function{Root: root, Runtime: "invalid"}); err == nil {
|
||||
t.Fatal("unsupported runtime did not generate error")
|
||||
}
|
||||
}
|
||||
|
|
@ -226,13 +226,13 @@ func TestNamed(t *testing.T) {
|
|||
}
|
||||
defer os.RemoveAll(root)
|
||||
|
||||
client := faas.New(faas.WithRegistry(TestRegistry))
|
||||
client := bosonFunc.New(bosonFunc.WithRegistry(TestRegistry))
|
||||
|
||||
if err := client.New(faas.Function{Root: root, Name: name}); err != nil {
|
||||
if err := client.New(bosonFunc.Function{Root: root, Name: name}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
f, err := faas.NewFunction(root)
|
||||
f, err := bosonFunc.NewFunction(root)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
@ -260,9 +260,9 @@ func TestRegistryRequired(t *testing.T) {
|
|||
}
|
||||
defer os.RemoveAll(root)
|
||||
|
||||
client := faas.New()
|
||||
client := bosonFunc.New()
|
||||
var err error
|
||||
if err = client.New(faas.Function{Root: root}); err == nil {
|
||||
if err = client.New(bosonFunc.Function{Root: root}); err == nil {
|
||||
t.Fatal("did not receive expected error creating a Function without specifying Registry")
|
||||
}
|
||||
fmt.Println(err)
|
||||
|
|
@ -280,13 +280,13 @@ func TestDeriveImage(t *testing.T) {
|
|||
defer os.RemoveAll(root)
|
||||
|
||||
// Create the function which calculates fields such as name and image.
|
||||
client := faas.New(faas.WithRegistry(TestRegistry))
|
||||
if err := client.New(faas.Function{Root: root}); err != nil {
|
||||
client := bosonFunc.New(bosonFunc.WithRegistry(TestRegistry))
|
||||
if err := client.New(bosonFunc.Function{Root: root}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
// Load the function with the now-populated fields.
|
||||
f, err := faas.NewFunction(root)
|
||||
f, err := bosonFunc.NewFunction(root)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
@ -312,18 +312,18 @@ func TestDeriveImageDefaultRegistry(t *testing.T) {
|
|||
// Create the function which calculates fields such as name and image.
|
||||
// Rather than use TestRegistry, use a single-token name and expect
|
||||
// the DefaultRegistry to be prepended.
|
||||
client := faas.New(faas.WithRegistry("alice"))
|
||||
if err := client.New(faas.Function{Root: root}); err != nil {
|
||||
client := bosonFunc.New(bosonFunc.WithRegistry("alice"))
|
||||
if err := client.New(bosonFunc.Function{Root: root}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
// Load the function with the now-populated fields.
|
||||
f, err := faas.NewFunction(root)
|
||||
f, err := bosonFunc.NewFunction(root)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
// Expected image is [DefaultRegistry]/[namespace]/[servicename]:latest
|
||||
expected := faas.DefaultRegistry + "/alice/" + f.Name + ":latest"
|
||||
expected := bosonFunc.DefaultRegistry + "/alice/" + f.Name + ":latest"
|
||||
if f.Image != expected {
|
||||
t.Fatalf("expected image '%v' got '%v'", expected, f.Image)
|
||||
}
|
||||
|
|
@ -349,11 +349,11 @@ func TestNewDelegates(t *testing.T) {
|
|||
defer os.RemoveAll(root)
|
||||
|
||||
// Create a client with mocks for each of the subcomponents.
|
||||
client := faas.New(
|
||||
faas.WithRegistry(TestRegistry),
|
||||
faas.WithBuilder(builder), // builds an image
|
||||
faas.WithPusher(pusher), // pushes images to a registry
|
||||
faas.WithDeployer(deployer), // deploys images as a running service
|
||||
client := bosonFunc.New(
|
||||
bosonFunc.WithRegistry(TestRegistry),
|
||||
bosonFunc.WithBuilder(builder), // builds an image
|
||||
bosonFunc.WithPusher(pusher), // pushes images to a registry
|
||||
bosonFunc.WithDeployer(deployer), // deploys images as a running service
|
||||
)
|
||||
|
||||
// Register Function delegates on the mocks which validate assertions
|
||||
|
|
@ -361,7 +361,7 @@ func TestNewDelegates(t *testing.T) {
|
|||
|
||||
// The builder should be invoked with a path to a Function project's source
|
||||
// An example image name is returned.
|
||||
builder.BuildFn = func(f faas.Function) error {
|
||||
builder.BuildFn = func(f bosonFunc.Function) error {
|
||||
expectedPath, err := filepath.Abs(root)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
|
@ -372,14 +372,14 @@ func TestNewDelegates(t *testing.T) {
|
|||
return nil
|
||||
}
|
||||
|
||||
pusher.PushFn = func(f faas.Function) (string, error) {
|
||||
pusher.PushFn = func(f bosonFunc.Function) (string, error) {
|
||||
if f.Image != expectedImage {
|
||||
t.Fatalf("pusher expected image '%v', got '%v'", expectedImage, f.Image)
|
||||
}
|
||||
return "", nil
|
||||
}
|
||||
|
||||
deployer.DeployFn = func(f faas.Function) error {
|
||||
deployer.DeployFn = func(f bosonFunc.Function) error {
|
||||
if f.Name != expectedName {
|
||||
t.Fatalf("deployer expected name '%v', got '%v'", expectedName, f.Name)
|
||||
}
|
||||
|
|
@ -394,7 +394,7 @@ func TestNewDelegates(t *testing.T) {
|
|||
|
||||
// Invoke the creation, triggering the Function delegates, and
|
||||
// perform follow-up assertions that the Functions were indeed invoked.
|
||||
if err := client.New(faas.Function{Root: root}); err != nil {
|
||||
if err := client.New(bosonFunc.Function{Root: root}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
|
@ -421,8 +421,8 @@ func TestRun(t *testing.T) {
|
|||
|
||||
// Create a client with the mock runner and the new test Function
|
||||
runner := mock.NewRunner()
|
||||
client := faas.New(faas.WithRegistry(TestRegistry), faas.WithRunner(runner))
|
||||
if err := client.New(faas.Function{Root: root}); err != nil {
|
||||
client := bosonFunc.New(bosonFunc.WithRegistry(TestRegistry), bosonFunc.WithRunner(runner))
|
||||
if err := client.New(bosonFunc.Function{Root: root}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
|
@ -463,19 +463,19 @@ func TestUpdate(t *testing.T) {
|
|||
defer os.RemoveAll(root)
|
||||
|
||||
// A client with mocks whose implementaton will validate input.
|
||||
client := faas.New(
|
||||
faas.WithRegistry(TestRegistry),
|
||||
faas.WithBuilder(builder),
|
||||
faas.WithPusher(pusher),
|
||||
faas.WithDeployer(deployer))
|
||||
client := bosonFunc.New(
|
||||
bosonFunc.WithRegistry(TestRegistry),
|
||||
bosonFunc.WithBuilder(builder),
|
||||
bosonFunc.WithPusher(pusher),
|
||||
bosonFunc.WithDeployer(deployer))
|
||||
|
||||
// create the new Function which will be updated
|
||||
if err := client.New(faas.Function{Root: root}); err != nil {
|
||||
if err := client.New(bosonFunc.Function{Root: root}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
// Builder whose implementation verifies the expected root
|
||||
builder.BuildFn = func(f faas.Function) error {
|
||||
builder.BuildFn = func(f bosonFunc.Function) error {
|
||||
rootPath, err := filepath.Abs(root)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
|
@ -487,7 +487,7 @@ func TestUpdate(t *testing.T) {
|
|||
}
|
||||
|
||||
// Pusher whose implementaiton verifies the expected image
|
||||
pusher.PushFn = func(f faas.Function) (string, error) {
|
||||
pusher.PushFn = func(f bosonFunc.Function) (string, error) {
|
||||
if f.Image != expectedImage {
|
||||
t.Fatalf("pusher expected image '%v', got '%v'", expectedImage, f.Image)
|
||||
}
|
||||
|
|
@ -496,7 +496,7 @@ func TestUpdate(t *testing.T) {
|
|||
}
|
||||
|
||||
// Update whose implementaiton verifed the expected name and image
|
||||
deployer.DeployFn = func(f faas.Function) error {
|
||||
deployer.DeployFn = func(f bosonFunc.Function) error {
|
||||
if f.Name != expectedName {
|
||||
t.Fatalf("updater expected name '%v', got '%v'", expectedName, f.Name)
|
||||
}
|
||||
|
|
@ -537,11 +537,11 @@ func TestRemoveByPath(t *testing.T) {
|
|||
}
|
||||
defer os.RemoveAll(root)
|
||||
|
||||
client := faas.New(
|
||||
faas.WithRegistry(TestRegistry),
|
||||
faas.WithRemover(remover))
|
||||
client := bosonFunc.New(
|
||||
bosonFunc.WithRegistry(TestRegistry),
|
||||
bosonFunc.WithRemover(remover))
|
||||
|
||||
if err := client.New(faas.Function{Root: root}); err != nil {
|
||||
if err := client.New(bosonFunc.Function{Root: root}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
|
@ -552,7 +552,7 @@ func TestRemoveByPath(t *testing.T) {
|
|||
return nil
|
||||
}
|
||||
|
||||
if err := client.Remove(faas.Function{Root: root}); err != nil {
|
||||
if err := client.Remove(bosonFunc.Function{Root: root}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
|
@ -576,11 +576,11 @@ func TestRemoveByName(t *testing.T) {
|
|||
}
|
||||
defer os.RemoveAll(root)
|
||||
|
||||
client := faas.New(
|
||||
faas.WithRegistry(TestRegistry),
|
||||
faas.WithRemover(remover))
|
||||
client := bosonFunc.New(
|
||||
bosonFunc.WithRegistry(TestRegistry),
|
||||
bosonFunc.WithRemover(remover))
|
||||
|
||||
if err := client.Create(faas.Function{Root: root}); err != nil {
|
||||
if err := client.Create(bosonFunc.Function{Root: root}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
|
@ -592,12 +592,12 @@ func TestRemoveByName(t *testing.T) {
|
|||
}
|
||||
|
||||
// Run remove with only a name
|
||||
if err := client.Remove(faas.Function{Name: expectedName}); err != nil {
|
||||
if err := client.Remove(bosonFunc.Function{Name: expectedName}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
// Run remove with a name and a root, which should be ignored in favor of the name.
|
||||
if err := client.Remove(faas.Function{Name: expectedName, Root: root}); err != nil {
|
||||
if err := client.Remove(bosonFunc.Function{Name: expectedName, Root: root}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
|
@ -627,12 +627,12 @@ func TestRemoveUninitializedFails(t *testing.T) {
|
|||
}
|
||||
|
||||
// Instantiate the client with the failing remover.
|
||||
client := faas.New(
|
||||
faas.WithRegistry(TestRegistry),
|
||||
faas.WithRemover(remover))
|
||||
client := bosonFunc.New(
|
||||
bosonFunc.WithRegistry(TestRegistry),
|
||||
bosonFunc.WithRemover(remover))
|
||||
|
||||
// Attempt to remove by path (uninitialized), expecting an error.
|
||||
if err := client.Remove(faas.Function{Root: root}); err == nil {
|
||||
if err := client.Remove(bosonFunc.Function{Root: root}); err == nil {
|
||||
t.Fatalf("did not received expeced error removing an uninitialized func")
|
||||
}
|
||||
}
|
||||
|
|
@ -641,7 +641,7 @@ func TestRemoveUninitializedFails(t *testing.T) {
|
|||
func TestList(t *testing.T) {
|
||||
lister := mock.NewLister()
|
||||
|
||||
client := faas.New(faas.WithLister(lister)) // lists deployed Functions.
|
||||
client := bosonFunc.New(bosonFunc.WithLister(lister)) // lists deployed Functions.
|
||||
|
||||
if _, err := client.List(); err != nil {
|
||||
t.Fatal(err)
|
||||
|
|
@ -660,7 +660,7 @@ func TestListOutsideRoot(t *testing.T) {
|
|||
lister := mock.NewLister()
|
||||
|
||||
// Instantiate in the current working directory, with no name.
|
||||
client := faas.New(faas.WithLister(lister))
|
||||
client := bosonFunc.New(bosonFunc.WithLister(lister))
|
||||
|
||||
if _, err := client.List(); err != nil {
|
||||
t.Fatal(err)
|
||||
|
|
|
|||
16
cmd/build.go
16
cmd/build.go
|
|
@ -6,9 +6,9 @@ import (
|
|||
"github.com/ory/viper"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/boson-project/faas"
|
||||
"github.com/boson-project/faas/buildpacks"
|
||||
"github.com/boson-project/faas/prompt"
|
||||
"github.com/boson-project/func/buildpacks"
|
||||
bosonFunc "github.com/boson-project/func"
|
||||
"github.com/boson-project/func/prompt"
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
|
@ -36,7 +36,7 @@ The func.yaml file is read to determine the image name and registry.
|
|||
If the project has not already been built, either --registry or --image must be provided
|
||||
and the image name is stored in the configuration file.
|
||||
`,
|
||||
Example: `
|
||||
Example: `
|
||||
# Build from the local directory, using the given registry as target.
|
||||
# The full image name will be determined automatically based on the
|
||||
# project directory name
|
||||
|
|
@ -95,10 +95,10 @@ func runBuild(cmd *cobra.Command, _ []string) (err error) {
|
|||
builder := buildpacks.NewBuilder()
|
||||
builder.Verbose = config.Verbose
|
||||
|
||||
client := faas.New(
|
||||
faas.WithVerbose(config.Verbose),
|
||||
faas.WithRegistry(config.Registry), // for deriving image name when --image not provided explicitly.
|
||||
faas.WithBuilder(builder))
|
||||
client := bosonFunc.New(
|
||||
bosonFunc.WithVerbose(config.Verbose),
|
||||
bosonFunc.WithRegistry(config.Registry), // for deriving image name when --image not provided explicitly.
|
||||
bosonFunc.WithBuilder(builder))
|
||||
|
||||
return client.Build(config.Path)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,14 +2,15 @@ package cmd
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/boson-project/faas"
|
||||
"os"
|
||||
"os/user"
|
||||
"path"
|
||||
|
||||
"github.com/boson-project/faas/buildpacks"
|
||||
"github.com/boson-project/faas/knative"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
bosonFunc "github.com/boson-project/func"
|
||||
"github.com/boson-project/func/buildpacks"
|
||||
"github.com/boson-project/func/knative"
|
||||
)
|
||||
|
||||
func CompleteFunctionList(cmd *cobra.Command, args []string, toComplete string) (strings []string, directive cobra.ShellCompDirective) {
|
||||
|
|
@ -24,7 +25,7 @@ func CompleteFunctionList(cmd *cobra.Command, args []string, toComplete string)
|
|||
return
|
||||
}
|
||||
|
||||
for _, item := range list{
|
||||
for _, item := range list {
|
||||
strings = append(strings, item.Name)
|
||||
}
|
||||
directive = cobra.ShellCompDirectiveDefault
|
||||
|
|
@ -78,7 +79,7 @@ func CompleteBuilderList(cmd *cobra.Command, args []string, complete string) (st
|
|||
var (
|
||||
err error
|
||||
path string
|
||||
f faas.Function
|
||||
f bosonFunc.Function
|
||||
)
|
||||
|
||||
path, err = cmd.Flags().GetString("path")
|
||||
|
|
@ -86,7 +87,7 @@ func CompleteBuilderList(cmd *cobra.Command, args []string, complete string) (st
|
|||
return
|
||||
}
|
||||
|
||||
f, err = faas.NewFunction(path)
|
||||
f, err = bosonFunc.NewFunction(path)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,17 +7,17 @@ import (
|
|||
"github.com/ory/viper"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/boson-project/faas"
|
||||
"github.com/boson-project/faas/prompt"
|
||||
"github.com/boson-project/faas/utils"
|
||||
bosonFunc "github.com/boson-project/func"
|
||||
"github.com/boson-project/func/prompt"
|
||||
"github.com/boson-project/func/utils"
|
||||
)
|
||||
|
||||
func init() {
|
||||
root.AddCommand(createCmd)
|
||||
createCmd.Flags().BoolP("confirm", "c", false, "Prompt to confirm all configuration options (Env: $FUNC_CONFIRM)")
|
||||
createCmd.Flags().StringP("runtime", "l", faas.DefaultRuntime, "Function runtime language/framework. Available runtimes: " + utils.RuntimeList() + " (Env: $FUNC_RUNTIME)")
|
||||
createCmd.Flags().StringP("runtime", "l", bosonFunc.DefaultRuntime, "Function runtime language/framework. Available runtimes: "+utils.RuntimeList()+" (Env: $FUNC_RUNTIME)")
|
||||
createCmd.Flags().StringP("templates", "", filepath.Join(configPath(), "templates"), "Path to additional templates (Env: $FUNC_TEMPLATES)")
|
||||
createCmd.Flags().StringP("trigger", "t", faas.DefaultTrigger, "Function trigger. Available triggers: 'http' and 'events' (Env: $FUNC_TRIGGER)")
|
||||
createCmd.Flags().StringP("trigger", "t", bosonFunc.DefaultTrigger, "Function trigger. Available triggers: 'http' and 'events' (Env: $FUNC_TRIGGER)")
|
||||
|
||||
if err := createCmd.RegisterFlagCompletionFunc("runtime", CompleteRuntimeList); err != nil {
|
||||
fmt.Println("internal: error while calling RegisterFlagCompletionFunc: ", err)
|
||||
|
|
@ -54,16 +54,16 @@ kn func create --trigger events myfunc
|
|||
func runCreate(cmd *cobra.Command, args []string) error {
|
||||
config := newCreateConfig(args).Prompt()
|
||||
|
||||
function := faas.Function{
|
||||
function := bosonFunc.Function{
|
||||
Name: config.Name,
|
||||
Root: config.Path,
|
||||
Runtime: config.Runtime,
|
||||
Trigger: config.Trigger,
|
||||
}
|
||||
|
||||
client := faas.New(
|
||||
faas.WithTemplates(config.Templates),
|
||||
faas.WithVerbose(config.Verbose))
|
||||
client := bosonFunc.New(
|
||||
bosonFunc.WithTemplates(config.Templates),
|
||||
bosonFunc.WithVerbose(config.Verbose))
|
||||
|
||||
return client.Create(function)
|
||||
}
|
||||
|
|
@ -80,8 +80,8 @@ type createConfig struct {
|
|||
|
||||
// Templates is an optional path that, if it exists, will be used as a source
|
||||
// for additional templates not included in the binary. If not provided
|
||||
// explicitly as a flag (--templates) or env (FAAS_TEMPLATES), the default
|
||||
// location is $XDG_CONFIG_HOME/templates ($HOME/.config/faas/templates)
|
||||
// explicitly as a flag (--templates) or env (FUNC_TEMPLATES), the default
|
||||
// location is $XDG_CONFIG_HOME/templates ($HOME/.config/func/templates)
|
||||
Templates string
|
||||
|
||||
// Trigger is the form of the resultant Function, i.e. the Function signature
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@ import (
|
|||
"github.com/ory/viper"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/boson-project/faas"
|
||||
"github.com/boson-project/faas/knative"
|
||||
"github.com/boson-project/faas/prompt"
|
||||
bosonFunc "github.com/boson-project/func"
|
||||
"github.com/boson-project/func/knative"
|
||||
"github.com/boson-project/func/prompt"
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
|
@ -45,7 +45,7 @@ kn func delete -n apps myfunc
|
|||
func runDelete(cmd *cobra.Command, args []string) (err error) {
|
||||
config := newDeleteConfig(args).Prompt()
|
||||
|
||||
function, err := faas.NewFunction(config.Path)
|
||||
function, err := bosonFunc.NewFunction(config.Path)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
|
@ -67,9 +67,9 @@ func runDelete(cmd *cobra.Command, args []string) (err error) {
|
|||
|
||||
remover.Verbose = config.Verbose
|
||||
|
||||
client := faas.New(
|
||||
faas.WithVerbose(config.Verbose),
|
||||
faas.WithRemover(remover))
|
||||
client := bosonFunc.New(
|
||||
bosonFunc.WithVerbose(config.Verbose),
|
||||
bosonFunc.WithRemover(remover))
|
||||
|
||||
return client.Remove(function)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,15 +2,16 @@ package cmd
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/ory/viper"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/boson-project/faas"
|
||||
"github.com/boson-project/faas/buildpacks"
|
||||
"github.com/boson-project/faas/docker"
|
||||
"github.com/boson-project/faas/knative"
|
||||
"github.com/boson-project/faas/progress"
|
||||
"github.com/boson-project/faas/prompt"
|
||||
bosonFunc "github.com/boson-project/func"
|
||||
"github.com/boson-project/func/buildpacks"
|
||||
"github.com/boson-project/func/docker"
|
||||
"github.com/boson-project/func/knative"
|
||||
"github.com/boson-project/func/progress"
|
||||
"github.com/boson-project/func/prompt"
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
|
@ -47,7 +48,7 @@ kn func deploy --registry quay.io/myuser
|
|||
# the namespace "myns"
|
||||
kn func deploy --image quay.io/myuser/myfunc -n myns
|
||||
`,
|
||||
SuggestFor: []string{"delpoy", "deplyo"},
|
||||
SuggestFor: []string{"delpoy", "deplyo"},
|
||||
PreRunE: bindEnv("image", "namespace", "path", "registry", "confirm"),
|
||||
RunE: runDeploy,
|
||||
}
|
||||
|
|
@ -111,13 +112,13 @@ func runDeploy(cmd *cobra.Command, _ []string) (err error) {
|
|||
|
||||
deployer.Verbose = config.Verbose
|
||||
|
||||
client := faas.New(
|
||||
faas.WithVerbose(config.Verbose),
|
||||
faas.WithRegistry(config.Registry), // for deriving image name when --image not provided explicitly.
|
||||
faas.WithBuilder(builder),
|
||||
faas.WithPusher(pusher),
|
||||
faas.WithDeployer(deployer),
|
||||
faas.WithProgressListener(listener))
|
||||
client := bosonFunc.New(
|
||||
bosonFunc.WithVerbose(config.Verbose),
|
||||
bosonFunc.WithRegistry(config.Registry), // for deriving image name when --image not provided explicitly.
|
||||
bosonFunc.WithBuilder(builder),
|
||||
bosonFunc.WithPusher(pusher),
|
||||
bosonFunc.WithDeployer(deployer),
|
||||
bosonFunc.WithProgressListener(listener))
|
||||
|
||||
return client.Deploy(config.Path)
|
||||
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@ import (
|
|||
"github.com/spf13/cobra"
|
||||
"gopkg.in/yaml.v2"
|
||||
|
||||
"github.com/boson-project/faas"
|
||||
"github.com/boson-project/faas/knative"
|
||||
bosonFunc "github.com/boson-project/func"
|
||||
"github.com/boson-project/func/knative"
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
|
@ -51,7 +51,7 @@ kn func describe --output yaml --path myotherfunc
|
|||
func runDescribe(cmd *cobra.Command, args []string) (err error) {
|
||||
config := newDescribeConfig(args)
|
||||
|
||||
function, err := faas.NewFunction(config.Path)
|
||||
function, err := bosonFunc.NewFunction(config.Path)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
|
@ -67,9 +67,9 @@ func runDescribe(cmd *cobra.Command, args []string) (err error) {
|
|||
}
|
||||
describer.Verbose = config.Verbose
|
||||
|
||||
client := faas.New(
|
||||
faas.WithVerbose(config.Verbose),
|
||||
faas.WithDescriber(describer))
|
||||
client := bosonFunc.New(
|
||||
bosonFunc.WithVerbose(config.Verbose),
|
||||
bosonFunc.WithDescriber(describer))
|
||||
|
||||
d, err := client.Describe(config.Name, config.Path)
|
||||
if err != nil {
|
||||
|
|
@ -109,7 +109,7 @@ func newDescribeConfig(args []string) describeConfig {
|
|||
// Output Formatting (serializers)
|
||||
// -------------------------------
|
||||
|
||||
type description faas.Description
|
||||
type description bosonFunc.Description
|
||||
|
||||
func (d description) Human(w io.Writer) error {
|
||||
fmt.Fprintln(w, "Function name:")
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"github.com/boson-project/faas/cmd"
|
||||
"github.com/boson-project/func/cmd"
|
||||
)
|
||||
|
||||
// Statically-populated build metadata set
|
||||
|
|
|
|||
12
cmd/list.go
12
cmd/list.go
|
|
@ -12,8 +12,8 @@ import (
|
|||
"github.com/spf13/cobra"
|
||||
"gopkg.in/yaml.v2"
|
||||
|
||||
"github.com/boson-project/faas"
|
||||
"github.com/boson-project/faas/knative"
|
||||
bosonFunc "github.com/boson-project/func"
|
||||
"github.com/boson-project/func/knative"
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
|
@ -66,9 +66,9 @@ func runList(cmd *cobra.Command, args []string) (err error) {
|
|||
lister.Namespace = ""
|
||||
}
|
||||
|
||||
client := faas.New(
|
||||
faas.WithVerbose(config.Verbose),
|
||||
faas.WithLister(lister))
|
||||
client := bosonFunc.New(
|
||||
bosonFunc.WithVerbose(config.Verbose),
|
||||
bosonFunc.WithLister(lister))
|
||||
|
||||
items, err := client.List()
|
||||
if err != nil {
|
||||
|
|
@ -105,7 +105,7 @@ func newListConfig() listConfig {
|
|||
// Output Formatting (serializers)
|
||||
// -------------------------------
|
||||
|
||||
type listItems []faas.ListItem
|
||||
type listItems []bosonFunc.ListItem
|
||||
|
||||
func (items listItems) Human(w io.Writer) error {
|
||||
return items.Plain(w)
|
||||
|
|
|
|||
18
cmd/root.go
18
cmd/root.go
|
|
@ -10,7 +10,7 @@ import (
|
|||
"github.com/ory/viper"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/boson-project/faas"
|
||||
bosonFunc "github.com/boson-project/func"
|
||||
)
|
||||
|
||||
// The root of the command tree defines the command name, descriotion, globally
|
||||
|
|
@ -37,7 +37,7 @@ curl $(kn service describe myfunc -o url)
|
|||
`,
|
||||
}
|
||||
|
||||
// NewRootCmd is used to initialize faas as kn plugin
|
||||
// NewRootCmd is used to initialize func as kn plugin
|
||||
func NewRootCmd() *cobra.Command {
|
||||
return root
|
||||
}
|
||||
|
|
@ -146,8 +146,8 @@ type functionOverrides struct {
|
|||
// Function project at root, if provided, and returns the Function
|
||||
// configuration values.
|
||||
// Please note that When this function is called, the overrides are not persisted.
|
||||
func functionWithOverrides(root string, overrides functionOverrides) (f faas.Function, err error) {
|
||||
f, err = faas.NewFunction(root)
|
||||
func functionWithOverrides(root string, overrides functionOverrides) (f bosonFunc.Function, err error) {
|
||||
f, err = bosonFunc.NewFunction(root)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
|
@ -180,7 +180,7 @@ func deriveName(explicitName string, path string) string {
|
|||
}
|
||||
|
||||
// If the directory at path contains an initialized Function, use the name therein
|
||||
f, err := faas.NewFunction(path)
|
||||
f, err := bosonFunc.NewFunction(path)
|
||||
if err == nil && f.Name != "" {
|
||||
return f.Name
|
||||
}
|
||||
|
|
@ -236,15 +236,15 @@ func deriveImage(explicitImage, defaultRegistry, path string) string {
|
|||
if explicitImage != "" {
|
||||
return explicitImage // use the explicit value provided.
|
||||
}
|
||||
f, err := faas.NewFunction(path)
|
||||
f, err := bosonFunc.NewFunction(path)
|
||||
if err != nil {
|
||||
return "" // unable to derive due to load error (uninitialized?)
|
||||
}
|
||||
if f.Image != "" {
|
||||
return f.Image // use value previously provided or derived.
|
||||
}
|
||||
derivedValue, _ := faas.DerivedImage(path, defaultRegistry)
|
||||
return derivedValue // Use the faas system's derivation logic.
|
||||
derivedValue, _ := bosonFunc.DerivedImage(path, defaultRegistry)
|
||||
return derivedValue // Use the func system's derivation logic.
|
||||
}
|
||||
|
||||
func envVarsFromCmd(cmd *cobra.Command) map[string]string {
|
||||
|
|
@ -266,7 +266,7 @@ func envVarsFromCmd(cmd *cobra.Command) map[string]string {
|
|||
}
|
||||
|
||||
func mergeEnvVarsMaps(dest, src map[string]string) map[string]string {
|
||||
result := make(map[string]string, len(dest) +len(src))
|
||||
result := make(map[string]string, len(dest)+len(src))
|
||||
|
||||
for name, value := range dest {
|
||||
if strings.HasSuffix(name, "-") {
|
||||
|
|
|
|||
12
cmd/run.go
12
cmd/run.go
|
|
@ -6,8 +6,8 @@ import (
|
|||
"github.com/ory/viper"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/boson-project/faas"
|
||||
"github.com/boson-project/faas/docker"
|
||||
bosonFunc "github.com/boson-project/func"
|
||||
"github.com/boson-project/func/docker"
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
|
@ -40,7 +40,7 @@ kn func run
|
|||
func runRun(cmd *cobra.Command, args []string) (err error) {
|
||||
config := newRunConfig(cmd)
|
||||
|
||||
function, err := faas.NewFunction(config.Path)
|
||||
function, err := bosonFunc.NewFunction(config.Path)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
|
@ -60,9 +60,9 @@ func runRun(cmd *cobra.Command, args []string) (err error) {
|
|||
runner := docker.NewRunner()
|
||||
runner.Verbose = config.Verbose
|
||||
|
||||
client := faas.New(
|
||||
faas.WithRunner(runner),
|
||||
faas.WithVerbose(config.Verbose))
|
||||
client := bosonFunc.New(
|
||||
bosonFunc.WithRunner(runner),
|
||||
bosonFunc.WithVerbose(config.Verbose))
|
||||
|
||||
return client.Run(config.Path)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import (
|
|||
"os/exec"
|
||||
"strings"
|
||||
|
||||
"github.com/boson-project/faas"
|
||||
bosonFunc "github.com/boson-project/func"
|
||||
)
|
||||
|
||||
// Pusher of images from local to remote registry.
|
||||
|
|
@ -24,7 +24,7 @@ func NewPusher() *Pusher {
|
|||
}
|
||||
|
||||
// Push the image of the Function.
|
||||
func (n *Pusher) Push(f faas.Function) (digest string, err error) {
|
||||
func (n *Pusher) Push(f bosonFunc.Function) (digest string, err error) {
|
||||
// Check for the docker binary explicitly so that we can return
|
||||
// an extra-friendly error message.
|
||||
_, err = exec.LookPath("docker")
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import (
|
|||
"os/exec"
|
||||
"strings"
|
||||
|
||||
"github.com/boson-project/faas"
|
||||
bosonFunc "github.com/boson-project/func"
|
||||
)
|
||||
|
||||
// Runner of functions using the docker command.
|
||||
|
|
@ -22,7 +22,7 @@ func NewRunner() *Runner {
|
|||
}
|
||||
|
||||
// Run the function at path
|
||||
func (n *Runner) Run(f faas.Function) error {
|
||||
func (n *Runner) Run(f bosonFunc.Function) error {
|
||||
// Check for the docker binary explicitly so that we can return
|
||||
// an extra-friendly error message.
|
||||
_, err := exec.LookPath("docker")
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@ import (
|
|||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/boson-project/faas"
|
||||
"github.com/boson-project/faas/docker"
|
||||
bosonFunc "github.com/boson-project/func"
|
||||
"github.com/boson-project/func/docker"
|
||||
)
|
||||
|
||||
// Docker Run Integraiton Test
|
||||
|
|
@ -24,7 +24,7 @@ func TestDockerRun(t *testing.T) {
|
|||
t.Skip()
|
||||
}
|
||||
|
||||
f, err := faas.NewFunction("testdata/example.com/runnable")
|
||||
f, err := bosonFunc.NewFunction("testdata/example.com/runnable")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ First edit `knative/config-domain.yaml` to contain your domain of choice and the
|
|||
```
|
||||
kubectl apply -f knative/config-domain.yaml
|
||||
```
|
||||
Note that this step is [pending automation](https://github.com/boson-project/faas/issues/47)
|
||||
Note that this step is [pending automation](https://github.com/boson-project/func/issues/47)
|
||||
|
||||
### DNS
|
||||
|
||||
|
|
|
|||
|
|
@ -15,9 +15,9 @@ docker run quay.io/boson/func:v0.9.0
|
|||
|
||||
### Prebuilt Binary
|
||||
|
||||
Download the latest binary appropriate for your system from the [Latest Release](https://github.com/boson-project/faas/releases/latest/).
|
||||
Download the latest binary appropriate for your system from the [Latest Release](https://github.com/boson-project/func/releases/latest/).
|
||||
|
||||
Each version is built and made available as a prebuilt binary. See [All Releases](https://github.com/boson-project/faas/releases/).
|
||||
Each version is built and made available as a prebuilt binary. See [All Releases](https://github.com/boson-project/func/releases/).
|
||||
|
||||
### From Source
|
||||
|
||||
|
|
|
|||
|
|
@ -11,22 +11,22 @@ package main
|
|||
import (
|
||||
"log"
|
||||
|
||||
"github.com/boson-project/faas"
|
||||
"github.com/boson-project/faas/buildpacks"
|
||||
"github.com/boson-project/faas/docker"
|
||||
"github.com/boson-project/faas/embedded"
|
||||
"github.com/boson-project/faas/knative"
|
||||
bosonFunc "github.com/boson-project/func"
|
||||
"github.com/boson-project/func/buildpacks"
|
||||
"github.com/boson-project/func/docker"
|
||||
"github.com/boson-project/func/embedded"
|
||||
"github.com/boson-project/func/knative"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// A client which uses embedded function templates,
|
||||
// Quay.io/alice for interstitial build artifacts.
|
||||
// Docker to build and push, and a Knative client for deployment.
|
||||
client, err := faas.New(
|
||||
faas.WithInitializer(embedded.NewInitializer("")),
|
||||
faas.WithBuilder(buildpacks.NewBuilder("quay.io/alice/my-function")),
|
||||
faas.WithPusher(docker.NewPusher()),
|
||||
faas.WithDeployer(knative.NewDeployer()))
|
||||
client, err := bosonFunc.New(
|
||||
bosonFunc.WithInitializer(embedded.NewInitializer("")),
|
||||
bosonFunc.WithBuilder(buildpacks.NewBuilder("quay.io/alice/my-function")),
|
||||
bosonFunc.WithPusher(docker.NewPusher()),
|
||||
bosonFunc.WithDeployer(knative.NewDeployer()))
|
||||
|
||||
// Create a Go function which listens for CloudEvents.
|
||||
// Publicly routable as https://www.example.com.
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package faas
|
||||
package function
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package faas
|
||||
package function
|
||||
|
||||
import "testing"
|
||||
|
||||
|
|
|
|||
4
go.mod
4
go.mod
|
|
@ -1,4 +1,4 @@
|
|||
module github.com/boson-project/faas
|
||||
module github.com/boson-project/func
|
||||
|
||||
go 1.14
|
||||
|
||||
|
|
@ -8,8 +8,6 @@ require (
|
|||
github.com/mitchellh/go-homedir v1.1.0
|
||||
github.com/ory/viper v1.7.4
|
||||
github.com/spf13/cobra v1.0.1-0.20201006035406-b97b5ead31f7
|
||||
golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a // indirect
|
||||
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f // indirect
|
||||
gopkg.in/yaml.v2 v2.3.0
|
||||
k8s.io/api v0.18.8
|
||||
k8s.io/apimachinery v0.19.1
|
||||
|
|
|
|||
2
go.sum
2
go.sum
|
|
@ -1361,8 +1361,6 @@ golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37/go.mod h1:LzIPMQfyMNhhGPh
|
|||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de h1:ikNHVSjEfnvz6sxdSPCaPt572qowuyMDMJLLm3Db3ig=
|
||||
golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a h1:vclmkQCjlDX5OydZ9wv8rBCcS0QyQY66Mpf/7BZbInM=
|
||||
golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/exp v0.0.0-20190125153040-c74c464bbbf2/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
|
|
|
|||
|
|
@ -13,8 +13,8 @@ import (
|
|||
servingv1 "knative.dev/serving/pkg/apis/serving/v1"
|
||||
v1 "knative.dev/serving/pkg/apis/serving/v1"
|
||||
|
||||
"github.com/boson-project/faas"
|
||||
"github.com/boson-project/faas/k8s"
|
||||
bosonFunc "github.com/boson-project/func"
|
||||
"github.com/boson-project/func/k8s"
|
||||
)
|
||||
|
||||
type Deployer struct {
|
||||
|
|
@ -35,7 +35,7 @@ func NewDeployer(namespaceOverride string) (deployer *Deployer, err error) {
|
|||
return
|
||||
}
|
||||
|
||||
func (d *Deployer) Deploy(f faas.Function) (err error) {
|
||||
func (d *Deployer) Deploy(f bosonFunc.Function) (err error) {
|
||||
|
||||
// k8s does not support service names with dots. so encode it such that
|
||||
// www.my-domain,com -> www-my--domain-com
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@ import (
|
|||
v1 "knative.dev/client/pkg/serving/v1"
|
||||
"knative.dev/eventing/pkg/apis/eventing/v1beta1"
|
||||
|
||||
"github.com/boson-project/faas"
|
||||
"github.com/boson-project/faas/k8s"
|
||||
bosonFunc "github.com/boson-project/func"
|
||||
"github.com/boson-project/func/k8s"
|
||||
)
|
||||
|
||||
type Describer struct {
|
||||
|
|
@ -29,7 +29,7 @@ func NewDescriber(namespaceOverride string) (describer *Describer, err error) {
|
|||
// restricts to label-syntax, which is thus escaped. Therefore as a knative (kube) implementation
|
||||
// detal proper full names have to be escaped on the way in and unescaped on the way out. ex:
|
||||
// www.example-site.com -> www-example--site-com
|
||||
func (d *Describer) Describe(name string) (description faas.Description, err error) {
|
||||
func (d *Describer) Describe(name string) (description bosonFunc.Description, err error) {
|
||||
|
||||
serviceName, err := k8s.ToK8sAllowedName(name)
|
||||
if err != nil {
|
||||
|
|
@ -74,11 +74,11 @@ func (d *Describer) Describe(name string) (description faas.Description, err err
|
|||
|
||||
}
|
||||
|
||||
subscriptions := make([]faas.Subscription, 0, len(triggers.Items))
|
||||
subscriptions := make([]bosonFunc.Subscription, 0, len(triggers.Items))
|
||||
for _, trigger := range triggers.Items {
|
||||
if triggerMatches(&trigger) {
|
||||
filterAttrs := trigger.Spec.Filter.Attributes
|
||||
subscription := faas.Subscription{
|
||||
subscription := bosonFunc.Subscription{
|
||||
Source: filterAttrs["source"],
|
||||
Type: filterAttrs["type"],
|
||||
Broker: trigger.Spec.Broker,
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@ import (
|
|||
clientservingv1 "knative.dev/client/pkg/serving/v1"
|
||||
"knative.dev/pkg/apis"
|
||||
|
||||
"github.com/boson-project/faas"
|
||||
"github.com/boson-project/faas/k8s"
|
||||
bosonFunc "github.com/boson-project/func"
|
||||
"github.com/boson-project/func/k8s"
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
@ -31,7 +31,7 @@ func NewLister(namespaceOverride string) (l *Lister, err error) {
|
|||
return
|
||||
}
|
||||
|
||||
func (l *Lister) List() (items []faas.ListItem, err error) {
|
||||
func (l *Lister) List() (items []bosonFunc.ListItem, err error) {
|
||||
|
||||
client, err := NewServingClient(l.Namespace)
|
||||
if err != nil {
|
||||
|
|
@ -61,7 +61,7 @@ func (l *Lister) List() (items []faas.ListItem, err error) {
|
|||
}
|
||||
}
|
||||
|
||||
listItem := faas.ListItem{
|
||||
listItem := bosonFunc.ListItem{
|
||||
Name: name,
|
||||
Namespace: service.Namespace,
|
||||
Runtime: service.Labels["boson.dev/runtime"],
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import (
|
|||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/boson-project/faas/k8s"
|
||||
"github.com/boson-project/func/k8s"
|
||||
)
|
||||
|
||||
func NewRemover(namespaceOverride string) (remover *Remover, err error) {
|
||||
|
|
@ -36,7 +36,7 @@ func (remover *Remover) Remove(name string) (err error) {
|
|||
}
|
||||
|
||||
fmt.Printf("Removing Knative Service: %v\n", serviceName)
|
||||
|
||||
|
||||
err = client.DeleteService(serviceName, time.Second*60)
|
||||
if err != nil {
|
||||
err = fmt.Errorf("knative remover failed to delete the service: %v", err)
|
||||
|
|
|
|||
|
|
@ -1,19 +1,19 @@
|
|||
package mock
|
||||
|
||||
import "github.com/boson-project/faas"
|
||||
import bosonFunc "github.com/boson-project/func"
|
||||
|
||||
type Builder struct {
|
||||
BuildInvoked bool
|
||||
BuildFn func(faas.Function) error
|
||||
BuildFn func(bosonFunc.Function) error
|
||||
}
|
||||
|
||||
func NewBuilder() *Builder {
|
||||
return &Builder{
|
||||
BuildFn: func(faas.Function) error { return nil },
|
||||
BuildFn: func(bosonFunc.Function) error { return nil },
|
||||
}
|
||||
}
|
||||
|
||||
func (i *Builder) Build(f faas.Function) error {
|
||||
func (i *Builder) Build(f bosonFunc.Function) error {
|
||||
i.BuildInvoked = true
|
||||
return i.BuildFn(f)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,19 +1,19 @@
|
|||
package mock
|
||||
|
||||
import "github.com/boson-project/faas"
|
||||
import bosonFunc "github.com/boson-project/func"
|
||||
|
||||
type Deployer struct {
|
||||
DeployInvoked bool
|
||||
DeployFn func(faas.Function) error
|
||||
DeployFn func(bosonFunc.Function) error
|
||||
}
|
||||
|
||||
func NewDeployer() *Deployer {
|
||||
return &Deployer{
|
||||
DeployFn: func(faas.Function) error { return nil },
|
||||
DeployFn: func(bosonFunc.Function) error { return nil },
|
||||
}
|
||||
}
|
||||
|
||||
func (i *Deployer) Deploy(f faas.Function) error {
|
||||
func (i *Deployer) Deploy(f bosonFunc.Function) error {
|
||||
i.DeployInvoked = true
|
||||
return i.DeployFn(f)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,19 +1,19 @@
|
|||
package mock
|
||||
|
||||
import "github.com/boson-project/faas"
|
||||
import bosonFunc "github.com/boson-project/func"
|
||||
|
||||
type Lister struct {
|
||||
ListInvoked bool
|
||||
ListFn func() ([]faas.ListItem, error)
|
||||
ListFn func() ([]bosonFunc.ListItem, error)
|
||||
}
|
||||
|
||||
func NewLister() *Lister {
|
||||
return &Lister{
|
||||
ListFn: func() ([]faas.ListItem, error) { return []faas.ListItem{}, nil },
|
||||
ListFn: func() ([]bosonFunc.ListItem, error) { return []bosonFunc.ListItem{}, nil },
|
||||
}
|
||||
}
|
||||
|
||||
func (l *Lister) List() ([]faas.ListItem, error) {
|
||||
func (l *Lister) List() ([]bosonFunc.ListItem, error) {
|
||||
l.ListInvoked = true
|
||||
return l.ListFn()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,19 +1,19 @@
|
|||
package mock
|
||||
|
||||
import "github.com/boson-project/faas"
|
||||
import bosonFunc "github.com/boson-project/func"
|
||||
|
||||
type Pusher struct {
|
||||
PushInvoked bool
|
||||
PushFn func(faas.Function) (string, error)
|
||||
PushFn func(bosonFunc.Function) (string, error)
|
||||
}
|
||||
|
||||
func NewPusher() *Pusher {
|
||||
return &Pusher{
|
||||
PushFn: func(faas.Function) (string, error) { return "", nil },
|
||||
PushFn: func(bosonFunc.Function) (string, error) { return "", nil },
|
||||
}
|
||||
}
|
||||
|
||||
func (i *Pusher) Push(f faas.Function) (string, error) {
|
||||
func (i *Pusher) Push(f bosonFunc.Function) (string, error) {
|
||||
i.PushInvoked = true
|
||||
return i.PushFn(f)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
package mock
|
||||
|
||||
import "github.com/boson-project/faas"
|
||||
import bosonFunc "github.com/boson-project/func"
|
||||
|
||||
type Runner struct {
|
||||
RunInvoked bool
|
||||
|
|
@ -11,7 +11,7 @@ func NewRunner() *Runner {
|
|||
return &Runner{}
|
||||
}
|
||||
|
||||
func (r *Runner) Run(f faas.Function) error {
|
||||
func (r *Runner) Run(f bosonFunc.Function) error {
|
||||
r.RunInvoked = true
|
||||
r.RootRequested = f.Root
|
||||
return nil
|
||||
|
|
|
|||
|
|
@ -1,28 +1,30 @@
|
|||
package plugin
|
||||
|
||||
import (
|
||||
"github.com/boson-project/faas/cmd"
|
||||
"knative.dev/client/pkg/kn/plugin"
|
||||
"os"
|
||||
"runtime/debug"
|
||||
"strings"
|
||||
|
||||
"knative.dev/client/pkg/kn/plugin"
|
||||
|
||||
"github.com/boson-project/func/cmd"
|
||||
)
|
||||
|
||||
func init() {
|
||||
plugin.InternalPlugins = append(plugin.InternalPlugins, &faasPlugin{})
|
||||
plugin.InternalPlugins = append(plugin.InternalPlugins, &funcPlugin{})
|
||||
}
|
||||
|
||||
type faasPlugin struct {}
|
||||
type funcPlugin struct{}
|
||||
|
||||
func (f *faasPlugin) Name() string {
|
||||
func (f *funcPlugin) Name() string {
|
||||
return "kn-func"
|
||||
}
|
||||
|
||||
func (f *faasPlugin) Execute(args []string) error {
|
||||
func (f *funcPlugin) Execute(args []string) error {
|
||||
rootCmd := cmd.NewRootCmd()
|
||||
info, _ := debug.ReadBuildInfo()
|
||||
for _, dep := range info.Deps {
|
||||
if strings.Contains(dep.Path, "boson-project/faas") {
|
||||
if strings.Contains(dep.Path, "boson-project/func") {
|
||||
cmd.SetMeta("", dep.Version, dep.Sum)
|
||||
}
|
||||
}
|
||||
|
|
@ -30,20 +32,20 @@ func (f *faasPlugin) Execute(args []string) error {
|
|||
defer (func() {
|
||||
os.Args = oldArgs
|
||||
})()
|
||||
os.Args = append([]string { "kn-func" }, args...)
|
||||
os.Args = append([]string{"kn-func"}, args...)
|
||||
return rootCmd.Execute()
|
||||
}
|
||||
|
||||
// Description for function subcommand visible in 'kn --help'
|
||||
func (f *faasPlugin) Description() (string, error) {
|
||||
func (f *funcPlugin) Description() (string, error) {
|
||||
return "Function plugin", nil
|
||||
}
|
||||
|
||||
func (f *faasPlugin) CommandParts() []string {
|
||||
return []string{ "func"}
|
||||
func (f *funcPlugin) CommandParts() []string {
|
||||
return []string{"func"}
|
||||
}
|
||||
|
||||
// Path is empty because its an internal plugins
|
||||
func (f *faasPlugin) Path() string {
|
||||
func (f *funcPlugin) Path() string {
|
||||
return ""
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import (
|
|||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/boson-project/faas/prompt"
|
||||
"github.com/boson-project/func/prompt"
|
||||
)
|
||||
|
||||
// TestForStringLabel ensures that a string prompt with a given label is printed to stdout.
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package faas
|
||||
package function
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
|
|
|||
|
|
@ -18,5 +18,5 @@ curl -X POST -d '{"hello": "world"}' \
|
|||
http://myFunction.example.com/
|
||||
```
|
||||
|
||||
For more, see [the complete documentation]('https://github.com/boson-project/faas/tree/main/docs')
|
||||
For more, see [the complete documentation]('https://github.com/boson-project/func/tree/main/docs')
|
||||
|
||||
|
|
|
|||
|
|
@ -15,6 +15,6 @@ library, and it can be invoked from your browser or from the command line:
|
|||
curl http://myfunction.example.com/
|
||||
```
|
||||
|
||||
For more, see [the complete documentation]('https://github.com/boson-project/faas/tree/main/docs')
|
||||
For more, see [the complete documentation]('https://github.com/boson-project/func/tree/main/docs')
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package faas
|
||||
package function
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
|
|
|||
|
|
@ -1,23 +1,24 @@
|
|||
package utils
|
||||
|
||||
import(
|
||||
import (
|
||||
"sort"
|
||||
"strings"
|
||||
"github.com/boson-project/faas/buildpacks"
|
||||
|
||||
"github.com/boson-project/func/buildpacks"
|
||||
)
|
||||
|
||||
//RuntimeList returns the list of supported runtimes
|
||||
//RuntimeList returns the list of supported runtimes
|
||||
//as comma seperated strings
|
||||
func RuntimeList() string {
|
||||
rb := buildpacks.RuntimeToBuildpack
|
||||
runtimes := make([]string, 0, len(rb))
|
||||
for k := range rb {
|
||||
rb := buildpacks.RuntimeToBuildpack
|
||||
runtimes := make([]string, 0, len(rb))
|
||||
for k := range rb {
|
||||
runtimes = append(runtimes, k)
|
||||
}
|
||||
sort.Strings(runtimes)
|
||||
//make it more grammatical :)
|
||||
s := runtimes[:len(runtimes)-1]
|
||||
str := strings.Join(s,", ")
|
||||
str = str + " and " + runtimes[len(runtimes)-1]
|
||||
return str
|
||||
}
|
||||
}
|
||||
sort.Strings(runtimes)
|
||||
//make it more grammatical :)
|
||||
s := runtimes[:len(runtimes)-1]
|
||||
str := strings.Join(s, ", ")
|
||||
str = str + " and " + runtimes[len(runtimes)-1]
|
||||
return str
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue