-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Add policycontroller fields to fleet default configs for GKE Hub Feature resource #9426
Merged
Merged
Changes from 76 commits
Commits
Show all changes
79 commits
Select commit
Hold shift + click to select a range
85298f1
Adding Terraform resources for Tenancy APIs in GKEHub
sahsagar-google 05f9e1d
Merge branch 'GoogleCloudPlatform:main' into main
sahsagar-google d056843
Merge branch 'GoogleCloudPlatform:main' into main
sahsagar-google 20fea52
Segregating MembershipBinding and MembershipRBACRoleBinding to keep t…
sahsagar-google 672494c
Merge branch 'GoogleCloudPlatform:main' into main
sahsagar-google 3a4cefa
Merge branch 'GoogleCloudPlatform:main' into main
sahsagar-google 693aaff
Fixing the docu URIs
sahsagar-google 1d65988
Merge branch 'GoogleCloudPlatform:main' into main
sahsagar-google d783ddd
Merge branch 'GoogleCloudPlatform:main' into main
sahsagar-google bc96cbb
Adding TF support for Tenancy API for Membership Binding
sahsagar-google f74ce0f
Adding dependent membership binding to the same commit chain
sahsagar-google e0c2212
Making Scope un-updatable and replacing hard coded project number wit…
sahsagar-google c77f8b2
Merge branch 'GoogleCloudPlatform:main' into main
sahsagar-google 71c92e6
Making Scope RRBAC updatable
sahsagar-google 2403caa
Merge branch 'GoogleCloudPlatform:main' into main
sahsagar-google 308091c
Merge branch 'GoogleCloudPlatform:main' into main
sahsagar-google a0f99d5
Merge branch 'GoogleCloudPlatform:main' into main
sahsagar-google 78c9611
Merge branch 'GoogleCloudPlatform:main' into main
sahsagar-google 45ee3fc
Making Namespace immutable
sahsagar-google 4852207
Merge branch 'GoogleCloudPlatform:main' into main
sahsagar-google 79a8e93
Merge branch 'GoogleCloudPlatform:main' into main
sahsagar-google db46dd0
Adding update test cases
sahsagar-google 1cb54db
Merge branch 'GoogleCloudPlatform:main' into main
sahsagar-google f574890
Removing all memberships field from Scope since it is no longer suppo…
sahsagar-google 35ea32e
Merge branch 'GoogleCloudPlatform:main' into main
sahsagar-google dd80ce3
Removing all_memberships field for Scope from all test cases
sahsagar-google 371905f
Merge branch 'GoogleCloudPlatform:main' into main
sahsagar-google ad76f8b
Merge branch 'GoogleCloudPlatform:main' into main
sahsagar-google 3d51fc1
Merge branch 'GoogleCloudPlatform:main' into main
sahsagar-google 61ed74c
Merge branch 'GoogleCloudPlatform:main' into main
sahsagar-google 5dd7c9d
Merge branch 'GoogleCloudPlatform:main' into main
sahsagar-google db7d7d2
Merge branch 'GoogleCloudPlatform:main' into main
sahsagar-google b72eff4
Merge branch 'GoogleCloudPlatform:main' into main
sahsagar-google 0093110
Merge branch 'GoogleCloudPlatform:main' into main
sahsagar-google cdccf65
Merge branch 'GoogleCloudPlatform:main' into main
sahsagar-google 90c0545
Enabling Membership resource to be regionalized with global as defaul…
sahsagar-google d2b5993
Moving the test to be the first one in sequence to work-around the IA…
sahsagar-google 999f595
Update mmv1/products/gkehub/Membership.yaml
sahsagar-google 9e24547
Adding state migration for gke hub membership
sahsagar-google 3b9d9dc
Update mmv1/templates/terraform/examples/gkehub_membership_regional.t…
sahsagar-google e94f51f
Adding fleet_default_member_config field to the Feature resource
sahsagar-google a36b481
Merge branch 'GoogleCloudPlatform:main' into membership
sahsagar-google 9014730
Fixing the enum value in example
sahsagar-google 626419a
Fixing lint error
sahsagar-google bc13d70
Merge branch 'GoogleCloudPlatform:main' into membership
sahsagar-google ea694b3
Temporary removal of skipIfVcr test flag for the tests to run in PR
sahsagar-google f213fb4
Temporary removal of skipIfVcr test flag for the tests to run in PR
sahsagar-google 9025020
Removing unnecessary field spec from feature
sahsagar-google a0289a7
Changing feature id to servicemesh
sahsagar-google dcea2a9
Merge branch 'GoogleCloudPlatform:main' into membership
sahsagar-google 8dc46ff
Merge branch 'GoogleCloudPlatform:main' into membership
sahsagar-google 95afea4
Adding dependency of feature on servicemesh API
sahsagar-google fb631ba
Enabling mesh and gkehub APIs to be used in the tests
sahsagar-google d47e330
Temporary enabling services in the test project
sahsagar-google 9fe8cf2
Merge branch 'membership' of https://github.com/sahsagar-google/magic…
tonyzhc 6804f8b
Merge branch 'GoogleCloudPlatform:main' into membership
sahsagar-google f040865
Adding dependency of feature test on new project
sahsagar-google f28c92a
Add Policy Controller fleet default config and basic create test
tonyzhc df15015
Testing a few more newly-added fields
sahsagar-google 49e3c48
Depending on Terraform test project
sahsagar-google ee893a3
Fix compile errors and add service related tests.
tonyzhc 93a792b
Merge branch 'membership' of https://github.com/sahsagar-google/magic…
tonyzhc 5ba7420
Skipping if VCR
sahsagar-google f29e3e6
Depending on the newly created project for the tests
sahsagar-google 6908ae5
Adding service enablement for Anthos
sahsagar-google 8d88d0d
Merge branch 'GoogleCloudPlatform:main' into membership
sahsagar-google 97602e3
Fix incorrect test terraform code format and other incorrect feature …
tonyzhc 095d066
Add custom expand/flatten field handlers for objects of type map<stri…
tonyzhc 80ebf17
Add missing test back.
tonyzhc d0755d6
Merge branch 'membership' of https://github.com/sahsagar-google/magic…
tonyzhc 92e3d7d
Merge branch 'main' of https://github.com/GoogleCloudPlatform/magic-m…
tonyzhc f5d37f6
Fix format of example config.
tonyzhc e84e63e
Improve test coverage for monitoring field.
tonyzhc 6ccce5f
Save my work before trying out the Map type, as an Array of NestedObj…
tonyzhc dfb64cf
Fix default from API errors to prevent permadiff.
tonyzhc c9be31c
Restore test cases.
tonyzhc d7fb6e5
Add more examples.
tonyzhc 3797ef9
Delete unused custom_expand functions.
tonyzhc d0d7d82
Remove PoCo API beta dependency.
tonyzhc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
66 changes: 66 additions & 0 deletions
66
...plates/terraform/custom_expand/gkehub2_feature_policycontroller_deployment_configs.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,66 @@ | ||
func expand<%= prefix -%><%= titlelize_property(property) -%>(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { | ||
if v == nil { | ||
return nil, nil | ||
} | ||
|
||
m, ok := v.([]interface{}) | ||
if !ok { | ||
return nil, fmt.Errorf("unable to convert %v to []interface{}", v) | ||
} | ||
req := make(map[string]interface{}) | ||
for _, raw := range m { | ||
if raw == nil { | ||
continue | ||
} | ||
|
||
deploymentConfig := raw.(map[string]interface{}) | ||
log.Printf("WTF*** config is: %v\n", deploymentConfig) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Haha, just to make sure, is this abbrev. 'What the feature,' correct? |
||
componentName := deploymentConfig["component"].(string) | ||
delete(deploymentConfig, "component") | ||
|
||
if v, ok := deploymentConfig["pod_toleration"]; ok { | ||
deploymentConfig["pod_tolerations"] = v | ||
delete(deploymentConfig, "pod_toleration") | ||
} | ||
|
||
if v, ok := deploymentConfig["pod_affinity"]; ok { | ||
pa := v.(string) | ||
if pa == "" { | ||
delete(deploymentConfig, "pod_affinity") | ||
} | ||
} | ||
|
||
if v, ok := deploymentConfig["replica_count"]; ok { | ||
rc := v.(int) | ||
if rc == 0 { | ||
delete(deploymentConfig, "replica_count") | ||
} | ||
} | ||
|
||
// Somehow the container_resources field gets encoded unexpectedly into an array. Fix that. | ||
if v, ok := deploymentConfig["container_resources"]; ok { | ||
if arr, ok := v.([]interface{}); ok && len(arr) == 1 { | ||
actualCR := arr[0].(map[string]interface{}) | ||
if l, ok := actualCR["limits"]; ok { | ||
if lArr, ok := l.([]interface{}); ok && len(lArr) == 1 { | ||
actualLimits := lArr[0].(map[string]interface{}) | ||
actualCR["limits"] = actualLimits | ||
} | ||
} | ||
if r, ok := actualCR["requests"]; ok { | ||
if rArr, ok := r.([]interface{}); ok && len(rArr) == 1 { | ||
actualRequests := rArr[0].(map[string]interface{}) | ||
actualCR["requests"] = actualRequests | ||
} | ||
} | ||
deploymentConfig["container_resources"] = actualCR | ||
} else if ok && len(arr) == 0 { | ||
delete(deploymentConfig, "container_resources") | ||
} | ||
} | ||
|
||
req[componentName] = deploymentConfig | ||
} | ||
|
||
return req, nil | ||
} |
23 changes: 23 additions & 0 deletions
23
...es/terraform/custom_expand/gkehub2_feature_policycontroller_policy_content_bundles.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,23 @@ | ||
func expand<%= prefix -%><%= titlelize_property(property) -%>(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { | ||
if v == nil { | ||
return nil, nil | ||
} | ||
|
||
m, ok := v.([]interface{}) | ||
if !ok { | ||
return nil, fmt.Errorf("unable to convert %v to []interface{}", v) | ||
} | ||
req := make(map[string]interface{}) | ||
for _, raw := range m { | ||
if raw == nil { | ||
continue | ||
} | ||
|
||
bundleObj := raw.(map[string]interface{}) | ||
bundleName := bundleObj["name"].(string) | ||
delete(bundleObj, "name") | ||
req[bundleName] = bundleObj | ||
} | ||
|
||
return req, nil | ||
} |
23 changes: 23 additions & 0 deletions
23
mmv1/templates/terraform/examples/enable_fleet_default_member_config_policycontroller.tf.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,23 @@ | ||
resource "google_gke_hub_feature" "feature" { | ||
name = "policycontroller" | ||
location = "global" | ||
fleet_default_member_config { | ||
policycontroller { | ||
policy_controller_hub_config { | ||
install_spec = "INSTALL_SPEC_ENABLED" | ||
exemptable_namespaces = ["foo"] | ||
policy_content { | ||
bundle { | ||
name = "policy-essentials-v2022" | ||
exempted_namespaces = ["foo", "bar"] | ||
} | ||
template_library { | ||
installation = "ALL" | ||
} | ||
} | ||
audit_interval_seconds = 30 | ||
referential_rules_enabled = true | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tonyzhc Hi, what's the main reason for skipping these? Were you able to test locally?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test and the API dependencies don't work well with VCR tests. We instead covered them in the custom acceptance tests and added the skip VCR options. I have added more examples to serve the documentation purpose.