github.com/caos/orbos@v1.5.14-0.20221103111702-e6cd0cea7ad4/cmd/chore/e2e/run/destroy.go (about) 1 package main 2 3 import ( 4 "context" 5 "strings" 6 "time" 7 ) 8 9 var _ testFunc = destroy 10 11 func destroy(_ *testSpecs, settings programSettings, conditions *conditions) interactFunc { 12 13 return func(ctx context.Context, _ uint8, newOrbctl newOrbctlCommandFunc) error { 14 15 destroyCtx, destroyCtxCancel := context.WithTimeout(ctx, 5*time.Minute) 16 defer destroyCtxCancel() 17 18 cmd := newOrbctl(destroyCtx) 19 stdin, err := cmd.StdinPipe() 20 if err != nil { 21 panic(err) 22 } 23 24 var confirmed bool 25 26 conditions.testCase = nil 27 28 return runCommand(settings, orbctl.strPtr(), nil, func(line string) { 29 if !confirmed && strings.HasPrefix(line, "Are you absolutely sure") { 30 confirmed = true 31 if _, err := stdin.Write([]byte("y\n")); err != nil { 32 panic(err) 33 } 34 } 35 }, cmd, "--gitops", "destroy") 36 } 37 }