Skip to content

Commit

Permalink
CDPCP-13591 Cloudera Data Warehouse - Data Visualisation Support
Browse files Browse the repository at this point in the history
Fix Deletion.
  • Loading branch information
Viktor Csomor committed Dec 20, 2024
1 parent 39d21ac commit 2d156bc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
7 changes: 0 additions & 7 deletions resources/dw/dataviz/model_dataviz.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,3 @@ type resourceModel struct {
func (m *resourceModel) GetPollingOptions() *utils.PollingOptions {
return m.PollingOptions
}

func (m *resourceModel) getImageVersion() string {
if m.ImageVersion.IsNull() || m.ImageVersion.IsUnknown() || m.ImageVersion.String() == "<unknown>" {
return ""
}
return m.ImageVersion.String()
}
10 changes: 9 additions & 1 deletion resources/dw/dataviz/resource_dataviz.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ func createRequestFromPlan(ctx context.Context, plan resourceModel) *operations.
ClusterID: plan.ClusterID.ValueStringPointer(),
Name: plan.Name.ValueStringPointer(),

ImageVersion: plan.getImageVersion(),
ImageVersion: plan.ImageVersion.ValueString(),
Config: &models.VizConfig{
AdminGroups: utils.FromListValueToStringList(plan.AdminGroups),
UserGroups: utils.FromListValueToStringList(plan.UserGroups),
Expand Down Expand Up @@ -222,6 +222,14 @@ func (r *datavizResource) stateRefresh(ctx context.Context, clusterID *string, v

resp, err := r.describeDataViz(describeRequest(ctx, clusterID, vizID))
if err != nil {
tflog.Error(ctx, fmt.Sprintf("Error describing Data Visualisation, error, %v", err))

if strings.Contains(err.Error(), "unable to get viz-webapp") {
// the &models.DescribeDataVisualizationResponse{} has to be a response otherwise it end up in an infinite loop
return &models.DescribeDataVisualizationResponse{}, "Deleted", nil
}

// the "Data Visualization not found" will be the correct way of handling
if strings.Contains(err.Error(), "Data Visualization not found") {
return nil, "Deleted", nil
}
Expand Down

0 comments on commit 2d156bc

Please sign in to comment.