Skip to content

Commit

Permalink
provider: Replace client config paths
Browse files Browse the repository at this point in the history
Signed-off-by: Stéphane Graber <[email protected]>
  • Loading branch information
stgraber committed Dec 15, 2023
1 parent 315e56a commit 2f56bb0
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions internal/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func (p *LxdProvider) Schema(_ context.Context, _ provider.SchemaRequest, resp *
Attributes: map[string]schema.Attribute{
"config_dir": schema.StringAttribute{
Optional: true,
Description: "The directory to look for existing LXD configuration. (default = $HOME/snap/lxd/common/config:$HOME/.config/lxc)",
Description: "The directory to look for existing LXD configuration. (default = $HOME/.config/incus)",
},

"generate_client_certificates": schema.BoolAttribute{
Expand Down Expand Up @@ -138,17 +138,10 @@ func (p *LxdProvider) Configure(ctx context.Context, req provider.ConfigureReque
diags := req.Config.Get(ctx, &data)
resp.Diagnostics.Append(diags...)

// Determine LXD configuration directory. First check for the presence
// of the /var/snap/lxd directory. If the directory exists, return
// snap's config path. Otherwise return the fallback path.
// Determine LXD configuration directory.
configDir := data.ConfigDir.ValueString()
if configDir == "" {
_, err := os.Stat("/var/snap/lxd")
if err == nil || os.IsExist(err) {
configDir = "$HOME/snap/lxd/common/config"
} else {
configDir = "$HOME/.config/lxc"
}
configDir = "$HOME/.config/incus"
}

// Try to load config.yml from determined configDir. If there's
Expand Down

0 comments on commit 2f56bb0

Please sign in to comment.