fix daemon 's host flag

This commit is contained in:
Lei Xue
2022-12-10 22:05:19 +08:00
parent d92d540c52
commit 8a3e19f0c9
3 changed files with 17 additions and 10 deletions

View File

@@ -23,13 +23,15 @@ import (
"strings"
"syscall"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"github.com/gostor/gotgt/pkg/apiserver"
"github.com/gostor/gotgt/pkg/config"
_ "github.com/gostor/gotgt/pkg/port/iscsit"
"github.com/gostor/gotgt/pkg/scsi"
_ "github.com/gostor/gotgt/pkg/scsi/backingstore"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)
func newDaemonCommand() *cobra.Command {
@@ -41,7 +43,11 @@ func newDaemonCommand() *cobra.Command {
Use: "daemon",
Short: "Setup a daemon",
Long: `Setup the Gotgt's daemon`,
PreRun: func(cmd *cobra.Command, args []string) {
viper.BindPFlags(cmd.Flags())
},
RunE: func(cmd *cobra.Command, args []string) error {
host = viper.GetString("host")
return createDaemon(host, driver, logLevel, blockMultipleHosts)
},
}