Skip to content

Commit

Permalink
chore: Rename templates package to web_templates (#4383)
Browse files Browse the repository at this point in the history
  • Loading branch information
X-Guardian authored Mar 27, 2024
1 parent e846d90 commit fb69965
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 36 deletions.
6 changes: 3 additions & 3 deletions server/controllers/github_app_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"net/http"
"net/url"

"github.com/runatlantis/atlantis/server/controllers/templates"
"github.com/runatlantis/atlantis/server/controllers/web_templates"
"github.com/runatlantis/atlantis/server/events/vcs"
"github.com/runatlantis/atlantis/server/logging"
)
Expand Down Expand Up @@ -70,7 +70,7 @@ func (g *GithubAppController) ExchangeCode(w http.ResponseWriter, r *http.Reques

g.Logger.Debug("Found credentials for GitHub app %q with id %d", app.Name, app.ID)

err = templates.GithubAppSetupTemplate.Execute(w, templates.GithubSetupData{
err = web_templates.GithubAppSetupTemplate.Execute(w, web_templates.GithubSetupData{
Target: "",
Manifest: "",
ID: app.ID,
Expand Down Expand Up @@ -142,7 +142,7 @@ func (g *GithubAppController) New(w http.ResponseWriter, _ *http.Request) {
return
}

err = templates.GithubAppSetupTemplate.Execute(w, templates.GithubSetupData{
err = web_templates.GithubAppSetupTemplate.Execute(w, web_templates.GithubSetupData{
Target: url.String(),
Manifest: string(jsonManifest),
})
Expand Down
8 changes: 4 additions & 4 deletions server/controllers/jobs_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"net/url"

"github.com/gorilla/mux"
"github.com/runatlantis/atlantis/server/controllers/templates"
"github.com/runatlantis/atlantis/server/controllers/web_templates"
"github.com/runatlantis/atlantis/server/controllers/websocket"
"github.com/runatlantis/atlantis/server/core/locking"
"github.com/runatlantis/atlantis/server/logging"
Expand All @@ -29,8 +29,8 @@ type JobsController struct {
AtlantisVersion string
AtlantisURL *url.URL
Logger logging.SimpleLogging
ProjectJobsTemplate templates.TemplateWriter
ProjectJobsErrorTemplate templates.TemplateWriter
ProjectJobsTemplate web_templates.TemplateWriter
ProjectJobsErrorTemplate web_templates.TemplateWriter
Backend locking.Backend
WsMux *websocket.Multiplexor
KeyGenerator JobIDKeyGenerator
Expand All @@ -45,7 +45,7 @@ func (j *JobsController) getProjectJobs(w http.ResponseWriter, r *http.Request)
return err
}

viewData := templates.ProjectJobData{
viewData := web_templates.ProjectJobData{
AtlantisVersion: j.AtlantisVersion,
ProjectPath: jobID,
CleanedBasePath: j.AtlantisURL.Path,
Expand Down
6 changes: 3 additions & 3 deletions server/controllers/locks_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"net/http"
"net/url"

"github.com/runatlantis/atlantis/server/controllers/templates"
"github.com/runatlantis/atlantis/server/controllers/web_templates"

"github.com/gorilla/mux"
"github.com/runatlantis/atlantis/server/core/locking"
Expand All @@ -23,7 +23,7 @@ type LocksController struct {
Logger logging.SimpleLogging
ApplyLocker locking.ApplyLocker
VCSClient vcs.Client
LockDetailTemplate templates.TemplateWriter
LockDetailTemplate web_templates.TemplateWriter
WorkingDir events.WorkingDir
WorkingDirLocker events.WorkingDirLocker
Backend locking.Backend
Expand Down Expand Up @@ -78,7 +78,7 @@ func (l *LocksController) GetLock(w http.ResponseWriter, r *http.Request) {
}

owner, repo := models.SplitRepoFullName(lock.Project.RepoFullName)
viewData := templates.LockDetailData{
viewData := web_templates.LockDetailData{
LockKeyEncoded: id,
LockKey: idUnencoded,
PullRequestLink: lock.Pull.URL,
Expand Down
6 changes: 3 additions & 3 deletions server/controllers/locks_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
"time"

"github.com/runatlantis/atlantis/server/controllers"
"github.com/runatlantis/atlantis/server/controllers/templates"
tMocks "github.com/runatlantis/atlantis/server/controllers/templates/mocks"
"github.com/runatlantis/atlantis/server/controllers/web_templates"
tMocks "github.com/runatlantis/atlantis/server/controllers/web_templates/mocks"
"github.com/runatlantis/atlantis/server/core/db"
"github.com/runatlantis/atlantis/server/core/locking"

Expand Down Expand Up @@ -185,7 +185,7 @@ func TestGetLock_Success(t *testing.T) {
req = mux.SetURLVars(req, map[string]string{"id": "id"})
w := httptest.NewRecorder()
lc.GetLock(w, req)
tmpl.VerifyWasCalledOnce().Execute(w, templates.LockDetailData{
tmpl.VerifyWasCalledOnce().Execute(w, web_templates.LockDetailData{
LockKeyEncoded: "id",
LockKey: "id",
RepoOwner: "owner",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// limitations under the License.
// Modified hereafter by contributors to runatlantis/atlantis.

package templates
package web_templates

import (
"html/template"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package templates
package web_templates

import (
"io"
Expand Down
32 changes: 16 additions & 16 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ import (
"github.com/pkg/errors"
"github.com/runatlantis/atlantis/server/controllers"
events_controllers "github.com/runatlantis/atlantis/server/controllers/events"
"github.com/runatlantis/atlantis/server/controllers/templates"
"github.com/runatlantis/atlantis/server/controllers/web_templates"
"github.com/runatlantis/atlantis/server/controllers/websocket"
"github.com/runatlantis/atlantis/server/core/locking"
"github.com/runatlantis/atlantis/server/core/runtime"
Expand Down Expand Up @@ -107,10 +107,10 @@ type Server struct {
StatusController *controllers.StatusController
JobsController *controllers.JobsController
APIController *controllers.APIController
IndexTemplate templates.TemplateWriter
LockDetailTemplate templates.TemplateWriter
ProjectJobsTemplate templates.TemplateWriter
ProjectJobsErrorTemplate templates.TemplateWriter
IndexTemplate web_templates.TemplateWriter
LockDetailTemplate web_templates.TemplateWriter
ProjectJobsTemplate web_templates.TemplateWriter
ProjectJobsErrorTemplate web_templates.TemplateWriter
SSLCertFile string
SSLKeyFile string
CertLastRefreshTime time.Time
Expand Down Expand Up @@ -853,7 +853,7 @@ func NewServer(userConfig UserConfig, config Config) (*Server, error) {
ApplyLocker: applyLockingClient,
Logger: logger,
VCSClient: vcsClient,
LockDetailTemplate: templates.LockTemplate,
LockDetailTemplate: web_templates.LockTemplate,
WorkingDir: workingDir,
WorkingDirLocker: workingDirLocker,
Backend: backend,
Expand All @@ -871,8 +871,8 @@ func NewServer(userConfig UserConfig, config Config) (*Server, error) {
AtlantisVersion: config.AtlantisVersion,
AtlantisURL: parsedURL,
Logger: logger,
ProjectJobsTemplate: templates.ProjectJobsTemplate,
ProjectJobsErrorTemplate: templates.ProjectJobsErrorTemplate,
ProjectJobsTemplate: web_templates.ProjectJobsTemplate,
ProjectJobsErrorTemplate: web_templates.ProjectJobsErrorTemplate,
Backend: backend,
WsMux: wsMux,
KeyGenerator: controllers.JobIDKeyGenerator{},
Expand Down Expand Up @@ -943,10 +943,10 @@ func NewServer(userConfig UserConfig, config Config) (*Server, error) {
JobsController: jobsController,
StatusController: statusController,
APIController: apiController,
IndexTemplate: templates.IndexTemplate,
LockDetailTemplate: templates.LockTemplate,
ProjectJobsTemplate: templates.ProjectJobsTemplate,
ProjectJobsErrorTemplate: templates.ProjectJobsErrorTemplate,
IndexTemplate: web_templates.IndexTemplate,
LockDetailTemplate: web_templates.LockTemplate,
ProjectJobsTemplate: web_templates.ProjectJobsTemplate,
ProjectJobsErrorTemplate: web_templates.ProjectJobsErrorTemplate,
SSLKeyFile: userConfig.SSLKeyFile,
SSLCertFile: userConfig.SSLCertFile,
DisableGlobalApplyLock: userConfig.DisableGlobalApplyLock,
Expand Down Expand Up @@ -1071,10 +1071,10 @@ func (s *Server) Index(w http.ResponseWriter, _ *http.Request) {
return
}

var lockResults []templates.LockIndexData
var lockResults []web_templates.LockIndexData
for id, v := range locks {
lockURL, _ := s.Router.Get(LockViewRouteName).URL("id", url.QueryEscape(id))
lockResults = append(lockResults, templates.LockIndexData{
lockResults = append(lockResults, web_templates.LockIndexData{
// NOTE: must use .String() instead of .Path because we need the
// query params as part of the lock URL.
LockPath: lockURL.String(),
Expand All @@ -1096,7 +1096,7 @@ func (s *Server) Index(w http.ResponseWriter, _ *http.Request) {
return
}

applyLockData := templates.ApplyLockData{
applyLockData := web_templates.ApplyLockData{
Time: applyCmdLock.Time,
Locked: applyCmdLock.Locked,
GlobalApplyLockEnabled: applyCmdLock.GlobalApplyLockEnabled,
Expand All @@ -1105,7 +1105,7 @@ func (s *Server) Index(w http.ResponseWriter, _ *http.Request) {
//Sort by date - newest to oldest.
sort.SliceStable(lockResults, func(i, j int) bool { return lockResults[i].Time.After(lockResults[j].Time) })

err = s.IndexTemplate.Execute(w, templates.IndexData{
err = s.IndexTemplate.Execute(w, web_templates.IndexData{
Locks: lockResults,
PullToJobMapping: preparePullToJobMappings(s),
ApplyLock: applyLockData,
Expand Down
10 changes: 5 additions & 5 deletions server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ import (
"github.com/gorilla/mux"
. "github.com/petergtz/pegomock/v4"
"github.com/runatlantis/atlantis/server"
"github.com/runatlantis/atlantis/server/controllers/templates"
tMocks "github.com/runatlantis/atlantis/server/controllers/templates/mocks"
"github.com/runatlantis/atlantis/server/controllers/web_templates"
tMocks "github.com/runatlantis/atlantis/server/controllers/web_templates/mocks"
"github.com/runatlantis/atlantis/server/core/locking/mocks"
"github.com/runatlantis/atlantis/server/events/models"
"github.com/runatlantis/atlantis/server/jobs"
Expand Down Expand Up @@ -113,13 +113,13 @@ func TestIndex_Success(t *testing.T) {
req, _ := http.NewRequest("GET", "", bytes.NewBuffer(nil))
w := httptest.NewRecorder()
s.Index(w, req)
it.VerifyWasCalledOnce().Execute(w, templates.IndexData{
ApplyLock: templates.ApplyLockData{
it.VerifyWasCalledOnce().Execute(w, web_templates.IndexData{
ApplyLock: web_templates.ApplyLockData{
Locked: false,
Time: time.Time{},
TimeFormatted: "01-01-0001 00:00:00",
},
Locks: []templates.LockIndexData{
Locks: []web_templates.LockIndexData{
{
LockPath: "/lock?id=lkysow%252Fatlantis-example%252F.%252Fdefault",
RepoFullName: "lkysow/atlantis-example",
Expand Down

0 comments on commit fb69965

Please sign in to comment.