Skip to content

Commit

Permalink
Merge pull request #1407 from kaytu-io/fix-steampipe-upgrade
Browse files Browse the repository at this point in the history
Fix steampipe upgrade
  • Loading branch information
artaasadi authored Aug 2, 2024
2 parents 1267c5f + 9c297ae commit 1eb29ec
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 8 deletions.
34 changes: 27 additions & 7 deletions pkg/describe/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -686,18 +686,14 @@ type ReEvaluateDescribeJob struct {

func (h HttpServer) getReEvaluateParams(benchmarkID string, connectionIDs, controlIDs []string) (*model2.JobSequencerJobTypeBenchmarkRunnerParameters, []ReEvaluateDescribeJob, error) {
var controls []complianceapi.Control
var err error
if len(controlIDs) == 0 {
benchmark, err := h.Scheduler.complianceClient.GetBenchmark(&httpclient.Context{UserRole: apiAuth.InternalRole}, benchmarkID)
controlIDs, err = h.getBenchmarkChildrenControls(benchmarkID)
if err != nil {
h.Scheduler.logger.Error("failed to get benchmark", zap.Error(err))
return nil, nil, err
}
controlIDs = make([]string, 0, len(benchmark.Controls))
for _, control := range benchmark.Controls {
controlIDs = append(controlIDs, control)
}
}
controls, err := h.Scheduler.complianceClient.ListControl(&httpclient.Context{UserRole: apiAuth.InternalRole}, controlIDs, nil)
controls, err = h.Scheduler.complianceClient.ListControl(&httpclient.Context{UserRole: apiAuth.InternalRole}, controlIDs, nil)
if err != nil {
h.Scheduler.logger.Error("failed to get controls", zap.Error(err))
return nil, nil, err
Expand Down Expand Up @@ -751,6 +747,30 @@ func (h HttpServer) getReEvaluateParams(benchmarkID string, connectionIDs, contr
}, describeJobs, nil
}

func (h HttpServer) getBenchmarkChildrenControls(benchmarkID string) ([]string, error) {
benchmark, err := h.Scheduler.complianceClient.GetBenchmark(&httpclient.Context{UserRole: apiAuth.InternalRole}, benchmarkID)
if err != nil {
h.Scheduler.logger.Error("failed to get benchmark", zap.Error(err))
return nil, err
}
if benchmark == nil {
return nil, echo.NewHTTPError(http.StatusNotFound, "benchmark not found")
}

var controlIDs []string
for _, control := range benchmark.Controls {
controlIDs = append(controlIDs, control)
}
for _, childBenchmarkID := range benchmark.Children {
childControlIDs, err := h.getBenchmarkChildrenControls(childBenchmarkID)
if err != nil {
return nil, err
}
controlIDs = append(controlIDs, childControlIDs...)
}
return controlIDs, nil
}

// ReEvaluateComplianceJob godoc
//
// @Summary Re-evaluates compliance job
Expand Down
2 changes: 2 additions & 0 deletions services/migrator/job/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@ func GitClone(conf config.MigratorConfig, logger *zap.Logger) (string, error) {
UserRole: api.AdminRole,
}, models.MetadataKeyAnalyticsGitURL)

logger.Info("url before metadata", zap.String("url", gitConfig.AnalyticsGitURL))
if err == nil && len(value.GetValue().(string)) > 0 {
gitConfig.AnalyticsGitURL = value.GetValue().(string)
} else if err != nil {
logger.Error("failed to get analytics git url from metadata", zap.Error(err))
}
logger.Info("url after metadata", zap.String("url", gitConfig.AnalyticsGitURL))
gitConfig.AnalyticsGitURL = "https://github.com/kaytu-io/configz-deprecated"

logger.Info("using git repo", zap.String("url", gitConfig.AnalyticsGitURL))
Expand Down
1 change: 0 additions & 1 deletion services/migrator/job/updated.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
)

func (w *Job) CheckIfUpdateIsNeeded(name string, mig types.Migration) (bool, error) {
return true, nil
m, err := w.db.GetMigration(name)
if err != nil {
return false, err
Expand Down

0 comments on commit 1eb29ec

Please sign in to comment.