Skip to content

Commit

Permalink
cherry pick of #67: fix: use the logger from std lib at cmd entry (#72)
Browse files Browse the repository at this point in the history
  • Loading branch information
dkeven authored Dec 13, 2024
1 parent 3d96fb0 commit ca88b4d
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 16 deletions.
8 changes: 4 additions & 4 deletions cmd/ctl/os/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ package os

import (
"bytetrade.io/web3os/installer/cmd/ctl/options"
"bytetrade.io/web3os/installer/pkg/core/logger"
"bytetrade.io/web3os/installer/pkg/pipelines"
"github.com/spf13/cobra"
"log"
)

func NewCmdRootDownload() *cobra.Command {
Expand All @@ -28,7 +28,7 @@ func NewCmdDownload() *cobra.Command {
Run: func(cmd *cobra.Command, args []string) {

if err := pipelines.DownloadInstallationPackage(o); err != nil {
logger.Fatalf("download installation package error: %v", err)
log.Fatalf("error: %v", err)
}
},
}
Expand All @@ -45,7 +45,7 @@ func NewCmdDownloadWizard() *cobra.Command {
Run: func(cmd *cobra.Command, args []string) {

if err := pipelines.DownloadInstallationWizard(o); err != nil {
logger.Fatalf("download installation wizard error: %v", err)
log.Fatalf("error: %v", err)
}
},
}
Expand All @@ -62,7 +62,7 @@ func NewCmdCheckDownload() *cobra.Command {
Run: func(cmd *cobra.Command, args []string) {

if err := pipelines.CheckDownloadInstallationPackage(o); err != nil {
logger.Errorf("check download error: %v", err)
log.Fatalf("error: %v", err)
}
},
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/ctl/os/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ package os

import (
"bytetrade.io/web3os/installer/cmd/ctl/options"
"bytetrade.io/web3os/installer/pkg/core/logger"
"bytetrade.io/web3os/installer/pkg/pipelines"
"github.com/spf13/cobra"
"log"
)

type InstallOsOptions struct {
Expand All @@ -24,7 +24,7 @@ func NewCmdInstallOs() *cobra.Command {
Short: "Install Olares",
Run: func(cmd *cobra.Command, args []string) {
if err := pipelines.CliInstallTerminusPipeline(o.InstallOptions); err != nil {
logger.Fatalf("install Olares error: %v", err)
log.Fatalf("error: %v", err)
}
},
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/ctl/os/prepare.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ package os

import (
"bytetrade.io/web3os/installer/cmd/ctl/options"
"bytetrade.io/web3os/installer/pkg/core/logger"
"bytetrade.io/web3os/installer/pkg/pipelines"
"github.com/spf13/cobra"
"log"
)

type PrepareSystemOptions struct {
Expand All @@ -25,7 +25,7 @@ func NewCmdPrepare() *cobra.Command {
Run: func(cmd *cobra.Command, args []string) {

if err := pipelines.PrepareSystemPipeline(o.PrepareOptions); err != nil {
logger.Fatalf("prepare system error: %v", err)
log.Fatalf("error: %v", err)
}
},
}
Expand Down
6 changes: 5 additions & 1 deletion cmd/ctl/os/uninstall.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytetrade.io/web3os/installer/cmd/ctl/options"
"bytetrade.io/web3os/installer/pkg/pipelines"
"github.com/spf13/cobra"
"log"
)

type UninstallOsOptions struct {
Expand All @@ -22,7 +23,10 @@ func NewCmdUninstallOs() *cobra.Command {
Use: "uninstall",
Short: "Uninstall Olares",
Run: func(cmd *cobra.Command, args []string) {
pipelines.UninstallTerminusPipeline(o.UninstallOptions)
err := pipelines.UninstallTerminusPipeline(o.UninstallOptions)
if err != nil {
log.Fatalf("error: %v", err)
}
},
}
o.UninstallOptions.AddFlags(cmd)
Expand Down
7 changes: 3 additions & 4 deletions pkg/pipelines/install_terminus.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package pipelines
import (
"encoding/base64"
"fmt"
"github.com/pkg/errors"
"io/ioutil"
"path"
"path/filepath"
Expand All @@ -18,8 +19,7 @@ import (
func CliInstallTerminusPipeline(opts *options.CliTerminusInstallOptions) error {
var terminusVersion, _ = phase.GetTerminusVersion()
if terminusVersion != "" {
fmt.Printf("Olares is already installed, please uninstall it first.")
return nil
return errors.New("Olares is already installed, please uninstall it first.")
}

arg := common.NewArgument()
Expand All @@ -33,8 +33,7 @@ func CliInstallTerminusPipeline(opts *options.CliTerminusInstallOptions) error {

runtime, err := common.NewKubeRuntime(common.AllInOne, *arg)
if err != nil {
fmt.Printf("Error creating installation runtime: %v\n", err)
return nil
return fmt.Errorf("error creating runtime: %v", err)
}

manifest := path.Join(runtime.GetInstallerDir(), "installation.manifest")
Expand Down
6 changes: 3 additions & 3 deletions pkg/pipelines/prepare_system.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package pipelines

import (
"errors"
"fmt"
"os"
"path"
Expand All @@ -15,8 +16,7 @@ func PrepareSystemPipeline(opts *options.CliPrepareSystemOptions) error {

var terminusVersion, _ = phase.GetTerminusVersion()
if terminusVersion != "" {
fmt.Printf("Olares is already installed, please uninstall it first.")
return nil
return errors.New("Olares is already installed, please uninstall it first.")
}

var arg = common.NewArgument()
Expand All @@ -34,7 +34,7 @@ func PrepareSystemPipeline(opts *options.CliPrepareSystemOptions) error {

runtime, err := common.NewKubeRuntime(common.AllInOne, *arg)
if err != nil {
return err
return fmt.Errorf("error creating runtime: %w", err)
}

manifest := path.Join(runtime.GetInstallerDir(), "installation.manifest")
Expand Down

0 comments on commit ca88b4d

Please sign in to comment.