Skip to content

Commit caa46c9

Browse files
Merge pull request #1005 from F5Networks/devel_01082024
deal sync to master
2 parents cf31cf3 + bf37ccb commit caa46c9

File tree

9 files changed

+202
-9
lines changed

9 files changed

+202
-9
lines changed

bigip/datasource_bigip_ltm_monitor.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,32 @@ func dataSourceBigipLtmMonitor() *schema.Resource {
103103
Computed: true,
104104
Description: "the database in which your user is created",
105105
},
106+
107+
"base": {
108+
Type: schema.TypeString,
109+
Computed: true,
110+
Description: "Specifies the location in the LDAP tree from which the monitor starts the health check",
111+
},
112+
"filter": {
113+
Type: schema.TypeString,
114+
Computed: true,
115+
Description: "Specifies an LDAP key for which the monitor searches",
116+
},
117+
"mandatory_attributes": {
118+
Type: schema.TypeString,
119+
Computed: true,
120+
Description: "Specifies whether the target must include attributes in its response to be considered up. The options are no (Specifies that the system performs only a one-level search (based on the Filter setting), and does not require that the target returns any attributes.) and yes (Specifies that the system performs a sub-tree search, and if the target returns no attributes, the target is considered down.)",
121+
},
122+
"chase_referrals": {
123+
Type: schema.TypeString,
124+
Computed: true,
125+
Description: "Specifies whether the system will query the LDAP servers pointed to by any referrals in the query results.",
126+
},
127+
"security": {
128+
Type: schema.TypeString,
129+
Computed: true,
130+
Description: "Specifies the secure communications protocol that the monitor uses to communicate with the target. The options are none (Specifies that the system does not use a security protocol for communications with the target.), ssl (Specifies that the system uses the SSL protocol for communications with the target.), and tls (Specifies that the system uses the TLS protocol for communications with the target.)",
131+
},
106132
},
107133
}
108134
}
@@ -141,6 +167,11 @@ func dataSourceBigipLtmMonitorRead(ctx context.Context, d *schema.ResourceData,
141167
_ = d.Set("username", m.Username)
142168
_ = d.Set("name", name)
143169
_ = d.Set("database", m.Database)
170+
_ = d.Set("base", m.Base)
171+
_ = d.Set("filter", m.Filter)
172+
_ = d.Set("mandatory_attributes", m.MandatoryAttributes)
173+
_ = d.Set("chase_referrals", m.ChaseReferrals)
174+
_ = d.Set("security", m.Security)
144175
d.SetId(m.FullPath)
145176
return nil
146177
}
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/*
2+
Original work from https://github.com/DealerDotCom/terraform-provider-bigip
3+
Modifications Copyright 2019 F5 Networks Inc.
4+
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
5+
If a copy of the MPL was not distributed with this file,You can obtain one at https://mozilla.org/MPL/2.0/.
6+
*/
7+
package bigip
8+
9+
import (
10+
"testing"
11+
12+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
13+
)
14+
15+
func TestAccBigipLtmWafPolicyTestCases(t *testing.T) {
16+
resource.Test(t, resource.TestCase{
17+
PreCheck: func() {
18+
testAcctPreCheck(t)
19+
},
20+
Providers: testAccProviders,
21+
CheckDestroy: testMonitorsDestroyed,
22+
Steps: []resource.TestStep{
23+
{
24+
Config: loadFixtureString("../examples/awaf/awaftest_issue822.tf"),
25+
Check: resource.ComposeTestCheckFunc(
26+
// testCheckMonitorExists("/Common/test_monitor_tc1"),
27+
// testCheckMonitorExists("/Common/test_monitor_tc2"),
28+
// testCheckMonitorExists("/Common/test_monitor_tc3"),
29+
// testCheckMonitorExists("/Common/test_monitor_tc4"),
30+
// testCheckMonitorExists("/Common/test_monitor_tc5"),
31+
),
32+
},
33+
},
34+
})
35+
}
36+
37+
// func testCheckMonitorExists(name string) resource.TestCheckFunc {
38+
// return func(s *terraform.State) error {
39+
// client := testAccProvider.Meta().(*bigip.BigIP)
40+
41+
// monitors, err := client.Monitors()
42+
// if err != nil {
43+
// return err
44+
// }
45+
46+
// for _, m := range monitors {
47+
// if m.FullPath == name {
48+
// return nil
49+
// }
50+
// }
51+
// return fmt.Errorf("Monitor %s was not created ", name)
52+
// }
53+
// }
54+
55+
// func testMonitorsDestroyed(s *terraform.State) error {
56+
// client := testAccProvider.Meta().(*bigip.BigIP)
57+
58+
// monitors, err := client.Monitors()
59+
// if err != nil {
60+
// return err
61+
// }
62+
63+
// for _, rs := range s.RootModule().Resources {
64+
// if rs.Type != "bigip_ltm_monitor" {
65+
// continue
66+
// }
67+
68+
// name := rs.Primary.ID
69+
// for _, m := range monitors {
70+
// if m.FullPath == name {
71+
// return fmt.Errorf("Monitor %s not destroyed ", name)
72+
// }
73+
// }
74+
// }
75+
// return nil
76+
// }

bigip/resource_bigip_ltm_monitor.go

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,33 @@ func resourceBigipLtmMonitor() *schema.Resource {
196196
Optional: true,
197197
Description: "the ssl profile",
198198
},
199+
200+
"base": {
201+
Type: schema.TypeString,
202+
Optional: true,
203+
Description: "Specifies the location in the LDAP tree from which the monitor starts the health check",
204+
},
205+
"filter": {
206+
Type: schema.TypeString,
207+
Optional: true,
208+
Description: "Specifies an LDAP key for which the monitor searches",
209+
},
210+
"mandatory_attributes": {
211+
Type: schema.TypeString,
212+
Optional: true,
213+
Description: "Specifies whether the target must include attributes in its response to be considered up. The options are no (Specifies that the system performs only a one-level search (based on the Filter setting), and does not require that the target returns any attributes.) and yes (Specifies that the system performs a sub-tree search, and if the target returns no attributes, the target is considered down.)",
214+
},
215+
"chase_referrals": {
216+
Type: schema.TypeString,
217+
Optional: true,
218+
Computed: true,
219+
Description: "Specifies whether the system will query the LDAP servers pointed to by any referrals in the query results.",
220+
},
221+
"security": {
222+
Type: schema.TypeString,
223+
Optional: true,
224+
Description: "Specifies the secure communications protocol that the monitor uses to communicate with the target. The options are none (Specifies that the system does not use a security protocol for communications with the target.), ssl (Specifies that the system uses the SSL protocol for communications with the target.), and tls (Specifies that the system uses the TLS protocol for communications with the target.)",
225+
},
199226
},
200227
}
201228
}
@@ -287,6 +314,12 @@ func resourceBigipLtmMonitorRead(ctx context.Context, d *schema.ResourceData, me
287314
_ = d.Set("password", m.Password)
288315
_ = d.Set("name", name)
289316
_ = d.Set("database", m.Database)
317+
318+
_ = d.Set("base", m.Base)
319+
_ = d.Set("filter", m.Filter)
320+
_ = d.Set("mandatory_attributes", m.MandatoryAttributes)
321+
_ = d.Set("chase_referrals", m.ChaseReferrals)
322+
_ = d.Set("security", m.Security)
290323
return nil
291324
}
292325
}
@@ -382,5 +415,10 @@ func getLtmMonitorConfig(d *schema.ResourceData, config *bigip.Monitor) *bigip.M
382415
config.Password = d.Get("password").(string)
383416
config.UpInterval = d.Get("up_interval").(int)
384417
config.SSLProfile = d.Get("ssl_profile").(string)
418+
config.Base = d.Get("base").(string)
419+
config.Filter = d.Get("filter").(string)
420+
config.MandatoryAttributes = d.Get("mandatory_attributes").(string)
421+
config.ChaseReferrals = d.Get("chase_referrals").(string)
422+
config.Security = d.Get("security").(string)
385423
return config
386424
}

bigip/resource_bigip_ltm_monitor_test.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ var TestHttpsMonitorName = fmt.Sprintf("/%s/test-https-monitor", TestPartition)
2222
var TestFtpMonitorName = fmt.Sprintf("/%s/test-ftp-monitor", TestPartition)
2323
var TestUdpMonitorName = fmt.Sprintf("/%s/test-udp-monitor", TestPartition)
2424
var TestPostgresqlMonitorName = fmt.Sprintf("/%s/test-postgresql-monitor", TestPartition)
25+
var TestLDAPMonitorName = fmt.Sprintf("/%s/test-ldap-monitor", TestPartition)
2526
var TestGatewayIcmpMonitorName = fmt.Sprintf("/%s/test-gateway", TestPartition)
2627
var TestTcpHalfOpenMonitorName = fmt.Sprintf("/%s/test-tcp-half-open", TestPartition)
2728

@@ -97,6 +98,17 @@ resource "bigip_ltm_monitor" "test-postgresql-monitor" {
9798
}
9899
`
99100

101+
var TestLDAPMonitorResource = `
102+
resource "bigip_ltm_monitor" "test-ldap-monitor" {
103+
name = "` + TestLDAPMonitorName + `"
104+
parent = "/Common/ldap"
105+
interval = 5
106+
timeout = 16
107+
base = "DC=company,DC=com"
108+
filter = "(cn=username)"
109+
security = "ssl"
110+
}
111+
`
100112
var TestGatewayIcmpMonitorResource = `
101113
resource "bigip_ltm_monitor" "test-gateway-icmp-monitor" {
102114
name = "` + TestGatewayIcmpMonitorName + `"
@@ -292,6 +304,30 @@ func TestAccBigipLtmMonitor_UdpCreate(t *testing.T) {
292304
},
293305
})
294306
}
307+
func TestAccBigipLtmMonitor_LDAPCreate(t *testing.T) {
308+
resource.Test(t, resource.TestCase{
309+
PreCheck: func() {
310+
testAcctPreCheck(t)
311+
},
312+
Providers: testAccProviders,
313+
CheckDestroy: testMonitorsDestroyed,
314+
Steps: []resource.TestStep{
315+
{
316+
Config: TestLDAPMonitorResource,
317+
Check: resource.ComposeTestCheckFunc(
318+
testCheckMonitorExists(TestLDAPMonitorName),
319+
resource.TestCheckResourceAttr("bigip_ltm_monitor.test-ldap-monitor", "parent", "/Common/ldap"),
320+
resource.TestCheckResourceAttr("bigip_ltm_monitor.test-ldap-monitor", "timeout", "16"),
321+
resource.TestCheckResourceAttr("bigip_ltm_monitor.test-ldap-monitor", "interval", "5"),
322+
resource.TestCheckResourceAttr("bigip_ltm_monitor.test-ldap-monitor", "filter", "(cn=username)"),
323+
resource.TestCheckResourceAttr("bigip_ltm_monitor.test-ldap-monitor", "security", "ssl"),
324+
resource.TestCheckResourceAttr("bigip_ltm_monitor.test-ldap-monitor", "base", "DC=company,DC=com"),
325+
),
326+
},
327+
},
328+
})
329+
}
330+
295331
func TestAccBigipLtmMonitor_PostgresqlCreate(t *testing.T) {
296332
resource.Test(t, resource.TestCase{
297333
PreCheck: func() {

bigip/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
package bigip
22

33
// ProviderVersion is set at build-time in the release process
4-
var ProviderVersion = "1.22.2"
4+
var ProviderVersion = "1.22.3"

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ require (
1010
github.com/Azure/azure-storage-blob-go v0.13.0
1111
github.com/Azure/go-autorest/autorest v0.11.18
1212
github.com/Azure/go-autorest/autorest/adal v0.9.13
13-
github.com/f5devcentral/go-bigip v0.0.0-20240614094559-88a99e648815
14-
github.com/f5devcentral/go-bigip/f5teem v0.0.0-20240614094559-88a99e648815
13+
github.com/f5devcentral/go-bigip v0.0.0-20240801101847-64d6eb419ed6
14+
github.com/f5devcentral/go-bigip/f5teem v0.0.0-20240801101847-64d6eb419ed6
1515
github.com/google/uuid v1.3.0
1616
github.com/hashicorp/terraform-plugin-sdk/v2 v2.25.0
1717
github.com/stretchr/testify v1.8.4

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
5151
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
5252
github.com/emirpasic/gods v1.12.0 h1:QAUIPSaCu4G+POclxeqb3F+WPpdKqFGlw36+yOzGlrg=
5353
github.com/emirpasic/gods v1.12.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3ymbK86o=
54-
github.com/f5devcentral/go-bigip v0.0.0-20240614094559-88a99e648815 h1:SV4C8S2tTdDCTVmqvpc+6qtZnu0R5oFZHzt06xbUUTo=
55-
github.com/f5devcentral/go-bigip v0.0.0-20240614094559-88a99e648815/go.mod h1:0Lkr0fBU6O1yBxF2mt9JFwXpaFbIb/wAY7oM3dMJDdA=
56-
github.com/f5devcentral/go-bigip/f5teem v0.0.0-20240614094559-88a99e648815 h1:djBhjzmQzoU7Up3Mwr+CXCo2QswlkpNEapwWX339JxI=
57-
github.com/f5devcentral/go-bigip/f5teem v0.0.0-20240614094559-88a99e648815/go.mod h1:r7o5I22EvO+fps2u10bz4ZUlTlNHopQSWzVcW19hK3U=
54+
github.com/f5devcentral/go-bigip v0.0.0-20240801101847-64d6eb419ed6 h1:ckTAKRScUrCQLzhr0LjuGEQ+Cdw+DihVacGtk7VHRn4=
55+
github.com/f5devcentral/go-bigip v0.0.0-20240801101847-64d6eb419ed6/go.mod h1:0Lkr0fBU6O1yBxF2mt9JFwXpaFbIb/wAY7oM3dMJDdA=
56+
github.com/f5devcentral/go-bigip/f5teem v0.0.0-20240801101847-64d6eb419ed6 h1:1n8eAKWABMl4ZkjdheVQC19fdyNwO5k/DqP8e3OB2sI=
57+
github.com/f5devcentral/go-bigip/f5teem v0.0.0-20240801101847-64d6eb419ed6/go.mod h1:r7o5I22EvO+fps2u10bz4ZUlTlNHopQSWzVcW19hK3U=
5858
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
5959
github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w=
6060
github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=

vendor/github.com/f5devcentral/go-bigip/ltm.go

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/modules.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ github.com/apparentlymart/go-textseg/v13/textseg
4242
# github.com/davecgh/go-spew v1.1.1
4343
## explicit
4444
github.com/davecgh/go-spew/spew
45-
# github.com/f5devcentral/go-bigip v0.0.0-20240614094559-88a99e648815
45+
# github.com/f5devcentral/go-bigip v0.0.0-20240801101847-64d6eb419ed6
4646
## explicit; go 1.20
4747
github.com/f5devcentral/go-bigip
48-
# github.com/f5devcentral/go-bigip/f5teem v0.0.0-20240614094559-88a99e648815
48+
# github.com/f5devcentral/go-bigip/f5teem v0.0.0-20240801101847-64d6eb419ed6
4949
## explicit; go 1.13
5050
github.com/f5devcentral/go-bigip/f5teem
5151
# github.com/fatih/color v1.13.0

0 commit comments

Comments
 (0)