Provisioning: Update spec and dependencies (#101746)

Co-authored-by: Clarity-89 <homes89@ukr.net>
This commit is contained in:
Ryan McKinley
2025-03-07 10:57:13 +03:00
committed by GitHub
co-authored by Clarity-89
parent aa5f2e43d4
commit f52b6a5a42
23 changed files with 1330 additions and 186 deletions
+37 -12
View File
@@ -26,14 +26,17 @@ type JobList struct {
type JobAction string
const (
// Update a pull request -- send preview images, links etc
JobActionPullRequest JobAction = "pr"
// Sync the remote branch with the grafana instance
JobActionSync JobAction = "sync"
JobActionSync JobAction = "pull"
// Export from grafana into the remote repository
JobActionExport JobAction = "export"
JobActionExport JobAction = "push"
// Process a pull request -- apply comments with preview images, links etc
JobActionPullRequest JobAction = "pr"
// Migration task -- this will migrate an full instance from SQL > Git
JobActionMigrate JobAction = "migrate"
)
// +enum
@@ -66,11 +69,14 @@ type JobSpec struct {
// Pull request options
PullRequest *PullRequestJobOptions `json:"pr,omitempty"`
// Required when the action is `export`
Export *ExportJobOptions `json:"export,omitempty"`
// Required when the action is `push`
Push *ExportJobOptions `json:"push,omitempty"`
// Required when the action is `sync`
Sync *SyncJobOptions `json:"sync,omitempty"`
// Required when the action is `pull`
Pull *SyncJobOptions `json:"pull,omitempty"`
// Required when the action is `migrate`
Migrate *MigrateJobOptions `json:"migrate,omitempty"`
}
type PullRequestJobOptions struct {
@@ -94,15 +100,23 @@ type ExportJobOptions struct {
// The source folder (or empty) to export
Folder string `json:"folder,omitempty"`
// Preserve history (if possible)
History bool `json:"history,omitempty"`
// Target branch for export (only git)
Branch string `json:"branch,omitempty"`
// Prefix in target file system
Prefix string `json:"prefix,omitempty"`
// Include the identifier in the exported metadata
Identifier bool `json:"identifier"`
}
type MigrateJobOptions struct {
// Target file prefix
Prefix string `json:"prefix,omitempty"`
// Preserve history (if possible)
History bool `json:"history,omitempty"`
// Include the identifier in the exported metadata
Identifier bool `json:"identifier"`
}
@@ -122,6 +136,17 @@ type JobStatus struct {
Summary []*JobResourceSummary `json:"summary,omitempty"`
}
// Convert a JOB to a
func (in JobStatus) ToSyncStatus(jobId string) SyncStatus {
return SyncStatus{
JobID: jobId,
State: in.State,
Started: in.Started,
Finished: in.Finished,
Message: in.Errors,
}
}
type JobResourceSummary struct {
Group string `json:"group,omitempty"`
Resource string `json:"resource,omitempty"`
@@ -9,6 +9,11 @@ import (
type RepositoryViewList struct {
metav1.TypeMeta `json:",inline"`
// The backend is using legacy storage
// FIXME: Not sure where this should be exposed... but we need it somewhere
// The UI should force the onboarding workflow when this is true
LegacyStorage bool `json:"legacyStorage,omitempty"`
// +mapType=atomic
Items []RepositoryView `json:"items"`
}
+41 -26
View File
@@ -102,8 +102,8 @@ const (
SyncTargetTypeInstance SyncTargetType = "instance"
// Resources will be saved into a folder managed by this repository
// The folder k8s name will be the same as the repository k8s name
// It will contain a copy of everything from the remote
// The folder k8s name will be the same as the repository k8s name
SyncTargetTypeFolder SyncTargetType = "folder"
)
@@ -150,7 +150,8 @@ type HealthStatus struct {
// When the health was checked last time
Checked int64 `json:"checked,omitempty"`
// Summary messages (will be shown to users)
// Summary messages (can be shown to users)
// Will only be populated when not healthy
// +listType=atomic
Message []string `json:"message,omitempty"`
}
@@ -218,46 +219,29 @@ type ResourceWrapper struct {
// Path to the remote file
Path string `json:"path,omitempty"`
// The commit hash (if exists)
// The request ref (or branch if exists)
Ref string `json:"ref,omitempty"`
// The repo hash value
Hash string `json:"hash,omitempty"`
// Basic repository info
Repository ResourceRepositoryInfo `json:"repository"`
// Typed links for this file (only supported by external systems, github etc)
URLs *ResourceURLs `json:"urls,omitempty"`
// The modified time in the remote file system
Timestamp *metav1.Time `json:"timestamp,omitempty"`
// Different flavors of the same object
Resource ResourceObjects `json:"resource"`
// Lint results
// +listType=atomic
Lint []LintIssue `json:"lint,omitempty"`
// If errors exist, show them here
// +listType=atomic
Errors []string `json:"errors,omitempty"`
}
// The kubernetes action required when loading a given resource
// +enum
type LintSeverity string
// ResourceAction values
const (
LintSeverityExclude LintSeverity = "exclude"
LintSeverityQuiet LintSeverity = "quiet"
LintSeverityWarning LintSeverity = "warning"
LintSeverityError LintSeverity = "error"
LintSeverityFixed LintSeverity = "fixed"
)
type LintIssue struct {
Severity LintSeverity `json:"severity"`
Rule string `json:"rule"`
Message string `json:"message"`
}
type ResourceType struct {
Group string `json:"group,omitempty"`
Version string `json:"version,omitempty"`
@@ -284,6 +268,37 @@ type ResourceObjects struct {
// The value returned from a dryRun request
DryRun common.Unstructured `json:"dryRun,omitempty"`
// For write events, this will return the value that was added or updated
Upsert common.Unstructured `json:"upsert,omitempty"`
}
type ResourceRepositoryInfo struct {
// The repository type
Type RepositoryType `json:"type"`
// The display name for this repository
Title string `json:"title"`
// The namespace this belongs to
Namespace string `json:"namespace"`
// The name (identifier)
Name string `json:"name"`
}
type ResourceURLs struct {
// A URL pointing to the this file in the repository
SourceURL string `json:"sourceURL,omitempty"`
// A URL pointing to the repository this lives in
RepositoryURL string `json:"repositoryURL,omitempty"`
// A URL that will create a new pull requeset for this branch
NewPullRequestURL string `json:"newPullRequestURL,omitempty"`
// Compare this version to the target branch
CompareURL string `json:"compareURL,omitempty"`
}
// Information we can get just from the file listing
@@ -276,16 +276,21 @@ func (in *JobSpec) DeepCopyInto(out *JobSpec) {
*out = new(PullRequestJobOptions)
**out = **in
}
if in.Export != nil {
in, out := &in.Export, &out.Export
if in.Push != nil {
in, out := &in.Push, &out.Push
*out = new(ExportJobOptions)
**out = **in
}
if in.Sync != nil {
in, out := &in.Sync, &out.Sync
if in.Pull != nil {
in, out := &in.Pull, &out.Pull
*out = new(SyncJobOptions)
**out = **in
}
if in.Migrate != nil {
in, out := &in.Migrate, &out.Migrate
*out = new(MigrateJobOptions)
**out = **in
}
return
}
@@ -331,22 +336,6 @@ func (in *JobStatus) DeepCopy() *JobStatus {
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *LintIssue) DeepCopyInto(out *LintIssue) {
*out = *in
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LintIssue.
func (in *LintIssue) DeepCopy() *LintIssue {
if in == nil {
return nil
}
out := new(LintIssue)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *LocalRepositoryConfig) DeepCopyInto(out *LocalRepositoryConfig) {
*out = *in
@@ -363,6 +352,22 @@ func (in *LocalRepositoryConfig) DeepCopy() *LocalRepositoryConfig {
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *MigrateJobOptions) DeepCopyInto(out *MigrateJobOptions) {
*out = *in
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MigrateJobOptions.
func (in *MigrateJobOptions) DeepCopy() *MigrateJobOptions {
if in == nil {
return nil
}
out := new(MigrateJobOptions)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *PullRequestJobOptions) DeepCopyInto(out *PullRequestJobOptions) {
*out = *in
@@ -616,6 +621,7 @@ func (in *ResourceObjects) DeepCopyInto(out *ResourceObjects) {
in.File.DeepCopyInto(&out.File)
in.Existing.DeepCopyInto(&out.Existing)
in.DryRun.DeepCopyInto(&out.DryRun)
in.Upsert.DeepCopyInto(&out.Upsert)
return
}
@@ -629,6 +635,22 @@ func (in *ResourceObjects) DeepCopy() *ResourceObjects {
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ResourceRepositoryInfo) DeepCopyInto(out *ResourceRepositoryInfo) {
*out = *in
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResourceRepositoryInfo.
func (in *ResourceRepositoryInfo) DeepCopy() *ResourceRepositoryInfo {
if in == nil {
return nil
}
out := new(ResourceRepositoryInfo)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ResourceStats) DeepCopyInto(out *ResourceStats) {
*out = *in
@@ -676,20 +698,37 @@ func (in *ResourceType) DeepCopy() *ResourceType {
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ResourceURLs) DeepCopyInto(out *ResourceURLs) {
*out = *in
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResourceURLs.
func (in *ResourceURLs) DeepCopy() *ResourceURLs {
if in == nil {
return nil
}
out := new(ResourceURLs)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ResourceWrapper) DeepCopyInto(out *ResourceWrapper) {
*out = *in
out.TypeMeta = in.TypeMeta
out.Repository = in.Repository
if in.URLs != nil {
in, out := &in.URLs, &out.URLs
*out = new(ResourceURLs)
**out = **in
}
if in.Timestamp != nil {
in, out := &in.Timestamp, &out.Timestamp
*out = (*in).DeepCopy()
}
in.Resource.DeepCopyInto(&out.Resource)
if in.Lint != nil {
in, out := &in.Lint, &out.Lint
*out = make([]LintIssue, len(*in))
copy(*out, *in)
}
if in.Errors != nil {
in, out := &in.Errors, &out.Errors
*out = make([]string, len(*in))
@@ -27,8 +27,8 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA
"github.com/grafana/grafana/pkg/apis/provisioning/v0alpha1.JobResourceSummary": schema_pkg_apis_provisioning_v0alpha1_JobResourceSummary(ref),
"github.com/grafana/grafana/pkg/apis/provisioning/v0alpha1.JobSpec": schema_pkg_apis_provisioning_v0alpha1_JobSpec(ref),
"github.com/grafana/grafana/pkg/apis/provisioning/v0alpha1.JobStatus": schema_pkg_apis_provisioning_v0alpha1_JobStatus(ref),
"github.com/grafana/grafana/pkg/apis/provisioning/v0alpha1.LintIssue": schema_pkg_apis_provisioning_v0alpha1_LintIssue(ref),
"github.com/grafana/grafana/pkg/apis/provisioning/v0alpha1.LocalRepositoryConfig": schema_pkg_apis_provisioning_v0alpha1_LocalRepositoryConfig(ref),
"github.com/grafana/grafana/pkg/apis/provisioning/v0alpha1.MigrateJobOptions": schema_pkg_apis_provisioning_v0alpha1_MigrateJobOptions(ref),
"github.com/grafana/grafana/pkg/apis/provisioning/v0alpha1.PullRequestJobOptions": schema_pkg_apis_provisioning_v0alpha1_PullRequestJobOptions(ref),
"github.com/grafana/grafana/pkg/apis/provisioning/v0alpha1.Repository": schema_pkg_apis_provisioning_v0alpha1_Repository(ref),
"github.com/grafana/grafana/pkg/apis/provisioning/v0alpha1.RepositoryList": schema_pkg_apis_provisioning_v0alpha1_RepositoryList(ref),
@@ -40,8 +40,10 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA
"github.com/grafana/grafana/pkg/apis/provisioning/v0alpha1.ResourceList": schema_pkg_apis_provisioning_v0alpha1_ResourceList(ref),
"github.com/grafana/grafana/pkg/apis/provisioning/v0alpha1.ResourceListItem": schema_pkg_apis_provisioning_v0alpha1_ResourceListItem(ref),
"github.com/grafana/grafana/pkg/apis/provisioning/v0alpha1.ResourceObjects": schema_pkg_apis_provisioning_v0alpha1_ResourceObjects(ref),
"github.com/grafana/grafana/pkg/apis/provisioning/v0alpha1.ResourceRepositoryInfo": schema_pkg_apis_provisioning_v0alpha1_ResourceRepositoryInfo(ref),
"github.com/grafana/grafana/pkg/apis/provisioning/v0alpha1.ResourceStats": schema_pkg_apis_provisioning_v0alpha1_ResourceStats(ref),
"github.com/grafana/grafana/pkg/apis/provisioning/v0alpha1.ResourceType": schema_pkg_apis_provisioning_v0alpha1_ResourceType(ref),
"github.com/grafana/grafana/pkg/apis/provisioning/v0alpha1.ResourceURLs": schema_pkg_apis_provisioning_v0alpha1_ResourceURLs(ref),
"github.com/grafana/grafana/pkg/apis/provisioning/v0alpha1.ResourceWrapper": schema_pkg_apis_provisioning_v0alpha1_ResourceWrapper(ref),
"github.com/grafana/grafana/pkg/apis/provisioning/v0alpha1.SyncJobOptions": schema_pkg_apis_provisioning_v0alpha1_SyncJobOptions(ref),
"github.com/grafana/grafana/pkg/apis/provisioning/v0alpha1.SyncOptions": schema_pkg_apis_provisioning_v0alpha1_SyncOptions(ref),
@@ -98,13 +100,6 @@ func schema_pkg_apis_provisioning_v0alpha1_ExportJobOptions(ref common.Reference
Format: "",
},
},
"history": {
SchemaProps: spec.SchemaProps{
Description: "Preserve history (if possible)",
Type: []string{"boolean"},
Format: "",
},
},
"branch": {
SchemaProps: spec.SchemaProps{
Description: "Target branch for export (only git)",
@@ -114,7 +109,7 @@ func schema_pkg_apis_provisioning_v0alpha1_ExportJobOptions(ref common.Reference
},
"prefix": {
SchemaProps: spec.SchemaProps{
Description: "Target file prefix",
Description: "Prefix in target file system",
Type: []string{"string"},
Format: "",
},
@@ -313,7 +308,7 @@ func schema_pkg_apis_provisioning_v0alpha1_HealthStatus(ref common.ReferenceCall
},
},
SchemaProps: spec.SchemaProps{
Description: "Summary messages (will be shown to users)",
Description: "Summary messages (can be shown to users) Will only be populated when not healthy",
Type: []string{"array"},
Items: &spec.SchemaOrArray{
Schema: &spec.Schema{
@@ -625,11 +620,11 @@ func schema_pkg_apis_provisioning_v0alpha1_JobSpec(ref common.ReferenceCallback)
Properties: map[string]spec.Schema{
"action": {
SchemaProps: spec.SchemaProps{
Description: "Possible enum values:\n - `\"export\"` Export from grafana into the remote repository\n - `\"pr\"` Update a pull request -- send preview images, links etc\n - `\"sync\"` Sync the remote branch with the grafana instance",
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",
Default: "",
Type: []string{"string"},
Format: "",
Enum: []interface{}{"export", "pr", "sync"},
Enum: []interface{}{"migrate", "pr", "pull", "push"},
},
},
"repository": {
@@ -646,24 +641,30 @@ func schema_pkg_apis_provisioning_v0alpha1_JobSpec(ref common.ReferenceCallback)
Ref: ref("github.com/grafana/grafana/pkg/apis/provisioning/v0alpha1.PullRequestJobOptions"),
},
},
"export": {
"push": {
SchemaProps: spec.SchemaProps{
Description: "Required when the action is `export`",
Description: "Required when the action is `push`",
Ref: ref("github.com/grafana/grafana/pkg/apis/provisioning/v0alpha1.ExportJobOptions"),
},
},
"sync": {
"pull": {
SchemaProps: spec.SchemaProps{
Description: "Required when the action is `sync`",
Description: "Required when the action is `pull`",
Ref: ref("github.com/grafana/grafana/pkg/apis/provisioning/v0alpha1.SyncJobOptions"),
},
},
"migrate": {
SchemaProps: spec.SchemaProps{
Description: "Required when the action is `migrate`",
Ref: ref("github.com/grafana/grafana/pkg/apis/provisioning/v0alpha1.MigrateJobOptions"),
},
},
},
Required: []string{"action", "repository"},
},
},
Dependencies: []string{
"github.com/grafana/grafana/pkg/apis/provisioning/v0alpha1.ExportJobOptions", "github.com/grafana/grafana/pkg/apis/provisioning/v0alpha1.PullRequestJobOptions", "github.com/grafana/grafana/pkg/apis/provisioning/v0alpha1.SyncJobOptions"},
"github.com/grafana/grafana/pkg/apis/provisioning/v0alpha1.ExportJobOptions", "github.com/grafana/grafana/pkg/apis/provisioning/v0alpha1.MigrateJobOptions", "github.com/grafana/grafana/pkg/apis/provisioning/v0alpha1.PullRequestJobOptions", "github.com/grafana/grafana/pkg/apis/provisioning/v0alpha1.SyncJobOptions"},
}
}
@@ -742,42 +743,6 @@ func schema_pkg_apis_provisioning_v0alpha1_JobStatus(ref common.ReferenceCallbac
}
}
func schema_pkg_apis_provisioning_v0alpha1_LintIssue(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
Type: []string{"object"},
Properties: map[string]spec.Schema{
"severity": {
SchemaProps: spec.SchemaProps{
Description: "Possible enum values:\n - `\"error\"`\n - `\"exclude\"`\n - `\"fixed\"`\n - `\"quiet\"`\n - `\"warning\"`",
Default: "",
Type: []string{"string"},
Format: "",
Enum: []interface{}{"error", "exclude", "fixed", "quiet", "warning"},
},
},
"rule": {
SchemaProps: spec.SchemaProps{
Default: "",
Type: []string{"string"},
Format: "",
},
},
"message": {
SchemaProps: spec.SchemaProps{
Default: "",
Type: []string{"string"},
Format: "",
},
},
},
Required: []string{"severity", "rule", "message"},
},
},
}
}
func schema_pkg_apis_provisioning_v0alpha1_LocalRepositoryConfig(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
@@ -796,6 +761,41 @@ func schema_pkg_apis_provisioning_v0alpha1_LocalRepositoryConfig(ref common.Refe
}
}
func schema_pkg_apis_provisioning_v0alpha1_MigrateJobOptions(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
Type: []string{"object"},
Properties: map[string]spec.Schema{
"prefix": {
SchemaProps: spec.SchemaProps{
Description: "Target file prefix",
Type: []string{"string"},
Format: "",
},
},
"history": {
SchemaProps: spec.SchemaProps{
Description: "Preserve history (if possible)",
Type: []string{"boolean"},
Format: "",
},
},
"identifier": {
SchemaProps: spec.SchemaProps{
Description: "Include the identifier in the exported metadata",
Default: false,
Type: []string{"boolean"},
Format: "",
},
},
},
Required: []string{"identifier"},
},
},
}
}
func schema_pkg_apis_provisioning_v0alpha1_PullRequestJobOptions(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
@@ -1112,7 +1112,7 @@ func schema_pkg_apis_provisioning_v0alpha1_RepositoryView(ref common.ReferenceCa
},
"target": {
SchemaProps: spec.SchemaProps{
Description: "When syncing, where values are saved\n\nPossible enum values:\n - `\"folder\"` Resources will be saved into a folder managed by this repository The folder k8s name will be the same as the repository k8s name It will contain a copy of everything from the remote\n - `\"instance\"` Resources are saved in the global context Only one repository may specify the `instance` target When this exists, the UI will promote writing to the instance repo rather than the grafana database (where possible)",
Description: "When syncing, where values are saved\n\nPossible enum values:\n - `\"folder\"` Resources will be saved into a folder managed by this repository It will contain a copy of everything from the remote The folder k8s name will be the same as the repository k8s name\n - `\"instance\"` Resources are saved in the global context Only one repository may specify the `instance` target When this exists, the UI will promote writing to the instance repo rather than the grafana database (where possible)",
Default: "",
Type: []string{"string"},
Format: "",
@@ -1147,6 +1147,13 @@ func schema_pkg_apis_provisioning_v0alpha1_RepositoryViewList(ref common.Referen
Format: "",
},
},
"legacyStorage": {
SchemaProps: spec.SchemaProps{
Description: "The backend is using legacy storage FIXME: Not sure where this should be exposed... but we need it somewhere The UI should force the onboarding workflow when this is true",
Type: []string{"boolean"},
Format: "",
},
},
"items": {
VendorExtensible: spec.VendorExtensible{
Extensions: spec.Extensions{
@@ -1373,6 +1380,12 @@ func schema_pkg_apis_provisioning_v0alpha1_ResourceObjects(ref common.ReferenceC
Ref: ref("github.com/grafana/grafana/pkg/apimachinery/apis/common/v0alpha1.Unstructured"),
},
},
"upsert": {
SchemaProps: spec.SchemaProps{
Description: "For write events, this will return the value that was added or updated",
Ref: ref("github.com/grafana/grafana/pkg/apimachinery/apis/common/v0alpha1.Unstructured"),
},
},
},
Required: []string{"type"},
},
@@ -1382,6 +1395,52 @@ func schema_pkg_apis_provisioning_v0alpha1_ResourceObjects(ref common.ReferenceC
}
}
func schema_pkg_apis_provisioning_v0alpha1_ResourceRepositoryInfo(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
Type: []string{"object"},
Properties: map[string]spec.Schema{
"type": {
SchemaProps: spec.SchemaProps{
Description: "The repository type\n\nPossible enum values:\n - `\"github\"`\n - `\"local\"`",
Default: "",
Type: []string{"string"},
Format: "",
Enum: []interface{}{"github", "local"},
},
},
"title": {
SchemaProps: spec.SchemaProps{
Description: "The display name for this repository",
Default: "",
Type: []string{"string"},
Format: "",
},
},
"namespace": {
SchemaProps: spec.SchemaProps{
Description: "The namespace this belongs to",
Default: "",
Type: []string{"string"},
Format: "",
},
},
"name": {
SchemaProps: spec.SchemaProps{
Description: "The name (identifier)",
Default: "",
Type: []string{"string"},
Format: "",
},
},
},
Required: []string{"type", "title", "namespace", "name"},
},
},
}
}
func schema_pkg_apis_provisioning_v0alpha1_ResourceStats(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
@@ -1479,6 +1538,46 @@ func schema_pkg_apis_provisioning_v0alpha1_ResourceType(ref common.ReferenceCall
}
}
func schema_pkg_apis_provisioning_v0alpha1_ResourceURLs(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
Type: []string{"object"},
Properties: map[string]spec.Schema{
"sourceURL": {
SchemaProps: spec.SchemaProps{
Description: "A URL pointing to the this file in the repository",
Type: []string{"string"},
Format: "",
},
},
"repositoryURL": {
SchemaProps: spec.SchemaProps{
Description: "A URL pointing to the repository this lives in",
Type: []string{"string"},
Format: "",
},
},
"newPullRequestURL": {
SchemaProps: spec.SchemaProps{
Description: "A URL that will create a new pull requeset for this branch",
Type: []string{"string"},
Format: "",
},
},
"compareURL": {
SchemaProps: spec.SchemaProps{
Description: "Compare this version to the target branch",
Type: []string{"string"},
Format: "",
},
},
},
},
},
}
}
func schema_pkg_apis_provisioning_v0alpha1_ResourceWrapper(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
@@ -1509,7 +1608,7 @@ func schema_pkg_apis_provisioning_v0alpha1_ResourceWrapper(ref common.ReferenceC
},
"ref": {
SchemaProps: spec.SchemaProps{
Description: "The commit hash (if exists)",
Description: "The request ref (or branch if exists)",
Type: []string{"string"},
Format: "",
},
@@ -1521,6 +1620,19 @@ func schema_pkg_apis_provisioning_v0alpha1_ResourceWrapper(ref common.ReferenceC
Format: "",
},
},
"repository": {
SchemaProps: spec.SchemaProps{
Description: "Basic repository info",
Default: map[string]interface{}{},
Ref: ref("github.com/grafana/grafana/pkg/apis/provisioning/v0alpha1.ResourceRepositoryInfo"),
},
},
"urls": {
SchemaProps: spec.SchemaProps{
Description: "Typed links for this file (only supported by external systems, github etc)",
Ref: ref("github.com/grafana/grafana/pkg/apis/provisioning/v0alpha1.ResourceURLs"),
},
},
"timestamp": {
SchemaProps: spec.SchemaProps{
Description: "The modified time in the remote file system",
@@ -1534,25 +1646,6 @@ func schema_pkg_apis_provisioning_v0alpha1_ResourceWrapper(ref common.ReferenceC
Ref: ref("github.com/grafana/grafana/pkg/apis/provisioning/v0alpha1.ResourceObjects"),
},
},
"lint": {
VendorExtensible: spec.VendorExtensible{
Extensions: spec.Extensions{
"x-kubernetes-list-type": "atomic",
},
},
SchemaProps: spec.SchemaProps{
Description: "Lint results",
Type: []string{"array"},
Items: &spec.SchemaOrArray{
Schema: &spec.Schema{
SchemaProps: spec.SchemaProps{
Default: map[string]interface{}{},
Ref: ref("github.com/grafana/grafana/pkg/apis/provisioning/v0alpha1.LintIssue"),
},
},
},
},
},
"errors": {
VendorExtensible: spec.VendorExtensible{
Extensions: spec.Extensions{
@@ -1574,11 +1667,11 @@ func schema_pkg_apis_provisioning_v0alpha1_ResourceWrapper(ref common.ReferenceC
},
},
},
Required: []string{"resource"},
Required: []string{"repository", "resource"},
},
},
Dependencies: []string{
"github.com/grafana/grafana/pkg/apis/provisioning/v0alpha1.LintIssue", "github.com/grafana/grafana/pkg/apis/provisioning/v0alpha1.ResourceObjects", "k8s.io/apimachinery/pkg/apis/meta/v1.Time"},
"github.com/grafana/grafana/pkg/apis/provisioning/v0alpha1.ResourceObjects", "github.com/grafana/grafana/pkg/apis/provisioning/v0alpha1.ResourceRepositoryInfo", "github.com/grafana/grafana/pkg/apis/provisioning/v0alpha1.ResourceURLs", "k8s.io/apimachinery/pkg/apis/meta/v1.Time"},
}
}
@@ -1619,7 +1712,7 @@ func schema_pkg_apis_provisioning_v0alpha1_SyncOptions(ref common.ReferenceCallb
},
"target": {
SchemaProps: spec.SchemaProps{
Description: "Where values should be saved\n\nPossible enum values:\n - `\"folder\"` Resources will be saved into a folder managed by this repository The folder k8s name will be the same as the repository k8s name It will contain a copy of everything from the remote\n - `\"instance\"` Resources are saved in the global context Only one repository may specify the `instance` target When this exists, the UI will promote writing to the instance repo rather than the grafana database (where possible)",
Description: "Where values should be saved\n\nPossible enum values:\n - `\"folder\"` Resources will be saved into a folder managed by this repository It will contain a copy of everything from the remote The folder k8s name will be the same as the repository k8s name\n - `\"instance\"` Resources are saved in the global context Only one repository may specify the `instance` target When this exists, the UI will promote writing to the instance repo rather than the grafana database (where possible)",
Default: "",
Type: []string{"string"},
Format: "",
@@ -12,5 +12,6 @@ API rule violation: list_type_missing,github.com/grafana/grafana/pkg/apis/provis
API rule violation: list_type_missing,github.com/grafana/grafana/pkg/apis/provisioning/v0alpha1,WebhookStatus,SubscribedEvents
API rule violation: names_match,github.com/grafana/grafana/pkg/apis/provisioning/v0alpha1,JobSpec,PullRequest
API rule violation: names_match,github.com/grafana/grafana/pkg/apis/provisioning/v0alpha1,RepositorySpec,GitHub
API rule violation: names_match,github.com/grafana/grafana/pkg/apis/provisioning/v0alpha1,ResourceWrapper,URLs
API rule violation: names_match,github.com/grafana/grafana/pkg/apis/provisioning/v0alpha1,SyncStatus,JobID
API rule violation: names_match,github.com/grafana/grafana/pkg/apis/provisioning/v0alpha1,WebhookResponse,Message
+4 -4
View File
@@ -175,12 +175,12 @@ func (s *jobStore) Add(ctx context.Context, job *provisioning.Job) (*provisionin
if job.Spec.Action == "" {
return nil, apierrors.NewBadRequest("missing spec.action")
}
if job.Spec.Action == provisioning.JobActionExport && job.Spec.Export == nil {
return nil, apierrors.NewBadRequest("missing spec.export")
if job.Spec.Action == provisioning.JobActionExport && job.Spec.Push == nil {
return nil, apierrors.NewBadRequest("missing spec.push")
}
if job.Spec.Action == provisioning.JobActionSync && job.Spec.Sync == nil {
return nil, apierrors.NewBadRequest("missing spec.sync")
if job.Spec.Action == provisioning.JobActionSync && job.Spec.Pull == nil {
return nil, apierrors.NewBadRequest("missing spec.pull")
}
// Only for add
+1 -1
View File
@@ -63,7 +63,7 @@ require (
github.com/Masterminds/squirrel v1.5.4 // indirect
github.com/Microsoft/go-winio v0.6.2 // indirect
github.com/NYTimes/gziphandler v1.1.1 // indirect
github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 // indirect
github.com/ProtonMail/go-crypto v1.1.6 // indirect
github.com/RoaringBitmap/roaring v1.9.3 // indirect
github.com/VividCortex/mysqlerr v0.0.0-20170204212430-6c6b55f8796f // indirect
github.com/Yiling-J/theine-go v0.6.0 // indirect
+2 -6
View File
@@ -688,8 +688,8 @@ github.com/NYTimes/gziphandler v1.1.1 h1:ZUDjpQae29j0ryrS0u/B8HZfJBtBQHjqw2rQ2cq
github.com/NYTimes/gziphandler v1.1.1/go.mod h1:n/CVRwUEOgIxrgPvAQhUUr9oeUtvrhMomdKFjzJNB0c=
github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5/go.mod h1:lmUJ/7eu/Q8D7ML55dXQrVaamCz2vxCfdQBasLZfHKk=
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 h1:kkhsdkhsCvIsutKu5zLMgWtgh9YxGCNAw8Ad8hjwfYg=
github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371/go.mod h1:EjAoLdwvbIOoOQr3ihjnSoLZRtE8azugULFRteWMNc0=
github.com/ProtonMail/go-crypto v1.1.6 h1:ZcV+Ropw6Qn0AX9brlQLAUXfqLBc7Bl+f/DmNxpLfdw=
github.com/ProtonMail/go-crypto v1.1.6/go.mod h1:rA3QumHc/FZ8pAHreoekgiAbzpNsfQAosU5td4SnOrE=
github.com/RoaringBitmap/roaring v1.9.3 h1:t4EbC5qQwnisr5PrP9nt0IRhRTb9gMUgQF4t4S2OByM=
github.com/RoaringBitmap/roaring v1.9.3/go.mod h1:6AXUsoIEzDTFFQCe1RbGA6uFONMhvejWj5rqITANK90=
github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo=
@@ -839,7 +839,6 @@ github.com/bufbuild/protocompile v0.4.0 h1:LbFKd2XowZvQ/kajzguUp2DC9UEIQhIq77fZZ
github.com/bufbuild/protocompile v0.4.0/go.mod h1:3v93+mbWn/v3xzN+31nwkJfrEpAUwp+BagBSZWx+TP8=
github.com/buger/jsonparser v1.1.1 h1:2PnMjfWD7wBILjqQbt530v576A/cAbQvEW9gGIpYMUs=
github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0=
github.com/bwesterb/go-ristretto v1.2.3/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0=
github.com/bwmarrin/snowflake v0.3.0 h1:xm67bEhkKh6ij1790JB83OujPR5CzNe8QuQqAgISZN0=
github.com/bwmarrin/snowflake v0.3.0/go.mod h1:NdZxfVWX+oR6y2K0o6qAYv6gIOP9rjG0/E9WsDpxqwE=
github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8=
@@ -862,7 +861,6 @@ github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMn
github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible/go.mod h1:nmEj6Dob7S7YxXgwXpfOuvO54S+tGdZdw9fuRZt25Ag=
github.com/circonus-labs/circonusllhist v0.1.3/go.mod h1:kMXHVDlOchFAehlya5ePtbp5jckzBHf4XRpQvBOLI+I=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/cloudflare/circl v1.3.3/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA=
github.com/cloudflare/circl v1.3.7 h1:qlCDlTPz2n9fu58M0Nh1J/JzcFpfgkFHHX3O35r5vcU=
github.com/cloudflare/circl v1.3.7/go.mod h1:sRTcRWXGLrKw6yIGJ+l7amYJFfAXbZG0kBSc8r4zxgA=
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
@@ -1915,8 +1913,6 @@ golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4=
golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU=
golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc=
golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg=
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
+2 -2
View File
@@ -679,8 +679,8 @@ github.com/Masterminds/sprig/v3 v3.3.0/go.mod h1:Zy1iXRYNqNLUolqCpL4uhk6SHUMAOSC
github.com/Microsoft/go-winio v0.4.11/go.mod h1:VhR8bwka0BXejwEJY73c50VrPtXAaKcyvVC4A4RozmA=
github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5/go.mod h1:lmUJ/7eu/Q8D7ML55dXQrVaamCz2vxCfdQBasLZfHKk=
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 h1:kkhsdkhsCvIsutKu5zLMgWtgh9YxGCNAw8Ad8hjwfYg=
github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371/go.mod h1:EjAoLdwvbIOoOQr3ihjnSoLZRtE8azugULFRteWMNc0=
github.com/ProtonMail/go-crypto v1.1.6 h1:ZcV+Ropw6Qn0AX9brlQLAUXfqLBc7Bl+f/DmNxpLfdw=
github.com/ProtonMail/go-crypto v1.1.6/go.mod h1:rA3QumHc/FZ8pAHreoekgiAbzpNsfQAosU5td4SnOrE=
github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo=
github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI=
github.com/VividCortex/mysqlerr v0.0.0-20170204212430-6c6b55f8796f h1:HR5nRmUQgXrwqZOwZ2DAc/aCi3Bu3xENpspW935vxu0=
@@ -1399,17 +1399,13 @@
"description": "The source folder (or empty) to export",
"type": "string"
},
"history": {
"description": "Preserve history (if possible)",
"type": "boolean"
},
"identifier": {
"description": "Include the identifier in the exported metadata",
"type": "boolean",
"default": false
},
"prefix": {
"description": "Target file prefix",
"description": "Prefix in target file system",
"type": "string"
}
}
@@ -1462,7 +1458,7 @@
"default": false
},
"message": {
"description": "Summary messages (will be shown to users)",
"description": "Summary messages (can be shown to users) Will only be populated when not healthy",
"type": "array",
"items": {
"type": "string",
@@ -1623,20 +1619,21 @@
],
"properties": {
"action": {
"description": "Possible enum values:\n - `\"export\"` Export from grafana into the remote repository\n - `\"pr\"` Update a pull request -- send preview images, links etc\n - `\"sync\"` Sync the remote branch with the grafana instance",
"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",
"type": "string",
"default": "",
"enum": [
"export",
"migrate",
"pr",
"sync"
"pull",
"push"
]
},
"export": {
"description": "Required when the action is `export`",
"migrate": {
"description": "Required when the action is `migrate`",
"allOf": [
{
"$ref": "#/components/schemas/com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1.ExportJobOptions"
"$ref": "#/components/schemas/com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1.MigrateJobOptions"
}
]
},
@@ -1648,18 +1645,26 @@
}
]
},
"repository": {
"description": "The the repository reference (for now also in labels)",
"type": "string",
"default": ""
},
"sync": {
"description": "Required when the action is `sync`",
"pull": {
"description": "Required when the action is `pull`",
"allOf": [
{
"$ref": "#/components/schemas/com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1.SyncJobOptions"
}
]
},
"push": {
"description": "Required when the action is `push`",
"allOf": [
{
"$ref": "#/components/schemas/com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1.ExportJobOptions"
}
]
},
"repository": {
"description": "The the repository reference (for now also in labels)",
"type": "string",
"default": ""
}
}
},
@@ -1717,6 +1722,27 @@
}
}
},
"com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1.MigrateJobOptions": {
"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
},
"prefix": {
"description": "Target file prefix",
"type": "string"
}
}
},
"com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1.PullRequestJobOptions": {
"type": "object",
"properties": {
@@ -2013,7 +2039,7 @@
"format": "int64"
},
"target": {
"description": "Where values should be saved\n\nPossible enum values:\n - `\"folder\"` Resources will be saved into a folder managed by this repository The folder k8s name will be the same as the repository k8s name It will contain a copy of everything from the remote\n - `\"instance\"` Resources are saved in the global context Only one repository may specify the `instance` target When this exists, the UI will promote writing to the instance repo rather than the grafana database (where possible)",
"description": "Where values should be saved\n\nPossible enum values:\n - `\"folder\"` Resources will be saved into a folder managed by this repository It will contain a copy of everything from the remote The folder k8s name will be the same as the repository k8s name\n - `\"instance\"` Resources are saved in the global context Only one repository may specify the `instance` target When this exists, the UI will promote writing to the instance repo rather than the grafana database (where possible)",
"type": "string",
"default": "",
"enum": [