2023-04-04 00:44:42 +00:00
|
|
|
package gitops
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"github.com/gorilla/mux"
|
|
|
|
httperror "github.com/portainer/libhttp/error"
|
|
|
|
portainer "github.com/portainer/portainer/api"
|
|
|
|
"github.com/portainer/portainer/api/dataservices"
|
|
|
|
"github.com/portainer/portainer/api/http/security"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Handler is the HTTP handler used to handle git repo operation
|
|
|
|
type Handler struct {
|
|
|
|
*mux.Router
|
|
|
|
dataStore dataservices.DataStore
|
|
|
|
gitService portainer.GitService
|
|
|
|
fileService portainer.FileService
|
|
|
|
}
|
|
|
|
|
2023-06-16 13:44:22 +00:00
|
|
|
func NewHandler(bouncer security.BouncerService, dataStore dataservices.DataStore, gitService portainer.GitService, fileService portainer.FileService) *Handler {
|
2023-04-04 00:44:42 +00:00
|
|
|
h := &Handler{
|
|
|
|
Router: mux.NewRouter(),
|
|
|
|
dataStore: dataStore,
|
|
|
|
gitService: gitService,
|
|
|
|
fileService: fileService,
|
|
|
|
}
|
|
|
|
|
|
|
|
h.Handle("/gitops/repo/file/preview",
|
|
|
|
bouncer.AuthenticatedAccess(httperror.LoggerHandler(h.gitOperationRepoFilePreview))).Methods(http.MethodPost)
|
|
|
|
|
|
|
|
return h
|
|
|
|
}
|