Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

suppress diff on website #6827

Merged
merged 3 commits into from
Nov 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -252,19 +252,26 @@ func resourceStorageBucket() *schema.Resource {
Type: schema.TypeList,
Optional: true,
MaxItems: 1,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"main_page_suffix": {
Type: schema.TypeString,
Optional: true,
AtLeastOneOf: []string{"website.0.not_found_page", "website.0.main_page_suffix"},
Description: `Behaves as the bucket's directory index where missing objects are treated as potential directories.`,
DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool {
return old != "" && new == ""
},
},
"not_found_page": {
Type: schema.TypeString,
Optional: true,
AtLeastOneOf: []string{"website.0.main_page_suffix", "website.0.not_found_page"},
Description: `The custom object to return when a requested resource is not found.`,
DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool {
return old != "" && new == ""
},
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1017,6 +1017,15 @@ func TestAccStorageBucket_website(t *testing.T) {
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"force_destroy"},
},
{
Config: testAccStorageBucket_websiteOneAttributeUpdate(bucketSuffix),
},
{
ResourceName: "google_storage_bucket.website",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"force_destroy"},
},
{
Config: testAccStorageBucket_website(bucketSuffix),
},
Expand All @@ -1026,6 +1035,15 @@ func TestAccStorageBucket_website(t *testing.T) {
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"force_destroy"},
},
{
Config: testAccStorageBucket_websiteRemoved(bucketSuffix),
},
{
ResourceName: "google_storage_bucket.website",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"force_destroy"},
},
},
})
}
Expand Down Expand Up @@ -1940,6 +1958,17 @@ resource "google_storage_bucket" "website" {
`, bucketName)
}

func testAccStorageBucket_websiteRemoved(bucketName string) string {
return fmt.Sprintf(`
resource "google_storage_bucket" "website" {
name = "%s.gcp.tfacc.hashicorptest.com"
location = "US"
storage_class = "STANDARD"
force_destroy = true
}
`, bucketName)
}

func testAccStorageBucket_websiteOneAttribute(bucketName string) string {
return fmt.Sprintf(`
resource "google_storage_bucket" "website" {
Expand All @@ -1955,6 +1984,21 @@ resource "google_storage_bucket" "website" {
`, bucketName)
}

func testAccStorageBucket_websiteOneAttributeUpdate(bucketName string) string {
return fmt.Sprintf(`
resource "google_storage_bucket" "website" {
name = "%s.gcp.tfacc.hashicorptest.com"
location = "US"
storage_class = "STANDARD"
force_destroy = true

website {
main_page_suffix = "default.html"
}
}
`, bucketName)
}

func testAccStorageBucket_forceDestroy(bucketName string) string {
return fmt.Sprintf(`
resource "google_storage_bucket" "bucket" {
Expand Down