Skip to content
This repository has been archived by the owner on Dec 26, 2023. It is now read-only.

Add a --auto-approve flag to layerform kill #62

Open
vieiralucas opened this issue Sep 7, 2023 · 4 comments
Open

Add a --auto-approve flag to layerform kill #62

vieiralucas opened this issue Sep 7, 2023 · 4 comments
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@vieiralucas
Copy link
Member

Problem:

When using layerform in a script, or CI environment, I want to be able to kill layer instances without having to answer yes to the "are you sure?" question.

Proposal:

Add a --auto-approve flag to the kill command that makes the cli skip the confirmation when killing a layer instance.

@vieiralucas
Copy link
Member Author

This should be an easy one, first thing is to add the flag here:
https://github.com/ergomake/layerform/blob/a4a1cefa32b826efd07900e1b05a9f03c7a3f55f/cmd/cli/kill.go#L17-L21
Something like this

  killCmd.Flags().Bool("auto-approve", false, "skip interactive approval before killing layer instance")

Then, do an if statement over here:
https://github.com/ergomake/layerform/blob/a4a1cefa32b826efd07900e1b05a9f03c7a3f55f/internal/command/kill.go#L185-L194
Something like this:

	if !autoApprove {
		var answer string
		fmt.Print("Are you sure? This can't be undone. [yes/no]: ")
		_, err = fmt.Scan(&answer)
		if err != nil {
			return errors.Wrap(err, "fail to read asnwer")
		}

		if strings.ToLower(strings.TrimSpace(answer)) != "yes" {
			return nil
		}
	}

Besides that, you'll need to pass some arguments around. I'm happy to further assist.

@hi-hi-ray
Copy link

Hi, is this issue still available to been worked on? Can i try to fixed with your suggestions? =]

@vieiralucas
Copy link
Member Author

Hey @hi-hi-ray, yes please. Let me know if you want some help.
I'll assign to you just to let other people know ok?
Thank you in advance!

@hi-hi-ray
Copy link

hi-hi-ray commented Sep 10, 2023

Hi, I created the PR it worked here, but to ensure that everything it's ok I strongly advise that you test in your local environments. =]

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants