Skip to content

Commit b170693

Browse files
author
ivan
committed
fix the bug of create two namespace which one name is other name's substr, return error of more than 1. reduce the program's complex
1 parent a553aa6 commit b170693

File tree

1 file changed

+14
-23
lines changed

1 file changed

+14
-23
lines changed

tencentcloud/service_tencentcloud_tcr.go

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -307,20 +307,15 @@ func (me *TCRService) DescribeTCRNameSpaceById(ctx context.Context, instanceId s
307307

308308
if len(namespaces) == 0 {
309309
return nil, has, nil
310-
} else if len(namespaces) > 1 {
311-
for i := range namespaces {
312-
if name == *namespaces[i].Name {
313-
namespace = namespaces[i]
314-
has = true
315-
return
316-
}
317-
}
318-
errRet = fmt.Errorf("TencentCloud SDK return more than 1 namespaces, %s %s", instanceId, name)
319-
return
320310
}
321311

322-
namespace = namespaces[0]
323-
has = true
312+
for i := range namespaces {
313+
if name == *namespaces[i].Name {
314+
namespace = namespaces[i]
315+
has = true
316+
return
317+
}
318+
}
324319
return
325320
}
326321

@@ -452,20 +447,16 @@ func (me *TCRService) DescribeTCRRepositoryById(ctx context.Context, instanceId
452447

453448
if len(repositories) == 0 {
454449
return nil, has, nil
455-
} else if len(repositories) > 1 {
456-
for i := range repositories {
457-
if *repositories[i].Name == namespace+"/"+repositoryName {
458-
repository = repositories[i]
459-
has = true
460-
return
461-
}
450+
}
451+
452+
for i := range repositories {
453+
if *repositories[i].Name == namespace+"/"+repositoryName {
454+
repository = repositories[i]
455+
has = true
456+
return
462457
}
463-
errRet = fmt.Errorf("TencentCloud SDK return more than 1 namespaces, %s %s %s", instanceId, namespace, repositoryName)
464-
return
465458
}
466459

467-
repository = repositories[0]
468-
has = true
469460
return
470461
}
471462

0 commit comments

Comments
 (0)