Provisioning: Sync API with current feature branch (#100252)

* Provisioning: Jobs: Define repository name field

* Provisioning: Jobs: Separate options per job type

* Provisioning: Define a sanitised settings resource

* Provisioning: Jobs: Define a job summary

* Provisioning: Remove linting

* Provisioning: Update docs for a few fields

* Provisioning: Remove HelloWorld

* Provisioning: Replace Repository with Message in job info

* Provisioning: Remove YAML support

* Provisioning: Remove custom folder specification

* Provisioning: Support read-only repositories

* Provisioning: Remove edit options

* Provisioning: Add sync options for repositories

* Provisioning: Add resource statistics

* Provisioning: Make slices atomic lists

* Provisioning: Message list needs to exist even if empty

If we don't do this, we can't clear the messages field, leading to buggy UX.

* Provisioning: Support incremental syncing

* Provisioning: Remove the 'items' subresource workaround

* Provisioning: Add resource list

* Provisioning: Reformat

* Provisioning: Declare new types

* OpenAPI: Generate openapi JSON spec from generated code

* Codegen: Generate OpenAPI spec

* Provisioning: Support generating frontend API

* Codegen: Generate Go code

* Provisioning: Define the base API

* Codegen: Generate frontend endpoints for provisioning

* Refactor: yarn prettier:write

* Provisioning: Tiger team takes ownership

* Chore: Remove dir we haven't added yet

* Provisioning: Remove frontend

* Test: Update example repositories
This commit is contained in:
Mariell Hoversholm
2025-02-07 15:35:55 +01:00
committed by GitHub
parent 9d7a4a53e4
commit dfaa12b800
20 changed files with 3516 additions and 286 deletions
@@ -1,43 +0,0 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Code generated by applyconfiguration-gen. DO NOT EDIT.
package v0alpha1
// EditingOptionsApplyConfiguration represents a declarative configuration of the EditingOptions type for use
// with apply.
type EditingOptionsApplyConfiguration struct {
Create *bool `json:"create,omitempty"`
Update *bool `json:"update,omitempty"`
Delete *bool `json:"delete,omitempty"`
}
// EditingOptionsApplyConfiguration constructs a declarative configuration of the EditingOptions type for use with
// apply.
func EditingOptions() *EditingOptionsApplyConfiguration {
return &EditingOptionsApplyConfiguration{}
}
// WithCreate sets the Create field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the Create field is set to the value of the last call.
func (b *EditingOptionsApplyConfiguration) WithCreate(value bool) *EditingOptionsApplyConfiguration {
b.Create = &value
return b
}
// WithUpdate sets the Update field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the Update field is set to the value of the last call.
func (b *EditingOptionsApplyConfiguration) WithUpdate(value bool) *EditingOptionsApplyConfiguration {
b.Update = &value
return b
}
// WithDelete sets the Delete field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the Delete field is set to the value of the last call.
func (b *EditingOptionsApplyConfiguration) WithDelete(value bool) *EditingOptionsApplyConfiguration {
b.Delete = &value
return b
}
@@ -13,7 +13,6 @@ type GitHubRepositoryConfigApplyConfiguration struct {
Token *string `json:"token,omitempty"`
BranchWorkflow *bool `json:"branchWorkflow,omitempty"`
GenerateDashboardPreviews *bool `json:"generateDashboardPreviews,omitempty"`
PullRequestLinter *bool `json:"pullRequestLinter,omitempty"`
}
// GitHubRepositoryConfigApplyConfiguration constructs a declarative configuration of the GitHubRepositoryConfig type for use with
@@ -69,11 +68,3 @@ func (b *GitHubRepositoryConfigApplyConfiguration) WithGenerateDashboardPreviews
b.GenerateDashboardPreviews = &value
return b
}
// WithPullRequestLinter sets the PullRequestLinter field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the PullRequestLinter field is set to the value of the last call.
func (b *GitHubRepositoryConfigApplyConfiguration) WithPullRequestLinter(value bool) *GitHubRepositoryConfigApplyConfiguration {
b.PullRequestLinter = &value
return b
}
@@ -13,11 +13,9 @@ import (
type RepositorySpecApplyConfiguration struct {
Title *string `json:"title,omitempty"`
Description *string `json:"description,omitempty"`
Folder *string `json:"folder,omitempty"`
PreferYAML *bool `json:"preferYaml,omitempty"`
Editing *EditingOptionsApplyConfiguration `json:"editing,omitempty"`
ReadOnly *bool `json:"readOnly,omitempty"`
Sync *SyncOptionsApplyConfiguration `json:"sync,omitempty"`
Type *provisioningv0alpha1.RepositoryType `json:"type,omitempty"`
Linting *bool `json:"linting,omitempty"`
Local *LocalRepositoryConfigApplyConfiguration `json:"local,omitempty"`
S3 *S3RepositoryConfigApplyConfiguration `json:"s3,omitempty"`
GitHub *GitHubRepositoryConfigApplyConfiguration `json:"github,omitempty"`
@@ -45,27 +43,19 @@ func (b *RepositorySpecApplyConfiguration) WithDescription(value string) *Reposi
return b
}
// WithFolder sets the Folder field in the declarative configuration to the given value
// WithReadOnly sets the ReadOnly field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the Folder field is set to the value of the last call.
func (b *RepositorySpecApplyConfiguration) WithFolder(value string) *RepositorySpecApplyConfiguration {
b.Folder = &value
// If called multiple times, the ReadOnly field is set to the value of the last call.
func (b *RepositorySpecApplyConfiguration) WithReadOnly(value bool) *RepositorySpecApplyConfiguration {
b.ReadOnly = &value
return b
}
// WithPreferYAML sets the PreferYAML field in the declarative configuration to the given value
// WithSync sets the Sync field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the PreferYAML field is set to the value of the last call.
func (b *RepositorySpecApplyConfiguration) WithPreferYAML(value bool) *RepositorySpecApplyConfiguration {
b.PreferYAML = &value
return b
}
// WithEditing sets the Editing field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the Editing field is set to the value of the last call.
func (b *RepositorySpecApplyConfiguration) WithEditing(value *EditingOptionsApplyConfiguration) *RepositorySpecApplyConfiguration {
b.Editing = value
// If called multiple times, the Sync field is set to the value of the last call.
func (b *RepositorySpecApplyConfiguration) WithSync(value *SyncOptionsApplyConfiguration) *RepositorySpecApplyConfiguration {
b.Sync = value
return b
}
@@ -77,14 +67,6 @@ func (b *RepositorySpecApplyConfiguration) WithType(value provisioningv0alpha1.R
return b
}
// WithLinting sets the Linting field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the Linting field is set to the value of the last call.
func (b *RepositorySpecApplyConfiguration) WithLinting(value bool) *RepositorySpecApplyConfiguration {
b.Linting = &value
return b
}
// WithLocal sets the Local field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the Local field is set to the value of the last call.
@@ -7,10 +7,11 @@ package v0alpha1
// RepositoryStatusApplyConfiguration represents a declarative configuration of the RepositoryStatus type for use
// with apply.
type RepositoryStatusApplyConfiguration struct {
ObservedGeneration *int64 `json:"observedGeneration,omitempty"`
Health *HealthStatusApplyConfiguration `json:"health,omitempty"`
Sync *SyncStatusApplyConfiguration `json:"sync,omitempty"`
Webhook *WebhookStatusApplyConfiguration `json:"webhook,omitempty"`
ObservedGeneration *int64 `json:"observedGeneration,omitempty"`
Health *HealthStatusApplyConfiguration `json:"health,omitempty"`
Sync *SyncStatusApplyConfiguration `json:"sync,omitempty"`
Stats []ResourceCountApplyConfiguration `json:"stats,omitempty"`
Webhook *WebhookStatusApplyConfiguration `json:"webhook,omitempty"`
}
// RepositoryStatusApplyConfiguration constructs a declarative configuration of the RepositoryStatus type for use with
@@ -43,6 +44,19 @@ func (b *RepositoryStatusApplyConfiguration) WithSync(value *SyncStatusApplyConf
return b
}
// WithStats adds the given value to the Stats field in the declarative configuration
// and returns the receiver, so that objects can be build by chaining "With" function invocations.
// If called multiple times, values provided by each call will be appended to the Stats field.
func (b *RepositoryStatusApplyConfiguration) WithStats(values ...*ResourceCountApplyConfiguration) *RepositoryStatusApplyConfiguration {
for i := range values {
if values[i] == nil {
panic("nil value passed to WithStats")
}
b.Stats = append(b.Stats, *values[i])
}
return b
}
// WithWebhook sets the Webhook field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the Webhook field is set to the value of the last call.
@@ -0,0 +1,52 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Code generated by applyconfiguration-gen. DO NOT EDIT.
package v0alpha1
// ResourceCountApplyConfiguration represents a declarative configuration of the ResourceCount type for use
// with apply.
type ResourceCountApplyConfiguration struct {
Repository *string `json:"repository,omitempty"`
Group *string `json:"group,omitempty"`
Resource *string `json:"resource,omitempty"`
Count *int64 `json:"count,omitempty"`
}
// ResourceCountApplyConfiguration constructs a declarative configuration of the ResourceCount type for use with
// apply.
func ResourceCount() *ResourceCountApplyConfiguration {
return &ResourceCountApplyConfiguration{}
}
// WithRepository sets the Repository field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the Repository field is set to the value of the last call.
func (b *ResourceCountApplyConfiguration) WithRepository(value string) *ResourceCountApplyConfiguration {
b.Repository = &value
return b
}
// WithGroup sets the Group field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the Group field is set to the value of the last call.
func (b *ResourceCountApplyConfiguration) WithGroup(value string) *ResourceCountApplyConfiguration {
b.Group = &value
return b
}
// WithResource sets the Resource field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the Resource field is set to the value of the last call.
func (b *ResourceCountApplyConfiguration) WithResource(value string) *ResourceCountApplyConfiguration {
b.Resource = &value
return b
}
// WithCount sets the Count field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the Count field is set to the value of the last call.
func (b *ResourceCountApplyConfiguration) WithCount(value int64) *ResourceCountApplyConfiguration {
b.Count = &value
return b
}
@@ -0,0 +1,47 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Code generated by applyconfiguration-gen. DO NOT EDIT.
package v0alpha1
import (
provisioningv0alpha1 "github.com/grafana/grafana/pkg/apis/provisioning/v0alpha1"
)
// SyncOptionsApplyConfiguration represents a declarative configuration of the SyncOptions type for use
// with apply.
type SyncOptionsApplyConfiguration struct {
Enabled *bool `json:"enabled,omitempty"`
Target *provisioningv0alpha1.SyncTargetType `json:"target,omitempty"`
IntervalSeconds *int64 `json:"intervalSeconds,omitempty"`
}
// SyncOptionsApplyConfiguration constructs a declarative configuration of the SyncOptions type for use with
// apply.
func SyncOptions() *SyncOptionsApplyConfiguration {
return &SyncOptionsApplyConfiguration{}
}
// WithEnabled sets the Enabled field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the Enabled field is set to the value of the last call.
func (b *SyncOptionsApplyConfiguration) WithEnabled(value bool) *SyncOptionsApplyConfiguration {
b.Enabled = &value
return b
}
// WithTarget sets the Target field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the Target field is set to the value of the last call.
func (b *SyncOptionsApplyConfiguration) WithTarget(value provisioningv0alpha1.SyncTargetType) *SyncOptionsApplyConfiguration {
b.Target = &value
return b
}
// WithIntervalSeconds sets the IntervalSeconds field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the IntervalSeconds field is set to the value of the last call.
func (b *SyncOptionsApplyConfiguration) WithIntervalSeconds(value int64) *SyncOptionsApplyConfiguration {
b.IntervalSeconds = &value
return b
}
@@ -11,13 +11,14 @@ import (
// SyncStatusApplyConfiguration represents a declarative configuration of the SyncStatus type for use
// with apply.
type SyncStatusApplyConfiguration struct {
State *provisioningv0alpha1.JobState `json:"state,omitempty"`
JobID *string `json:"job,omitempty"`
Started *int64 `json:"started,omitempty"`
Finished *int64 `json:"finished,omitempty"`
Scheduled *int64 `json:"scheduled,omitempty"`
Message []string `json:"message,omitempty"`
Hash *string `json:"hash,omitempty"`
State *provisioningv0alpha1.JobState `json:"state,omitempty"`
JobID *string `json:"job,omitempty"`
Started *int64 `json:"started,omitempty"`
Finished *int64 `json:"finished,omitempty"`
Scheduled *int64 `json:"scheduled,omitempty"`
Message []string `json:"message,omitempty"`
Hash *string `json:"hash,omitempty"`
Incremental *bool `json:"incremental,omitempty"`
}
// SyncStatusApplyConfiguration constructs a declarative configuration of the SyncStatus type for use with
@@ -83,3 +84,11 @@ func (b *SyncStatusApplyConfiguration) WithHash(value string) *SyncStatusApplyCo
b.Hash = &value
return b
}
// WithIncremental sets the Incremental field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the Incremental field is set to the value of the last call.
func (b *SyncStatusApplyConfiguration) WithIncremental(value bool) *SyncStatusApplyConfiguration {
b.Incremental = &value
return b
}
+4 -2
View File
@@ -20,8 +20,6 @@ import (
func ForKind(kind schema.GroupVersionKind) interface{} {
switch kind {
// Group=provisioning.grafana.app, Version=v0alpha1
case v0alpha1.SchemeGroupVersion.WithKind("EditingOptions"):
return &provisioningv0alpha1.EditingOptionsApplyConfiguration{}
case v0alpha1.SchemeGroupVersion.WithKind("GitHubRepositoryConfig"):
return &provisioningv0alpha1.GitHubRepositoryConfigApplyConfiguration{}
case v0alpha1.SchemeGroupVersion.WithKind("HealthStatus"):
@@ -34,8 +32,12 @@ func ForKind(kind schema.GroupVersionKind) interface{} {
return &provisioningv0alpha1.RepositorySpecApplyConfiguration{}
case v0alpha1.SchemeGroupVersion.WithKind("RepositoryStatus"):
return &provisioningv0alpha1.RepositoryStatusApplyConfiguration{}
case v0alpha1.SchemeGroupVersion.WithKind("ResourceCount"):
return &provisioningv0alpha1.ResourceCountApplyConfiguration{}
case v0alpha1.SchemeGroupVersion.WithKind("S3RepositoryConfig"):
return &provisioningv0alpha1.S3RepositoryConfigApplyConfiguration{}
case v0alpha1.SchemeGroupVersion.WithKind("SyncOptions"):
return &provisioningv0alpha1.SyncOptionsApplyConfiguration{}
case v0alpha1.SchemeGroupVersion.WithKind("SyncStatus"):
return &provisioningv0alpha1.SyncStatusApplyConfiguration{}
case v0alpha1.SchemeGroupVersion.WithKind("WebhookStatus"):