diff --git a/pkg/api/provider.go b/pkg/api/provider.go index 622cfa3..0f2e4aa 100644 --- a/pkg/api/provider.go +++ b/pkg/api/provider.go @@ -10,10 +10,10 @@ import ( "strconv" "syscall" - "forge.lthn.ai/core/api" - "forge.lthn.ai/core/api/pkg/provider" process "dappco.re/go/core/process" "dappco.re/go/core/ws" + "forge.lthn.ai/core/api" + "forge.lthn.ai/core/api/pkg/provider" "github.com/gin-gonic/gin" ) @@ -119,6 +119,8 @@ func (p *ProcessProvider) Describe() []api.RouteDescription { "daemon": map[string]any{"type": "string"}, "pid": map[string]any{"type": "integer"}, "health": map[string]any{"type": "string"}, + "project": map[string]any{"type": "string"}, + "binary": map[string]any{"type": "string"}, "started": map[string]any{"type": "string", "format": "date-time"}, }, }, @@ -147,6 +149,7 @@ func (p *ProcessProvider) Describe() []api.RouteDescription { "properties": map[string]any{ "healthy": map[string]any{"type": "boolean"}, "address": map[string]any{"type": "string"}, + "reason": map[string]any{"type": "string"}, }, }, }, diff --git a/pkg/api/provider_test.go b/pkg/api/provider_test.go index aa92075..ec06882 100644 --- a/pkg/api/provider_test.go +++ b/pkg/api/provider_test.go @@ -49,6 +49,14 @@ func TestProcessProvider_Describe_Good(t *testing.T) { assert.NotEmpty(t, d.Summary) assert.NotEmpty(t, d.Tags) } + + for _, d := range descs { + if d.Path == "/daemons/:code/:daemon/health" { + props, ok := d.Response["properties"].(map[string]any) + require.True(t, ok) + assert.Contains(t, props, "reason") + } + } } func TestProcessProvider_ListDaemons_Good(t *testing.T) { diff --git a/program.go b/program.go index ab40876..4e42902 100644 --- a/program.go +++ b/program.go @@ -58,6 +58,9 @@ func (p *Program) RunDir(ctx context.Context, dir string, args ...string) (strin if binary == "" { binary = p.Name } + if ctx == nil { + ctx = context.Background() + } var out bytes.Buffer cmd := execCommandContext(ctx, binary, args...) diff --git a/program_test.go b/program_test.go index 67e6410..d6dd7fa 100644 --- a/program_test.go +++ b/program_test.go @@ -56,6 +56,14 @@ func TestProgram_RunFallback_Good(t *testing.T) { assert.Equal(t, "fallback", out) } +func TestProgram_RunNilContext_Good(t *testing.T) { + p := &process.Program{Name: "echo"} + + out, err := p.Run(nil, "nil-context") + require.NoError(t, err) + assert.Equal(t, "nil-context", out) +} + func TestProgram_RunDir_Good(t *testing.T) { p := &process.Program{Name: "pwd"} require.NoError(t, p.Find())