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 AWS CodeCommit Repo support. #975

Merged
merged 5 commits into from
Apr 3, 2018
Merged

Add AWS CodeCommit Repo support. #975

merged 5 commits into from
Apr 3, 2018

Conversation

newloong
Copy link
Contributor

@newloong newloong commented Apr 1, 2018

Hey,

This pull request add AWS CodeCommit repo support.

Related: #969

Tested on:

macOS 10.13.3
ansible 2.4.3.0

@swalkinshaw
Copy link
Member

I'm wondering if this check is even useful at this point. There's later connection test to make sure we can connect to the Git repo.

@fullyint
Copy link
Contributor

fullyint commented Apr 1, 2018

@newloong Thanks for this. We discussed internally and agree we should enable the ssh:// form.

Background. I think #459 added the regexp validation to quickly warn users against the http(s):// format that often doesn't allow connection to private repos during later deploy tasks. I think #516 adjusted the regexp to ensure users had the : in their repo's git format (:x: git@github.com/roots/bedrock but ✅ git@github.com:roots/bedrock).

Your regexp. Could you revise your regexp to disallow the http(s) repo format? See proposed revision in example below. Does that regexp work for your CodeCommit repo?

Example revision. Maybe the fail msg could give the ssh:// format as an example too, e.g.,

    - name: Ensure repo is valid
      connection: local
      fail:
        msg: |
          Invalid Git repository format.
          Ensure that your site's `repo` variable is defined in
          `group_vars/{{ env }}/wordpress_sites.yml` and uses an SSH format.
          Examples:
            - git@github.com:roots/bedrock.git
            - ssh://git@github.com/roots/bedrock
          More info:
          > https://roots.io/trellis/docs/deploys/
      when: project.repo is not defined or not project.repo | match("(^ssh:|.+@.+:.+)")

@fullyint
Copy link
Contributor

fullyint commented Apr 3, 2018

@newloong Thanks for the revised regexp. I like how you got rid of the unnecessary ( ) from my suggested example.

.git I should have mentioned it explicitly, but given that git clone git@github.com:roots/bedrock succeeds without the .git at the end, could you remove the regexp's requirement that repo values in \.git? I realize the original regexp in trellis had the .git so it made sense that you kept it.

slashes. Your pattern requires ssh:\/\/. I don't think it is necessary to escape the slashes. I don't think slashes are special/control characters in this context (a la https://docs.python.org/2/library/re.html#regular-expression-syntax) and aren't being used as pattern delimiters. Could you use the visually simpler ssh://?

.* vs .+ This last comment is trivial and you can ignore it if you want. I think each instance of .* truly needs "one or more" characters (.+); it would be an incorrect format if a user were to specify zero characters in any of those locations of the pattern, a la the "zero or more" of .*. Once again, I realize the original regexp used .*, but I think it'd be nice to get the extra accuracy given that it comes at no additional characters/cost.

summary. So, altogether I'm proposing:

- match("^ssh:\/\/.*@.*|.*@.*:.*\.git")
+ match("^ssh://.+@.+|.+@.+:.+")

Thanks again! Your help with this PR brings Trellis a good improvement.

@fullyint fullyint merged commit 9dfddfd into roots:master Apr 3, 2018
primozcigler added a commit to proteusthemes/pt-ops that referenced this pull request Apr 19, 2018
* trellis/master:
  Add gold sponsor [ci skip]
  Support git url format ssh://user@host/path/to/repo (roots#975)
  Fix path to h5bp/mime.types (roots#974)
  Vendor h5bp Nginx configs (roots#973)
  Add support for sSMTP revaliases configuration (roots#956)
  Add gold sponsor [ci skip]
  Update CHANGELOG
  Refactor --subdomains flag in the Install WP task
  Add support for includes.d on all sites
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.

3 participants