Skip to content

Commit fedc058

Browse files
authored
Merge branch 'lxc:main' into main
2 parents 1dc6b4b + 704c2cd commit fedc058

File tree

10 files changed

+56
-17
lines changed

10 files changed

+56
-17
lines changed

.github/workflows/test.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
INCUS_SCHEME: https
4040

4141
steps:
42-
- uses: actions/checkout@v4
42+
- uses: actions/checkout@v5
4343
- name: Setup Go ${{ matrix.go-version }}
4444
uses: actions/setup-go@v5
4545
with:
@@ -102,7 +102,7 @@ jobs:
102102
- stable
103103

104104
steps:
105-
- uses: actions/checkout@v4
105+
- uses: actions/checkout@v5
106106
- name: Setup Go ${{ matrix.go-version }}
107107
uses: actions/setup-go@v5
108108
with:
@@ -124,7 +124,7 @@ jobs:
124124
- stable
125125

126126
steps:
127-
- uses: actions/checkout@v4
127+
- uses: actions/checkout@v5
128128
- name: Setup Go ${{ matrix.go-version }}
129129
uses: actions/setup-go@v5
130130
with:

docs/index.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ The following arguments are supported:
6161
to. See the `remote` reference below for details.
6262

6363
* `config_dir` - *Optional* - The directory to look for existing Incus
64-
configuration. Defaults to `$HOME/.config/incus`
64+
configuration. This can also be set with the `INCUS_CONF`
65+
Environment variable. Defaults to `$HOME/.config/incus`
6566

6667
* `generate_client_certificates` - *Optional* - Automatically generate the Incus
6768
client certificate if it does not exist. Valid values are `true` and `false`.
@@ -89,7 +90,8 @@ The `remote` block supports:
8990
for more information.
9091
The default can also be set with the `INCUS_REMOTE` Environment variable.
9192

92-
* `name` - *Optional* - The name of the Incus remote.
93+
* `name` - **Required** - Name of the Incus remote. Name is used to locate
94+
server certificate if incus_scheme is set to `https`.
9395

9496
* `token` - *Optional* - The one-time trust [token](https://linuxcontainers.org/incus/docs/main/authentication/#adding-client-certificates-using-tokens) used for initial authentication with the Incus remote.
9597

docs/resources/storage_pool.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ for more details on how to create a storage pool in clustered mode.
5555

5656
* `driver` - **Required** - Storage Pool driver. Must be one of `dir`, `zfs`, `lvm`, `lvmcluster`, `btrfs`, `ceph`, `cephfs`, `cephobject` or `linstor`.
5757

58-
* `description` - *Optional* - Description of the storage pool.
58+
* `description` - *Optional* - Description of the storage pool. `description` is mutual exclusive with `target`. The `description` can only be set on cluster level (with `target` not set) or on non-clustered setups.
5959

6060
* `config` - *Optional* - Map of key/value pairs of
6161
[storage pool config settings](https://linuxcontainers.org/incus/docs/main/reference/storage_drivers/).

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ require (
99
github.com/hashicorp/terraform-plugin-framework-validators v0.18.0
1010
github.com/hashicorp/terraform-plugin-go v0.28.0
1111
github.com/hashicorp/terraform-plugin-sdk/v2 v2.37.0
12-
github.com/hashicorp/terraform-plugin-testing v1.13.2
12+
github.com/hashicorp/terraform-plugin-testing v1.13.3
1313
github.com/lxc/incus/v6 v6.15.0
1414
github.com/mitchellh/go-homedir v1.1.0
1515
github.com/stretchr/testify v1.10.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,8 @@ github.com/hashicorp/terraform-plugin-log v0.9.0 h1:i7hOA+vdAItN1/7UrfBqBwvYPQ9T
132132
github.com/hashicorp/terraform-plugin-log v0.9.0/go.mod h1:rKL8egZQ/eXSyDqzLUuwUYLVdlYeamldAHSxjUFADow=
133133
github.com/hashicorp/terraform-plugin-sdk/v2 v2.37.0 h1:NFPMacTrY/IdcIcnUB+7hsore1ZaRWU9cnB6jFoBnIM=
134134
github.com/hashicorp/terraform-plugin-sdk/v2 v2.37.0/go.mod h1:QYmYnLfsosrxjCnGY1p9c7Zj6n9thnEE+7RObeYs3fA=
135-
github.com/hashicorp/terraform-plugin-testing v1.13.2 h1:mSotG4Odl020vRjIenA3rggwo6Kg6XCKIwtRhYgp+/M=
136-
github.com/hashicorp/terraform-plugin-testing v1.13.2/go.mod h1:WHQ9FDdiLoneey2/QHpGM/6SAYf4A7AZazVg7230pLE=
135+
github.com/hashicorp/terraform-plugin-testing v1.13.3 h1:QLi/khB8Z0a5L54AfPrHukFpnwsGL8cwwswj4RZduCo=
136+
github.com/hashicorp/terraform-plugin-testing v1.13.3/go.mod h1:WHQ9FDdiLoneey2/QHpGM/6SAYf4A7AZazVg7230pLE=
137137
github.com/hashicorp/terraform-registry-address v0.2.5 h1:2GTftHqmUhVOeuu9CW3kwDkRe4pcBDq0uuK5VJngU1M=
138138
github.com/hashicorp/terraform-registry-address v0.2.5/go.mod h1:PpzXWINwB5kuVS5CA7m1+eO2f1jKb5ZDIxrOPfpnGkg=
139139
github.com/hashicorp/terraform-svchost v0.1.1 h1:EZZimZ1GxdqFRinZ1tpJwVxxt49xc/S52uzrw4x0jKQ=

internal/network/resource_network.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,7 @@ func (_ NetworkModel) ComputedKeys() []string {
396396
"ipv6.address",
397397
"ipv6.nat",
398398
"network",
399+
"tunnel.",
399400
"volatile.",
400401
}
401402
}

internal/profile/resource_profile.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ func (r ProfileResource) Schema(_ context.Context, _ resource.SchemaRequest, res
6969

7070
"project": schema.StringAttribute{
7171
Optional: true,
72+
Computed: true,
73+
Default: stringdefault.StaticString(api.ProjectDefaultName),
7274
PlanModifiers: []planmodifier.String{
7375
stringplanmodifier.RequiresReplace(),
7476
},
@@ -356,6 +358,12 @@ func (r ProfileResource) ImportState(ctx context.Context, req resource.ImportSta
356358
return
357359
}
358360

361+
// If the imported profile does not specify the project, set the correct default value.
362+
_, ok := fields["project"]
363+
if !ok {
364+
fields["project"] = api.ProjectDefaultName
365+
}
366+
359367
for k, v := range fields {
360368
resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root(k), v)...)
361369
}

internal/provider/provider.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ func (p *IncusProvider) Schema(_ context.Context, _ provider.SchemaRequest, resp
9797
Attributes: map[string]schema.Attribute{
9898
"name": schema.StringAttribute{
9999
Required: true,
100-
Description: "Name of the Incus remote. Required when incus_scheme set to https, to enable locating server certificate.",
100+
Description: "Name of the Incus remote. Name is used to locate server certificate if incus_scheme is set to \"https\".",
101101
},
102102

103103
"address": schema.StringAttribute{
@@ -146,6 +146,11 @@ func (p *IncusProvider) Configure(ctx context.Context, req provider.ConfigureReq
146146
configDir := data.ConfigDir.ValueString()
147147
if configDir == "" {
148148
configDir = "$HOME/.config/incus"
149+
150+
v, ok := os.LookupEnv("INCUS_CONF")
151+
if ok {
152+
configDir = v
153+
}
149154
}
150155
configDir = os.ExpandEnv(configDir)
151156

internal/storage/resource_storage_pool.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ func (r StoragePoolResource) Schema(_ context.Context, _ resource.SchemaRequest,
6363
Optional: true,
6464
Computed: true,
6565
Default: stringdefault.StaticString(""),
66+
Validators: []validator.String{
67+
stringvalidator.ConflictsWith(path.MatchRoot("target")),
68+
},
6669
},
6770

6871
"driver": schema.StringAttribute{
@@ -320,10 +323,16 @@ func (r StoragePoolResource) SyncState(ctx context.Context, tfState *tfsdk.State
320323
respDiags.Append(diags...)
321324

322325
m.Name = types.StringValue(pool.Name)
323-
m.Description = types.StringValue(pool.Description)
324326
m.Driver = types.StringValue(pool.Driver)
325327
m.Config = config
326328

329+
// target and description are mutual exclusive, but description might be
330+
// set by the cluster level resource (without target) and is then returned
331+
// by the API also for requests using target.
332+
if m.Target.IsUnknown() || m.Target.IsNull() {
333+
m.Description = types.StringValue(pool.Description)
334+
}
335+
327336
if respDiags.HasError() {
328337
return respDiags
329338
}

internal/storage/resource_storage_pool_test.go

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ func TestAccStoragePool_dir(t *testing.T) {
2222
Config: testAccStoragePool(poolName, driverName),
2323
Check: resource.ComposeTestCheckFunc(
2424
resource.TestCheckResourceAttr("incus_storage_pool.storage_pool1", "name", poolName),
25+
resource.TestCheckResourceAttr("incus_storage_pool.storage_pool1", "description", poolName),
2526
resource.TestCheckResourceAttr("incus_storage_pool.storage_pool1", "driver", driverName),
2627
resource.TestCheckResourceAttr("incus_storage_pool.storage_pool1", "config.%", "0"),
2728
// Ensure computed keys are not tracked.
@@ -33,6 +34,7 @@ func TestAccStoragePool_dir(t *testing.T) {
3334
Config: testAccStoragePool(poolName, driverName),
3435
Check: resource.ComposeTestCheckFunc(
3536
resource.TestCheckResourceAttr("incus_storage_pool.storage_pool1", "name", poolName),
37+
resource.TestCheckResourceAttr("incus_storage_pool.storage_pool1", "description", poolName),
3638
resource.TestCheckResourceAttr("incus_storage_pool.storage_pool1", "driver", driverName),
3739
resource.TestCheckResourceAttr("incus_storage_pool.storage_pool1", "config.%", "0"),
3840
),
@@ -53,6 +55,7 @@ func TestAccStoragePool_zfs(t *testing.T) {
5355
Config: testAccStoragePool(poolName, driverName),
5456
Check: resource.ComposeTestCheckFunc(
5557
resource.TestCheckResourceAttr("incus_storage_pool.storage_pool1", "name", poolName),
58+
resource.TestCheckResourceAttr("incus_storage_pool.storage_pool1", "description", poolName),
5659
resource.TestCheckResourceAttr("incus_storage_pool.storage_pool1", "driver", driverName),
5760
resource.TestCheckResourceAttr("incus_storage_pool.storage_pool1", "config.%", "0"),
5861
// Ensure computed keys are not tracked.
@@ -66,6 +69,7 @@ func TestAccStoragePool_zfs(t *testing.T) {
6669
Config: testAccStoragePool(poolName, driverName),
6770
Check: resource.ComposeTestCheckFunc(
6871
resource.TestCheckResourceAttr("incus_storage_pool.storage_pool1", "name", poolName),
72+
resource.TestCheckResourceAttr("incus_storage_pool.storage_pool1", "description", poolName),
6973
resource.TestCheckResourceAttr("incus_storage_pool.storage_pool1", "driver", driverName),
7074
resource.TestCheckResourceAttr("incus_storage_pool.storage_pool1", "config.%", "0"),
7175
),
@@ -86,6 +90,7 @@ func TestAccStoragePool_lvm(t *testing.T) {
8690
Config: testAccStoragePool(poolName, driverName),
8791
Check: resource.ComposeTestCheckFunc(
8892
resource.TestCheckResourceAttr("incus_storage_pool.storage_pool1", "name", poolName),
93+
resource.TestCheckResourceAttr("incus_storage_pool.storage_pool1", "description", poolName),
8994
resource.TestCheckResourceAttr("incus_storage_pool.storage_pool1", "driver", driverName),
9095
resource.TestCheckResourceAttr("incus_storage_pool.storage_pool1", "config.%", "0"),
9196
// Ensure computed keys are not tracked.
@@ -100,6 +105,7 @@ func TestAccStoragePool_lvm(t *testing.T) {
100105
Config: testAccStoragePool(poolName, driverName),
101106
Check: resource.ComposeTestCheckFunc(
102107
resource.TestCheckResourceAttr("incus_storage_pool.storage_pool1", "name", poolName),
108+
resource.TestCheckResourceAttr("incus_storage_pool.storage_pool1", "description", poolName),
103109
resource.TestCheckResourceAttr("incus_storage_pool.storage_pool1", "driver", driverName),
104110
resource.TestCheckResourceAttr("incus_storage_pool.storage_pool1", "config.%", "0"),
105111
),
@@ -120,6 +126,7 @@ func TestAccStoragePool_btrfs(t *testing.T) {
120126
Config: testAccStoragePool(poolName, driverName),
121127
Check: resource.ComposeTestCheckFunc(
122128
resource.TestCheckResourceAttr("incus_storage_pool.storage_pool1", "name", poolName),
129+
resource.TestCheckResourceAttr("incus_storage_pool.storage_pool1", "description", poolName),
123130
resource.TestCheckResourceAttr("incus_storage_pool.storage_pool1", "driver", driverName),
124131
resource.TestCheckResourceAttr("incus_storage_pool.storage_pool1", "config.%", "0"),
125132
// Ensure computed keys are not tracked.
@@ -132,6 +139,7 @@ func TestAccStoragePool_btrfs(t *testing.T) {
132139
Config: testAccStoragePool(poolName, driverName),
133140
Check: resource.ComposeTestCheckFunc(
134141
resource.TestCheckResourceAttr("incus_storage_pool.storage_pool1", "name", poolName),
142+
resource.TestCheckResourceAttr("incus_storage_pool.storage_pool1", "description", poolName),
135143
resource.TestCheckResourceAttr("incus_storage_pool.storage_pool1", "driver", driverName),
136144
resource.TestCheckResourceAttr("incus_storage_pool.storage_pool1", "config.%", "0"),
137145
),
@@ -216,14 +224,18 @@ func TestAccStoragePool_target(t *testing.T) {
216224
{
217225
Config: testAccStoragePool_target(poolName, driverName),
218226
Check: resource.ComposeTestCheckFunc(
219-
resource.TestCheckResourceAttr("incus_storage_pool.storage_pool1_node2", "name", poolName),
220-
resource.TestCheckResourceAttr("incus_storage_pool.storage_pool1_node2", "driver", driverName),
227+
resource.TestCheckResourceAttr("incus_storage_pool.storage_pool1_node1", "name", poolName),
228+
resource.TestCheckResourceAttr("incus_storage_pool.storage_pool1", "description", poolName),
229+
resource.TestCheckResourceAttr("incus_storage_pool.storage_pool1_node1", "driver", driverName),
221230
resource.TestCheckResourceAttr("incus_storage_pool.storage_pool1_node1", "target", "node-1"),
231+
resource.TestCheckResourceAttr("incus_storage_pool.storage_pool1_node1", "description", ""), // Since target and description are mutual exclusive, we expect the default value in the state.
222232
resource.TestCheckResourceAttr("incus_storage_pool.storage_pool1_node2", "name", poolName),
223233
resource.TestCheckResourceAttr("incus_storage_pool.storage_pool1_node2", "driver", driverName),
224234
resource.TestCheckResourceAttr("incus_storage_pool.storage_pool1_node2", "target", "node-2"),
235+
resource.TestCheckResourceAttr("incus_storage_pool.storage_pool1_node2", "description", ""), // Since target and description are mutual exclusive, we expect the default value in the state.
225236
resource.TestCheckResourceAttr("incus_storage_pool.storage_pool1", "name", poolName),
226237
resource.TestCheckResourceAttr("incus_storage_pool.storage_pool1", "driver", driverName),
238+
resource.TestCheckResourceAttr("incus_storage_pool.storage_pool1", "description", "clustered storage pool description"),
227239
),
228240
},
229241
},
@@ -303,8 +315,9 @@ func TestAccStoragePool_importProject(t *testing.T) {
303315
func testAccStoragePool(name string, driver string) string {
304316
return fmt.Sprintf(`
305317
resource "incus_storage_pool" "storage_pool1" {
306-
name = "%s"
307-
driver = "%s"
318+
name = "%s"
319+
driver = "%s"
320+
description = "%[1]s"
308321
}
309322
`, name, driver)
310323
}
@@ -359,8 +372,9 @@ resource "incus_storage_pool" "storage_pool1" {
359372
incus_storage_pool.storage_pool1_node2,
360373
]
361374
362-
name = "%[1]s"
363-
driver = "%[2]s"
375+
name = "%[1]s"
376+
driver = "%[2]s"
377+
description = "clustered storage pool description"
364378
}
365379
`, name, driver)
366380
}

0 commit comments

Comments
 (0)