diff --git a/Makefile b/Makefile index c177c0751..e0656f179 100644 --- a/Makefile +++ b/Makefile @@ -18,7 +18,8 @@ VERSION=${DEFAULT_VERSION} endif PLATFORM_TARGETS=$(addprefix release-, $(PLATFORMS)) -LDFLAGS=-w -s -X main.Version=${VERSION} +COMMIT=$(shell git rev-parse --short HEAD) +LDFLAGS=-w -s -X main.Version=${VERSION} -X main.Commit=${COMMIT} CMD_COLOR_ON=\033[32m\xE2\x9c\x93 CMD_COLOR_OFF=\033[0m diff --git a/cmd/fleet/main.go b/cmd/fleet/main.go index a2a87dae1..3c619da54 100644 --- a/cmd/fleet/main.go +++ b/cmd/fleet/main.go @@ -68,7 +68,26 @@ func makeCache(cfg *config.Config) (cache.Cache, error) { return cache.New(cacheCfg) } -func getRunCommand(version string) func(cmd *cobra.Command, args []string) error { +func initLogger(cfg *config.Config, version, commit string) (*logger.Logger, error) { + l, err := logger.Init(cfg) + if err != nil { + return nil, err + } + + log.Info(). + Str("version", version). + Str("commit", commit). + Int("pid", os.Getpid()). + Int("ppid", os.Getppid()). + Str("exe", os.Args[0]). + Strs("args", os.Args[1:]). + Msg("boot") + log.Debug().Strs("env", os.Environ()).Msg("environment") + + return l, err +} + +func getRunCommand(version, commit string) func(cmd *cobra.Command, args []string) error { return func(cmd *cobra.Command, args []string) error { cfgObject := cmd.Flags().Lookup("E").Value.(*config.Flag) cliCfg := cfgObject.Config() @@ -85,7 +104,7 @@ func getRunCommand(version string) func(cmd *cobra.Command, args []string) error if err != nil { return err } - l, err = logger.Init(cfg) + l, err = initLogger(cfg, version, commit) if err != nil { return err } @@ -119,7 +138,7 @@ func getRunCommand(version string) func(cmd *cobra.Command, args []string) error return err } - l, err = logger.Init(cfg) + l, err = initLogger(cfg, version, commit) if err != nil { return err } @@ -147,11 +166,11 @@ func getRunCommand(version string) func(cmd *cobra.Command, args []string) error } } -func NewCommand(version string) *cobra.Command { +func NewCommand(version, commit string) *cobra.Command { cmd := &cobra.Command{ Use: "fleet-server", Short: "Fleet Server controls a fleet of Elastic Agents", - RunE: getRunCommand(version), + RunE: getRunCommand(version, commit), } cmd.Flags().StringP("config", "c", "fleet-server.yml", "Configuration for Fleet Server") cmd.Flags().Bool(kAgentMode, false, "Running under execution of the Elastic Agent") diff --git a/dev-tools/integration/.env b/dev-tools/integration/.env index ef0e7d05d..cb72652b4 100644 --- a/dev-tools/integration/.env +++ b/dev-tools/integration/.env @@ -1,4 +1,4 @@ -ELASTICSEARCH_VERSION=8.0.0-bd957996-SNAPSHOT +ELASTICSEARCH_VERSION=8.0.0-5197c308-SNAPSHOT ELASTICSEARCH_USERNAME=elastic ELASTICSEARCH_PASSWORD=changeme TEST_ELASTICSEARCH_HOSTS=localhost:9200 \ No newline at end of file diff --git a/internal/pkg/apikey/invalidate.go b/internal/pkg/apikey/invalidate.go index 2e47ea6df..1a4b0abde 100644 --- a/internal/pkg/apikey/invalidate.go +++ b/internal/pkg/apikey/invalidate.go @@ -18,9 +18,11 @@ import ( func Invalidate(ctx context.Context, client *elasticsearch.Client, ids ...string) error { payload := struct { - IDs []string `json:"ids,omitempty"` + IDs []string `json:"ids,omitempty"` + Owner bool `json:"owner"` }{ ids, + true, } body, err := json.Marshal(&payload) diff --git a/internal/pkg/logger/logger.go b/internal/pkg/logger/logger.go index 7ea38f75a..420b08a6a 100644 --- a/internal/pkg/logger/logger.go +++ b/internal/pkg/logger/logger.go @@ -88,14 +88,6 @@ func Init(cfg *config.Config) (*Logger, error) { if !cfg.Logging.Pretty || !cfg.Logging.ToStderr { zerolog.TimestampFunc = func() time.Time { return time.Now().UTC() } } - - log.Info(). - Int("pid", os.Getpid()). - Int("ppid", os.Getppid()). - Str("exe", os.Args[0]). - Strs("args", os.Args[1:]). - Msg("boot") - log.Debug().Strs("env", os.Environ()).Msg("environment") }) return gLogger, err } diff --git a/main.go b/main.go index b1aec97ea..105ac052e 100644 --- a/main.go +++ b/main.go @@ -23,10 +23,11 @@ const defaultVersion = "8.0.0" var ( Version string = defaultVersion + Commit string ) func main() { - cmd := fleet.NewCommand(Version) + cmd := fleet.NewCommand(Version, Commit) if err := cmd.Execute(); err != nil { fmt.Fprintln(os.Stderr, err) os.Exit(1)