Skip to content

Commit

Permalink
✨ Add project key, creator and issue type (#4623)
Browse files Browse the repository at this point in the history
  • Loading branch information
slntopp authored Sep 2, 2024
1 parent 2638643 commit f1e22a0
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 1 deletion.
6 changes: 6 additions & 0 deletions providers/atlassian/resources/atlassian.lr
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,18 @@ atlassian.jira.issue @defaults("id createdAt") {
id string
// Project
project string
// Project key
projectKey string
// Status
status string
// Description
description string
// Issue create time in UTC
createdAt time
// Issue creator
creator atlassian.jira.user
// Issue type name
typeName string
}

// Jira server info
Expand Down
36 changes: 36 additions & 0 deletions providers/atlassian/resources/atlassian.lr.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions providers/atlassian/resources/atlassian.lr.manifest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,13 @@ resources:
atlassian.jira.issue:
fields:
createdAt: {}
creator: {}
description: {}
id: {}
project: {}
projectKey: {}
status: {}
typeName: {}
min_mondoo_version: 9.0.0
atlassian.jira.project:
fields:
Expand Down
17 changes: 16 additions & 1 deletion providers/atlassian/resources/atlassian_jira.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ func (a *mqlAtlassianJira) issues() ([]interface{}, error) {
jira := conn.Client()
validate := ""
jql := "order by created DESC"
fields := []string{"created", "status", "project", "description"}
fields := []string{"created", "creator", "status", "project", "description", "issuetype"}
expands := []string{"changelog", "renderedFields", "names", "schema", "transitions", "operations", "editmeta"}

res := []interface{}{}
Expand All @@ -226,13 +226,28 @@ func (a *mqlAtlassianJira) issues() ([]interface{}, error) {
return nil, err
}

creator := issue.Fields.Creator
mqlAtlassianJiraUser, err := CreateResource(a.MqlRuntime, "atlassian.jira.user",
map[string]*llx.RawData{
"id": llx.StringData(creator.AccountID),
"name": llx.StringData(creator.DisplayName),
"type": llx.StringData(creator.AccountType),
"picture": llx.StringData(creator.AvatarUrls.One6X16),
})
if err != nil {
return nil, err
}

mqlAtlassianJiraIssue, err := CreateResource(a.MqlRuntime, "atlassian.jira.issue",
map[string]*llx.RawData{
"id": llx.StringData(issue.ID),
"project": llx.StringData(issue.Fields.Project.Name),
"projectKey": llx.StringData(issue.Fields.Project.Key),
"status": llx.StringData(issue.Fields.Status.Name),
"description": llx.StringData(issue.Fields.Description),
"createdAt": llx.TimeData(created.UTC()),
"creator": llx.AnyData(mqlAtlassianJiraUser),
"typeName": llx.StringData(issue.Fields.IssueType.Name),
})
if err != nil {
return nil, err
Expand Down

0 comments on commit f1e22a0

Please sign in to comment.