Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Atlas plugin with DCO commit #41

Merged
merged 1 commit into from
Oct 16, 2024
Merged

Atlas plugin with DCO commit #41

merged 1 commit into from
Oct 16, 2024

Conversation

sajit
Copy link
Contributor

@sajit sajit commented Oct 16, 2024

…kal.com>

What does this PR change?

  • Atlas plugin

Does this PR relate to any other PRs?

  • No

How will this PR impact users?

Does this PR address any GitHub or Zendesk issues?

How was this PR tested?

Does this PR require changes to documentation?

Copy link
Contributor

@ameijer ameijer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a last few things - also, your DCO failed 😢

requestErrors := validateRequest(req)
if len(requestErrors) > 0 {
//return empty response
return results
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!


if err1 != nil || err2 != nil {
// If parsing fails, skip this item
continue
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

log the errors here so we at least know something is up

// // Iterate over the UsageDetails in CostResponse
// for _, lineItem := range pendingInvoicesResponse.LineItems {
// Create a new pb.CustomCost for each LineItem
//log.Debugf("Line item %v", item)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rm dead code

log.Debugf("Line Item %s %s", startDate.UTC(), endDate.UTC())
// Check if the item's StartDate >= win.start and EndDate <= win.end
if (startDate.UTC().After(winStartUTC) || startDate.UTC().Equal(winStartUTC)) &&
(endDate.UTC().Before(winEndUTC) || endDate.UTC().Equal(winEndUTC)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup this is good!


func (a *AtlasCostSource) getAtlasCostsForWindow(win *opencost.Window, lineItems []atlasplugin.LineItem) (*pb.CustomCostResponse, error) {

//filter responses between
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unfinished comment?

MagicCookieValue: "mongodb-atlas",
}

const costExplorerPendingInvoices = "https://cloud.mongodb.com/api/atlas/v2/orgs/%s/invoices/pending"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const costExplorerPendingInvoices = "https://cloud.mongodb.com/api/atlas/v2/orgs/%s/invoices/pending"
const costExplorerPendingInvoicesURL = "https://cloud.mongodb.com/api/atlas/v2/orgs/%s/invoices/pending"

}

func GetPendingInvoices(org string, client HTTPClient) ([]atlasplugin.LineItem, error) {
request, _ := http.NewRequest("GET", fmt.Sprintf(costExplorerPendingInvoices, org), nil)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
request, _ := http.NewRequest("GET", fmt.Sprintf(costExplorerPendingInvoices, org), nil)
request, _ := http.NewRequest("GET", fmt.Sprintf(costExplorerPendingInvoicesURL, org), nil)

StatusCode: http.StatusOK,
Body: io.NopCloser(bytes.NewBuffer(mockResponseJson)),
}, nil
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice mock!

Copy link
Contributor

@ameijer ameijer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

approving, we can patch later, none of my comments are blocking

@ameijer ameijer enabled auto-merge (squash) October 16, 2024 18:22
@cliffcolvin cliffcolvin disabled auto-merge October 16, 2024 18:23
@ameijer ameijer merged commit 5b117bc into opencost:main Oct 16, 2024
2 checks passed
@ameijer ameijer mentioned this pull request Oct 16, 2024
@sajit sajit mentioned this pull request Oct 16, 2024
@sajit sajit deleted the atlas-2 branch October 19, 2024 22:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants