Skip to content

Commit ad95671

Browse files
author
ivan
committed
fix the bug that create two repository which one name is other name's substr, return error of more than 1. name in response is contains namespace, / and repositoryName
fix the bug of create two namespace which one name is other name's substr, return error of more than 1. change CHANGELOG.md 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 8e41ec7 commit ad95671

File tree

2 files changed

+24
-11
lines changed

2 files changed

+24
-11
lines changed

CHANGELOG.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
## 1.56.10 (Unreleased)
1+
## 1.56.11 (Unreleased)
2+
3+
## 1.56.10
4+
5+
BUG FIXES
6+
7+
* Resource `tencentcloud_tcr_namespace` fix create two namespace and one name is substring of another, then got an error about more than 1
8+
* Resource `tencentcloud_tcr_namespace` fix create two repositories and one name is substring of another, then got an error about more than 1
9+
210
## 1.56.9 (Jun 09, 2021)
311

412
BUG FIXES:

tencentcloud/service_tencentcloud_tcr.go

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -307,13 +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-
errRet = fmt.Errorf("TencentCloud SDK return more than 1 namespaces, %s %s", instanceId, name)
312-
return
313310
}
314311

315-
namespace = namespaces[0]
316-
has = true
312+
for i := range namespaces {
313+
if name == *namespaces[i].Name {
314+
namespace = namespaces[i]
315+
has = true
316+
return
317+
}
318+
}
317319
return
318320
}
319321

@@ -445,13 +447,16 @@ func (me *TCRService) DescribeTCRRepositoryById(ctx context.Context, instanceId
445447

446448
if len(repositories) == 0 {
447449
return nil, has, nil
448-
} else if len(repositories) > 1 {
449-
errRet = fmt.Errorf("TencentCloud SDK return more than 1 namespaces, %s %s %s", instanceId, namespace, repositoryName)
450-
return
451450
}
452451

453-
repository = repositories[0]
454-
has = true
452+
for i := range repositories {
453+
if *repositories[i].Name == namespace+"/"+repositoryName {
454+
repository = repositories[i]
455+
has = true
456+
return
457+
}
458+
}
459+
455460
return
456461
}
457462

0 commit comments

Comments
 (0)