Skip to content

Commit

Permalink
Add Firebase AppleApp Data Source (#6876)
Browse files Browse the repository at this point in the history
* Update api.yaml

* Update api.yaml

* Update api.yaml

* Update api.yaml

* Update terraform.yaml

* Create firebase_apple_app_basic.tf.erb

* Responding to tylerg-dev's comments

* Fixing the failing TestAccFirebaseAppleApp_firebaseAppleAppBasicExample test

* Add a handwritten sweeper to hard-delete the AppleApp

* Fix typo in update_mask

* Fix var name in test

* Add delete request body

* Change appId to app_id in the sweeper delete url

* Use custom_delete for deleting the AppleApp resource

* Update api.yaml

* Remove the repeated block in terraform.api

* Add a 5 sec in the post_delete template

* Move the 5 sec delay to the custom delete code

* Add "Optional" to the deletion_policy description.

* Address melinath@ comments

* Add a manual update test

* Remove unnecessary randomness. Also, move attributes to the vars section so they show up in docs.

* Update mmv1/products/firebase/terraform.yaml

Co-authored-by: Stephen Lewis (Burrows) <stephen.r.burrows@gmail.com>

* Update mmv1/products/firebase/terraform.yaml

Co-authored-by: Stephen Lewis (Burrows) <stephen.r.burrows@gmail.com>

* Update mmv1/products/firebase/terraform.yaml

Co-authored-by: Stephen Lewis (Burrows) <stephen.r.burrows@gmail.com>

* Update mmv1/third_party/terraform/tests/resource_firebase_apple_app_update_test.go.erb

Co-authored-by: Stephen Lewis (Burrows) <stephen.r.burrows@gmail.com>

* Update mmv1/third_party/terraform/tests/resource_firebase_apple_app_update_test.go.erb

Co-authored-by: Stephen Lewis (Burrows) <stephen.r.burrows@gmail.com>

* Update mmv1/third_party/terraform/tests/resource_firebase_apple_app_update_test.go.erb

Co-authored-by: Stephen Lewis (Burrows) <stephen.r.burrows@gmail.com>

* Adding back the test_vars_overrides.

* Add a Datasource for Firebase AppleApp

* Fix lint warnings

* Add documentations and fix the test

* Update the test providers.

* Remove the providers from the AppleApp datasource tests

* Add GA tags to the data source test and rename it to .go.erb

* Fix tabs in Datasource map.

* Add randomness to bundle_id to avoid collision.

* Responding to roaks3's comments

* Remove ws from data_source_google_firebase_web_app.go.erb

* Remove unneeded whitespaces from provider.go.erb

Co-authored-by: Stephen Lewis (Burrows) <stephen.r.burrows@gmail.com>
  • Loading branch information
mraouffouad and melinath authored Dec 14, 2022
1 parent 65d3ecf commit 7011e81
Show file tree
Hide file tree
Showing 5 changed files with 154 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<% autogen_exception -%>
package google
<% unless version == 'ga' -%>
import (
"fmt"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

func dataSourceGoogleFirebaseAppleApp() *schema.Resource {
// Generate datasource schema from resource
dsSchema := datasourceSchemaFromResourceSchema(resourceFirebaseAppleApp().Schema)

// Set 'Required' schema elements
addRequiredFieldsToSchema(dsSchema, "app_id")

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

func dataSourceGoogleFirebaseAppleAppRead(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)
appId := d.Get("app_id")
project, err := getProject(d, config)
if err != nil {
return err
}
name := fmt.Sprintf("projects/%s/iosApps/%s", project, appId.(string))
d.SetId(name)
if err := d.Set("name", name); err != nil {
return fmt.Errorf("Error setting name: %s", err)
}
return resourceFirebaseAppleAppRead(d, meta)
}
<% end -%>
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<% autogen_exception -%>
package google
<% unless version == 'ga' -%>
import (
"testing"

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

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

context := map[string]interface{}{
"project_id": getTestProjectFromEnv(),
"bundle_id": "apple.app." + randString(t, 5),
"display_name": "Display Name AppleApp DataSource",
"app_store_id": 12345,
"team_id": 1234567890,
}

resourceName := "data.google_firebase_apple_app.my_app"

vcrTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccDataSourceGoogleFirebaseAppleApp(context),
Check: resource.ComposeTestCheckFunc(
checkDataSourceStateMatchesResourceStateWithIgnores(
resourceName,
"google_firebase_apple_app.my_app",
map[string]struct{}{
"deletion_policy": {},
},
),
),
},
},
})
}

func testAccDataSourceGoogleFirebaseAppleApp(context map[string]interface{}) string {
return Nprintf(`
resource "google_firebase_apple_app" "my_app" {
project = "%{project_id}"
bundle_id = "%{bundle_id}"
display_name = "%{display_name}"
app_store_id = "%{app_store_id}"
team_id = "%{team_id}"
}

data "google_firebase_apple_app" "my_app" {
app_id = google_firebase_apple_app.my_app.app_id
}
`, context)
}
<% end -%>
1 change: 1 addition & 0 deletions mmv1/third_party/terraform/utils/provider.go.erb
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ func Provider() *schema.Provider {
<% unless version == 'ga' -%>
"google_kms_secret_asymmetric": dataSourceGoogleKmsSecretAsymmetric(),
"google_firebase_android_app": dataSourceGoogleFirebaseAndroidApp(),
"google_firebase_apple_app": dataSourceGoogleFirebaseAppleApp(),
"google_firebase_web_app": dataSourceGoogleFirebaseWebApp(),
"google_firebase_web_app_config": dataSourceGoogleFirebaseWebappConfig(),
<% end -%>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ The following arguments are supported:

* `app_id` -
(Required)
The app_ip of name of the Firebase androidApp.
The app_id of name of the Firebase androidApp.


- - -
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---
subcategory: "Firebase"
page_title: "Google: google_firebase_apple_app"
description: |-
A Google Cloud Firebase Apple application instance
---

# google\_firebase\_apple\_app

A Google Cloud Firebase Apple application instance

~> **Warning:** This resource is in beta, and should be used with the terraform-provider-google-beta provider.
See [Provider Versions](https://terraform.io/docs/providers/google/guides/provider_versions.html) for more details on beta resources.


## Argument Reference

The following arguments are supported:


* `app_id` -
(Required)
The app_id of name of the Firebase iosApp.


- - -


* `project` - (Optional) The ID of the project in which the resource belongs.
If it is not provided, the provider project is used.


## Attributes Reference

In addition to the arguments listed above, the following computed attributes are exported:

* `id` - an identifier for the resource with format `{{name}}`

* `name` -
The fully qualified resource name of the App, for example:
projects/projectId/iosApps/appId

* `app_id` -
Immutable. The globally unique, Firebase-assigned identifier of the App.
This identifier should be treated as an opaque token, as the data format is not specified.

* `display_name` -
The user-assigned display name of the App.

* `bundle_id` -
The canonical bundle ID of the Apple app as it would appear in the Apple AppStore.

* `app_store_id` -
The automatically generated Apple ID assigned to the Apple app by Apple in the Apple App Store.

* `team_id` -
The Apple Developer Team ID associated with the App in the App Store.

0 comments on commit 7011e81

Please sign in to comment.