Add "create" and "remove" events for secrets.

This commit adds the "secret" Event type and emits
"create" and "remove" events for this Event type
when Secret is created or removed.

This can be used for example by podman interfaces to
view and manage secrets.

Fixes: #24030

Signed-off-by: Jan Kaluza <jkaluza@redhat.com>
This commit is contained in:
Jan Kaluza
2025-02-28 11:04:36 +01:00
parent 350429cc3c
commit 20523152f8
8 changed files with 42 additions and 2 deletions

View File

@ -191,6 +191,16 @@ func (v *Volume) newVolumeEvent(status events.Status) {
}
}
// NewSecretEvent creates a new event for a libpod secret
func (r *Runtime) NewSecretEvent(status events.Status, secretID string) {
e := events.NewEvent(status)
e.ID = secretID
e.Type = events.Secret
if err := r.eventer.Write(e); err != nil {
logrus.Errorf("Unable to write secret event: %q", err)
}
}
// Events is a wrapper function for everyone to begin tailing the events log
// with options
func (r *Runtime) Events(ctx context.Context, options events.ReadOptions) error {