feat: coordinate Active Profile target panel
This commit is contained in:
+24
-1
@@ -15,7 +15,10 @@ import (
|
||||
"golang.org/x/sys/unix"
|
||||
|
||||
"proxyctl/internal/app"
|
||||
"proxyctl/internal/apt"
|
||||
"proxyctl/internal/dockerclient"
|
||||
"proxyctl/internal/dockerdaemon"
|
||||
"proxyctl/internal/gnome"
|
||||
"proxyctl/internal/operationlock"
|
||||
"proxyctl/internal/oplog"
|
||||
"proxyctl/internal/profile"
|
||||
@@ -76,7 +79,10 @@ func runWithEnvironmentAndTargets(args []string, input io.Reader, output io.Writ
|
||||
}
|
||||
shellTarget := shell.New(shellConfiguration, files, environment)
|
||||
if systemTargets == nil {
|
||||
systemTargets = []target.Target{dockerdaemon.New(dockerdaemon.DefaultConfiguration(), nil, nil)}
|
||||
systemTargets, err = productionTargets(environment)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
targets := append([]target.Target{shellTarget}, systemTargets...)
|
||||
stateDirectory := filepath.Dir(shellConfiguration.RecoveryFile)
|
||||
@@ -136,6 +142,23 @@ func runWithEnvironmentAndTargets(args []string, input io.Reader, output io.Writ
|
||||
return err
|
||||
}
|
||||
|
||||
func productionTargets(environment profile.IdentityEnvironment) ([]target.Target, error) {
|
||||
dockerClientConfiguration, err := dockerclient.ResolveConfiguration(environment)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("resolve Docker containers/builds Target configuration: %w", err)
|
||||
}
|
||||
gnomeConfiguration, err := gnome.ResolveConfiguration(environment)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("resolve GNOME Target configuration: %w", err)
|
||||
}
|
||||
return []target.Target{
|
||||
apt.New(apt.DefaultConfiguration(), nil, nil),
|
||||
dockerclient.New(dockerClientConfiguration, nil),
|
||||
gnome.New(gnomeConfiguration, nil, nil),
|
||||
dockerdaemon.New(dockerdaemon.DefaultConfiguration(), nil, nil),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func runMaintenanceCommand(args []string, input io.Reader, output io.Writer, store *profile.FileStore, targets []target.Target, mutationLock app.MutationLock, logger app.OperationLogger, checks []target.Check) error {
|
||||
if len(args) != 1 {
|
||||
return errors.New("invalid maintenance command")
|
||||
|
||||
@@ -7,9 +7,27 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"proxyctl/internal/profile"
|
||||
"proxyctl/internal/target"
|
||||
)
|
||||
|
||||
func TestProductionCompositionRegistersAPTContainerGNOMEAndDaemonTargets(t *testing.T) {
|
||||
home := t.TempDir()
|
||||
environment := commandEnvironment{identity: profile.UserIdentity{Username: "tester", HomeDir: home, UID: os.Getuid(), GID: os.Getgid()}, env: map[string]string{"SHELL": "/bin/bash"}}
|
||||
targets, err := productionTargets(environment)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var ids []string
|
||||
for _, adapter := range targets {
|
||||
ids = append(ids, adapter.ID())
|
||||
}
|
||||
want := []string{"apt", "docker-containers", "gnome", "docker-daemon"}
|
||||
if strings.Join(ids, ",") != strings.Join(want, ",") {
|
||||
t.Fatalf("production Target IDs = %#v, want %#v", ids, want)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDefaultInvocationStartsTUIWithNoProfileState(t *testing.T) {
|
||||
t.Setenv("XDG_CONFIG_HOME", t.TempDir())
|
||||
var output bytes.Buffer
|
||||
|
||||
Reference in New Issue
Block a user