From 5b633cc017e594c4ed29fe83efd6b426ce7acdbe Mon Sep 17 00:00:00 2001 From: "Alex Ellis (OpenFaaS Ltd)" Date: Tue, 17 Sep 2024 11:18:07 +0100 Subject: [PATCH] Remove newlines from log lines, which are not required Signed-off-by: Alex Ellis (OpenFaaS Ltd) --- cmd/root.go | 8 ++++++-- pkg/connectivity.go | 7 +++++-- pkg/provider/handlers/delete.go | 2 +- pkg/provider/handlers/deploy.go | 2 +- pkg/provider/handlers/read.go | 2 +- pkg/provider/handlers/scale.go | 2 +- pkg/provider/handlers/secret.go | 2 +- pkg/provider/handlers/update.go | 2 +- pkg/supervisor.go | 8 ++++---- 9 files changed, 21 insertions(+), 14 deletions(-) diff --git a/cmd/root.go b/cmd/root.go index acb91f5d..ec85af8d 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -36,12 +36,16 @@ var rootCommand = &cobra.Command{ Use: "faasd", Short: "Start faasd", Long: ` -faasd - Serverless For Everyone Else +faasd Community Edition (CE): Learn how to build, secure, and monitor functions with faasd with the eBook: 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, SilenceUsage: true, @@ -68,7 +72,7 @@ func parseBaseCommand(_ *cobra.Command, _ []string) { } 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() { diff --git a/pkg/connectivity.go b/pkg/connectivity.go index 6547ac92..a837cf3d 100644 --- a/pkg/connectivity.go +++ b/pkg/connectivity.go @@ -9,7 +9,7 @@ import ( // ConnectivityCheck checks if the controller can reach the // 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 { req, err := http.NewRequest(http.MethodGet, "https://checkip.amazonaws.com", nil) if err != nil { @@ -27,7 +27,10 @@ func ConnectivityCheck() error { } 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))) } diff --git a/pkg/provider/handlers/delete.go b/pkg/provider/handlers/delete.go index 73e968f0..fb054be6 100644 --- a/pkg/provider/handlers/delete.go +++ b/pkg/provider/handlers/delete.go @@ -33,7 +33,7 @@ func MakeDeleteHandler(client *containerd.Client, cni gocni.CNI) func(w http.Res req := types.DeleteFunctionRequest{} 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) return diff --git a/pkg/provider/handlers/deploy.go b/pkg/provider/handlers/deploy.go index 94497b08..2ed91bc1 100644 --- a/pkg/provider/handlers/deploy.go +++ b/pkg/provider/handlers/deploy.go @@ -44,7 +44,7 @@ func MakeDeployHandler(client *containerd.Client, cni gocni.CNI, secretMountPath req := types.FunctionDeployment{} err := json.Unmarshal(body, &req) 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) return diff --git a/pkg/provider/handlers/read.go b/pkg/provider/handlers/read.go index 8eda1d0f..f7fd94e6 100644 --- a/pkg/provider/handlers/read.go +++ b/pkg/provider/handlers/read.go @@ -31,7 +31,7 @@ func MakeReadHandler(client *containerd.Client) func(w http.ResponseWriter, r *h res := []types.FunctionStatus{} fns, err := ListFunctions(client, lookupNamespace) 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) return } diff --git a/pkg/provider/handlers/scale.go b/pkg/provider/handlers/scale.go index d137f88f..c759a9ed 100644 --- a/pkg/provider/handlers/scale.go +++ b/pkg/provider/handlers/scale.go @@ -31,7 +31,7 @@ func MakeReplicaUpdateHandler(client *containerd.Client, cni gocni.CNI) func(w h req := types.ScaleServiceRequest{} 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) return diff --git a/pkg/provider/handlers/secret.go b/pkg/provider/handlers/secret.go index 6c249ce7..3aeb67cc 100644 --- a/pkg/provider/handlers/secret.go +++ b/pkg/provider/handlers/secret.go @@ -71,7 +71,7 @@ func listSecrets(store provider.Labeller, w http.ResponseWriter, r *http.Request } 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) return } diff --git a/pkg/provider/handlers/update.go b/pkg/provider/handlers/update.go index 50d22538..57918d38 100644 --- a/pkg/provider/handlers/update.go +++ b/pkg/provider/handlers/update.go @@ -33,7 +33,7 @@ func MakeUpdateHandler(client *containerd.Client, cni gocni.CNI, secretMountPath req := types.FunctionDeployment{} err := json.Unmarshal(body, &req) 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) return diff --git a/pkg/supervisor.go b/pkg/supervisor.go index c95051ea..a2a73354 100644 --- a/pkg/supervisor.go +++ b/pkg/supervisor.go @@ -227,7 +227,7 @@ func (s *Supervisor) Start(svcs []Service) error { ) if err != nil { - log.Printf("Error creating container: %s\n", err) + log.Printf("Error creating container: %s", 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)) if err != nil { - log.Printf("Error creating task: %s\n", err) + log.Printf("Error creating task: %s", err) return err } @@ -268,7 +268,7 @@ func (s *Supervisor) Start(svcs []Service) error { } if _, err := task.Wait(ctx); err != nil { - log.Printf("Task wait error: %s\n", err) + log.Printf("Task wait error: %s", err) return err } @@ -276,7 +276,7 @@ func (s *Supervisor) Start(svcs []Service) error { // log.Println("Exited: ", exitStatusC) if err = task.Start(ctx); err != nil { - log.Printf("Task start error: %s\n", err) + log.Printf("Task start error: %s", err) return err } }