-
Notifications
You must be signed in to change notification settings - Fork 553
feat: show deployment status and timeline for helm apps deployed via gitops #3299
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 43 commits
607876b
00b78b2
a349ee2
2c09f75
d8e0797
291b503
8a75c45
2576950
169c24c
4612591
27efa09
5183ef4
806a903
38e5e4f
2e01f43
6bd0213
faa50b8
2fd5ac1
fc871c0
843d6e5
cc82597
8c33456
b4fedfd
36ba898
03db26a
51414f1
760c237
41b2e8a
187f9ea
790cc53
dc9bf49
be64350
9bfbd84
9c94dd3
eb4f272
02ab39c
c6e270e
7e498b1
210a19b
2d8a0b3
0535762
4ccc227
d373a89
49fba84
62dfafc
198cd14
51bb13f
1a6ba39
80bd037
52b18f5
7c64d5a
3c46118
4120098
e431aef
07f372b
5f5213c
19e5ae0
e56bf69
e565a33
63fb492
b003c9d
7062fc7
d5b5b29
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,27 +29,34 @@ type AppStoreRouter interface { | |
| } | ||
|
|
||
| type AppStoreRouterImpl struct { | ||
| deployRestHandler InstalledAppRestHandler | ||
| appStoreValuesRouter appStoreValues.AppStoreValuesRouter | ||
| appStoreDiscoverRouter appStoreDiscover.AppStoreDiscoverRouter | ||
| appStoreDeploymentRouter appStoreDeployment.AppStoreDeploymentRouter | ||
| deployRestHandler InstalledAppRestHandler | ||
| appStoreValuesRouter appStoreValues.AppStoreValuesRouter | ||
| appStoreDiscoverRouter appStoreDiscover.AppStoreDiscoverRouter | ||
| appStoreDeploymentRouter appStoreDeployment.AppStoreDeploymentRouter | ||
| appStoreStatusTimelineRestHandler AppStoreStatusTimelineRestHandler | ||
| } | ||
|
|
||
| func NewAppStoreRouterImpl(restHandler InstalledAppRestHandler, | ||
| appStoreValuesRouter appStoreValues.AppStoreValuesRouter, appStoreDiscoverRouter appStoreDiscover.AppStoreDiscoverRouter, | ||
| appStoreDeploymentRouter appStoreDeployment.AppStoreDeploymentRouter) *AppStoreRouterImpl { | ||
| appStoreDeploymentRouter appStoreDeployment.AppStoreDeploymentRouter, | ||
| appStoreStatusTimelineRestHandler AppStoreStatusTimelineRestHandler) *AppStoreRouterImpl { | ||
| return &AppStoreRouterImpl{ | ||
| deployRestHandler: restHandler, | ||
| appStoreValuesRouter: appStoreValuesRouter, | ||
| appStoreDiscoverRouter: appStoreDiscoverRouter, | ||
| appStoreDeploymentRouter: appStoreDeploymentRouter, | ||
| deployRestHandler: restHandler, | ||
| appStoreValuesRouter: appStoreValuesRouter, | ||
| appStoreDiscoverRouter: appStoreDiscoverRouter, | ||
| appStoreDeploymentRouter: appStoreDeploymentRouter, | ||
| appStoreStatusTimelineRestHandler: appStoreStatusTimelineRestHandler, | ||
| } | ||
| } | ||
|
|
||
| func (router AppStoreRouterImpl) Init(configRouter *mux.Router) { | ||
| // deployment router starts | ||
| appStoreDeploymentSubRouter := configRouter.PathPrefix("/deployment").Subrouter() | ||
| router.appStoreDeploymentRouter.Init(appStoreDeploymentSubRouter) | ||
|
|
||
| configRouter.Path("/deployment-status/timeline/{installedAppId}/{envId}"). | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. installed app id is already mapped with environment id There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm directly getting installedAppVersion from these two ids, hence saving one db call in which I would have needed to fetch installed apps from db then get env id from installed app object then pass env id to function |
||
| HandlerFunc(router.appStoreStatusTimelineRestHandler.FetchTimelinesForAppStore).Methods("GET") | ||
|
|
||
| // deployment router ends | ||
|
|
||
| // values router starts | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| package appStore | ||
|
|
||
| import ( | ||
| "fmt" | ||
| "github.com/devtron-labs/devtron/api/restHandler/common" | ||
| "github.com/devtron-labs/devtron/pkg/app/status" | ||
| "github.com/devtron-labs/devtron/pkg/user/casbin" | ||
| "github.com/devtron-labs/devtron/util/rbac" | ||
| "github.com/gorilla/mux" | ||
| "go.uber.org/zap" | ||
| "net/http" | ||
| "strconv" | ||
| ) | ||
|
|
||
| type AppStoreStatusTimelineRestHandler interface { | ||
| FetchTimelinesForAppStore(w http.ResponseWriter, r *http.Request) | ||
| } | ||
|
|
||
| type AppStoreStatusTimelineRestHandlerImpl struct { | ||
| logger *zap.SugaredLogger | ||
| pipelineStatusTimelineService status.PipelineStatusTimelineService | ||
| enforcerUtil rbac.EnforcerUtil | ||
| enforcer casbin.Enforcer | ||
| } | ||
|
|
||
| func NewAppStoreStatusTimelineRestHandlerImpl(logger *zap.SugaredLogger, | ||
| pipelineStatusTimelineService status.PipelineStatusTimelineService, | ||
| enforcerUtil rbac.EnforcerUtil, | ||
| enforcer casbin.Enforcer) *AppStoreStatusTimelineRestHandlerImpl { | ||
| return &AppStoreStatusTimelineRestHandlerImpl{ | ||
| logger: logger, | ||
| pipelineStatusTimelineService: pipelineStatusTimelineService, | ||
| enforcerUtil: enforcerUtil, | ||
| enforcer: enforcer, | ||
| } | ||
| } | ||
|
|
||
| func (handler AppStoreStatusTimelineRestHandlerImpl) FetchTimelinesForAppStore(w http.ResponseWriter, r *http.Request) { | ||
| vars := mux.Vars(r) | ||
| installedAppId, err := strconv.Atoi(vars["installedAppId"]) | ||
| if err != nil { | ||
| common.WriteJsonResp(w, err, nil, http.StatusBadRequest) | ||
| return | ||
| } | ||
| envId, err := strconv.Atoi(vars["envId"]) | ||
| if err != nil { | ||
| common.WriteJsonResp(w, err, nil, http.StatusBadRequest) | ||
| return | ||
| } | ||
| installedAppVersionHistoryId := 0 | ||
| installedAppVersionHistoryIdParam := r.URL.Query().Get("installedAppVersionHistoryId") | ||
| if len(installedAppVersionHistoryIdParam) != 0 { | ||
| installedAppVersionHistoryId, err = strconv.Atoi(installedAppVersionHistoryIdParam) | ||
| if err != nil { | ||
| common.WriteJsonResp(w, err, nil, http.StatusBadRequest) | ||
| return | ||
| } | ||
| } | ||
| resourceName := handler.enforcerUtil.GetAppRBACNameByAppId(installedAppId) | ||
| token := r.Header.Get("token") | ||
| if ok := handler.enforcer.Enforce(token, casbin.ResourceApplications, casbin.ActionGet, resourceName); !ok { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. need to check environment enforcer |
||
| common.WriteJsonResp(w, fmt.Errorf("unauthorized user"), "Unauthorized User", http.StatusForbidden) | ||
| return | ||
| } | ||
|
|
||
| timelines, err := handler.pipelineStatusTimelineService.FetchTimelinesForAppStore(installedAppId, envId, installedAppVersionHistoryId) | ||
| if err != nil { | ||
| handler.logger.Errorw("error in getting pipeline status timelines by installedAppVersionHistoryId", "err", err, "installedAppVersionHistoryId", installedAppVersionHistoryId, "installedAppId", installedAppId, "envId", envId) | ||
| common.WriteJsonResp(w, err, nil, http.StatusInternalServerError) | ||
| return | ||
| } | ||
| common.WriteJsonResp(w, err, timelines, http.StatusOK) | ||
| return | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.