agent/pkg/setup/service.go
Virgil 0779a7dbe5 refactor(setup-monitor): align service option names with RFC
Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-02 08:13:16 +00:00

44 lines
1.1 KiB
Go

// SPDX-License-Identifier: EUPL-1.2
package setup
import (
"context"
core "dappco.re/go/core"
)
// options := setup.SetupOptions{}
type SetupOptions struct{}
// RuntimeOptions is kept as a compatibility alias for older callers.
type RuntimeOptions = SetupOptions
// c := core.New(core.WithService(setup.Register))
// service := c.Service("setup")
type Service struct {
*core.ServiceRuntime[SetupOptions]
}
// c := core.New(core.WithService(setup.Register))
// service := c.Service("setup")
func Register(c *core.Core) core.Result {
service := &Service{
ServiceRuntime: core.NewServiceRuntime(c, SetupOptions{}),
}
return core.Result{Value: service, OK: true}
}
// result := service.OnStartup(context.Background())
func (s *Service) OnStartup(ctx context.Context) core.Result {
return core.Result{OK: true}
}
// remote := service.DetectGitRemote("/srv/repos/agent")
func (s *Service) DetectGitRemote(path string) string {
result := s.Core().Process().RunIn(context.Background(), path, "git", "remote", "get-url", "origin")
if !result.OK {
return ""
}
return parseGitRemote(core.Trim(result.Value.(string)))
}