summaryrefslogtreecommitdiff
path: root/pkg/machine/e2e/config_rm_test.go
blob: 1f9c9b4ecc6404505d8db3c942d6fd35b991bafb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package e2e_test

type rmMachine struct {
	/*
	  -f, --force           Stop and do not prompt before rming
	      --save-ignition   Do not delete ignition file
	      --save-image      Do not delete the image file
	      --save-keys       Do not delete SSH keys

	*/
	force        bool
	saveIgnition bool
	saveImage    bool
	saveKeys     bool

	cmd []string
}

func (i *rmMachine) buildCmd(m *machineTestBuilder) []string {
	cmd := []string{"machine", "rm"}
	if i.force {
		cmd = append(cmd, "--force")
	}
	if i.saveIgnition {
		cmd = append(cmd, "--save-ignition")
	}
	if i.saveImage {
		cmd = append(cmd, "--save-image")
	}
	if i.saveKeys {
		cmd = append(cmd, "--save-keys")
	}
	cmd = append(cmd, m.name)
	i.cmd = cmd
	return cmd
}

func (i *rmMachine) withForce() *rmMachine {
	i.force = true
	return i
}

func (i *rmMachine) withSaveIgnition() *rmMachine { //nolint:unused
	i.saveIgnition = true
	return i
}

func (i *rmMachine) withSaveImage() *rmMachine { //nolint:unused
	i.saveImage = true
	return i
}

func (i *rmMachine) withSaveKeys() *rmMachine { //nolint:unused
	i.saveKeys = true
	return i
}