Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/solo/subcommand/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (

"github.com/spf13/cobra"

"github.com/spaulg/solo/internal/pkg/common/domain/version"
"github.com/spaulg/solo/internal/pkg/host/app/context"
"github.com/spaulg/solo/internal/pkg/host/app/version"
)

func NewVersionCommand(_ *context.CliContext) *cobra.Command {
Expand Down
4 changes: 1 addition & 3 deletions internal/pkg/architecture_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@ func (t *ArchitectureTestSuite) SetupTest() {
}

func (t *ArchitectureTestSuite) TestLayerDependencies() {
t.T().Skipf("Skipping architecture test as the architecture is still evolving." +
" Re-enable once the architecture is stable.")

configuration := archgo_config.Config{
DependenciesRules: []*archgo_config.DependenciesRule{
// Commands
Expand All @@ -67,6 +64,7 @@ func (t *ArchitectureTestSuite) TestLayerDependencies() {
Internal: []string{
t.moduleName + "/cmd/solo-entrypoint.**",
t.moduleName + "/internal/pkg/entrypoint.**",
t.moduleName + "/internal/pkg/common/domain.**",
},
},
},
Expand Down
36 changes: 18 additions & 18 deletions internal/pkg/host/app/audit/state_directory_auditor.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (
"sync"

"github.com/spaulg/solo/internal/pkg/host/app/context"
"github.com/spaulg/solo/internal/pkg/host/app/event_manager/events"
"github.com/spaulg/solo/internal/pkg/host/app/wms/wf"
domain2 "github.com/spaulg/solo/internal/pkg/host/domain"
"github.com/spaulg/solo/internal/pkg/host/domain"
"github.com/spaulg/solo/internal/pkg/host/domain/events"
)

const auditLogsPath = "audit_logs"
Expand All @@ -19,25 +19,25 @@ const metaFileSuffix = ".meta.json"
type StateDirectoryAuditor struct {
soloCtx *context.CliContext
logger *slog.Logger
config *domain2.Config
project domain2.Project
config *domain.Config
project domain.Project
mu sync.Mutex
outputDirectory string
executionEventRepository domain2.ExecutionEventRepository
workflowLogMetaRepository domain2.WorkflowLogMetaRepository
workflowStepLogMetaRepository domain2.WorkflowStepLogMetaRepository
logWriter domain2.LogWriter
executionEventRepository domain.ExecutionEventRepository
workflowLogMetaRepository domain.WorkflowLogMetaRepository
workflowStepLogMetaRepository domain.WorkflowStepLogMetaRepository
logWriter domain.LogWriter
}

func NewAuditor(
soloCtx *context.CliContext,
logger *slog.Logger,
config *domain2.Config,
project domain2.Project,
executionEventRepository domain2.ExecutionEventRepository,
workflowLogMetaRepository domain2.WorkflowLogMetaRepository,
workflowStepLogMetaRepository domain2.WorkflowStepLogMetaRepository,
logWriter domain2.LogWriter,
config *domain.Config,
project domain.Project,
executionEventRepository domain.ExecutionEventRepository,
workflowLogMetaRepository domain.WorkflowLogMetaRepository,
workflowStepLogMetaRepository domain.WorkflowStepLogMetaRepository,
logWriter domain.LogWriter,
) *StateDirectoryAuditor {
outputDirectory := path.Join(
project.GetStateDirectoryRoot(),
Expand All @@ -61,7 +61,7 @@ func NewAuditor(
func (t *StateDirectoryAuditor) RecordExecutionEvent(callback func() error) error {
eventFile := path.Join(t.outputDirectory, executionEventFile)

workflowEvent := domain2.NewExecutionEvent(t.soloCtx.CommandPath, t.soloCtx.CommandArgs)
workflowEvent := domain.NewExecutionEvent(t.soloCtx.CommandPath, t.soloCtx.CommandArgs)
if err := t.executionEventRepository.Save(eventFile, workflowEvent); err != nil {
return fmt.Errorf("failed to record workflow event start: %w", err)
}
Expand Down Expand Up @@ -113,7 +113,7 @@ func (t *StateDirectoryAuditor) writeStepOutput(e *wf.StepOutputEvent) {
}

if meta == nil {
meta = domain2.NewWorkflowStepLogMeta()
meta = domain.NewWorkflowStepLogMeta()

if err := t.workflowStepLogMetaRepository.Save(filePath, meta); err != nil {
t.logger.Error(fmt.Sprintf(
Expand Down Expand Up @@ -187,7 +187,7 @@ func (t *StateDirectoryAuditor) writeStepResult(e *wf.StepCompleteEvent) {
}

if metaJSON == nil {
metaJSON = domain2.NewWorkflowStepLogMeta()
metaJSON = domain.NewWorkflowStepLogMeta()
}

metaJSON.SetExecutionInfo(e.ExitCode, e.Command, e.Arguments, e.Cwd)
Expand All @@ -213,7 +213,7 @@ func (t *StateDirectoryAuditor) writeStepResult(e *wf.StepCompleteEvent) {
}

if workflowMeta == nil {
workflowMeta = domain2.NewWorkflowLogMeta()
workflowMeta = domain.NewWorkflowLogMeta()
}

workflowMeta.AppendStep(e.ContainerName, e.StepID)
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/host/app/auditor.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package app

import (
"github.com/spaulg/solo/internal/pkg/host/app/event_manager/events"
"github.com/spaulg/solo/internal/pkg/host/domain/events"
)

type Auditor interface {
Expand Down
16 changes: 8 additions & 8 deletions internal/pkg/host/app/event_manager/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ package event_manager
import (
"sync"

events2 "github.com/spaulg/solo/internal/pkg/host/app/event_manager/events"
"github.com/spaulg/solo/internal/pkg/host/domain/events"
)

type Manager struct {
subscribers map[events2.Subscriber]chan events2.Event
subscribers map[events.Subscriber]chan events.Event
mu sync.RWMutex
wg sync.WaitGroup
}
Expand All @@ -28,26 +28,26 @@ func GetEventManagerInstance() *Manager {

func NewEventManager() *Manager {
return &Manager{
subscribers: make(map[events2.Subscriber]chan events2.Event),
subscribers: make(map[events.Subscriber]chan events.Event),
}
}

func (t *Manager) Subscribe(eventSubscriber events2.Subscriber) {
func (t *Manager) Subscribe(eventSubscriber events.Subscriber) {
t.mu.Lock()
defer t.mu.Unlock()

subscriberChannel := make(chan events2.Event, 30)
subscriberChannel := make(chan events.Event, 30)
t.subscribers[eventSubscriber] = subscriberChannel

go func(subscriber events2.Subscriber) {
go func(subscriber events.Subscriber) {
for val := range subscriberChannel {
subscriber.Publish(val)
t.wg.Done()
}
}(eventSubscriber)
}

func (t *Manager) Unsubscribe(eventSubscriber events2.Subscriber) {
func (t *Manager) Unsubscribe(eventSubscriber events.Subscriber) {
t.mu.Lock()
defer t.mu.Unlock()

Expand All @@ -57,7 +57,7 @@ func (t *Manager) Unsubscribe(eventSubscriber events2.Subscriber) {
}
}

func (t *Manager) Publish(event events2.Event) {
func (t *Manager) Publish(event events.Event) {
t.mu.RLock()
defer t.mu.RUnlock()

Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/host/app/project_control.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import (

workflowcommon "github.com/spaulg/solo/internal/pkg/common/domain/wms"
"github.com/spaulg/solo/internal/pkg/host/app/context"
"github.com/spaulg/solo/internal/pkg/host/app/event_manager/events"
"github.com/spaulg/solo/internal/pkg/host/app/project"
"github.com/spaulg/solo/internal/pkg/host/app/wms"
"github.com/spaulg/solo/internal/pkg/host/domain"
"github.com/spaulg/solo/internal/pkg/host/domain/events"
"github.com/spaulg/solo/internal/pkg/host/infra/grpc"
)

Expand Down
9 changes: 9 additions & 0 deletions internal/pkg/host/app/version/retrieval.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package version

import (
domain_version "github.com/spaulg/solo/internal/pkg/common/domain/version"
)

func Get() domain_version.Info {
return domain_version.Get()
}
2 changes: 1 addition & 1 deletion internal/pkg/host/app/wms/wf/guard.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package wf

import (
workflowcommon "github.com/spaulg/solo/internal/pkg/common/domain/wms"
"github.com/spaulg/solo/internal/pkg/host/app/event_manager/events"
"github.com/spaulg/solo/internal/pkg/host/domain/events"
)

type Guard interface {
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/host/app/wms/workflow_guard.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import (
"time"

workflowcommon "github.com/spaulg/solo/internal/pkg/common/domain/wms"
"github.com/spaulg/solo/internal/pkg/host/app/event_manager/events"
"github.com/spaulg/solo/internal/pkg/host/app/wms/wf"
domain2 "github.com/spaulg/solo/internal/pkg/host/domain"
"github.com/spaulg/solo/internal/pkg/host/domain/events"
)

type WorkflowGuard struct {
Expand Down
9 changes: 5 additions & 4 deletions internal/pkg/host/app/wms/workflow_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ package wms
import (
"fmt"

"github.com/spaulg/solo/internal/pkg/host/app/event_manager/events"
wf2 "github.com/spaulg/solo/internal/pkg/host/app/wms/wf"
domain2 "github.com/spaulg/solo/internal/pkg/host/domain"
"github.com/spaulg/solo/internal/pkg/host/domain/events"
"github.com/spaulg/solo/internal/pkg/host/infra/grpc/service_definitions/wfsession"
)

type WorkflowRunner struct {
Expand All @@ -29,7 +30,7 @@ func NewWorkflowRunner(
}
}

func (t *WorkflowRunner) RunWorkflow(workflowSession wf2.Session) error {
func (t *WorkflowRunner) RunWorkflow(workflowSession wfsession.Session) error {
// Handle previously run once-only workflows
hasServiceWorkflowRun, err := workflowSession.HasServiceWorkflowRun(workflowSession.GetServiceName())
if err != nil {
Expand Down Expand Up @@ -69,7 +70,7 @@ func (t *WorkflowRunner) RunWorkflow(workflowSession wf2.Session) error {
return workflowSession.MarkCompletion()
}

func (t *WorkflowRunner) handleRunWorkflow(workflowSession wf2.Session) (bool, error) {
func (t *WorkflowRunner) handleRunWorkflow(workflowSession wfsession.Session) (bool, error) {
workflowSuccess := true

t.eventManager.Publish(&wf2.StartedEvent{
Expand Down Expand Up @@ -117,7 +118,7 @@ func (t *WorkflowRunner) handleRunWorkflow(workflowSession wf2.Session) (bool, e
Shell: step.GetShell(),
})

return workflowSession.RunCommand(&wf2.RunCommandRequest{
return workflowSession.RunCommand(&wfsession.RunCommandRequest{
Command: step.GetCommand(),
Arguments: step.GetArguments(),
WorkingDirectory: step.GetWorkingDirectory(),
Expand Down
7 changes: 4 additions & 3 deletions internal/pkg/host/app/wms/workflow_runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/spaulg/solo/internal/pkg/host/app/wms/wf"
"github.com/spaulg/solo/internal/pkg/host/domain"
"github.com/spaulg/solo/internal/pkg/host/domain/config"
"github.com/spaulg/solo/internal/pkg/host/infra/grpc/service_definitions/wfsession"
"github.com/spaulg/solo/test"
"github.com/spaulg/solo/test/mocks/host/app/events"
"github.com/spaulg/solo/test/mocks/host/app/wms"
Expand Down Expand Up @@ -147,7 +148,7 @@ func (t *WorkflowRunnerTestSuite) testWorkflowExecFor(wfName commonworkflow.Work
Shell: "/bin/sh",
}).Return()

t.workflowSession.On("RunCommand", &wf.RunCommandRequest{
t.workflowSession.On("RunCommand", &wfsession.RunCommandRequest{
Command: "/bin/sh",
Arguments: []string{"-c", "echo \"Hello World\""},
WorkingDirectory: "/",
Expand All @@ -160,7 +161,7 @@ func (t *WorkflowRunnerTestSuite) testWorkflowExecFor(wfName commonworkflow.Work
t.Nil(err)

// progress
t.workflowSession.On("RecvCommandResponse").Return(&wf.CommandResponse{
t.workflowSession.On("RecvCommandResponse").Return(&wfsession.CommandResponse{
Stdout: "Hello World",
Stderr: "",
ExitCode: &exitCode,
Expand Down Expand Up @@ -518,7 +519,7 @@ func (t *WorkflowRunnerTestSuite) testServerRecvErrorFor(wfName commonworkflow.W
Shell: "/bin/sh",
}).Return()

t.workflowSession.On("RunCommand", &wf.RunCommandRequest{
t.workflowSession.On("RunCommand", &wfsession.RunCommandRequest{
Command: "/bin/sh",
Arguments: []string{"-c", "echo \"Hello World\""},
WorkingDirectory: "/",
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/host/infra/container/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import (
"github.com/compose-spec/compose-go/v2/types"
"google.golang.org/grpc/metadata"

"github.com/spaulg/solo/internal/pkg/host/app/event_manager/events"
domain2 "github.com/spaulg/solo/internal/pkg/host/domain"
"github.com/spaulg/solo/internal/pkg/host/domain/events"
"github.com/spaulg/solo/internal/pkg/host/infra/container/progress"
)

Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/host/infra/container/orchestrator_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"log/slog"
"os/exec"

"github.com/spaulg/solo/internal/pkg/host/app/event_manager/events"
domain2 "github.com/spaulg/solo/internal/pkg/host/domain"
"github.com/spaulg/solo/internal/pkg/host/domain/events"
)

type OrchestratorFactory struct {
Expand Down
12 changes: 6 additions & 6 deletions internal/pkg/host/infra/container/progress/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,23 @@ import (
"io"
"log/slog"

"github.com/spaulg/solo/internal/pkg/host/app/event_manager/events"
domain2 "github.com/spaulg/solo/internal/pkg/host/domain"
"github.com/spaulg/solo/internal/pkg/host/domain"
"github.com/spaulg/solo/internal/pkg/host/domain/events"
)

type ProgressEventPublisher struct {
logger *slog.Logger
config *domain2.Config
project domain2.Project
config *domain.Config
project domain.Project
eventManager events.Manager
projectName string
stream io.ReadCloser
}

func NewProgressEventPublisher(
logger *slog.Logger,
config *domain2.Config,
project domain2.Project,
config *domain.Config,
project domain.Project,
eventManager events.Manager,
projectName string,
stream io.ReadCloser,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package wfsession

type CommandResponse struct {
Stdout string
Stderr string
ExitCode *uint8
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package wfsession

type RunCommandRequest struct {
Command string
Arguments []string
WorkingDirectory string
}
Original file line number Diff line number Diff line change
@@ -1,21 +1,9 @@
package wf
package wfsession

import (
commonworkflow "github.com/spaulg/solo/internal/pkg/common/domain/wms"
)

type RunCommandRequest struct {
Command string
Arguments []string
WorkingDirectory string
}

type CommandResponse struct {
Stdout string
Stderr string
ExitCode *uint8
}

type Session interface {
GetWorkflowName() commonworkflow.WorkflowName
HasServiceWorkflowRun(serviceName string) (bool, error)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package service_definitions

import (
"github.com/spaulg/solo/internal/pkg/host/app/wms/wf"
"github.com/spaulg/solo/internal/pkg/host/infra/grpc/service_definitions/wfsession"
)

type WorkflowRunner interface {
RunWorkflow(workflowSession wf.Session) error
RunWorkflow(workflowSession wfsession.Session) error
}
Loading