Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
131 commits
Select commit Hold shift + click to select a range
7f9a0c4
Made chenges
ShashwatDevtron Feb 11, 2023
893c803
Made chenges
ShashwatDevtron Feb 11, 2023
c60f6f0
Made chenges
ShashwatDevtron Feb 12, 2023
a69a006
Clone job function added
ShashwatDevtron Feb 12, 2023
d21dbac
fixed typo
ShashwatDadhich Feb 12, 2023
777725b
fixed typo
ShashwatDadhich Feb 12, 2023
20159c3
Merge branch 'main' into job-feature-branch
ShashwatDadhich Feb 12, 2023
916e196
Merging main to job-feature-branch (#2955)
ShashwatDadhich Feb 12, 2023
73211b1
Merge remote-tracking branch 'origin/job-feature-branch' into job-fea…
ShashwatDadhich Feb 13, 2023
292e7bb
made changes to the queries
ShashwatDadhich Feb 13, 2023
d170f30
Update AppListingRepository.go
ShashwatDadhich Feb 13, 2023
864702c
Update version.go
ShashwatDadhich Feb 13, 2023
caab518
Update version.go
ShashwatDadhich Feb 13, 2023
83b3aa2
Update 1_insert.up.sql
ShashwatDadhich Feb 13, 2023
e8b2b0a
Update 1_insert.up.sql
ShashwatDadhich Feb 13, 2023
c494b18
Update AppCloneService.go
ShashwatDadhich Feb 14, 2023
c10d7b9
Update AppCloneService.go
ShashwatDadhich Feb 14, 2023
a918e70
Uodated app listing api
ShashwatDadhich Feb 16, 2023
15c372d
Merge remote-tracking branch 'origin/job-feature-branch' into job-fea…
ShashwatDadhich Feb 16, 2023
9d68eaa
Uodated app listing api restHandler
ShashwatDadhich Feb 16, 2023
5dbc6c7
Updated app listing api restHandler
ShashwatDadhich Feb 16, 2023
4ec7114
Updated app listing api service layer
ShashwatDadhich Feb 16, 2023
d117efb
Updated app listing api service layer
ShashwatDadhich Feb 16, 2023
0c7c51a
Updated app listing api service layer
ShashwatDadhich Feb 16, 2023
0af2f35
Updated app listing api service layer
ShashwatDadhich Feb 16, 2023
6f77fec
Updated app listing api service layer
ShashwatDadhich Feb 17, 2023
dfea05a
Updated app listing api service layer
ShashwatDadhich Feb 18, 2023
837fa26
MAde the patch-ci-pipeline api
ShashwatDadhich Feb 18, 2023
e409097
MAde the patch-ci-pipeline api
ShashwatDadhich Feb 19, 2023
86f6d0d
Reduced Code duplicacy
ShashwatDadhich Feb 19, 2023
1121d6c
Corrected the code of clone job.
ShashwatDadhich Feb 19, 2023
843d7d2
Corrected the code of clone job.
ShashwatDadhich Feb 20, 2023
70a90b2
Updated the api specs
ShashwatDadhich Feb 21, 2023
ddbe197
Updated the api specs
ShashwatDadhich Feb 21, 2023
4ad51e3
Updated the api specs
ShashwatDadhich Feb 21, 2023
b09e80f
Updated the api specs
ShashwatDadhich Feb 21, 2023
bc3fc5e
Merge branch 'main' into job-feature-branch
ShashwatDadhich Feb 21, 2023
db63681
Updated the api specs
ShashwatDadhich Feb 21, 2023
2e9b3d1
Copied the earlier deleted files
ShashwatDadhich Feb 22, 2023
7d2f5f7
Copied the earlier deleted files
ShashwatDadhich Feb 22, 2023
de20607
Update jobs.yaml
ShashwatDadhich Feb 22, 2023
9eea012
Updated the api end points and wrote the api specs.
ShashwatDadhich Feb 22, 2023
3241569
Merge remote-tracking branch 'origin/job-feature-branch' into job-fea…
ShashwatDadhich Feb 22, 2023
27b9a0b
Updated the api end points and wrote the api specs.
ShashwatDadhich Feb 22, 2023
818497c
Updated the api end points and wrote the api specs.
ShashwatDadhich Feb 22, 2023
0adfb31
Updated the api end points and wrote the api specs.
ShashwatDadhich Feb 22, 2023
e71d643
wire err fix
ShashwatDadhich Feb 22, 2023
7f01861
Wrote the sql migrate down command.
ShashwatDadhich Feb 23, 2023
b12d9d7
Removed the extra api endpoints.
ShashwatDadhich Feb 23, 2023
7a3425e
Removed the commented code
ShashwatDadhich Feb 23, 2023
168fae6
Removed the commented code.
ShashwatDadhich Feb 23, 2023
c5ab938
Update version.go
ShashwatDadhich Feb 23, 2023
2421d84
Added logger wherever required.
ShashwatDadhich Feb 23, 2023
e59c38a
Merge remote-tracking branch 'origin/job-feature-branch' into job-fea…
ShashwatDadhich Feb 23, 2023
4639c98
Fixed a bug.
ShashwatDadhich Feb 23, 2023
1002ad0
Updated the api specs.
ShashwatDadhich Feb 23, 2023
f9e3c14
Added the user authentications
ShashwatDadhich Feb 27, 2023
efdd496
Added the user authentications
ShashwatDadhich Feb 27, 2023
8b3471d
Added the user authentications
ShashwatDadhich Feb 27, 2023
d0faf60
Added the user authentications
ShashwatDadhich Feb 27, 2023
d833dbf
Added the user authentications
ShashwatDadhich Feb 27, 2023
fc0902b
Added the user authentications
ShashwatDadhich Feb 27, 2023
9b3a498
Added the user authentications for triggerCiPipeline
ShashwatDadhich Feb 27, 2023
42a0c85
Added the user authentications for triggerCiPipeline
ShashwatDadhich Feb 27, 2023
78dd576
Updated the api specs and rbac checks
ShashwatDadhich Feb 27, 2023
1b9a862
Updated the api specs and rbac checks
ShashwatDadhich Feb 27, 2023
bcd9d26
Updated the stage status api in case of jobs.
ShashwatDadhich Feb 28, 2023
c9111d1
Updated the job autocomplete api.
ShashwatDadhich Feb 28, 2023
4a874c5
Made the status changes
ShashwatDadhich Feb 28, 2023
cc87216
Fixed the bug of last succeeded time
ShashwatDadhich Mar 1, 2023
da8002e
merge main
ShashwatDadhich Mar 1, 2023
666bc01
undid the reverted changes
ShashwatDadhich Mar 1, 2023
44ff4ff
Job count added
ShashwatDadhich Mar 1, 2023
c762560
Job count corrected
ShashwatDadhich Mar 2, 2023
528a8f2
Job count bug fixed
ShashwatDadhich Mar 2, 2023
5009f03
Sorting order corrected
ShashwatDadhich Mar 2, 2023
8f03388
Sorting order DESC added
ShashwatDadhich Mar 2, 2023
8eab28a
Corrected the app overview page deleted pipeline bug.
ShashwatDadhich Mar 3, 2023
a2c758c
Corrected the app overview page deleted pipeline bug.
ShashwatDadhich Mar 4, 2023
7df1925
added column is_artifact_uploaded to the ci_artifact table.
ShashwatDadhich Mar 4, 2023
7367ba8
Added the check of deleted pipeline.
ShashwatDadhich Mar 4, 2023
bfeeed4
Merge branch 'main' into job-feature-branch
ShashwatDadhich Mar 4, 2023
5bba364
Added the check of deleted pipeline.
ShashwatDadhich Mar 6, 2023
302066b
Added the check of deleted pipeline.
ShashwatDadhich Mar 6, 2023
a361f63
Clone app
ShashwatDadhich Mar 6, 2023
ce0a041
Multiple git repo patch
ShashwatDadhich Mar 6, 2023
126fc15
removed the commented lines.
ShashwatDadhich Mar 6, 2023
0b94d6c
Minor bug fixes
ShashwatDadhich Mar 9, 2023
8efbddd
Delete Git material bug fix.
ShashwatDadhich Mar 9, 2023
a04a1fd
Fixed minor bug
ShashwatDadhich Mar 9, 2023
92850fe
Wrote the sql down command.
ShashwatDadhich Mar 9, 2023
cd20162
minor fix
ShashwatDadhich Mar 9, 2023
30ade14
resolved the comments of PR.
ShashwatDadhich Mar 10, 2023
e8d5971
fixed a minor bug
ShashwatDadhich Mar 10, 2023
fc67089
Changed from app_store to app_type
ShashwatDadhich Mar 10, 2023
b3031f2
Changed from app_store to app_type
ShashwatDadhich Mar 10, 2023
2a399f4
changes as mentioned in the PR
ShashwatDadhich Mar 11, 2023
c0e3ed7
Checked the ci_artifacts
ShashwatDadhich Mar 11, 2023
b9ff2a5
Changes done as mentioned in the PR
ShashwatDadhich Mar 11, 2023
b8daf29
Changes done as mentioned in the PR
ShashwatDadhich Mar 11, 2023
7714bc1
data optimization added
kripanshdevtron Mar 13, 2023
c62f18e
Changes done as mentioned in the PR
ShashwatDadhich Mar 13, 2023
bc0f1ef
Merge remote-tracking branch 'origin/job-feature-branch' into job-fea…
ShashwatDadhich Mar 13, 2023
d3e8872
Fixed minor bug
ShashwatDadhich Mar 13, 2023
089fa82
Fixed minor bug
ShashwatDadhich Mar 13, 2023
a2c82e4
Jobs sql up number update
ShashwatDadhich Mar 13, 2023
782d9e6
Bug fix
ShashwatDadhich Mar 13, 2023
8e3bde6
Merge branch 'main' into job-feature-branch
ShashwatDadhich Mar 13, 2023
8d17528
Bug fix
ShashwatDadhich Mar 13, 2023
86a7d31
Bug fix
ShashwatDadhich Mar 13, 2023
0296ede
Bug fix
ShashwatDadhich Mar 13, 2023
d511439
Bug fix
ShashwatDadhich Mar 13, 2023
3ffdfe2
Bug fix
ShashwatDadhich Mar 13, 2023
ebb9cb4
Bug fix
ShashwatDadhich Mar 14, 2023
56b87b1
Artifact logger added
ShashwatDadhich Mar 14, 2023
a5c4ecd
Additional loggers removed
ShashwatDadhich Mar 15, 2023
74a1484
Logger No tasks configured for this job added
ShashwatDadhich Mar 15, 2023
61e59a7
Removed No tasks configured for this job added
ShashwatDadhich Mar 15, 2023
f160b63
Merge branch 'main' into job-feature-branch
ShashwatDadhich Mar 16, 2023
c527590
Added a validation for AppType
ShashwatDadhich Mar 16, 2023
4c32037
Added comments for validation for AppType
ShashwatDadhich Mar 16, 2023
e07997e
Added a default value to IsArtifactUploaded
ShashwatDadhich Mar 17, 2023
a41d0ae
Removed default value to IsArtifactUploaded
ShashwatDadhich Mar 17, 2023
4606631
Added false to isArtifactUploaded
ShashwatDadhich Mar 17, 2023
14fdad7
Removed false to isArtifactUploaded
ShashwatDadhich Mar 17, 2023
39a1d02
Optimized sql up and down.
ShashwatDadhich Mar 17, 2023
a3af9d4
Merge branch 'main' into job-feature-branch
ShashwatDadhich Mar 17, 2023
f9da98e
changed the sql number
ShashwatDadhich Mar 17, 2023
aaedddf
Optimized the sql query.
ShashwatDadhich Mar 20, 2023
ed3bceb
Removed the history tables from sql down.
ShashwatDadhich Mar 20, 2023
0a9a8b9
Removed the history tables from sql down.
ShashwatDadhich Mar 20, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Wire.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,9 @@ func InitializeApp() (*App, error) {
repository.NewAppListingRepositoryImpl,
wire.Bind(new(repository.AppListingRepository), new(*repository.AppListingRepositoryImpl)),

router.NewJobRouterImpl,
wire.Bind(new(router.JobRouter), new(*router.JobRouterImpl)),

pipelineConfig.NewPipelineRepositoryImpl,
wire.Bind(new(pipelineConfig.PipelineRepository), new(*pipelineConfig.PipelineRepositoryImpl)),
pipeline.NewPropertiesConfigServiceImpl,
Expand Down
36 changes: 36 additions & 0 deletions api/bean/AppView.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package bean
import (
"encoding/json"
"github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1"
"time"
)

type AppContainer struct {
Expand All @@ -36,6 +37,11 @@ type AppContainerResponse struct {
DeploymentGroupDTO DeploymentGroupDTO `json:"deploymentGroup,omitempty"`
}

type JobContainerResponse struct {
JobContainers []*JobContainer `json:"jobContainers"`
JobCount int `json:"jobCount"`
}

type DeploymentGroupDTO struct {
Id int `json:"id"`
Name string `json:"name"`
Expand All @@ -52,6 +58,36 @@ type CiMaterialDTO struct {
SourceValue string `json:"value"`
}

type JobContainer struct {
JobId int `json:"jobId"`
JobName string `json:"jobName""`
Description string `json:"description"`
JobCiPipelines []JobCIPipeline `json:"ciPipelines"'`
}

type JobCIPipeline struct {
CiPipelineId int `json:"ciPipelineId"`
CiPipelineName string `json:"ciPipelineName"`
Status string `json:"status"`
LastRunAt time.Time `json:"lastRunAt"`
LastSuccessAt time.Time `json:"lastSuccessAt"`
}

type JobListingContainer struct {
JobId int `json:"job_id"`
JobName string `json:"job_name"`
Description string `json:"description"`
CiPipelineID int `json:"ci_pipeline_id"`
CiPipelineName string `json:"ci_pipeline_name"`
Status string `json:"status"`
StartedOn time.Time `json:"started_on"`
}

type CiPipelineLastSucceededTime struct {
CiPipelineID int `json:"ci_pipeline_id"`
LastSucceededOn time.Time `json:"last_succeeded_on"`
}

type AppEnvironmentContainer struct {
AppId int `json:"appId"`
AppName string `json:"appName"`
Expand Down
90 changes: 89 additions & 1 deletion api/restHandler/AppListingRestHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
"github.com/devtron-labs/devtron/client/argocdServer/application"
"github.com/devtron-labs/devtron/client/cron"
"github.com/devtron-labs/devtron/internal/constants"
"github.com/devtron-labs/devtron/internal/sql/repository/helper"
"github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig"
"github.com/devtron-labs/devtron/internal/util"
"github.com/devtron-labs/devtron/pkg/app"
Expand Down Expand Up @@ -57,6 +58,8 @@ import (

type AppListingRestHandler interface {
FetchAppsByEnvironment(w http.ResponseWriter, r *http.Request)
FetchJobs(w http.ResponseWriter, r *http.Request)
FetchJobOverviewCiPipelines(w http.ResponseWriter, r *http.Request)
FetchAppDetails(w http.ResponseWriter, r *http.Request)
FetchAllDevtronManagedApps(w http.ResponseWriter, r *http.Request)
FetchAppTriggerView(w http.ResponseWriter, r *http.Request)
Expand Down Expand Up @@ -157,6 +160,91 @@ func (handler AppListingRestHandlerImpl) FetchAllDevtronManagedApps(w http.Respo
res, err := handler.appListingService.FetchAllDevtronManagedApps()
common.WriteJsonResp(w, err, res, http.StatusOK)
}
func (handler AppListingRestHandlerImpl) FetchJobs(w http.ResponseWriter, r *http.Request) {
userId, err := handler.userService.GetLoggedInUser(r)
if userId == 0 || err != nil {
handler.logger.Errorw("request err, userId", "err", err, "payload", userId)
common.WriteJsonResp(w, err, "Unauthorized User", http.StatusUnauthorized)
return
}
isSuperAdmin, err := handler.userService.IsSuperAdmin(int(userId))
if !isSuperAdmin || err != nil {
if err != nil {
handler.logger.Errorw("request err, CheckSuperAdmin", "err", isSuperAdmin, "isSuperAdmin", isSuperAdmin)
}
common.WriteJsonResp(w, err, "Unauthorized User", http.StatusUnauthorized)
return
}
var fetchJobListingRequest app.FetchAppListingRequest
decoder := json.NewDecoder(r.Body)
err = decoder.Decode(&fetchJobListingRequest)
if err != nil {
handler.logger.Errorw("request err, FetchAppsByEnvironment", "err", err, "payload", fetchJobListingRequest)
common.WriteJsonResp(w, err, nil, http.StatusBadRequest)
return
}
jobs, err := handler.appListingService.FetchJobs(fetchJobListingRequest)
if err != nil {
handler.logger.Errorw("service err, FetchJobs", "err", err, "payload", fetchJobListingRequest)
common.WriteJsonResp(w, err, "", http.StatusInternalServerError)
return
}
jobsCount := len(jobs)
offset := fetchJobListingRequest.Offset
limit := fetchJobListingRequest.Size

if limit > 0 {
if offset+limit <= len(jobs) {
jobs = jobs[offset : offset+limit]
} else {
jobs = jobs[offset:]
}
}
jobContainerResponse := bean.JobContainerResponse{
JobContainers: jobs,
JobCount: jobsCount,
}

common.WriteJsonResp(w, err, jobContainerResponse, http.StatusOK)
}
func (handler AppListingRestHandlerImpl) FetchJobOverviewCiPipelines(w http.ResponseWriter, r *http.Request) {
userId, err := handler.userService.GetLoggedInUser(r)
if userId == 0 || err != nil {
handler.logger.Errorw("request err, userId", "err", err, "payload", userId)
common.WriteJsonResp(w, err, "Unauthorized User", http.StatusUnauthorized)
return
}
isSuperAdmin, err := handler.userService.IsSuperAdmin(int(userId))
if !isSuperAdmin || err != nil {
if err != nil {
handler.logger.Errorw("request err, CheckSuperAdmin", "err", isSuperAdmin, "isSuperAdmin", isSuperAdmin)
}
common.WriteJsonResp(w, err, "Unauthorized User", http.StatusUnauthorized)
return
}
vars := mux.Vars(r)
jobId, err := strconv.Atoi(vars["jobId"])
if err != nil {
handler.logger.Errorw("request err, GetAppMetaInfo", "err", err, "jobId", jobId)
common.WriteJsonResp(w, err, nil, http.StatusBadRequest)
return
}
job, err := handler.pipeline.GetApp(jobId)
if err != nil || job == nil || job.AppType != helper.Job {
handler.logger.Errorw("Job with the given Id does not exist", "err", err, "jobId", jobId)
common.WriteJsonResp(w, err, "Job with the given Id does not exist", http.StatusBadRequest)
return
}

jobCi, err := handler.appListingService.FetchOverviewCiPipelines(jobId)
if err != nil {
handler.logger.Errorw("request err, GetJobCi", "err", jobCi, "jobCi", jobCi)
common.WriteJsonResp(w, err, nil, http.StatusBadRequest)
return
}

common.WriteJsonResp(w, err, jobCi, http.StatusOK)
}
func (handler AppListingRestHandlerImpl) FetchAppsByEnvironment(w http.ResponseWriter, r *http.Request) {
//Allow CORS here By * or specific origin
setupResponse(&w, r)
Expand Down Expand Up @@ -571,7 +659,7 @@ func (handler AppListingRestHandlerImpl) FetchAppStageStatus(w http.ResponseWrit
}
//RBAC enforcer Ends

triggerView, err := handler.appListingService.FetchAppStageStatus(appId)
triggerView, err := handler.appListingService.FetchAppStageStatus(appId, int(app.AppType))
if err != nil {
handler.logger.Errorw("service err, FetchAppStageStatus", "err", err, "appId", appId)
common.WriteJsonResp(w, err, nil, http.StatusInternalServerError)
Expand Down
13 changes: 12 additions & 1 deletion api/restHandler/app/AutoCompleteRestHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package app

import (
"github.com/devtron-labs/devtron/api/restHandler/common"
"github.com/devtron-labs/devtron/internal/sql/repository/helper"
"github.com/devtron-labs/devtron/pkg/pipeline"
"github.com/devtron-labs/devtron/pkg/user/casbin"
"github.com/gorilla/mux"
Expand Down Expand Up @@ -32,10 +33,20 @@ func (handler PipelineConfigRestHandlerImpl) GetAppListForAutocomplete(w http.Re
v := r.URL.Query()
teamId := v.Get("teamId")
appName := v.Get("appName")
appTypeParam := v.Get("appType")
var appType int
if appTypeParam != "" {
appType, err = strconv.Atoi(appTypeParam)
if err != nil {
handler.Logger.Errorw("service err, GetAppListForAutocomplete", "err", err, "teamId", teamId, "appTypeParam", appTypeParam)
common.WriteJsonResp(w, err, "Failed to parse appType param", http.StatusInternalServerError)
return
}
}
handler.Logger.Infow("request payload, GetAppListForAutocomplete", "teamId", teamId)
var apps []*pipeline.AppBean
if len(teamId) == 0 {
apps, err = handler.pipelineBuilder.FindAllMatchesByAppName(appName)
apps, err = handler.pipelineBuilder.FindAllMatchesByAppName(appName, helper.AppType(appType))
if err != nil {
handler.Logger.Errorw("service err, GetAppListForAutocomplete", "err", err, "teamId", teamId)
common.WriteJsonResp(w, err, nil, http.StatusInternalServerError)
Expand Down
Loading