mirror of
https://github.com/cloudnative-pg/plugin-barman-cloud.git
synced 2026-01-11 21:23:12 +01:00
feat: add instance cnpgi probe
Signed-off-by: Armando Ruocco <armando.ruocco@enterprisedb.com>
This commit is contained in:
parent
1bd96b0126
commit
276ec942a2
@ -2,12 +2,17 @@ package instance
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
barmancloudv1 "github.com/cloudnative-pg/plugin-barman-cloud/api/v1"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||
|
||||
"github.com/cloudnative-pg/cnpg-i/pkg/identity"
|
||||
)
|
||||
|
||||
type IdentityImplementation struct {
|
||||
identity.UnimplementedIdentityServer
|
||||
BarmanObjectKey client.ObjectKey
|
||||
Client client.Client
|
||||
}
|
||||
|
||||
func (i IdentityImplementation) GetPluginMetadata(
|
||||
@ -45,6 +50,11 @@ func (i IdentityImplementation) Probe(
|
||||
ctx context.Context,
|
||||
request *identity.ProbeRequest,
|
||||
) (*identity.ProbeResponse, error) {
|
||||
var obj barmancloudv1.ObjectStore
|
||||
if err := i.Client.Get(ctx, i.BarmanObjectKey, &obj); err != nil {
|
||||
return nil, fmt.Errorf("while fetching object store %s: %w", i.BarmanObjectKey.Name, err)
|
||||
}
|
||||
|
||||
return &identity.ProbeResponse{
|
||||
Ready: true,
|
||||
}, nil
|
||||
|
||||
@ -38,7 +38,10 @@ func (c *CNPGI) Start(ctx context.Context) error {
|
||||
}
|
||||
|
||||
srv := http.Server{
|
||||
IdentityImpl: IdentityImplementation{},
|
||||
IdentityImpl: IdentityImplementation{
|
||||
Client: c.Client,
|
||||
BarmanObjectKey: c.BarmanObjectKey,
|
||||
},
|
||||
Enrichers: []http.ServerEnricher{enrich},
|
||||
ServerCertPath: c.ServerCertPath,
|
||||
ServerKeyPath: c.ServerKeyPath,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user