Skip to content

Commit 38eafa2

Browse files
fix linting
1 parent 8f79ff8 commit 38eafa2

File tree

2 files changed

+15
-23
lines changed

2 files changed

+15
-23
lines changed

check_upgrade/check_upgrade.go

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -160,13 +160,6 @@ func contains(slice []string, value string) bool {
160160
return false
161161
}
162162

163-
func remove(slice []int, index int) []int {
164-
if index < 0 || index >= len(slice) {
165-
return slice // Return the original slice if the index is out of bounds
166-
}
167-
return append(slice[:index], slice[index+1:]...)
168-
}
169-
170163
func findDuplicateNodes(aclNodes []aclNode) [3]map[string][]string {
171164
du := make(map[string][]string)
172165
dg := make(map[string][]string)
@@ -226,7 +219,7 @@ func queryDuplicateNodes(hc *dgraphapi.HTTPClient) ([3]map[string][]string, erro
226219
return findDuplicateNodes(result.Data.Nodes), nil
227220
}
228221

229-
func printDuplicates(hc *dgraphapi.HTTPClient, entityType string, ns uint64, nodesmap map[string][]string,
222+
func printAndDeleteDuplicates(hc *dgraphapi.HTTPClient, entityType string, ns uint64, nodesmap map[string][]string,
230223
dupDelete bool) error {
231224
if len(nodesmap) == 0 {
232225
return nil
@@ -502,7 +495,8 @@ func init() {
502495
flag.String(namespace, "", "Namespace to check for duplicate nodes")
503496
flag.String(dgUser, "groot", "Username of the namespace's user")
504497
flag.String(password, "password", "Password of the namespace's user")
505-
flag.String(aclSecretKeyFilePath, "", "path of file that stores secret key or private key, which is used to sign the ACL JWT")
498+
flag.String(aclSecretKeyFilePath, "", "path of file that stores secret key or private key,"+
499+
" which is used to sign the ACL JWT")
506500
flag.String(jwtAlg, "HS256", "JWT signing algorithm")
507501
flag.String(deleteDup, "false", "set this flag to true to delete duplicates nodes")
508502
}
@@ -551,21 +545,29 @@ func checkUpgrade() error {
551545
return errors.Wrapf(err, "while getting access jwt token for namespace %v", ns)
552546
}
553547
} else {
554-
hc.LoginIntoNamespace(cmdInput.dgUser, cmdInput.password, ns)
548+
if err := hc.LoginIntoNamespace(cmdInput.dgUser, cmdInput.password, ns); err != nil {
549+
return errors.Wrapf(err, "while logging into namespace %v", ns)
550+
}
555551
}
556552

557553
duplicates, err := queryDuplicateNodes(hc)
558554
if err != nil {
559555
return err
560556
}
561-
printDuplicates(hc, "user", ns, duplicates[0], cmdInput.dupDelete)
557+
if err := printAndDeleteDuplicates(hc, "user", ns, duplicates[0], cmdInput.dupDelete); err != nil {
558+
return err
559+
}
562560
// example output:
563561
// Found duplicate users in namespace: #0
564562
// dgraph.xid user1 , Uids: [0x4 0x3]
565-
printDuplicates(hc, "group", ns, duplicates[1], cmdInput.dupDelete)
563+
if err := printAndDeleteDuplicates(hc, "group", ns, duplicates[1], cmdInput.dupDelete); err != nil {
564+
return err
565+
}
566566
// Found duplicate groups in namespace: #1
567567
// dgraph.xid group1 , Uids: [0x2714 0x2711]
568-
printDuplicates(hc, "groups and user", ns, duplicates[2], cmdInput.dupDelete)
568+
if err := printAndDeleteDuplicates(hc, "groups and user", ns, duplicates[2], cmdInput.dupDelete); err != nil {
569+
return err
570+
}
569571
// Found duplicate groups and users in namespace: #0
570572
// dgraph.xid userGroup1 , Uids: [0x7532 0x7531]
571573
}

check_upgrade/check_upgrade_test.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -197,13 +197,3 @@ func TestQueryDuplicateNodes(t *testing.T) {
197197
require.NoError(t, deleteDuplicatesGroup(hc, duplicateNodes[1]))
198198
require.NoError(t, deleteDuplicatesGroup(hc, duplicateNodes[2]))
199199
}
200-
201-
func TestDeleteDuplicateUser(t *testing.T) {
202-
hc, err := setupClient("localhost:36085")
203-
204-
require.NoError(t, err)
205-
206-
require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser,
207-
dgraphapi.DefaultPassword, x.GalaxyNamespace))
208-
209-
}

0 commit comments

Comments
 (0)