Skip to content

Commit 2088803

Browse files
Report repo provider in repo info (#589)
* report vcs provider in repo info * rename azure to azure-devops
1 parent 6383f3f commit 2088803

2 files changed

Lines changed: 24 additions & 18 deletions

File tree

cmd/kosli/attestation.go

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,8 @@ func getGitRepoInfoFromEnvironment() (*gitview.GitRepoInfo, error) {
195195
return getGitRepoInfoFromAzureDevops(), nil
196196
case circleci:
197197
return getGitRepoInfoFromCircleci(), nil
198-
case codeBuild:
199-
return getGitRepoInfoFromCodeBuild(), nil
198+
// case codeBuild:
199+
// return getGitRepoInfoFromCodeBuild(), nil
200200
case unknown:
201201
return nil, nil
202202
}
@@ -205,9 +205,10 @@ func getGitRepoInfoFromEnvironment() (*gitview.GitRepoInfo, error) {
205205

206206
func getGitRepoInfoFromGitHub() *gitview.GitRepoInfo {
207207
return &gitview.GitRepoInfo{
208-
URL: fmt.Sprintf("%s/%s", os.Getenv("GITHUB_SERVER_URL"), os.Getenv("GITHUB_REPOSITORY")),
209-
Name: os.Getenv("GITHUB_REPOSITORY"),
210-
ID: os.Getenv("GITHUB_REPOSITORY_ID"),
208+
URL: fmt.Sprintf("%s/%s", os.Getenv("GITHUB_SERVER_URL"), os.Getenv("GITHUB_REPOSITORY")),
209+
Name: os.Getenv("GITHUB_REPOSITORY"),
210+
ID: os.Getenv("GITHUB_REPOSITORY_ID"),
211+
Provider: "github",
211212
}
212213
}
213214

@@ -217,34 +218,38 @@ func getGitRepoInfoFromGitLab() *gitview.GitRepoInfo {
217218
Name: os.Getenv("CI_PROJECT_PATH"),
218219
ID: os.Getenv("CI_PROJECT_ID"),
219220
Description: os.Getenv("CI_PROJECT_DESCRIPTION"),
221+
Provider: "gitlab",
220222
}
221223
}
222224

223225
func getGitRepoInfoFromBitbucket() *gitview.GitRepoInfo {
224226
return &gitview.GitRepoInfo{
225-
URL: os.Getenv("BITBUCKET_GIT_HTTP_ORIGIN"),
226-
Name: os.Getenv("BITBUCKET_REPO_FULL_NAME"),
227-
ID: os.Getenv("BITBUCKET_REPO_UUID"),
227+
URL: os.Getenv("BITBUCKET_GIT_HTTP_ORIGIN"),
228+
Name: os.Getenv("BITBUCKET_REPO_FULL_NAME"),
229+
ID: os.Getenv("BITBUCKET_REPO_UUID"),
230+
Provider: "bitbucket",
228231
}
229232
}
230233

231234
func getGitRepoInfoFromAzureDevops() *gitview.GitRepoInfo {
232235
return &gitview.GitRepoInfo{
233-
URL: os.Getenv("BUILD_REPOSITORY_URI"),
234-
Name: os.Getenv("BUILD_REPOSITORY_NAME"),
235-
ID: os.Getenv("BUILD_REPOSITORY_ID"),
236+
URL: os.Getenv("BUILD_REPOSITORY_URI"),
237+
Name: os.Getenv("BUILD_REPOSITORY_NAME"),
238+
ID: os.Getenv("BUILD_REPOSITORY_ID"),
239+
Provider: "azure-devops",
236240
}
237241
}
238242

239243
func getGitRepoInfoFromCircleci() *gitview.GitRepoInfo {
240244
return &gitview.GitRepoInfo{
241-
URL: os.Getenv("CIRCLE_REPOSITORY_URL"),
242-
Name: os.Getenv("CIRCLE_PROJECT_REPONAME"),
245+
URL: os.Getenv("CIRCLE_REPOSITORY_URL"),
246+
Name: os.Getenv("CIRCLE_PROJECT_REPONAME"),
247+
Provider: "circleci",
243248
}
244249
}
245250

246-
func getGitRepoInfoFromCodeBuild() *gitview.GitRepoInfo {
247-
return &gitview.GitRepoInfo{
248-
URL: os.Getenv("CODEBUILD_SOURCE_REPO_URL"),
249-
}
250-
}
251+
// func getGitRepoInfoFromCodeBuild() *gitview.GitRepoInfo {
252+
// return &gitview.GitRepoInfo{
253+
// URL: os.Getenv("CODEBUILD_SOURCE_REPO_URL"),
254+
// }
255+
// }

internal/gitview/gitView.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ type GitRepoInfo struct {
3333
Name string `json:"name,omitempty"`
3434
ID string `json:"id,omitempty"`
3535
Description string `json:"description,omitempty"`
36+
Provider string `json:"provider,omitempty"`
3637
}
3738

3839
// GitView

0 commit comments

Comments
 (0)