Provisioning: Complete rename of jobs (#102979)

Fixes: https://github.com/grafana/git-ui-sync-project/issues/164
pull/102010/head
Mariell Hoversholm 2 months ago committed by GitHub
parent 57cc4f101d
commit 69803300f1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 12
      pkg/apis/provisioning/v0alpha1/jobs.go
  2. 2
      pkg/apis/provisioning/v0alpha1/zz_generated.openapi.go
  3. 2
      pkg/registry/apis/provisioning/controller/repository.go
  4. 2
      pkg/registry/apis/provisioning/export.go
  5. 2
      pkg/registry/apis/provisioning/jobs/export/worker.go
  6. 2
      pkg/registry/apis/provisioning/jobs/persistentstore.go
  7. 2
      pkg/registry/apis/provisioning/jobs/sync/worker.go
  8. 2
      pkg/registry/apis/provisioning/repository/github.go
  9. 4
      pkg/registry/apis/provisioning/repository/github_test.go
  10. 2
      pkg/registry/apis/provisioning/sync.go
  11. 2
      pkg/tests/apis/openapi_snapshots/provisioning.grafana.app-v0alpha1.json
  12. 8
      public/app/api/clients/provisioning/endpoints.gen.ts

@ -46,16 +46,16 @@ type HistoricJobList struct {
type JobAction string type JobAction string
const ( const (
// Sync the remote branch with the grafana instance // JobActionPull replicates the remote branch in the local copy of the repository.
JobActionSync JobAction = "pull" JobActionPull JobAction = "pull"
// Export from grafana into the remote repository // JobActionPush replicates the local copy of the repository in the remote branch.
JobActionExport JobAction = "push" JobActionPush JobAction = "push"
// Process a pull request -- apply comments with preview images, links etc // JobActionPullRequest adds additional useful information to a PR, such as comments with preview links and rendered images.
JobActionPullRequest JobAction = "pr" JobActionPullRequest JobAction = "pr"
// Migration task -- this will migrate an full instance from SQL > Git // JobActionMigrate acts like JobActionExport, then JobActionPull. It also tries to preserve the history.
JobActionMigrate JobAction = "migrate" JobActionMigrate JobAction = "migrate"
) )

@ -724,7 +724,7 @@ func schema_pkg_apis_provisioning_v0alpha1_JobSpec(ref common.ReferenceCallback)
Properties: map[string]spec.Schema{ Properties: map[string]spec.Schema{
"action": { "action": {
SchemaProps: spec.SchemaProps{ SchemaProps: spec.SchemaProps{
Description: "Possible enum values:\n - `\"migrate\"` Migration task -- this will migrate an full instance from SQL > Git\n - `\"pr\"` Process a pull request -- apply comments with preview images, links etc\n - `\"pull\"` Sync the remote branch with the grafana instance\n - `\"push\"` Export from grafana into the remote repository", Description: "Possible enum values:\n - `\"migrate\"` acts like JobActionExport, then JobActionPull. It also tries to preserve the history.\n - `\"pr\"` adds additional useful information to a PR, such as comments with preview links and rendered images.\n - `\"pull\"` replicates the remote branch in the local copy of the repository.\n - `\"push\"` replicates the local copy of the repository in the remote branch.",
Default: "", Default: "",
Type: []string{"string"}, Type: []string{"string"},
Format: "", Format: "",

@ -367,7 +367,7 @@ func (rc *RepositoryController) addSyncJob(ctx context.Context, obj *provisionin
}, },
Spec: provisioning.JobSpec{ Spec: provisioning.JobSpec{
Repository: obj.GetName(), Repository: obj.GetName(),
Action: provisioning.JobActionSync, Action: provisioning.JobActionPull,
Pull: syncOptions, Pull: syncOptions,
}, },
}) })

@ -63,7 +63,7 @@ func (c *exportConnector) Connect(ctx context.Context, name string, opts runtime
Namespace: cfg.Namespace, Namespace: cfg.Namespace,
}, },
Spec: provisioning.JobSpec{ Spec: provisioning.JobSpec{
Action: provisioning.JobActionExport, Action: provisioning.JobActionPush,
Repository: cfg.Name, Repository: cfg.Name,
Push: options, Push: options,
}, },

@ -45,7 +45,7 @@ func NewExportWorker(clientFactory *resources.ClientFactory,
} }
func (r *ExportWorker) IsSupported(ctx context.Context, job provisioning.Job) bool { func (r *ExportWorker) IsSupported(ctx context.Context, job provisioning.Job) bool {
return job.Spec.Action == provisioning.JobActionExport return job.Spec.Action == provisioning.JobActionPush
} }
// Process will start a job // Process will start a job

@ -408,7 +408,7 @@ func (s *persistentStore) InsertNotifications() chan struct{} {
// generateJobName creates and updates the job's name to one that fits it. // generateJobName creates and updates the job's name to one that fits it.
func (s *persistentStore) generateJobName(job *provisioning.Job) { func (s *persistentStore) generateJobName(job *provisioning.Job) {
switch job.Spec.Action { switch job.Spec.Action {
case provisioning.JobActionMigrate, provisioning.JobActionSync: case provisioning.JobActionMigrate, provisioning.JobActionPull:
// Sync and migrate jobs should never run at the same time. Hence, the name encapsulates them both (and the spec differentiates them). // Sync and migrate jobs should never run at the same time. Hence, the name encapsulates them both (and the spec differentiates them).
job.Name = job.Spec.Repository + "-syncmigrate" job.Name = job.Spec.Repository + "-syncmigrate"
case provisioning.JobActionPullRequest: case provisioning.JobActionPullRequest:

@ -53,7 +53,7 @@ func NewSyncWorker(
} }
func (r *SyncWorker) IsSupported(ctx context.Context, job provisioning.Job) bool { func (r *SyncWorker) IsSupported(ctx context.Context, job provisioning.Job) bool {
return job.Spec.Action == provisioning.JobActionSync return job.Spec.Action == provisioning.JobActionPull
} }
func (r *SyncWorker) Process(ctx context.Context, repo repository.Repository, job provisioning.Job, progress jobs.JobProgressRecorder) error { func (r *SyncWorker) Process(ctx context.Context, repo repository.Repository, job provisioning.Job, progress jobs.JobProgressRecorder) error {

@ -580,7 +580,7 @@ func (r *githubRepository) parsePushEvent(event *github.PushEvent) (*provisionin
Code: http.StatusAccepted, Code: http.StatusAccepted,
Job: &provisioning.JobSpec{ Job: &provisioning.JobSpec{
Repository: r.Config().GetName(), Repository: r.Config().GetName(),
Action: provisioning.JobActionSync, Action: provisioning.JobActionPull,
Pull: &provisioning.SyncJobOptions{ Pull: &provisioning.SyncJobOptions{
Incremental: true, Incremental: true,
}, },

@ -83,7 +83,7 @@ func TestParseWebhooks(t *testing.T) {
Code: http.StatusAccepted, Code: http.StatusAccepted,
Job: &provisioning.JobSpec{ // we want to always push a sync job Job: &provisioning.JobSpec{ // we want to always push a sync job
Repository: "unit-test-repo", Repository: "unit-test-repo",
Action: provisioning.JobActionSync, Action: provisioning.JobActionPull,
Pull: &provisioning.SyncJobOptions{ Pull: &provisioning.SyncJobOptions{
Incremental: true, Incremental: true,
}, },
@ -93,7 +93,7 @@ func TestParseWebhooks(t *testing.T) {
Code: http.StatusAccepted, Code: http.StatusAccepted,
Job: &provisioning.JobSpec{ Job: &provisioning.JobSpec{
Repository: "unit-test-repo", Repository: "unit-test-repo",
Action: provisioning.JobActionSync, Action: provisioning.JobActionPull,
Pull: &provisioning.SyncJobOptions{ Pull: &provisioning.SyncJobOptions{
Incremental: true, Incremental: true,
}, },

@ -67,7 +67,7 @@ func (c *syncConnector) Connect(
Namespace: cfg.Namespace, Namespace: cfg.Namespace,
}, },
Spec: provisioning.JobSpec{ Spec: provisioning.JobSpec{
Action: provisioning.JobActionSync, Action: provisioning.JobActionPull,
Repository: cfg.Name, Repository: cfg.Name,
Pull: &options, Pull: &options,
}, },

@ -3206,7 +3206,7 @@
], ],
"properties": { "properties": {
"action": { "action": {
"description": "Possible enum values:\n - `\"migrate\"` Migration task -- this will migrate an full instance from SQL \u003e Git\n - `\"pr\"` Process a pull request -- apply comments with preview images, links etc\n - `\"pull\"` Sync the remote branch with the grafana instance\n - `\"push\"` Export from grafana into the remote repository", "description": "Possible enum values:\n - `\"migrate\"` acts like JobActionExport, then JobActionPull. It also tries to preserve the history.\n - `\"pr\"` adds additional useful information to a PR, such as comments with preview links and rendered images.\n - `\"pull\"` replicates the remote branch in the local copy of the repository.\n - `\"push\"` replicates the local copy of the repository in the remote branch.",
"type": "string", "type": "string",
"default": "", "default": "",
"enum": [ "enum": [

@ -852,10 +852,10 @@ export type ExportJobOptions = {
}; };
export type JobSpec = { export type JobSpec = {
/** Possible enum values: /** Possible enum values:
- `"migrate"` Migration task -- this will migrate an full instance from SQL > Git - `"migrate"` acts like JobActionExport, then JobActionPull. It also tries to preserve the history.
- `"pr"` Process a pull request -- apply comments with preview images, links etc - `"pr"` adds additional useful information to a PR, such as comments with preview links and rendered images.
- `"pull"` Sync the remote branch with the grafana instance - `"pull"` replicates the remote branch in the local copy of the repository.
- `"push"` Export from grafana into the remote repository */ - `"push"` replicates the local copy of the repository in the remote branch. */
action: 'migrate' | 'pr' | 'pull' | 'push'; action: 'migrate' | 'pr' | 'pull' | 'push';
/** Required when the action is `migrate` */ /** Required when the action is `migrate` */
migrate?: MigrateJobOptions; migrate?: MigrateJobOptions;

Loading…
Cancel
Save