Remove newlines from log lines, which are not required

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
This commit is contained in:
Alex Ellis (OpenFaaS Ltd) 2024-09-17 11:18:07 +01:00
parent 1c1bfa6759
commit 5b633cc017
9 changed files with 21 additions and 14 deletions

View File

@ -36,12 +36,16 @@ var rootCommand = &cobra.Command{
Use: "faasd", Use: "faasd",
Short: "Start faasd", Short: "Start faasd",
Long: ` Long: `
faasd - Serverless For Everyone Else faasd Community Edition (CE):
Learn how to build, secure, and monitor functions with faasd with Learn how to build, secure, and monitor functions with faasd with
the eBook: the eBook:
https://openfaas.gumroad.com/l/serverless-for-everyone-else https://openfaas.gumroad.com/l/serverless-for-everyone-else
License: OpenFaaS CE EULA with faasd addendum:
https://github.com/openfaas/faasd/blob/master/EULA.md
`, `,
RunE: runRootCommand, RunE: runRootCommand,
SilenceUsage: true, SilenceUsage: true,
@ -68,7 +72,7 @@ func parseBaseCommand(_ *cobra.Command, _ []string) {
} }
func printVersion() { func printVersion() {
fmt.Printf("faasd version: %s\tcommit: %s\n", pkg.GetVersion(), pkg.GitCommit) fmt.Printf("faasd Community Edition (CE) version: %s\tcommit: %s\n", pkg.GetVersion(), pkg.GitCommit)
} }
func printLogo() { func printLogo() {

View File

@ -9,7 +9,7 @@ import (
// ConnectivityCheck checks if the controller can reach the // ConnectivityCheck checks if the controller can reach the
// public Internet via HTTPS. // public Internet via HTTPS.
// A license is required to use OpenFaaS for Commercial Use. // A license is required to use OpenFaaS CE for Commercial Use.
func ConnectivityCheck() error { func ConnectivityCheck() error {
req, err := http.NewRequest(http.MethodGet, "https://checkip.amazonaws.com", nil) req, err := http.NewRequest(http.MethodGet, "https://checkip.amazonaws.com", nil)
if err != nil { if err != nil {
@ -27,7 +27,10 @@ func ConnectivityCheck() error {
} }
if res.StatusCode != http.StatusOK { if res.StatusCode != http.StatusOK {
body, _ := io.ReadAll(res.Body) var body []byte
if res.Body != nil {
body, _ = io.ReadAll(res.Body)
}
return fmt.Errorf("unexpected status code checking connectivity: %d, body: %s", res.StatusCode, strings.TrimSpace(string(body))) return fmt.Errorf("unexpected status code checking connectivity: %d, body: %s", res.StatusCode, strings.TrimSpace(string(body)))
} }

View File

@ -33,7 +33,7 @@ func MakeDeleteHandler(client *containerd.Client, cni gocni.CNI) func(w http.Res
req := types.DeleteFunctionRequest{} req := types.DeleteFunctionRequest{}
if err := json.Unmarshal(body, &req); err != nil { if err := json.Unmarshal(body, &req); err != nil {
log.Printf("[Delete] error parsing input: %s\n", err) log.Printf("[Delete] error parsing input: %s", err)
http.Error(w, err.Error(), http.StatusBadRequest) http.Error(w, err.Error(), http.StatusBadRequest)
return return

View File

@ -44,7 +44,7 @@ func MakeDeployHandler(client *containerd.Client, cni gocni.CNI, secretMountPath
req := types.FunctionDeployment{} req := types.FunctionDeployment{}
err := json.Unmarshal(body, &req) err := json.Unmarshal(body, &req)
if err != nil { if err != nil {
log.Printf("[Deploy] - error parsing input: %s\n", err) log.Printf("[Deploy] - error parsing input: %s", err)
http.Error(w, err.Error(), http.StatusBadRequest) http.Error(w, err.Error(), http.StatusBadRequest)
return return

View File

@ -31,7 +31,7 @@ func MakeReadHandler(client *containerd.Client) func(w http.ResponseWriter, r *h
res := []types.FunctionStatus{} res := []types.FunctionStatus{}
fns, err := ListFunctions(client, lookupNamespace) fns, err := ListFunctions(client, lookupNamespace)
if err != nil { if err != nil {
log.Printf("[Read] error listing functions. Error: %s\n", err) log.Printf("[Read] error listing functions. Error: %s", err)
http.Error(w, err.Error(), http.StatusBadRequest) http.Error(w, err.Error(), http.StatusBadRequest)
return return
} }

View File

@ -31,7 +31,7 @@ func MakeReplicaUpdateHandler(client *containerd.Client, cni gocni.CNI) func(w h
req := types.ScaleServiceRequest{} req := types.ScaleServiceRequest{}
if err := json.Unmarshal(body, &req); err != nil { if err := json.Unmarshal(body, &req); err != nil {
log.Printf("[Scale] error parsing input: %s\n", err) log.Printf("[Scale] error parsing input: %s", err)
http.Error(w, err.Error(), http.StatusBadRequest) http.Error(w, err.Error(), http.StatusBadRequest)
return return

View File

@ -71,7 +71,7 @@ func listSecrets(store provider.Labeller, w http.ResponseWriter, r *http.Request
} }
if err != nil { if err != nil {
fmt.Printf("Error Occured: %s \n", err) log.Printf("[Secret] Error listing secrets: %s ", err)
http.Error(w, err.Error(), http.StatusInternalServerError) http.Error(w, err.Error(), http.StatusInternalServerError)
return return
} }

View File

@ -33,7 +33,7 @@ func MakeUpdateHandler(client *containerd.Client, cni gocni.CNI, secretMountPath
req := types.FunctionDeployment{} req := types.FunctionDeployment{}
err := json.Unmarshal(body, &req) err := json.Unmarshal(body, &req)
if err != nil { if err != nil {
log.Printf("[Update] error parsing input: %s\n", err) log.Printf("[Update] error parsing input: %s", err)
http.Error(w, err.Error(), http.StatusBadRequest) http.Error(w, err.Error(), http.StatusBadRequest)
return return

View File

@ -227,7 +227,7 @@ func (s *Supervisor) Start(svcs []Service) error {
) )
if err != nil { if err != nil {
log.Printf("Error creating container: %s\n", err) log.Printf("Error creating container: %s", err)
return err return err
} }
@ -235,7 +235,7 @@ func (s *Supervisor) Start(svcs []Service) error {
task, err := newContainer.NewTask(ctx, cio.BinaryIO("/usr/local/bin/faasd", nil)) task, err := newContainer.NewTask(ctx, cio.BinaryIO("/usr/local/bin/faasd", nil))
if err != nil { if err != nil {
log.Printf("Error creating task: %s\n", err) log.Printf("Error creating task: %s", err)
return err return err
} }
@ -268,7 +268,7 @@ func (s *Supervisor) Start(svcs []Service) error {
} }
if _, err := task.Wait(ctx); err != nil { if _, err := task.Wait(ctx); err != nil {
log.Printf("Task wait error: %s\n", err) log.Printf("Task wait error: %s", err)
return err return err
} }
@ -276,7 +276,7 @@ func (s *Supervisor) Start(svcs []Service) error {
// log.Println("Exited: ", exitStatusC) // log.Println("Exited: ", exitStatusC)
if err = task.Start(ctx); err != nil { if err = task.Start(ctx); err != nil {
log.Printf("Task start error: %s\n", err) log.Printf("Task start error: %s", err)
return err return err
} }
} }