From 5c58e7d14654ed12953703d9c180072583ebdecc Mon Sep 17 00:00:00 2001 From: artaasadi Date: Sun, 29 Dec 2024 15:35:38 +0100 Subject: [PATCH] fix: update migrator params default value --- .../job/migrations/compliance/git_parser.go | 24 +++++++++---------- .../job/migrations/inventory/migrator.go | 4 ++-- .../job/migrations/shared/query.go | 2 +- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/jobs/post-install-job/job/migrations/compliance/git_parser.go b/jobs/post-install-job/job/migrations/compliance/git_parser.go index 3796cdda6..733ccc393 100644 --- a/jobs/post-install-job/job/migrations/compliance/git_parser.go +++ b/jobs/post-install-job/job/migrations/compliance/git_parser.go @@ -263,8 +263,8 @@ func (g *GitParser) ExtractControls(complianceControlsPath string, controlEnrich } else { paramsValues := make(map[string]string) for _, pv := range control.Query.Parameters { - if pv.DefaultValue != nil { - paramsValues[pv.Key] = *pv.DefaultValue + if pv.DefaultValue != "" { + paramsValues[pv.Key] = pv.DefaultValue } } var integrationTypes pq.StringArray @@ -294,10 +294,10 @@ func (g *GitParser) ExtractControls(complianceControlsPath string, controlEnrich Value: v, }) } else { - if parameter.DefaultValue != nil { + if parameter.DefaultValue != "" { g.queryParams = append(g.queryParams, models.QueryParameterValues{ Key: parameter.Key, - Value: *parameter.DefaultValue, + Value: parameter.DefaultValue, }) } } @@ -323,10 +323,10 @@ func (g *GitParser) ExtractControls(complianceControlsPath string, controlEnrich Required: parameter.Required, }) - if parameter.DefaultValue != nil { + if parameter.DefaultValue != "" { g.queryParams = append(g.queryParams, models.QueryParameterValues{ Key: parameter.Key, - Value: *parameter.DefaultValue, + Value: parameter.DefaultValue, }) } } @@ -775,8 +775,8 @@ func (g *GitParser) ExtractQueryViews(viewsPath string) error { } else { paramsValues := make(map[string]string) for _, pv := range obj.Query.Parameters { - if pv.DefaultValue != nil { - paramsValues[pv.Key] = *pv.DefaultValue + if pv.DefaultValue != "" { + paramsValues[pv.Key] = pv.DefaultValue } } var integrationTypes pq.StringArray @@ -805,10 +805,10 @@ func (g *GitParser) ExtractQueryViews(viewsPath string) error { Value: v, }) } else { - if parameter.DefaultValue != nil { + if parameter.DefaultValue != "" { g.queryParams = append(g.queryParams, models.QueryParameterValues{ Key: parameter.Key, - Value: *parameter.DefaultValue, + Value: parameter.DefaultValue, }) } } @@ -832,10 +832,10 @@ func (g *GitParser) ExtractQueryViews(viewsPath string) error { Required: parameter.Required, }) - if parameter.DefaultValue != nil { + if parameter.DefaultValue != "" { g.queryParams = append(g.queryParams, models.QueryParameterValues{ Key: parameter.Key, - Value: *parameter.DefaultValue, + Value: parameter.DefaultValue, }) } } diff --git a/jobs/post-install-job/job/migrations/inventory/migrator.go b/jobs/post-install-job/job/migrations/inventory/migrator.go index 28acebe72..4a1fcda6a 100644 --- a/jobs/post-install-job/job/migrations/inventory/migrator.go +++ b/jobs/post-install-job/job/migrations/inventory/migrator.go @@ -284,10 +284,10 @@ func populateFinderItem(logger *zap.Logger, tx *gorm.DB, path string, info fs.Fi Required: qp.Required, QueryID: dbMetric.ID, }) - if qp.DefaultValue != nil { + if qp.DefaultValue != "" { queryParamObj := models.QueryParameterValues{ Key: qp.Key, - Value: *qp.DefaultValue, + Value: qp.DefaultValue, } QueryParameters = append(QueryParameters, queryParamObj) } diff --git a/jobs/post-install-job/job/migrations/shared/query.go b/jobs/post-install-job/job/migrations/shared/query.go index 2b5e3d324..cc7959851 100644 --- a/jobs/post-install-job/job/migrations/shared/query.go +++ b/jobs/post-install-job/job/migrations/shared/query.go @@ -14,5 +14,5 @@ type Query struct { type QueryParameter struct { Key string `json:"Key" yaml:"Key"` Required bool `json:"Required" yaml:"Required"` - DefaultValue *string `json:"DefaultValue" yaml:"DefaultValue"` + DefaultValue string `json:"DefaultValue" yaml:"DefaultValue"` }