diff --git a/cmd/apply.go b/cmd/apply.go index 8dfbdc859..f3e626e93 100644 --- a/cmd/apply.go +++ b/cmd/apply.go @@ -113,6 +113,20 @@ func NewApplyCmd() *cobra.Command { outDir = homeDir } + // Get current working directory + currentDir, err := os.Getwd() + if err != nil { + cmdEvent.AddErrorMessage(err) + tracker.Track(cmdEvent) + + return fmt.Errorf("error while getting current working directory: %w", err) + } + + if outDir == "." { + outDir = currentDir + logrus.Debug("Set outDir to currentDir: ", currentDir) + } + if flags.BinPath == "" { flags.BinPath = filepath.Join(outDir, ".furyctl", "bin") } diff --git a/cmd/connect/openvpn.go b/cmd/connect/openvpn.go index 47f6ba6bd..5be458f9c 100644 --- a/cmd/connect/openvpn.go +++ b/cmd/connect/openvpn.go @@ -79,6 +79,20 @@ func NewOpenVPNCmd() *cobra.Command { outDir = homeDir } + // Get current working directory + currentDir, err := os.Getwd() + if err != nil { + cmdEvent.AddErrorMessage(err) + tracker.Track(cmdEvent) + + return fmt.Errorf("error while getting current working directory: %w", err) + } + + if outDir == "." { + outDir = currentDir + logrus.Debug("Set outDir to currentDir: ", currentDir) + } + // Parse furyctl.yaml config. logrus.Debug("Parsing furyctl.yaml file...") furyctlConf, err := yamlx.FromFileV3[config.Furyctl](flags.FuryctlPath) diff --git a/cmd/delete/cluster.go b/cmd/delete/cluster.go index eaf4fe5bd..735a4a8c5 100644 --- a/cmd/delete/cluster.go +++ b/cmd/delete/cluster.go @@ -99,6 +99,20 @@ func NewClusterCmd() *cobra.Command { outDir = homeDir } + // Get current working directory + currentDir, err := os.Getwd() + if err != nil { + cmdEvent.AddErrorMessage(err) + tracker.Track(cmdEvent) + + return fmt.Errorf("error while getting current working directory: %w", err) + } + + if outDir == "." { + outDir = currentDir + logrus.Debug("Set outDir to currentDir: ", currentDir) + } + if flags.BinPath == "" { flags.BinPath = filepath.Join(outDir, ".furyctl", "bin") } diff --git a/cmd/diff.go b/cmd/diff.go index de3c999dc..93de8d0a5 100644 --- a/cmd/diff.go +++ b/cmd/diff.go @@ -82,6 +82,20 @@ func NewDiffCmd() *cobra.Command { outDir = homeDir } + // Get current working directory + currentDir, err := os.Getwd() + if err != nil { + cmdEvent.AddErrorMessage(err) + tracker.Track(cmdEvent) + + return fmt.Errorf("error while getting current working directory: %w", err) + } + + if outDir == "." { + outDir = currentDir + logrus.Debug("Set outDir to currentDir: ", currentDir) + } + if flags.BinPath == "" { flags.BinPath = filepath.Join(outDir, ".furyctl", "bin") } diff --git a/cmd/dump/template.go b/cmd/dump/template.go index f177ea38d..c7920a394 100644 --- a/cmd/dump/template.go +++ b/cmd/dump/template.go @@ -171,7 +171,7 @@ The generated folder will be created starting from a provided templates folder a return fmt.Errorf("error while getting current directory: %w", err) } - if outDir == "" { + if outDir == "." { outDir = currentDir }