Provisioning: Manage repo jobs as single sub-resource (#103090)

This commit is contained in:
Ryan McKinley
2025-04-01 13:22:47 +03:00
committed by GitHub
parent 1ead18d856
commit ca35a89916
25 changed files with 691 additions and 1177 deletions
@@ -36,232 +36,6 @@
}
}
},
"/apis/provisioning.grafana.app/v0alpha1/namespaces/{namespace}/historicjobs": {
"get": {
"tags": [
"HistoricJob"
],
"description": "list or watch objects of kind HistoricJob",
"operationId": "listHistoricJob",
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1.HistoricJobList"
}
},
"application/json;stream=watch": {
"schema": {
"$ref": "#/components/schemas/com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1.HistoricJobList"
}
},
"application/vnd.kubernetes.protobuf": {
"schema": {
"$ref": "#/components/schemas/com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1.HistoricJobList"
}
},
"application/vnd.kubernetes.protobuf;stream=watch": {
"schema": {
"$ref": "#/components/schemas/com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1.HistoricJobList"
}
},
"application/yaml": {
"schema": {
"$ref": "#/components/schemas/com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1.HistoricJobList"
}
}
}
}
},
"x-kubernetes-action": "list",
"x-kubernetes-group-version-kind": {
"group": "provisioning.grafana.app",
"version": "v0alpha1",
"kind": "HistoricJob"
}
},
"parameters": [
{
"name": "allowWatchBookmarks",
"in": "query",
"description": "allowWatchBookmarks requests watch events with type \"BOOKMARK\". Servers that do not implement bookmarks may ignore this flag and bookmarks are sent at the server's discretion. Clients should not assume bookmarks are returned at any specific interval, nor may they assume the server will send any BOOKMARK event during a session. If this is not a watch, this field is ignored.",
"schema": {
"type": "boolean",
"uniqueItems": true
}
},
{
"name": "continue",
"in": "query",
"description": "The continue option should be set when retrieving more results from the server. Since this value is server defined, clients may only use the continue value from a previous query result with identical query parameters (except for the value of continue) and the server may reject a continue value it does not recognize. If the specified continue value is no longer valid whether due to expiration (generally five to fifteen minutes) or a configuration change on the server, the server will respond with a 410 ResourceExpired error together with a continue token. If the client needs a consistent list, it must restart their list without the continue field. Otherwise, the client may send another list request with the token received with the 410 error, the server will respond with a list starting from the next key, but from the latest snapshot, which is inconsistent from the previous list results - objects that are created, modified, or deleted after the first list request will be included in the response, as long as their keys are after the \"next key\".\n\nThis field is not supported when watch is true. Clients may start a watch from the last resourceVersion value returned by the server and not miss any modifications.",
"schema": {
"type": "string",
"uniqueItems": true
}
},
{
"name": "fieldSelector",
"in": "query",
"description": "A selector to restrict the list of returned objects by their fields. Defaults to everything.",
"schema": {
"type": "string",
"uniqueItems": true
}
},
{
"name": "labelSelector",
"in": "query",
"description": "A selector to restrict the list of returned objects by their labels. Defaults to everything.",
"schema": {
"type": "string",
"uniqueItems": true
}
},
{
"name": "limit",
"in": "query",
"description": "limit is a maximum number of responses to return for a list call. If more items exist, the server will set the `continue` field on the list metadata to a value that can be used with the same initial query to retrieve the next set of results. Setting a limit may return fewer than the requested amount of items (up to zero items) in the event all requested objects are filtered out and clients should only use the presence of the continue field to determine whether more results are available. Servers may choose not to support the limit argument and will return all of the available results. If limit is specified and the continue field is empty, clients may assume that no more results are available. This field is not supported if watch is true.\n\nThe server guarantees that the objects returned when using continue will be identical to issuing a single list call without a limit - that is, no objects created, modified, or deleted after the first request is issued will be included in any subsequent continued requests. This is sometimes referred to as a consistent snapshot, and ensures that a client that is using limit to receive smaller chunks of a very large result can ensure they see all possible objects. If objects are updated during a chunked list the version of the object that was present at the time the first list result was calculated is returned.",
"schema": {
"type": "integer",
"uniqueItems": true
}
},
{
"name": "namespace",
"in": "path",
"description": "object name and auth scope, such as for teams and projects",
"required": true,
"schema": {
"type": "string",
"uniqueItems": true
}
},
{
"name": "pretty",
"in": "query",
"description": "If 'true', then the output is pretty printed. Defaults to 'false' unless the user-agent indicates a browser or command-line HTTP tool (curl and wget).",
"schema": {
"type": "string",
"uniqueItems": true
}
},
{
"name": "resourceVersion",
"in": "query",
"description": "resourceVersion sets a constraint on what resource versions a request may be served from. See https://kubernetes.io/docs/reference/using-api/api-concepts/#resource-versions for details.\n\nDefaults to unset",
"schema": {
"type": "string",
"uniqueItems": true
}
},
{
"name": "resourceVersionMatch",
"in": "query",
"description": "resourceVersionMatch determines how resourceVersion is applied to list calls. It is highly recommended that resourceVersionMatch be set for list calls where resourceVersion is set See https://kubernetes.io/docs/reference/using-api/api-concepts/#resource-versions for details.\n\nDefaults to unset",
"schema": {
"type": "string",
"uniqueItems": true
}
},
{
"name": "sendInitialEvents",
"in": "query",
"description": "`sendInitialEvents=true` may be set together with `watch=true`. In that case, the watch stream will begin with synthetic events to produce the current state of objects in the collection. Once all such events have been sent, a synthetic \"Bookmark\" event will be sent. The bookmark will report the ResourceVersion (RV) corresponding to the set of objects, and be marked with `\"k8s.io/initial-events-end\": \"true\"` annotation. Afterwards, the watch stream will proceed as usual, sending watch events corresponding to changes (subsequent to the RV) to objects watched.\n\nWhen `sendInitialEvents` option is set, we require `resourceVersionMatch` option to also be set. The semantic of the watch request is as following: - `resourceVersionMatch` = NotOlderThan\n is interpreted as \"data at least as new as the provided `resourceVersion`\"\n and the bookmark event is send when the state is synced\n to a `resourceVersion` at least as fresh as the one provided by the ListOptions.\n If `resourceVersion` is unset, this is interpreted as \"consistent read\" and the\n bookmark event is send when the state is synced at least to the moment\n when request started being processed.\n- `resourceVersionMatch` set to any other value or unset\n Invalid error is returned.\n\nDefaults to true if `resourceVersion=\"\"` or `resourceVersion=\"0\"` (for backward compatibility reasons) and to false otherwise.",
"schema": {
"type": "boolean",
"uniqueItems": true
}
},
{
"name": "timeoutSeconds",
"in": "query",
"description": "Timeout for the list/watch call. This limits the duration of the call, regardless of any activity or inactivity.",
"schema": {
"type": "integer",
"uniqueItems": true
}
},
{
"name": "watch",
"in": "query",
"description": "Watch for changes to the described resources and return them as a stream of add, update, and remove notifications. Specify resourceVersion.",
"schema": {
"type": "boolean",
"uniqueItems": true
}
}
]
},
"/apis/provisioning.grafana.app/v0alpha1/namespaces/{namespace}/historicjobs/{name}": {
"get": {
"tags": [
"HistoricJob"
],
"description": "read the specified HistoricJob",
"operationId": "getHistoricJob",
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1.HistoricJob"
}
},
"application/vnd.kubernetes.protobuf": {
"schema": {
"$ref": "#/components/schemas/com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1.HistoricJob"
}
},
"application/yaml": {
"schema": {
"$ref": "#/components/schemas/com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1.HistoricJob"
}
}
}
}
},
"x-kubernetes-action": "get",
"x-kubernetes-group-version-kind": {
"group": "provisioning.grafana.app",
"version": "v0alpha1",
"kind": "HistoricJob"
}
},
"parameters": [
{
"name": "name",
"in": "path",
"description": "name of the HistoricJob",
"required": true,
"schema": {
"type": "string",
"uniqueItems": true
}
},
{
"name": "namespace",
"in": "path",
"description": "object name and auth scope, such as for teams and projects",
"required": true,
"schema": {
"type": "string",
"uniqueItems": true
}
},
{
"name": "pretty",
"in": "query",
"description": "If 'true', then the output is pretty printed. Defaults to 'false' unless the user-agent indicates a browser or command-line HTTP tool (curl and wget).",
"schema": {
"type": "string",
"uniqueItems": true
}
}
]
},
"/apis/provisioning.grafana.app/v0alpha1/namespaces/{namespace}/jobs": {
"get": {
"tags": [
@@ -1318,92 +1092,6 @@
}
]
},
"/apis/provisioning.grafana.app/v0alpha1/namespaces/{namespace}/repositories/{name}/export": {
"post": {
"tags": [
"Repository"
],
"description": "Export from grafana into the remote repository",
"operationId": "createRepositoryExport",
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"identifier"
],
"properties": {
"branch": {
"description": "Target branch for export (only git)",
"type": "string"
},
"folder": {
"description": "The source folder (or empty) to export",
"type": "string"
},
"identifier": {
"description": "Include the identifier in the exported metadata",
"type": "boolean",
"default": false
},
"path": {
"description": "Prefix in target file system",
"type": "string"
}
}
},
"example": {
"folder": "grafan-folder-ref",
"branch": "target-branch",
"path": "path/in/tree",
"identifier": false
}
}
}
},
"responses": {
"200": {
"description": "OK",
"content": {
"*/*": {
"schema": {
"$ref": "#/components/schemas/com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1.Job"
}
}
}
}
},
"x-kubernetes-action": "connect",
"x-kubernetes-group-version-kind": {
"group": "provisioning.grafana.app",
"version": "v0alpha1",
"kind": "Job"
}
},
"parameters": [
{
"name": "name",
"in": "path",
"description": "name of the Job",
"required": true,
"schema": {
"type": "string",
"uniqueItems": true
}
},
{
"name": "namespace",
"in": "path",
"description": "object name and auth scope, such as for teams and projects",
"required": true,
"schema": {
"type": "string",
"uniqueItems": true
}
}
]
},
"/apis/provisioning.grafana.app/v0alpha1/namespaces/{namespace}/repositories/{name}/files/": {
"get": {
"tags": [
@@ -1982,36 +1670,63 @@
}
]
},
"/apis/provisioning.grafana.app/v0alpha1/namespaces/{namespace}/repositories/{name}/migrate": {
"/apis/provisioning.grafana.app/v0alpha1/namespaces/{namespace}/repositories/{name}/jobs": {
"get": {
"tags": [
"Repository"
],
"description": "List recent jobs",
"operationId": "getRepositoryJobs",
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1.JobList"
}
}
}
}
},
"x-kubernetes-action": "connect",
"x-kubernetes-group-version-kind": {
"group": "provisioning.grafana.app",
"version": "v0alpha1",
"kind": "Repository"
}
},
"post": {
"tags": [
"Repository"
],
"description": "Export from grafana into the remote repository",
"operationId": "createRepositoryMigrate",
"description": "Register a job for this repository",
"operationId": "createRepositoryJobs",
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"identifier"
],
"properties": {
"history": {
"description": "Preserve history (if possible)",
"type": "boolean"
},
"identifier": {
"description": "Include the identifier in the exported metadata",
"type": "boolean",
"default": false
"$ref": "#/components/schemas/com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1.JobSpec"
},
"examples": {
"incremental": {
"summary": "Pull (incremental)",
"description": "look for changes since the last sync",
"value": {
"pull": {
"incremental": true
}
}
},
"pull": {
"summary": "Pull from repository",
"description": "pull all files",
"value": {
"pull": {
"incremental": false
}
}
}
},
"example": {
"history": true,
"identifier": false
}
}
}
@@ -2020,7 +1735,7 @@
"200": {
"description": "OK",
"content": {
"*/*": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1.Job"
}
@@ -2032,14 +1747,14 @@
"x-kubernetes-group-version-kind": {
"group": "provisioning.grafana.app",
"version": "v0alpha1",
"kind": "Job"
"kind": "Repository"
}
},
"parameters": [
{
"name": "name",
"in": "path",
"description": "name of the Job",
"description": "name of the Repository",
"required": true,
"schema": {
"type": "string",
@@ -2058,7 +1773,66 @@
}
]
},
"/apis/provisioning.grafana.app/v0alpha1/namespaces/{namespace}/repositories/{name}/render/{path}": {
"/apis/provisioning.grafana.app/v0alpha1/namespaces/{namespace}/repositories/{name}/jobs/{uid}": {
"get": {
"tags": [
"Repository"
],
"description": "Get job by UID",
"operationId": "getRepositoryJobsWithPath",
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1.Job"
}
}
}
}
},
"x-kubernetes-action": "connect",
"x-kubernetes-group-version-kind": {
"group": "provisioning.grafana.app",
"version": "v0alpha1",
"kind": "Repository"
}
},
"parameters": [
{
"name": "name",
"in": "path",
"description": "name of the Repository",
"required": true,
"schema": {
"type": "string",
"uniqueItems": true
}
},
{
"name": "namespace",
"in": "path",
"description": "object name and auth scope, such as for teams and projects",
"required": true,
"schema": {
"type": "string",
"uniqueItems": true
}
},
{
"name": "uid",
"in": "path",
"description": "Original Job UID",
"required": true,
"schema": {
"type": "string",
"uniqueItems": true
}
}
]
},
"/apis/provisioning.grafana.app/v0alpha1/namespaces/{namespace}/repositories/{name}/render/{guid}": {
"get": {
"tags": [
"Repository"
@@ -2102,9 +1876,9 @@
}
},
{
"name": "path",
"name": "guid",
"in": "path",
"description": "path to the resource",
"description": "Image GUID",
"required": true,
"schema": {
"type": "string",
@@ -2452,77 +2226,6 @@
}
]
},
"/apis/provisioning.grafana.app/v0alpha1/namespaces/{namespace}/repositories/{name}/sync": {
"post": {
"tags": [
"Repository"
],
"description": "Sync from repository into Grafana",
"operationId": "createRepositorySync",
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"incremental"
],
"properties": {
"incremental": {
"description": "Incremental synchronization for versioned repositories",
"type": "boolean",
"default": false
}
}
},
"example": {
"incremental": false
}
}
}
},
"responses": {
"200": {
"description": "OK",
"content": {
"*/*": {
"schema": {
"$ref": "#/components/schemas/com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1.Job"
}
}
}
}
},
"x-kubernetes-action": "connect",
"x-kubernetes-group-version-kind": {
"group": "provisioning.grafana.app",
"version": "v0alpha1",
"kind": "Job"
}
},
"parameters": [
{
"name": "name",
"in": "path",
"description": "name of the Job",
"required": true,
"schema": {
"type": "string",
"uniqueItems": true
}
},
{
"name": "namespace",
"in": "path",
"description": "object name and auth scope, such as for teams and projects",
"required": true,
"schema": {
"type": "string",
"uniqueItems": true
}
}
]
},
"/apis/provisioning.grafana.app/v0alpha1/namespaces/{namespace}/repositories/{name}/test": {
"post": {
"tags": [
@@ -2919,42 +2622,15 @@
"type": "string"
},
"metadata": {
"default": {},
"allOf": [
{
"$ref": "#/components/schemas/io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta"
}
]
"default": {}
},
"spec": {
"default": {},
"allOf": [
{
"$ref": "#/components/schemas/com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1.JobSpec"
}
]
"default": {}
},
"status": {
"default": {},
"allOf": [
{
"$ref": "#/components/schemas/com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1.JobStatus"
}
]
"default": {}
}
},
"x-kubernetes-group-version-kind": [
{
"group": "provisioning.grafana.app",
"kind": "HistoricJob",
"version": "__internal"
},
{
"group": "provisioning.grafana.app",
"kind": "HistoricJob",
"version": "v0alpha1"
}
]
}
},
"com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1.HistoricJobList": {
"type": "object",
@@ -2966,12 +2642,7 @@
"items": {
"type": "array",
"items": {
"default": {},
"allOf": [
{
"$ref": "#/components/schemas/com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1.HistoricJob"
}
]
"default": {}
}
},
"kind": {
@@ -2979,26 +2650,9 @@
"type": "string"
},
"metadata": {
"default": {},
"allOf": [
{
"$ref": "#/components/schemas/io.k8s.apimachinery.pkg.apis.meta.v1.ListMeta"
}
]
"default": {}
}
},
"x-kubernetes-group-version-kind": [
{
"group": "provisioning.grafana.app",
"kind": "HistoricJobList",
"version": "__internal"
},
{
"group": "provisioning.grafana.app",
"kind": "HistoricJobList",
"version": "v0alpha1"
}
]
}
},
"com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1.HistoryItem": {
"type": "object",
@@ -3200,15 +2854,10 @@
},
"com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1.JobSpec": {
"type": "object",
"required": [
"action",
"repository"
],
"properties": {
"action": {
"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": [
"migrate",
"pr",
@@ -3249,9 +2898,8 @@
]
},
"repository": {
"description": "The the repository reference (for now also in labels)",
"type": "string",
"default": ""
"description": "The the repository reference (for now also in labels) This value is required, but will be popuplated from the job making the request",
"type": "string"
}
}
},
+36 -34
View File
@@ -45,7 +45,6 @@ type provisioningTestHelper struct {
Repositories *apis.K8sResourceClient
Jobs *apis.K8sResourceClient
HistoricJobs *apis.K8sResourceClient
Folders *apis.K8sResourceClient
Dashboards *apis.K8sResourceClient
AdminREST *rest.RESTClient
@@ -55,17 +54,19 @@ type provisioningTestHelper struct {
func (h *provisioningTestHelper) SyncAndWait(t *testing.T, repo string, options *provisioning.SyncJobOptions) {
t.Helper()
var opts provisioning.SyncJobOptions
if options != nil {
opts = *options
if options == nil {
options = &provisioning.SyncJobOptions{}
}
body := asJSON(opts)
body := asJSON(&provisioning.JobSpec{
Action: provisioning.JobActionPull,
Pull: options,
})
result := h.AdminREST.Post().
Namespace("default").
Resource("repositories").
Name(repo).
SubResource("sync").
SubResource("jobs").
Body(body).
SetHeader("Content-Type", "application/json").
Do(t.Context())
@@ -84,30 +85,33 @@ func (h *provisioningTestHelper) SyncAndWait(t *testing.T, repo string, options
name := unstruct.GetName()
require.NotEmpty(t, name, "expecting name to be set")
h.AwaitJobSuccess(t, t.Context(), name)
h.AwaitJobSuccess(t, t.Context(), unstruct)
}
func (h *provisioningTestHelper) AwaitJobSuccess(t *testing.T, ctx context.Context, jobName string) {
func (h *provisioningTestHelper) AwaitJobSuccess(t *testing.T, ctx context.Context, job *unstructured.Unstructured) {
t.Helper()
if !assert.EventuallyWithT(t, func(collect *assert.CollectT) {
jobs, err := h.HistoricJobs.Resource.List(ctx, metav1.ListOptions{
LabelSelector: jobs.LabelJobOriginalName + "=" + jobName,
})
if assert.NoError(collect, err) && assert.NotEmpty(collect, jobs.Items, "no historic jobs found yet") {
for _, job := range jobs.Items {
state := mustNestedString(job.Object, "status", "state")
if state == "" {
// The job hasn't gotten its state yet. We do two requests: one to insert the job, one to set the status.
assert.Fail(collect, "job '%s' has no state yet", jobName)
}
// We can fail fast once the job is here: HistoricJobs are immutable.
require.Equal(t, string(provisioning.JobStateSuccess), state, "historic job '%s' was not successful", jobName)
}
repo := job.GetLabels()[jobs.LabelRepository]
require.NotEmpty(t, repo)
if !assert.EventuallyWithT(t, func(collect *assert.CollectT) {
result, err := h.Repositories.Resource.Get(ctx, repo, metav1.GetOptions{},
"jobs", string(job.GetUID()))
if apierrors.IsNotFound(err) {
assert.Fail(collect, "job '%s' not found yet yet", job.GetName())
return // continue trying
}
// Can fail fast here -- the jobs are immutable
require.NoError(t, err)
require.NotNil(t, result)
state := mustNestedString(result.Object, "status", "state")
require.Equal(t, string(provisioning.JobStateSuccess), state,
"historic job '%s' was not successful", job.GetName())
}, time.Second*5, time.Millisecond*20) {
// We also want to add the job details to the error when it fails.
job, err := h.Jobs.Resource.Get(ctx, jobName, metav1.GetOptions{})
job, err := h.Jobs.Resource.Get(ctx, job.GetName(), metav1.GetOptions{})
if err != nil {
t.Logf("failed to get job details for further help: %v", err)
} else {
@@ -135,14 +139,18 @@ func (h *provisioningTestHelper) AwaitJobs(t *testing.T, repoName string) {
}, time.Second*5, time.Millisecond*20)
// Then, as all jobs are now historic jobs, we make sure they are successful.
list, err := h.HistoricJobs.Resource.List(context.Background(), metav1.ListOptions{})
result, err := h.Repositories.Resource.Get(context.Background(), repoName, metav1.GetOptions{}, "jobs")
require.NoError(t, err, "failed to list historic jobs")
list, err := result.ToList()
require.NoError(t, err, "results should be a list")
require.NotEmpty(t, list.Items, "expect at least one job")
for _, elem := range list.Items {
// TODO: Use the spec field of the job.
if elem.GetLabels()["repository"] == repoName {
require.Equal(t, string(provisioning.JobStateSuccess), mustNestedString(elem.Object, "status", "state"), "job %s failed: %+v", elem.GetName(), elem.Object)
}
require.Equal(t, repoName, elem.GetLabels()[jobs.LabelRepository], "should have repo label")
state := mustNestedString(elem.Object, "status", "state")
require.Equal(t, string(provisioning.JobStateSuccess), state, "job %s failed: %+v", elem.GetName(), elem.Object)
}
}
@@ -238,11 +246,6 @@ func runGrafana(t *testing.T, options ...grafanaOption) *provisioningTestHelper
Namespace: "default", // actually org1
GVR: provisioning.JobResourceInfo.GroupVersionResource(),
})
historicJobs := helper.GetResourceClient(apis.ResourceClientArgs{
User: helper.Org1.Admin,
Namespace: "default", // actually org1
GVR: provisioning.HistoricJobResourceInfo.GroupVersionResource(),
})
folders := helper.GetResourceClient(apis.ResourceClientArgs{
User: helper.Org1.Admin,
Namespace: "default", // actually org1
@@ -289,7 +292,6 @@ func runGrafana(t *testing.T, options ...grafanaOption) *provisioningTestHelper
AdminREST: restClient,
ViewerREST: viewerClient,
Jobs: jobs,
HistoricJobs: historicJobs,
Folders: folders,
Dashboards: dashboards,
}
@@ -306,12 +306,14 @@ func TestProvisioning_ExportUnifiedToRepository(t *testing.T) {
Namespace("default").
Resource("repositories").
Name(repo).
SubResource("export").
SubResource("jobs").
SetHeader("Content-Type", "application/json").
Body(asJSON(&provisioning.ExportJobOptions{
Folder: "", // export entire instance
Path: "", // no prefix necessary for testing
Identifier: true, // doesn't _really_ matter, but handy for debugging.
Body(asJSON(&provisioning.JobSpec{
Push: &provisioning.ExportJobOptions{
Folder: "", // export entire instance
Path: "", // no prefix necessary for testing
Identifier: true, // doesn't _really_ matter, but handy for debugging.
},
})).
Do(ctx)
require.NoError(t, result.Error())