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

Use the basename of the SQL file as filename in the container #391

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions mgradm/cmd/support/sql/sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"io"
"os"
"os/exec"
"path"
"strings"

"github.com/rs/zerolog/log"
Expand All @@ -25,22 +26,23 @@ import (
)

func prepareSource(args []string, cnx *shared.Connection) (string, error) {
source := "-"
target := "-"
if len(args) > 0 {
source = args[0]
source := args[0]
target = path.Base(source)
if !utils.FileExists(source) {
return "", fmt.Errorf(L("source %s does not exists"), source)
}
randBytes := make([]byte, 16)
if _, err := rand.Read(randBytes); err != nil {
return "", utils.Errorf(err, L("unable to get random file prefix"))
}
source = hex.EncodeToString(randBytes) + source
if err := cnx.Copy(args[0], "server:"+source, "", ""); err != nil {
target = hex.EncodeToString(randBytes) + target
if err := cnx.Copy(args[0], "server:"+target, "", ""); err != nil {
return "", err
}
}
return source, nil
return target, nil
}

func cleanupSource(file string, cnx *shared.Connection) {
Expand Down Expand Up @@ -176,7 +178,6 @@ func (l copyWriter) Write(p []byte) (n int, err error) {
// Trim CR added by stdlog.
p = p[0 : n-1]
}
log.Debug().Msg(string(p))
}
return
}
Expand Down
1 change: 1 addition & 0 deletions uyuni-tools.changes.cbosdo.sql-file-fix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Use path in mgradm support sql file input (bsc#1227505)