mirror of
https://github.com/openfaas/faasd.git
synced 2025-06-21 22:33:27 +00:00
Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
17845457e2 | |||
300d8b082a | |||
17a5e2c625 | |||
f0172e618a |
2
Makefile
2
Makefile
@ -1,6 +1,6 @@
|
|||||||
Version := $(shell git describe --tags --dirty)
|
Version := $(shell git describe --tags --dirty)
|
||||||
GitCommit := $(shell git rev-parse HEAD)
|
GitCommit := $(shell git rev-parse HEAD)
|
||||||
LDFLAGS := "-s -w -X pkg.Version=$(Version) -X pkg.GitCommit=$(GitCommit)"
|
LDFLAGS := "-s -w -X main.Version=$(Version) -X main.GitCommit=$(GitCommit)"
|
||||||
|
|
||||||
.PHONY: all
|
.PHONY: all
|
||||||
all: local
|
all: local
|
||||||
|
@ -82,8 +82,6 @@ go build
|
|||||||
# sudo ./faasd up
|
# sudo ./faasd up
|
||||||
```
|
```
|
||||||
|
|
||||||
You will then need to get the basic-auth password, it is written to `$GOPATH/src/github.com/alexellis/faasd/basic-auth-password` if you followed the above instructions.
|
|
||||||
The default Basic Auth username is `admin`, which is written to `$GOPATH/src/github.com/alexellis/faasd/basic-auth-user`, if you wish to use a non-standard user then create this file and add your username (no newlines or other characters)
|
|
||||||
### Build and run (binaries)
|
### Build and run (binaries)
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
@ -125,6 +123,11 @@ Since faas-containerd uses containerd heavily it is not running as a container,
|
|||||||
|
|
||||||
* Now go to the gateway's IP address as shown above on port 8080, i.e. http://172.19.0.3:8080 - you can also use this address to deploy OpenFaaS Functions via the `faas-cli`.
|
* Now go to the gateway's IP address as shown above on port 8080, i.e. http://172.19.0.3:8080 - you can also use this address to deploy OpenFaaS Functions via the `faas-cli`.
|
||||||
|
|
||||||
|
* basic-auth
|
||||||
|
|
||||||
|
You will then need to get the basic-auth password, it is written to `$GOPATH/src/github.com/alexellis/faasd/basic-auth-password` if you followed the above instructions.
|
||||||
|
The default Basic Auth username is `admin`, which is written to `$GOPATH/src/github.com/alexellis/faasd/basic-auth-user`, if you wish to use a non-standard user then create this file and add your username (no newlines or other characters)
|
||||||
|
|
||||||
#### Installation with systemd
|
#### Installation with systemd
|
||||||
|
|
||||||
* `faasd install` - install faasd and containerd with systemd, run in `$GOPATH/src/github.com/alexellis/faasd`
|
* `faasd install` - install faasd and containerd with systemd, run in `$GOPATH/src/github.com/alexellis/faasd`
|
||||||
|
92
cmd/root.go
92
cmd/root.go
@ -3,19 +3,10 @@ package cmd
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/alexellis/faasd/pkg"
|
|
||||||
"github.com/morikuni/aec"
|
"github.com/morikuni/aec"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
|
||||||
// Version as per git repo
|
|
||||||
Version string
|
|
||||||
|
|
||||||
// GitCommit as per git repo
|
|
||||||
GitCommit string
|
|
||||||
)
|
|
||||||
|
|
||||||
// WelcomeMessage to introduce ofc-bootstrap
|
// WelcomeMessage to introduce ofc-bootstrap
|
||||||
const WelcomeMessage = "Welcome to faasd"
|
const WelcomeMessage = "Welcome to faasd"
|
||||||
|
|
||||||
@ -25,39 +16,14 @@ func init() {
|
|||||||
rootCommand.AddCommand(installCmd)
|
rootCommand.AddCommand(installCmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
var rootCommand = &cobra.Command{
|
var (
|
||||||
Use: "faasd",
|
// GitCommit Git Commit SHA
|
||||||
Short: "Start faasd",
|
GitCommit string
|
||||||
Long: `
|
// Version version of the CLI
|
||||||
faasd - serverless without Kubernetes
|
Version string
|
||||||
`,
|
)
|
||||||
RunE: runRootCommand,
|
|
||||||
SilenceUsage: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
var versionCmd = &cobra.Command{
|
|
||||||
Use: "version",
|
|
||||||
Short: "Display version information.",
|
|
||||||
Run: parseBaseCommand,
|
|
||||||
}
|
|
||||||
|
|
||||||
func getVersion() string {
|
|
||||||
if len(Version) != 0 {
|
|
||||||
return Version
|
|
||||||
}
|
|
||||||
return "dev"
|
|
||||||
}
|
|
||||||
|
|
||||||
func parseBaseCommand(_ *cobra.Command, _ []string) {
|
|
||||||
printLogo()
|
|
||||||
|
|
||||||
fmt.Printf(
|
|
||||||
`faasd
|
|
||||||
Commit: %s
|
|
||||||
Version: %s
|
|
||||||
`, pkg.GitCommit, pkg.GetVersion())
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// Execute faasd
|
||||||
func Execute(version, gitCommit string) error {
|
func Execute(version, gitCommit string) error {
|
||||||
|
|
||||||
// Get Version and GitCommit values from main.go.
|
// Get Version and GitCommit values from main.go.
|
||||||
@ -70,6 +36,16 @@ func Execute(version, gitCommit string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var rootCommand = &cobra.Command{
|
||||||
|
Use: "faasd",
|
||||||
|
Short: "Start faasd",
|
||||||
|
Long: `
|
||||||
|
faasd - serverless without Kubernetes
|
||||||
|
`,
|
||||||
|
RunE: runRootCommand,
|
||||||
|
SilenceUsage: true,
|
||||||
|
}
|
||||||
|
|
||||||
func runRootCommand(cmd *cobra.Command, args []string) error {
|
func runRootCommand(cmd *cobra.Command, args []string) error {
|
||||||
|
|
||||||
printLogo()
|
printLogo()
|
||||||
@ -78,7 +54,39 @@ func runRootCommand(cmd *cobra.Command, args []string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var versionCmd = &cobra.Command{
|
||||||
|
Use: "version",
|
||||||
|
Short: "Display version information.",
|
||||||
|
Run: parseBaseCommand,
|
||||||
|
}
|
||||||
|
|
||||||
|
func parseBaseCommand(_ *cobra.Command, _ []string) {
|
||||||
|
printLogo()
|
||||||
|
|
||||||
|
fmt.Printf(
|
||||||
|
`faasd
|
||||||
|
Commit: %s
|
||||||
|
Version: %s
|
||||||
|
`, GitCommit, GetVersion())
|
||||||
|
}
|
||||||
|
|
||||||
func printLogo() {
|
func printLogo() {
|
||||||
logoText := aec.WhiteF.Apply(pkg.Logo)
|
logoText := aec.WhiteF.Apply(Logo)
|
||||||
fmt.Println(logoText)
|
fmt.Println(logoText)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetVersion get latest version
|
||||||
|
func GetVersion() string {
|
||||||
|
if len(Version) == 0 {
|
||||||
|
return "dev"
|
||||||
|
}
|
||||||
|
return Version
|
||||||
|
}
|
||||||
|
|
||||||
|
// Logo for version and root command
|
||||||
|
const Logo = ` __ _
|
||||||
|
/ _| __ _ __ _ ___ __| |
|
||||||
|
| |_ / _` + "`" + ` |/ _` + "`" + ` / __|/ _` + "`" + ` |
|
||||||
|
| _| (_| | (_| \__ \ (_| |
|
||||||
|
|_| \__,_|\__,_|___/\__,_|
|
||||||
|
`
|
||||||
|
12
main.go
12
main.go
@ -4,13 +4,19 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/alexellis/faasd/cmd"
|
"github.com/alexellis/faasd/cmd"
|
||||||
"github.com/alexellis/faasd/pkg"
|
)
|
||||||
|
|
||||||
|
// These values will be injected into these variables at the build time.
|
||||||
|
var (
|
||||||
|
// GitCommit Git Commit SHA
|
||||||
|
GitCommit string
|
||||||
|
// Version version of the CLI
|
||||||
|
Version string
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
if err := cmd.Execute(pkg.Version, pkg.GitCommit); err != nil {
|
if err := cmd.Execute(Version, GitCommit); err != nil {
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,23 +1 @@
|
|||||||
package pkg
|
package pkg
|
||||||
|
|
||||||
var (
|
|
||||||
//GitCommit Git Commit SHA
|
|
||||||
GitCommit string
|
|
||||||
//Version version of the CLI
|
|
||||||
Version string
|
|
||||||
)
|
|
||||||
|
|
||||||
//GetVersion get latest version
|
|
||||||
func GetVersion() string {
|
|
||||||
if len(Version) == 0 {
|
|
||||||
return "dev"
|
|
||||||
}
|
|
||||||
return Version
|
|
||||||
}
|
|
||||||
|
|
||||||
const Logo = ` __ _
|
|
||||||
/ _| __ _ __ _ ___ __| |
|
|
||||||
| |_ / _` + "`" + ` |/ _` + "`" + ` / __|/ _` + "`" + ` |
|
|
||||||
| _| (_| | (_| \__ \ (_| |
|
|
||||||
|_| \__,_|\__,_|___/\__,_|
|
|
||||||
`
|
|
||||||
|
Reference in New Issue
Block a user