mirror of
https://git.vectorsigma.ru/public/atlantis.git
synced 2026-07-28 21:28:20 +00:00
chore: Rename templates package to web_templates (#4383)
This commit is contained in:
@@ -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"
|
||||
)
|
||||
@@ -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,
|
||||
@@ -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),
|
||||
})
|
||||
|
||||
@@ -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"
|
||||
@@ -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
|
||||
@@ -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,
|
||||
|
||||
@@ -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"
|
||||
@@ -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
|
||||
@@ -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,
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
// limitations under the License.
|
||||
// Modified hereafter by contributors to runatlantis/atlantis.
|
||||
|
||||
package templates
|
||||
package web_templates
|
||||
|
||||
import (
|
||||
"html/template"
|
||||
@@ -1,4 +1,4 @@
|
||||
package templates
|
||||
package web_templates
|
||||
|
||||
import (
|
||||
"io"
|
||||
@@ -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"
|
||||
@@ -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
|
||||
@@ -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,
|
||||
@@ -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{},
|
||||
@@ -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,
|
||||
@@ -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(),
|
||||
@@ -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,
|
||||
@@ -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,
|
||||
|
||||
@@ -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"
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user