mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-01 19:17:58 +00:00
refactor: replace strings.Replace with strings.ReplaceAll (#15392)
strings.ReplaceAll(s, old, new) is a wrapper function for strings.Replace(s, old, new, -1). But strings.ReplaceAll is more readable and removes the hardcoded -1. Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
This commit is contained in:
@@ -106,7 +106,7 @@ func (h *HANA) NewUser(ctx context.Context, req dbplugin.NewUserRequest) (respon
|
||||
}
|
||||
|
||||
// HANA does not allow hyphens in usernames, and highly prefers capital letters
|
||||
username = strings.Replace(username, "-", "_", -1)
|
||||
username = strings.ReplaceAll(username, "-", "_")
|
||||
username = strings.ToUpper(username)
|
||||
|
||||
// If expiration is in the role SQL, HANA will deactivate the user when time is up,
|
||||
|
||||
@@ -16,7 +16,7 @@ import (
|
||||
|
||||
const (
|
||||
defaultMysqlRevocationStmts = `
|
||||
REVOKE ALL PRIVILEGES, GRANT OPTION FROM '{{name}}'@'%';
|
||||
REVOKE ALL PRIVILEGES, GRANT OPTION FROM '{{name}}'@'%';
|
||||
DROP USER '{{name}}'@'%'
|
||||
`
|
||||
|
||||
@@ -174,8 +174,8 @@ func (m *MySQL) DeleteUser(ctx context.Context, req dbplugin.DeleteUserRequest)
|
||||
// This is not a prepared statement because not all commands are supported
|
||||
// 1295: This command is not supported in the prepared statement protocol yet
|
||||
// Reference https://mariadb.com/kb/en/mariadb/prepare-statement/
|
||||
query = strings.Replace(query, "{{name}}", req.Username, -1)
|
||||
query = strings.Replace(query, "{{username}}", req.Username, -1)
|
||||
query = strings.ReplaceAll(query, "{{name}}", req.Username)
|
||||
query = strings.ReplaceAll(query, "{{username}}", req.Username)
|
||||
_, err = tx.ExecContext(ctx, query)
|
||||
if err != nil {
|
||||
return dbplugin.DeleteUserResponse{}, err
|
||||
|
||||
@@ -482,7 +482,7 @@ func containsMultilineStatement(stmt string) bool {
|
||||
}
|
||||
stmtWithoutLiterals := stmt
|
||||
for _, literal := range literals {
|
||||
stmtWithoutLiterals = strings.Replace(stmt, literal, "", -1)
|
||||
stmtWithoutLiterals = strings.ReplaceAll(stmt, literal, "")
|
||||
}
|
||||
// Now look for the word "END" specifically. This will miss any
|
||||
// representations of END that aren't surrounded by spaces, but
|
||||
|
||||
Reference in New Issue
Block a user