Skip to content

Commit

Permalink
nest iteration stuff under iteration
Browse files Browse the repository at this point in the history
  • Loading branch information
azr committed Jul 27, 2021
1 parent 7afcdc7 commit 8063413
Showing 1 changed file with 79 additions and 79 deletions.
158 changes: 79 additions & 79 deletions internal/provider/data_source_packer_image.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,82 +48,87 @@ func dataSourcePackerImage() *schema.Resource {
Type: schema.TypeString,
Computed: true,
},

"incremental_version": {
Description: "The Packer version of the registry.",
Type: schema.TypeInt,
Computed: true,
},
"created_at": {
Description: "The time that the Packer registry was created.",
Type: schema.TypeString,
"iteration": {
Description: "Iteration this channel points to",
Type: schema.TypeSet,
Computed: true,
},
"image_id": {
Description: "The ID of the image.",
Type: schema.TypeString,
Computed: true,
},
"builds": {
Description: "Builds for this iteration",
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeSet,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"cloud_provider": {
Type: schema.TypeString,
},
"component_type": {
Type: schema.TypeString,
},
"created_at": {
Type: schema.TypeString,
},
"id": {
Type: schema.TypeString,
},
"images": {
Type: schema.TypeList,
Elem: &schema.Schema{
Type: schema.TypeSet,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"created_at": {
Type: schema.TypeString,
},
"id": {
Type: schema.TypeString,
},
"image_id": {
Type: schema.TypeString,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"id": {
Description: "ID of this iteration",
Type: schema.TypeString,
},
"incremental_version": {
Description: "Incremental version of this iteration",
Type: schema.TypeString,
},
"created_at": {
Description: "Creation time of this iteration",
Type: schema.TypeString,
},
"builds": {
Description: "Builds for this iteration",
Type: schema.TypeList,
// Computed: true,
Elem: &schema.Schema{
Type: schema.TypeSet,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"cloud_provider": {
Type: schema.TypeString,
},
"component_type": {
Type: schema.TypeString,
},
"created_at": {
Type: schema.TypeString,
},
// "id": {
// Type: schema.TypeString,
// },
"images": {
Type: schema.TypeList,
Elem: &schema.Schema{
Type: schema.TypeSet,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"created_at": {
Type: schema.TypeString,
},
"id": {
Type: schema.TypeString,
},
"image_id": {
Type: schema.TypeString,
},
"region": {
Type: schema.TypeString,
},
},
},
},
"region": {
},
"iteration_id": {
Type: schema.TypeString,
},
"labels": {
Type: schema.TypeMap,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"packer_run_uuid": {
Type: schema.TypeString,
},
"status": {
Type: schema.TypeString,
},
"updated_at": {
Type: schema.TypeString,
},
},
},
},
"iteration_id": {
Type: schema.TypeString,
},
"labels": {
Type: schema.TypeMap,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"packer_run_uuid": {
Type: schema.TypeString,
},
"status": {
Type: schema.TypeString,
},
"updated_at": {
Type: schema.TypeString,
},
},
},
},
Expand Down Expand Up @@ -177,19 +182,14 @@ func setPackerImageData(d *schema.ResourceData, it *packermodels.HashicorpCloudP

d.SetId(it.ID)

if err := d.Set("incremental_version", it.IncrementalVersion); err != nil {
return err
}
if err := d.Set("created_at", it.CreatedAt.String()); err != nil {
if err := d.Set("iteration", map[string]interface{}{
"id": it.ID,
"incremental_version": it.IncrementalVersion,
"created_at": it.CreatedAt.String,
"builds": flattenPackerBuildList(it.Builds),
}); err != nil {
return err
}
if err := d.Set("image_id", it.ID); err != nil {
return err
}
if err := d.Set("builds", flattenPackerBuildList(it.Builds)); err != nil {
return err
}

return nil
}

Expand Down

0 comments on commit 8063413

Please sign in to comment.