pomerium/internal/zero/reconciler/report_status.go
Denis Mishin 60ab9dafbe zero: report resource bundle reconciliation status (#4618)
* zero: report resource bundle reconciliation status

* use latest zero-sdk
2023-11-15 09:21:56 -08:00

44 lines
1.4 KiB
Go

package reconciler
import (
"context"
"github.com/pomerium/pomerium/internal/log"
cluster_api "github.com/pomerium/zero-sdk/cluster"
)
const (
// BundleStatusFailureDatabrokerError indicates a failure due to a databroker error
BundleStatusFailureDatabrokerError = cluster_api.DatabrokerError
// BundleStatusFailureDownloadError indicates a failure due to a download error
BundleStatusFailureDownloadError = cluster_api.DownloadError
// BundleStatusFailureInvalidBundle indicates a failure due to an invalid bundle
BundleStatusFailureInvalidBundle = cluster_api.InvalidBundle
// BundleStatusFailureIO indicates a failure due to an IO error
BundleStatusFailureIO = cluster_api.IoError
// BundleStatusFailureUnknownError indicates a failure due to an unknown error
BundleStatusFailureUnknownError = cluster_api.UnknownError
)
func (c *service) ReportBundleAppliedSuccess(
ctx context.Context,
bundleID string,
metadata map[string]string,
) {
err := c.config.api.ReportBundleAppliedSuccess(ctx, bundleID, metadata)
if err != nil {
log.Ctx(ctx).Err(err).Msg("reconciler: error reporting bundle status")
}
}
func (c *service) ReportBundleAppliedFailure(
ctx context.Context,
bundleID string,
source cluster_api.BundleStatusFailureSource,
err error,
) {
err = c.config.api.ReportBundleAppliedFailure(ctx, bundleID, source, err)
if err != nil {
log.Ctx(ctx).Err(err).Msg("reconciler: error reporting bundle status")
}
}