Provisioning: Move repository package to provisioning app (#110228)
* Move repository package to apps
* Move operators to grafana/grafana
* Go mod tidy
* Own package by git sync team for now
* Merged
* Do not use settings in local extra
* Remove dependency on webhook extra
* Hack to work around issue with secure contracts
* Sync Go modules
* Revert "Move operators to grafana/grafana"
This reverts commit 9f19b30a2e.
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
package git
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
provisioning "github.com/grafana/grafana/apps/provisioning/pkg/apis/provisioning/v0alpha1"
|
||||
"github.com/grafana/grafana/apps/provisioning/pkg/repository"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
||||
type extra struct {
|
||||
decrypter repository.Decrypter
|
||||
}
|
||||
|
||||
func Extra(decrypter repository.Decrypter) repository.Extra {
|
||||
return &extra{
|
||||
decrypter: decrypter,
|
||||
}
|
||||
}
|
||||
|
||||
func (e *extra) Type() provisioning.RepositoryType {
|
||||
return provisioning.GitRepositoryType
|
||||
}
|
||||
|
||||
func (e *extra) Build(ctx context.Context, r *provisioning.Repository) (repository.Repository, error) {
|
||||
secure := e.decrypter(r)
|
||||
cfg := r.Spec.Git
|
||||
if cfg == nil {
|
||||
return nil, fmt.Errorf("git configuration is required")
|
||||
}
|
||||
|
||||
token, err := secure.Token(ctx)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("unable to decrypt token: %w", err)
|
||||
}
|
||||
|
||||
return NewRepository(ctx, r, RepositoryConfig{
|
||||
URL: cfg.URL,
|
||||
Branch: cfg.Branch,
|
||||
Path: cfg.Path,
|
||||
TokenUser: cfg.TokenUser,
|
||||
Token: token,
|
||||
})
|
||||
}
|
||||
|
||||
func (e *extra) Mutate(ctx context.Context, obj runtime.Object) error {
|
||||
return Mutate(ctx, obj)
|
||||
}
|
||||
Reference in New Issue
Block a user