diff --git a/builtin/providers/scaleway/data_source_scaleway_bootscript.go b/builtin/providers/scaleway/data_source_scaleway_bootscript.go index 3c2a6a275..63232bfda 100644 --- a/builtin/providers/scaleway/data_source_scaleway_bootscript.go +++ b/builtin/providers/scaleway/data_source_scaleway_bootscript.go @@ -80,12 +80,16 @@ func dataSourceScalewayBootscriptRead(d *schema.ResourceData, meta interface{}) var isMatch func(api.ScalewayBootscript) bool + architecture := d.Get("architecture") if name, ok := d.GetOk("name"); ok { isMatch = func(s api.ScalewayBootscript) bool { - return s.Title == name.(string) + architectureMatch := true + if architecture != "" { + architectureMatch = architecture == s.Arch + } + return s.Title == name.(string) && architectureMatch } } else if nameFilter, ok := d.GetOk("name_filter"); ok { - architecture := d.Get("architecture") exp, err := regexp.Compile(nameFilter.(string)) if err != nil { return err diff --git a/builtin/providers/scaleway/data_source_scaleway_bootscript_test.go b/builtin/providers/scaleway/data_source_scaleway_bootscript_test.go index 7c5ee3a5e..3c0c10696 100644 --- a/builtin/providers/scaleway/data_source_scaleway_bootscript_test.go +++ b/builtin/providers/scaleway/data_source_scaleway_bootscript_test.go @@ -2,31 +2,12 @@ package scaleway import ( "fmt" - "regexp" "testing" "github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/terraform" ) -func TestAccScalewayDataSourceBootscript_Basic(t *testing.T) { - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - Steps: []resource.TestStep{ - resource.TestStep{ - Config: testAccCheckScalewayBootscriptConfig, - Check: resource.ComposeTestCheckFunc( - testAccCheckBootscriptID("data.scaleway_bootscript.debug"), - resource.TestCheckResourceAttr("data.scaleway_bootscript.debug", "architecture", "x86_64"), - resource.TestCheckResourceAttr("data.scaleway_bootscript.debug", "public", "true"), - resource.TestMatchResourceAttr("data.scaleway_bootscript.debug", "kernel", regexp.MustCompile("4.8.3")), - ), - }, - }, - }) -} - func TestAccScalewayDataSourceBootscript_Filtered(t *testing.T) { resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -65,12 +46,6 @@ func testAccCheckBootscriptID(n string) resource.TestCheckFunc { } } -const testAccCheckScalewayBootscriptConfig = ` -data "scaleway_bootscript" "debug" { - name = "x86_64 4.8.3 debug #1" -} -` - const testAccCheckScalewayBootscriptFilterConfig = ` data "scaleway_bootscript" "debug" { architecture = "arm"