mirror of
https://github.com/hanzoai/git-runner.git
synced 2026-11-14 02:38:33 +00:00
The GITEA_->GIT_ rename landed on upstream's back-compat table, turning GITEA_DEBUG/GITEA_TRACE into GIT_DEBUG/GIT_TRACE — git's OWN variables. Anyone debugging git with GIT_TRACE=1 would silently reconfigure the runner's log level. This fork was born on GIT_*, so it has no deprecated names to support and the whole table goes. Also: our release lane pushed a MUTABLE :0.6.1 beside the immutable 0.6.1-hanzo.<sha> — the pin law we hold everything else to. Dropped. LDFLAGS -X named a module that does not exist, so the version string was never set. Deleted three orphan release mechanisms (goreleaser, Makefile release targets, half-renamed examples), the upstream renovate preset pointer, the s6 service dir name, the .gitea/workflows exec default, and the state-file banner. Co-authored-by: Hanzo Dev <[email protected]>
56 lines
1.3 KiB
Go
56 lines
1.3 KiB
Go
// Copyright 2023 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package config
|
|
|
|
import (
|
|
"encoding/json"
|
|
"os"
|
|
)
|
|
|
|
const registrationWarning = "This file is automatically generated by git-runner. Do not edit it manually unless you know what you are doing. Removing this file will cause git-runner to re-register as a new runner."
|
|
|
|
// Registration is the registration information for a runner
|
|
type Registration struct {
|
|
Warning string `json:"WARNING"` // Warning message to display, it's always the registrationWarning constant
|
|
|
|
ID int64 `json:"id"`
|
|
UUID string `json:"uuid"`
|
|
Name string `json:"name"`
|
|
Token string `json:"token"`
|
|
Address string `json:"address"`
|
|
Labels []string `json:"labels"`
|
|
Ephemeral bool `json:"ephemeral"`
|
|
}
|
|
|
|
func LoadRegistration(file string) (*Registration, error) {
|
|
f, err := os.Open(file)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer f.Close()
|
|
|
|
var reg Registration
|
|
if err := json.NewDecoder(f).Decode(®); err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
reg.Warning = ""
|
|
|
|
return ®, nil
|
|
}
|
|
|
|
func SaveRegistration(file string, reg *Registration) error {
|
|
f, err := os.Create(file)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
defer f.Close()
|
|
|
|
reg.Warning = registrationWarning
|
|
|
|
enc := json.NewEncoder(f)
|
|
enc.SetIndent("", " ")
|
|
return enc.Encode(reg)
|
|
}
|