From 04973cf8d209886bed2d00c32de834a46e42544c Mon Sep 17 00:00:00 2001 From: hayzam Date: Sat, 7 Sep 2024 16:53:28 +0530 Subject: [PATCH] handlers: add git parameters --- handlers/docs.go | 16 +++++++++++++++- services/docs_docs.go | 13 ++++++++++++- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/handlers/docs.go b/handlers/docs.go index ee8abe3..41e4b8d 100644 --- a/handlers/docs.go +++ b/handlers/docs.go @@ -84,6 +84,10 @@ func CreateDocumentation(services *services.ServiceRegistry, w http.ResponseWrit MoreLabelLinks string `json:"moreLabelLinks"` CopyrightText string `json:"copyrightText" validate:"required"` RequireAuth bool `json:"requireAuth"` + GitRepo string `json:"gitRepo"` + GitBranch string `json:"gitBranch"` + GitUser string `json:"gitUser"` + GitPassword string `json:"gitPassword"` } req, err := ValidateRequest[Request](w, r) @@ -114,6 +118,10 @@ func CreateDocumentation(services *services.ServiceRegistry, w http.ResponseWrit MoreLabelLinks: req.MoreLabelLinks, CopyrightText: req.CopyrightText, RequireAuth: req.RequireAuth, + GitRepo: req.GitRepo, + GitBranch: req.GitBranch, + GitUser: req.GitUser, + GitPassword: req.GitPassword, } err = services.DocService.CreateDocumentation(documentation, user) @@ -146,6 +154,10 @@ func EditDocumentation(services *services.ServiceRegistry, w http.ResponseWriter MoreLabelLinks string `json:"moreLabelLinks"` CopyrightText string `json:"copyrightText" validate:"required"` RequireAuth bool `json:"requireAuth"` + GitRepo string `json:"gitRepo"` + GitBranch string `json:"gitBranch"` + GitUser string `json:"gitUser"` + GitPassword string `json:"gitPassword"` } req, err := ValidateRequest[Request](w, r) @@ -166,7 +178,9 @@ func EditDocumentation(services *services.ServiceRegistry, w http.ResponseWriter return } - err = services.DocService.EditDocumentation(user, req.ID, req.Name, req.Description, req.Version, req.Favicon, req.MetaImage, req.NavImage, req.NavImageDark, req.CustomCSS, req.FooterLabelLinks, req.MoreLabelLinks, req.CopyrightText, req.URL, req.OrganizationName, req.ProjectName, req.BaseURL, req.LanderDetails, req.RequireAuth) + err = services.DocService.EditDocumentation(user, req.ID, req.Name, req.Description, req.Version, req.Favicon, req.MetaImage, + req.NavImage, req.NavImageDark, req.CustomCSS, req.FooterLabelLinks, req.MoreLabelLinks, req.CopyrightText, + req.URL, req.OrganizationName, req.ProjectName, req.BaseURL, req.LanderDetails, req.RequireAuth, req.GitRepo, req.GitBranch, req.GitUser, req.GitPassword) if err != nil { SendJSONResponse(http.StatusInternalServerError, w, map[string]string{"status": "error", "message": err.Error()}) diff --git a/services/docs_docs.go b/services/docs_docs.go index 4bc75f5..15b0672 100644 --- a/services/docs_docs.go +++ b/services/docs_docs.go @@ -258,7 +258,10 @@ func (service *DocService) CreateDocumentation(documentation *models.Documentati return nil } -func (service *DocService) EditDocumentation(user models.User, id uint, name, description, version, favicon, metaImage, navImage, navImageDark, customCSS, footerLabelLinks, moreLabelLinks, copyrightText, url, organizationName, projectName, baseURL, landerDetails string, requireAuth bool) error { +func (service *DocService) EditDocumentation(user models.User, id uint, name, description, version, favicon, metaImage, navImage, + navImageDark, customCSS, footerLabelLinks, moreLabelLinks, copyrightText, url, + organizationName, projectName, baseURL, landerDetails string, requireAuth bool, + gitRepo string, gitBranch string, gitUser string, gitPassword string) error { tx := service.DB.Begin() if !utils.IsBaseURLValid(baseURL) { return fmt.Errorf("invalid_base_url") @@ -282,6 +285,10 @@ func (service *DocService) EditDocumentation(user models.User, id uint, name, de doc.MoreLabelLinks = moreLabelLinks doc.CopyrightText = copyrightText doc.RequireAuth = requireAuth + doc.GitRepo = gitRepo + doc.GitBranch = gitBranch + doc.GitUser = gitUser + doc.GitPassword = gitPassword if isTarget && version != "" { doc.Version = version } @@ -506,6 +513,10 @@ func (service *DocService) CreateDocumentationVersion(originalDocId uint, newVer Editors: originalDoc.Editors, LastEditorID: originalDoc.LastEditorID, RequireAuth: originalDoc.RequireAuth, + GitRepo: originalDoc.GitRepo, + GitBranch: originalDoc.GitBranch, + GitUser: originalDoc.GitUser, + GitPassword: originalDoc.GitPassword, } err = service.DB.Transaction(func(tx *gorm.DB) error {