mirror of
https://github.com/photoprism/photoprism.git
synced 2025-12-12 00:34:13 +01:00
CLI: Add audit logs to cluster management commands
Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
@@ -8,7 +8,11 @@ import (
|
||||
"net/url"
|
||||
"strings"
|
||||
|
||||
"github.com/urfave/cli/v2"
|
||||
|
||||
"github.com/photoprism/photoprism/internal/config"
|
||||
"github.com/photoprism/photoprism/internal/service/cluster"
|
||||
"github.com/photoprism/photoprism/pkg/clean"
|
||||
"github.com/photoprism/photoprism/pkg/http/header"
|
||||
)
|
||||
|
||||
@@ -53,3 +57,23 @@ func obtainClientCredentialsViaRegister(portalURL, joinToken, nodeName string) (
|
||||
}
|
||||
return id, secret, nil
|
||||
}
|
||||
|
||||
// clusterAuditWho builds the leading audit log segments for CLI commands.
|
||||
func clusterAuditWho(ctx *cli.Context, conf *config.Config) []string {
|
||||
actor := clean.Log(conf.NodeName())
|
||||
if actor == "" {
|
||||
actor = clean.Log(conf.SiteUrl())
|
||||
}
|
||||
if actor == "" {
|
||||
actor = "cli"
|
||||
}
|
||||
|
||||
context := "cli"
|
||||
if ctx != nil && ctx.Command != nil {
|
||||
if full := strings.TrimSpace(ctx.Command.FullName()); full != "" {
|
||||
context = "cli " + full
|
||||
}
|
||||
}
|
||||
|
||||
return []string{actor, context}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user