mirror of
https://github.com/cloudnative-pg/plugin-barman-cloud.git
synced 2026-01-13 22:23:11 +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 (
|
import (
|
||||||
"context"
|
"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"
|
"github.com/cloudnative-pg/cnpg-i/pkg/identity"
|
||||||
)
|
)
|
||||||
|
|
||||||
type IdentityImplementation struct {
|
type IdentityImplementation struct {
|
||||||
identity.UnimplementedIdentityServer
|
identity.UnimplementedIdentityServer
|
||||||
|
BarmanObjectKey client.ObjectKey
|
||||||
|
Client client.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i IdentityImplementation) GetPluginMetadata(
|
func (i IdentityImplementation) GetPluginMetadata(
|
||||||
@ -45,6 +50,11 @@ func (i IdentityImplementation) Probe(
|
|||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
request *identity.ProbeRequest,
|
request *identity.ProbeRequest,
|
||||||
) (*identity.ProbeResponse, error) {
|
) (*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{
|
return &identity.ProbeResponse{
|
||||||
Ready: true,
|
Ready: true,
|
||||||
}, nil
|
}, nil
|
||||||
|
|||||||
@ -38,7 +38,10 @@ func (c *CNPGI) Start(ctx context.Context) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
srv := http.Server{
|
srv := http.Server{
|
||||||
IdentityImpl: IdentityImplementation{},
|
IdentityImpl: IdentityImplementation{
|
||||||
|
Client: c.Client,
|
||||||
|
BarmanObjectKey: c.BarmanObjectKey,
|
||||||
|
},
|
||||||
Enrichers: []http.ServerEnricher{enrich},
|
Enrichers: []http.ServerEnricher{enrich},
|
||||||
ServerCertPath: c.ServerCertPath,
|
ServerCertPath: c.ServerCertPath,
|
||||||
ServerKeyPath: c.ServerKeyPath,
|
ServerKeyPath: c.ServerKeyPath,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user