Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use the logger from std lib at cmd entry #67

Merged
merged 1 commit into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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