-
Notifications
You must be signed in to change notification settings - Fork 554
feat:store notes.txt in db and fetch from db #3183
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
Merged
Merged
Changes from 10 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
fc7b04f
notes.txt added to database
adi6859 46d6228
Merge branch 'main' into store-notes-db
adi6859 ac0b96b
issue fixed
adi6859 635f830
rbac function added
adi6859 74d83e6
error message updated
adi6859 f766d46
open api spec added
adi6859 1ca9704
Merge branch 'main' into store-notes-db
adi6859 7a479bd
made changes as suggested
adi6859 d06a98e
version issue fixed
adi6859 4dcd6e2
println statement for chartversion removed
adi6859 504124d
chartversion updated
adi6859 3f4d69d
chartversion updated
adi6859 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -40,6 +40,7 @@ import ( | |
| util3 "github.com/devtron-labs/devtron/util" | ||
| "github.com/devtron-labs/devtron/util/argo" | ||
| "net/http" | ||
| "regexp" | ||
|
|
||
| /* #nosec */ | ||
| "crypto/sha1" | ||
|
|
@@ -82,6 +83,7 @@ type InstalledAppService interface { | |
| MarkGitOpsInstalledAppsDeletedIfArgoAppIsDeleted(installedAppId int, envId int) error | ||
| CheckAppExistsByInstalledAppId(installedAppId int) error | ||
| FindNotesForArgoApplication(installedAppId, envId int) (string, string, error) | ||
| FetchChartNotes(installedAppId int, envId int, token string, checkNotesAuth func(token string, appName string, envId int) bool) (string, error) | ||
| } | ||
|
|
||
| type InstalledAppServiceImpl struct { | ||
|
|
@@ -783,6 +785,48 @@ func (impl *InstalledAppServiceImpl) FindAppDetailsForAppstoreApplication(instal | |
| } | ||
| return appDetail, nil | ||
| } | ||
| func (impl *InstalledAppServiceImpl) FetchChartNotes(installedAppId int, envId int, token string, checkNotesAuth func(token string, appName string, envId int) bool) (string, error) { | ||
| //check notes.txt in db | ||
| installedApp, err := impl.installedAppRepository.FetchNotes(installedAppId) | ||
| installedAppVerison, err := impl.installedAppRepository.GetInstalledAppVersionByInstalledAppIdAndEnvId(installedAppId, envId) | ||
| if err != nil { | ||
| impl.logger.Errorw("error fetching installed app version in installed app service", "err", err) | ||
| return "", err | ||
| } | ||
| appStoreAppVersion, err := impl.appStoreApplicationVersionRepository.FindById(installedAppVerison.AppStoreApplicationVersion.Id) | ||
| if err != nil { | ||
| impl.logger.Errorw("error fetching app store app version in installed app service", "err", err) | ||
| return "", err | ||
| } | ||
| chartVersion := appStoreAppVersion.Version | ||
| re := regexp.MustCompile(`CHART VERSION: ([0-9]+\.[0-9]+\.[0-9]+)`) | ||
| newStr := re.ReplaceAllString(installedApp.Notes, "CHART VERSION: "+chartVersion) | ||
| installedApp.Notes = newStr | ||
| appName := installedApp.App.AppName | ||
| if err != nil { | ||
| impl.logger.Errorw("error fetching notes from db", "err", err) | ||
| return "", err | ||
| } | ||
| isValidAuth := checkNotesAuth(token, appName, envId) | ||
| if !isValidAuth { | ||
| impl.logger.Errorw("unauthorized user", "isValidAuth", isValidAuth) | ||
| return "", fmt.Errorf("unauthorized user") | ||
| } | ||
| //if notes is not present in db then below call will happen | ||
| if installedApp.Notes == "" { | ||
|
Contributor
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. put comments
Contributor
Author
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 |
||
| notes, _, err := impl.FindNotesForArgoApplication(installedAppId, envId) | ||
| if err != nil { | ||
| impl.logger.Errorw("error fetching notes", "err", err) | ||
| return "", err | ||
| } | ||
| if notes == "" { | ||
| impl.logger.Errorw("error fetching notes", "err", err) | ||
| } | ||
| return notes, err | ||
| } | ||
|
|
||
| return installedApp.Notes, nil | ||
| } | ||
| func (impl *InstalledAppServiceImpl) FindNotesForArgoApplication(installedAppId, envId int) (string, string, error) { | ||
| installedAppVerison, err := impl.installedAppRepository.GetInstalledAppVersionByInstalledAppIdAndEnvId(installedAppId, envId) | ||
| if err != nil { | ||
|
|
@@ -829,7 +873,13 @@ func (impl *InstalledAppServiceImpl) FindNotesForArgoApplication(installedAppId, | |
| impl.logger.Errorw("error in fetching notes", "err", err) | ||
| return notes, appName, err | ||
| } | ||
| _, err = impl.appStoreDeploymentService.UpdateNotesForInstalledApp(installedAppId, notes) | ||
| if err != nil { | ||
| impl.logger.Errorw("error in updating notes in db ", "err", err) | ||
| return notes, appName, err | ||
| } | ||
| } | ||
|
|
||
| return notes, appName, nil | ||
| } | ||
|
|
||
|
|
||
This file contains hidden or 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
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.
we are already getting appStoreAppVersion by installedAppVerison, err := impl.installedAppRepository.GetInstalledAppVersionByInstalledAppIdAndEnvId(installedAppId, envId) , no need to fetch it again.
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.
ok,changes done