Skip to content

Commit

Permalink
Merge pull request #2438 from opengovern/fix-queries
Browse files Browse the repository at this point in the history
fix: get organization parameter in PullRequests
  • Loading branch information
artaasadi authored Jan 13, 2025
2 parents 1b08ad2 + 86e19d3 commit dad9474
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,16 @@ var ResourceTypeConfigs = map[string]*interfaces.ResourceTypeConfiguration{
},
},
},
"Github/PullRequest": {
Name: "Github/PullRequest",
IntegrationType: IntegrationTypeGithubAccount,
Description: "",
Params: []interfaces.Param{
{
Name: "organization",
Description: `Please provide the organization name`,
Required: false,
},
},
},
}
36 changes: 18 additions & 18 deletions services/scheduler/schedulers/compliance-quick-run/publisher.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,24 @@ func (s *JobScheduler) runPublisher(ctx context.Context) error {
}
s.logger.Info("Fetch Created Policy Runner Jobs", zap.Any("Jobs Count", len(jobs)))
for _, job := range jobs {
if job.Status == model.ComplianceJobCreated {
framework, err := s.complianceClient.GetBenchmark(&httpclient.Context{UserRole: api.AdminRole}, job.FrameworkID)
if err != nil {
s.logger.Error("error while getting framework", zap.String("frameworkID", job.FrameworkID), zap.Error(err))
continue
}
if framework == nil {
s.logger.Error("framework not exist", zap.String("frameworkID", job.FrameworkID))
continue
}
s.logger.Info("validating compliance job")
err = s.validateComplianceJob(*framework)
if err != nil {
s.logger.Error("framework validation failed", zap.String("frameworkID", job.FrameworkID), zap.Error(err))
_ = s.db.UpdateComplianceJob(job.ID, model.ComplianceJobFailed, err.Error())
continue
}
}
//if job.Status == model.ComplianceJobCreated {
// framework, err := s.complianceClient.GetBenchmark(&httpclient.Context{UserRole: api.AdminRole}, job.FrameworkID)
// if err != nil {
// s.logger.Error("error while getting framework", zap.String("frameworkID", job.FrameworkID), zap.Error(err))
// continue
// }
// if framework == nil {
// s.logger.Error("framework not exist", zap.String("frameworkID", job.FrameworkID))
// continue
// }
// s.logger.Info("validating compliance job")
// err = s.validateComplianceJob(*framework)
// if err != nil {
// s.logger.Error("framework validation failed", zap.String("frameworkID", job.FrameworkID), zap.Error(err))
// _ = s.db.UpdateComplianceJob(job.ID, model.ComplianceJobFailed, err.Error())
// continue
// }
//}

auditJobMsg := auditjob.AuditJob{
JobID: job.ID,
Expand Down
34 changes: 17 additions & 17 deletions services/scheduler/schedulers/compliance/trigger.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,23 +256,23 @@ func (s *JobScheduler) enqueueRunnersCycle() error {
}
s.logger.Info("jobs with unqueued runners", zap.Int("count", len(jobsWithUnqueuedRunners)))
for _, job := range jobsWithUnqueuedRunners {
if job.Status == model.ComplianceJobCreated {
framework, err := s.complianceClient.GetBenchmark(&httpclient.Context{UserRole: api.AdminRole}, job.FrameworkID)
if err != nil {
s.logger.Error("error while getting framework", zap.String("frameworkID", job.FrameworkID), zap.Error(err))
continue
}
if framework == nil {
s.logger.Error("framework not exist", zap.String("frameworkID", job.FrameworkID))
continue
}
err = s.validateComplianceJob(*framework)
if err != nil {
s.logger.Error("framework validation failed", zap.String("frameworkID", job.FrameworkID), zap.Error(err))
_ = s.db.UpdateComplianceJob(job.ID, model.ComplianceJobFailed, err.Error())
continue
}
}
//if job.Status == model.ComplianceJobCreated {
// framework, err := s.complianceClient.GetBenchmark(&httpclient.Context{UserRole: api.AdminRole}, job.FrameworkID)
// if err != nil {
// s.logger.Error("error while getting framework", zap.String("frameworkID", job.FrameworkID), zap.Error(err))
// continue
// }
// if framework == nil {
// s.logger.Error("framework not exist", zap.String("frameworkID", job.FrameworkID))
// continue
// }
// err = s.validateComplianceJob(*framework)
// if err != nil {
// s.logger.Error("framework validation failed", zap.String("frameworkID", job.FrameworkID), zap.Error(err))
// _ = s.db.UpdateComplianceJob(job.ID, model.ComplianceJobFailed, err.Error())
// continue
// }
//}
s.logger.Info("processing job with unqueued runners", zap.Uint("jobID", job.ID))
var allRunners []*model.ComplianceRunner
var assignments *complianceApi.BenchmarkAssignedEntities
Expand Down
4 changes: 3 additions & 1 deletion services/scheduler/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -1592,7 +1592,9 @@ func (h HttpServer) RunDiscovery(ctx echo.Context) error {
}
} else {
jobId = job.ID
status = string(job.Status)
if status == "" {
status = string(job.Status)
}
}
jobs = append(jobs, api.RunDiscoveryJob{
JobId: jobId,
Expand Down

0 comments on commit dad9474

Please sign in to comment.