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

feat(dl): add credential support for dl service #163

Merged
merged 1 commit into from
Jul 23, 2024

Conversation

wuhuizuo
Copy link
Contributor

Signed-off-by: wuhuizuo [email protected]

@ti-chi-bot ti-chi-bot bot requested a review from purelind July 23, 2024 02:15
Copy link

ti-chi-bot bot commented Jul 23, 2024

I have already done a preliminary review for you, and I hope to help you do a better job.

This pull request adds support for credentials to the dl service, allowing the service to connect to an Oracle Cloud Infrastructure (OCI) registry. The key changes include:

  • adding an oci-config flag to the dl server command
  • modifying the NewOci function to read OCI configuration from a YAML file specified by the oci-config flag
  • modifying the ocisrvc struct to store the credentials read from the configuration file
  • modifying the ListFiles and NewFileReadCloser functions to accept a remote.Repository parameter instead of a repository string

Overall, the changes seem reasonable and well-documented. However, there are some potential issues that should be addressed:

  • The cre variable in newKS3Client is not used if cfg is nil. This could result in a nil pointer dereference if cfg is nil and newKS3Client is called.
  • The credential field in the ocisrvc struct is a pointer to an auth.Credential. It's not clear why this is necessary, as the auth.EmptyCredential value could be used instead for cases where no credentials are provided.
  • The getTargetRepo function in ocisrvc uses a Credential value that is not protected by a mutex or other synchronization mechanism. This could result in race conditions if multiple goroutines access the same ocisrvc instance concurrently.

To address these issues:

  • In newKS3Client, cre should be initialized to credentials.AnonymousCredentials if cfg is nil.
  • In ocisrvc, the credential field should be changed to a non-pointer auth.Credential and initialized to auth.EmptyCredential.
  • In ocisrvc, the getTargetRepo function should use a mutex to protect access to the Credential value. Alternatively, the Credential field could be changed to an atomic.Value.

@ti-chi-bot ti-chi-bot bot added the size/L label Jul 23, 2024
@wuhuizuo
Copy link
Contributor Author

/approve

Copy link

ti-chi-bot bot commented Jul 23, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: wuhuizuo

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Copy link

PR-Agent was enabled for this repository, but no eligible user found. Please link your git user with your CodiumAI identity here.

@ti-chi-bot ti-chi-bot bot added the approved label Jul 23, 2024
@ti-chi-bot ti-chi-bot bot merged commit 6dcfc9c into main Jul 23, 2024
2 of 3 checks passed
@ti-chi-bot ti-chi-bot bot deleted the feature/oci-credential branch July 23, 2024 02:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant