Skip to content

Commit

Permalink
Image adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
asaha2 committed Dec 5, 2024
1 parent 0f3cb75 commit c2db11d
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 29 deletions.
24 changes: 12 additions & 12 deletions digitalocean/dropletautoscale/datasource_droplet_autoscale_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ data "digitalocean_droplet_autoscale" "foo" {
resource.TestCheckResourceAttr(
"data.digitalocean_droplet_autoscale.foo", "droplet_template.0.size", "c-2"),
resource.TestCheckResourceAttr(
"data.digitalocean_droplet_autoscale.foo", "droplet_template.0.region", "s2r1"),
resource.TestCheckResourceAttr(
"data.digitalocean_droplet_autoscale.foo", "droplet_template.0.image", "547864"),
"data.digitalocean_droplet_autoscale.foo", "droplet_template.0.region", "nyc3"),
resource.TestCheckResourceAttrSet(
"data.digitalocean_droplet_autoscale.foo", "droplet_template.0.image"),
resource.TestCheckResourceAttr(
"data.digitalocean_droplet_autoscale.foo", "droplet_template.0.with_droplet_agent", "true"),
resource.TestCheckResourceAttr(
Expand Down Expand Up @@ -109,9 +109,9 @@ data "digitalocean_droplet_autoscale" "foo" {
resource.TestCheckResourceAttr(
"data.digitalocean_droplet_autoscale.foo", "droplet_template.0.size", "c-2"),
resource.TestCheckResourceAttr(
"data.digitalocean_droplet_autoscale.foo", "droplet_template.0.region", "s2r1"),
resource.TestCheckResourceAttr(
"data.digitalocean_droplet_autoscale.foo", "droplet_template.0.image", "547864"),
"data.digitalocean_droplet_autoscale.foo", "droplet_template.0.region", "nyc3"),
resource.TestCheckResourceAttrSet(
"data.digitalocean_droplet_autoscale.foo", "droplet_template.0.image"),
resource.TestCheckResourceAttr(
"data.digitalocean_droplet_autoscale.foo", "droplet_template.0.with_droplet_agent", "true"),
resource.TestCheckResourceAttr(
Expand Down Expand Up @@ -187,9 +187,9 @@ data "digitalocean_droplet_autoscale" "foo" {
resource.TestCheckResourceAttr(
"data.digitalocean_droplet_autoscale.foo", "droplet_template.0.size", "c-2"),
resource.TestCheckResourceAttr(
"data.digitalocean_droplet_autoscale.foo", "droplet_template.0.region", "s2r1"),
resource.TestCheckResourceAttr(
"data.digitalocean_droplet_autoscale.foo", "droplet_template.0.image", "547864"),
"data.digitalocean_droplet_autoscale.foo", "droplet_template.0.region", "nyc3"),
resource.TestCheckResourceAttrSet(
"data.digitalocean_droplet_autoscale.foo", "droplet_template.0.image"),
resource.TestCheckResourceAttr(
"data.digitalocean_droplet_autoscale.foo", "droplet_template.0.with_droplet_agent", "true"),
resource.TestCheckResourceAttr(
Expand Down Expand Up @@ -235,9 +235,9 @@ data "digitalocean_droplet_autoscale" "foo" {
resource.TestCheckResourceAttr(
"data.digitalocean_droplet_autoscale.foo", "droplet_template.0.size", "c-2"),
resource.TestCheckResourceAttr(
"data.digitalocean_droplet_autoscale.foo", "droplet_template.0.region", "s2r1"),
resource.TestCheckResourceAttr(
"data.digitalocean_droplet_autoscale.foo", "droplet_template.0.image", "547864"),
"data.digitalocean_droplet_autoscale.foo", "droplet_template.0.region", "nyc3"),
resource.TestCheckResourceAttrSet(
"data.digitalocean_droplet_autoscale.foo", "droplet_template.0.image"),
resource.TestCheckResourceAttr(
"data.digitalocean_droplet_autoscale.foo", "droplet_template.0.with_droplet_agent", "true"),
resource.TestCheckResourceAttr(
Expand Down
15 changes: 14 additions & 1 deletion digitalocean/dropletautoscale/resource_droplet_autoscale.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ func ResourceDigitalOceanDropletAutoscale() *schema.Resource {
},
"config": {
Type: schema.TypeList,
MaxItems: 1,
Required: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
Expand Down Expand Up @@ -81,6 +82,7 @@ func ResourceDigitalOceanDropletAutoscale() *schema.Resource {
},
"droplet_template": {
Type: schema.TypeList,
MaxItems: 1,
Required: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
Expand Down Expand Up @@ -268,12 +270,23 @@ func resourceDigitalOceanDropletAutoscaleRead(ctx context.Context, d *schema.Res

d.Set("name", pool.Name)
d.Set("config", flattenConfig(pool.Config))
d.Set("droplet_template", flattenTemplate(pool.DropletTemplate))
d.Set("current_utilization", flattenUtilization(pool.CurrentUtilization))
d.Set("status", pool.Status)
d.Set("created_at", pool.CreatedAt.UTC().String())
d.Set("updated_at", pool.UpdatedAt.UTC().String())

// Persist existing image specification (id/slug) if it exists
if t, ok := d.GetOk("droplet_template"); ok {
tList := t.([]interface{})
if len(tList) > 0 {
tMap := tList[0].(map[string]interface{})
if tMap["image"] != "" {
pool.DropletTemplate.Image = tMap["image"].(string)
}
}
}
d.Set("droplet_template", flattenTemplate(pool.DropletTemplate))

return nil
}

Expand Down
32 changes: 16 additions & 16 deletions digitalocean/dropletautoscale/resource_droplet_autoscale_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ func TestAccDigitalOceanDropletAutoscale_Static(t *testing.T) {
resource.TestCheckResourceAttr(
"digitalocean_droplet_autoscale.foobar", "droplet_template.0.size", "c-2"),
resource.TestCheckResourceAttr(
"digitalocean_droplet_autoscale.foobar", "droplet_template.0.region", "s2r1"),
resource.TestCheckResourceAttr(
"digitalocean_droplet_autoscale.foobar", "droplet_template.0.image", "547864"),
"digitalocean_droplet_autoscale.foobar", "droplet_template.0.region", "nyc3"),
resource.TestCheckResourceAttrSet(
"digitalocean_droplet_autoscale.foobar", "droplet_template.0.image"),
resource.TestCheckResourceAttr(
"digitalocean_droplet_autoscale.foobar", "droplet_template.0.with_droplet_agent", "true"),
resource.TestCheckResourceAttr(
Expand Down Expand Up @@ -101,9 +101,9 @@ func TestAccDigitalOceanDropletAutoscale_Static(t *testing.T) {
resource.TestCheckResourceAttr(
"digitalocean_droplet_autoscale.foobar", "droplet_template.0.size", "c-2"),
resource.TestCheckResourceAttr(
"digitalocean_droplet_autoscale.foobar", "droplet_template.0.region", "s2r1"),
resource.TestCheckResourceAttr(
"digitalocean_droplet_autoscale.foobar", "droplet_template.0.image", "547864"),
"digitalocean_droplet_autoscale.foobar", "droplet_template.0.region", "nyc3"),
resource.TestCheckResourceAttrSet(
"digitalocean_droplet_autoscale.foobar", "droplet_template.0.image"),
resource.TestCheckResourceAttr(
"digitalocean_droplet_autoscale.foobar", "droplet_template.0.with_droplet_agent", "true"),
resource.TestCheckResourceAttr(
Expand Down Expand Up @@ -165,9 +165,9 @@ func TestAccDigitalOceanDropletAutoscale_Dynamic(t *testing.T) {
resource.TestCheckResourceAttr(
"digitalocean_droplet_autoscale.foobar", "droplet_template.0.size", "c-2"),
resource.TestCheckResourceAttr(
"digitalocean_droplet_autoscale.foobar", "droplet_template.0.region", "s2r1"),
resource.TestCheckResourceAttr(
"digitalocean_droplet_autoscale.foobar", "droplet_template.0.image", "547864"),
"digitalocean_droplet_autoscale.foobar", "droplet_template.0.region", "nyc3"),
resource.TestCheckResourceAttrSet(
"digitalocean_droplet_autoscale.foobar", "droplet_template.0.image"),
resource.TestCheckResourceAttr(
"digitalocean_droplet_autoscale.foobar", "droplet_template.0.with_droplet_agent", "true"),
resource.TestCheckResourceAttr(
Expand Down Expand Up @@ -213,9 +213,9 @@ func TestAccDigitalOceanDropletAutoscale_Dynamic(t *testing.T) {
resource.TestCheckResourceAttr(
"digitalocean_droplet_autoscale.foobar", "droplet_template.0.size", "c-2"),
resource.TestCheckResourceAttr(
"digitalocean_droplet_autoscale.foobar", "droplet_template.0.region", "s2r1"),
resource.TestCheckResourceAttr(
"digitalocean_droplet_autoscale.foobar", "droplet_template.0.image", "547864"),
"digitalocean_droplet_autoscale.foobar", "droplet_template.0.region", "nyc3"),
resource.TestCheckResourceAttrSet(
"digitalocean_droplet_autoscale.foobar", "droplet_template.0.image"),
resource.TestCheckResourceAttr(
"digitalocean_droplet_autoscale.foobar", "droplet_template.0.with_droplet_agent", "true"),
resource.TestCheckResourceAttr(
Expand Down Expand Up @@ -319,8 +319,8 @@ resource "digitalocean_droplet_autoscale" "foobar" {
droplet_template {
size = "c-2"
region = "s2r1"
image = "547864"
region = "nyc3"
image = "ubuntu-24-04-x64"
tags = [digitalocean_tag.foo.id, digitalocean_tag.bar.id]
ssh_keys = [digitalocean_ssh_key.foo.id, digitalocean_ssh_key.bar.id]
with_droplet_agent = true
Expand Down Expand Up @@ -380,8 +380,8 @@ resource "digitalocean_droplet_autoscale" "foobar" {
droplet_template {
size = "c-2"
region = "s2r1"
image = "547864"
region = "nyc3"
image = "ubuntu-24-04-x64"
tags = [digitalocean_tag.foo.id, digitalocean_tag.bar.id]
ssh_keys = [digitalocean_ssh_key.foo.id, digitalocean_ssh_key.bar.id]
with_droplet_agent = true
Expand Down

0 comments on commit c2db11d

Please sign in to comment.