-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Prefix URLs in templates with AtlantisURL #314
Conversation
Codecov Report
@@ Coverage Diff @@
## master #314 +/- ##
=========================================
+ Coverage 70.67% 70.7% +0.03%
=========================================
Files 61 62 +1
Lines 3655 3673 +18
=========================================
+ Hits 2583 2597 +14
- Misses 893 895 +2
- Partials 179 181 +2
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR!
A couple thoughts:
- Ideally we'd use a function like
linkify
but the template is compiled as avar
so it would require a refactor to get theAtlantisURL
into a FuncMap before the template is compiled. Thus for now I think this is an okay way to do it. - We need to add some validation into
cmd/server.go
to ensure that users don't pass in anatlantis-url
with a trailing/
- The docs for
--atlantis-url
should be updated to point out that a URL prefix is supported:URL that Atlantis can be reached at. Defaults to http://$(hostname):$port where $port is from --port. Supports a base path, ex. https://example.com/basepath.
server/web_templates.go
Outdated
<link rel="stylesheet" href="{{ .AtlantisURL }}/static/css/skeleton.css"> | ||
<link rel="stylesheet" href="{{ .AtlantisURL }}/static/css/custom.css"> | ||
<link rel="icon" type="image/png" href="{{ .AtlantisURL }}/static/images/atlantis-icon.png"> | ||
<scnript src="{{ .AtlantisURL }}/static/js/jquery-3.2.1.min.js"></script> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like things got messed up here (snscript
, </hea
)
server/web_templates.go
Outdated
</head> | ||
<body> | ||
<div class="container"> | ||
<section class="header"> | ||
<a title="atlantis" href="/"><img src="/static/images/atlantis-icon.png"/></a> | ||
<a title="atlantis" href="{{ .AtlantisURL }}/"><img src="{{ .AtlantisURL }}/static/images/atlantis-icon.png"/></a> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't need the /
at the end here for <a title="atlantis" href="{{ .AtlantisURL }}/">
server/web_templates.go
Outdated
@@ -83,7 +84,7 @@ var indexTemplate = template.Must(template.New("index.html.tmpl").Parse(` | |||
<p class="title-heading small"><strong>Locks</strong></p> | |||
{{ if .Locks }} | |||
{{ range .Locks }} | |||
<a href="{{.LockURL}}"> | |||
<a href="{{ .AtlantisURL }}/{{.LockURL}}"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure .LockURL
doesn't start with /
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In fact, it always starts with a /
(unless it starts with "https://..."!). Have adjusted accordingly.
server/web_templates.go
Outdated
<div class="container"> | ||
<section class="header"> | ||
<a title="atlantis" href="/"><img src="/static/images/atlantis-icon.png"/></a> | ||
<a title="atlantis" href="{{ .AtlantisURL }}/"><img src="{{ .AtlantisURL }}/static/images/atlantis-icon.png"/></a> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
again, don't need the /
here.
Thanks! All good comments, I'll get to them as soon as I can.
Good point. I think what I'd like to do is:
I think if a user passes one with a trailing slash, we should silently remove it. |
Okay that sounds good. Just note that |
I've addressed all the comments. I want to do some more local testing to ensure this doesn't mess up the routing. |
Also, congratulations on your recent acquisition! |
@jml the site is pretty broken at the moment. Can you squash your changes into one commit and then I can do the remaining fixes. |
Resolves runatlantis#213 Allows users to run Atlantis behind a shared reverse proxy, which is a fairly common use case.
Done. Thanks. |
For future reference here is how I've been testing this.
version: '2'
services:
reverseproxy:
image: mynginx
ports:
- 8080:8080
restart: always
atlantis:
ports:
- 4141:4141
depends_on:
- reverseproxy
image: reverse-proxy
restart: "no"
command: [server, --gh-user, atlantisbot, --gh-token, ****, --log-level, debug, --repo-whitelist, "github.com/*", --atlantis-url, "https://f80439fb.ngrok.io/basepath"] Building my nginx proxy image
|
- Refactoring work from #314 - Use just the path in templates, not the fully qualified URL since that is a best practice. - Add logging to errors when rendering templates. - Silence help output on cli errors since the help output is now so large that you have to scroll up to see the errors.
Resolves #213
Allows users to run Atlantis behind a shared reverse proxy, which is a fairly common use case.
make test
passes for me, butmake test-all
does not, both on this branch and an unchanged master.