mirror of
https://github.com/cloudnative-pg/plugin-barman-cloud.git
synced 2026-01-11 21:23:12 +01:00
chore: makes linter happy (#17)
Signed-off-by: Leonardo Cecchi <leonardo.cecchi@enterprisedb.com>
This commit is contained in:
parent
cbefe26440
commit
88e8762858
146
.golangci.yml
146
.golangci.yml
@ -8,43 +8,127 @@ linters-settings:
|
|||||||
- prefix(github.com/cloudnative-pg/plugin-barman-cloud)
|
- prefix(github.com/cloudnative-pg/plugin-barman-cloud)
|
||||||
- blank
|
- blank
|
||||||
- dot
|
- dot
|
||||||
nlreturn:
|
gosec:
|
||||||
# Size of the block (including return statement that is still "OK")
|
excludes:
|
||||||
# so no return split required.
|
- G101 # remove this exclude when https://github.com/securego/gosec/issues/1001 is fixed
|
||||||
# Default: 1
|
|
||||||
block-size: 3
|
linters:
|
||||||
|
# please, do not use `enable-all`: it's deprecated and will be removed soon.
|
||||||
|
# inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint
|
||||||
|
disable-all: true
|
||||||
|
enable:
|
||||||
|
- asciicheck
|
||||||
|
- bodyclose
|
||||||
|
- dogsled
|
||||||
|
- dupl
|
||||||
|
- durationcheck
|
||||||
|
- errcheck
|
||||||
|
- copyloopvar
|
||||||
|
- gci
|
||||||
|
- gocognit
|
||||||
|
- goconst
|
||||||
|
- gocritic
|
||||||
|
- gocyclo
|
||||||
|
- gofmt
|
||||||
|
- gofumpt
|
||||||
|
- goheader
|
||||||
|
- goimports
|
||||||
|
- gomoddirectives
|
||||||
|
- gomodguard
|
||||||
|
- goprintffuncname
|
||||||
|
- gosec
|
||||||
|
- gosimple
|
||||||
|
- govet
|
||||||
|
- ginkgolinter
|
||||||
|
- importas
|
||||||
|
- ineffassign
|
||||||
|
- lll
|
||||||
|
- makezero
|
||||||
|
- misspell
|
||||||
|
- nakedret
|
||||||
|
- nestif
|
||||||
|
- prealloc
|
||||||
|
- predeclared
|
||||||
|
- revive
|
||||||
|
- rowserrcheck
|
||||||
|
- sqlclosecheck
|
||||||
|
- staticcheck
|
||||||
|
- stylecheck
|
||||||
|
- thelper
|
||||||
|
- tparallel
|
||||||
|
- typecheck
|
||||||
|
- unconvert
|
||||||
|
- unparam
|
||||||
|
- unused
|
||||||
|
- wastedassign
|
||||||
|
- whitespace
|
||||||
|
|
||||||
|
# to be checked:
|
||||||
|
# - errorlint
|
||||||
|
# - forbidigo
|
||||||
|
# - forcetypeassert
|
||||||
|
# - goerr113
|
||||||
|
# - ifshort
|
||||||
|
# - nilerr
|
||||||
|
# - nlreturn
|
||||||
|
# - noctx
|
||||||
|
# - nolintlint
|
||||||
|
# - paralleltest
|
||||||
|
# - promlinter
|
||||||
|
# - tagliatelle
|
||||||
|
# - wrapcheck
|
||||||
|
|
||||||
|
# don't enable:
|
||||||
|
# - cyclop
|
||||||
|
# - depguard
|
||||||
|
# - exhaustive
|
||||||
|
# - exhaustivestruct
|
||||||
|
# - funlen
|
||||||
|
# - gochecknoglobals
|
||||||
|
# - gochecknoinits
|
||||||
|
# - godot
|
||||||
|
# - godox
|
||||||
|
# - gomnd
|
||||||
|
# - testpackage
|
||||||
|
# - wsl
|
||||||
|
|
||||||
|
# deprecated:
|
||||||
|
# - deadcode
|
||||||
|
# - golint
|
||||||
|
# - interfacer
|
||||||
|
# - maligned
|
||||||
|
# - scopelint
|
||||||
|
# - structcheck
|
||||||
|
# - varcheck
|
||||||
|
|
||||||
|
run:
|
||||||
|
timeout: 5m
|
||||||
|
|
||||||
issues:
|
issues:
|
||||||
exclude-rules:
|
exclude-rules:
|
||||||
# Allow dot imports for ginkgo and gomega
|
# Allow dot imports for ginkgo and gomega
|
||||||
- source: ginkgo|gomega
|
- source: ginkgo|gomega
|
||||||
linters:
|
linters:
|
||||||
- revive
|
- revive
|
||||||
text: "should not use dot imports"
|
text: "should not use dot imports"
|
||||||
|
# Exclude some linters from running on tests files.
|
||||||
|
- path: _test\.go
|
||||||
|
linters:
|
||||||
|
- goconst
|
||||||
|
# Exclude lll issues for lines with long annotations
|
||||||
- linters:
|
- linters:
|
||||||
- stylecheck
|
- lll
|
||||||
text: "should not use dot imports"
|
source: "//\\s*\\+"
|
||||||
|
# We have no control of this in zz_generated files and it looks like that excluding those files is not enough
|
||||||
|
# so we disable "ST1016: methods on the same type should have the same receiver name" in api directory
|
||||||
|
- linters:
|
||||||
|
- stylecheck
|
||||||
|
text: "ST1016:"
|
||||||
|
path: api/
|
||||||
|
exclude-use-default: false
|
||||||
exclude-dirs:
|
exclude-dirs:
|
||||||
- vendor
|
# This tests are generated by kubebuilder
|
||||||
|
- test
|
||||||
linters:
|
exclude-files:
|
||||||
enable-all: true
|
- zz_generated.*
|
||||||
disable:
|
- internal/controller/suite_test.go
|
||||||
- depguard
|
|
||||||
- err113
|
|
||||||
- exhaustruct
|
|
||||||
- execinquery
|
|
||||||
- exportloopref
|
|
||||||
- funlen
|
|
||||||
- gochecknoglobals
|
|
||||||
- gochecknoinits
|
|
||||||
- godox
|
|
||||||
- gomnd
|
|
||||||
- paralleltest
|
|
||||||
- testpackage
|
|
||||||
- varnamelen
|
|
||||||
- wsl
|
|
||||||
|
|
||||||
run:
|
|
||||||
timeout: 10m
|
|
||||||
allow-parallel-runners: true
|
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
// Package main is the implementation of the CNPG-i PostgreSQL sidecar
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@ -9,7 +10,6 @@ import (
|
|||||||
"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"
|
||||||
controllerruntime "sigs.k8s.io/controller-runtime"
|
|
||||||
ctrl "sigs.k8s.io/controller-runtime"
|
ctrl "sigs.k8s.io/controller-runtime"
|
||||||
"sigs.k8s.io/controller-runtime/pkg/cache"
|
"sigs.k8s.io/controller-runtime/pkg/cache"
|
||||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||||
@ -37,7 +37,7 @@ func main() {
|
|||||||
clusterName := mustGetEnv("CLUSTER_NAME")
|
clusterName := mustGetEnv("CLUSTER_NAME")
|
||||||
instanceName := mustGetEnv("INSTANCE_NAME")
|
instanceName := mustGetEnv("INSTANCE_NAME")
|
||||||
|
|
||||||
mgr, err := controllerruntime.NewManager(controllerruntime.GetConfigOrDie(), controllerruntime.Options{
|
mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
|
||||||
Scheme: scheme,
|
Scheme: scheme,
|
||||||
Cache: cache.Options{
|
Cache: cache.Options{
|
||||||
ByObject: map[client.Object]cache.ByObject{
|
ByObject: map[client.Object]cache.ByObject{
|
||||||
|
|||||||
@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// Package main contains the implementation of the CNPG-i operator plugin
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@ -6,10 +6,13 @@ import (
|
|||||||
"github.com/cloudnative-pg/cnpg-i/pkg/backup"
|
"github.com/cloudnative-pg/cnpg-i/pkg/backup"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// BackupServiceImplementation is the implementation
|
||||||
|
// of the Backup CNPG capability
|
||||||
type BackupServiceImplementation struct {
|
type BackupServiceImplementation struct {
|
||||||
backup.UnimplementedBackupServer
|
backup.UnimplementedBackupServer
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetCapabilities implements the BackupService interface
|
||||||
func (b BackupServiceImplementation) GetCapabilities(
|
func (b BackupServiceImplementation) GetCapabilities(
|
||||||
_ context.Context, _ *backup.BackupCapabilitiesRequest,
|
_ context.Context, _ *backup.BackupCapabilitiesRequest,
|
||||||
) (*backup.BackupCapabilitiesResult, error) {
|
) (*backup.BackupCapabilitiesResult, error) {
|
||||||
@ -26,6 +29,7 @@ func (b BackupServiceImplementation) GetCapabilities(
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Backup implements the Backup interface
|
||||||
func (b BackupServiceImplementation) Backup(_ context.Context, _ *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")
|
||||||
|
|||||||
@ -2,6 +2,8 @@ package instance
|
|||||||
|
|
||||||
import "github.com/cloudnative-pg/cnpg-i/pkg/identity"
|
import "github.com/cloudnative-pg/cnpg-i/pkg/identity"
|
||||||
|
|
||||||
|
// PluginName is the name of the plugin from the instance manager
|
||||||
|
// Point-of-view
|
||||||
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.
|
||||||
|
|||||||
2
internal/cnpgi/instance/doc.go
Normal file
2
internal/cnpgi/instance/doc.go
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
// Package instance implements the capabilities used by the operator sidecar
|
||||||
|
package instance
|
||||||
@ -10,12 +10,14 @@ import (
|
|||||||
barmancloudv1 "github.com/cloudnative-pg/plugin-barman-cloud/api/v1"
|
barmancloudv1 "github.com/cloudnative-pg/plugin-barman-cloud/api/v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// IdentityImplementation implements IdentityServer
|
||||||
type IdentityImplementation struct {
|
type IdentityImplementation struct {
|
||||||
identity.UnimplementedIdentityServer
|
identity.UnimplementedIdentityServer
|
||||||
BarmanObjectKey client.ObjectKey
|
BarmanObjectKey client.ObjectKey
|
||||||
Client client.Client
|
Client client.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetPluginMetadata implements IdentityServer
|
||||||
func (i IdentityImplementation) GetPluginMetadata(
|
func (i IdentityImplementation) GetPluginMetadata(
|
||||||
_ context.Context,
|
_ context.Context,
|
||||||
_ *identity.GetPluginMetadataRequest,
|
_ *identity.GetPluginMetadataRequest,
|
||||||
@ -23,6 +25,7 @@ func (i IdentityImplementation) GetPluginMetadata(
|
|||||||
return &Data, nil
|
return &Data, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetPluginCapabilities implements IdentityServer
|
||||||
func (i IdentityImplementation) GetPluginCapabilities(
|
func (i IdentityImplementation) GetPluginCapabilities(
|
||||||
_ context.Context,
|
_ context.Context,
|
||||||
_ *identity.GetPluginCapabilitiesRequest,
|
_ *identity.GetPluginCapabilitiesRequest,
|
||||||
@ -47,6 +50,7 @@ func (i IdentityImplementation) GetPluginCapabilities(
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Probe implements IdentityServer
|
||||||
func (i IdentityImplementation) Probe(
|
func (i IdentityImplementation) Probe(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
_ *identity.ProbeRequest,
|
_ *identity.ProbeRequest,
|
||||||
|
|||||||
@ -10,6 +10,7 @@ import (
|
|||||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// CNPGI is the implementation of the PostgreSQL sidecar
|
||||||
type CNPGI struct {
|
type CNPGI struct {
|
||||||
Client client.Client
|
Client client.Client
|
||||||
BarmanObjectKey client.ObjectKey
|
BarmanObjectKey client.ObjectKey
|
||||||
@ -27,6 +28,7 @@ type CNPGI struct {
|
|||||||
InstanceName string
|
InstanceName string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Start starts the GRPC service
|
||||||
func (c *CNPGI) Start(ctx context.Context) error {
|
func (c *CNPGI) Start(ctx context.Context) error {
|
||||||
enrich := func(server *grpc.Server) error {
|
enrich := func(server *grpc.Server) error {
|
||||||
wal.RegisterWALServer(server, WALServiceImplementation{
|
wal.RegisterWALServer(server, WALServiceImplementation{
|
||||||
|
|||||||
@ -22,6 +22,7 @@ import (
|
|||||||
barmancloudv1 "github.com/cloudnative-pg/plugin-barman-cloud/api/v1"
|
barmancloudv1 "github.com/cloudnative-pg/plugin-barman-cloud/api/v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// WALServiceImplementation is the implementation of the WAL Service
|
||||||
type WALServiceImplementation struct {
|
type WALServiceImplementation struct {
|
||||||
BarmanObjectKey client.ObjectKey
|
BarmanObjectKey client.ObjectKey
|
||||||
ClusterObjectKey client.ObjectKey
|
ClusterObjectKey client.ObjectKey
|
||||||
@ -33,7 +34,11 @@ type WALServiceImplementation struct {
|
|||||||
wal.UnimplementedWALServer
|
wal.UnimplementedWALServer
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w WALServiceImplementation) GetCapabilities(ctx context.Context, request *wal.WALCapabilitiesRequest) (*wal.WALCapabilitiesResult, error) {
|
// GetCapabilities implements the WALService interface
|
||||||
|
func (w WALServiceImplementation) GetCapabilities(
|
||||||
|
_ context.Context,
|
||||||
|
_ *wal.WALCapabilitiesRequest,
|
||||||
|
) (*wal.WALCapabilitiesResult, error) {
|
||||||
return &wal.WALCapabilitiesResult{
|
return &wal.WALCapabilitiesResult{
|
||||||
Capabilities: []*wal.WALCapability{
|
Capabilities: []*wal.WALCapability{
|
||||||
{
|
{
|
||||||
@ -54,7 +59,11 @@ func (w WALServiceImplementation) GetCapabilities(ctx context.Context, request *
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w WALServiceImplementation) Archive(ctx context.Context, request *wal.WALArchiveRequest) (*wal.WALArchiveResult, error) {
|
// Archive implements the WALService interface
|
||||||
|
func (w WALServiceImplementation) Archive(
|
||||||
|
ctx context.Context,
|
||||||
|
request *wal.WALArchiveRequest,
|
||||||
|
) (*wal.WALArchiveResult, error) {
|
||||||
var objectStore barmancloudv1.ObjectStore
|
var objectStore barmancloudv1.ObjectStore
|
||||||
if err := w.Client.Get(ctx, w.BarmanObjectKey, &objectStore); err != nil {
|
if err := w.Client.Get(ctx, w.BarmanObjectKey, &objectStore); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -90,7 +99,11 @@ func (w WALServiceImplementation) Archive(ctx context.Context, request *wal.WALA
|
|||||||
return &wal.WALArchiveResult{}, nil
|
return &wal.WALArchiveResult{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w WALServiceImplementation) Restore(ctx context.Context, request *wal.WALRestoreRequest) (*wal.WALRestoreResult, error) {
|
// Restore implements the WALService interface
|
||||||
|
func (w WALServiceImplementation) Restore(
|
||||||
|
ctx context.Context,
|
||||||
|
request *wal.WALRestoreRequest,
|
||||||
|
) (*wal.WALRestoreResult, error) {
|
||||||
contextLogger := log.FromContext(ctx)
|
contextLogger := log.FromContext(ctx)
|
||||||
startTime := time.Now()
|
startTime := time.Now()
|
||||||
|
|
||||||
@ -181,7 +194,7 @@ func (w WALServiceImplementation) Restore(ctx context.Context, request *wal.WALR
|
|||||||
return nil, walStatus[0].Err
|
return nil, walStatus[0].Err
|
||||||
}
|
}
|
||||||
|
|
||||||
//We skip this step if streaming connection is not available
|
// We skip this step if streaming connection is not available
|
||||||
endOfWALStream := isEndOfWALStream(walStatus)
|
endOfWALStream := isEndOfWALStream(walStatus)
|
||||||
if isStreamingAvailable(cluster, w.InstanceName) && endOfWALStream {
|
if isStreamingAvailable(cluster, w.InstanceName) && endOfWALStream {
|
||||||
contextLogger.Info(
|
contextLogger.Info(
|
||||||
@ -213,12 +226,20 @@ func (w WALServiceImplementation) Restore(ctx context.Context, request *wal.WALR
|
|||||||
return &wal.WALRestoreResult{}, nil
|
return &wal.WALRestoreResult{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w WALServiceImplementation) Status(ctx context.Context, request *wal.WALStatusRequest) (*wal.WALStatusResult, error) {
|
// Status implements the WALService interface
|
||||||
|
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) {
|
// SetFirstRequired implements the WALService interface
|
||||||
|
func (w WALServiceImplementation) SetFirstRequired(
|
||||||
|
_ context.Context,
|
||||||
|
_ *wal.SetFirstRequiredRequest,
|
||||||
|
) (*wal.SetFirstRequiredResult, error) {
|
||||||
// TODO implement me
|
// TODO implement me
|
||||||
panic("implement me")
|
panic("implement me")
|
||||||
}
|
}
|
||||||
@ -325,7 +346,7 @@ func gatherWALFilesToRestore(walName string, parallel int) (walList []string, er
|
|||||||
return walList, err
|
return walList, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// ErrEndOfWALStreamReached is returned when end of WAL is detected in the cloud archive
|
// ErrEndOfWALStreamReached is returned when end of WAL is detected in the cloud archive.
|
||||||
var ErrEndOfWALStreamReached = errors.New("end of WAL reached")
|
var ErrEndOfWALStreamReached = errors.New("end of WAL reached")
|
||||||
|
|
||||||
// checkEndOfWALStreamFlag returns ErrEndOfWALStreamReached if the flag is set in the restorer.
|
// checkEndOfWALStreamFlag returns ErrEndOfWALStreamReached if the flag is set in the restorer.
|
||||||
|
|||||||
@ -75,8 +75,8 @@ var (
|
|||||||
WALSegmentNameRe +
|
WALSegmentNameRe +
|
||||||
`$`)
|
`$`)
|
||||||
|
|
||||||
// ErrorBadWALSegmentName is raised when parsing an invalid segment name.
|
// ErrBadWALSegmentName is raised when parsing an invalid segment name.
|
||||||
ErrorBadWALSegmentName = errors.New("invalid WAL segment name")
|
ErrBadWALSegmentName = errors.New("invalid WAL segment name")
|
||||||
)
|
)
|
||||||
|
|
||||||
// Segment contains the information inside a WAL segment name.
|
// Segment contains the information inside a WAL segment name.
|
||||||
@ -109,23 +109,23 @@ func SegmentFromName(name string) (Segment, error) {
|
|||||||
// We could have used WALSegmentRe directly, but we wanted to adhere to barman code
|
// We could have used WALSegmentRe directly, but we wanted to adhere to barman code
|
||||||
subMatches := WALRe.FindStringSubmatch(baseName)
|
subMatches := WALRe.FindStringSubmatch(baseName)
|
||||||
if len(subMatches) != 4 {
|
if len(subMatches) != 4 {
|
||||||
return Segment{}, ErrorBadWALSegmentName
|
return Segment{}, ErrBadWALSegmentName
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(subMatches[0]) != 24 {
|
if len(subMatches[0]) != 24 {
|
||||||
return Segment{}, ErrorBadWALSegmentName
|
return Segment{}, ErrBadWALSegmentName
|
||||||
}
|
}
|
||||||
|
|
||||||
if tli, err = strconv.ParseInt(subMatches[1], 16, 32); err != nil {
|
if tli, err = strconv.ParseInt(subMatches[1], 16, 32); err != nil {
|
||||||
return Segment{}, ErrorBadWALSegmentName
|
return Segment{}, ErrBadWALSegmentName
|
||||||
}
|
}
|
||||||
|
|
||||||
if log, err = strconv.ParseInt(subMatches[2], 16, 32); err != nil {
|
if log, err = strconv.ParseInt(subMatches[2], 16, 32); err != nil {
|
||||||
return Segment{}, ErrorBadWALSegmentName
|
return Segment{}, ErrBadWALSegmentName
|
||||||
}
|
}
|
||||||
|
|
||||||
if seg, err = strconv.ParseInt(subMatches[3], 16, 32); err != nil {
|
if seg, err = strconv.ParseInt(subMatches[3], 16, 32); err != nil {
|
||||||
return Segment{}, ErrorBadWALSegmentName
|
return Segment{}, ErrBadWALSegmentName
|
||||||
}
|
}
|
||||||
|
|
||||||
return Segment{
|
return Segment{
|
||||||
|
|||||||
@ -2,6 +2,7 @@ package operator
|
|||||||
|
|
||||||
import "github.com/cloudnative-pg/cnpg-i/pkg/identity"
|
import "github.com/cloudnative-pg/cnpg-i/pkg/identity"
|
||||||
|
|
||||||
|
// PluginName is the name of this plugin
|
||||||
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.
|
||||||
|
|||||||
2
internal/cnpgi/operator/doc.go
Normal file
2
internal/cnpgi/operator/doc.go
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
// Package operator implements the capabilities used by CNPG
|
||||||
|
package operator
|
||||||
@ -6,10 +6,13 @@ import (
|
|||||||
"github.com/cloudnative-pg/cnpg-i/pkg/identity"
|
"github.com/cloudnative-pg/cnpg-i/pkg/identity"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// IdentityImplementation is the implementation of the CNPG-i
|
||||||
|
// Identity entrypoint
|
||||||
type IdentityImplementation struct {
|
type IdentityImplementation struct {
|
||||||
identity.UnimplementedIdentityServer
|
identity.UnimplementedIdentityServer
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetPluginMetadata implements Identity
|
||||||
func (i IdentityImplementation) GetPluginMetadata(
|
func (i IdentityImplementation) GetPluginMetadata(
|
||||||
_ context.Context,
|
_ context.Context,
|
||||||
_ *identity.GetPluginMetadataRequest,
|
_ *identity.GetPluginMetadataRequest,
|
||||||
@ -17,6 +20,7 @@ func (i IdentityImplementation) GetPluginMetadata(
|
|||||||
return &Data, nil
|
return &Data, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetPluginCapabilities implements identity
|
||||||
func (i IdentityImplementation) GetPluginCapabilities(
|
func (i IdentityImplementation) GetPluginCapabilities(
|
||||||
_ context.Context,
|
_ context.Context,
|
||||||
_ *identity.GetPluginCapabilitiesRequest,
|
_ *identity.GetPluginCapabilitiesRequest,
|
||||||
@ -41,6 +45,7 @@ func (i IdentityImplementation) GetPluginCapabilities(
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Probe implements Identity
|
||||||
func (i IdentityImplementation) Probe(
|
func (i IdentityImplementation) Probe(
|
||||||
_ context.Context,
|
_ context.Context,
|
||||||
_ *identity.ProbeRequest,
|
_ *identity.ProbeRequest,
|
||||||
|
|||||||
@ -6,10 +6,12 @@ import (
|
|||||||
"github.com/cloudnative-pg/cnpg-i/pkg/reconciler"
|
"github.com/cloudnative-pg/cnpg-i/pkg/reconciler"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// ReconcilerImplementation implements the Reconciler capability
|
||||||
type ReconcilerImplementation struct {
|
type ReconcilerImplementation struct {
|
||||||
reconciler.UnimplementedReconcilerHooksServer
|
reconciler.UnimplementedReconcilerHooksServer
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetCapabilities implements the Reconciler interface
|
||||||
func (r ReconcilerImplementation) GetCapabilities(
|
func (r ReconcilerImplementation) GetCapabilities(
|
||||||
_ context.Context,
|
_ context.Context,
|
||||||
_ *reconciler.ReconcilerHooksCapabilitiesRequest,
|
_ *reconciler.ReconcilerHooksCapabilitiesRequest,
|
||||||
@ -26,6 +28,7 @@ func (r ReconcilerImplementation) GetCapabilities(
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Pre implements the reconciler interface
|
||||||
func (r ReconcilerImplementation) Pre(
|
func (r ReconcilerImplementation) Pre(
|
||||||
_ context.Context,
|
_ context.Context,
|
||||||
_ *reconciler.ReconcilerHooksRequest,
|
_ *reconciler.ReconcilerHooksRequest,
|
||||||
@ -35,6 +38,7 @@ func (r ReconcilerImplementation) Pre(
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Post implements the reconciler interface
|
||||||
func (r ReconcilerImplementation) Post(
|
func (r ReconcilerImplementation) Post(
|
||||||
_ context.Context,
|
_ context.Context,
|
||||||
_ *reconciler.ReconcilerHooksRequest,
|
_ *reconciler.ReconcilerHooksRequest,
|
||||||
|
|||||||
@ -9,8 +9,10 @@ import (
|
|||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// CNPGI is the implementation of the Operator plugin
|
||||||
type CNPGI struct{}
|
type CNPGI struct{}
|
||||||
|
|
||||||
|
// Start starts the GRPC server
|
||||||
func (c *CNPGI) Start(ctx context.Context) error {
|
func (c *CNPGI) Start(ctx context.Context) error {
|
||||||
cmd := http.CreateMainCmd(IdentityImplementation{}, func(server *grpc.Server) error {
|
cmd := http.CreateMainCmd(IdentityImplementation{}, func(server *grpc.Server) error {
|
||||||
// Register the declared implementations
|
// Register the declared implementations
|
||||||
|
|||||||
3
internal/controller/doc.go
Normal file
3
internal/controller/doc.go
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
// Package controller implements a controller for the CRDs as defined
|
||||||
|
// by this operator
|
||||||
|
package controller
|
||||||
Loading…
Reference in New Issue
Block a user