plugin-barman-cloud/test/e2e/internal/objectstore/objectstore.go
Marco Nenciarini 1be34fe13e
feat(ip): assign copyright to the Linux Foundation (#571)
Adopt the new attribution information for contributions to
CloudNativePG:

```
Copyright © contributors to CloudNativePG, established as
CloudNativePG a Series of LF Projects, LLC.
```

Adopt the SPDX format for Apache License 2.0

Signed-off-by: Marco Nenciarini <marco.nenciarini@enterprisedb.com>
Signed-off-by: Leonardo Cecchi <leonardo.cecchi@enterprisedb.com>
Co-authored-by: Leonardo Cecchi <leonardo.cecchi@enterprisedb.com>
2025-10-07 18:06:06 +02:00

69 lines
1.8 KiB
Go

/*
Copyright © contributors to CloudNativePG, established as
CloudNativePG a Series of LF Projects, LLC.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
SPDX-License-Identifier: Apache-2.0
*/
package objectstore
import (
"context"
"fmt"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
"sigs.k8s.io/controller-runtime/pkg/client"
)
const (
// DefaultSize is the default size of the PVCs for the object stores.
DefaultSize = "1Gi"
)
// Resources represents the resources required to create an object store.
type Resources struct {
Deployment *appsv1.Deployment
Service *corev1.Service
Secret *corev1.Secret
PVC *corev1.PersistentVolumeClaim
}
// Create creates the object store resources.
func (osr Resources) Create(ctx context.Context, cl client.Client) error {
if osr.PVC != nil {
if err := cl.Create(ctx, osr.PVC); err != nil {
return fmt.Errorf("failed to create PVC: %w", err)
}
}
if osr.Secret != nil {
if err := cl.Create(ctx, osr.Secret); err != nil {
return fmt.Errorf("failed to create secret: %w", err)
}
}
if osr.Deployment != nil {
if err := cl.Create(ctx, osr.Deployment); err != nil {
return fmt.Errorf("failed to create deployment: %w", err)
}
}
if osr.Service != nil {
if err := cl.Create(ctx, osr.Service); err != nil {
return fmt.Errorf("failed to create service: %w", err)
}
}
return nil
}