zero/healthchecks: add checks for ability to save bootstrap parameter and bundle status reporting (#5064)

This commit is contained in:
Denis Mishin 2024-04-11 10:47:52 -04:00 committed by GitHub
parent 25aceea626
commit dc7820ea3e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 33 additions and 69 deletions

View file

@ -15,6 +15,7 @@ import (
"os"
"github.com/pomerium/pomerium/pkg/cryptutil"
"github.com/pomerium/pomerium/pkg/health"
cluster_api "github.com/pomerium/pomerium/pkg/zero/cluster"
)
@ -40,6 +41,16 @@ func LoadBootstrapConfigFromFile(fp string, cipher cipher.AEAD) (*cluster_api.Bo
// SaveBootstrapConfigToFile saves the bootstrap configuration to a file.
func SaveBootstrapConfigToFile(src *cluster_api.BootstrapConfig, fp string, cipher cipher.AEAD) error {
err := saveBootstrapConfigToFile(src, fp, cipher)
if err != nil {
health.ReportError(health.ZeroBootstrapConfigSave, err)
} else {
health.ReportOK(health.ZeroBootstrapConfigSave)
}
return err
}
func saveBootstrapConfigToFile(src *cluster_api.BootstrapConfig, fp string, cipher cipher.AEAD) error {
plaintext, err := json.Marshal(src)
if err != nil {
return fmt.Errorf("marshal file config: %w", err)