@@ -105,11 +105,16 @@ func resourcePackageInstallCreate(ctx context.Context, d *schema.ResourceData, m
105
105
return diag .Errorf ("Unable to create Tanzu Mission Control package install entry; Scope full name is empty" )
106
106
}
107
107
108
+ specVal , err := spec .ConstructSpecForClusterScope (d )
109
+ if err != nil {
110
+ return diag .FromErr (err )
111
+ }
112
+
108
113
packageInstallReq := & pkginstallclustermodel.VmwareTanzuManageV1alpha1ClusterNamespaceTanzupackageInstallInstallRequest {
109
114
Install : & pkginstallclustermodel.VmwareTanzuManageV1alpha1ClusterNamespaceTanzupackageInstallInstall {
110
115
FullName : scopedFullnameData .FullnameCluster ,
111
116
Meta : common .ConstructMeta (d ),
112
- Spec : spec . ConstructSpecForClusterScope ( d ) ,
117
+ Spec : specVal ,
113
118
},
114
119
}
115
120
@@ -187,8 +192,14 @@ func resourcePackageInstallInPlaceUpdate(ctx context.Context, d *schema.Resource
187
192
updateAvailable = true
188
193
}
189
194
190
- if updateCheckForSpec (d , installSpec ) {
191
- err := CheckForUpdatedPackage (config , scopedFullnameData , installSpec )
195
+ specCheck , err := updateCheckForSpec (d , installSpec )
196
+ if err != nil {
197
+ log .Println ("[ERROR] Unable to check spec has been updated." )
198
+ diag .FromErr (err )
199
+ }
200
+
201
+ if specCheck {
202
+ err = CheckForUpdatedPackage (config , scopedFullnameData , installSpec )
192
203
if err != nil {
193
204
return diag .FromErr (err )
194
205
}
@@ -197,6 +208,7 @@ func resourcePackageInstallInPlaceUpdate(ctx context.Context, d *schema.Resource
197
208
}
198
209
199
210
if ! updateAvailable {
211
+ log .Printf ("[INFO] package install update is not required" )
200
212
return
201
213
}
202
214
@@ -283,21 +295,24 @@ func updateCheckForMeta(d *schema.ResourceData, meta *objectmetamodel.VmwareTanz
283
295
return true
284
296
}
285
297
286
- func updateCheckForSpec (d * schema.ResourceData , installSpec * pkginstallclustermodel.VmwareTanzuManageV1alpha1ClusterNamespaceTanzupackageInstallSpec ) bool {
298
+ func updateCheckForSpec (d * schema.ResourceData , installSpec * pkginstallclustermodel.VmwareTanzuManageV1alpha1ClusterNamespaceTanzupackageInstallSpec ) ( bool , error ) {
287
299
if ! spec .HasSpecChanged (d ) {
288
- return false
300
+ return false , nil
289
301
}
290
302
291
- updatedInstallSpec := spec .ConstructSpecForClusterScope (d )
303
+ specVal , err := spec .ConstructSpecForClusterScope (d )
304
+ if err != nil {
305
+ return false , err
306
+ }
292
307
293
- installSpec .PackageRef .PackageMetadataName = updatedInstallSpec .PackageRef .PackageMetadataName
294
- installSpec .PackageRef .VersionSelection .Constraints = updatedInstallSpec .PackageRef .VersionSelection .Constraints
295
- installSpec .RoleBindingScope = updatedInstallSpec .RoleBindingScope
296
- installSpec .InlineValues = updatedInstallSpec .InlineValues
308
+ installSpec .PackageRef .PackageMetadataName = specVal .PackageRef .PackageMetadataName
309
+ installSpec .PackageRef .VersionSelection .Constraints = specVal .PackageRef .VersionSelection .Constraints
310
+ installSpec .RoleBindingScope = specVal .RoleBindingScope
311
+ installSpec .InlineValues = specVal .InlineValues
297
312
298
313
log .Printf ("[INFO] updating package install spec" )
299
314
300
- return true
315
+ return true , nil
301
316
}
302
317
303
318
func GetGlobalNamespace (config authctx.TanzuContext , searchscope * tanzupakageclustermodel.VmwareTanzuManageV1alpha1ClusterTanzupackageSearchScope ) (string , error ) {
0 commit comments