src: rename from faas to func (#253)

Signed-off-by: Zbynek Roubalik <zroubali@redhat.com>
This commit is contained in:
Zbynek Roubalik 2021-01-21 17:10:39 +01:00 committed by GitHub
parent 8d1f5b833d
commit a5cbe3061b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
43 changed files with 268 additions and 255 deletions

View File

@ -2,7 +2,7 @@ style: github
template: CHANGELOG.tpl.md template: CHANGELOG.tpl.md
info: info:
title: CHANGELOG title: CHANGELOG
repository_url: https://github.com/boson-project/faas repository_url: https://github.com/boson-project/func
options: options:
commits: commits:
filters: filters:

View File

@ -1,11 +1,11 @@
# Boson Function CLI # Boson Function CLI
[![Main Build Status](https://github.com/boson-project/faas/workflows/Main/badge.svg?branch=main)](https://github.com/boson-project/faas/actions?query=workflow%3AMain+branch%3Amain) [![Main Build Status](https://github.com/boson-project/func/workflows/Main/badge.svg?branch=main)](https://github.com/boson-project/func/actions?query=workflow%3AMain+branch%3Amain)
[![Develop Build Status](https://github.com/boson-project/faas/workflows/Develop/badge.svg?branch=develop&label=develop)](https://github.com/boson-project/faas/actions?query=workflow%3ADevelop+branch%3Adevelop) [![Develop Build Status](https://github.com/boson-project/func/workflows/Develop/badge.svg?branch=develop&label=develop)](https://github.com/boson-project/func/actions?query=workflow%3ADevelop+branch%3Adevelop)
[![Client API Documentation](https://godoc.org/github.com/boson-project/faas?status.svg)](http://godoc.org/github.com/boson-project/faas) [![Client API Documentation](https://godoc.org/github.com/boson-project/func?status.svg)](http://godoc.org/github.com/boson-project/func)
[![GitHub Issues](https://img.shields.io/github/issues/boson-project/faas.svg)](https://github.com/boson-project/faas/issues) [![GitHub Issues](https://img.shields.io/github/issues/boson-project/func.svg)](https://github.com/boson-project/func/issues)
[![License](https://img.shields.io/github/license/boson-project/faas)](https://github.com/boson-project/faas/blob/main/LICENSE) [![License](https://img.shields.io/github/license/boson-project/func)](https://github.com/boson-project/func/blob/main/LICENSE)
[![Release](https://img.shields.io/github/release/boson-project/faas.svg?label=Release)](https://github.com/boson-project/faas/releases) [![Release](https://img.shields.io/github/release/boson-project/func.svg?label=Release)](https://github.com/boson-project/func/releases)
[Demo Screencast] [Demo Screencast]

View File

@ -11,10 +11,10 @@ import (
"github.com/buildpacks/pack" "github.com/buildpacks/pack"
"github.com/buildpacks/pack/logging" "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 //Buildpack builder
type Builder struct { type Builder struct {
Verbose bool Verbose bool
@ -28,14 +28,14 @@ func NewBuilder() *Builder {
//RuntimeToBuildpack holds the mapping between the Runtime and its corresponding //RuntimeToBuildpack holds the mapping between the Runtime and its corresponding
//Buildpack builder to use //Buildpack builder to use
var RuntimeToBuildpack = map[string]string{ var RuntimeToBuildpack = map[string]string{
"quarkus": "quay.io/boson/faas-quarkus-builder", "quarkus": "quay.io/boson/faas-quarkus-builder",
"node": "quay.io/boson/faas-nodejs-builder", "node": "quay.io/boson/faas-nodejs-builder",
"go": "quay.io/boson/faas-go-builder", "go": "quay.io/boson/faas-go-builder",
"springboot": "quay.io/boson/faas-springboot-builder", "springboot": "quay.io/boson/faas-springboot-builder",
} }
// Build the Function at path. // 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 // Use the builder found in the Function configuration file
// If one isn't found, use the defaults // If one isn't found, use the defaults

View File

@ -1,4 +1,4 @@
package faas package function
import ( import (
"fmt" "fmt"

View File

@ -1,4 +1,4 @@
package faas_test package function_test
import ( import (
"fmt" "fmt"
@ -7,8 +7,8 @@ import (
"path/filepath" "path/filepath"
"testing" "testing"
"github.com/boson-project/faas" bosonFunc "github.com/boson-project/func"
"github.com/boson-project/faas/mock" "github.com/boson-project/func/mock"
) )
// TestRegistry for calculating destination image during tests. // TestRegistry for calculating destination image during tests.
@ -28,10 +28,10 @@ func TestNew(t *testing.T) {
defer os.RemoveAll(root) defer os.RemoveAll(root)
// New Client // New Client
client := faas.New(faas.WithRegistry(TestRegistry)) client := bosonFunc.New(bosonFunc.WithRegistry(TestRegistry))
// New Function using Client // 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) t.Fatal(err)
} }
} }
@ -44,14 +44,14 @@ func TestTemplateWrites(t *testing.T) {
} }
defer os.RemoveAll(root) defer os.RemoveAll(root)
client := faas.New(faas.WithRegistry(TestRegistry)) client := bosonFunc.New(bosonFunc.WithRegistry(TestRegistry))
if err := client.Create(faas.Function{Root: root}); err != nil { if err := client.Create(bosonFunc.Function{Root: root}); err != nil {
t.Fatal(err) t.Fatal(err)
} }
// Assert file was written // Assert file was written
if _, err := os.Stat(filepath.Join(root, faas.ConfigFile)); os.IsNotExist(err) { if _, err := os.Stat(filepath.Join(root, bosonFunc.ConfigFile)); os.IsNotExist(err) {
t.Fatalf("Initialize did not result in '%v' being written to '%v'", faas.ConfigFile, root) 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) defer os.RemoveAll(root)
// New once // New once
client := faas.New(faas.WithRegistry(TestRegistry)) client := bosonFunc.New(bosonFunc.WithRegistry(TestRegistry))
if err := client.New(faas.Function{Root: root}); err != nil { if err := client.New(bosonFunc.Function{Root: root}); err != nil {
t.Fatal(err) t.Fatal(err)
} }
// New again should fail as already initialized // 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") t.Fatal("error expected initilizing a path already containing an initialized Function")
} }
} }
@ -91,8 +91,8 @@ func TestNonemptyDirectoryAborts(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
client := faas.New(faas.WithRegistry(TestRegistry)) client := bosonFunc.New(bosonFunc.WithRegistry(TestRegistry))
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 Function in a nonempty directory") t.Fatal("error expected initilizing a Function in a nonempty directory")
} }
} }
@ -116,8 +116,8 @@ func TestHiddenFilesIgnored(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
client := faas.New(faas.WithRegistry(TestRegistry)) client := bosonFunc.New(bosonFunc.WithRegistry(TestRegistry))
if err := client.New(faas.Function{Root: root}); err != nil { if err := client.New(bosonFunc.Function{Root: root}); err != nil {
t.Fatal(err) t.Fatal(err)
} }
} }
@ -133,19 +133,19 @@ func TestDefaultRuntime(t *testing.T) {
defer os.RemoveAll(root) defer os.RemoveAll(root)
// Create a new function at root with all defaults. // Create a new function at root with all defaults.
client := faas.New(faas.WithRegistry(TestRegistry)) client := bosonFunc.New(bosonFunc.WithRegistry(TestRegistry))
if err := client.New(faas.Function{Root: root}); err != nil { if err := client.New(bosonFunc.Function{Root: root}); err != nil {
t.Fatal(err) t.Fatal(err)
} }
// Load the function // Load the function
f, err := faas.NewFunction(root) f, err := bosonFunc.NewFunction(root)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
// Ensure it has defaulted runtime // 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.") t.Fatal("The default runtime was not applied or persisted.")
} }
} }
@ -175,12 +175,12 @@ func TestExtensibleTemplates(t *testing.T) {
defer os.RemoveAll(root) defer os.RemoveAll(root)
// Create a new client with a path to the extensible templates // Create a new client with a path to the extensible templates
client := faas.New( client := bosonFunc.New(
faas.WithTemplates("testdata/templates"), bosonFunc.WithTemplates("testdata/templates"),
faas.WithRegistry(TestRegistry)) bosonFunc.WithRegistry(TestRegistry))
// Create a Function specifying a template, 'json' that only exists in the extensible set // 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) t.Fatal(err)
} }
@ -201,11 +201,11 @@ func TestUnsupportedRuntime(t *testing.T) {
} }
defer os.RemoveAll(root) 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 // create a Function call witn an unsupported runtime should bubble
// the error generated by the underlying initializer. // 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") t.Fatal("unsupported runtime did not generate error")
} }
} }
@ -226,13 +226,13 @@ func TestNamed(t *testing.T) {
} }
defer os.RemoveAll(root) 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) t.Fatal(err)
} }
f, err := faas.NewFunction(root) f, err := bosonFunc.NewFunction(root)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -260,9 +260,9 @@ func TestRegistryRequired(t *testing.T) {
} }
defer os.RemoveAll(root) defer os.RemoveAll(root)
client := faas.New() client := bosonFunc.New()
var err error 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") t.Fatal("did not receive expected error creating a Function without specifying Registry")
} }
fmt.Println(err) fmt.Println(err)
@ -280,13 +280,13 @@ func TestDeriveImage(t *testing.T) {
defer os.RemoveAll(root) defer os.RemoveAll(root)
// Create the function which calculates fields such as name and image. // Create the function which calculates fields such as name and image.
client := faas.New(faas.WithRegistry(TestRegistry)) client := bosonFunc.New(bosonFunc.WithRegistry(TestRegistry))
if err := client.New(faas.Function{Root: root}); err != nil { if err := client.New(bosonFunc.Function{Root: root}); err != nil {
t.Fatal(err) t.Fatal(err)
} }
// Load the function with the now-populated fields. // Load the function with the now-populated fields.
f, err := faas.NewFunction(root) f, err := bosonFunc.NewFunction(root)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -312,18 +312,18 @@ func TestDeriveImageDefaultRegistry(t *testing.T) {
// Create the function which calculates fields such as name and image. // Create the function which calculates fields such as name and image.
// Rather than use TestRegistry, use a single-token name and expect // Rather than use TestRegistry, use a single-token name and expect
// the DefaultRegistry to be prepended. // the DefaultRegistry to be prepended.
client := faas.New(faas.WithRegistry("alice")) client := bosonFunc.New(bosonFunc.WithRegistry("alice"))
if err := client.New(faas.Function{Root: root}); err != nil { if err := client.New(bosonFunc.Function{Root: root}); err != nil {
t.Fatal(err) t.Fatal(err)
} }
// Load the function with the now-populated fields. // Load the function with the now-populated fields.
f, err := faas.NewFunction(root) f, err := bosonFunc.NewFunction(root)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
// Expected image is [DefaultRegistry]/[namespace]/[servicename]:latest // 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 { if f.Image != expected {
t.Fatalf("expected image '%v' got '%v'", expected, f.Image) t.Fatalf("expected image '%v' got '%v'", expected, f.Image)
} }
@ -349,11 +349,11 @@ func TestNewDelegates(t *testing.T) {
defer os.RemoveAll(root) defer os.RemoveAll(root)
// Create a client with mocks for each of the subcomponents. // Create a client with mocks for each of the subcomponents.
client := faas.New( client := bosonFunc.New(
faas.WithRegistry(TestRegistry), bosonFunc.WithRegistry(TestRegistry),
faas.WithBuilder(builder), // builds an image bosonFunc.WithBuilder(builder), // builds an image
faas.WithPusher(pusher), // pushes images to a registry bosonFunc.WithPusher(pusher), // pushes images to a registry
faas.WithDeployer(deployer), // deploys images as a running service bosonFunc.WithDeployer(deployer), // deploys images as a running service
) )
// Register Function delegates on the mocks which validate assertions // 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 // The builder should be invoked with a path to a Function project's source
// An example image name is returned. // 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) expectedPath, err := filepath.Abs(root)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
@ -372,14 +372,14 @@ func TestNewDelegates(t *testing.T) {
return nil return nil
} }
pusher.PushFn = func(f faas.Function) (string, error) { pusher.PushFn = func(f bosonFunc.Function) (string, error) {
if f.Image != expectedImage { if f.Image != expectedImage {
t.Fatalf("pusher expected image '%v', got '%v'", expectedImage, f.Image) t.Fatalf("pusher expected image '%v', got '%v'", expectedImage, f.Image)
} }
return "", nil return "", nil
} }
deployer.DeployFn = func(f faas.Function) error { deployer.DeployFn = func(f bosonFunc.Function) error {
if f.Name != expectedName { if f.Name != expectedName {
t.Fatalf("deployer expected name '%v', got '%v'", expectedName, f.Name) 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 // Invoke the creation, triggering the Function delegates, and
// perform follow-up assertions that the Functions were indeed invoked. // 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) t.Fatal(err)
} }
@ -421,8 +421,8 @@ func TestRun(t *testing.T) {
// Create a client with the mock runner and the new test Function // Create a client with the mock runner and the new test Function
runner := mock.NewRunner() runner := mock.NewRunner()
client := faas.New(faas.WithRegistry(TestRegistry), faas.WithRunner(runner)) client := bosonFunc.New(bosonFunc.WithRegistry(TestRegistry), bosonFunc.WithRunner(runner))
if err := client.New(faas.Function{Root: root}); err != nil { if err := client.New(bosonFunc.Function{Root: root}); err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -463,19 +463,19 @@ func TestUpdate(t *testing.T) {
defer os.RemoveAll(root) defer os.RemoveAll(root)
// A client with mocks whose implementaton will validate input. // A client with mocks whose implementaton will validate input.
client := faas.New( client := bosonFunc.New(
faas.WithRegistry(TestRegistry), bosonFunc.WithRegistry(TestRegistry),
faas.WithBuilder(builder), bosonFunc.WithBuilder(builder),
faas.WithPusher(pusher), bosonFunc.WithPusher(pusher),
faas.WithDeployer(deployer)) bosonFunc.WithDeployer(deployer))
// create the new Function which will be updated // 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) t.Fatal(err)
} }
// Builder whose implementation verifies the expected root // 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) rootPath, err := filepath.Abs(root)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
@ -487,7 +487,7 @@ func TestUpdate(t *testing.T) {
} }
// Pusher whose implementaiton verifies the expected image // 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 { if f.Image != expectedImage {
t.Fatalf("pusher expected image '%v', got '%v'", expectedImage, f.Image) 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 // 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 { if f.Name != expectedName {
t.Fatalf("updater expected name '%v', got '%v'", expectedName, f.Name) t.Fatalf("updater expected name '%v', got '%v'", expectedName, f.Name)
} }
@ -537,11 +537,11 @@ func TestRemoveByPath(t *testing.T) {
} }
defer os.RemoveAll(root) defer os.RemoveAll(root)
client := faas.New( client := bosonFunc.New(
faas.WithRegistry(TestRegistry), bosonFunc.WithRegistry(TestRegistry),
faas.WithRemover(remover)) 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) t.Fatal(err)
} }
@ -552,7 +552,7 @@ func TestRemoveByPath(t *testing.T) {
return nil 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) t.Fatal(err)
} }
@ -576,11 +576,11 @@ func TestRemoveByName(t *testing.T) {
} }
defer os.RemoveAll(root) defer os.RemoveAll(root)
client := faas.New( client := bosonFunc.New(
faas.WithRegistry(TestRegistry), bosonFunc.WithRegistry(TestRegistry),
faas.WithRemover(remover)) 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) t.Fatal(err)
} }
@ -592,12 +592,12 @@ func TestRemoveByName(t *testing.T) {
} }
// Run remove with only a name // 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) t.Fatal(err)
} }
// Run remove with a name and a root, which should be ignored in favor of the name. // 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) t.Fatal(err)
} }
@ -627,12 +627,12 @@ func TestRemoveUninitializedFails(t *testing.T) {
} }
// Instantiate the client with the failing remover. // Instantiate the client with the failing remover.
client := faas.New( client := bosonFunc.New(
faas.WithRegistry(TestRegistry), bosonFunc.WithRegistry(TestRegistry),
faas.WithRemover(remover)) bosonFunc.WithRemover(remover))
// Attempt to remove by path (uninitialized), expecting an error. // 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") 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) { func TestList(t *testing.T) {
lister := mock.NewLister() 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 { if _, err := client.List(); err != nil {
t.Fatal(err) t.Fatal(err)
@ -660,7 +660,7 @@ func TestListOutsideRoot(t *testing.T) {
lister := mock.NewLister() lister := mock.NewLister()
// Instantiate in the current working directory, with no name. // 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 { if _, err := client.List(); err != nil {
t.Fatal(err) t.Fatal(err)

View File

@ -6,9 +6,9 @@ import (
"github.com/ory/viper" "github.com/ory/viper"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/boson-project/faas" "github.com/boson-project/func/buildpacks"
"github.com/boson-project/faas/buildpacks" bosonFunc "github.com/boson-project/func"
"github.com/boson-project/faas/prompt" "github.com/boson-project/func/prompt"
) )
func init() { 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 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. and the image name is stored in the configuration file.
`, `,
Example: ` Example: `
# Build from the local directory, using the given registry as target. # Build from the local directory, using the given registry as target.
# The full image name will be determined automatically based on the # The full image name will be determined automatically based on the
# project directory name # project directory name
@ -95,10 +95,10 @@ func runBuild(cmd *cobra.Command, _ []string) (err error) {
builder := buildpacks.NewBuilder() builder := buildpacks.NewBuilder()
builder.Verbose = config.Verbose builder.Verbose = config.Verbose
client := faas.New( client := bosonFunc.New(
faas.WithVerbose(config.Verbose), bosonFunc.WithVerbose(config.Verbose),
faas.WithRegistry(config.Registry), // for deriving image name when --image not provided explicitly. bosonFunc.WithRegistry(config.Registry), // for deriving image name when --image not provided explicitly.
faas.WithBuilder(builder)) bosonFunc.WithBuilder(builder))
return client.Build(config.Path) return client.Build(config.Path)
} }

View File

@ -2,14 +2,15 @@ package cmd
import ( import (
"encoding/json" "encoding/json"
"github.com/boson-project/faas"
"os" "os"
"os/user" "os/user"
"path" "path"
"github.com/boson-project/faas/buildpacks"
"github.com/boson-project/faas/knative"
"github.com/spf13/cobra" "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) { 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 return
} }
for _, item := range list{ for _, item := range list {
strings = append(strings, item.Name) strings = append(strings, item.Name)
} }
directive = cobra.ShellCompDirectiveDefault directive = cobra.ShellCompDirectiveDefault
@ -78,7 +79,7 @@ func CompleteBuilderList(cmd *cobra.Command, args []string, complete string) (st
var ( var (
err error err error
path string path string
f faas.Function f bosonFunc.Function
) )
path, err = cmd.Flags().GetString("path") path, err = cmd.Flags().GetString("path")
@ -86,7 +87,7 @@ func CompleteBuilderList(cmd *cobra.Command, args []string, complete string) (st
return return
} }
f, err = faas.NewFunction(path) f, err = bosonFunc.NewFunction(path)
if err != nil { if err != nil {
return return
} }

View File

@ -7,17 +7,17 @@ import (
"github.com/ory/viper" "github.com/ory/viper"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/boson-project/faas" bosonFunc "github.com/boson-project/func"
"github.com/boson-project/faas/prompt" "github.com/boson-project/func/prompt"
"github.com/boson-project/faas/utils" "github.com/boson-project/func/utils"
) )
func init() { func init() {
root.AddCommand(createCmd) root.AddCommand(createCmd)
createCmd.Flags().BoolP("confirm", "c", false, "Prompt to confirm all configuration options (Env: $FUNC_CONFIRM)") 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("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 { if err := createCmd.RegisterFlagCompletionFunc("runtime", CompleteRuntimeList); err != nil {
fmt.Println("internal: error while calling RegisterFlagCompletionFunc: ", err) 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 { func runCreate(cmd *cobra.Command, args []string) error {
config := newCreateConfig(args).Prompt() config := newCreateConfig(args).Prompt()
function := faas.Function{ function := bosonFunc.Function{
Name: config.Name, Name: config.Name,
Root: config.Path, Root: config.Path,
Runtime: config.Runtime, Runtime: config.Runtime,
Trigger: config.Trigger, Trigger: config.Trigger,
} }
client := faas.New( client := bosonFunc.New(
faas.WithTemplates(config.Templates), bosonFunc.WithTemplates(config.Templates),
faas.WithVerbose(config.Verbose)) bosonFunc.WithVerbose(config.Verbose))
return client.Create(function) 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 // 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 // for additional templates not included in the binary. If not provided
// explicitly as a flag (--templates) or env (FAAS_TEMPLATES), the default // explicitly as a flag (--templates) or env (FUNC_TEMPLATES), the default
// location is $XDG_CONFIG_HOME/templates ($HOME/.config/faas/templates) // location is $XDG_CONFIG_HOME/templates ($HOME/.config/func/templates)
Templates string Templates string
// Trigger is the form of the resultant Function, i.e. the Function signature // Trigger is the form of the resultant Function, i.e. the Function signature

View File

@ -6,9 +6,9 @@ import (
"github.com/ory/viper" "github.com/ory/viper"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/boson-project/faas" bosonFunc "github.com/boson-project/func"
"github.com/boson-project/faas/knative" "github.com/boson-project/func/knative"
"github.com/boson-project/faas/prompt" "github.com/boson-project/func/prompt"
) )
func init() { func init() {
@ -45,7 +45,7 @@ kn func delete -n apps myfunc
func runDelete(cmd *cobra.Command, args []string) (err error) { func runDelete(cmd *cobra.Command, args []string) (err error) {
config := newDeleteConfig(args).Prompt() config := newDeleteConfig(args).Prompt()
function, err := faas.NewFunction(config.Path) function, err := bosonFunc.NewFunction(config.Path)
if err != nil { if err != nil {
return return
} }
@ -67,9 +67,9 @@ func runDelete(cmd *cobra.Command, args []string) (err error) {
remover.Verbose = config.Verbose remover.Verbose = config.Verbose
client := faas.New( client := bosonFunc.New(
faas.WithVerbose(config.Verbose), bosonFunc.WithVerbose(config.Verbose),
faas.WithRemover(remover)) bosonFunc.WithRemover(remover))
return client.Remove(function) return client.Remove(function)
} }

View File

@ -2,15 +2,16 @@ package cmd
import ( import (
"fmt" "fmt"
"github.com/ory/viper" "github.com/ory/viper"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/boson-project/faas" bosonFunc "github.com/boson-project/func"
"github.com/boson-project/faas/buildpacks" "github.com/boson-project/func/buildpacks"
"github.com/boson-project/faas/docker" "github.com/boson-project/func/docker"
"github.com/boson-project/faas/knative" "github.com/boson-project/func/knative"
"github.com/boson-project/faas/progress" "github.com/boson-project/func/progress"
"github.com/boson-project/faas/prompt" "github.com/boson-project/func/prompt"
) )
func init() { func init() {
@ -47,7 +48,7 @@ kn func deploy --registry quay.io/myuser
# the namespace "myns" # the namespace "myns"
kn func deploy --image quay.io/myuser/myfunc -n 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"), PreRunE: bindEnv("image", "namespace", "path", "registry", "confirm"),
RunE: runDeploy, RunE: runDeploy,
} }
@ -111,13 +112,13 @@ func runDeploy(cmd *cobra.Command, _ []string) (err error) {
deployer.Verbose = config.Verbose deployer.Verbose = config.Verbose
client := faas.New( client := bosonFunc.New(
faas.WithVerbose(config.Verbose), bosonFunc.WithVerbose(config.Verbose),
faas.WithRegistry(config.Registry), // for deriving image name when --image not provided explicitly. bosonFunc.WithRegistry(config.Registry), // for deriving image name when --image not provided explicitly.
faas.WithBuilder(builder), bosonFunc.WithBuilder(builder),
faas.WithPusher(pusher), bosonFunc.WithPusher(pusher),
faas.WithDeployer(deployer), bosonFunc.WithDeployer(deployer),
faas.WithProgressListener(listener)) bosonFunc.WithProgressListener(listener))
return client.Deploy(config.Path) return client.Deploy(config.Path)

View File

@ -11,8 +11,8 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
"gopkg.in/yaml.v2" "gopkg.in/yaml.v2"
"github.com/boson-project/faas" bosonFunc "github.com/boson-project/func"
"github.com/boson-project/faas/knative" "github.com/boson-project/func/knative"
) )
func init() { func init() {
@ -51,7 +51,7 @@ kn func describe --output yaml --path myotherfunc
func runDescribe(cmd *cobra.Command, args []string) (err error) { func runDescribe(cmd *cobra.Command, args []string) (err error) {
config := newDescribeConfig(args) config := newDescribeConfig(args)
function, err := faas.NewFunction(config.Path) function, err := bosonFunc.NewFunction(config.Path)
if err != nil { if err != nil {
return return
} }
@ -67,9 +67,9 @@ func runDescribe(cmd *cobra.Command, args []string) (err error) {
} }
describer.Verbose = config.Verbose describer.Verbose = config.Verbose
client := faas.New( client := bosonFunc.New(
faas.WithVerbose(config.Verbose), bosonFunc.WithVerbose(config.Verbose),
faas.WithDescriber(describer)) bosonFunc.WithDescriber(describer))
d, err := client.Describe(config.Name, config.Path) d, err := client.Describe(config.Name, config.Path)
if err != nil { if err != nil {
@ -109,7 +109,7 @@ func newDescribeConfig(args []string) describeConfig {
// Output Formatting (serializers) // Output Formatting (serializers)
// ------------------------------- // -------------------------------
type description faas.Description type description bosonFunc.Description
func (d description) Human(w io.Writer) error { func (d description) Human(w io.Writer) error {
fmt.Fprintln(w, "Function name:") fmt.Fprintln(w, "Function name:")

View File

@ -1,7 +1,7 @@
package main package main
import ( import (
"github.com/boson-project/faas/cmd" "github.com/boson-project/func/cmd"
) )
// Statically-populated build metadata set // Statically-populated build metadata set

View File

@ -12,8 +12,8 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
"gopkg.in/yaml.v2" "gopkg.in/yaml.v2"
"github.com/boson-project/faas" bosonFunc "github.com/boson-project/func"
"github.com/boson-project/faas/knative" "github.com/boson-project/func/knative"
) )
func init() { func init() {
@ -66,9 +66,9 @@ func runList(cmd *cobra.Command, args []string) (err error) {
lister.Namespace = "" lister.Namespace = ""
} }
client := faas.New( client := bosonFunc.New(
faas.WithVerbose(config.Verbose), bosonFunc.WithVerbose(config.Verbose),
faas.WithLister(lister)) bosonFunc.WithLister(lister))
items, err := client.List() items, err := client.List()
if err != nil { if err != nil {
@ -105,7 +105,7 @@ func newListConfig() listConfig {
// Output Formatting (serializers) // Output Formatting (serializers)
// ------------------------------- // -------------------------------
type listItems []faas.ListItem type listItems []bosonFunc.ListItem
func (items listItems) Human(w io.Writer) error { func (items listItems) Human(w io.Writer) error {
return items.Plain(w) return items.Plain(w)

View File

@ -10,7 +10,7 @@ import (
"github.com/ory/viper" "github.com/ory/viper"
"github.com/spf13/cobra" "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 // 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 { func NewRootCmd() *cobra.Command {
return root return root
} }
@ -146,8 +146,8 @@ type functionOverrides struct {
// Function project at root, if provided, and returns the Function // Function project at root, if provided, and returns the Function
// configuration values. // configuration values.
// Please note that When this function is called, the overrides are not persisted. // Please note that When this function is called, the overrides are not persisted.
func functionWithOverrides(root string, overrides functionOverrides) (f faas.Function, err error) { func functionWithOverrides(root string, overrides functionOverrides) (f bosonFunc.Function, err error) {
f, err = faas.NewFunction(root) f, err = bosonFunc.NewFunction(root)
if err != nil { if err != nil {
return 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 // 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 != "" { if err == nil && f.Name != "" {
return f.Name return f.Name
} }
@ -236,15 +236,15 @@ func deriveImage(explicitImage, defaultRegistry, path string) string {
if explicitImage != "" { if explicitImage != "" {
return explicitImage // use the explicit value provided. return explicitImage // use the explicit value provided.
} }
f, err := faas.NewFunction(path) f, err := bosonFunc.NewFunction(path)
if err != nil { if err != nil {
return "" // unable to derive due to load error (uninitialized?) return "" // unable to derive due to load error (uninitialized?)
} }
if f.Image != "" { if f.Image != "" {
return f.Image // use value previously provided or derived. return f.Image // use value previously provided or derived.
} }
derivedValue, _ := faas.DerivedImage(path, defaultRegistry) derivedValue, _ := bosonFunc.DerivedImage(path, defaultRegistry)
return derivedValue // Use the faas system's derivation logic. return derivedValue // Use the func system's derivation logic.
} }
func envVarsFromCmd(cmd *cobra.Command) map[string]string { 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 { 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 { for name, value := range dest {
if strings.HasSuffix(name, "-") { if strings.HasSuffix(name, "-") {

View File

@ -6,8 +6,8 @@ import (
"github.com/ory/viper" "github.com/ory/viper"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/boson-project/faas" bosonFunc "github.com/boson-project/func"
"github.com/boson-project/faas/docker" "github.com/boson-project/func/docker"
) )
func init() { func init() {
@ -40,7 +40,7 @@ kn func run
func runRun(cmd *cobra.Command, args []string) (err error) { func runRun(cmd *cobra.Command, args []string) (err error) {
config := newRunConfig(cmd) config := newRunConfig(cmd)
function, err := faas.NewFunction(config.Path) function, err := bosonFunc.NewFunction(config.Path)
if err != nil { if err != nil {
return return
} }
@ -60,9 +60,9 @@ func runRun(cmd *cobra.Command, args []string) (err error) {
runner := docker.NewRunner() runner := docker.NewRunner()
runner.Verbose = config.Verbose runner.Verbose = config.Verbose
client := faas.New( client := bosonFunc.New(
faas.WithRunner(runner), bosonFunc.WithRunner(runner),
faas.WithVerbose(config.Verbose)) bosonFunc.WithVerbose(config.Verbose))
return client.Run(config.Path) return client.Run(config.Path)
} }

View File

@ -1,4 +1,4 @@
package faas package function
import ( import (
"io/ioutil" "io/ioutil"

View File

@ -9,7 +9,7 @@ import (
"os/exec" "os/exec"
"strings" "strings"
"github.com/boson-project/faas" bosonFunc "github.com/boson-project/func"
) )
// Pusher of images from local to remote registry. // Pusher of images from local to remote registry.
@ -24,7 +24,7 @@ func NewPusher() *Pusher {
} }
// Push the image of the Function. // 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 // Check for the docker binary explicitly so that we can return
// an extra-friendly error message. // an extra-friendly error message.
_, err = exec.LookPath("docker") _, err = exec.LookPath("docker")

View File

@ -7,7 +7,7 @@ import (
"os/exec" "os/exec"
"strings" "strings"
"github.com/boson-project/faas" bosonFunc "github.com/boson-project/func"
) )
// Runner of functions using the docker command. // Runner of functions using the docker command.
@ -22,7 +22,7 @@ func NewRunner() *Runner {
} }
// Run the function at path // 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 // Check for the docker binary explicitly so that we can return
// an extra-friendly error message. // an extra-friendly error message.
_, err := exec.LookPath("docker") _, err := exec.LookPath("docker")

View File

@ -6,8 +6,8 @@ import (
"os" "os"
"testing" "testing"
"github.com/boson-project/faas" bosonFunc "github.com/boson-project/func"
"github.com/boson-project/faas/docker" "github.com/boson-project/func/docker"
) )
// Docker Run Integraiton Test // Docker Run Integraiton Test
@ -24,7 +24,7 @@ func TestDockerRun(t *testing.T) {
t.Skip() t.Skip()
} }
f, err := faas.NewFunction("testdata/example.com/runnable") f, err := bosonFunc.NewFunction("testdata/example.com/runnable")
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }

View File

@ -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 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 ### DNS

View File

@ -15,9 +15,9 @@ docker run quay.io/boson/func:v0.9.0
### Prebuilt Binary ### 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 ### From Source

View File

@ -11,22 +11,22 @@ package main
import ( import (
"log" "log"
"github.com/boson-project/faas" bosonFunc "github.com/boson-project/func"
"github.com/boson-project/faas/buildpacks" "github.com/boson-project/func/buildpacks"
"github.com/boson-project/faas/docker" "github.com/boson-project/func/docker"
"github.com/boson-project/faas/embedded" "github.com/boson-project/func/embedded"
"github.com/boson-project/faas/knative" "github.com/boson-project/func/knative"
) )
func main() { func main() {
// A client which uses embedded function templates, // A client which uses embedded function templates,
// Quay.io/alice for interstitial build artifacts. // Quay.io/alice for interstitial build artifacts.
// Docker to build and push, and a Knative client for deployment. // Docker to build and push, and a Knative client for deployment.
client, err := faas.New( client, err := bosonFunc.New(
faas.WithInitializer(embedded.NewInitializer("")), bosonFunc.WithInitializer(embedded.NewInitializer("")),
faas.WithBuilder(buildpacks.NewBuilder("quay.io/alice/my-function")), bosonFunc.WithBuilder(buildpacks.NewBuilder("quay.io/alice/my-function")),
faas.WithPusher(docker.NewPusher()), bosonFunc.WithPusher(docker.NewPusher()),
faas.WithDeployer(knative.NewDeployer())) bosonFunc.WithDeployer(knative.NewDeployer()))
// Create a Go function which listens for CloudEvents. // Create a Go function which listens for CloudEvents.
// Publicly routable as https://www.example.com. // Publicly routable as https://www.example.com.

View File

@ -1,4 +1,4 @@
package faas package function
import ( import (
"errors" "errors"

View File

@ -1,4 +1,4 @@
package faas package function
import "testing" import "testing"

4
go.mod
View File

@ -1,4 +1,4 @@
module github.com/boson-project/faas module github.com/boson-project/func
go 1.14 go 1.14
@ -8,8 +8,6 @@ require (
github.com/mitchellh/go-homedir v1.1.0 github.com/mitchellh/go-homedir v1.1.0
github.com/ory/viper v1.7.4 github.com/ory/viper v1.7.4
github.com/spf13/cobra v1.0.1-0.20201006035406-b97b5ead31f7 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 gopkg.in/yaml.v2 v2.3.0
k8s.io/api v0.18.8 k8s.io/api v0.18.8
k8s.io/apimachinery v0.19.1 k8s.io/apimachinery v0.19.1

2
go.sum
View File

@ -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-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 h1:ikNHVSjEfnvz6sxdSPCaPt572qowuyMDMJLLm3Db3ig=
golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= 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-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-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190125153040-c74c464bbbf2/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190125153040-c74c464bbbf2/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=

View File

@ -13,8 +13,8 @@ import (
servingv1 "knative.dev/serving/pkg/apis/serving/v1" servingv1 "knative.dev/serving/pkg/apis/serving/v1"
v1 "knative.dev/serving/pkg/apis/serving/v1" v1 "knative.dev/serving/pkg/apis/serving/v1"
"github.com/boson-project/faas" bosonFunc "github.com/boson-project/func"
"github.com/boson-project/faas/k8s" "github.com/boson-project/func/k8s"
) )
type Deployer struct { type Deployer struct {
@ -35,7 +35,7 @@ func NewDeployer(namespaceOverride string) (deployer *Deployer, err error) {
return 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 // k8s does not support service names with dots. so encode it such that
// www.my-domain,com -> www-my--domain-com // www.my-domain,com -> www-my--domain-com

View File

@ -5,8 +5,8 @@ import (
v1 "knative.dev/client/pkg/serving/v1" v1 "knative.dev/client/pkg/serving/v1"
"knative.dev/eventing/pkg/apis/eventing/v1beta1" "knative.dev/eventing/pkg/apis/eventing/v1beta1"
"github.com/boson-project/faas" bosonFunc "github.com/boson-project/func"
"github.com/boson-project/faas/k8s" "github.com/boson-project/func/k8s"
) )
type Describer struct { 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 // 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: // 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 // 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) serviceName, err := k8s.ToK8sAllowedName(name)
if err != nil { 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 { for _, trigger := range triggers.Items {
if triggerMatches(&trigger) { if triggerMatches(&trigger) {
filterAttrs := trigger.Spec.Filter.Attributes filterAttrs := trigger.Spec.Filter.Attributes
subscription := faas.Subscription{ subscription := bosonFunc.Subscription{
Source: filterAttrs["source"], Source: filterAttrs["source"],
Type: filterAttrs["type"], Type: filterAttrs["type"],
Broker: trigger.Spec.Broker, Broker: trigger.Spec.Broker,

View File

@ -5,8 +5,8 @@ import (
clientservingv1 "knative.dev/client/pkg/serving/v1" clientservingv1 "knative.dev/client/pkg/serving/v1"
"knative.dev/pkg/apis" "knative.dev/pkg/apis"
"github.com/boson-project/faas" bosonFunc "github.com/boson-project/func"
"github.com/boson-project/faas/k8s" "github.com/boson-project/func/k8s"
) )
const ( const (
@ -31,7 +31,7 @@ func NewLister(namespaceOverride string) (l *Lister, err error) {
return return
} }
func (l *Lister) List() (items []faas.ListItem, err error) { func (l *Lister) List() (items []bosonFunc.ListItem, err error) {
client, err := NewServingClient(l.Namespace) client, err := NewServingClient(l.Namespace)
if err != nil { if err != nil {
@ -61,7 +61,7 @@ func (l *Lister) List() (items []faas.ListItem, err error) {
} }
} }
listItem := faas.ListItem{ listItem := bosonFunc.ListItem{
Name: name, Name: name,
Namespace: service.Namespace, Namespace: service.Namespace,
Runtime: service.Labels["boson.dev/runtime"], Runtime: service.Labels["boson.dev/runtime"],

View File

@ -4,7 +4,7 @@ import (
"fmt" "fmt"
"time" "time"
"github.com/boson-project/faas/k8s" "github.com/boson-project/func/k8s"
) )
func NewRemover(namespaceOverride string) (remover *Remover, err error) { 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) fmt.Printf("Removing Knative Service: %v\n", serviceName)
err = client.DeleteService(serviceName, time.Second*60) err = client.DeleteService(serviceName, time.Second*60)
if err != nil { if err != nil {
err = fmt.Errorf("knative remover failed to delete the service: %v", err) err = fmt.Errorf("knative remover failed to delete the service: %v", err)

View File

@ -1,19 +1,19 @@
package mock package mock
import "github.com/boson-project/faas" import bosonFunc "github.com/boson-project/func"
type Builder struct { type Builder struct {
BuildInvoked bool BuildInvoked bool
BuildFn func(faas.Function) error BuildFn func(bosonFunc.Function) error
} }
func NewBuilder() *Builder { func NewBuilder() *Builder {
return &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 i.BuildInvoked = true
return i.BuildFn(f) return i.BuildFn(f)
} }

View File

@ -1,19 +1,19 @@
package mock package mock
import "github.com/boson-project/faas" import bosonFunc "github.com/boson-project/func"
type Deployer struct { type Deployer struct {
DeployInvoked bool DeployInvoked bool
DeployFn func(faas.Function) error DeployFn func(bosonFunc.Function) error
} }
func NewDeployer() *Deployer { func NewDeployer() *Deployer {
return &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 i.DeployInvoked = true
return i.DeployFn(f) return i.DeployFn(f)
} }

View File

@ -1,19 +1,19 @@
package mock package mock
import "github.com/boson-project/faas" import bosonFunc "github.com/boson-project/func"
type Lister struct { type Lister struct {
ListInvoked bool ListInvoked bool
ListFn func() ([]faas.ListItem, error) ListFn func() ([]bosonFunc.ListItem, error)
} }
func NewLister() *Lister { func NewLister() *Lister {
return &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 l.ListInvoked = true
return l.ListFn() return l.ListFn()
} }

View File

@ -1,19 +1,19 @@
package mock package mock
import "github.com/boson-project/faas" import bosonFunc "github.com/boson-project/func"
type Pusher struct { type Pusher struct {
PushInvoked bool PushInvoked bool
PushFn func(faas.Function) (string, error) PushFn func(bosonFunc.Function) (string, error)
} }
func NewPusher() *Pusher { func NewPusher() *Pusher {
return &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 i.PushInvoked = true
return i.PushFn(f) return i.PushFn(f)
} }

View File

@ -1,6 +1,6 @@
package mock package mock
import "github.com/boson-project/faas" import bosonFunc "github.com/boson-project/func"
type Runner struct { type Runner struct {
RunInvoked bool RunInvoked bool
@ -11,7 +11,7 @@ func NewRunner() *Runner {
return &Runner{} return &Runner{}
} }
func (r *Runner) Run(f faas.Function) error { func (r *Runner) Run(f bosonFunc.Function) error {
r.RunInvoked = true r.RunInvoked = true
r.RootRequested = f.Root r.RootRequested = f.Root
return nil return nil

12
pkged.go Normal file

File diff suppressed because one or more lines are too long

View File

@ -1,28 +1,30 @@
package plugin package plugin
import ( import (
"github.com/boson-project/faas/cmd"
"knative.dev/client/pkg/kn/plugin"
"os" "os"
"runtime/debug" "runtime/debug"
"strings" "strings"
"knative.dev/client/pkg/kn/plugin"
"github.com/boson-project/func/cmd"
) )
func init() { 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" return "kn-func"
} }
func (f *faasPlugin) Execute(args []string) error { func (f *funcPlugin) Execute(args []string) error {
rootCmd := cmd.NewRootCmd() rootCmd := cmd.NewRootCmd()
info, _ := debug.ReadBuildInfo() info, _ := debug.ReadBuildInfo()
for _, dep := range info.Deps { 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) cmd.SetMeta("", dep.Version, dep.Sum)
} }
} }
@ -30,20 +32,20 @@ func (f *faasPlugin) Execute(args []string) error {
defer (func() { defer (func() {
os.Args = oldArgs os.Args = oldArgs
})() })()
os.Args = append([]string { "kn-func" }, args...) os.Args = append([]string{"kn-func"}, args...)
return rootCmd.Execute() return rootCmd.Execute()
} }
// Description for function subcommand visible in 'kn --help' // Description for function subcommand visible in 'kn --help'
func (f *faasPlugin) Description() (string, error) { func (f *funcPlugin) Description() (string, error) {
return "Function plugin", nil return "Function plugin", nil
} }
func (f *faasPlugin) CommandParts() []string { func (f *funcPlugin) CommandParts() []string {
return []string{ "func"} return []string{"func"}
} }
// Path is empty because its an internal plugins // Path is empty because its an internal plugins
func (f *faasPlugin) Path() string { func (f *funcPlugin) Path() string {
return "" return ""
} }

View File

@ -5,7 +5,7 @@ import (
"fmt" "fmt"
"testing" "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. // TestForStringLabel ensures that a string prompt with a given label is printed to stdout.

View File

@ -1,4 +1,4 @@
package faas package function
import ( import (
"errors" "errors"

View File

@ -18,5 +18,5 @@ curl -X POST -d '{"hello": "world"}' \
http://myFunction.example.com/ 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')

View File

@ -15,6 +15,6 @@ library, and it can be invoked from your browser or from the command line:
curl http://myfunction.example.com/ 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')

View File

@ -1,4 +1,4 @@
package faas package function
import ( import (
"os" "os"

View File

@ -1,23 +1,24 @@
package utils package utils
import( import (
"sort" "sort"
"strings" "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 //as comma seperated strings
func RuntimeList() string { func RuntimeList() string {
rb := buildpacks.RuntimeToBuildpack rb := buildpacks.RuntimeToBuildpack
runtimes := make([]string, 0, len(rb)) runtimes := make([]string, 0, len(rb))
for k := range rb { for k := range rb {
runtimes = append(runtimes, k) runtimes = append(runtimes, k)
} }
sort.Strings(runtimes) sort.Strings(runtimes)
//make it more grammatical :) //make it more grammatical :)
s := runtimes[:len(runtimes)-1] s := runtimes[:len(runtimes)-1]
str := strings.Join(s,", ") str := strings.Join(s, ", ")
str = str + " and " + runtimes[len(runtimes)-1] str = str + " and " + runtimes[len(runtimes)-1]
return str return str
} }