-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Support v1 Game Servers. * Update resource id regexes Signed-off-by: Modular Magician <magic-modules@google.com>
- Loading branch information
1 parent
75c7fc4
commit 37592d8
Showing
28 changed files
with
4,479 additions
and
69 deletions.
There are no files selected for viewing
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,7 @@ | ||
```release-note:new-resource | ||
`gameservices: Added new resource `google_game_services_realm` | ||
`gameservices: Added new resource `google_game_services_game_server_cluster` | ||
`gameservices: Added new resource `google_game_services_game_server_config` | ||
`gameservices: Added new resource `google_game_services_game_server_deployment` | ||
`gameservices: Added new resource `google_game_services_game_server_deployment_rollout` | ||
``` |
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
30 changes: 30 additions & 0 deletions
30
google/data_google_game_services_game_server_deployment_rollout.go
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 |
---|---|---|
@@ -1 +1,31 @@ | ||
package google | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/helper/schema" | ||
) | ||
|
||
func dataSourceGameServicesGameServerDeploymentRollout() *schema.Resource { | ||
|
||
dsSchema := datasourceSchemaFromResourceSchema(resourceGameServicesGameServerDeploymentRollout().Schema) | ||
addRequiredFieldsToSchema(dsSchema, "deployment_id") | ||
|
||
return &schema.Resource{ | ||
Read: dataSourceGameServicesGameServerDeploymentRolloutRead, | ||
Schema: dsSchema, | ||
} | ||
} | ||
|
||
func dataSourceGameServicesGameServerDeploymentRolloutRead(d *schema.ResourceData, meta interface{}) error { | ||
config := meta.(*Config) | ||
|
||
id, err := replaceVars(d, config, "projects/{{project}}/locations/global/gameServerDeployments/{{deployment_id}}/rollout") | ||
if err != nil { | ||
return fmt.Errorf("Error constructing id: %s", err) | ||
} | ||
d.SetId(id) | ||
|
||
return resourceGameServicesGameServerDeploymentRolloutRead(d, meta) | ||
|
||
} |
60 changes: 60 additions & 0 deletions
60
google/data_google_game_services_game_server_deployment_rollout_test.go
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 |
---|---|---|
@@ -1 +1,61 @@ | ||
package google | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/helper/resource" | ||
) | ||
|
||
func TestAccDataSourceGameServicesGameServerDeploymentRollout_basic(t *testing.T) { | ||
t.Parallel() | ||
|
||
context := map[string]interface{}{ | ||
"random_suffix": randString(t, 10), | ||
} | ||
|
||
vcrTest(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
CheckDestroy: testAccCheckGameServicesGameServerDeploymentRolloutDestroyProducer(t), | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccDataSourceGameServicesGameServerDeploymentRollout_basic(context), | ||
Check: resource.ComposeTestCheckFunc( | ||
checkDataSourceStateMatchesResourceState("data.google_game_services_game_server_deployment_rollout.qa", "google_game_services_game_server_deployment_rollout.foo"), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccDataSourceGameServicesGameServerDeploymentRollout_basic(context map[string]interface{}) string { | ||
return Nprintf(` | ||
resource "google_game_services_game_server_deployment" "default" { | ||
deployment_id = "tf-test-deployment-%{random_suffix}" | ||
description = "a deployment description" | ||
} | ||
resource "google_game_services_game_server_config" "default" { | ||
config_id = "tf-test-config-%{random_suffix}" | ||
deployment_id = google_game_services_game_server_deployment.default.deployment_id | ||
description = "a config description" | ||
fleet_configs { | ||
name = "some-non-guid" | ||
fleet_spec = jsonencode({ "replicas" : 1, "scheduling" : "Packed", "template" : { "metadata" : { "name" : "tf-test-game-server-template" }, "spec" : { "template" : { "spec" : { "containers" : [{ "name" : "simple-udp-server", "image" : "gcr.io/agones-images/udp-server:0.14" }] } } } } }) | ||
// Alternate usage: | ||
// fleet_spec = file(fleet_configs.json) | ||
} | ||
} | ||
resource "google_game_services_game_server_deployment_rollout" "foo" { | ||
deployment_id = google_game_services_game_server_deployment.default.deployment_id | ||
default_game_server_config = google_game_services_game_server_config.default.name | ||
} | ||
data "google_game_services_game_server_deployment_rollout" "qa" { | ||
deployment_id = google_game_services_game_server_deployment_rollout.foo.deployment_id | ||
} | ||
`, context) | ||
} |
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,72 @@ | ||
// ---------------------------------------------------------------------------- | ||
// | ||
// *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** | ||
// | ||
// ---------------------------------------------------------------------------- | ||
// | ||
// This file is automatically generated by Magic Modules and manual | ||
// changes will be clobbered when the file is regenerated. | ||
// | ||
// Please read more about how to change this file in | ||
// .github/CONTRIBUTING.md. | ||
// | ||
// ---------------------------------------------------------------------------- | ||
package google | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
"time" | ||
) | ||
|
||
type GameServicesOperationWaiter struct { | ||
Config *Config | ||
Project string | ||
CommonOperationWaiter | ||
} | ||
|
||
func (w *GameServicesOperationWaiter) QueryOp() (interface{}, error) { | ||
if w == nil { | ||
return nil, fmt.Errorf("Cannot query operation, it's unset or nil.") | ||
} | ||
// Returns the proper get. | ||
url := fmt.Sprintf("https://gameservices.googleapis.com/v1/%s", w.CommonOperationWaiter.Op.Name) | ||
return sendRequest(w.Config, "GET", w.Project, url, nil) | ||
} | ||
|
||
func createGameServicesWaiter(config *Config, op map[string]interface{}, project, activity string) (*GameServicesOperationWaiter, error) { | ||
if val, ok := op["name"]; !ok || val == "" { | ||
// This was a synchronous call - there is no operation to wait for. | ||
return nil, nil | ||
} | ||
w := &GameServicesOperationWaiter{ | ||
Config: config, | ||
Project: project, | ||
} | ||
if err := w.CommonOperationWaiter.SetOp(op); err != nil { | ||
return nil, err | ||
} | ||
return w, nil | ||
} | ||
|
||
// nolint: deadcode,unused | ||
func gameServicesOperationWaitTimeWithResponse(config *Config, op map[string]interface{}, response *map[string]interface{}, project, activity string, timeout time.Duration) error { | ||
w, err := createGameServicesWaiter(config, op, project, activity) | ||
if err != nil || w == nil { | ||
// If w is nil, the op was synchronous. | ||
return err | ||
} | ||
if err := OperationWait(w, activity, timeout, config.PollInterval); err != nil { | ||
return err | ||
} | ||
return json.Unmarshal([]byte(w.CommonOperationWaiter.Op.Response), response) | ||
} | ||
|
||
func gameServicesOperationWaitTime(config *Config, op map[string]interface{}, project, activity string, timeout time.Duration) error { | ||
w, err := createGameServicesWaiter(config, op, project, activity) | ||
if err != nil || w == nil { | ||
// If w is nil, the op was synchronous. | ||
return err | ||
} | ||
return OperationWait(w, activity, timeout, config.PollInterval) | ||
} |
Oops, something went wrong.