Provisioning: Improve validation by validating across all dashboard providers (#26742)
* Provisioning: check sanity across all dashboard readers Signed-off-by: m.nabokikh <maksim.nabokikh@flant.com> * Apply suggestions from code review Co-authored-by: Emil Tullstedt <emil.tullstedt@grafana.com> Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com> * Refactor of duplicateValidator and fix issues according to commentaries Signed-off-by: m.nabokikh <maksim.nabokikh@flant.com> * Apply suggestions from code review Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com> * Remove newDuplicateEntries function Signed-off-by: m.nabokikh <maksim.nabokikh@flant.com> * Change folderUid in logs to folderUID Signed-off-by: m.nabokikh <maksim.nabokikh@flant.com> * Restrict write access for readers, which are provisioning duplicate dashboards Signed-off-by: m.nabokikh <maksim.nabokikh@flant.com> * Fix file reader after rebasing onto master Signed-off-by: m.nabokikh <maksim.nabokikh@flant.com> * Apply suggestions from code review Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com> * Format file_reader Signed-off-by: m.nabokikh <maksim.nabokikh@flant.com> * Apply suggestions from code review Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com> * Apply suggestions from code review Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com> * Fix lint problem Signed-off-by: m.nabokikh <maksim.nabokikh@flant.com> * Apply suggestions from code review Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com> Signed-off-by: m.nabokikh <maksim.nabokikh@flant.com> Co-authored-by: Emil Tullstedt <emil.tullstedt@grafana.com> Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com> Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>
This commit is contained in:
@@ -27,9 +27,10 @@ type DashboardProvisionerFactory func(string, dashboards.Store) (DashboardProvis
|
||||
|
||||
// Provisioner is responsible for syncing dashboard from disk to Grafana's database.
|
||||
type Provisioner struct {
|
||||
log log.Logger
|
||||
fileReaders []*FileReader
|
||||
configs []*config
|
||||
log log.Logger
|
||||
fileReaders []*FileReader
|
||||
configs []*config
|
||||
duplicateValidator duplicateValidator
|
||||
}
|
||||
|
||||
// New returns a new DashboardProvisioner
|
||||
@@ -47,9 +48,10 @@ func New(configDirectory string, store dashboards.Store) (DashboardProvisioner,
|
||||
}
|
||||
|
||||
d := &Provisioner{
|
||||
log: logger,
|
||||
fileReaders: fileReaders,
|
||||
configs: configs,
|
||||
log: logger,
|
||||
fileReaders: fileReaders,
|
||||
configs: configs,
|
||||
duplicateValidator: newDuplicateValidator(logger, fileReaders),
|
||||
}
|
||||
|
||||
return d, nil
|
||||
@@ -70,6 +72,7 @@ func (provider *Provisioner) Provision() error {
|
||||
}
|
||||
}
|
||||
|
||||
provider.duplicateValidator.validate()
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -92,6 +95,8 @@ func (provider *Provisioner) PollChanges(ctx context.Context) {
|
||||
for _, reader := range provider.fileReaders {
|
||||
go reader.pollChanges(ctx)
|
||||
}
|
||||
|
||||
go provider.duplicateValidator.Run(ctx)
|
||||
}
|
||||
|
||||
// GetProvisionerResolvedPath returns resolved path for the specified provisioner name. Can be used to generate
|
||||
|
||||
Reference in New Issue
Block a user