-
Notifications
You must be signed in to change notification settings - Fork 264
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
Signed-off-by: Modular Magician <magic-modules@google.com>
- Loading branch information
1 parent
2fda8ed
commit 803c4bc
Showing
108 changed files
with
40,802 additions
and
1,718 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,3 @@ | ||
```release-note:enhancement | ||
billing: Added `calendar_period` and `custom_period` fields to `google_billing_budget` | ||
``` |
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,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), | ||
} | ||
) |
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,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...) | ||
} |
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,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 | ||
} |
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,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" | ||
} |
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,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 | ||
} |
Oops, something went wrong.