Skip to content

Commit

Permalink
prepend the replacePkgAlias in model.ReplacePkgName only when it'…
Browse files Browse the repository at this point in the history
…s not empty
  • Loading branch information
a-hilaly committed Jul 22, 2021
1 parent c1145b4 commit 3a3f2f0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
10 changes: 7 additions & 3 deletions pkg/model/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,15 @@ func ReplacePkgName(
// alias the Kubernetes API types for the service API with that
if strings.Contains(memberType, ".") {
pkgName := strings.Split(memberType, ".")[0]
typeName := strings.Split(memberType, ".")[1]
memberType = strings.Split(memberType, ".")[1]
if pkgName == apiPkgName {
memberType = replacePkgAlias + "." + typeName
if replacePkgAlias != "" {
memberType = replacePkgAlias + "." + memberType
}
} else {
memberType = pkgName + "." + typeName
if replacePkgAlias != "" {
memberType = pkgName + "." + memberType
}
}
}
if isPointerType && keepPointer {
Expand Down
7 changes: 7 additions & 0 deletions pkg/model/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ func TestReplacePkgName(t *testing.T) {
true,
"[][]*svcsdk.EC2TagFilter",
},
{ // empty replacePkgAlias
"*ecr.Repository",
"ecr",
"",
true,
"*Repository",
},
}

for _, tc := range testCases {
Expand Down

0 comments on commit 3a3f2f0

Please sign in to comment.