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

ApigeeInstance add ipRange field #10928

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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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