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

Data source addition for Backupdr Beta #8854

Merged
merged 34 commits into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
47ed128
Add Backupdr with Management Server resource
niharika-98 Aug 10, 2023
72b0a4f
Merge pull request #2 from niharika-98/backupdr-ms
niharika-98 Aug 10, 2023
cab6956
Fixing lint issue
niharika-98 Aug 10, 2023
210fc35
Merge pull request #4 from niharika-98/backupdr-ms
niharika-98 Aug 10, 2023
e20740e
Fixing Variable name
niharika-98 Aug 10, 2023
f528716
Merge pull request #5 from niharika-98/backupdr-ms
niharika-98 Aug 10, 2023
14caf7e
FIxing values of type and peering mode
niharika-98 Aug 11, 2023
4d24393
Merge pull request #6 from niharika-98/backupdr-ms
niharika-98 Aug 11, 2023
296b0c3
Fixing description and example
niharika-98 Aug 11, 2023
c67f382
Merge pull request #7 from niharika-98/backupdr-ms
niharika-98 Aug 11, 2023
bb62751
Adding type and Peering_mode to coverage
niharika-98 Aug 11, 2023
3079e15
Merge pull request #8 from niharika-98/backupdr-ms
niharika-98 Aug 11, 2023
82aa62e
Changing release version of provider to only beta
niharika-98 Aug 11, 2023
8a81d75
Merge pull request #9 from niharika-98/backupdr-ms
niharika-98 Aug 11, 2023
210dd98
Changing variable name
niharika-98 Aug 11, 2023
08d8ce8
Merge pull request #10 from niharika-98/backupdr-ms
niharika-98 Aug 11, 2023
f613d57
Fixing Acceptance test and trademark
niharika-98 Aug 11, 2023
9714b8b
Merge pull request #11 from niharika-98/backupdr-ms
niharika-98 Aug 11, 2023
82453bd
datasource changes
niharika-98 Aug 29, 2023
ceda8b2
Merge pull request #12 from niharika-98/budr-tf-provider
niharika-98 Sep 4, 2023
17e313f
Merge branch 'GoogleCloudPlatform:main' into main
niharika-98 Sep 4, 2023
1994a12
Making additional changes
niharika-98 Sep 11, 2023
68b5fe9
Fix data source and acceptance tests
niharika-98 Sep 12, 2023
6a6a941
Merging conditions for data source changes
niharika-98 Sep 12, 2023
6960767
Removing additional resources in examples
niharika-98 Sep 13, 2023
ed65a6f
Fixing data source review comments
niharika-98 Oct 9, 2023
9b70113
Added changes for backupdr management server
niharika-98 Oct 9, 2023
55d3d05
Merge pull request #13 from GoogleCloudPlatform/main
niharika-98 Oct 16, 2023
a55a814
Update mmv1/third_party/terraform/services/backupdr/data_source_backu…
niharika-98 Oct 24, 2023
c723b42
Update mmv1/third_party/terraform/provider/provider.go.erb
niharika-98 Nov 1, 2023
dd1e92a
Added comments as per review comment
niharika-98 Nov 1, 2023
9de6310
Update data_source_backup_dr_management_server.go.erb
niharika-98 Nov 1, 2023
32950f7
Update mmv1/third_party/terraform/services/backupdr/data_source_backu…
shuyama1 Nov 1, 2023
79513bd
Update mmv1/third_party/terraform/services/backupdr/data_source_backu…
shuyama1 Nov 1, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package backupdr

import (
"fmt"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-provider-google/google/tpgresource"
transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport"
)

func dataSourceGoogleCloudBackupDRService() *schema.Resource {

dsSchema := tpgresource.DatasourceSchemaFromResourceSchema(ResourceBackupDRManagementServer().Schema)
tpgresource.AddRequiredFieldsToSchema(dsSchema, "name", "location", "network")
niharika-98 marked this conversation as resolved.
Show resolved Hide resolved
tpgresource.AddOptionalFieldsToSchema(dsSchema, "project")

return &schema.Resource{
Read: dataSourceGoogleCloudBackupDRServiceRead,
Schema: dsSchema,
}
}

func dataSourceGoogleCloudBackupDRServiceRead(d *schema.ResourceData, meta interface{}) error {
config := meta.(*transport_tpg.Config)

id, err := tpgresource.ReplaceVars(d, config, "projects/{{project}}/locations/{{location}}/managementServers/{{name}}")
if err != nil {
return fmt.Errorf("Error constructing id: %s", err)
}
d.SetId(id)
return resourceBackupDRManagementServerRead(d, meta)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package google
niharika-98 marked this conversation as resolved.
Show resolved Hide resolved

import (
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-provider-google/google/acctest"
)

func TestAccDataSourceGoogleBackupDRManagementServer_basic(t *testing.T) {
t.Parallel()

context := map[string]interface{}{
"random_suffix": acctest.RandString(t, 10),
}

acctest.VcrTest(t, resource.TestCase{
PreCheck: func() { acctest.AccTestPreCheck(t) },
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
Steps: []resource.TestStep{
{
Config: testAccDataSourceGoogleBackupDRManagementServer_basic(context),
Check: resource.ComposeTestCheckFunc(
acctest.CheckDataSourceStateMatchesResourceState("data.google_cloud_backup_dr_management_server.foo", "google_cloud_backup_dr_management_server.foo"),
),
},
},
})
}


func testAccDataSourceGoogleBackupDRManagementServer_basic(context map[string]interface{}) string {
return acctest.Nprintf(`
resource "google_compute_network" "default" {
provider = google-beta
name = "vpc-network"
}

resource "google_compute_global_address" "private_ip_address" {
provider = google-beta
name = "vpc-network"
address_type = "INTERNAL"
purpose = "VPC_PEERING"
prefix_length = 20
network = google_compute_network.default.id
}

resource "google_service_networking_connection" "default" {
niharika-98 marked this conversation as resolved.
Show resolved Hide resolved
provider = google-beta
network = google_compute_network.default.id
service = "servicenetworking.googleapis.com"
reserved_peering_ranges = [google_compute_global_address.private_ip_address.name]
}

resource "google_backup_dr_management_server" "foo" {
provider = google-beta
location = "us-central1"
name = "management_server"
type = "BACKUP_RESTORE"
networks {
network = google_compute_network.default.id
peering_mode = "PRIVATE_SERVICE_ACCESS"
}
depends_on = [ google_service_networking_connection.default ]
}
niharika-98 marked this conversation as resolved.
Show resolved Hide resolved

data "ggoogle_backup_dr_management_server" "foo" {
location = google_backup_dr_management_server.foo.location
}
`, context)
}
Loading