@@ -11,7 +11,6 @@ import (
11
11
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/packages"
12
12
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/projects"
13
13
"github.com/hashicorp/terraform-plugin-framework/types"
14
- "github.com/hashicorp/terraform-plugin-framework/types/basetypes"
15
14
"github.com/hashicorp/terraform-plugin-log/tflog"
16
15
)
17
16
@@ -109,9 +108,15 @@ func expandProject(ctx context.Context, model projectResourceModel) *projects.Pr
109
108
}
110
109
111
110
if ! model .ReleaseCreationStrategy .IsNull () {
112
- var strategy releaseCreationStrategyModel
113
- model .ReleaseCreationStrategy .ElementsAs (ctx , & strategy , false )
114
- project .ReleaseCreationStrategy = expandReleaseCreationStrategy (strategy )
111
+ var strategyList []releaseCreationStrategyModel
112
+ diags := model .ReleaseCreationStrategy .ElementsAs (ctx , & strategyList , false )
113
+ if diags .HasError () {
114
+ tflog .Error (ctx , fmt .Sprintf ("Error converting release creation strategy settings: %v\n " , diags ))
115
+ } else {
116
+ if len (strategyList ) > 0 {
117
+ project .ReleaseCreationStrategy = expandReleaseCreationStrategy (strategyList [0 ])
118
+ }
119
+ }
115
120
}
116
121
117
122
if ! model .Template .IsNull () {
@@ -306,20 +311,25 @@ func expandReleaseCreationStrategy(model releaseCreationStrategyModel) *projects
306
311
ChannelID : model .ChannelID .ValueString (),
307
312
ReleaseCreationPackageStepID : model .ReleaseCreationPackageStepID .ValueString (),
308
313
}
309
- if ! model .ReleaseCreationPackage .IsNull () {
310
- var releaseCreationPackage deploymentActionPackageModel
311
- model .ReleaseCreationPackage .As (context .Background (), & releaseCreationPackage , basetypes.ObjectAsOptions {})
312
- strategy .ReleaseCreationPackage = expandDeploymentActionPackage (releaseCreationPackage )
314
+ if model .ReleaseCreationPackage != nil {
315
+ strategy .ReleaseCreationPackage = expandDeploymentActionPackage (model .ReleaseCreationPackage [0 ])
313
316
}
314
317
return strategy
315
318
}
316
319
317
320
func expandDeploymentActionPackage (model deploymentActionPackageModel ) * packages.DeploymentActionPackage {
318
- return & packages.DeploymentActionPackage {
319
- DeploymentAction : model .DeploymentAction .ValueString (),
320
- PackageReference : model .PackageReference .ValueString (),
321
+ deploymentActionPackage := & packages.DeploymentActionPackage {}
322
+
323
+ if ! model .DeploymentAction .IsNull () {
324
+ deploymentActionPackage .DeploymentAction = model .DeploymentAction .ValueString ()
325
+ }
326
+ if ! model .PackageReference .IsNull () {
327
+ deploymentActionPackage .PackageReference = model .PackageReference .ValueString ()
321
328
}
329
+
330
+ return deploymentActionPackage
322
331
}
332
+
323
333
func expandTemplates (templates []templateModel ) []actiontemplates.ActionTemplateParameter {
324
334
result := make ([]actiontemplates.ActionTemplateParameter , len (templates ))
325
335
for i , template := range templates {
0 commit comments