mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
merge
This commit is contained in:
commit
d654e4c530
@ -6,6 +6,7 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/grafana/grafana/pkg/api/response"
|
||||
@ -237,10 +238,10 @@ func (s *Service) ValidateToken(ctx context.Context, cm cloudmigration.CloudMigr
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *Service) GetMigration(ctx context.Context, uid string) (*cloudmigration.CloudMigration, error) {
|
||||
func (s *Service) GetMigration(ctx context.Context, id int64) (*cloudmigration.CloudMigration, error) {
|
||||
ctx, span := s.tracer.Start(ctx, "CloudMigrationService.GetMigration")
|
||||
defer span.End()
|
||||
migration, err := s.store.GetMigrationByUID(ctx, uid)
|
||||
migration, err := s.store.GetMigration(ctx, id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -257,7 +258,7 @@ func (s *Service) GetMigrationList(ctx context.Context) (*cloudmigration.CloudMi
|
||||
migrations := make([]cloudmigration.CloudMigrationResponse, 0)
|
||||
for _, v := range values {
|
||||
migrations = append(migrations, cloudmigration.CloudMigrationResponse{
|
||||
UID: v.UID,
|
||||
ID: v.ID,
|
||||
Stack: v.Stack,
|
||||
Created: v.Created,
|
||||
Updated: v.Updated,
|
||||
@ -292,21 +293,21 @@ func (s *Service) CreateMigration(ctx context.Context, cmd cloudmigration.CloudM
|
||||
}
|
||||
|
||||
return &cloudmigration.CloudMigrationResponse{
|
||||
UID: cm.UID,
|
||||
ID: cm.ID,
|
||||
Stack: token.Instance.Slug,
|
||||
Created: cm.Created,
|
||||
Updated: cm.Updated,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *Service) UpdateMigration(ctx context.Context, uid string, request cloudmigration.CloudMigrationRequest) (*cloudmigration.CloudMigrationResponse, error) {
|
||||
func (s *Service) UpdateMigration(ctx context.Context, id int64, cm cloudmigration.CloudMigrationRequest) (*cloudmigration.CloudMigrationResponse, error) {
|
||||
// TODO: Implement method
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (s *Service) RunMigration(ctx context.Context, uid string) (*cloudmigration.MigrateDataResponseDTO, error) {
|
||||
func (s *Service) RunMigration(ctx context.Context, id int64) (*cloudmigration.MigrateDataResponseDTO, error) {
|
||||
// Get migration to read the auth token
|
||||
migration, err := s.GetMigration(ctx, uid)
|
||||
migration, err := s.GetMigration(ctx, id)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("migration get error: %w", err)
|
||||
}
|
||||
@ -333,15 +334,15 @@ func (s *Service) RunMigration(ctx context.Context, uid string) (*cloudmigration
|
||||
}
|
||||
|
||||
// save the result of the migration
|
||||
runUID, err := s.SaveMigrationRun(ctx, &cloudmigration.CloudMigrationRun{
|
||||
CloudMigrationUID: migration.UID,
|
||||
runID, err := s.SaveMigrationRun(ctx, &cloudmigration.CloudMigrationRun{
|
||||
CloudMigrationUID: strconv.Itoa(int(id)),
|
||||
Result: respData,
|
||||
})
|
||||
if err != nil {
|
||||
response.Error(http.StatusInternalServerError, "migration run save error", err)
|
||||
}
|
||||
|
||||
resp.RunUID = runUID
|
||||
resp.RunID = runID
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
@ -469,50 +470,45 @@ func (s *Service) getDashboards(ctx context.Context) ([]dashboards.Dashboard, er
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (s *Service) SaveMigrationRun(ctx context.Context, cmr *cloudmigration.CloudMigrationRun) (string, error) {
|
||||
func (s *Service) SaveMigrationRun(ctx context.Context, cmr *cloudmigration.CloudMigrationRun) (int64, error) {
|
||||
cmr.Created = time.Now()
|
||||
cmr.Updated = time.Now()
|
||||
cmr.Finished = time.Now()
|
||||
err := s.store.SaveMigrationRun(ctx, cmr)
|
||||
if err != nil {
|
||||
s.log.Error("Failed to save migration run", "err", err)
|
||||
return "", err
|
||||
return -1, err
|
||||
}
|
||||
return cmr.UID, nil
|
||||
return cmr.ID, nil
|
||||
}
|
||||
|
||||
func (s *Service) GetMigrationStatus(ctx context.Context, runUID string) (*cloudmigration.CloudMigrationRun, error) {
|
||||
cmr, err := s.store.GetMigrationStatus(ctx, runUID)
|
||||
func (s *Service) GetMigrationStatus(ctx context.Context, id string, runID string) (*cloudmigration.CloudMigrationRun, error) {
|
||||
cmr, err := s.store.GetMigrationStatus(ctx, id, runID)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("retrieving migration status from db: %w", err)
|
||||
}
|
||||
|
||||
return cmr, nil
|
||||
}
|
||||
|
||||
func (s *Service) GetMigrationRunList(ctx context.Context, migUID string) (*cloudmigration.CloudMigrationRunList, error) {
|
||||
runs, err := s.store.GetMigrationStatusList(ctx, migUID)
|
||||
func (s *Service) GetMigrationRunList(ctx context.Context, migrationID string) (*cloudmigration.CloudMigrationRunList, error) {
|
||||
runs, err := s.store.GetMigrationStatusList(ctx, migrationID)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("retrieving migration statuses from db: %w", err)
|
||||
}
|
||||
|
||||
runList := &cloudmigration.CloudMigrationRunList{Runs: []cloudmigration.MigrateDataResponseDTO{}}
|
||||
runList := &cloudmigration.CloudMigrationRunList{Runs: []cloudmigration.MigrateDataResponseListDTO{}}
|
||||
for _, s := range runs {
|
||||
// attempt to bind the raw result to a list of response item DTOs
|
||||
r := cloudmigration.MigrateDataResponseDTO{
|
||||
Items: []cloudmigration.MigrateDataResponseItemDTO{},
|
||||
}
|
||||
if err := json.Unmarshal(s.Result, &r); err != nil {
|
||||
return nil, fmt.Errorf("error unmarshalling migration response items: %w", err)
|
||||
}
|
||||
r.RunUID = s.UID
|
||||
runList.Runs = append(runList.Runs, r)
|
||||
runList.Runs = append(runList.Runs, cloudmigration.MigrateDataResponseListDTO{
|
||||
RunID: s.ID,
|
||||
})
|
||||
}
|
||||
|
||||
return runList, nil
|
||||
}
|
||||
|
||||
func (s *Service) DeleteMigration(ctx context.Context, uid string) (*cloudmigration.CloudMigration, error) {
|
||||
c, err := s.store.DeleteMigration(ctx, uid)
|
||||
func (s *Service) DeleteMigration(ctx context.Context, id int64) (*cloudmigration.CloudMigration, error) {
|
||||
c, err := s.store.DeleteMigration(ctx, id)
|
||||
if err != nil {
|
||||
return c, fmt.Errorf("deleting migration from db: %w", err)
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ func (r CloudMigrationRun) ToResponse() (*MigrateDataResponseDTO, error) {
|
||||
}
|
||||
|
||||
type CloudMigrationRunList struct {
|
||||
Runs []MigrateDataResponseDTO `json:"runs"`
|
||||
Runs []MigrateDataResponseListDTO `json:"runs"`
|
||||
}
|
||||
|
||||
// swagger:parameters createMigration
|
||||
@ -178,6 +178,10 @@ type MigrateDataResponseDTO struct {
|
||||
Items []MigrateDataResponseItemDTO `json:"items"`
|
||||
}
|
||||
|
||||
type MigrateDataResponseListDTO struct {
|
||||
RunID int64 `json:"id"`
|
||||
}
|
||||
|
||||
type MigrateDataResponseItemDTO struct {
|
||||
// required:true
|
||||
Type MigrateDataType `json:"type"`
|
||||
|
@ -13053,7 +13053,7 @@
|
||||
"runs": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/MigrateDataResponseDTO"
|
||||
"$ref": "#/definitions/MigrateDataResponseListDTO"
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -16244,6 +16244,15 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"MigrateDataResponseListDTO": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
}
|
||||
}
|
||||
},
|
||||
"MoveFolderCommand": {
|
||||
"description": "MoveFolderCommand captures the information required by the folder service\nto move a folder.",
|
||||
"type": "object",
|
||||
|
@ -38,7 +38,7 @@ export const XYChartPanel2 = (props: Props2) => {
|
||||
let { builder, prepData } = useMemo(
|
||||
() => prepConfig(series, config.theme2),
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
[mapping, mappedSeries, props.data.structureRev, props.fieldConfig]
|
||||
[mapping, mappedSeries, props.data.structureRev, props.fieldConfig, props.options.tooltip]
|
||||
);
|
||||
|
||||
// generate data struct for uPlot mode: 2
|
||||
|
@ -24,7 +24,7 @@ export interface Props {
|
||||
}
|
||||
|
||||
function stripSeriesName(fieldName: string, seriesName: string) {
|
||||
if (fieldName.includes(' ')) {
|
||||
if (fieldName !== seriesName && fieldName.includes(' ')) {
|
||||
fieldName = fieldName.replace(seriesName, '').trim();
|
||||
}
|
||||
|
||||
|
@ -3688,7 +3688,7 @@
|
||||
"properties": {
|
||||
"runs": {
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/MigrateDataResponseDTO"
|
||||
"$ref": "#/components/schemas/MigrateDataResponseListDTO"
|
||||
},
|
||||
"type": "array"
|
||||
}
|
||||
@ -6881,6 +6881,15 @@
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
"MigrateDataResponseListDTO": {
|
||||
"properties": {
|
||||
"id": {
|
||||
"format": "int64",
|
||||
"type": "integer"
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
},
|
||||
"MoveFolderCommand": {
|
||||
"description": "MoveFolderCommand captures the information required by the folder service\nto move a folder.",
|
||||
"properties": {
|
||||
|
Loading…
Reference in New Issue
Block a user