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

Conversation

luigidematteis
Copy link

@luigidematteis luigidematteis commented Nov 20, 2024

This PR solves the issue #508.

Now is possible to use . to specify the current directory when using the --outdir flag.

In addition to the --outdir flag for the apply command, the same behavior has been implement also for the other commands that use it, which are: delete cluster, diff, connect openvpn and dump template.

Tests

  • Result of furyctl apply:
furyctl apply --outdir . --debug
...
Apply script completed.
  • Result of furyctl dump template:
furyctl dump template --workdir $(PWD) --outdir . --debug 
...       
INFO Distribution manifests generated successfully 
  • Result of furyctl diff command:
furyctl diff --workdir $(PWD) -o .
...
INFO No differences found from previous cluster configuration 
  • Check connect openvpn command:

Help needed

  • Result of furyctl delete cluster command:
furyctl delete cluster --workdir $(PWD) --outdir .
...
INFO Kubernetes Fury Distribution deleted successfully

Copy link
Contributor

@g-iannelli g-iannelli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like the change in default behavior for --output-dir. Using the user's home directory is safer than using the current directory. No one can guarantee that someone won't run a command like furyctl dump template -c /dir1/dir2/dir3/furcytl.yaml and write it to the current directory (which is unknown) instead of using the user's home.

IMHO the user's home should be the default and the check for the --output-dir == . should be added in addition.

@g-iannelli
Copy link
Contributor

g-iannelli commented Nov 20, 2024

Moreover the fix doen't work in case of --workdir is specified

pwd && go run main.go dump template -D -w /tmp -o .
~/Workspace/github.com/luigidematteis/furyctl
DEBU logging to: .furyctl/furyctl.1732113133-33825.log
DEBU Changed working directory to /tmp
DEBU Getting Home Directory Path...
INFO Downloading distribution...
INFO Compatibility patches applied for v1.29.4
INFO Validating configuration file...
INFO Generating distribution manifests...
DEBU config path = /var/folders/k9/3lv0pm253td7mqnyhqfryprw0000gn/T/furyctl-dist-2246877313/config.yaml
DEBU output directory = /private/tmp/distribution
INFO Distribution manifests generated successfully

With the old $(pwd) workaround it works fine

pwd && go run main.go dump template -D -w /tmp -o $(pwd)
~/Workspace/github.com/luigidematteis/furyctl
DEBU logging to: ~/Workspace/github.com/luigidematteis/furyctl/.furyctl/furyctl.1732113242-9295.log
DEBU Changed working directory to /tmp
DEBU Getting Home Directory Path...
INFO Downloading distribution...
INFO Compatibility patches applied for v1.29.4
INFO Validating configuration file...
INFO Generating distribution manifests...
DEBU config path = /var/folders/k9/3lv0pm253td7mqnyhqfryprw0000gn/T/furyctl-dist-3600317983/config.yaml
DEBU output directory = ~/Workspace/github.com/luigidematteis/furyctl/distribution
INFO Distribution manifests generated successfully

@luigidematteis luigidematteis force-pushed the fix/outdir-flag-current-dir branch from 8e15603 to 8b70b51 Compare November 20, 2024 15:09
@luigidematteis
Copy link
Author

I don't like the change in default behavior for --output-dir. Using the user's home directory is safer than using the current directory. No one can guarantee that someone won't run a command like furyctl dump template -c /dir1/dir2/dir3/furcytl.yaml and write it to the current directory (which is unknown) instead of using the user's home.

IMHO the user's home should be the default and the check for the --output-dir == . should be added in addition.

Hi @g-iannelli, I got your point, but this change was only for the apply command, not for dump template. In any case, I agree that it would be better to just add it as an additional check.

Regarding the dump template command, I just noticed that we already had a check for setting the currentDir, but it was not working because we was checking if value of outDir was empty instead of .

I made a fix for that as well.

@luigidematteis luigidematteis changed the title fix(cmd): use dot to specify current dir when using --outdir flag on apply cmd fix(cmd): use dot to specify current dir when using --outdir flag Nov 20, 2024
@luigidematteis luigidematteis changed the title fix(cmd): use dot to specify current dir when using --outdir flag feat(cmd): use dot to specify current dir when using --outdir flag Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants