Skip to content

Commit

Permalink
Split boxes for snapshot schedule and retention (#4592)
Browse files Browse the repository at this point in the history
* html update mk1

* format

* split routes

* format, again

* fix route naming

* show message in right location

* add blank line

* explicitly callout that retention policies are for both manual and scheduled snapshots

* f

* fix nbsp

* update schedule box whitespace, retention button name

* fix whitespace in retention box

* scheduled, not automatic
  • Loading branch information
laverya authored May 3, 2024
1 parent 6ffd146 commit bfc971a
Show file tree
Hide file tree
Showing 6 changed files with 346 additions and 96 deletions.
12 changes: 8 additions & 4 deletions pkg/handlers/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,10 @@ func RegisterSessionAuthRoutes(r *mux.Router, kotsStore store.Store, handler KOT
HandlerFunc(middleware.EnforceAccess(policy.AppBackupRead, handler.ListBackups))
r.Name("GetSnapshotConfig").Path("/api/v1/app/{appSlug}/snapshot/config").Methods("GET").
HandlerFunc(middleware.EnforceAccess(policy.AppSnapshotsettingsRead, handler.GetSnapshotConfig))
r.Name("SaveSnapshotConfig").Path("/api/v1/app/{appSlug}/snapshot/config").Methods("PUT").
HandlerFunc(middleware.EnforceAccess(policy.AppSnapshotsettingsWrite, handler.SaveSnapshotConfig))
r.Name("SaveSnapshotSchedule").Path("/api/v1/app/{appSlug}/snapshot/schedule").Methods("PUT").
HandlerFunc(middleware.EnforceAccess(policy.AppSnapshotsettingsWrite, handler.SaveSnapshotSchedule))
r.Name("SaveSnapshotRetention").Path("/api/v1/app/{appSlug}/snapshot/retention").Methods("PUT").
HandlerFunc(middleware.EnforceAccess(policy.AppSnapshotsettingsWrite, handler.SaveSnapshotRetention))

// Global snapshot routes
r.Name("ListInstanceBackups").Path("/api/v1/snapshots").Methods("GET").
Expand All @@ -235,8 +237,10 @@ func RegisterSessionAuthRoutes(r *mux.Router, kotsStore store.Store, handler KOT
HandlerFunc(middleware.EnforceAccess(policy.BackupWrite, handler.CreateInstanceBackup))
r.Name("GetInstanceSnapshotConfig").Path("/api/v1/snapshot/config").Methods("GET").
HandlerFunc(middleware.EnforceAccess(policy.SnapshotsettingsRead, handler.GetInstanceSnapshotConfig))
r.Name("SaveInstanceSnapshotConfig").Path("/api/v1/snapshot/config").Methods("PUT").
HandlerFunc(middleware.EnforceAccess(policy.SnapshotsettingsWrite, handler.SaveInstanceSnapshotConfig))
r.Name("SaveInstanceSnapshotSchedule").Path("/api/v1/snapshot/schedule").Methods("PUT").
HandlerFunc(middleware.EnforceAccess(policy.SnapshotsettingsWrite, handler.SaveInstanceSnapshotSchedule))
r.Name("SaveInstanceSnapshotRetention").Path("/api/v1/snapshot/retention").Methods("PUT").
HandlerFunc(middleware.EnforceAccess(policy.SnapshotsettingsWrite, handler.SaveInstanceSnapshotRetention))
r.Name("GetGlobalSnapshotSettings").Path("/api/v1/snapshots/settings").Methods("GET").
HandlerFunc(middleware.EnforceAccess(policy.SnapshotsettingsRead, handler.GetGlobalSnapshotSettings))
r.Name("UpdateGlobalSnapshotSettings").Path("/api/v1/snapshots/settings").Methods("PUT").
Expand Down
29 changes: 25 additions & 4 deletions pkg/handlers/handlers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -976,13 +976,24 @@ var HandlerPolicyTests = map[string][]HandlerPolicyTest{
ExpectStatus: http.StatusOK,
},
},
"SaveSnapshotConfig": {
"SaveSnapshotSchedule": {
{
Vars: map[string]string{"appSlug": "my-app"},
Roles: []rbactypes.Role{rbac.ClusterAdminRole},
SessionRoles: []string{rbac.ClusterAdminRoleID},
Calls: func(storeRecorder *mock_store.MockStoreMockRecorder, handlerRecorder *mock_handlers.MockKOTSHandlerMockRecorder) {
handlerRecorder.SaveSnapshotConfig(gomock.Any(), gomock.Any())
handlerRecorder.SaveSnapshotSchedule(gomock.Any(), gomock.Any())
},
ExpectStatus: http.StatusOK,
},
},
"SaveSnapshotRetention": {
{
Vars: map[string]string{"appSlug": "my-app"},
Roles: []rbactypes.Role{rbac.ClusterAdminRole},
SessionRoles: []string{rbac.ClusterAdminRoleID},
Calls: func(storeRecorder *mock_store.MockStoreMockRecorder, handlerRecorder *mock_handlers.MockKOTSHandlerMockRecorder) {
handlerRecorder.SaveSnapshotRetention(gomock.Any(), gomock.Any())
},
ExpectStatus: http.StatusOK,
},
Expand Down Expand Up @@ -1018,12 +1029,22 @@ var HandlerPolicyTests = map[string][]HandlerPolicyTest{
ExpectStatus: http.StatusOK,
},
},
"SaveInstanceSnapshotConfig": {
"SaveInstanceSnapshotSchedule": {
{
Roles: []rbactypes.Role{rbac.ClusterAdminRole},
SessionRoles: []string{rbac.ClusterAdminRoleID},
Calls: func(storeRecorder *mock_store.MockStoreMockRecorder, handlerRecorder *mock_handlers.MockKOTSHandlerMockRecorder) {
handlerRecorder.SaveInstanceSnapshotSchedule(gomock.Any(), gomock.Any())
},
ExpectStatus: http.StatusOK,
},
},
"SaveInstanceSnapshotRetention": {
{
Roles: []rbactypes.Role{rbac.ClusterAdminRole},
SessionRoles: []string{rbac.ClusterAdminRoleID},
Calls: func(storeRecorder *mock_store.MockStoreMockRecorder, handlerRecorder *mock_handlers.MockKOTSHandlerMockRecorder) {
handlerRecorder.SaveInstanceSnapshotConfig(gomock.Any(), gomock.Any())
handlerRecorder.SaveInstanceSnapshotRetention(gomock.Any(), gomock.Any())
},
ExpectStatus: http.StatusOK,
},
Expand Down
6 changes: 4 additions & 2 deletions pkg/handlers/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,15 @@ type KOTSHandler interface {
GetRestoreDetails(w http.ResponseWriter, r *http.Request)
ListBackups(w http.ResponseWriter, r *http.Request)
GetSnapshotConfig(w http.ResponseWriter, r *http.Request)
SaveSnapshotConfig(w http.ResponseWriter, r *http.Request)
SaveSnapshotSchedule(w http.ResponseWriter, r *http.Request)
SaveSnapshotRetention(w http.ResponseWriter, r *http.Request)

// Global snapshot routes
ListInstanceBackups(w http.ResponseWriter, r *http.Request)
CreateInstanceBackup(w http.ResponseWriter, r *http.Request)
GetInstanceSnapshotConfig(w http.ResponseWriter, r *http.Request)
SaveInstanceSnapshotConfig(w http.ResponseWriter, r *http.Request)
SaveInstanceSnapshotSchedule(w http.ResponseWriter, r *http.Request)
SaveInstanceSnapshotRetention(w http.ResponseWriter, r *http.Request)
GetGlobalSnapshotSettings(w http.ResponseWriter, r *http.Request)
UpdateGlobalSnapshotSettings(w http.ResponseWriter, r *http.Request)
GetFileSystemSnapshotProviderInstructions(w http.ResponseWriter, r *http.Request)
Expand Down
48 changes: 36 additions & 12 deletions pkg/handlers/mock/mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit bfc971a

Please sign in to comment.