mirror of
https://github.com/cloudnative-pg/plugin-barman-cloud.git
synced 2026-01-11 21:23:12 +01:00
chore: fix linter complaints
Signed-off-by: Francesco Canovai <francesco.canovai@enterprisedb.com>
This commit is contained in:
parent
4889612e46
commit
f30afb83eb
@ -25,10 +25,10 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// GroupVersion is group version used to register these objects
|
// GroupVersion is group version used to register these objects.
|
||||||
GroupVersion = schema.GroupVersion{Group: "barmancloud.cnpg.io", Version: "v1"}
|
GroupVersion = schema.GroupVersion{Group: "barmancloud.cnpg.io", Version: "v1"}
|
||||||
|
|
||||||
// SchemeBuilder is used to add go types to the GroupVersionKind scheme
|
// SchemeBuilder is used to add go types to the GroupVersionKind scheme.
|
||||||
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
|
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
|
||||||
|
|
||||||
// AddToScheme adds the types in this group-version to the given scheme.
|
// AddToScheme adds the types in this group-version to the given scheme.
|
||||||
|
|||||||
@ -17,22 +17,21 @@ limitations under the License.
|
|||||||
package v1
|
package v1
|
||||||
|
|
||||||
import (
|
import (
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
||||||
|
|
||||||
barmanapi "github.com/cloudnative-pg/barman-cloud/pkg/api"
|
barmanapi "github.com/cloudnative-pg/barman-cloud/pkg/api"
|
||||||
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
|
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
|
||||||
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
|
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
|
||||||
|
|
||||||
// ObjectStoreSpec defines the desired state of ObjectStore
|
// ObjectStoreSpec defines the desired state of ObjectStore.
|
||||||
type ObjectStoreSpec struct {
|
type ObjectStoreSpec struct {
|
||||||
Configuration barmanapi.BarmanObjectStoreConfiguration `json:"configuration"`
|
Configuration barmanapi.BarmanObjectStoreConfiguration `json:"configuration"`
|
||||||
|
|
||||||
// TODO: we add here any exclusive fields for our plugin CRD
|
// TODO: we add here any exclusive fields for our plugin CRD
|
||||||
}
|
}
|
||||||
|
|
||||||
// ObjectStoreStatus defines the observed state of ObjectStore
|
// ObjectStoreStatus defines the observed state of ObjectStore.
|
||||||
type ObjectStoreStatus struct {
|
type ObjectStoreStatus struct {
|
||||||
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
|
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
|
||||||
// Important: Run "make" to regenerate code after modifying this file
|
// Important: Run "make" to regenerate code after modifying this file
|
||||||
@ -41,7 +40,7 @@ type ObjectStoreStatus struct {
|
|||||||
// +kubebuilder:object:root=true
|
// +kubebuilder:object:root=true
|
||||||
// +kubebuilder:subresource:status
|
// +kubebuilder:subresource:status
|
||||||
|
|
||||||
// ObjectStore is the Schema for the objectstores API
|
// ObjectStore is the Schema for the objectstores API.
|
||||||
type ObjectStore struct {
|
type ObjectStore struct {
|
||||||
metav1.TypeMeta `json:",inline"`
|
metav1.TypeMeta `json:",inline"`
|
||||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||||
@ -52,7 +51,7 @@ type ObjectStore struct {
|
|||||||
|
|
||||||
// +kubebuilder:object:root=true
|
// +kubebuilder:object:root=true
|
||||||
|
|
||||||
// ObjectStoreList contains a list of ObjectStore
|
// ObjectStoreList contains a list of ObjectStore.
|
||||||
type ObjectStoreList struct {
|
type ObjectStoreList struct {
|
||||||
metav1.TypeMeta `json:",inline"`
|
metav1.TypeMeta `json:",inline"`
|
||||||
metav1.ListMeta `json:"metadata,omitempty"`
|
metav1.ListMeta `json:"metadata,omitempty"`
|
||||||
|
|||||||
13
cmd/main.go
13
cmd/main.go
@ -21,12 +21,7 @@ import (
|
|||||||
"flag"
|
"flag"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/cloudnative-pg/plugin-barman-cloud/internal/cnpgi/operator"
|
// +kubebuilder:scaffold:imports
|
||||||
|
|
||||||
// Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.)
|
|
||||||
// to ensure that exec-entrypoint and run can make use of them.
|
|
||||||
_ "k8s.io/client-go/plugin/pkg/client/auth"
|
|
||||||
|
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
|
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
|
||||||
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
|
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
|
||||||
@ -38,8 +33,12 @@ import (
|
|||||||
"sigs.k8s.io/controller-runtime/pkg/webhook"
|
"sigs.k8s.io/controller-runtime/pkg/webhook"
|
||||||
|
|
||||||
barmancloudv1 "github.com/cloudnative-pg/plugin-barman-cloud/api/v1"
|
barmancloudv1 "github.com/cloudnative-pg/plugin-barman-cloud/api/v1"
|
||||||
|
"github.com/cloudnative-pg/plugin-barman-cloud/internal/cnpgi/operator"
|
||||||
"github.com/cloudnative-pg/plugin-barman-cloud/internal/controller"
|
"github.com/cloudnative-pg/plugin-barman-cloud/internal/controller"
|
||||||
// +kubebuilder:scaffold:imports
|
|
||||||
|
// Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.)
|
||||||
|
// to ensure that exec-entrypoint and run can make use of them.
|
||||||
|
_ "k8s.io/client-go/plugin/pkg/client/auth"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|||||||
@ -10,7 +10,9 @@ type BackupServiceImplementation struct {
|
|||||||
backup.UnimplementedBackupServer
|
backup.UnimplementedBackupServer
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b BackupServiceImplementation) GetCapabilities(ctx context.Context, request *backup.BackupCapabilitiesRequest) (*backup.BackupCapabilitiesResult, error) {
|
func (b BackupServiceImplementation) GetCapabilities(
|
||||||
|
_ context.Context, _ *backup.BackupCapabilitiesRequest,
|
||||||
|
) (*backup.BackupCapabilitiesResult, error) {
|
||||||
return &backup.BackupCapabilitiesResult{
|
return &backup.BackupCapabilitiesResult{
|
||||||
Capabilities: []*backup.BackupCapability{
|
Capabilities: []*backup.BackupCapability{
|
||||||
{
|
{
|
||||||
@ -24,7 +26,7 @@ func (b BackupServiceImplementation) GetCapabilities(ctx context.Context, reques
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b BackupServiceImplementation) Backup(ctx context.Context, request *backup.BackupRequest) (*backup.BackupResult, error) {
|
func (b BackupServiceImplementation) Backup(_ context.Context, _ *backup.BackupRequest) (*backup.BackupResult, error) {
|
||||||
// TODO implement me
|
// TODO implement me
|
||||||
panic("implement me")
|
panic("implement me")
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,11 +1,10 @@
|
|||||||
package instance
|
package instance
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/spf13/cobra"
|
|
||||||
|
|
||||||
"github.com/cloudnative-pg/cnpg-i-machinery/pkg/pluginhelper/http"
|
"github.com/cloudnative-pg/cnpg-i-machinery/pkg/pluginhelper/http"
|
||||||
"github.com/cloudnative-pg/cnpg-i/pkg/backup"
|
"github.com/cloudnative-pg/cnpg-i/pkg/backup"
|
||||||
"github.com/cloudnative-pg/cnpg-i/pkg/wal"
|
"github.com/cloudnative-pg/cnpg-i/pkg/wal"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -18,5 +17,6 @@ func NewCMD() *cobra.Command {
|
|||||||
})
|
})
|
||||||
|
|
||||||
cmd.Use = "plugin-instance"
|
cmd.Use = "plugin-instance"
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import "github.com/cloudnative-pg/cnpg-i/pkg/identity"
|
|||||||
|
|
||||||
const PluginName = "instance.barman-cloud.cloudnative-pg.io"
|
const PluginName = "instance.barman-cloud.cloudnative-pg.io"
|
||||||
|
|
||||||
// Data is the metadata of this plugin
|
// Data is the metadata of this plugin.
|
||||||
var Data = identity.GetPluginMetadataResponse{
|
var Data = identity.GetPluginMetadataResponse{
|
||||||
Name: PluginName,
|
Name: PluginName,
|
||||||
Version: "0.0.1",
|
Version: "0.0.1",
|
||||||
|
|||||||
@ -11,15 +11,15 @@ type IdentityImplementation struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (i IdentityImplementation) GetPluginMetadata(
|
func (i IdentityImplementation) GetPluginMetadata(
|
||||||
ctx context.Context,
|
_ context.Context,
|
||||||
request *identity.GetPluginMetadataRequest,
|
_ *identity.GetPluginMetadataRequest,
|
||||||
) (*identity.GetPluginMetadataResponse, error) {
|
) (*identity.GetPluginMetadataResponse, error) {
|
||||||
return &Data, nil
|
return &Data, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i IdentityImplementation) GetPluginCapabilities(
|
func (i IdentityImplementation) GetPluginCapabilities(
|
||||||
ctx context.Context,
|
_ context.Context,
|
||||||
request *identity.GetPluginCapabilitiesRequest,
|
_ *identity.GetPluginCapabilitiesRequest,
|
||||||
) (*identity.GetPluginCapabilitiesResponse, error) {
|
) (*identity.GetPluginCapabilitiesResponse, error) {
|
||||||
return &identity.GetPluginCapabilitiesResponse{
|
return &identity.GetPluginCapabilitiesResponse{
|
||||||
Capabilities: []*identity.PluginCapability{
|
Capabilities: []*identity.PluginCapability{
|
||||||
@ -42,8 +42,8 @@ func (i IdentityImplementation) GetPluginCapabilities(
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (i IdentityImplementation) Probe(
|
func (i IdentityImplementation) Probe(
|
||||||
ctx context.Context,
|
_ context.Context,
|
||||||
request *identity.ProbeRequest,
|
_ *identity.ProbeRequest,
|
||||||
) (*identity.ProbeResponse, error) {
|
) (*identity.ProbeResponse, error) {
|
||||||
return &identity.ProbeResponse{
|
return &identity.ProbeResponse{
|
||||||
Ready: true,
|
Ready: true,
|
||||||
|
|||||||
@ -10,7 +10,9 @@ type WALServiceImplementation struct {
|
|||||||
wal.UnimplementedWALServer
|
wal.UnimplementedWALServer
|
||||||
}
|
}
|
||||||
|
|
||||||
func (W WALServiceImplementation) GetCapabilities(ctx context.Context, request *wal.WALCapabilitiesRequest) (*wal.WALCapabilitiesResult, error) {
|
func (w WALServiceImplementation) GetCapabilities(
|
||||||
|
_ context.Context, _ *wal.WALCapabilitiesRequest,
|
||||||
|
) (*wal.WALCapabilitiesResult, error) {
|
||||||
return &wal.WALCapabilitiesResult{
|
return &wal.WALCapabilitiesResult{
|
||||||
Capabilities: []*wal.WALCapability{
|
Capabilities: []*wal.WALCapability{
|
||||||
{
|
{
|
||||||
@ -31,22 +33,30 @@ func (W WALServiceImplementation) GetCapabilities(ctx context.Context, request *
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (W WALServiceImplementation) Archive(ctx context.Context, request *wal.WALArchiveRequest) (*wal.WALArchiveResult, error) {
|
func (w WALServiceImplementation) Archive(_ context.Context, _ *wal.WALArchiveRequest) (*wal.WALArchiveResult,
|
||||||
|
error,
|
||||||
|
) {
|
||||||
// TODO implement me
|
// TODO implement me
|
||||||
panic("implement me")
|
panic("implement me")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (W WALServiceImplementation) Restore(ctx context.Context, request *wal.WALRestoreRequest) (*wal.WALRestoreResult, error) {
|
func (w WALServiceImplementation) Restore(_ context.Context, _ *wal.WALRestoreRequest) (*wal.WALRestoreResult,
|
||||||
|
error,
|
||||||
|
) {
|
||||||
// TODO implement me
|
// TODO implement me
|
||||||
panic("implement me")
|
panic("implement me")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (W WALServiceImplementation) Status(ctx context.Context, request *wal.WALStatusRequest) (*wal.WALStatusResult, error) {
|
func (w WALServiceImplementation) Status(_ context.Context, _ *wal.WALStatusRequest) (*wal.WALStatusResult,
|
||||||
|
error,
|
||||||
|
) {
|
||||||
// TODO implement me
|
// TODO implement me
|
||||||
panic("implement me")
|
panic("implement me")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (W WALServiceImplementation) SetFirstRequired(ctx context.Context, request *wal.SetFirstRequiredRequest) (*wal.SetFirstRequiredResult, error) {
|
func (w WALServiceImplementation) SetFirstRequired(
|
||||||
|
_ context.Context, _ *wal.SetFirstRequiredRequest,
|
||||||
|
) (*wal.SetFirstRequiredResult, error) {
|
||||||
// TODO implement me
|
// TODO implement me
|
||||||
panic("implement me")
|
panic("implement me")
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import "github.com/cloudnative-pg/cnpg-i/pkg/identity"
|
|||||||
|
|
||||||
const PluginName = "operator.barman-cloud.cloudnative-pg.io"
|
const PluginName = "operator.barman-cloud.cloudnative-pg.io"
|
||||||
|
|
||||||
// Data is the metadata of this plugin
|
// Data is the metadata of this plugin.
|
||||||
var Data = identity.GetPluginMetadataResponse{
|
var Data = identity.GetPluginMetadataResponse{
|
||||||
Name: PluginName,
|
Name: PluginName,
|
||||||
Version: "0.0.1",
|
Version: "0.0.1",
|
||||||
|
|||||||
@ -11,15 +11,15 @@ type IdentityImplementation struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (i IdentityImplementation) GetPluginMetadata(
|
func (i IdentityImplementation) GetPluginMetadata(
|
||||||
ctx context.Context,
|
_ context.Context,
|
||||||
request *identity.GetPluginMetadataRequest,
|
_ *identity.GetPluginMetadataRequest,
|
||||||
) (*identity.GetPluginMetadataResponse, error) {
|
) (*identity.GetPluginMetadataResponse, error) {
|
||||||
return &Data, nil
|
return &Data, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i IdentityImplementation) GetPluginCapabilities(
|
func (i IdentityImplementation) GetPluginCapabilities(
|
||||||
ctx context.Context,
|
_ context.Context,
|
||||||
request *identity.GetPluginCapabilitiesRequest,
|
_ *identity.GetPluginCapabilitiesRequest,
|
||||||
) (*identity.GetPluginCapabilitiesResponse, error) {
|
) (*identity.GetPluginCapabilitiesResponse, error) {
|
||||||
return &identity.GetPluginCapabilitiesResponse{
|
return &identity.GetPluginCapabilitiesResponse{
|
||||||
Capabilities: []*identity.PluginCapability{
|
Capabilities: []*identity.PluginCapability{
|
||||||
@ -42,8 +42,8 @@ func (i IdentityImplementation) GetPluginCapabilities(
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (i IdentityImplementation) Probe(
|
func (i IdentityImplementation) Probe(
|
||||||
ctx context.Context,
|
_ context.Context,
|
||||||
request *identity.ProbeRequest,
|
_ *identity.ProbeRequest,
|
||||||
) (*identity.ProbeResponse, error) {
|
) (*identity.ProbeResponse, error) {
|
||||||
return &identity.ProbeResponse{
|
return &identity.ProbeResponse{
|
||||||
Ready: true,
|
Ready: true,
|
||||||
|
|||||||
@ -11,8 +11,8 @@ type ReconcilerImplementation struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (r ReconcilerImplementation) GetCapabilities(
|
func (r ReconcilerImplementation) GetCapabilities(
|
||||||
ctx context.Context,
|
_ context.Context,
|
||||||
request *reconciler.ReconcilerHooksCapabilitiesRequest,
|
_ *reconciler.ReconcilerHooksCapabilitiesRequest,
|
||||||
) (*reconciler.ReconcilerHooksCapabilitiesResult, error) {
|
) (*reconciler.ReconcilerHooksCapabilitiesResult, error) {
|
||||||
return &reconciler.ReconcilerHooksCapabilitiesResult{
|
return &reconciler.ReconcilerHooksCapabilitiesResult{
|
||||||
ReconcilerCapabilities: []*reconciler.ReconcilerHooksCapability{
|
ReconcilerCapabilities: []*reconciler.ReconcilerHooksCapability{
|
||||||
@ -27,8 +27,8 @@ func (r ReconcilerImplementation) GetCapabilities(
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (r ReconcilerImplementation) Pre(
|
func (r ReconcilerImplementation) Pre(
|
||||||
ctx context.Context,
|
_ context.Context,
|
||||||
request *reconciler.ReconcilerHooksRequest,
|
_ *reconciler.ReconcilerHooksRequest,
|
||||||
) (*reconciler.ReconcilerHooksResult, error) {
|
) (*reconciler.ReconcilerHooksResult, error) {
|
||||||
return &reconciler.ReconcilerHooksResult{
|
return &reconciler.ReconcilerHooksResult{
|
||||||
Behavior: reconciler.ReconcilerHooksResult_BEHAVIOR_CONTINUE,
|
Behavior: reconciler.ReconcilerHooksResult_BEHAVIOR_CONTINUE,
|
||||||
@ -36,8 +36,8 @@ func (r ReconcilerImplementation) Pre(
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (r ReconcilerImplementation) Post(
|
func (r ReconcilerImplementation) Post(
|
||||||
ctx context.Context,
|
_ context.Context,
|
||||||
request *reconciler.ReconcilerHooksRequest,
|
_ *reconciler.ReconcilerHooksRequest,
|
||||||
) (*reconciler.ReconcilerHooksResult, error) {
|
) (*reconciler.ReconcilerHooksResult, error) {
|
||||||
return &reconciler.ReconcilerHooksResult{
|
return &reconciler.ReconcilerHooksResult{
|
||||||
Behavior: reconciler.ReconcilerHooksResult_BEHAVIOR_CONTINUE,
|
Behavior: reconciler.ReconcilerHooksResult_BEHAVIOR_CONTINUE,
|
||||||
|
|||||||
@ -20,5 +20,5 @@ func (c *CNPGI) Start(ctx context.Context) error {
|
|||||||
})
|
})
|
||||||
cmd.Use = "plugin-operator"
|
cmd.Use = "plugin-operator"
|
||||||
|
|
||||||
return cmd.ExecuteContext(ctx)
|
return cmd.ExecuteContext(ctx) //nolint:wrapcheck
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,6 +18,7 @@ package controller
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
ctrl "sigs.k8s.io/controller-runtime"
|
ctrl "sigs.k8s.io/controller-runtime"
|
||||||
@ -27,7 +28,7 @@ import (
|
|||||||
barmancloudv1 "github.com/cloudnative-pg/plugin-barman-cloud/api/v1"
|
barmancloudv1 "github.com/cloudnative-pg/plugin-barman-cloud/api/v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ObjectStoreReconciler reconciles a ObjectStore object
|
// ObjectStoreReconciler reconciles a ObjectStore object.
|
||||||
type ObjectStoreReconciler struct {
|
type ObjectStoreReconciler struct {
|
||||||
client.Client
|
client.Client
|
||||||
Scheme *runtime.Scheme
|
Scheme *runtime.Scheme
|
||||||
@ -46,7 +47,7 @@ type ObjectStoreReconciler struct {
|
|||||||
//
|
//
|
||||||
// For more details, check Reconcile and its Result here:
|
// For more details, check Reconcile and its Result here:
|
||||||
// - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.19.0/pkg/reconcile
|
// - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.19.0/pkg/reconcile
|
||||||
func (r *ObjectStoreReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
|
func (r *ObjectStoreReconciler) Reconcile(ctx context.Context, _ ctrl.Request) (ctrl.Result, error) {
|
||||||
_ = log.FromContext(ctx)
|
_ = log.FromContext(ctx)
|
||||||
|
|
||||||
// TODO(user): your logic here
|
// TODO(user): your logic here
|
||||||
@ -56,7 +57,12 @@ func (r *ObjectStoreReconciler) Reconcile(ctx context.Context, req ctrl.Request)
|
|||||||
|
|
||||||
// SetupWithManager sets up the controller with the Manager.
|
// SetupWithManager sets up the controller with the Manager.
|
||||||
func (r *ObjectStoreReconciler) SetupWithManager(mgr ctrl.Manager) error {
|
func (r *ObjectStoreReconciler) SetupWithManager(mgr ctrl.Manager) error {
|
||||||
return ctrl.NewControllerManagedBy(mgr).
|
err := ctrl.NewControllerManagedBy(mgr).
|
||||||
For(&barmancloudv1.ObjectStore{}).
|
For(&barmancloudv1.ObjectStore{}).
|
||||||
Complete(r)
|
Complete(r)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("unable to create controller: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,15 +19,16 @@ package controller
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
. "github.com/onsi/ginkgo/v2"
|
barmanapi "github.com/cloudnative-pg/barman-cloud/pkg/api"
|
||||||
. "github.com/onsi/gomega"
|
|
||||||
"k8s.io/apimachinery/pkg/api/errors"
|
"k8s.io/apimachinery/pkg/api/errors"
|
||||||
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/types"
|
"k8s.io/apimachinery/pkg/types"
|
||||||
"sigs.k8s.io/controller-runtime/pkg/reconcile"
|
"sigs.k8s.io/controller-runtime/pkg/reconcile"
|
||||||
|
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
||||||
|
|
||||||
barmancloudv1 "github.com/cloudnative-pg/plugin-barman-cloud/api/v1"
|
barmancloudv1 "github.com/cloudnative-pg/plugin-barman-cloud/api/v1"
|
||||||
|
|
||||||
|
. "github.com/onsi/ginkgo/v2"
|
||||||
|
. "github.com/onsi/gomega"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ = Describe("ObjectStore Controller", func() {
|
var _ = Describe("ObjectStore Controller", func() {
|
||||||
@ -51,6 +52,9 @@ var _ = Describe("ObjectStore Controller", func() {
|
|||||||
Name: resourceName,
|
Name: resourceName,
|
||||||
Namespace: "default",
|
Namespace: "default",
|
||||||
},
|
},
|
||||||
|
Spec: barmancloudv1.ObjectStoreSpec{
|
||||||
|
Configuration: barmanapi.BarmanObjectStoreConfiguration{DestinationPath: "/tmp"},
|
||||||
|
},
|
||||||
// TODO(user): Specify other spec details if needed.
|
// TODO(user): Specify other spec details if needed.
|
||||||
}
|
}
|
||||||
Expect(k8sClient.Create(ctx, resource)).To(Succeed())
|
Expect(k8sClient.Create(ctx, resource)).To(Succeed())
|
||||||
|
|||||||
@ -23,9 +23,7 @@ import (
|
|||||||
"runtime"
|
"runtime"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
. "github.com/onsi/ginkgo/v2"
|
// +kubebuilder:scaffold:imports
|
||||||
. "github.com/onsi/gomega"
|
|
||||||
|
|
||||||
"k8s.io/client-go/kubernetes/scheme"
|
"k8s.io/client-go/kubernetes/scheme"
|
||||||
"k8s.io/client-go/rest"
|
"k8s.io/client-go/rest"
|
||||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||||
@ -34,17 +32,21 @@ import (
|
|||||||
"sigs.k8s.io/controller-runtime/pkg/log/zap"
|
"sigs.k8s.io/controller-runtime/pkg/log/zap"
|
||||||
|
|
||||||
barmancloudv1 "github.com/cloudnative-pg/plugin-barman-cloud/api/v1"
|
barmancloudv1 "github.com/cloudnative-pg/plugin-barman-cloud/api/v1"
|
||||||
// +kubebuilder:scaffold:imports
|
|
||||||
|
. "github.com/onsi/ginkgo/v2"
|
||||||
|
. "github.com/onsi/gomega"
|
||||||
)
|
)
|
||||||
|
|
||||||
// These tests use Ginkgo (BDD-style Go testing framework). Refer to
|
// These tests use Ginkgo (BDD-style Go testing framework). Refer to
|
||||||
// http://onsi.github.io/ginkgo/ to learn more about Ginkgo.
|
// http://onsi.github.io/ginkgo/ to learn more about Ginkgo.
|
||||||
|
|
||||||
var cfg *rest.Config
|
var (
|
||||||
var k8sClient client.Client
|
cfg *rest.Config
|
||||||
var testEnv *envtest.Environment
|
k8sClient client.Client
|
||||||
var ctx context.Context
|
testEnv *envtest.Environment
|
||||||
var cancel context.CancelFunc
|
ctx context.Context
|
||||||
|
cancel context.CancelFunc
|
||||||
|
)
|
||||||
|
|
||||||
func TestControllers(t *testing.T) {
|
func TestControllers(t *testing.T) {
|
||||||
RegisterFailHandler(Fail)
|
RegisterFailHandler(Fail)
|
||||||
@ -55,7 +57,7 @@ func TestControllers(t *testing.T) {
|
|||||||
var _ = BeforeSuite(func() {
|
var _ = BeforeSuite(func() {
|
||||||
logf.SetLogger(zap.New(zap.WriteTo(GinkgoWriter), zap.UseDevMode(true)))
|
logf.SetLogger(zap.New(zap.WriteTo(GinkgoWriter), zap.UseDevMode(true)))
|
||||||
|
|
||||||
ctx, cancel = context.WithCancel(context.TODO())
|
ctx, cancel = context.WithCancel(context.TODO()) //nolint: fatcontext
|
||||||
|
|
||||||
By("bootstrapping test environment")
|
By("bootstrapping test environment")
|
||||||
testEnv = &envtest.Environment{
|
testEnv = &envtest.Environment{
|
||||||
@ -85,7 +87,6 @@ var _ = BeforeSuite(func() {
|
|||||||
k8sClient, err = client.New(cfg, client.Options{Scheme: scheme.Scheme})
|
k8sClient, err = client.New(cfg, client.Options{Scheme: scheme.Scheme})
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(k8sClient).NotTo(BeNil())
|
Expect(k8sClient).NotTo(BeNil())
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
var _ = AfterSuite(func() {
|
var _ = AfterSuite(func() {
|
||||||
|
|||||||
@ -21,10 +21,10 @@ import (
|
|||||||
"os/exec"
|
"os/exec"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/cloudnative-pg/plugin-barman-cloud/test/utils"
|
||||||
|
|
||||||
. "github.com/onsi/ginkgo/v2"
|
. "github.com/onsi/ginkgo/v2"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
|
|
||||||
"github.com/cloudnative-pg/plugin-barman-cloud/test/utils"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const namespace = "plugin-barman-cloud-system"
|
const namespace = "plugin-barman-cloud-system"
|
||||||
@ -60,14 +60,15 @@ var _ = Describe("controller", Ordered, func() {
|
|||||||
var err error
|
var err error
|
||||||
|
|
||||||
// projectimage stores the name of the image used in the example
|
// projectimage stores the name of the image used in the example
|
||||||
var projectimage = "example.com/plugin-barman-cloud:v0.0.1"
|
projectimage := "example.com/plugin-barman-cloud:v0.0.1"
|
||||||
|
|
||||||
By("building the manager(Operator) image")
|
By("building the manager(Operator) image")
|
||||||
|
//nolint:gosec,perfsprint
|
||||||
cmd := exec.Command("make", "docker-build", fmt.Sprintf("IMG=%s", projectimage))
|
cmd := exec.Command("make", "docker-build", fmt.Sprintf("IMG=%s", projectimage))
|
||||||
_, err = utils.Run(cmd)
|
_, err = utils.Run(cmd)
|
||||||
ExpectWithOffset(1, err).NotTo(HaveOccurred())
|
ExpectWithOffset(1, err).NotTo(HaveOccurred())
|
||||||
|
|
||||||
By("loading the the manager(Operator) image on Kind")
|
By("loading the manager(Operator) image on Kind")
|
||||||
err = utils.LoadImageToKindClusterWithName(projectimage)
|
err = utils.LoadImageToKindClusterWithName(projectimage)
|
||||||
ExpectWithOffset(1, err).NotTo(HaveOccurred())
|
ExpectWithOffset(1, err).NotTo(HaveOccurred())
|
||||||
|
|
||||||
@ -77,6 +78,7 @@ var _ = Describe("controller", Ordered, func() {
|
|||||||
ExpectWithOffset(1, err).NotTo(HaveOccurred())
|
ExpectWithOffset(1, err).NotTo(HaveOccurred())
|
||||||
|
|
||||||
By("deploying the controller-manager")
|
By("deploying the controller-manager")
|
||||||
|
//nolint:gosec,perfsprint
|
||||||
cmd = exec.Command("make", "deploy", fmt.Sprintf("IMG=%s", projectimage))
|
cmd = exec.Command("make", "deploy", fmt.Sprintf("IMG=%s", projectimage))
|
||||||
_, err = utils.Run(cmd)
|
_, err = utils.Run(cmd)
|
||||||
ExpectWithOffset(1, err).NotTo(HaveOccurred())
|
ExpectWithOffset(1, err).NotTo(HaveOccurred())
|
||||||
@ -113,10 +115,10 @@ var _ = Describe("controller", Ordered, func() {
|
|||||||
if string(status) != "Running" {
|
if string(status) != "Running" {
|
||||||
return fmt.Errorf("controller pod in %s status", status)
|
return fmt.Errorf("controller pod in %s status", status)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
EventuallyWithOffset(1, verifyControllerUp, time.Minute, time.Second).Should(Succeed())
|
EventuallyWithOffset(1, verifyControllerUp, time.Minute, time.Second).Should(Succeed())
|
||||||
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@ -22,7 +22,7 @@ import (
|
|||||||
"os/exec"
|
"os/exec"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
. "github.com/onsi/ginkgo/v2" //nolint:golint,revive
|
. "github.com/onsi/ginkgo/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -43,10 +43,11 @@ func InstallPrometheusOperator() error {
|
|||||||
url := fmt.Sprintf(prometheusOperatorURL, prometheusOperatorVersion)
|
url := fmt.Sprintf(prometheusOperatorURL, prometheusOperatorVersion)
|
||||||
cmd := exec.Command("kubectl", "create", "-f", url)
|
cmd := exec.Command("kubectl", "create", "-f", url)
|
||||||
_, err := Run(cmd)
|
_, err := Run(cmd)
|
||||||
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run executes the provided command within this context
|
// Run executes the provided command within this context.
|
||||||
func Run(cmd *exec.Cmd) ([]byte, error) {
|
func Run(cmd *exec.Cmd) ([]byte, error) {
|
||||||
dir, _ := GetProjectDir()
|
dir, _ := GetProjectDir()
|
||||||
cmd.Dir = dir
|
cmd.Dir = dir
|
||||||
@ -60,13 +61,13 @@ func Run(cmd *exec.Cmd) ([]byte, error) {
|
|||||||
_, _ = fmt.Fprintf(GinkgoWriter, "running: %s\n", command)
|
_, _ = fmt.Fprintf(GinkgoWriter, "running: %s\n", command)
|
||||||
output, err := cmd.CombinedOutput()
|
output, err := cmd.CombinedOutput()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return output, fmt.Errorf("%s failed with error: (%v) %s", command, err, string(output))
|
return output, fmt.Errorf("%s failed with error: (%w) %s", command, err, string(output))
|
||||||
}
|
}
|
||||||
|
|
||||||
return output, nil
|
return output, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// UninstallPrometheusOperator uninstalls the prometheus
|
// UninstallPrometheusOperator uninstalls the prometheus.
|
||||||
func UninstallPrometheusOperator() {
|
func UninstallPrometheusOperator() {
|
||||||
url := fmt.Sprintf(prometheusOperatorURL, prometheusOperatorVersion)
|
url := fmt.Sprintf(prometheusOperatorURL, prometheusOperatorVersion)
|
||||||
cmd := exec.Command("kubectl", "delete", "-f", url)
|
cmd := exec.Command("kubectl", "delete", "-f", url)
|
||||||
@ -75,7 +76,7 @@ func UninstallPrometheusOperator() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// UninstallCertManager uninstalls the cert manager
|
// UninstallCertManager uninstalls the cert manager.
|
||||||
func UninstallCertManager() {
|
func UninstallCertManager() {
|
||||||
url := fmt.Sprintf(certmanagerURLTmpl, certmanagerVersion)
|
url := fmt.Sprintf(certmanagerURLTmpl, certmanagerVersion)
|
||||||
cmd := exec.Command("kubectl", "delete", "-f", url)
|
cmd := exec.Command("kubectl", "delete", "-f", url)
|
||||||
@ -100,10 +101,11 @@ func InstallCertManager() error {
|
|||||||
)
|
)
|
||||||
|
|
||||||
_, err := Run(cmd)
|
_, err := Run(cmd)
|
||||||
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// LoadImageToKindClusterWithName loads a local docker image to the kind cluster
|
// LoadImageToKindClusterWithName loads a local docker image to the kind cluster.
|
||||||
func LoadImageToKindClusterWithName(name string) error {
|
func LoadImageToKindClusterWithName(name string) error {
|
||||||
cluster := "kind"
|
cluster := "kind"
|
||||||
if v, ok := os.LookupEnv("KIND_CLUSTER"); ok {
|
if v, ok := os.LookupEnv("KIND_CLUSTER"); ok {
|
||||||
@ -112,6 +114,7 @@ func LoadImageToKindClusterWithName(name string) error {
|
|||||||
kindOptions := []string{"load", "docker-image", name, "--name", cluster}
|
kindOptions := []string{"load", "docker-image", name, "--name", cluster}
|
||||||
cmd := exec.Command("kind", kindOptions...)
|
cmd := exec.Command("kind", kindOptions...)
|
||||||
_, err := Run(cmd)
|
_, err := Run(cmd)
|
||||||
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -129,12 +132,13 @@ func GetNonEmptyLines(output string) []string {
|
|||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetProjectDir will return the directory where the project is
|
// GetProjectDir will return the directory where the project is.
|
||||||
func GetProjectDir() (string, error) {
|
func GetProjectDir() (string, error) {
|
||||||
wd, err := os.Getwd()
|
wd, err := os.Getwd()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return wd, err
|
return wd, fmt.Errorf("failed to get the current working directory: %w", err)
|
||||||
}
|
}
|
||||||
wd = strings.Replace(wd, "/test/e2e", "", -1)
|
wd = strings.ReplaceAll(wd, "/test/e2e", "")
|
||||||
|
|
||||||
return wd, nil
|
return wd, nil
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user