[Provisioning] Remove S3 Option (#100638)

Remove S3 option
This commit is contained in:
Roberto Jiménez Sánchez
2025-02-13 17:10:10 +01:00
committed by GitHub
parent cf78a43bd7
commit 18a938cf03
15 changed files with 22 additions and 324 deletions
@@ -39,8 +39,6 @@ var RepositoryResourceInfo = utils.NewResourceInfo(GROUP, VERSION,
switch m.Spec.Type {
case LocalRepositoryType:
target = m.Spec.Local.Path
case S3RepositoryType:
target = m.Spec.S3.Bucket
case GitHubRepositoryType:
target = m.Spec.GitHub.URL
}
+2 -16
View File
@@ -23,15 +23,6 @@ type LocalRepositoryConfig struct {
Path string `json:"path,omitempty"`
}
type S3RepositoryConfig struct {
Region string `json:"region,omitempty"`
Bucket string `json:"bucket,omitempty"`
// TODO: Add ACL?
// TODO: Encryption??
// TODO: How do we define access? Secrets?
}
// Workflow used for changes in the repository.
// +enum
type Workflow string
@@ -76,7 +67,6 @@ type RepositoryType string
// RepositoryType values
const (
LocalRepositoryType RepositoryType = "local"
S3RepositoryType RepositoryType = "s3"
GitHubRepositoryType RepositoryType = "github"
)
@@ -97,15 +87,11 @@ type RepositorySpec struct {
Type RepositoryType `json:"type"`
// The repository on the local file system.
// Mutually exclusive with local | s3 | github.
// Mutually exclusive with local | github.
Local *LocalRepositoryConfig `json:"local,omitempty"`
// The repository in an S3 bucket.
// Mutually exclusive with local | s3 | github.
S3 *S3RepositoryConfig `json:"s3,omitempty"`
// The repository on GitHub.
// Mutually exclusive with local | s3 | github.
// Mutually exclusive with local | github.
// TODO: github or just 'git'??
GitHub *GitHubRepositoryConfig `json:"github,omitempty"`
}
@@ -454,11 +454,6 @@ func (in *RepositorySpec) DeepCopyInto(out *RepositorySpec) {
*out = new(LocalRepositoryConfig)
**out = **in
}
if in.S3 != nil {
in, out := &in.S3, &out.S3
*out = new(S3RepositoryConfig)
**out = **in
}
if in.GitHub != nil {
in, out := &in.GitHub, &out.GitHub
*out = new(GitHubRepositoryConfig)
@@ -721,22 +716,6 @@ func (in *ResourceWrapper) DeepCopyObject() runtime.Object {
return nil
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *S3RepositoryConfig) DeepCopyInto(out *S3RepositoryConfig) {
*out = *in
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new S3RepositoryConfig.
func (in *S3RepositoryConfig) DeepCopy() *S3RepositoryConfig {
if in == nil {
return nil
}
out := new(S3RepositoryConfig)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *SyncJobOptions) DeepCopyInto(out *SyncJobOptions) {
*out = *in
@@ -43,7 +43,6 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA
"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.ResourceWrapper": schema_pkg_apis_provisioning_v0alpha1_ResourceWrapper(ref),
"github.com/grafana/grafana/pkg/apis/provisioning/v0alpha1.S3RepositoryConfig": schema_pkg_apis_provisioning_v0alpha1_S3RepositoryConfig(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),
"github.com/grafana/grafana/pkg/apis/provisioning/v0alpha1.SyncStatus": schema_pkg_apis_provisioning_v0alpha1_SyncStatus(ref),
@@ -989,28 +988,22 @@ func schema_pkg_apis_provisioning_v0alpha1_RepositorySpec(ref common.ReferenceCa
},
"type": {
SchemaProps: spec.SchemaProps{
Description: "The repository type. When selected oneOf the values below should be non-nil\n\nPossible enum values:\n - `\"github\"`\n - `\"local\"`\n - `\"s3\"`",
Description: "The repository type. When selected oneOf the values below should be non-nil\n\nPossible enum values:\n - `\"github\"`\n - `\"local\"`",
Default: "",
Type: []string{"string"},
Format: "",
Enum: []interface{}{"github", "local", "s3"},
Enum: []interface{}{"github", "local"},
},
},
"local": {
SchemaProps: spec.SchemaProps{
Description: "The repository on the local file system. Mutually exclusive with local | s3 | github.",
Description: "The repository on the local file system. Mutually exclusive with local | github.",
Ref: ref("github.com/grafana/grafana/pkg/apis/provisioning/v0alpha1.LocalRepositoryConfig"),
},
},
"s3": {
SchemaProps: spec.SchemaProps{
Description: "The repository in an S3 bucket. Mutually exclusive with local | s3 | github.",
Ref: ref("github.com/grafana/grafana/pkg/apis/provisioning/v0alpha1.S3RepositoryConfig"),
},
},
"github": {
SchemaProps: spec.SchemaProps{
Description: "The repository on GitHub. Mutually exclusive with local | s3 | github.",
Description: "The repository on GitHub. Mutually exclusive with local | github.",
Ref: ref("github.com/grafana/grafana/pkg/apis/provisioning/v0alpha1.GitHubRepositoryConfig"),
},
},
@@ -1019,7 +1012,7 @@ func schema_pkg_apis_provisioning_v0alpha1_RepositorySpec(ref common.ReferenceCa
},
},
Dependencies: []string{
"github.com/grafana/grafana/pkg/apis/provisioning/v0alpha1.GitHubRepositoryConfig", "github.com/grafana/grafana/pkg/apis/provisioning/v0alpha1.LocalRepositoryConfig", "github.com/grafana/grafana/pkg/apis/provisioning/v0alpha1.S3RepositoryConfig", "github.com/grafana/grafana/pkg/apis/provisioning/v0alpha1.SyncOptions"},
"github.com/grafana/grafana/pkg/apis/provisioning/v0alpha1.GitHubRepositoryConfig", "github.com/grafana/grafana/pkg/apis/provisioning/v0alpha1.LocalRepositoryConfig", "github.com/grafana/grafana/pkg/apis/provisioning/v0alpha1.SyncOptions"},
}
}
@@ -1118,11 +1111,11 @@ func schema_pkg_apis_provisioning_v0alpha1_RepositoryView(ref common.ReferenceCa
},
"type": {
SchemaProps: spec.SchemaProps{
Description: "The repository type\n\nPossible enum values:\n - `\"github\"`\n - `\"local\"`\n - `\"s3\"`",
Description: "The repository type\n\nPossible enum values:\n - `\"github\"`\n - `\"local\"`",
Default: "",
Type: []string{"string"},
Format: "",
Enum: []interface{}{"github", "local", "s3"},
Enum: []interface{}{"github", "local"},
},
},
"target": {
@@ -1604,30 +1597,6 @@ func schema_pkg_apis_provisioning_v0alpha1_ResourceWrapper(ref common.ReferenceC
}
}
func schema_pkg_apis_provisioning_v0alpha1_S3RepositoryConfig(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
Type: []string{"object"},
Properties: map[string]spec.Schema{
"region": {
SchemaProps: spec.SchemaProps{
Type: []string{"string"},
Format: "",
},
},
"bucket": {
SchemaProps: spec.SchemaProps{
Type: []string{"string"},
Format: "",
},
},
},
},
},
}
}
func schema_pkg_apis_provisioning_v0alpha1_SyncJobOptions(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
@@ -17,7 +17,6 @@ type RepositorySpecApplyConfiguration struct {
Sync *SyncOptionsApplyConfiguration `json:"sync,omitempty"`
Type *provisioningv0alpha1.RepositoryType `json:"type,omitempty"`
Local *LocalRepositoryConfigApplyConfiguration `json:"local,omitempty"`
S3 *S3RepositoryConfigApplyConfiguration `json:"s3,omitempty"`
GitHub *GitHubRepositoryConfigApplyConfiguration `json:"github,omitempty"`
}
@@ -75,14 +74,6 @@ func (b *RepositorySpecApplyConfiguration) WithLocal(value *LocalRepositoryConfi
return b
}
// WithS3 sets the S3 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 S3 field is set to the value of the last call.
func (b *RepositorySpecApplyConfiguration) WithS3(value *S3RepositoryConfigApplyConfiguration) *RepositorySpecApplyConfiguration {
b.S3 = value
return b
}
// WithGitHub sets the GitHub 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 GitHub field is set to the value of the last call.
@@ -1,34 +0,0 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Code generated by applyconfiguration-gen. DO NOT EDIT.
package v0alpha1
// S3RepositoryConfigApplyConfiguration represents a declarative configuration of the S3RepositoryConfig type for use
// with apply.
type S3RepositoryConfigApplyConfiguration struct {
Region *string `json:"region,omitempty"`
Bucket *string `json:"bucket,omitempty"`
}
// S3RepositoryConfigApplyConfiguration constructs a declarative configuration of the S3RepositoryConfig type for use with
// apply.
func S3RepositoryConfig() *S3RepositoryConfigApplyConfiguration {
return &S3RepositoryConfigApplyConfiguration{}
}
// WithRegion sets the Region 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 Region field is set to the value of the last call.
func (b *S3RepositoryConfigApplyConfiguration) WithRegion(value string) *S3RepositoryConfigApplyConfiguration {
b.Region = &value
return b
}
// WithBucket sets the Bucket 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 Bucket field is set to the value of the last call.
func (b *S3RepositoryConfigApplyConfiguration) WithBucket(value string) *S3RepositoryConfigApplyConfiguration {
b.Bucket = &value
return b
}
@@ -34,8 +34,6 @@ func ForKind(kind schema.GroupVersionKind) interface{} {
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"):
@@ -332,8 +332,6 @@ func (b *APIBuilder) AsRepository(ctx context.Context, r *provisioning.Repositor
r.GetName(),
)
return repository.NewGitHub(ctx, r, b.ghFactory, b.secrets, webhookURL)
case provisioning.S3RepositoryType:
return repository.NewS3(r), nil
default:
return repository.NewUnknown(r), nil
}
@@ -1,121 +0,0 @@
package repository
import (
"context"
"net/http"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/validation/field"
provisioning "github.com/grafana/grafana/pkg/apis/provisioning/v0alpha1"
)
type s3Repository struct {
config *provisioning.Repository
}
var _ Repository = (*s3Repository)(nil)
func NewS3(config *provisioning.Repository) *s3Repository {
return &s3Repository{config}
}
func (r *s3Repository) Config() *provisioning.Repository {
return r.config
}
// Validate implements provisioning.Repository.
func (r *s3Repository) Validate() (list field.ErrorList) {
s3 := r.Config().Spec.S3
if s3 == nil {
list = append(list, field.Required(field.NewPath("spec", "s3"), "an s3 config is required"))
return
}
if s3.Region == "" {
list = append(list, field.Required(field.NewPath("spec", "s3", "region"), "an s3 region is required"))
}
if s3.Bucket == "" {
list = append(list, field.Required(field.NewPath("spec", "s3", "bucket"), "an s3 bucket name is required"))
}
return
}
// Test implements provisioning.Repository.
func (r *s3Repository) Test(ctx context.Context) (*provisioning.TestResults, error) {
return nil, &errors.StatusError{
ErrStatus: metav1.Status{
Message: "test is not yet implemented",
Code: http.StatusNotImplemented,
},
}
}
// ReadResource implements provisioning.Repository.
func (r *s3Repository) Read(ctx context.Context, path string, ref string) (*FileInfo, error) {
return nil, &errors.StatusError{
ErrStatus: metav1.Status{
Message: "read resource is not yet implemented",
Code: http.StatusNotImplemented,
},
}
}
func (r *s3Repository) ReadTree(ctx context.Context, ref string) ([]FileTreeEntry, error) {
return nil, &errors.StatusError{
ErrStatus: metav1.Status{
Message: "read file tree resource is not yet implemented",
Code: http.StatusNotImplemented,
},
}
}
func (r *s3Repository) Create(ctx context.Context, path string, ref string, data []byte, comment string) error {
return &errors.StatusError{
ErrStatus: metav1.Status{
Message: "write file is not yet implemented",
Code: http.StatusNotImplemented,
},
}
}
func (r *s3Repository) Update(ctx context.Context, path string, ref string, data []byte, comment string) error {
return &errors.StatusError{
ErrStatus: metav1.Status{
Message: "write file is not yet implemented",
Code: http.StatusNotImplemented,
},
}
}
func (r *s3Repository) Delete(ctx context.Context, path string, ref string, comment string) error {
return &errors.StatusError{
ErrStatus: metav1.Status{
Message: "delete file not yet implemented",
Code: http.StatusNotImplemented,
},
}
}
func (r *s3Repository) Write(ctx context.Context, path string, ref string, data []byte, message string) error {
return writeWithReadThenCreateOrUpdate(ctx, r, path, ref, data, message)
}
func (r *s3Repository) History(ctx context.Context, path string, ref string) ([]provisioning.HistoryItem, error) {
return nil, &errors.StatusError{
ErrStatus: metav1.Status{
Message: "history is not yet implemented",
Code: http.StatusNotImplemented,
},
}
}
// Webhook implements Repository.
func (r *s3Repository) Webhook(ctx context.Context, req *http.Request) (*provisioning.WebhookResponse, error) {
return nil, &errors.StatusError{
ErrStatus: metav1.Status{
Code: http.StatusNotImplemented,
Message: "webhook not implemented",
},
}
}
@@ -70,9 +70,5 @@ func ValidateRepository(repo Repository) field.ErrorList {
cfg.Spec.GitHub, "Github config only valid when type is github"))
}
if cfg.Spec.Type != provisioning.S3RepositoryType && cfg.Spec.S3 != nil {
list = append(list, field.Invalid(field.NewPath("spec", "s3"),
cfg.Spec.GitHub, "S3 config only valid when type is s3"))
}
return list
}
@@ -3308,7 +3308,7 @@
"type": "string"
},
"github": {
"description": "The repository on GitHub. Mutually exclusive with local | s3 | github.",
"description": "The repository on GitHub. Mutually exclusive with local | github.",
"allOf": [
{
"$ref": "#/components/schemas/com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1.GitHubRepositoryConfig"
@@ -3316,7 +3316,7 @@
]
},
"local": {
"description": "The repository on the local file system. Mutually exclusive with local | s3 | github.",
"description": "The repository on the local file system. Mutually exclusive with local | github.",
"allOf": [
{
"$ref": "#/components/schemas/com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1.LocalRepositoryConfig"
@@ -3328,14 +3328,6 @@
"type": "boolean",
"default": false
},
"s3": {
"description": "The repository in an S3 bucket. Mutually exclusive with local | s3 | github.",
"allOf": [
{
"$ref": "#/components/schemas/com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1.S3RepositoryConfig"
}
]
},
"sync": {
"description": "Sync settings -- how values are pulled from the repository into grafana",
"default": {},
@@ -3351,13 +3343,12 @@
"default": ""
},
"type": {
"description": "The repository type. When selected oneOf the values below should be non-nil\n\nPossible enum values:\n - `\"github\"`\n - `\"local\"`\n - `\"s3\"`",
"description": "The repository type. When selected oneOf the values below should be non-nil\n\nPossible enum values:\n - `\"github\"`\n - `\"local\"`",
"type": "string",
"default": "",
"enum": [
"github",
"local",
"s3"
"local"
]
}
}
@@ -3454,13 +3445,12 @@
"default": ""
},
"type": {
"description": "The repository type\n\nPossible enum values:\n - `\"github\"`\n - `\"local\"`\n - `\"s3\"`",
"description": "The repository type\n\nPossible enum values:\n - `\"github\"`\n - `\"local\"`",
"type": "string",
"default": "",
"enum": [
"github",
"local",
"s3"
"local"
]
}
}
@@ -3797,17 +3787,6 @@
}
]
},
"com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1.S3RepositoryConfig": {
"type": "object",
"properties": {
"bucket": {
"type": "string"
},
"region": {
"type": "string"
}
}
},
"com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1.SyncJobOptions": {
"type": "object",
"required": [
@@ -136,7 +136,6 @@ func TestIntegrationProvisioning(t *testing.T) {
"testdata/local-devenv.json",
"testdata/local-tmp.json",
"testdata/local-xxx.json",
"testdata/s3-example.json",
} {
t.Run(inputFilePath, func(t *testing.T) {
input := helper.LoadYAMLOrJSONFile(inputFilePath)
-22
View File
@@ -1,22 +0,0 @@
{
"apiVersion": "provisioning.grafana.app/v0alpha1",
"kind": "Repository",
"metadata": {
"name": "s3-example"
},
"spec": {
"description": "load resources from an S3 bucket",
"s3": {
"bucket": "my-bucket",
"region": "us-west-1"
},
"sync": {
"enabled": false,
"target": "folder",
"intervalSeconds": 60
},
"readOnly": false,
"title": "S3 Example",
"type": "s3"
}
}
@@ -25,7 +25,7 @@ import { useCreateOrUpdateRepository } from './hooks';
import { RepositoryFormData, WorkflowOption } from './types';
import { dataToSpec, specToData } from './utils/data';
const typeOptions = ['GitHub', 'Local', 'S3'].map((label) => ({ label, value: label.toLowerCase() }));
const typeOptions = ['GitHub', 'Local'].map((label) => ({ label, value: label.toLowerCase() }));
const targetOptions = [
{ value: 'instance', label: 'Entire instance' },
{ value: 'folder', label: 'Managed folder' },
@@ -201,16 +201,6 @@ export function ConfigForm({ data }: ConfigFormProps) {
</Field>
)}
{type === 's3' && (
<FieldSet label="local">
<Field label={'S3 bucket'} error={errors?.bucket?.message} invalid={!!errors?.bucket}>
<Input {...register('bucket', { required: 'This field is required.' })} placeholder={'bucket-name'} />
</Field>
<Field label={'S3 region'} error={errors?.region?.message} invalid={!!errors?.region}>
<Input {...register('region', { required: 'This field is required.' })} placeholder={'us-west-2'} />
</Field>
</FieldSet>
)}
<FieldSet label="Sync Settings">
<Field label={'Enabled'} description={'Once sync is enabled, the target cannot be changed.'}>
<Switch {...register('sync.enabled')} id={'sync.enabled'} />
@@ -751,10 +751,6 @@ export type GitHubRepositoryConfig = {
export type LocalRepositoryConfig = {
path?: string;
};
export type S3RepositoryConfig = {
bucket?: string;
region?: string;
};
export type SyncOptions = {
/** Enabled must be saved as true before any sync job will run */
enabled: boolean;
@@ -770,14 +766,12 @@ export type SyncOptions = {
export type RepositorySpec = {
/** Repository description */
description?: string;
/** The repository on GitHub. Mutually exclusive with local | s3 | github. */
/** The repository on GitHub. Mutually exclusive with local | github. */
github?: GitHubRepositoryConfig;
/** The repository on the local file system. Mutually exclusive with local | s3 | github. */
/** The repository on the local file system. Mutually exclusive with local | github. */
local?: LocalRepositoryConfig;
/** ReadOnly repository does not allow any write commands */
readOnly: boolean;
/** The repository in an S3 bucket. Mutually exclusive with local | s3 | github. */
s3?: S3RepositoryConfig;
/** Sync settings -- how values are pulled from the repository into grafana */
sync: SyncOptions;
/** The repository display name (shown in the UI) */
@@ -786,9 +780,8 @@ export type RepositorySpec = {
Possible enum values:
- `"github"`
- `"local"`
- `"s3"` */
type: 'github' | 'local' | 's3';
- `"local"` */
type: 'github' | 'local';
};
export type HealthStatus = {
/** When the health was checked last time */
@@ -1059,9 +1052,8 @@ export type RepositoryView = {
Possible enum values:
- `"github"`
- `"local"`
- `"s3"` */
type: 'github' | 'local' | 's3';
- `"local"` */
type: 'github' | 'local';
};
export type RepositoryViewList = {
/** APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources */