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

Add support for Google Artifact Registry #1377

Merged
merged 9 commits into from
May 26, 2023

Conversation

cw75
Copy link
Contributor

@cw75 cw75 commented May 25, 2023

Describe your changes and why you are making these changes

This PR enables support for GAR. The APIs on the UI and SDK are exactly the same as ECR, but expecting GCP credentials (service account key in our case).

Manually verified that both the success case and failure cases (invalid credentials, non-existent images) work.

Related issue number (if any)

Loom demo (if any)

Checklist before requesting a review

  • I have created a descriptive PR title. The PR title should complete the sentence "This PR...".
  • I have performed a self-review of my code.
  • I have included a small demo of the changes. For the UI, this would be a screenshot or a Loom video.
  • If this is a new feature, I have added unit tests and integration tests.
  • I have run the integration tests locally and they are passing.
  • I have run the linter script locally (See python3 scripts/run_linters.py -h for usage).
  • All features on the UI continue to work correctly.
  • Added one of the following CI labels:
    • run_integration_test: Runs integration tests
    • skip_integration_test: Skips integration tests (Should be used when changes are ONLY documentation/UI)

@cw75 cw75 requested review from likawind, saurav-c, hsubbaraj-spiral and jpurusho65 and removed request for hsubbaraj-spiral May 25, 2023 19:58
@@ -80,7 +80,7 @@ class APIClient:
GET_DYNAMIC_ENGINE_STATUS_ROUTE = "/api/resource/dynamic-engine/status"
EDIT_DYNAMIC_ENGINE_ROUTE_TEMPLATE = "/api/resource/dynamic-engine/%s/edit"

GET_IMAGE_URL_ROUTE = "/api/resourece/container-registry/url"
Copy link
Contributor

Choose a reason for hiding this comment

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

do you see any other this typo in the code base?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nope

return getImageURLResponse{
Url: args.imageName,
}, http.StatusOK, nil
} else if resp.StatusCode == http.StatusUnauthorized || resp.StatusCode == http.StatusForbidden {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd generally prefer not use else if the previous if block returns. We can just use a series of if blocks.

image := strings.Split(fullImageUrl, "/")[3]

// Create a new HTTP request against the Google Artifact Registry API
req, err := http.NewRequest("GET", fmt.Sprintf("https://%s/v2/%s/%s/%s/manifests/%s", host, projectID, repo, image, tag), nil)
Copy link
Contributor

Choose a reason for hiding this comment

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

Does GAR has any go library that we can use? Nowadays I'd imagine most such endpoints has go clients and shouldn't require us to implement raw http requests

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I tried multiple attempts but Google's container registry client API seems broken, and multiple sources suggest that we just use the HTTP APIs here..

Copy link
Contributor

Choose a reason for hiding this comment

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

lol that's really badly maintained

return emptyResponse, resp.StatusCode, errors.Newf("Received unexpected status: %d", resp.StatusCode)
}
} else {
return emptyResponse, http.StatusBadRequest, errors.Newf("Container registry service %s is not supported.", args.service)
Copy link
Contributor

Choose a reason for hiding this comment

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

I may misread, but it seems we will fall at this line if service is GAR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If the service is GAR, we will hit line 117 } else if args.service == shared.GAR { right? This line is for services other than ECR and GAR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To make it clearer, I removed the else statements since we're returning in each case.

@cw75 cw75 added the skip_integration_test Skips required integration test (only documentation/UI changes) label May 26, 2023
@cw75 cw75 merged commit 6efb825 into main May 26, 2023
23 checks passed
@cw75 cw75 deleted the eng-2980-add-support-for-google-artifact-registry branch May 26, 2023 05:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip_integration_test Skips required integration test (only documentation/UI changes)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants