99 "github.com/Telmate/terraform-provider-proxmox/v2/proxmox/Internal/resource/guest/dns"
1010 "github.com/Telmate/terraform-provider-proxmox/v2/proxmox/Internal/resource/guest/lxc/architecture"
1111 "github.com/Telmate/terraform-provider-proxmox/v2/proxmox/Internal/resource/guest/lxc/cpu"
12- "github.com/Telmate/terraform-provider-proxmox/v2/proxmox/Internal/resource/guest/lxc/features"
1312 tags "github.com/Telmate/terraform-provider-proxmox/v2/proxmox/Internal/resource/guest/lxc/lxc_tags"
1413 "github.com/Telmate/terraform-provider-proxmox/v2/proxmox/Internal/resource/guest/lxc/memory"
1514 "github.com/Telmate/terraform-provider-proxmox/v2/proxmox/Internal/resource/guest/lxc/mounts"
@@ -34,24 +33,24 @@ import (
3433
3534var lxcNewResourceDef * schema.Resource
3635
37- func ResourceLxcNew () * schema.Resource {
36+ func resourceLxcGuest () * schema.Resource {
3837 lxcNewResourceDef = & schema.Resource {
39- CreateContext : resourceLxcNewCreate ,
40- ReadContext : resourceLxcNewReadWithLock ,
41- UpdateContext : resourceLxcNewUpdate ,
42- DeleteContext : resourceLxcNewDelete ,
38+ CreateContext : resourceLxcGuestCreate ,
39+ ReadContext : resourceLxcGuestReadWithLock ,
40+ UpdateContext : resourceLxcGuestUpdate ,
41+ DeleteContext : resourceLxcGuestDelete ,
4342 Importer : & schema.ResourceImporter {
4443 StateContext : schema .ImportStatePassthroughContext ,
4544 },
4645 CustomizeDiff : reboot .CustomizeDiff (),
4746
4847 Schema : map [string ]* schema.Schema {
49- architecture .Root : architecture .Schema (),
50- clone .Root : clone .Schema (),
51- cpu .Root : cpu .Schema (),
52- description .Root : description .Schema (),
53- dns .Root : dns .Schema (),
54- features .Root : features .Schema (),
48+ architecture .Root : architecture .Schema (),
49+ clone .Root : clone .Schema (),
50+ cpu .Root : cpu .Schema (),
51+ description .Root : description .Schema (),
52+ dns .Root : dns .Schema (),
53+ // features.Root: features.Schema(),
5554 memory .Root : memory .Schema (),
5655 mounts .RootMount : mounts .SchemaMount (),
5756 mounts .RootMounts : mounts .SchemaMounts (),
@@ -81,15 +80,21 @@ func ResourceLxcNew() *schema.Resource {
8180 return lxcNewResourceDef
8281}
8382
84- func resourceLxcNewCreate (ctx context.Context , d * schema.ResourceData , meta any ) diag.Diagnostics {
83+ func resourceLxcGuestCreate (ctx context.Context , d * schema.ResourceData , meta any ) diag.Diagnostics {
8584 pconf := meta .(* providerConfiguration )
8685 lock := pmParallelBegin (pconf )
8786 defer lock .unlock ()
8887
88+ diags := lxcGuestWarning ()
89+
8990 client := pconf .Client
9091
9192 privileged := privilege .SDK (d )
92- config , diags := lxcSDK (privileged , d )
93+ config , tmpDiags := lxcSDK (privileged , d )
94+ diags = append (diags , tmpDiags ... )
95+ if diags .HasError () {
96+ return diags
97+ }
9398 config .Privileged = & privileged
9499
95100 // Set the node for the LXC container
@@ -150,36 +155,41 @@ func resourceLxcNewCreate(ctx context.Context, d *schema.ResourceData, meta any)
150155 Type : id .GuestLxc }.String ())
151156 }
152157
153- return append (diags , resourceLxcNewRead (ctx , d , meta , vmr , client )... )
158+ return append (diags , resourceLxcGuestRead (ctx , d , meta , vmr , client )... )
154159}
155160
156- func resourceLxcNewUpdate (ctx context.Context , d * schema.ResourceData , meta any ) diag.Diagnostics {
161+ func resourceLxcGuestUpdate (ctx context.Context , d * schema.ResourceData , meta any ) diag.Diagnostics {
157162 pConf := meta .(* providerConfiguration )
158163 lock := pmParallelBegin (pConf )
159164 defer lock .unlock ()
160165
161166 client := pConf .Client
162167
168+ diags := lxcGuestWarning ()
169+
163170 // Get vm reference
164171 var resourceID id.Guest
165172 err := resourceID .Parse (d .Id ())
166173 if err != nil {
167174 d .SetId ("" )
168- return diag.Diagnostics { {
175+ return append ( diags , diag.Diagnostic {
169176 Summary : "unexpected error when trying to read and parse the resource: " + err .Error (),
170- Severity : diag .Error }}
177+ Severity : diag .Error })
171178 }
172179 var vmr * pveSDK.VmRef
173180 vmr , err = client .GetVmRefById (ctx , resourceID .ID )
174181 if err != nil {
175- return diag.Diagnostics {
176- diag.Diagnostic {
177- Summary : err .Error (),
178- Severity : diag .Error }}
182+ return append (diags , diag.Diagnostic {
183+ Summary : err .Error (),
184+ Severity : diag .Error })
179185 }
180186
181187 // create a new config from the resource data
182- config , diags := lxcSDK (privilege .SDK (d ), d )
188+ config , tmpDiags := lxcSDK (privilege .SDK (d ), d )
189+ diags = append (diags , tmpDiags ... )
190+ if diags .HasError () {
191+ return diags
192+ }
183193
184194 // update the targetNode for the LXC container
185195 var targetNode pveSDK.NodeName
@@ -201,27 +211,29 @@ func resourceLxcNewUpdate(ctx context.Context, d *schema.ResourceData, meta any)
201211 Severity : diag .Error })
202212 }
203213
204- return append (diags , resourceLxcNewRead (ctx , d , meta , vmr , client )... )
214+ return append (diags , resourceLxcGuestRead (ctx , d , meta , vmr , client )... )
205215}
206216
207- func resourceLxcNewReadWithLock (ctx context.Context , d * schema.ResourceData , meta any ) diag.Diagnostics {
217+ func resourceLxcGuestReadWithLock (ctx context.Context , d * schema.ResourceData , meta any ) diag.Diagnostics {
208218 pConf := meta .(* providerConfiguration )
209219 lock := pmParallelBegin (pConf )
210220 defer lock .unlock ()
211221
222+ diags := lxcGuestWarning ()
223+
212224 var resourceID id.Guest
213225 err := resourceID .Parse (d .Id ())
214226 if err != nil {
215227 d .SetId ("" )
216- return diag.Diagnostics { {
228+ return append ( diags , diag.Diagnostic {
217229 Summary : "unexpected error when trying to read and parse the resource: " + err .Error (),
218- Severity : diag .Error }}
230+ Severity : diag .Error })
219231 }
220232
221- return resourceLxcNewRead ( ctx , d , meta , pveSDK .NewVmRef (resourceID .ID ), pConf .Client )
233+ return append ( diags , resourceLxcGuestRead ( ctx , d , meta , pveSDK .NewVmRef (resourceID .ID ), pConf .Client ) ... )
222234}
223235
224- func resourceLxcNewRead (ctx context.Context , d * schema.ResourceData , meta any , vmr * pveSDK.VmRef , client * pveSDK.Client ) diag.Diagnostics {
236+ func resourceLxcGuestRead (ctx context.Context , d * schema.ResourceData , meta any , vmr * pveSDK.VmRef , client * pveSDK.Client ) diag.Diagnostics {
225237 guestStatus , err := vmr .GetRawGuestStatus (ctx , client )
226238 if err != nil {
227239 return diag.Diagnostics {{
@@ -245,7 +257,7 @@ func resourceLxcNewRead(ctx context.Context, d *schema.ResourceData, meta any, v
245257 cpu .Terraform (config .CPU , d )
246258 description .Terraform (config .Description , false , d )
247259 dns .Terraform (config .DNS , d )
248- features .Terraform (config .Features , d )
260+ // features.Terraform(config.Features, d)
249261 memory .Terraform (config .Memory , d )
250262 mounts .Terraform (config .Mounts , d )
251263 name .Terraform_Unsafe (config .Name , d )
@@ -261,7 +273,7 @@ func resourceLxcNewRead(ctx context.Context, d *schema.ResourceData, meta any, v
261273 return nil
262274}
263275
264- func resourceLxcNewDelete (ctx context.Context , d * schema.ResourceData , meta any ) diag.Diagnostics {
276+ func resourceLxcGuestDelete (ctx context.Context , d * schema.ResourceData , meta any ) diag.Diagnostics {
265277 return guestDelete (ctx , d , meta , "LXC" )
266278}
267279
@@ -275,12 +287,12 @@ func lxcSDK(privilidged bool, d *schema.ResourceData) (pveSDK.ConfigLXC, diag.Di
275287 CPU : cpu .SDK (d ),
276288 DNS : dns .SDK (d ),
277289 Description : description .SDK (false , d ),
278- Features : features .SDK (privilidged , d ),
279- Memory : memory .SDK (d ),
280- Name : guestName ,
281- State : powerstate .SDK (d ),
282- Swap : swap .SDK (d ),
283- Tags : tags .SDK (d ),
290+ // Features: features.SDK(privilidged, d),
291+ Memory : memory .SDK (d ),
292+ Name : guestName ,
293+ State : powerstate .SDK (d ),
294+ Swap : swap .SDK (d ),
295+ Tags : tags .SDK (d ),
284296 }
285297 var diags , tmpDiags diag.Diagnostics
286298 config .Networks , diags = networks .SDK (d )
@@ -291,3 +303,10 @@ func lxcSDK(privilidged bool, d *schema.ResourceData) (pveSDK.ConfigLXC, diag.Di
291303 diags = append (diags , tmpDiags ... )
292304 return config , diags
293305}
306+
307+ func lxcGuestWarning () diag.Diagnostics {
308+ return diag.Diagnostics {{
309+ Detail : "The LXC Guest resource is experimental. The schema and functionality may change in future releases without a major version bump." ,
310+ Summary : "LXC Guest resource is experimental" ,
311+ Severity : diag .Warning }}
312+ }
0 commit comments