Provisioning: add URL and Path in setting response (#114534)

* Provisioning: add URL and Path in setting response

* linting

* marking fields as non-required
This commit is contained in:
Daniele Stefano Ferru
2025-11-27 16:06:03 +01:00
committed by GitHub
parent 763067f8e1
commit 8e4be891c5
6 changed files with 49 additions and 0 deletions
@@ -43,6 +43,12 @@ type RepositoryView struct {
// For git, this is the target branch
Branch string `json:"branch,omitempty"`
// For git, this is the target URL
URL string `json:"url,omitempty"`
// For git, this is the target path
Path string `json:"path,omitempty"`
// The supported workflows
Workflows []Workflow `json:"workflows"`
}
@@ -1690,6 +1690,20 @@ func schema_pkg_apis_provisioning_v0alpha1_RepositoryView(ref common.ReferenceCa
Format: "",
},
},
"url": {
SchemaProps: spec.SchemaProps{
Description: "For git, this is the target URL",
Type: []string{"string"},
Format: "",
},
},
"path": {
SchemaProps: spec.SchemaProps{
Description: "For git, this is the target path",
Type: []string{"string"},
Format: "",
},
},
"workflows": {
SchemaProps: spec.SchemaProps{
Description: "The supported workflows",
@@ -1581,6 +1581,8 @@ export type RepositoryView = {
branch?: string;
/** The k8s name for this repository */
name: string;
/** For git, this is the target path */
path?: string;
/** When syncing, where values are saved
Possible enum values:
@@ -1598,6 +1600,8 @@ export type RepositoryView = {
- `"gitlab"`
- `"local"` */
type: 'bitbucket' | 'git' | 'github' | 'gitlab' | 'local';
/** For git, this is the target URL */
url?: string;
/** The supported workflows */
workflows: ('branch' | 'write')[];
};
+4
View File
@@ -172,6 +172,8 @@ func (b *APIBuilder) handleSettings(w http.ResponseWriter, r *http.Request) {
for i, val := range all {
branch := val.Branch()
url := val.URL()
path := val.Path()
settings.Items[i] = provisioning.RepositoryView{
Name: val.Name,
@@ -179,6 +181,8 @@ func (b *APIBuilder) handleSettings(w http.ResponseWriter, r *http.Request) {
Type: val.Spec.Type,
Target: val.Spec.Sync.Target,
Branch: branch,
URL: url,
Path: path,
Workflows: val.Spec.Workflows,
}
}
@@ -4309,6 +4309,10 @@
"type": "string",
"default": ""
},
"path": {
"description": "For git, this is the target path",
"type": "string"
},
"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",
@@ -4335,6 +4339,10 @@
"local"
]
},
"url": {
"description": "For git, this is the target URL",
"type": "string"
},
"workflows": {
"description": "The supported workflows",
"type": "array",
@@ -136,6 +136,19 @@ func TestIntegrationProvisioning_CreatingAndGetting(t *testing.T) {
return
}
for _, i := range settings.Items {
switch i.Type {
case provisioning.LocalRepositoryType:
assert.Equal(collect, i.Path, helper.ProvisioningPath)
case provisioning.GitHubRepositoryType:
assert.Equal(collect, i.URL, "https://github.com/grafana/grafana-git-sync-demo")
assert.Equal(collect, i.Path, "grafana/")
default:
assert.NotEmpty(collect, i.Path)
assert.NotEmpty(collect, i.URL)
}
}
assert.ElementsMatch(collect, []provisioning.RepositoryType{
provisioning.LocalRepositoryType,
provisioning.GitHubRepositoryType,