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

Support AWS CodeCommit with "guess" option ? #61

Closed
ajoga opened this issue Aug 20, 2019 · 3 comments · Fixed by #64
Closed

Support AWS CodeCommit with "guess" option ? #61

ajoga opened this issue Aug 20, 2019 · 3 comments · Fixed by #64

Comments

@ajoga
Copy link

ajoga commented Aug 20, 2019

Hey,

TL;DR : how to have the plugin auto guess the correct URI for AWS CodeCommit. bottom line questions are at the very bottom.

I'm trying to get the URL thingy working for an AWS CodeCommit repository.

There's multiple way to clone such repository :

  • SSH
  • HTTPS

I used HTTPS.

There's multiple ways to authenticate to the git repository for checking out :

  • Specific "https" credentials bound to that usage
  • SSH key configured for that
  • a git helper provided by AWS whom relies on other classic AWS authentication methods.

I use the later, but I'm unsure if this is important to the use of this extension.

When cloning a repository via HTTPS, regardless of the authentication method, we get an URI like this : https://git-codecommit.[AWS_REGION].amazonaws.com/v1/repos/[REPONAME]

This extension uses this URI by default to construct the link for viewing : I believe this URI cannot be used via a browser to browse the repository. I tried to authenticate with credentials fetched from the aws-cli helper, with no success :

$ echo 'protocol=https
host=eu-west-1.console.aws.amazon.com
path=codesuite/codecommit/repositories/[REPONAME]' | aws codecommit --profile [AWS_PROFILE] --region eu-west-1 credential-helper get

This returns a username & password that I used to access :

All of these URI yield :

<AccessDeniedException>
  <Message>Invalid request</Message>
</AccessDeniedException>

From the AWS Console, the browsing URI to see a commit details would be https://[AWS_REGION].console.aws.amazon.com/codesuite/codecommit/repositories/[REPONAME]/commit/[COMMITID]?region=[AWS_REGION] (I'm not sure about the usefulness of this last AWS_REGION, as removing it let stuff working).

I have read the README about constructing a custom URI with the help of variables, an I can make one work for me : https://eu-west-1.console.aws.amazon.com/codesuite/codecommit/repositories/${project.name}/commit/${hash}, but this assumes all repository will be in eu-west-1

  1. How could the region could be parsed / obtained to fill in the URI ?
  2. How could we have the plugin "guess" this correctly ?
@Sertion
Copy link
Owner

Sertion commented Aug 20, 2019

Hello Aurélien!

Thank you for the very detailed feature request.

Right now the "guess" options is perhaps a bit of a misnomer as it only does some static replacements on the git origin URI and hopes that it is the right URL.

A while back we added an option that will change "commit" to "commits" in the guessed URL if it finds any of the configured sub-strings in the origin.

If it is possible to make a change of similar size I would love to add it. For example I could add a token for getting the nth URL component from the git origin (e.g. ${domain-part,2} when the domain is git@some.domain.com would be com). Would an addition like that be a solution?

@nitzel
Copy link

nitzel commented Aug 27, 2019

I'd love to see such a feature for ${project.remote, nth} so that one could use your plugin with the folder/project structure of bitbucket. Also, the relative file path of the change could be used to directly open the corresponding file:
https://server/projects/${project.remote, 1}/repos/${project.name}/commits/${hash}#${relativefilepath}

@Sertion
Copy link
Owner

Sertion commented Aug 27, 2019

Thank you for the input nitzel!

The relative path for the file is not readily available already and is therefore a lot more work to add. I will however add ${gitorigin.hostname,n} in an upcoming release.

@Sertion Sertion mentioned this issue Aug 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants