Skip to content

Commit b6d1594

Browse files
committed
Added fix for 1024, 1009
1 parent 825bdc0 commit b6d1594

File tree

5 files changed

+105
-6
lines changed

5 files changed

+105
-6
lines changed

bigip/resource_bigip_ltm_datagroup.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ func resourceBigipLtmDataGroupRead(ctx context.Context, d *schema.ResourceData,
128128
name := d.Id()
129129
log.Printf("[DEBUG] Retrieving Data Group List %s", name)
130130
datagroup, err := client.GetInternalDataGroup(name)
131-
if err != nil {
131+
if err != nil && !strings.Contains(err.Error(), "not found") {
132132
return diag.FromErr(fmt.Errorf("Error retrieving Data Group List %s: %v ", name, err))
133133
}
134134

bigip/resource_bigip_ltm_datagroup_test.go

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,15 @@ var TestDatagroupStringResource = `
3030
}
3131
}`
3232

33+
var TestExternalDatagroupResource = `
34+
resource "bigip_ltm_datagroup" "test-datagroup-string" {
35+
name = "` + TestDatagroupName + `"
36+
type = "string"
37+
internal = false
38+
records_src = "foo.bars"
39+
40+
}`
41+
3342
var TestDatagroupIpResource = `
3443
resource "bigip_ltm_datagroup" "test-datagroup-ip" {
3544
name = "` + TestDatagroupName + `"
@@ -73,6 +82,24 @@ func TestAccBigipLtmDataGroup_Create_TypeString(t *testing.T) {
7382
},
7483
})
7584
}
85+
86+
func TestAccBigipLtmDataGroup_Create_External(t *testing.T) {
87+
resource.Test(t, resource.TestCase{
88+
PreCheck: func() {
89+
testAcctPreCheck(t)
90+
},
91+
Providers: testAccProviders,
92+
CheckDestroy: testCheckDataGroupDestroyed,
93+
Steps: []resource.TestStep{
94+
{
95+
Config: TestExternalDatagroupResource,
96+
Check: resource.ComposeTestCheckFunc(
97+
testCheckExternalDataGroupExists(TestDatagroupName),
98+
),
99+
},
100+
},
101+
})
102+
}
76103
func TestAccBigipLtmDataGroup_Create_TypeIp(t *testing.T) {
77104
resource.Test(t, resource.TestCase{
78105
PreCheck: func() {
@@ -186,6 +213,22 @@ func testCheckDataGroupExists(name string) resource.TestCheckFunc {
186213
}
187214
}
188215

216+
func testCheckExternalDataGroupExists(name string) resource.TestCheckFunc {
217+
return func(s *terraform.State) error {
218+
client := testAccProvider.Meta().(*bigip.BigIP)
219+
datagroup, err := client.GetExternalDataGroup(name)
220+
if err != nil {
221+
return fmt.Errorf("Error while fetching Data Group: %v ", err)
222+
223+
}
224+
datagroupName := datagroup.FullPath
225+
if datagroupName != name {
226+
return fmt.Errorf("Data Group name does not match. Expecting %s got %s ", name, datagroupName)
227+
}
228+
return nil
229+
}
230+
}
231+
189232
func testCheckDataGroupDestroyed(s *terraform.State) error {
190233
client := testAccProvider.Meta().(*bigip.BigIP)
191234

bigip/resource_bigip_ltm_profile_http.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ func resourceBigipLtmProfileHttp() *schema.Resource {
7979
Description: "Specifies a passphrase for the cookie encryption. Note: Since it's a sensitive entity idempotency will fail for it in the update call.",
8080
},
8181
"fallback_host": {
82-
Type: schema.TypeString,
83-
Optional: true,
84-
Computed: true,
82+
Type: schema.TypeString,
83+
Optional: true,
84+
// Computed: true,
8585
Description: "Specifies an HTTP fallback host. HTTP redirection allows you to redirect HTTP traffic to another protocol identifier, host name, port number, or URI path.",
8686
},
8787
"fallback_status_codes": {
@@ -468,7 +468,12 @@ func getHttpProfileConfig(d *schema.ResourceData, config *bigip.HttpProfile) *bi
468468
config.Description = d.Get("description").(string)
469469
config.EncryptCookieSecret = d.Get("encrypt_cookie_secret").(string)
470470
config.EncryptCookies = setToStringSlice(d.Get("encrypt_cookies").(*schema.Set))
471-
config.FallbackHost = d.Get("fallback_host").(string)
471+
if _, ok := d.GetOk("fallback_host"); ok {
472+
config.FallbackHost = d.Get("fallback_host").(string)
473+
} else {
474+
config.FallbackHost = ""
475+
}
476+
472477
config.FallbackStatusCodes = setToStringSlice(d.Get("fallback_status_codes").(*schema.Set))
473478
config.HeaderErase = d.Get("head_erase").(string)
474479
config.HeaderInsert = d.Get("head_insert").(string)

bigip/resource_bigip_ltm_profile_http_test.go

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,47 @@ func TestAccBigipLtmProfileHttpUpdateServerAgent(t *testing.T) {
121121
})
122122
}
123123

124+
func TestAccBigipLtmProfileHttpUpdateFallbackHost(t *testing.T) {
125+
t.Parallel()
126+
var instName = "test-http-Update-fallbackhost"
127+
var TestHttpName = fmt.Sprintf("/%s/%s", TestPartition, instName)
128+
resFullName := fmt.Sprintf("%s.%s", resHttpName, "http-profile-test")
129+
resource.Test(t, resource.TestCase{
130+
PreCheck: func() {
131+
testAcctPreCheck(t)
132+
},
133+
Providers: testAccProviders,
134+
// CheckDestroy: testCheckHttpsDestroyed,
135+
Steps: []resource.TestStep{
136+
{
137+
Config: testaccbigipltmprofilehttpDefaultConfig(TestPartition, TestHttpName, "http-profile-test"),
138+
Check: resource.ComposeTestCheckFunc(
139+
testCheckhttpExists(TestHttpName),
140+
resource.TestCheckResourceAttr(resFullName, "name", TestHttpName),
141+
resource.TestCheckResourceAttr(resFullName, "defaults_from", "/Common/http"),
142+
),
143+
},
144+
{
145+
Config: testaccbigipltmprofilehttpUpdateFallbackHost(TestPartition, TestHttpName, "http-profile-test"),
146+
Check: resource.ComposeTestCheckFunc(
147+
testCheckhttpExists(TestHttpName),
148+
resource.TestCheckResourceAttr(resFullName, "name", TestHttpName),
149+
resource.TestCheckResourceAttr(resFullName, "defaults_from", "/Common/http"),
150+
resource.TestCheckResourceAttr(resFullName, "fallback_host", "https://www.google.de"),
151+
),
152+
},
153+
{
154+
Config: testaccbigipltmprofilehttpDefaultConfig(TestPartition, TestHttpName, "http-profile-test"),
155+
Check: resource.ComposeTestCheckFunc(
156+
testCheckhttpExists(TestHttpName),
157+
resource.TestCheckResourceAttr(resFullName, "name", TestHttpName),
158+
resource.TestCheckResourceAttr(resFullName, "defaults_from", "/Common/http"),
159+
),
160+
},
161+
},
162+
})
163+
}
164+
124165
func TestAccBigipLtmProfileHttpUpdateFallbackhost(t *testing.T) {
125166
t.Parallel()
126167
var instName = "test-http-Update-FallbackHost"
@@ -544,6 +585,16 @@ resource "bigip_ltm_profile_http" "%[3]s" {
544585
`, partition, profileName, resourceName)
545586
}
546587

588+
func testaccbigipltmprofilehttpUpdateFallbackHost(partition, profileName, resourceName string) string {
589+
return fmt.Sprintf(`
590+
resource "bigip_ltm_profile_http" "%[3]s" {
591+
name = "%[2]s"
592+
defaults_from = "/%[1]s/http"
593+
fallback_host = "https://www.google.de"
594+
}
595+
`, partition, profileName, resourceName)
596+
}
597+
547598
func testaccBigipLtmHttpProfileImportConfig() string {
548599
return fmt.Sprintf(`
549600
resource "bigip_ltm_profile_http" "test-http" {

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

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)