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

Add Firebase AndroidApp Data Source #6903

Merged
merged 8 commits into from
Dec 6, 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
2 changes: 1 addition & 1 deletion mmv1/products/firebase/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -295,4 +295,4 @@ objects:
- !ruby/object:Api::Type::String
name: teamId
description: |
The Apple Developer Team ID associated with the App in the App Store.
The Apple Developer Team ID associated with the App in the App Store.
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 dataSourceGoogleFirebaseAndroidApp() *schema.Resource {
// Generate datasource schema from resource
dsSchema := datasourceSchemaFromResourceSchema(resourceFirebaseAndroidApp().Schema)

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

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

func dataSourceGoogleFirebaseAndroidAppRead(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/androidApps/%s", project, appId.(string))
d.SetId(name)
if err := d.Set("name", name); err != nil {
return fmt.Errorf("Error setting name: %s", err)
}
return resourceFirebaseAndroidAppRead(d, meta)
}
<% end -%>
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<% autogen_exception -%>
package google
<% unless version == 'ga' -%>
import (
"testing"

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

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

context := map[string]interface{}{
"project_id": getTestProjectFromEnv(),
"package_name": "android.package." + randString(t, 5),
"display_name": "Display Name AndroidApp DataSource",
}

resourceName := "data.google_firebase_android_app.my_app"

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

func testAccDataSourceGoogleFirebaseAndroidApp(context map[string]interface{}) string {
return Nprintf(`
resource "google_firebase_android_app" "my_app" {
project = "%{project_id}"
package_name ="%{package_name}"
display_name = "%{display_name}"
}

data "google_firebase_android_app" "my_app" {
app_id = google_firebase_android_app.my_app.app_id
}
`, context)
}
<% end -%>
3 changes: 2 additions & 1 deletion mmv1/third_party/terraform/utils/provider.go.erb
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,8 @@ func Provider() *schema.Provider {
"google_kms_secret": dataSourceGoogleKmsSecret(),
"google_kms_secret_ciphertext": dataSourceGoogleKmsSecretCiphertext(),
<% unless version == 'ga' -%>
"google_kms_secret_asymmetric": dataSourceGoogleKmsSecretAsymmetric(),
"google_kms_secret_asymmetric": dataSourceGoogleKmsSecretAsymmetric(),
"google_firebase_android_app": dataSourceGoogleFirebaseAndroidApp(),
"google_firebase_web_app": dataSourceGoogleFirebaseWebApp(),
"google_firebase_web_app_config": dataSourceGoogleFirebaseWebappConfig(),
<% end -%>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
subcategory: "Firebase"
page_title: "Google: google_firebase_android_app"
description: |-
A Google Cloud Firebase Android application instance
---

# google\_firebase\_android\_app

A Google Cloud Firebase Android 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_ip of name of the Firebase androidApp.


- - -


* `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/androidApps/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.

* `package_name` -
The canonical package name of the Android app as would appear in the Google Play Developer Console.