Skip to content

Commit f140f68

Browse files
authored
Merge pull request #6 from opengovern/feat-make-task
fix: add progress to task
2 parents 5423942 + 0b9d299 commit f140f68

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

discovery/task/run-task.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ func NewTaskRunner(ctx context.Context, jq *jq.JobQueue, coreServiceEndpoint str
5757
type TaskResult struct {
5858
AllIntegrations []string `json:"all_integrations"`
5959
AllIntegrationsCount int `json:"all_integrations_count"`
60-
ProgressedIntegrations map[string]*IntegrationResult `json:"proposed_integrations"`
61-
ProgressedIntegrationsCount int `json:"proposed_integrations_count"`
60+
ProgressedIntegrations map[string]*IntegrationResult `json:"progressed_integrations"`
61+
ProgressedIntegrationsCount int `json:"progressed_integrations_count"`
6262
}
6363

6464
type IntegrationResult struct {
@@ -105,7 +105,6 @@ func (tr *TaskRunner) RunTask(ctx context.Context) error {
105105
}
106106
}
107107

108-
taskResult.AllIntegrations = make([]string, len(integrations))
109108
for _, i := range integrations {
110109
taskResult.AllIntegrations = append(taskResult.AllIntegrations, i.IntegrationID)
111110
}
@@ -155,12 +154,10 @@ func (tr *TaskRunner) describeIntegrationResourceTypes(ctx context.Context, i In
155154
}
156155
}
157156

158-
taskResult.ProgressedIntegrations[i.IntegrationID].AllResourceTypes = make([]string, len(resourceTypes))
159157
for _, rt := range resourceTypes {
160158
taskResult.ProgressedIntegrations[i.IntegrationID].AllResourceTypes = append(taskResult.ProgressedIntegrations[i.IntegrationID].AllResourceTypes, rt.Name)
161159
}
162160
taskResult.ProgressedIntegrations[i.IntegrationID].AllResourceTypesCount = len(resourceTypes)
163-
taskResult.ProgressedIntegrations[i.IntegrationID].ResourceTypeResults = make([]ResourceTypeResult, len(resourceTypes))
164161

165162
for _, rt := range resourceTypes {
166163
params := make(map[string]string)

discovery/worker/worker.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,11 +184,11 @@ func (w *Worker) ProcessMessage(ctx context.Context, msg jetstream.Msg) (err err
184184
produceCtx, produceCancel := context.WithTimeout(context.Background(), 30*time.Second)
185185
defer produceCancel()
186186

187-
msgId := fmt.Sprintf("task-run-result-%d", runID)
187+
msgId := fmt.Sprintf("task-run-result-%d-final", runID)
188188
if _, pubErr := w.jq.Produce(produceCtx, envs.ResultTopicName, responseJson, msgId); pubErr != nil {
189189
msgLogger.Error("failed to publish final job result", zap.String("jobResult", string(responseJson)), zap.Error(pubErr))
190190
} else {
191-
msgLogger.Info("Published final job result", zap.String("status", string(finalStatus)), zap.String("msgId", msgId))
191+
msgLogger.Info("Published final job result", zap.Any("response", *response), zap.String("status", string(finalStatus)), zap.String("msgId", msgId))
192192
}
193193
}()
194194

0 commit comments

Comments
 (0)