Skip to content

Commit

Permalink
ApigeeInstance add ipRange field (#5607) (#10928)
Browse files Browse the repository at this point in the history
* Add support IAM policy for the Environment of Apigee X

* Add support IAM policy for the Environment of Apigee X

* Add support IAM policy for the Environment of Apigee X

* Add support IAM policy for the Environment of Apigee X

* Revert all changes to test files.

* Revert all changes to test files.

* Revert all changes to test files.

* Add primary_resource_name to fix tests.

* Update iam_attributes.tf.erb to honor skip_test.

* Don't reject skip_tests when example is nil.

* Update mmv1/products/apigee/api.yaml

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

* Fix primary_resource_name for apigee organization name.

* Add a new field "ipRange".

Co-authored-by: Stephen Lewis (Burrows) <stephen.r.burrows@gmail.com>
Signed-off-by: Modular Magician <magic-modules@google.com>

Co-authored-by: Stephen Lewis (Burrows) <stephen.r.burrows@gmail.com>
  • Loading branch information
modular-magician and melinath authored Jan 18, 2022
1 parent 968ee03 commit ed35c1c
Show file tree
Hide file tree
Showing 73 changed files with 28,672 additions and 1,354 deletions.
3 changes: 3 additions & 0 deletions .changelog/5607.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
apigee: added ip_range field to `google_apigee_instance`
```
20 changes: 20 additions & 0 deletions google/dcl.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package google

import (
dcl "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl"
)

var (
// CreateDirective restricts Apply to creating resources for Create
CreateDirective = []dcl.ApplyOption{
dcl.WithLifecycleParam(dcl.BlockAcquire),
dcl.WithLifecycleParam(dcl.BlockDestruction),
dcl.WithLifecycleParam(dcl.BlockModification),
}

// UpdateDirective restricts Apply to modifying resources for Update
UpdateDirective = []dcl.ApplyOption{
dcl.WithLifecycleParam(dcl.BlockCreation),
dcl.WithLifecycleParam(dcl.BlockDestruction),
}
)
38 changes: 38 additions & 0 deletions google/dcl_logger.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package google

import (
"fmt"
"log"
)

type dclLogger struct{}

// Fatal records Fatal errors.
func (l dclLogger) Fatal(args ...interface{}) {
log.Fatal(args...)
}

// Fatalf records Fatal errors with added arguments.
func (l dclLogger) Fatalf(format string, args ...interface{}) {
log.Fatalf(fmt.Sprintf("[DEBUG][DCL FATAL] %s", format), args...)
}

// Info records Info errors.
func (l dclLogger) Info(args ...interface{}) {
log.Print(args...)
}

// Infof records Info errors with added arguments.
func (l dclLogger) Infof(format string, args ...interface{}) {
log.Printf(fmt.Sprintf("[DEBUG][DCL INFO] %s", format), args...)
}

// Warningf records Warning errors with added arguments.
func (l dclLogger) Warningf(format string, args ...interface{}) {
log.Printf(fmt.Sprintf("[DEBUG][DCL WARNING] %s", format), args...)
}

// Warning records Warning errors.
func (l dclLogger) Warning(args ...interface{}) {
log.Print(args...)
}
65 changes: 65 additions & 0 deletions google/expanders.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package google

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

func expandStringArray(v interface{}) []string {
arr, ok := v.([]string)

if ok {
return arr
}

if arr, ok := v.(*schema.Set); ok {
return convertStringSet(arr)
}

arr = convertStringArr(v.([]interface{}))
if arr == nil {
// Send empty array specifically instead of nil
return make([]string, 0)
}
return arr
}

func expandIntegerArray(v interface{}) []int64 {
arr, ok := v.([]int64)

if ok {
return arr
}

if arr, ok := v.(*schema.Set); ok {
return convertIntegerSet(arr)
}

return convertIntegerArr(v.([]interface{}))
}

func convertIntegerSet(v *schema.Set) []int64 {
return convertIntegerArr(v.List())
}

func convertIntegerArr(v []interface{}) []int64 {
var vi []int64
for _, vs := range v {
vi = append(vi, int64(vs.(int)))
}
return vi
}

// Returns the DCL representation of a three-state boolean value represented by a string in terraform.
func expandEnumBool(v interface{}) *bool {
s, ok := v.(string)
if !ok {
return nil
}
switch s {
case "TRUE":
b := true
return &b
case "FALSE":
b := false
return &b
}
return nil
}
13 changes: 13 additions & 0 deletions google/flatteners.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package google

// Returns the terraform representation of a three-state boolean value represented by a pointer to bool in DCL.
func flattenEnumBool(v interface{}) string {
b, ok := v.(*bool)
if !ok || b == nil {
return ""
}
if *b {
return "TRUE"
}
return "FALSE"
}
28 changes: 28 additions & 0 deletions google/orgpolicy_utils.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package google

import (
"fmt"

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

// OrgPolicyPolicy has a custom import method because the parent field needs to allow an additional forward slash
// to represent the type of parent (e.g. projects/{project_id}).
func resourceOrgPolicyPolicyCustomImport(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)
if err := parseImportId([]string{
"^(?P<parent>[^/]+/?[^/]*)/policies/(?P<name>[^/]+)",
"^(?P<parent>[^/]+/?[^/]*)/(?P<name>[^/]+)",
}, d, config); err != nil {
return err
}

// Replace import id for the resource id
id, err := replaceVarsRecursive(d, config, "{{parent}}/policies/{{name}}", false, 0)
if err != nil {
return fmt.Errorf("Error constructing id: %s", err)
}
d.SetId(id)

return nil
}
Loading

0 comments on commit ed35c1c

Please sign in to comment.