Skip to content

Commit

Permalink
address PR comments: change error to warnings Signed-off-by: Sajit Ku…
Browse files Browse the repository at this point in the history
…nnumkal <[email protected]>

Signed-off-by: sajit <[email protected]>
  • Loading branch information
sajit committed Oct 16, 2024
1 parent b81730a commit 52e0d61
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions pkg/plugins/mongodb-atlas/cmd/main/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,19 +94,25 @@ func validateRequest(req *pb.CustomCostRequest) []string {
now := time.Now()
// 1. Check if resolution is less than a day
if req.Resolution.AsDuration() < 24*time.Hour {
errors = append(errors, "Resolution should be at least one day.")
var resolutionMessage = "Resolution should be at least one day."
log.Warnf(resolutionMessage)
errors = append(errors, resolutionMessage)
}
// Get the start of the current month
currentMonthStart := time.Date(now.Year(), now.Month(), 1, 0, 0, 0, 0, time.UTC)

// 2. Check if start time is before the start of the current month
if req.Start.AsTime().Before(currentMonthStart) {
errors = append(errors, "Start date cannot be before the current month. Historical costs not currently supported")
var startDateMessage = "Start date cannot be before the current month. Historical costs not currently supported"
log.Warnf(startDateMessage)
errors = append(errors, startDateMessage)
}

// 3. Check if end time is before the start of the current month
if req.End.AsTime().Before(currentMonthStart) {
errors = append(errors, "End date cannot be before the current month. Historical costs not currently supported")
var endDateMessage = "End date cannot be before the current month. Historical costs not currently supported"
log.Warnf(endDateMessage)
errors = append(errors, endDateMessage)
}

return errors
Expand All @@ -116,10 +122,7 @@ func (a *AtlasCostSource) GetCustomCosts(req *pb.CustomCostRequest) []*pb.Custom

requestErrors := validateRequest(req)
if len(requestErrors) > 0 {
errResp := pb.CustomCostResponse{
Errors: requestErrors,
}
results = append(results, &errResp)
//return empty response
return results
}

Expand Down

0 comments on commit 52e0d61

Please sign in to comment.