daemon: improve error messages

Signed-off-by: Frank Villaro-Dixon <frank@villaro-dixon.eu>
pull/179/head
Frank Villaro-Dixon 2024-04-10 00:09:50 +02:00
parent 8a2d4cb7cb
commit be2063abf5
1 changed files with 3 additions and 3 deletions

View File

@ -103,14 +103,14 @@ func runDaemon(ctx context.Context, configFile *string) func(cmd *cobra.Command,
resp, err := runner.Declare(ctx, ls.Names()) resp, err := runner.Declare(ctx, ls.Names())
if err != nil && connect.CodeOf(err) == connect.CodeUnimplemented { if err != nil && connect.CodeOf(err) == connect.CodeUnimplemented {
// Gitea instance is older version. skip declare step. // Gitea instance is older version. skip declare step.
log.Warn("Because the Forgejo instance is an old version, skip declare labels and version.") log.Warn("Because the Forgejo instance is an old version, skipping declaring the labels and version.")
} else if err != nil { } else if err != nil {
log.WithError(err).Error("fail to invoke Declare") log.WithError(err).Error("fail to invoke Declare")
return err return err
} else { } else {
log.Infof("runner: %s, with version: %s, with labels: %v, declare successfully", log.Infof("runner: %s, with version: %s, with labels: %v, declared successfully",
resp.Msg.Runner.Name, resp.Msg.Runner.Version, resp.Msg.Runner.Labels) resp.Msg.Runner.Name, resp.Msg.Runner.Version, resp.Msg.Runner.Labels)
// if declare successfully, override the labels in the.runner file with valid labels in the config file (if specified) // if declared successfully, override the labels in the.runner file with valid labels in the config file (if specified)
reg.Labels = ls.ToStrings() reg.Labels = ls.ToStrings()
if err := config.SaveRegistration(cfg.Runner.File, reg); err != nil { if err := config.SaveRegistration(cfg.Runner.File, reg); err != nil {
return fmt.Errorf("failed to save runner config: %w", err) return fmt.Errorf("failed to save runner config: %w", err)