-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Firebase AppleApp Data Source (#6876)
* 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
1 parent
65d3ecf
commit 7011e81
Showing
5 changed files
with
154 additions
and
1 deletion.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
mmv1/third_party/terraform/data_sources/data_source_google_firebase_apple_app.go.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 -%> |
58 changes: 58 additions & 0 deletions
58
mmv1/third_party/terraform/tests/data_source_google_firebase_apple_app_test.go.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 -%> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
mmv1/third_party/terraform/website/docs/d/firebase_apple_app.html.markdown
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |