-
Notifications
You must be signed in to change notification settings - Fork 711
fix: delete app also deletes metadata #1736
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 all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
5ce3bb7
Merge branch 'main' of github.com:pyroscope-io/pyroscope
eh-am 5eea381
chore: add an ApplicationService that bridges metadata and storage
eh-am fad2496
use an application service
eh-am 83bc499
cleanup
eh-am d183b90
delete unneeded file
eh-am c604634
cleanup
eh-am a2c586a
fix tests
eh-am 39fed39
cleanup
eh-am bf3b5ab
more cleanup
eh-am 250a598
use struct wrapping
eh-am bf96e4f
handleError
eh-am c79f509
remove storage.GetApps() since it's not used
eh-am 5586999
move applicationMetadata type from storage into model
eh-am 51f4474
fix tests
eh-am 0433082
cleanup
eh-am 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
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 was deleted.
Oops, something went wrong.
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 |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| package api | ||
|
|
||
| import ( | ||
| "context" | ||
| "encoding/json" | ||
| "fmt" | ||
| "net/http" | ||
|
|
||
| "github.com/pyroscope-io/pyroscope/pkg/model/appmetadata" | ||
| "github.com/pyroscope-io/pyroscope/pkg/server/httputils" | ||
| ) | ||
|
|
||
| type ApplicationListerAndDeleter interface { | ||
| List(context.Context) ([]appmetadata.ApplicationMetadata, error) | ||
| Delete(ctx context.Context, name string) error | ||
| } | ||
|
|
||
| type ApplicationsHandler struct { | ||
| svc ApplicationListerAndDeleter | ||
| httpUtils httputils.Utils | ||
| } | ||
|
|
||
| func NewApplicationsHandler(svc ApplicationListerAndDeleter, httpUtils httputils.Utils) *ApplicationsHandler { | ||
| return &ApplicationsHandler{ | ||
| svc: svc, | ||
| httpUtils: httpUtils, | ||
| } | ||
| } | ||
|
|
||
| func (h *ApplicationsHandler) GetApps(w http.ResponseWriter, r *http.Request) { | ||
| apps, err := h.svc.List(r.Context()) | ||
| if err != nil { | ||
| h.httpUtils.HandleError(r, w, err) | ||
| return | ||
| } | ||
|
|
||
| w.WriteHeader(http.StatusOK) | ||
| h.httpUtils.WriteResponseJSON(r, w, apps) | ||
| } | ||
|
|
||
| type DeleteAppInput struct { | ||
| Name string `json:"name"` | ||
| } | ||
kolesnikovae marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| func (h *ApplicationsHandler) DeleteApp(w http.ResponseWriter, r *http.Request) { | ||
| var payload DeleteAppInput | ||
|
|
||
| fmt.Println("calling delete app") | ||
| err := json.NewDecoder(r.Body).Decode(&payload) | ||
| if err != nil { | ||
| h.httpUtils.HandleError(r, w, httputils.JSONError{Err: err}) | ||
| return | ||
| } | ||
|
|
||
| err = h.svc.Delete(r.Context(), payload.Name) | ||
| if err != nil { | ||
| h.httpUtils.HandleError(r, w, err) | ||
| return | ||
| } | ||
| } | ||
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
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.
Uh oh!
There was an error while loading. Please reload this page.