Skip to content
This repository has been archived by the owner on May 24, 2024. It is now read-only.

Commit

Permalink
Add components to schema (#11)
Browse files Browse the repository at this point in the history
* add components to schema

Signed-off-by: Ayman <[email protected]>

* fix conflicts

Signed-off-by: Ayman <[email protected]>

* clean up

Signed-off-by: Ayman <[email protected]>

* add components to schema

Signed-off-by: Ayman <[email protected]>

* fix conflicts

Signed-off-by: Ayman <[email protected]>

* clean up

Signed-off-by: Ayman <[email protected]>

* enhance logging

Signed-off-by: Ayman <[email protected]>

Signed-off-by: Ayman <[email protected]>
Signed-off-by: khalifapro <[email protected]>
Co-authored-by: Ayman <[email protected]>
  • Loading branch information
khalifapro and enkhalifapro authored Aug 16, 2022
1 parent 1f540be commit 5534373
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ GO_ERRCHECK=errcheck -asserts -ignore '[FS]?[Pp]rint*'
BINARIES=jira
COMMIT=`git rev-parse --short HEAD`
VERSION=`git describe --tags --always | cut -d- -f1`
LDFLAGS=-ldflags "-s -w -extldflags '-static' -X github.com/LF-Engineering/insights-datasource-jira/build.GitCommit=$(COMMIT) \
-X github.com/LF-Engineering/insights-datasource-jira/build.Version=$(VERSION)"
LDFLAGS=-ldflags "-s -w -extldflags '-static' -X github.com/LF-Engineering/insights-connector-jira/build.GitCommit=$(COMMIT) \
-X github.com/LF-Engineering/insights-connector-jira/build.Version=$(VERSION)"
all: check ${BINARIES}
jira: ${GO_BIN_FILES}
${GO_ENV} ${GO_BUILD} -o jira ${LDFLAGS} ${GO_BIN_FILES}
Expand Down
28 changes: 27 additions & 1 deletion cmd/jira/jira.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,8 @@ func (j *DSJira) GetModelData(ctx *shared.Ctx, docs []interface{}) (map[string][
source := JiraDataSource
for _, iDoc := range docs {
var (
labels []string
labels []string
components []string
)
nComments := 0
doc, _ := iDoc.(map[string]interface{})
Expand All @@ -326,6 +327,15 @@ func (j *DSJira) GetModelData(ctx *shared.Ctx, docs []interface{}) (map[string][
}
}
}
iComponents, okComponents := doc["components"].([]interface{})
if okComponents {
for _, iCom := range iComponents {
com, _ := iCom.(string)
if com != "" {
components = append(components, com)
}
}
}
projectID, err := jira.GenerateJiraProjectID(j.URL, jiraProjectID)
if err != nil {
j.log.WithFields(logrus.Fields{"operation": "GetModelData"}).Errorf("GenerateJiraProjectID(%s,%s): %+v for %+v", jiraProjectID, j.URL, err, doc)
Expand Down Expand Up @@ -517,6 +527,7 @@ func (j *DSJira) GetModelData(ctx *shared.Ctx, docs []interface{}) (map[string][
Project: project,
Labels: labels,
Watchers: watchers,
Components: components,
Contributors: shared.DedupContributors(issueContributors),
Issue: insights.Issue{
Title: title,
Expand Down Expand Up @@ -1117,6 +1128,20 @@ func (j *DSJira) EnrichItem(ctx *shared.Ctx, item map[string]interface{}, roles
}
rich["releases"] = rels
}
components, ok := shared.Dig(fields, []string{"components"}, false, true)
if ok {
coms := []interface{}{}
cs, ok := components.([]interface{})
if ok {
for _, com := range cs {
name, ok := shared.Dig(com, []string{"name"}, false, true)
if ok {
coms = append(coms, name)
}
}
}
rich["components"] = coms
}
for field, fieldValue := range fields {
if !strings.HasPrefix(strings.ToLower(field), "customfield_") {
continue
Expand Down Expand Up @@ -1941,6 +1966,7 @@ func main() {
jira.log.WithFields(logrus.Fields{"operation": "main"}).Errorf("Error Init jira: %+v", err)
return
}
jira.log = jira.log.WithFields(logrus.Fields{"endpoint": jira.URL})
// Update status to in progress in log clusterx
timestamp := time.Now()
shared.SetSyncMode(true, false)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.17

require (
github.com/LF-Engineering/insights-datasource-shared v1.5.12
github.com/LF-Engineering/lfx-event-schema v0.1.20-0.20220510142557-956ba192fade
github.com/LF-Engineering/lfx-event-schema v0.1.29-0.20220814063134-d194fa6ec2ef
github.com/aws/aws-lambda-go v1.28.0
github.com/aws/aws-sdk-go v1.43.4
github.com/json-iterator/go v1.1.12
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/LF-Engineering/insights-datasource-shared v1.5.12 h1:26zqp9OO15HS1KENSaHoXpizAtcSmHVAJvQ/yryGsxY=
github.com/LF-Engineering/insights-datasource-shared v1.5.12/go.mod h1:ZQCRAJNyizhBemQDSjqm14G2MPkOJbRzCPfjwFhYKy4=
github.com/LF-Engineering/insights-datasource-shared v1.4.5-0.20220511063206-6754a12066b9 h1:CcKhPF0SgXbOFasPhoD/1of1ohvgLc4aASJj2KTdsrI=
github.com/LF-Engineering/insights-datasource-shared v1.4.5-0.20220511063206-6754a12066b9/go.mod h1:ZQCRAJNyizhBemQDSjqm14G2MPkOJbRzCPfjwFhYKy4=
github.com/LF-Engineering/lfx-event-schema v0.1.14/go.mod h1:CfFIZ4mwzo88umf5+KxDQEzqlVkPG7Vx8eLK2oDfWIs=
github.com/LF-Engineering/lfx-event-schema v0.1.20-0.20220510142557-956ba192fade h1:YTBk0uQnUVrfEFcyHaR2hzVXDh6ebmeliV0f/O/jj8c=
github.com/LF-Engineering/lfx-event-schema v0.1.20-0.20220510142557-956ba192fade/go.mod h1:CfFIZ4mwzo88umf5+KxDQEzqlVkPG7Vx8eLK2oDfWIs=
github.com/LF-Engineering/lfx-event-schema v0.1.29-0.20220814063134-d194fa6ec2ef h1:CcdZsFrNs3gL9QOTDMFy+XOFyXpuhXOTO1+3y5eP6Q8=
github.com/LF-Engineering/lfx-event-schema v0.1.29-0.20220814063134-d194fa6ec2ef/go.mod h1:CfFIZ4mwzo88umf5+KxDQEzqlVkPG7Vx8eLK2oDfWIs=
github.com/alecthomas/jsonschema v0.0.0-20210920000243-787cd8204a0d/go.mod h1:/n6+1/DWPltRLWL/VKyUxg6tzsl5kHUCcraimt4vr60=
github.com/avast/retry-go v3.0.0+incompatible h1:4SOWQ7Qs+oroOTQOYnAHqelpCO0biHSxpiH9JdtuBj0=
github.com/avast/retry-go v3.0.0+incompatible/go.mod h1:XtSnn+n/sHqQIpZ10K1qAevBhOOCWBLXXy3hyiqqBrY=
Expand Down

0 comments on commit 5534373

Please sign in to comment.