From 47fa09a9c99d937fe1b2788e3f6c96ca164baa36 Mon Sep 17 00:00:00 2001 From: Adrien Delorme Date: Wed, 17 Mar 2021 09:42:47 +0100 Subject: [PATCH] hcl2template: Rename Datasource type to DatasourceBlock --- hcl2template/common_test.go | 2 +- hcl2template/types.datasource.go | 12 ++++++------ hcl2template/types.packer_config_test.go | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/hcl2template/common_test.go b/hcl2template/common_test.go index 834539103..c9f7b9789 100644 --- a/hcl2template/common_test.go +++ b/hcl2template/common_test.go @@ -344,7 +344,7 @@ var cmpOpts = []cmp.Option{ PackerConfig{}, Variable{}, SourceBlock{}, - Datasource{}, + DatasourceBlock{}, ProvisionerBlock{}, PostProcessorBlock{}, packer.CoreBuild{}, diff --git a/hcl2template/types.datasource.go b/hcl2template/types.datasource.go index c25ab5b1a..568a0882f 100644 --- a/hcl2template/types.datasource.go +++ b/hcl2template/types.datasource.go @@ -11,8 +11,8 @@ import ( "github.com/zclconf/go-cty/cty" ) -// DataBlock references an HCL 'data' block. -type Datasource struct { +// DatasourceBlock references an HCL 'data' block. +type DatasourceBlock struct { Type string Name string @@ -25,9 +25,9 @@ type DatasourceRef struct { Name string } -type Datasources map[DatasourceRef]Datasource +type Datasources map[DatasourceRef]DatasourceBlock -func (data *Datasource) Ref() DatasourceRef { +func (data *DatasourceBlock) Ref() DatasourceRef { return DatasourceRef{ Type: data.Type, Name: data.Name, @@ -124,9 +124,9 @@ func (cfg *PackerConfig) startDatasource(dataSourceStore packer.DatasourceStore, return datasource, diags } -func (p *Parser) decodeDataBlock(block *hcl.Block) (*Datasource, hcl.Diagnostics) { +func (p *Parser) decodeDataBlock(block *hcl.Block) (*DatasourceBlock, hcl.Diagnostics) { var diags hcl.Diagnostics - r := &Datasource{ + r := &DatasourceBlock{ Type: block.Labels[0], Name: block.Labels[1], block: block, diff --git a/hcl2template/types.packer_config_test.go b/hcl2template/types.packer_config_test.go index 5a522b4d0..a045ebb68 100644 --- a/hcl2template/types.packer_config_test.go +++ b/hcl2template/types.packer_config_test.go @@ -131,7 +131,7 @@ func TestParser_complete(t *testing.T) { }, }, Datasources: Datasources{ - DatasourceRef{Type: "amazon-ami", Name: "test"}: Datasource{ + DatasourceRef{Type: "amazon-ami", Name: "test"}: DatasourceBlock{ Type: "amazon-ami", Name: "test", value: cty.StringVal("foo"),