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
const (
// Sync the remote branch with the grafana instance
JobActionSync JobAction = "pull"
// JobActionPull replicates the remote branch in the local copy of the repository.
JobActionPull JobAction = "pull"
// Export from grafana into the remote repository
JobActionExport JobAction = "push"
// JobActionPush replicates the local copy of the repository in the remote branch.
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"
// 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"
)

@ -724,7 +724,7 @@ func schema_pkg_apis_provisioning_v0alpha1_JobSpec(ref common.ReferenceCallback)
Properties: map[string]spec.Schema{
"action": {
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: "",
Type: []string{"string"},
Format: "",

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

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

@ -45,7 +45,7 @@ func NewExportWorker(clientFactory *resources.ClientFactory,
}
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

@ -408,7 +408,7 @@ func (s *persistentStore) InsertNotifications() chan struct{} {
// generateJobName creates and updates the job's name to one that fits it.
func (s *persistentStore) generateJobName(job *provisioning.Job) {
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).
job.Name = job.Spec.Repository + "-syncmigrate"
case provisioning.JobActionPullRequest:

@ -53,7 +53,7 @@ func NewSyncWorker(
}
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 {

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

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

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

@ -3206,7 +3206,7 @@
],
"properties": {
"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",
"default": "",
"enum": [

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

Loading…
Cancel
Save