agent/pkg/setup/service.go
Virgil f0c903d8c3 fix(ax): replace typed service lookups with Core.Service
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-31 05:43:14 +00:00

41 lines
1 KiB
Go

// SPDX-License-Identifier: EUPL-1.2
package setup
import (
"context"
core "dappco.re/go/core"
)
// options := setup.RuntimeOptions{}
type RuntimeOptions struct{}
// c := core.New(core.WithService(setup.Register))
// service := c.Service("setup")
type Service struct {
*core.ServiceRuntime[RuntimeOptions]
}
// c := core.New(core.WithService(setup.Register))
// service := c.Service("setup")
func Register(c *core.Core) core.Result {
service := &Service{
ServiceRuntime: core.NewServiceRuntime(c, RuntimeOptions{}),
}
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)))
}