Skip to content

Commit e1c42ef

Browse files
committed
cmd: move command.go into a new package
Move 'command.go' (containing the 'CommandExecutor' interface) into a new package 'cmd'. This helps set up for future enhancements to the interface, including the addition of supplemental types (like 'cmd.Setting', used to configure the behavior of the 'Run()' function). Signed-off-by: Victoria Dye <[email protected]>
1 parent 686d758 commit e1c42ef

File tree

5 files changed

+13
-9
lines changed

5 files changed

+13
-9
lines changed

cmd/utils/container-helpers.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55

66
"github.com/github/git-bundle-server/internal/bundles"
7+
"github.com/github/git-bundle-server/internal/cmd"
78
"github.com/github/git-bundle-server/internal/common"
89
"github.com/github/git-bundle-server/internal/core"
910
"github.com/github/git-bundle-server/internal/daemon"
@@ -15,8 +16,8 @@ func BuildGitBundleServerContainer(logger log.TraceLogger) *DependencyContainer
1516
registerDependency(container, func(ctx context.Context) common.UserProvider {
1617
return common.NewUserProvider()
1718
})
18-
registerDependency(container, func(ctx context.Context) common.CommandExecutor {
19-
return common.NewCommandExecutor()
19+
registerDependency(container, func(ctx context.Context) cmd.CommandExecutor {
20+
return cmd.NewCommandExecutor()
2021
})
2122
registerDependency(container, func(ctx context.Context) common.FileSystem {
2223
return common.NewFileSystem()
@@ -35,7 +36,7 @@ func BuildGitBundleServerContainer(logger log.TraceLogger) *DependencyContainer
3536
t, err := daemon.NewDaemonProvider(
3637
logger,
3738
GetDependency[common.UserProvider](ctx, container),
38-
GetDependency[common.CommandExecutor](ctx, container),
39+
GetDependency[cmd.CommandExecutor](ctx, container),
3940
GetDependency[common.FileSystem](ctx, container),
4041
)
4142
if err != nil {

internal/common/command.go renamed to internal/cmd/command.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package common
1+
package cmd
22

33
import (
44
"fmt"

internal/daemon/daemon.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"fmt"
66
"runtime"
77

8+
"github.com/github/git-bundle-server/internal/cmd"
89
"github.com/github/git-bundle-server/internal/common"
910
"github.com/github/git-bundle-server/internal/log"
1011
)
@@ -29,7 +30,7 @@ type DaemonProvider interface {
2930
func NewDaemonProvider(
3031
l log.TraceLogger,
3132
u common.UserProvider,
32-
c common.CommandExecutor,
33+
c cmd.CommandExecutor,
3334
fs common.FileSystem,
3435
) (DaemonProvider, error) {
3536
switch thisOs := runtime.GOOS; thisOs {

internal/daemon/launchd.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"fmt"
88
"path/filepath"
99

10+
"github.com/github/git-bundle-server/internal/cmd"
1011
"github.com/github/git-bundle-server/internal/common"
1112
"github.com/github/git-bundle-server/internal/log"
1213
"github.com/github/git-bundle-server/internal/utils"
@@ -94,14 +95,14 @@ func (c *launchdConfig) toPlist() *plist {
9495
type launchd struct {
9596
logger log.TraceLogger
9697
user common.UserProvider
97-
cmdExec common.CommandExecutor
98+
cmdExec cmd.CommandExecutor
9899
fileSystem common.FileSystem
99100
}
100101

101102
func NewLaunchdProvider(
102103
l log.TraceLogger,
103104
u common.UserProvider,
104-
c common.CommandExecutor,
105+
c cmd.CommandExecutor,
105106
fs common.FileSystem,
106107
) DaemonProvider {
107108
return &launchd{

internal/daemon/systemd.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"strings"
99
"text/template"
1010

11+
"github.com/github/git-bundle-server/internal/cmd"
1112
"github.com/github/git-bundle-server/internal/common"
1213
"github.com/github/git-bundle-server/internal/log"
1314
)
@@ -25,14 +26,14 @@ const SystemdUnitNotInstalledErrorCode int = 5
2526
type systemd struct {
2627
logger log.TraceLogger
2728
user common.UserProvider
28-
cmdExec common.CommandExecutor
29+
cmdExec cmd.CommandExecutor
2930
fileSystem common.FileSystem
3031
}
3132

3233
func NewSystemdProvider(
3334
l log.TraceLogger,
3435
u common.UserProvider,
35-
c common.CommandExecutor,
36+
c cmd.CommandExecutor,
3637
fs common.FileSystem,
3738
) DaemonProvider {
3839
return &systemd{

0 commit comments

Comments
 (0)