From 8ad99a40c616fdaa3455094e25800963ab51d191 Mon Sep 17 00:00:00 2001 From: Megan Marsh Date: Fri, 8 Oct 2021 15:58:29 -0700 Subject: [PATCH] Read labels into the data source, and regenerate code. --- datasource/hcp-packer-image/data.go | 3 +++ datasource/hcp-packer-image/data.hcl2spec.go | 18 ++++++++++-------- .../hcp-packer-image/DatasourceOutput.mdx | 2 ++ .../DeactivatedDatasource.mdx | 7 +++++++ 4 files changed, 22 insertions(+), 8 deletions(-) create mode 100644 website/content/partials/datasource/packer-image-iteration/DeactivatedDatasource.mdx diff --git a/datasource/hcp-packer-image/data.go b/datasource/hcp-packer-image/data.go index 5347936fe..3878956a1 100644 --- a/datasource/hcp-packer-image/data.go +++ b/datasource/hcp-packer-image/data.go @@ -100,6 +100,8 @@ type DatasourceOutput struct { // For locally managed clouds, this may map instead to a cluster, server // or datastore. Region string `mapstructure:"region"` + // The key:value metadata labels associated with this build. + Labels map[string]string `mapstructure:"labels"` } func (d *Datasource) OutputSpec() hcldec.ObjectSpec { @@ -142,6 +144,7 @@ func (d *Datasource) Execute() (cty.Value, error) { PackerRunUUID: build.PackerRunUUID, ID: image.ImageID, Region: image.Region, + Labels: build.Labels, } return hcl2helper.HCL2ValueFromConfig(output, d.OutputSpec()), nil } diff --git a/datasource/hcp-packer-image/data.hcl2spec.go b/datasource/hcp-packer-image/data.hcl2spec.go index 9506bf06b..99f3239b3 100644 --- a/datasource/hcp-packer-image/data.hcl2spec.go +++ b/datasource/hcp-packer-image/data.hcl2spec.go @@ -55,14 +55,15 @@ func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec { // FlatDatasourceOutput is an auto-generated flat version of DatasourceOutput. // Where the contents of a field with a `mapstructure:,squash` tag are bubbled up. type FlatDatasourceOutput struct { - CloudProvider *string `mapstructure:"cloud_provider" cty:"cloud_provider" hcl:"cloud_provider"` - ComponentType *string `mapstructure:"component_type" cty:"component_type" hcl:"component_type"` - CreatedAt *string `mapstructure:"created_at" cty:"created_at" hcl:"created_at"` - BuildID *string `mapstructure:"build_id" cty:"build_id" hcl:"build_id"` - IterationID *string `mapstructure:"iteration_id" cty:"iteration_id" hcl:"iteration_id"` - PackerRunUUID *string `mapstructure:"packer_run_uuid" cty:"packer_run_uuid" hcl:"packer_run_uuid"` - ID *string `mapstructure:"id" cty:"id" hcl:"id"` - Region *string `mapstructure:"region" cty:"region" hcl:"region"` + CloudProvider *string `mapstructure:"cloud_provider" cty:"cloud_provider" hcl:"cloud_provider"` + ComponentType *string `mapstructure:"component_type" cty:"component_type" hcl:"component_type"` + CreatedAt *string `mapstructure:"created_at" cty:"created_at" hcl:"created_at"` + BuildID *string `mapstructure:"build_id" cty:"build_id" hcl:"build_id"` + IterationID *string `mapstructure:"iteration_id" cty:"iteration_id" hcl:"iteration_id"` + PackerRunUUID *string `mapstructure:"packer_run_uuid" cty:"packer_run_uuid" hcl:"packer_run_uuid"` + ID *string `mapstructure:"id" cty:"id" hcl:"id"` + Region *string `mapstructure:"region" cty:"region" hcl:"region"` + Labels map[string]string `mapstructure:"labels" cty:"labels" hcl:"labels"` } // FlatMapstructure returns a new FlatDatasourceOutput. @@ -85,6 +86,7 @@ func (*FlatDatasourceOutput) HCL2Spec() map[string]hcldec.Spec { "packer_run_uuid": &hcldec.AttrSpec{Name: "packer_run_uuid", Type: cty.String, Required: false}, "id": &hcldec.AttrSpec{Name: "id", Type: cty.String, Required: false}, "region": &hcldec.AttrSpec{Name: "region", Type: cty.String, Required: false}, + "labels": &hcldec.AttrSpec{Name: "labels", Type: cty.Map(cty.String), Required: false}, } return s } diff --git a/website/content/partials/datasource/hcp-packer-image/DatasourceOutput.mdx b/website/content/partials/datasource/hcp-packer-image/DatasourceOutput.mdx index 2d7974fa7..5b5ec7c70 100644 --- a/website/content/partials/datasource/hcp-packer-image/DatasourceOutput.mdx +++ b/website/content/partials/datasource/hcp-packer-image/DatasourceOutput.mdx @@ -23,4 +23,6 @@ For locally managed clouds, this may map instead to a cluster, server or datastore. +- `labels` (map[string]string) - The key:value metadata labels associated with this build. + diff --git a/website/content/partials/datasource/packer-image-iteration/DeactivatedDatasource.mdx b/website/content/partials/datasource/packer-image-iteration/DeactivatedDatasource.mdx new file mode 100644 index 000000000..a666b605d --- /dev/null +++ b/website/content/partials/datasource/packer-image-iteration/DeactivatedDatasource.mdx @@ -0,0 +1,7 @@ + + +Type for Packer datasource has been renamed temporarily to prevent it from being +automatically registered as a viable datasource plugin in command/plugin.go. +In the future this type will be renamed to allow for the use of the datasource. + +