1
0
mirror of https://github.com/lxc/incus.git synced 2026-02-05 09:46:19 +01:00

cmd/incus-user: Eliminate use of shared package

Signed-off-by: Stéphane Graber <stgraber@stgraber.org>
This commit is contained in:
Stéphane Graber
2023-09-28 01:08:15 -04:00
parent 35f910a2df
commit eca6f7e32b
2 changed files with 15 additions and 14 deletions

View File

@@ -11,8 +11,9 @@ import (
log "github.com/sirupsen/logrus"
"github.com/lxc/incus/incusd/ucred"
"github.com/lxc/incus/shared"
internalUtil "github.com/lxc/incus/internal/util"
localtls "github.com/lxc/incus/shared/tls"
"github.com/lxc/incus/shared/util"
)
func tlsConfig(uid uint32) (*tls.Config, error) {
@@ -33,9 +34,9 @@ func tlsConfig(uid uint32) (*tls.Config, error) {
tlsClientKey := string(content)
// Load the server certificate.
certPath := shared.VarPath("cluster.crt")
if !shared.PathExists(certPath) {
certPath = shared.VarPath("server.crt")
certPath := internalUtil.VarPath("cluster.crt")
if !util.PathExists(certPath) {
certPath = internalUtil.VarPath("server.crt")
}
content, err = os.ReadFile(certPath)
@@ -81,7 +82,7 @@ func proxyConnection(conn *net.UnixConn) {
defer logger.Debug("Disconnected")
// Check if the user was setup.
if !shared.PathExists(filepath.Join("users", fmt.Sprintf("%d", creds.Uid))) {
if !util.PathExists(filepath.Join("users", fmt.Sprintf("%d", creds.Uid))) {
log.Infof("Setting up for uid %d", creds.Uid)
err := serverSetupUser(creds.Uid)
if err != nil {
@@ -91,7 +92,7 @@ func proxyConnection(conn *net.UnixConn) {
}
// Connect to the daemon.
unixAddr, err := net.ResolveUnixAddr("unix", shared.VarPath("unix.socket"))
unixAddr, err := net.ResolveUnixAddr("unix", internalUtil.VarPath("unix.socket"))
if err != nil {
log.Errorf("Unable to resolve the target server: %v", err)
return

View File

@@ -8,13 +8,13 @@ import (
"strings"
"github.com/lxc/incus/client"
"github.com/lxc/incus/incusd/revert"
"github.com/lxc/incus/internal/linux"
"github.com/lxc/incus/internal/util"
"github.com/lxc/incus/shared"
"github.com/lxc/incus/internal/revert"
internalUtil "github.com/lxc/incus/internal/util"
"github.com/lxc/incus/shared/api"
"github.com/lxc/incus/shared/subprocess"
localtls "github.com/lxc/incus/shared/tls"
"github.com/lxc/incus/shared/util"
)
func serverIsConfigured(client incus.InstanceServer) (bool, error) {
@@ -24,7 +24,7 @@ func serverIsConfigured(client incus.InstanceServer) (bool, error) {
return false, fmt.Errorf("Failed to list networks: %w", err)
}
if !shared.ValueInSlice("incusbr0", networks) {
if !util.ValueInSlice("incusbr0", networks) {
// Couldn't find incusbr0.
return false, nil
}
@@ -35,7 +35,7 @@ func serverIsConfigured(client incus.InstanceServer) (bool, error) {
return false, fmt.Errorf("Failed to list storage pools: %w", err)
}
if !shared.ValueInSlice("default", pools) {
if !util.ValueInSlice("default", pools) {
// No storage pool found.
return false, nil
}
@@ -50,7 +50,7 @@ func serverInitialConfiguration(client incus.InstanceServer) error {
return fmt.Errorf("Failed to get server info: %w", err)
}
availableBackends := linux.AvailableStorageDrivers(info.Environment.StorageSupportedDrivers, util.PoolTypeLocal)
availableBackends := linux.AvailableStorageDrivers(internalUtil.VarPath(), info.Environment.StorageSupportedDrivers, internalUtil.PoolTypeLocal)
// Load the default profile.
profile, profileEtag, err := client.GetProfile("default")
@@ -70,7 +70,7 @@ func serverInitialConfiguration(client incus.InstanceServer) error {
pool.Name = "default"
// Check if ZFS supported.
if shared.ValueInSlice("zfs", availableBackends) {
if util.ValueInSlice("zfs", availableBackends) {
pool.Driver = "zfs"
// Check if zsys.
@@ -188,7 +188,7 @@ func serverSetupUser(uid uint32) error {
return fmt.Errorf("Unable to retrieve project list: %w", err)
}
if !shared.ValueInSlice(projectName, projects) {
if !util.ValueInSlice(projectName, projects) {
// Create the project.
err := client.CreateProject(api.ProjectsPost{
Name: projectName,