Skip to content

Commit

Permalink
Changed run to start and wait
Browse files Browse the repository at this point in the history
  • Loading branch information
c0untingNumbers committed Nov 8, 2024
1 parent 07cdb33 commit cf86b07
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
2 changes: 1 addition & 1 deletion commands/slash/openstack.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func Openstack() (*discordgo.ApplicationCommand, func(s *discordgo.Session, i *d
}

// CREATE THE ACCOUNT
username, password, err := helpers.DebugCreate(s, i.Member.User, span, email)
username, password, err := helpers.Create(email)
if err != nil {
logging.Error(s, err.Error(), i.Member.User, span)
return
Expand Down
16 changes: 6 additions & 10 deletions helpers/openstack.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@ package helpers

import (
"bytes"
"io"
"os/exec"
"strings"

"github.com/bwmarrin/discordgo"
"github.com/ritsec/ops-bot-iii/logging"
"gopkg.in/DataDog/dd-trace-go.v1/ddtrace"
)

Expand All @@ -19,17 +17,11 @@ func DebugCreate(s *discordgo.Session, user *discordgo.User, span ddtrace.Span,
createCmd.Stdout = stdout
createCmd.Stderr = stderr

combinedOutput := &bytes.Buffer{}
createCmd.Stdout = io.MultiWriter(stdout, combinedOutput)
createCmd.Stderr = io.MultiWriter(stderr, combinedOutput)

err := createCmd.Run()
err := createCmd.Start()
if err != nil {
logging.Error(s, combinedOutput.String(), user, span)
return "", "", err
}

logging.Debug(s, combinedOutput.String(), user, span)
output := strings.Fields(stdout.String())

username = output[0]
Expand All @@ -46,7 +38,11 @@ func Create(email string) (username string, password string, error error) {
createCmd.Stdout = stdout
createCmd.Stderr = stderr

err := createCmd.Run()
err := createCmd.Start()
if err != nil {
return "", "", err
}
err = createCmd.Wait()
if err != nil {
return "", "", err
}
Expand Down

0 comments on commit cf86b07

Please sign in to comment.