skip readonly check when provisioning correlations

This commit is contained in:
Elfo404 2022-07-12 17:21:21 +02:00
parent 83814af498
commit 1f3307637e
No known key found for this signature in database
GPG Key ID: 586539D9491F0726
4 changed files with 19 additions and 18 deletions

View File

@ -246,8 +246,6 @@ datasources:
type: loki
access: proxy
url: http://localhost:3100
editable: true
version: 10
correlations:
- targetUid: gdev-jaeger
label: "Jaeger traces"

View File

@ -29,7 +29,7 @@ func (s CorrelationsService) createCorrelation(ctx context.Context, cmd CreateCo
return ErrSourceDataSourceDoesNotExists
}
if query.Result.ReadOnly {
if !cmd.SkipReadOnlyCheck && query.Result.ReadOnly {
return ErrSourceDataSourceReadOnly
}

View File

@ -40,11 +40,12 @@ type CreateCorrelationResponse struct {
type CreateCorrelationCommand struct {
// UID of the data source for which correlation is created.
// example: PE1C5CBDA0504A6A3
SourceUID string
OrgId int64
TargetUID string `json:"targetUid" binding:"Required"`
Label string `json:"label"`
Description string `json:"description"`
SourceUID string
OrgId int64
TargetUID string `json:"targetUid" binding:"Required"`
Label string `json:"label"`
Description string `json:"description"`
SkipReadOnlyCheck bool
}
type DeleteCorrelationsBySourceUIDCommand struct {

View File

@ -77,11 +77,12 @@ func (dc *DatasourceProvisioner) apply(ctx context.Context, cfg *configs) error
for _, correlation := range ds.Correlations {
if field, ok := correlation.(map[string]interface{}); ok {
correlationsToInsert = append(correlationsToInsert, correlations.CreateCorrelationCommand{
SourceUID: insertCmd.Result.Uid,
TargetUID: field["targetUid"].(string),
Label: field["label"].(string),
Description: field["description"].(string),
OrgId: insertCmd.OrgId,
SourceUID: insertCmd.Result.Uid,
TargetUID: field["targetUid"].(string),
Label: field["label"].(string),
Description: field["description"].(string),
OrgId: insertCmd.OrgId,
SkipReadOnlyCheck: true,
})
}
}
@ -102,11 +103,12 @@ func (dc *DatasourceProvisioner) apply(ctx context.Context, cfg *configs) error
for _, correlation := range ds.Correlations {
if field, ok := correlation.(map[string]interface{}); ok {
correlationsToInsert = append(correlationsToInsert, correlations.CreateCorrelationCommand{
SourceUID: cmd.Result.Uid,
TargetUID: field["targetUid"].(string),
Label: field["label"].(string),
Description: field["description"].(string),
OrgId: updateCmd.OrgId,
SourceUID: cmd.Result.Uid,
TargetUID: field["targetUid"].(string),
Label: field["label"].(string),
Description: field["description"].(string),
OrgId: updateCmd.OrgId,
SkipReadOnlyCheck: true,
})
}
}