-
Notifications
You must be signed in to change notification settings - Fork 460
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
feat: description for apps and jobs #3668
Merged
Merged
Changes from 18 commits
Commits
Show all changes
47 commits
Select commit
Hold shift + click to select a range
859a528
cluster notes code refactoring
gireesh-devtron 1d9d385
uncommit port change
gireesh-devtron 801c596
code refactoring and cluster note struct changes
gireesh-devtron df0bc4e
Merge branch 'main' into app_job_description
gireesh-devtron 33bddb6
revert description from appListing api
gireesh-devtron d813956
wip
gireesh-devtron 2f96e57
query fix
gireesh-devtron 89bb62a
fix test files
gireesh-devtron 1905b8b
added all the db operations in transaction
gireesh-devtron 1a7dfbf
non pointer payload in db request
gireesh-devtron 2187cad
fixes
gireesh-devtron 7e45ba5
rewire
gireesh-devtron ed3dce8
fix
gireesh-devtron fdd8483
error log added
gireesh-devtron d376b5e
pg table name fix and trasaction handling bug fix
gireesh-devtron 1cbf69b
err handling
gireesh-devtron 53a168d
added cascade delete constraint
gireesh-devtron 85ab74d
updated down script
gireesh-devtron 557d79a
added missing logs
gireesh-devtron 7d82b01
renaming
gireesh-devtron d493df4
fix existing integration tests
gireesh-devtron 872a123
remove logger
gireesh-devtron d384561
rewire
gireesh-devtron 32e2180
rewire
gireesh-devtron 01a73a4
refactor
gireesh-devtron c7285a2
moved history data handling from genericNoteService to genericNoteHis…
gireesh-devtron b3a09d2
generated mocks
gireesh-devtron 25d96e0
added unit tests for save method
gireesh-devtron ae67b01
sql down's code fixed
ShashwatDadhich e555817
sql down's code fixed for ;
ShashwatDadhich fad7a21
identifier missing
gireesh-devtron 3c2775c
identifier missing
gireesh-devtron 18a1033
unit tests WIP
gireesh-devtron 4e3ff51
unit tests added for save function
gireesh-devtron 8a8f6ef
vars rename
gireesh-devtron 7a36f04
remove commented code
gireesh-devtron a60fbfc
changed end point
gireesh-devtron 2f852f3
Merge branch 'main' into app_job_description
gireesh-devtron 8db2711
resolve review comments
gireesh-devtron 9ed8cc2
refactor
gireesh-devtron b9c488d
fix
gireesh-devtron 07c48eb
test script
gireesh-devtron a749184
cyclic dependency fix
gireesh-devtron c191ce1
query fix
gireesh-devtron babef63
added unit tests for update method
gireesh-devtron a6ce8e7
fix
gireesh-devtron 4932825
merge main
gireesh-devtron File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,8 @@ import ( | |
"github.com/devtron-labs/devtron/api/restHandler/common" | ||
"github.com/devtron-labs/devtron/pkg/app" | ||
"github.com/devtron-labs/devtron/pkg/bean" | ||
"github.com/devtron-labs/devtron/pkg/genericNotes" | ||
"github.com/devtron-labs/devtron/pkg/genericNotes/repository" | ||
"github.com/devtron-labs/devtron/pkg/user" | ||
"github.com/devtron-labs/devtron/pkg/user/casbin" | ||
"github.com/devtron-labs/devtron/util/rbac" | ||
|
@@ -42,31 +44,35 @@ type AppRestHandler interface { | |
UpdateApp(w http.ResponseWriter, r *http.Request) | ||
UpdateProjectForApps(w http.ResponseWriter, r *http.Request) | ||
GetAppListByTeamIds(w http.ResponseWriter, r *http.Request) | ||
UpdateAppDescription(w http.ResponseWriter, r *http.Request) | ||
} | ||
|
||
type AppRestHandlerImpl struct { | ||
logger *zap.SugaredLogger | ||
appService app.AppCrudOperationService | ||
userAuthService user.UserService | ||
validator *validator.Validate | ||
enforcerUtil rbac.EnforcerUtil | ||
enforcer casbin.Enforcer | ||
helmAppService client.HelmAppService | ||
enforcerUtilHelm rbac.EnforcerUtilHelm | ||
logger *zap.SugaredLogger | ||
appService app.AppCrudOperationService | ||
userAuthService user.UserService | ||
validator *validator.Validate | ||
enforcerUtil rbac.EnforcerUtil | ||
enforcer casbin.Enforcer | ||
helmAppService client.HelmAppService | ||
enforcerUtilHelm rbac.EnforcerUtilHelm | ||
genericNoteService genericNotes.GenericNoteService | ||
} | ||
|
||
func NewAppRestHandlerImpl(logger *zap.SugaredLogger, appService app.AppCrudOperationService, | ||
userAuthService user.UserService, validator *validator.Validate, enforcerUtil rbac.EnforcerUtil, | ||
enforcer casbin.Enforcer, helmAppService client.HelmAppService, enforcerUtilHelm rbac.EnforcerUtilHelm) *AppRestHandlerImpl { | ||
enforcer casbin.Enforcer, helmAppService client.HelmAppService, enforcerUtilHelm rbac.EnforcerUtilHelm, | ||
genericNoteService genericNotes.GenericNoteService) *AppRestHandlerImpl { | ||
handler := &AppRestHandlerImpl{ | ||
logger: logger, | ||
appService: appService, | ||
userAuthService: userAuthService, | ||
validator: validator, | ||
enforcerUtil: enforcerUtil, | ||
enforcer: enforcer, | ||
helmAppService: helmAppService, | ||
enforcerUtilHelm: enforcerUtilHelm, | ||
logger: logger, | ||
appService: appService, | ||
userAuthService: userAuthService, | ||
validator: validator, | ||
enforcerUtil: enforcerUtil, | ||
enforcer: enforcer, | ||
helmAppService: helmAppService, | ||
enforcerUtilHelm: enforcerUtilHelm, | ||
genericNoteService: genericNoteService, | ||
} | ||
return handler | ||
} | ||
|
@@ -337,3 +343,48 @@ func (handler AppRestHandlerImpl) GetAppListByTeamIds(w http.ResponseWriter, r * | |
// RBAC | ||
common.WriteJsonResp(w, err, projectWiseApps, http.StatusOK) | ||
} | ||
|
||
func (handler AppRestHandlerImpl) UpdateAppDescription(w http.ResponseWriter, r *http.Request) { | ||
token := r.Header.Get("token") | ||
decoder := json.NewDecoder(r.Body) | ||
userId, err := handler.userAuthService.GetLoggedInUser(r) | ||
if userId == 0 || err != nil { | ||
handler.logger.Errorw("service err, Update", "error", err, "userId", userId) | ||
common.WriteJsonResp(w, err, "Unauthorized User", http.StatusUnauthorized) | ||
return | ||
} | ||
var bean repository.GenericNote | ||
err = decoder.Decode(&bean) | ||
if err != nil { | ||
handler.logger.Errorw("request err, Update", "error", err, "payload", bean) | ||
common.WriteJsonResp(w, err, nil, http.StatusBadRequest) | ||
return | ||
} | ||
handler.logger.Infow("request payload, Update", "payload", bean) | ||
err = handler.validator.Struct(bean) | ||
if err != nil { | ||
handler.logger.Errorw("validate err, Update", "error", err, "payload", bean) | ||
common.WriteJsonResp(w, err, nil, http.StatusBadRequest) | ||
return | ||
} | ||
bean.IdentifierType = repository.AppType | ||
|
||
//rbac implementation starts here | ||
|
||
// check for existing project/app permission | ||
object := handler.enforcerUtil.GetAppRBACNameByAppId(bean.Identifier) | ||
if ok := handler.enforcer.Enforce(token, casbin.ResourceApplications, casbin.ActionUpdate, object); !ok { | ||
common.WriteJsonResp(w, err, "Unauthorized User", http.StatusForbidden) | ||
return | ||
} | ||
|
||
// RBAC enforcer ends | ||
|
||
clusterNoteResponseBean, err := handler.genericNoteService.Update(&bean, userId) | ||
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. rename variable name 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. done |
||
if err != nil { | ||
handler.logger.Errorw("cluster note service err, Update", "error", err, "payload", bean) | ||
common.WriteJsonResp(w, err, nil, http.StatusInternalServerError) | ||
return | ||
} | ||
common.WriteJsonResp(w, err, clusterNoteResponseBean, http.StatusOK) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
put its log level to
debug
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done