Skip to content

Commit

Permalink
Add firewall_policy field to server group
Browse files Browse the repository at this point in the history
- Add read-only field to server group: data and resource
- Update documentation to follow
  • Loading branch information
NeilW committed Dec 15, 2022
1 parent c8cc1d1 commit 153f077
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 6 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
## 3.1.0 (December 15, 2022)

IMPROVEMENTS:
- resource/server_group: Add read-only firewall_policy field
- data/server_group: Add firewall_policy field

NOTES:
- Update SDK to 2.24
- Update oauth to 0.3.0

## 3.0.6 (December 5, 2022)

BUG FIXES:
Expand Down
5 changes: 5 additions & 0 deletions brightbox/data_source_brightbox_server_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ func dataSourceBrightboxServerGroup() *schema.Resource {
Optional: true,
Computed: true,
},
"firewall_policy": {
Description: "The firewall policy associated with this server group",
Type: schema.TypeString,
Computed: true,
},
},
}
}
Expand Down
2 changes: 2 additions & 0 deletions brightbox/data_source_brightbox_server_group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ func TestAccBrightboxDataServerGroup_basic(t *testing.T) {
"data.brightbox_server_group.default", "name", "default"),
resource.TestCheckResourceAttr(
"data.brightbox_server_group.default", "default", "true"),
resource.TestMatchResourceAttr(
"data.brightbox_server_group.default", "firewall_policy", firewallPolicyRegexp),
),
},
},
Expand Down
13 changes: 13 additions & 0 deletions brightbox/resource_brightbox_server_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ func resourceBrightboxServerGroup() *schema.Resource {
Type: schema.TypeString,
Optional: true,
},
"firewall_policy": {
Description: "The firewall policy associated with this server group",
Type: schema.TypeString,
Computed: true,
},
},
}
}
Expand Down Expand Up @@ -121,6 +126,14 @@ func setServerGroupAttributes(
if err != nil {
diags = append(diags, diag.Errorf("unexpected: %s", err)...)
}
firewallTarget := ""
if serverGroup.FirewallPolicy != nil {
firewallTarget = serverGroup.FirewallPolicy.ID
}
err = d.Set("firewall_policy", firewallTarget)
if err != nil {
diags = append(diags, diag.Errorf("unexpected: %s", err)...)
}
return diags
}

Expand Down
13 changes: 7 additions & 6 deletions brightbox/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,11 +259,12 @@ func validToken(tok string) bool {

// validHeaderFieldByte reports whether b is a valid byte in a header
// field name. RFC 7230 says:
// header-field = field-name ":" OWS field-value OWS
// field-name = token
// tchar = "!" / "#" / "$" / "%" / "&" / "'" / "*" / "+" / "-" / "." /
// "^" / "_" / "`" / "|" / "~" / DIGIT / ALPHA
// token = 1*tchar
//
// header-field = field-name ":" OWS field-value OWS
// field-name = token
// tchar = "!" / "#" / "$" / "%" / "&" / "'" / "*" / "+" / "-" / "." /
// "^" / "_" / "`" / "|" / "~" / DIGIT / ALPHA
// token = 1*tchar
//
// Underscore isn't valid. Needs to be a hyphen as Swift silently
// converts otherwise.
Expand Down Expand Up @@ -364,7 +365,7 @@ func CheckDeleted(d *schema.ResourceData, err error, msg string) error {

// getEnvVarWithDefault retrieves the value of the environment variable
// named by the key. If the variable is not present, return the default
//value instead.
// value instead.
func getenvWithDefault(key string, defaultValue string) string {
if val, exists := os.LookupEnv(key); exists {
return val
Expand Down
1 change: 1 addition & 0 deletions website/docs/d/brightbox_server_group.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,4 @@ The following attributes are exported:
* `id` - The ID of the Server
* `default` - Is this the default server group?
* `fqdn` - The Fully Qualified Domain Name of the server group
* `firewall_policy` - The ID of the Firewall Policy associated with this group
1 change: 1 addition & 0 deletions website/docs/r/server_group.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ The following attributes are exported:
* `id` - The ID of the Server
* `default` - Is this the default server group?
* `fqdn` - The Fully Qualified Domain Name of the server group
* `firewall_policy` - The ID of the Firewall Policy associated with this group

## Import

Expand Down

0 comments on commit 153f077

Please sign in to comment.