Skip to content

Commit

Permalink
Merge pull request #3805 from broswen/bswenson/waiting-room-origin-co…
Browse files Browse the repository at this point in the history
…mmands

add enabled_origin_commands field to waiting_room
  • Loading branch information
jacobbednarz authored Sep 2, 2024
2 parents d3cc413 + d49c77b commit bf5d7df
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .changelog/3805.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/cloudflare_waiting_room: Add enabled_origin_commands field.
```
2 changes: 2 additions & 0 deletions examples/resources/cloudflare_waiting_room/resource.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,6 @@ resource "cloudflare_waiting_room" "example" {
}

queueing_status_code = 200

enabled_origin_commands = ["revoke"]
}
2 changes: 2 additions & 0 deletions internal/sdkv2provider/resource_cloudflare_waiting_room.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ func buildWaitingRoom(d *schema.ResourceData) cloudflare.WaitingRoom {
CookieSuffix: d.Get("cookie_suffix").(string),
AdditionalRoutes: additional_routes,
QueueingStatusCode: d.Get("queueing_status_code").(int),
EnabledOriginCommands: expandInterfaceToStringList(d.Get("enabled_origin_commands").([]interface{})),
}
}

Expand Down Expand Up @@ -119,6 +120,7 @@ func resourceCloudflareWaitingRoomRead(ctx context.Context, d *schema.ResourceDa
d.Set("cookie_suffix", waitingRoom.CookieSuffix)
d.Set("additional_routes", flattenWaitingRoomAdditionalRoutes(waitingRoom.AdditionalRoutes))
d.Set("queueing_status_code", waitingRoom.QueueingStatusCode)
d.Set("enabled_origin_commands", waitingRoom.EnabledOriginCommands)
return nil
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ func TestAccCloudflareWaitingRoom_Create(t *testing.T) {
resource.TestCheckResourceAttr(name, "additional_routes.1.host", "shop2."+domain),
resource.TestCheckResourceAttr(name, "additional_routes.1.path", "/"),
resource.TestCheckResourceAttr(name, "queueing_status_code", "200"),
resource.TestCheckResourceAttr(name, "enabled_origin_commands.0", "revoke"),
),
},
},
Expand Down Expand Up @@ -149,6 +150,8 @@ resource "cloudflare_waiting_room" "%[1]s" {
queueing_status_code = 200
enabled_origin_commands = ["revoke"]
depends_on = [cloudflare_record.%[1]s-shop-1, cloudflare_record.%[1]s-shop-2]
}
`, resourceName, waitingRoomName, zoneID, domain, path)
Expand Down
14 changes: 14 additions & 0 deletions internal/sdkv2provider/schema_cloudflare_waiting_room.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ var waitingRoomQueueingMethod = []string{
"reject",
}

var waitingRoomOriginCommands = []string{
"revoke",
}

func resourceCloudflareWaitingRoomSchema() map[string]*schema.Schema {
return map[string]*schema.Schema{
consts.ZoneIDSchemaKey: {
Expand Down Expand Up @@ -177,5 +181,15 @@ func resourceCloudflareWaitingRoomSchema() map[string]*schema.Schema {
Optional: true,
Default: 200,
},

"enabled_origin_commands": {
Description: fmt.Sprintf("The list of enabled origin commands for the waiting room. %s", renderAvailableDocumentationValuesStringSlice(waitingRoomOriginCommands)),
Type: schema.TypeList,
Optional: true,
Elem: &schema.Schema{
Type: schema.TypeString,
ValidateFunc: validation.StringInSlice(waitingRoomOriginCommands, false),
},
},
}
}

0 comments on commit bf5d7df

Please sign in to comment.