Skip to content

Commit

Permalink
Remove viper from VolumeCreate
Browse files Browse the repository at this point in the history
Refer to lf-edge#855

Signed-off-by: Pavel Abramov <uncle.decart@gmail.com>
  • Loading branch information
uncleDecart committed Mar 27, 2023
1 parent 2649672 commit efcb4d8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
15 changes: 9 additions & 6 deletions cmd/edenVolume.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,20 @@ import (
"github.com/spf13/cobra"
)

func newVolumeCmd() *cobra.Command {
func newVolumeCmd(configName, verbosity *string) *cobra.Command {
cfg := &openevec.EdenSetupArgs{}

var volumeCmd = &cobra.Command{
Use: "volume",
Use: "volume",
PersistentPreRunE: preRunViperLoadFunction(cfg, configName, verbosity),
}

groups := CommandGroups{
{
Message: "Basic Commands",
Commands: []*cobra.Command{
newVolumeLsCmd(),
newVolumeCreateCmd(),
newVolumeCreateCmd(cfg),
newVolumeDeleteCmd(),
newVolumeDetachCmd(),
newVolumeAttachCmd(),
Expand All @@ -44,7 +47,7 @@ func newVolumeLsCmd() *cobra.Command {
return volumeLsCmd
}

func newVolumeCreateCmd() *cobra.Command {
func newVolumeCreateCmd(cfg *openevec.EdenSetupArgs) *cobra.Command {
var registry, diskSize, volumeName, volumeType, datastoreOverride string
var sftpLoad, directLoad bool

Expand All @@ -55,8 +58,8 @@ func newVolumeCreateCmd() *cobra.Command {
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
appLink := args[0]
err := openevec.VolumeCreate(appLink, registry, diskSize, volumeName,
volumeType, datastoreOverride, sftpLoad, directLoad)
err := openevec.VolumeCreate(appLink, registry, cfg.Registry.IP, diskSize, volumeName,
volumeType, datastoreOverride, cfg.Registry.Port, sftpLoad, directLoad)
if err != nil {
log.Fatal(err)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func NewEdenCommand() *cobra.Command {
newUtilsCmd(&configName, &verbosity),
newControllerCmd(&configName, &verbosity),
newNetworkCmd(),
newVolumeCmd(),
newVolumeCmd(&configName, &verbosity),
newDisksCmd(),
newPacketCmd(&configName, &verbosity),
newRolCmd(&configName, &verbosity),
Expand Down
5 changes: 2 additions & 3 deletions pkg/openevec/edenVolume.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"github.com/lf-edge/eve/api/go/config"
uuid "github.com/satori/go.uuid"
log "github.com/sirupsen/logrus"
"github.com/spf13/viper"
)

func VolumeLs() error {
Expand All @@ -35,7 +34,7 @@ func VolumeLs() error {
return nil
}

func VolumeCreate(appLink, registry, diskSize, volumeName, volumeType, datastoreOverride string, sftpLoad, directLoad bool) error {
func VolumeCreate(appLink, registry, registryIp, diskSize, volumeName, volumeType, datastoreOverride string, registryPort int, sftpLoad, directLoad bool) error {
changer := &adamChanger{}
ctrl, dev, err := changer.getControllerAndDev()
if err != nil {
Expand Down Expand Up @@ -82,7 +81,7 @@ func VolumeCreate(appLink, registry, diskSize, volumeName, volumeType, datastore
registryToUse := registry
switch registry {
case "local":
registryToUse = fmt.Sprintf("%s:%d", viper.GetString("registry.ip"), viper.GetInt("registry.port"))
registryToUse = fmt.Sprintf("%s:%d", registryIp, registryPort)
case "remote":
registryToUse = ""
}
Expand Down

0 comments on commit efcb4d8

Please sign in to comment.