mirror of https://github.com/grafana/grafana
Chore: Split usagestats service (#65191)
parent
9ba38b760a
commit
10adb1ff66
@ -0,0 +1,12 @@ |
||||
package validator |
||||
|
||||
import ( |
||||
"context" |
||||
"strings" |
||||
) |
||||
|
||||
type FakeUsageStatsValidator struct{} |
||||
|
||||
func (uss *FakeUsageStatsValidator) ShouldBeReported(ctx context.Context, s string) bool { |
||||
return !strings.HasPrefix(s, "unknown") |
||||
} |
@ -0,0 +1,28 @@ |
||||
package validator |
||||
|
||||
import ( |
||||
"context" |
||||
|
||||
"github.com/grafana/grafana/pkg/plugins" |
||||
) |
||||
|
||||
type UsageStatsValidator struct { |
||||
pluginStore plugins.Store |
||||
} |
||||
|
||||
func ProvideService(pluginStore plugins.Store) (Service, error) { |
||||
s := &UsageStatsValidator{ |
||||
pluginStore: pluginStore, |
||||
} |
||||
|
||||
return s, nil |
||||
} |
||||
|
||||
func (uss *UsageStatsValidator) ShouldBeReported(ctx context.Context, dsType string) bool { |
||||
ds, exists := uss.pluginStore.Plugin(ctx, dsType) |
||||
if !exists { |
||||
return false |
||||
} |
||||
|
||||
return ds.Signature.IsValid() || ds.Signature.IsInternal() |
||||
} |
@ -0,0 +1,7 @@ |
||||
package validator |
||||
|
||||
import "context" |
||||
|
||||
type Service interface { |
||||
ShouldBeReported(context.Context, string) bool |
||||
} |
Loading…
Reference in new issue