Skip to content

Commit c55dfb5

Browse files
committed
fix: ut error
Signed-off-by: Meng JiaFeng <[email protected]>
1 parent 7b3eb2a commit c55dfb5

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

internal/pkg/plugin/gitlabci/generic/options_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ var _ = Describe("action struct", func() {
3434
},
3535
}
3636
repoInfo = &git.RepoInfo{
37-
Repo: repoName,
37+
Repo: repoName,
38+
RepoType: "gitlab",
3839
}
3940
})
4041
Context("buildCIFileConfig method", func() {
@@ -51,6 +52,7 @@ var _ = Describe("action struct", func() {
5152
"AppName": "test_repo",
5253
"ImageRepoSecret": "IMAGE_REPO_SECRET",
5354
"ImageRepoDockerSecret": "image-repo-auth",
55+
"RepoType": "gitlab",
5456
"imageRepo": map[string]interface{}{
5557
"url": "exmaple.com",
5658
"user": "test_user",

internal/pkg/plugin/installer/ci/ci_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ var _ = Describe("PipelineConfig struct", func() {
3333
},
3434
}
3535
r = &git.RepoInfo{
36-
Repo: repoName,
36+
Repo: repoName,
37+
RepoType: "gitlab",
3738
}
3839
})
3940
Context("BuildCIFileConfig method", func() {
@@ -60,6 +61,7 @@ var _ = Describe("PipelineConfig struct", func() {
6061
"StepGlobalVars": "",
6162
"configLocation": downloader.ResourceLocation("123/workflows"),
6263
"sonarqube": nilStepConfig,
64+
"RepoType": "gitlab",
6365
"GitlabConnectionID": "gitlabConnection",
6466
"test": map[string]interface{}{
6567
"enable": emptyBool,
@@ -89,6 +91,7 @@ var _ = Describe("PipelineConfig struct", func() {
8991
"ImageRepoSecret": "IMAGE_REPO_SECRET",
9092
"ImageRepoDockerSecret": "image-repo-auth",
9193
"StepGlobalVars": "",
94+
"RepoType": "gitlab",
9295
"imageRepo": map[string]interface{}{
9396
"url": "exmaple.com",
9497
"user": "test_user",

internal/pkg/plugin/installer/ci/step/step.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ func GetStepGlobalVars(repoInfo *git.RepoInfo) *StepGlobalVars {
4242
RepoType: repoInfo.RepoType,
4343
}
4444
// config credentialID for jenkins if SSHPrivateKey is configured
45-
if repoInfo.SSHPrivateKey != "" {
46-
switch repoInfo.RepoType {
47-
case "github":
48-
v.CredentialID = githubCredentialName
49-
case "gitlab":
45+
switch repoInfo.RepoType {
46+
case "github":
47+
v.CredentialID = githubCredentialName
48+
case "gitlab":
49+
if repoInfo.SSHPrivateKey != "" {
5050
v.CredentialID = gitlabCredentialName
5151
}
5252
}

0 commit comments

Comments
 (0)