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

Adding default_pod_security_admission_configuration_template_name option #1144

Closed
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
1 change: 1 addition & 0 deletions docs/data-sources/cluster_v2.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,6 @@ The following attributes are exported:
* `rke_config` - (Computed) The RKE configuration for `k3s` and `rke2` Clusters v2. (list maxitems:1)
* `cloud_credential_secret_name` - (Computed) Cluster V2 cloud credential secret name (string)
* `default_pod_security_policy_template_name` - (Computed) Cluster V2 default pod security policy template name (string)
* `default_pod_security_admission_configuration_template_name` - (Computed) Cluster V2 default pod security admission configuration template name (string)
* `default_cluster_role_for_project_members` - (Computed) Cluster V2 default cluster role for project members (string)
* `enable_network_policy` - (Computed) Enable k8s network policy at Cluster V2 (bool)
1 change: 1 addition & 0 deletions docs/resources/cluster_v2.md
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,7 @@ The following arguments are supported:
* `local_auth_endpoint` - (Optional) Cluster V2 local auth endpoint (list maxitems:1)
* `cloud_credential_secret_name` - (Optional) Cluster V2 cloud credential secret name (string)
* `default_pod_security_policy_template_name` - (Optional) Cluster V2 default pod security policy template name (string)
* `default_pod_security_admission_configuration_template_name` - (Optional) Cluster V2 default pod security admission configuration template name (string)
* `default_cluster_role_for_project_members` - (Optional) Cluster V2 default cluster role for project members (string)
* `enable_network_policy` - (Optional) Enable k8s network policy at Cluster V2 (bool)
* `annotations` - (Optional/Computed) Annotations for the Cluster V2 (map)
Expand Down
5 changes: 5 additions & 0 deletions rancher2/data_source_rancher2_cluster_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ func dataSourceRancher2ClusterV2() *schema.Resource {
Computed: true,
Description: "Cluster V2 default pod security policy template name",
},
"default_pod_security_admission_configuration_template_name": {
Type: schema.TypeString,
Computed: true,
Description: "Cluster V2 default pod security admission configuration template name",
},
"default_cluster_role_for_project_members": {
Type: schema.TypeString,
Computed: true,
Expand Down
5 changes: 5 additions & 0 deletions rancher2/schema_cluster_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ func clusterV2Fields() map[string]*schema.Schema {
Optional: true,
Description: "Cluster V2 default pod security policy template name",
},
"default_pod_security_admission_configuration_template_name": {
Type: schema.TypeString,
Optional: true,
Description: "Cluster V2 default pod security admission configuration template name",
},
"default_cluster_role_for_project_members": {
Type: schema.TypeString,
Optional: true,
Expand Down
6 changes: 6 additions & 0 deletions rancher2/structure_cluster_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ func flattenClusterV2(d *schema.ResourceData, in *ClusterV2) error {
if len(in.Spec.DefaultPodSecurityPolicyTemplateName) > 0 {
d.Set("default_pod_security_policy_template_name", in.Spec.DefaultPodSecurityPolicyTemplateName)
}
if len(in.Spec.DefaultPodSecurityAdmissionConfigurationTemplateName) > 0 {
d.Set("default_pod_security_admission_configuration_template_name", in.Spec.DefaultPodSecurityAdmissionConfigurationTemplateName)
}
if len(in.Spec.DefaultClusterRoleForProjectMembers) > 0 {
d.Set("default_cluster_role_for_project_members", in.Spec.DefaultClusterRoleForProjectMembers)
}
Expand Down Expand Up @@ -142,6 +145,9 @@ func expandClusterV2(in *schema.ResourceData) (*ClusterV2, error) {
if v, ok := in.Get("default_pod_security_policy_template_name").(string); ok && len(v) > 0 {
obj.Spec.DefaultPodSecurityPolicyTemplateName = v
}
if v, ok := in.Get("default_pod_security_admission_configuration_template_name").(string); ok && len(v) > 0 {
obj.Spec.DefaultPodSecurityAdmissionConfigurationTemplateName = v
}
if v, ok := in.Get("default_cluster_role_for_project_members").(string); ok && len(v) > 0 {
obj.Spec.DefaultClusterRoleForProjectMembers = v
}
Expand Down
6 changes: 4 additions & 2 deletions rancher2/structure_cluster_v2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ func init() {
testClusterV2Conf.Spec.AgentEnvVars = testClusterV2EnvVarConf
testClusterV2Conf.Spec.CloudCredentialSecretName = "cloud_credential_secret_name"
testClusterV2Conf.Spec.DefaultPodSecurityPolicyTemplateName = "default_pod_security_policy_template_name"
testClusterV2Conf.Spec.DefaultPodSecurityAdmissionConfigurationTemplateName = "default_pod_security_admission_configuration_template_name"
testClusterV2Conf.Spec.DefaultClusterRoleForProjectMembers = "default_cluster_role_for_project_members"
testClusterV2Conf.Spec.EnableNetworkPolicy = newTrue()

Expand Down Expand Up @@ -162,8 +163,9 @@ func init() {
"fleet_agent_deployment_customization": testClusterV2AgentCustomizationInterface,
"cloud_credential_secret_name": "cloud_credential_secret_name",
"default_pod_security_policy_template_name": "default_pod_security_policy_template_name",
"default_cluster_role_for_project_members": "default_cluster_role_for_project_members",
"enable_network_policy": true,
"default_pod_security_admission_configuration_template_name": "default_pod_security_admission_configuration_template_name",
"default_cluster_role_for_project_members": "default_cluster_role_for_project_members",
"enable_network_policy": true,
"annotations": map[string]interface{}{
"value1": "one",
"value2": "two",
Expand Down