Skip to content

Commit

Permalink
Fix for cluster profile
Browse files Browse the repository at this point in the history
  • Loading branch information
saamalik committed Jan 18, 2021
1 parent 84d5114 commit b475aa4
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion spectrocloud/resource_cluster_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,35 @@ func resourceClusterProfileRead(_ context.Context, d *schema.ResourceData, m int
return diags
}

// TODO(saamalik) read the pack values and upate (for reconciliation)
d.Set("name", cp.Metadata.Name)
packs := flattenPacks(cp.Spec.Published.Packs)
if err := d.Set("pack", packs); err != nil {
return diag.FromErr(err)
}

return diags
}

func flattenPacks(packs []*models.V1alpha1PackRef) []interface{} {
if packs == nil {
return make([]interface{}, 0)
}

ps := make([]interface{}, len(packs))
for i, pack := range packs {
p := make(map[string]interface{})

p["uid"] = pack.PackUID
p["name"] = *pack.Name
p["tag"] = pack.Tag
p["values"] = pack.Values

ps[i] = p
}

return ps
}

func resourceClusterProfileUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
c := m.(*client.V1alpha1Client)

Expand Down

0 comments on commit b475aa4

Please sign in to comment.