Provisioning: Use repository view rather than raw config (#103449)
This commit is contained in:
@@ -25,12 +25,12 @@ type RepositoryView struct {
|
||||
// Repository display
|
||||
Title string `json:"title"`
|
||||
|
||||
// Edit options within the repository
|
||||
ReadOnly bool `json:"readOnly"`
|
||||
|
||||
// The repository type
|
||||
Type RepositoryType `json:"type"`
|
||||
|
||||
// When syncing, where values are saved
|
||||
Target SyncTargetType `json:"target"`
|
||||
|
||||
// The supported workflows
|
||||
Workflows []Workflow `json:"workflows"`
|
||||
}
|
||||
|
||||
@@ -590,6 +590,11 @@ func (in *RepositoryStatus) DeepCopy() *RepositoryStatus {
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *RepositoryView) DeepCopyInto(out *RepositoryView) {
|
||||
*out = *in
|
||||
if in.Workflows != nil {
|
||||
in, out := &in.Workflows, &out.Workflows
|
||||
*out = make([]Workflow, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@@ -610,7 +615,9 @@ func (in *RepositoryViewList) DeepCopyInto(out *RepositoryViewList) {
|
||||
if in.Items != nil {
|
||||
in, out := &in.Items, &out.Items
|
||||
*out = make([]RepositoryView, len(*in))
|
||||
copy(*out, *in)
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1212,14 +1212,6 @@ func schema_pkg_apis_provisioning_v0alpha1_RepositoryView(ref common.ReferenceCa
|
||||
Format: "",
|
||||
},
|
||||
},
|
||||
"readOnly": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Description: "Edit options within the repository",
|
||||
Default: false,
|
||||
Type: []string{"boolean"},
|
||||
Format: "",
|
||||
},
|
||||
},
|
||||
"type": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Description: "The repository type\n\nPossible enum values:\n - `\"github\"`\n - `\"local\"`",
|
||||
@@ -1238,8 +1230,24 @@ func schema_pkg_apis_provisioning_v0alpha1_RepositoryView(ref common.ReferenceCa
|
||||
Enum: []interface{}{"folder", "instance"},
|
||||
},
|
||||
},
|
||||
"workflows": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Description: "The supported workflows",
|
||||
Type: []string{"array"},
|
||||
Items: &spec.SchemaOrArray{
|
||||
Schema: &spec.Schema{
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Default: "",
|
||||
Type: []string{"string"},
|
||||
Format: "",
|
||||
Enum: []interface{}{"branch", "write"},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
Required: []string{"name", "title", "readOnly", "type", "target"},
|
||||
Required: []string{"name", "title", "type", "target", "workflows"},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ 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,ManagerStats,Stats
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/pkg/apis/provisioning/v0alpha1,RepositoryList,Items
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/pkg/apis/provisioning/v0alpha1,RepositorySpec,Workflows
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/pkg/apis/provisioning/v0alpha1,RepositoryView,Workflows
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/pkg/apis/provisioning/v0alpha1,RepositoryViewList,Items
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/pkg/apis/provisioning/v0alpha1,ResourceList,Items
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/pkg/apis/provisioning/v0alpha1,TestResults,Errors
|
||||
|
||||
@@ -163,11 +163,11 @@ func (b *APIBuilder) handleSettings(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
for i, val := range all {
|
||||
settings.Items[i] = provisioning.RepositoryView{
|
||||
Name: val.ObjectMeta.Name,
|
||||
Title: val.Spec.Title,
|
||||
Type: val.Spec.Type,
|
||||
ReadOnly: len(val.Spec.Workflows) == 0,
|
||||
Target: val.Spec.Sync.Target,
|
||||
Name: val.ObjectMeta.Name,
|
||||
Title: val.Spec.Title,
|
||||
Type: val.Spec.Type,
|
||||
Target: val.Spec.Sync.Target,
|
||||
Workflows: val.Spec.Workflows,
|
||||
}
|
||||
}
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
|
||||
@@ -3229,9 +3229,9 @@
|
||||
"required": [
|
||||
"name",
|
||||
"title",
|
||||
"readOnly",
|
||||
"type",
|
||||
"target"
|
||||
"target",
|
||||
"workflows"
|
||||
],
|
||||
"properties": {
|
||||
"name": {
|
||||
@@ -3239,11 +3239,6 @@
|
||||
"type": "string",
|
||||
"default": ""
|
||||
},
|
||||
"readOnly": {
|
||||
"description": "Edit options within the repository",
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"target": {
|
||||
"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)",
|
||||
"type": "string",
|
||||
@@ -3266,6 +3261,18 @@
|
||||
"github",
|
||||
"local"
|
||||
]
|
||||
},
|
||||
"workflows": {
|
||||
"description": "The supported workflows",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string",
|
||||
"default": "",
|
||||
"enum": [
|
||||
"branch",
|
||||
"write"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user