CloudMigrations: Break snapshot resources out into their own table (#89575)
* create a new table for migration resources * remove raw result bytes from db * more snapshot resource management stuff * integrate new table with snapshots * pass in result limit and offset as params * combine create and update * set up xorm store test * add unit tests * save some cpu * remove unneeded arg * regen swagger * fix bug with result processing * fix update create logic so that uid isn't required for lookup * change offset to page * regen swagger * revert accidental changes to file * curl command page should be 1 indexed
This commit is contained in:
@@ -2,7 +2,6 @@ package gmsclient
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"math/rand"
|
||||
"time"
|
||||
|
||||
@@ -29,11 +28,11 @@ func (c *memoryClientImpl) MigrateData(
|
||||
request cloudmigration.MigrateDataRequest,
|
||||
) (*cloudmigration.MigrateDataResponse, error) {
|
||||
result := cloudmigration.MigrateDataResponse{
|
||||
Items: make([]cloudmigration.MigrateDataResponseItem, len(request.Items)),
|
||||
Items: make([]cloudmigration.CloudMigrationResource, len(request.Items)),
|
||||
}
|
||||
|
||||
for i, v := range request.Items {
|
||||
result.Items[i] = cloudmigration.MigrateDataResponseItem{
|
||||
result.Items[i] = cloudmigration.CloudMigrationResource{
|
||||
Type: v.Type,
|
||||
RefID: v.RefID,
|
||||
Status: cloudmigration.ItemStatusOK,
|
||||
@@ -60,38 +59,32 @@ func (c *memoryClientImpl) InitializeSnapshot(context.Context, cloudmigration.Cl
|
||||
}
|
||||
|
||||
func (c *memoryClientImpl) GetSnapshotStatus(ctx context.Context, session cloudmigration.CloudMigrationSession, snapshot cloudmigration.CloudMigrationSnapshot) (*cloudmigration.CloudMigrationSnapshot, error) {
|
||||
// just fake an entire response
|
||||
gmsSnapshot := cloudmigration.CloudMigrationSnapshot{
|
||||
Status: cloudmigration.SnapshotStatusFinished,
|
||||
GMSSnapshotUID: util.GenerateShortUID(),
|
||||
Result: []byte{},
|
||||
Finished: time.Now(),
|
||||
}
|
||||
|
||||
result := []cloudmigration.MigrateDataResponseItem{
|
||||
results := []cloudmigration.CloudMigrationResource{
|
||||
{
|
||||
Type: cloudmigration.DashboardDataType,
|
||||
RefID: util.GenerateShortUID(),
|
||||
RefID: "dash1",
|
||||
Status: cloudmigration.ItemStatusOK,
|
||||
},
|
||||
{
|
||||
Type: cloudmigration.DatasourceDataType,
|
||||
RefID: util.GenerateShortUID(),
|
||||
RefID: "ds1",
|
||||
Status: cloudmigration.ItemStatusError,
|
||||
Error: "fake error",
|
||||
},
|
||||
{
|
||||
Type: cloudmigration.FolderDataType,
|
||||
RefID: util.GenerateShortUID(),
|
||||
RefID: "folder1",
|
||||
Status: cloudmigration.ItemStatusOK,
|
||||
},
|
||||
}
|
||||
|
||||
b, err := json.Marshal(result)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
// just fake an entire response
|
||||
gmsSnapshot := cloudmigration.CloudMigrationSnapshot{
|
||||
Status: cloudmigration.SnapshotStatusFinished,
|
||||
GMSSnapshotUID: "gmssnapshotuid",
|
||||
Resources: results,
|
||||
Finished: time.Now(),
|
||||
}
|
||||
gmsSnapshot.Result = b
|
||||
|
||||
return &gmsSnapshot, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user