Codegen: Remove pfs codegen dependency from Grafana codebase (#98840)
* Remove pfs dependency for IAM struct to avoid to import codegen code in main go.mod * Remove pointer * Remove dependency cycle * Update tests
This commit is contained in:
@@ -2,8 +2,6 @@ package auth
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/grafana/grafana/pkg/plugins/codegen/pfs"
|
||||
)
|
||||
|
||||
type ExternalService struct {
|
||||
@@ -12,8 +10,17 @@ type ExternalService struct {
|
||||
PrivateKey string `json:"privateKey"`
|
||||
}
|
||||
|
||||
type IAM struct {
|
||||
Permissions []Permission `json:"permissions,omitempty"`
|
||||
}
|
||||
|
||||
type Permission struct {
|
||||
Action string `json:"action"`
|
||||
Scope string `json:"scope"`
|
||||
}
|
||||
|
||||
type ExternalServiceRegistry interface {
|
||||
HasExternalService(ctx context.Context, pluginID string) (bool, error)
|
||||
RegisterExternalService(ctx context.Context, pluginID string, pType pfs.Type, svc *pfs.IAM) (*ExternalService, error)
|
||||
RegisterExternalService(ctx context.Context, pluginID string, pType string, svc *IAM) (*ExternalService, error)
|
||||
RemoveExternalService(ctx context.Context, pluginID string) error
|
||||
}
|
||||
|
||||
@@ -1,38 +1,17 @@
|
||||
package pfs
|
||||
|
||||
type Type string
|
||||
|
||||
// Defines values for Type.
|
||||
const (
|
||||
TypeApp Type = "app"
|
||||
TypeDatasource Type = "datasource"
|
||||
TypePanel Type = "panel"
|
||||
TypeRenderer Type = "renderer"
|
||||
TypeSecretsmanager Type = "secretsmanager"
|
||||
)
|
||||
|
||||
type PluginDef struct {
|
||||
Id string
|
||||
Name string
|
||||
Backend *bool
|
||||
Type Type
|
||||
Type string
|
||||
Info Info
|
||||
IAM IAM
|
||||
}
|
||||
|
||||
type Info struct {
|
||||
Version *string
|
||||
}
|
||||
|
||||
type IAM struct {
|
||||
Permissions []Permission `json:"permissions,omitempty"`
|
||||
}
|
||||
|
||||
type Permission struct {
|
||||
Action string `json:"action"`
|
||||
Scope *string `json:"scope,omitempty"`
|
||||
}
|
||||
|
||||
func (pd PluginDef) Validate() error {
|
||||
if pd.Id == "" || pd.Name == "" || pd.Type == "" {
|
||||
return ErrInvalidRootFile
|
||||
|
||||
@@ -14,7 +14,6 @@ import (
|
||||
"github.com/grafana/grafana/pkg/plugins"
|
||||
"github.com/grafana/grafana/pkg/plugins/auth"
|
||||
"github.com/grafana/grafana/pkg/plugins/backendplugin"
|
||||
"github.com/grafana/grafana/pkg/plugins/codegen/pfs"
|
||||
"github.com/grafana/grafana/pkg/plugins/log"
|
||||
"github.com/grafana/grafana/pkg/plugins/repo"
|
||||
"github.com/grafana/grafana/pkg/plugins/storage"
|
||||
@@ -517,7 +516,7 @@ func (f *FakeAuthService) HasExternalService(ctx context.Context, pluginID strin
|
||||
return f.Result != nil, nil
|
||||
}
|
||||
|
||||
func (f *FakeAuthService) RegisterExternalService(ctx context.Context, pluginID string, pType pfs.Type, svc *pfs.IAM) (*auth.ExternalService, error) {
|
||||
func (f *FakeAuthService) RegisterExternalService(ctx context.Context, pluginID string, pType string, svc *auth.IAM) (*auth.ExternalService, error) {
|
||||
return f.Result, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@ import (
|
||||
"github.com/grafana/grafana/pkg/plugins/backendplugin"
|
||||
"github.com/grafana/grafana/pkg/plugins/backendplugin/pluginextensionv2"
|
||||
"github.com/grafana/grafana/pkg/plugins/backendplugin/secretsmanagerplugin"
|
||||
"github.com/grafana/grafana/pkg/plugins/codegen/pfs"
|
||||
"github.com/grafana/grafana/pkg/plugins/log"
|
||||
"github.com/grafana/grafana/pkg/services/org"
|
||||
"github.com/grafana/grafana/pkg/util"
|
||||
@@ -131,7 +130,7 @@ type JSONData struct {
|
||||
Executable string `json:"executable,omitempty"`
|
||||
|
||||
// App Service Auth Registration
|
||||
IAM *pfs.IAM `json:"iam,omitempty"`
|
||||
IAM *auth.IAM `json:"iam,omitempty"`
|
||||
}
|
||||
|
||||
func ReadPluginJSON(reader io.Reader) (JSONData, error) {
|
||||
|
||||
Reference in New Issue
Block a user