[Provisioning] Move Pull Request into its own package (#100270)
* Move pull request to separate package * Fix linting
This commit is contained in:
1 parent
3943b8a2c3
commit
26d3b125cc
2 files changed
+8
-7
No files matched your search
+4
-4
@@ -1,4 +1,4 @@
|
||||
package jobs
|
||||
package pullrequest
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
@@ -17,7 +17,7 @@ import (
|
||||
)
|
||||
|
||||
type PullRequestWorker interface {
|
||||
ProcessPullRequest(ctx context.Context,
|
||||
Process(ctx context.Context,
|
||||
repo repository.Repository,
|
||||
options provisioning.PullRequestJobOptions,
|
||||
progress func(provisioning.JobStatus) error,
|
||||
@@ -83,7 +83,7 @@ type pullRequestCommenter struct {
|
||||
renderer PreviewRenderer
|
||||
}
|
||||
|
||||
func NewPullRequestCommenter(
|
||||
func NewPullRequestWorker(
|
||||
repo PullRequestRepo,
|
||||
parser *resources.Parser,
|
||||
renderer PreviewRenderer,
|
||||
@@ -108,7 +108,7 @@ func NewPullRequestCommenter(
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (c *pullRequestCommenter) ProcessPullRequest(ctx context.Context,
|
||||
func (c *pullRequestCommenter) Process(ctx context.Context,
|
||||
repo repository.Repository,
|
||||
options provisioning.PullRequestJobOptions,
|
||||
progress func(provisioning.JobStatus) error,
|
||||
@@ -13,6 +13,7 @@ import (
|
||||
provisioning "github.com/grafana/grafana/pkg/apis/provisioning/v0alpha1"
|
||||
"github.com/grafana/grafana/pkg/registry/apis/provisioning/auth"
|
||||
"github.com/grafana/grafana/pkg/registry/apis/provisioning/jobs/export"
|
||||
"github.com/grafana/grafana/pkg/registry/apis/provisioning/jobs/pullrequest"
|
||||
"github.com/grafana/grafana/pkg/registry/apis/provisioning/repository"
|
||||
"github.com/grafana/grafana/pkg/registry/apis/provisioning/resources"
|
||||
"github.com/grafana/grafana/pkg/services/rendering"
|
||||
@@ -98,7 +99,7 @@ func (g *JobWorker) Process(ctx context.Context, job provisioning.Job, progress
|
||||
case provisioning.JobActionSync:
|
||||
return g.syncWorker.Process(ctx, repo, job, progress)
|
||||
case provisioning.JobActionPullRequest:
|
||||
prRepo, ok := repo.(PullRequestRepo)
|
||||
prRepo, ok := repo.(pullrequest.PullRequestRepo)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("repository is not a github repository")
|
||||
}
|
||||
@@ -121,11 +122,11 @@ func (g *JobWorker) Process(ctx context.Context, job provisioning.Job, progress
|
||||
return nil, apierrors.NewBadRequest("missing spec.pr")
|
||||
}
|
||||
|
||||
commenter, err := NewPullRequestCommenter(prRepo, parser, renderer, baseURL)
|
||||
commenter, err := pullrequest.NewPullRequestWorker(prRepo, parser, renderer, baseURL)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error creating pull request commenter: %w", err)
|
||||
}
|
||||
return commenter.ProcessPullRequest(ctx, repo, *options, progress)
|
||||
return commenter.Process(ctx, repo, *options, progress)
|
||||
|
||||
case provisioning.JobActionExport:
|
||||
if job.Spec.Export == nil {
|
||||
|
||||
Reference in new issue
Block a user