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

feat(cmd): use dot to specify current dir when using --outdir flag #557

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
14 changes: 14 additions & 0 deletions cmd/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
14 changes: 14 additions & 0 deletions cmd/connect/openvpn.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
14 changes: 14 additions & 0 deletions cmd/delete/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
14 changes: 14 additions & 0 deletions cmd/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/dump/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down