From f7e2ae926ea47d8fe439c5e5e2bf03c1882759da Mon Sep 17 00:00:00 2001 From: Sakala Venkata Krishna Rohit Date: Thu, 18 Jul 2024 10:51:30 -0700 Subject: [PATCH] Remove monitoring alerting notifier v1 from rancher2 terraform provider (#1372) Signed-off-by: Venkata Krishna Rohit Sakala Co-authored-by: Diogo --- docs/data-sources/cluster.md | 3 - docs/data-sources/cluster_alert_group.md | 32 - docs/data-sources/cluster_alert_rule.md | 37 - docs/data-sources/cluster_v2.md | 1 - docs/data-sources/notifier.md | 36 - .../pod_security_policy_template.md | 53 -- docs/data-sources/project.md | 2 - docs/data-sources/project_alert_group.md | 32 - docs/data-sources/project_alert_rule.md | 36 - docs/resources/cluster.md | 72 +- docs/resources/cluster_alert_group.md | 72 -- docs/resources/cluster_alert_rule.md | 106 --- docs/resources/cluster_sync.md | 2 - docs/resources/cluster_template.md | 3 - docs/resources/cluster_v2.md | 1 - docs/resources/notifier.md | 127 --- .../resources/pod_security_policy_template.md | 235 ------ docs/resources/project.md | 35 +- docs/resources/project_alert_group.md | 71 -- docs/resources/project_alert_rule.md | 123 --- go.mod | 175 ++-- go.sum | 285 +++---- rancher2/0_provider_upgrade_test.go | 46 - rancher2/config.go | 50 -- rancher2/data_source_rancher2_cluster.go | 24 - ...ata_source_rancher2_cluster_alert_group.go | 93 -- ...ource_rancher2_cluster_alert_group_test.go | 31 - ...data_source_rancher2_cluster_alert_rule.go | 131 --- ...source_rancher2_cluster_alert_rule_test.go | 31 - rancher2/data_source_rancher2_cluster_v2.go | 5 - rancher2/data_source_rancher2_notifier.go | 133 --- .../data_source_rancher2_notifier_test.go | 31 - ...e_rancher2_pod_security_policy_template.go | 28 - ...cher2_pod_security_policy_template_test.go | 29 - rancher2/data_source_rancher2_project.go | 11 - ...ata_source_rancher2_project_alert_group.go | 93 -- ...ource_rancher2_project_alert_group_test.go | 31 - ...data_source_rancher2_project_alert_rule.go | 122 --- ...source_rancher2_project_alert_rule_test.go | 31 - .../import_rancher2_cluster_alert_group.go | 14 - .../import_rancher2_cluster_alert_rule.go | 14 - rancher2/import_rancher2_notifier.go | 14 - ...t_rancher2_pod_security_policy_template.go | 14 - .../import_rancher2_project_alert_group.go | 14 - .../import_rancher2_project_alert_rule.go | 14 - rancher2/provider.go | 12 - rancher2/resource_rancher2_cluster.go | 165 +--- .../resource_rancher2_cluster_alert_group.go | 233 ----- ...ource_rancher2_cluster_alert_group_test.go | 203 ----- .../resource_rancher2_cluster_alert_rule.go | 212 ----- ...source_rancher2_cluster_alert_rule_test.go | 204 ----- rancher2/resource_rancher2_cluster_sync.go | 39 +- ...resource_rancher2_cluster_template_test.go | 6 - rancher2/resource_rancher2_notifier.go | 191 ----- rancher2/resource_rancher2_notifier_test.go | 799 ------------------ ...curity_admission_configuration_template.go | 10 +- ...e_rancher2_pod_security_policy_template.go | 155 ---- ...cher2_pod_security_policy_template_test.go | 275 ------ rancher2/resource_rancher2_project.go | 156 +--- .../resource_rancher2_project_alert_group.go | 234 ----- ...ource_rancher2_project_alert_group_test.go | 203 ----- .../resource_rancher2_project_alert_rule.go | 207 ----- ...source_rancher2_project_alert_rule_test.go | 203 ----- rancher2/schema_alert_group.go | 54 -- rancher2/schema_alert_rule.go | 282 ------- rancher2/schema_cluster.go | 65 +- rancher2/schema_cluster_alert_group.go | 23 - rancher2/schema_cluster_alert_rule.go | 63 -- ...ma_cluster_rke_config_services_kube_api.go | 15 - rancher2/schema_cluster_sync.go | 12 - rancher2/schema_cluster_template.go | 54 -- rancher2/schema_cluster_v2.go | 10 - rancher2/schema_monitoring_input.go | 24 - rancher2/schema_notifier.go | 103 --- rancher2/schema_notifier_dingtalk_config.go | 30 - rancher2/schema_notifier_msteams_config.go | 24 - rancher2/schema_notifier_pagerduty_config.go | 24 - rancher2/schema_notifier_slack_config.go | 29 - rancher2/schema_notifier_smtp_config.go | 51 -- rancher2/schema_notifier_webhook_config.go | 24 - rancher2/schema_notifier_wechat_config.go | 58 -- rancher2/schema_project.go | 19 - rancher2/schema_project_alert_group.go | 23 - rancher2/schema_project_alert_rule.go | 53 -- rancher2/schema_recipient.go | 45 - rancher2/structure_alert_rule.go | 295 ------- rancher2/structure_alert_rule_test.go | 330 -------- rancher2/structure_cluster.go | 25 +- rancher2/structure_cluster_alert_group.go | 77 -- .../structure_cluster_alert_group_test.go | 101 --- rancher2/structure_cluster_alert_rule.go | 130 --- rancher2/structure_cluster_alert_rule_test.go | 158 ---- ...re_cluster_rke_config_services_kube_api.go | 6 - ...uster_rke_config_services_kube_api_test.go | 2 - rancher2/structure_cluster_template.go | 18 - rancher2/structure_cluster_template_test.go | 20 +- rancher2/structure_cluster_test.go | 218 ++--- rancher2/structure_cluster_v2.go | 6 - rancher2/structure_cluster_v2_test.go | 20 +- rancher2/structure_monitoring_input.go | 53 -- rancher2/structure_monitoring_input_test.go | 64 -- rancher2/structure_notifier.go | 164 ---- .../structure_notifier_dingtalk_config.go | 56 -- ...structure_notifier_dingtalk_config_test.go | 63 -- rancher2/structure_notifier_msteams_config.go | 48 -- .../structure_notifier_msteams_config_test.go | 62 -- .../structure_notifier_pagerduty_config.go | 48 -- ...tructure_notifier_pagerduty_config_test.go | 62 -- rancher2/structure_notifier_slack_config.go | 50 -- .../structure_notifier_slack_config_test.go | 64 -- rancher2/structure_notifier_smtp_config.go | 68 -- .../structure_notifier_smtp_config_test.go | 72 -- rancher2/structure_notifier_webhook_config.go | 48 -- .../structure_notifier_webhook_config_test.go | 62 -- rancher2/structure_notifier_wechat_config.go | 61 -- .../structure_notifier_wechat_config_test.go | 70 -- rancher2/structure_notifier_z_test.go | 213 ----- ...pod_security_policy_allowed_csi_drivers.go | 47 -- ...ecurity_policy_allowed_csi_drivers_test.go | 74 -- ...od_security_policy_allowed_flex_volumes.go | 47 -- ...curity_policy_allowed_flex_volumes_test.go | 74 -- ..._pod_security_policy_allowed_host_paths.go | 54 -- ...security_policy_allowed_host_paths_test.go | 77 -- .../structure_pod_security_policy_fs_group.go | 48 -- ...cture_pod_security_policy_fs_group_test.go | 91 -- ...ure_pod_security_policy_host_port_range.go | 49 -- ...od_security_policy_host_port_range_test.go | 78 -- ...structure_pod_security_policy_id_ranges.go | 47 -- ...ture_pod_security_policy_id_ranges_test.go | 79 -- ...ucture_pod_security_policy_run_as_group.go | 48 -- ...e_pod_security_policy_run_as_group_test.go | 68 -- ...ructure_pod_security_policy_run_as_user.go | 48 -- ...re_pod_security_policy_run_as_user_test.go | 69 -- ..._security_policy_runtime_class_strategy.go | 48 -- ...rity_policy_runtime_class_strategy_test.go | 69 -- ...re_pod_security_policy_se_linux_options.go | 65 -- ...d_security_policy_se_linux_options_test.go | 72 -- ...e_pod_security_policy_se_linux_strategy.go | 48 -- ..._security_policy_se_linux_strategy_test.go | 69 -- ...pod_security_policy_supplemental_groups.go | 48 -- ...ecurity_policy_supplemental_groups_test.go | 69 -- .../structure_pod_security_policy_template.go | 229 ----- ...cture_pod_security_policy_template_test.go | 140 --- rancher2/structure_project.go | 18 +- rancher2/structure_project_alert_group.go | 77 -- .../structure_project_alert_group_test.go | 97 --- rancher2/structure_project_alert_rule.go | 114 --- rancher2/structure_project_alert_rule_test.go | 142 ---- rancher2/structure_project_test.go | 16 +- rancher2/structure_recipient.go | 52 -- rancher2/structure_recipient_test.go | 66 -- website/rancher2.erb | 30 - 152 files changed, 354 insertions(+), 11982 deletions(-) delete mode 100644 docs/data-sources/cluster_alert_group.md delete mode 100644 docs/data-sources/cluster_alert_rule.md delete mode 100644 docs/data-sources/notifier.md delete mode 100644 docs/data-sources/pod_security_policy_template.md delete mode 100644 docs/data-sources/project_alert_group.md delete mode 100644 docs/data-sources/project_alert_rule.md delete mode 100644 docs/resources/cluster_alert_group.md delete mode 100644 docs/resources/cluster_alert_rule.md delete mode 100644 docs/resources/notifier.md delete mode 100644 docs/resources/pod_security_policy_template.md delete mode 100644 docs/resources/project_alert_group.md delete mode 100644 docs/resources/project_alert_rule.md delete mode 100644 rancher2/data_source_rancher2_cluster_alert_group.go delete mode 100644 rancher2/data_source_rancher2_cluster_alert_group_test.go delete mode 100644 rancher2/data_source_rancher2_cluster_alert_rule.go delete mode 100644 rancher2/data_source_rancher2_cluster_alert_rule_test.go delete mode 100644 rancher2/data_source_rancher2_notifier.go delete mode 100644 rancher2/data_source_rancher2_notifier_test.go delete mode 100644 rancher2/data_source_rancher2_pod_security_policy_template.go delete mode 100644 rancher2/data_source_rancher2_pod_security_policy_template_test.go delete mode 100644 rancher2/data_source_rancher2_project_alert_group.go delete mode 100644 rancher2/data_source_rancher2_project_alert_group_test.go delete mode 100644 rancher2/data_source_rancher2_project_alert_rule.go delete mode 100644 rancher2/data_source_rancher2_project_alert_rule_test.go delete mode 100644 rancher2/import_rancher2_cluster_alert_group.go delete mode 100644 rancher2/import_rancher2_cluster_alert_rule.go delete mode 100644 rancher2/import_rancher2_notifier.go delete mode 100644 rancher2/import_rancher2_pod_security_policy_template.go delete mode 100644 rancher2/import_rancher2_project_alert_group.go delete mode 100644 rancher2/import_rancher2_project_alert_rule.go delete mode 100644 rancher2/resource_rancher2_cluster_alert_group.go delete mode 100644 rancher2/resource_rancher2_cluster_alert_group_test.go delete mode 100644 rancher2/resource_rancher2_cluster_alert_rule.go delete mode 100644 rancher2/resource_rancher2_cluster_alert_rule_test.go delete mode 100644 rancher2/resource_rancher2_notifier.go delete mode 100644 rancher2/resource_rancher2_notifier_test.go delete mode 100644 rancher2/resource_rancher2_pod_security_policy_template.go delete mode 100644 rancher2/resource_rancher2_pod_security_policy_template_test.go delete mode 100644 rancher2/resource_rancher2_project_alert_group.go delete mode 100644 rancher2/resource_rancher2_project_alert_group_test.go delete mode 100644 rancher2/resource_rancher2_project_alert_rule.go delete mode 100644 rancher2/resource_rancher2_project_alert_rule_test.go delete mode 100644 rancher2/schema_alert_group.go delete mode 100644 rancher2/schema_alert_rule.go delete mode 100644 rancher2/schema_cluster_alert_group.go delete mode 100644 rancher2/schema_cluster_alert_rule.go delete mode 100644 rancher2/schema_monitoring_input.go delete mode 100644 rancher2/schema_notifier.go delete mode 100644 rancher2/schema_notifier_dingtalk_config.go delete mode 100644 rancher2/schema_notifier_msteams_config.go delete mode 100644 rancher2/schema_notifier_pagerduty_config.go delete mode 100644 rancher2/schema_notifier_slack_config.go delete mode 100644 rancher2/schema_notifier_smtp_config.go delete mode 100644 rancher2/schema_notifier_webhook_config.go delete mode 100644 rancher2/schema_notifier_wechat_config.go delete mode 100644 rancher2/schema_project_alert_group.go delete mode 100644 rancher2/schema_project_alert_rule.go delete mode 100644 rancher2/schema_recipient.go delete mode 100644 rancher2/structure_alert_rule.go delete mode 100644 rancher2/structure_alert_rule_test.go delete mode 100644 rancher2/structure_cluster_alert_group.go delete mode 100644 rancher2/structure_cluster_alert_group_test.go delete mode 100644 rancher2/structure_cluster_alert_rule.go delete mode 100644 rancher2/structure_cluster_alert_rule_test.go delete mode 100644 rancher2/structure_monitoring_input.go delete mode 100644 rancher2/structure_monitoring_input_test.go delete mode 100644 rancher2/structure_notifier.go delete mode 100644 rancher2/structure_notifier_dingtalk_config.go delete mode 100644 rancher2/structure_notifier_dingtalk_config_test.go delete mode 100644 rancher2/structure_notifier_msteams_config.go delete mode 100644 rancher2/structure_notifier_msteams_config_test.go delete mode 100644 rancher2/structure_notifier_pagerduty_config.go delete mode 100644 rancher2/structure_notifier_pagerduty_config_test.go delete mode 100644 rancher2/structure_notifier_slack_config.go delete mode 100644 rancher2/structure_notifier_slack_config_test.go delete mode 100644 rancher2/structure_notifier_smtp_config.go delete mode 100644 rancher2/structure_notifier_smtp_config_test.go delete mode 100644 rancher2/structure_notifier_webhook_config.go delete mode 100644 rancher2/structure_notifier_webhook_config_test.go delete mode 100644 rancher2/structure_notifier_wechat_config.go delete mode 100644 rancher2/structure_notifier_wechat_config_test.go delete mode 100644 rancher2/structure_notifier_z_test.go delete mode 100644 rancher2/structure_pod_security_policy_allowed_csi_drivers.go delete mode 100644 rancher2/structure_pod_security_policy_allowed_csi_drivers_test.go delete mode 100644 rancher2/structure_pod_security_policy_allowed_flex_volumes.go delete mode 100644 rancher2/structure_pod_security_policy_allowed_flex_volumes_test.go delete mode 100644 rancher2/structure_pod_security_policy_allowed_host_paths.go delete mode 100644 rancher2/structure_pod_security_policy_allowed_host_paths_test.go delete mode 100644 rancher2/structure_pod_security_policy_fs_group.go delete mode 100644 rancher2/structure_pod_security_policy_fs_group_test.go delete mode 100644 rancher2/structure_pod_security_policy_host_port_range.go delete mode 100644 rancher2/structure_pod_security_policy_host_port_range_test.go delete mode 100644 rancher2/structure_pod_security_policy_id_ranges.go delete mode 100644 rancher2/structure_pod_security_policy_id_ranges_test.go delete mode 100644 rancher2/structure_pod_security_policy_run_as_group.go delete mode 100644 rancher2/structure_pod_security_policy_run_as_group_test.go delete mode 100644 rancher2/structure_pod_security_policy_run_as_user.go delete mode 100644 rancher2/structure_pod_security_policy_run_as_user_test.go delete mode 100644 rancher2/structure_pod_security_policy_runtime_class_strategy.go delete mode 100644 rancher2/structure_pod_security_policy_runtime_class_strategy_test.go delete mode 100644 rancher2/structure_pod_security_policy_se_linux_options.go delete mode 100644 rancher2/structure_pod_security_policy_se_linux_options_test.go delete mode 100644 rancher2/structure_pod_security_policy_se_linux_strategy.go delete mode 100644 rancher2/structure_pod_security_policy_se_linux_strategy_test.go delete mode 100644 rancher2/structure_pod_security_policy_supplemental_groups.go delete mode 100644 rancher2/structure_pod_security_policy_supplemental_groups_test.go delete mode 100644 rancher2/structure_pod_security_policy_template.go delete mode 100644 rancher2/structure_pod_security_policy_template_test.go delete mode 100644 rancher2/structure_project_alert_group.go delete mode 100644 rancher2/structure_project_alert_group_test.go delete mode 100644 rancher2/structure_project_alert_rule.go delete mode 100644 rancher2/structure_project_alert_rule_test.go delete mode 100644 rancher2/structure_recipient.go delete mode 100644 rancher2/structure_recipient_test.go diff --git a/docs/data-sources/cluster.md b/docs/data-sources/cluster.md index 1f339df0..ebb1dfc5 100644 --- a/docs/data-sources/cluster.md +++ b/docs/data-sources/cluster.md @@ -44,13 +44,10 @@ The following attributes are exported: * `oke_config` - (Computed) The Oracle OKE configuration for `oke` Clusters. Conflicts with `aks_config`, `aks_config_v2`, `eks_config`, `eks_config_v2`, `gke_config`, `gke_config_v2`, `k3s_config` and `rke_config` (list maxitems:1) * `description` - (Computed) The description for Cluster (string) * `cluster_auth_endpoint` - (Computed) Enabling the [local cluster authorized endpoint](https://rancher.com/docs/rancher/v2.x/en/cluster-provisioning/rke-clusters/options/#local-cluster-auth-endpoint) allows direct communication with the cluster, bypassing the Rancher API proxy. (list maxitems:1) -* `cluster_monitoring_input` - (Computed) Cluster monitoring config (list maxitems:1) * `cluster_template_answers` - (Computed) Cluster template answers (list maxitems:1) * `cluster_template_id` - (Computed) Cluster template ID (string) * `cluster_template_questions` - (Computed) Cluster template questions (list) * `cluster_template_revision_id` - (Computed) Cluster template revision ID (string) -* `default_pod_security_policy_template_id` - (Optional/Computed) [Default pod security policy template id](https://rancher.com/docs/rancher/v2.x/en/cluster-provisioning/rke-clusters/options/#pod-security-policy-support) (string) -* `enable_cluster_monitoring` - (Computed) Enable built-in cluster monitoring. Default `false` (bool) * `enable_network_policy` - (Computed) Enable project network isolation. Default `false` (bool) * `enable_cluster_istio` - (Computed) Enable built-in cluster istio. Default `false` (bool) * `fleet_workspace_name` - (Computed) Fleet workspace name (string) diff --git a/docs/data-sources/cluster_alert_group.md b/docs/data-sources/cluster_alert_group.md deleted file mode 100644 index 26c589ca..00000000 --- a/docs/data-sources/cluster_alert_group.md +++ /dev/null @@ -1,32 +0,0 @@ ---- -page_title: "rancher2_cluster_alert_group Data Source" ---- - -# rancher2\_cluster\_alert\_group Data Source - -Use this data source to retrieve information about a Rancher v2 cluster alert group. - -## Example Usage - -``` -data "rancher2_cluster_alert_group" "foo" { - cluster_id = "" - name = "" -} -``` - -## Argument Reference - -* `cluster_id` - (Required) The cluster id where create cluster alert group (string) -* `name` - (Required) The cluster alert group name (string) - -## Attributes Reference - -* `description` - (Computed) The cluster alert group description (string) -* `group_interval_seconds` - (Computed) The cluster alert group interval seconds. Default: `180` (int) -* `group_wait_seconds` - (Computed) The cluster alert group wait seconds. Default: `180` (int) -* `recipients` - (Computed) The cluster alert group recipients (list) -* `repeat_interval_seconds` - (Computed) The cluster alert group wait seconds. Default: `3600` (int) -* `annotations` - (Computed) The cluster alert group annotations (map) -* `labels` - (Computed) The cluster alert group labels (map) - diff --git a/docs/data-sources/cluster_alert_rule.md b/docs/data-sources/cluster_alert_rule.md deleted file mode 100644 index 0f2f64a6..00000000 --- a/docs/data-sources/cluster_alert_rule.md +++ /dev/null @@ -1,37 +0,0 @@ ---- -page_title: "rancher2_cluster_alert_rule Data Source" ---- - -# rancher2\_cluster\_alert\_rule Data Source - -Use this data source to retrieve information about a Rancher v2 cluster alert rule. - -## Example Usage - -``` -data "rancher2_cluster_alert_rule" "foo" { - cluster_id = "" - name = "" -} -``` - -## Argument Reference - -* `cluster_id` - (Required) The cluster id where create cluster alert rule (string) -* `name` - (Required) The cluster alert rule name (string) - -## Attributes Reference - -* `group_id` - (Computed) The cluster alert rule alert group ID (string) -* `event_rule` - (Computed) The cluster alert rule event rule. ConflictsWith: `"metric_rule", "node_rule", "system_service_rule"` (list Maxitems:1) -* `group_interval_seconds` - (Computed) The cluster alert rule group interval seconds. Default: `180` (int) -* `group_wait_seconds` - (Computed) The cluster alert rule group wait seconds. Default: `180` (int) -* `inherited` - (Computed) The cluster alert rule inherited. Default: `true` (bool) -* `metric_rule` - (Computed) The cluster alert rule metric rule. ConflictsWith: `"event_rule", "node_rule", "system_service_rule"`` (list Maxitems:1) -* `node_rule` - (Computed) The cluster alert rule node rule. ConflictsWith: `"event_rule", "metric_rule", "system_service_rule"`` (list Maxitems:1) -* `repeat_interval_seconds` - (Optional) The cluster alert rule wait seconds. Default: `3600` (int) -* `severity` - (Computed) The cluster alert rule severity. Supported values : `"critical" | "info" | "warning"`. Default: `critical` (string) -* `system_service_rule` - (Computed) The cluster alert rule system service rule. ConflictsWith: `"event_rule", "metric_rule", "node_rule"`` (list Maxitems:1) -* `annotations` - (Computed) The cluster alert rule annotations (map) -* `labels` - (Computed) The cluster alert rule labels (map) - diff --git a/docs/data-sources/cluster_v2.md b/docs/data-sources/cluster_v2.md index e32133fc..a24f9143 100644 --- a/docs/data-sources/cluster_v2.md +++ b/docs/data-sources/cluster_v2.md @@ -35,7 +35,6 @@ The following attributes are exported: * `agent_env_vars` - (Computed) Optional Agent Env Vars for Rancher agent (list) * `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) diff --git a/docs/data-sources/notifier.md b/docs/data-sources/notifier.md deleted file mode 100644 index 8f0451c1..00000000 --- a/docs/data-sources/notifier.md +++ /dev/null @@ -1,36 +0,0 @@ ---- -page_title: "rancher2_notifier Data Source" ---- - -# rancher2\_notifier Data Source - -Use this data source to retrieve information about a Rancher v2 notifier. - -## Example Usage - -``` -data "rancher2_notifier" "foo" { - name = "foo" - cluster_id = "" -} -``` - -## Argument Reference - -* `name` - (Required) The name of the notifier (string) -* `cluster_id` - (Required) The cluster id where create notifier (string) - -## Attributes Reference - -* `id` - (Computed) The ID of the resource (string) -* `description` - (Computed) The notifier description (string) -* `send_resolved` - (Computed) If the notifier sends resolved notifications (bool) -* `dingtalk_config` - (Computed) Dingtalk config for notifier (list maxitems:1) -* `msteams_config` - (Computed) MSTeams config for notifier (list maxitems:1) -* `pagerduty_config` - (Computed) Pagerduty config for notifier (list maxitems:1) -* `slack_config` - (Computed) Slack config for notifier (list maxitems:1) -* `smtp_config` - (Computed) SMTP config for notifier (list maxitems:1) -* `webhook_config` - (Computed) Webhook config for notifier (list maxitems:1) -* `wechat_config` - (Computed) Wechat config for notifier (list maxitems:1) -* `annotations` - (Computed) Annotations for notifier object (map) -* `labels` - (Computed) Labels for notifier object (map) diff --git a/docs/data-sources/pod_security_policy_template.md b/docs/data-sources/pod_security_policy_template.md deleted file mode 100644 index bd86603f..00000000 --- a/docs/data-sources/pod_security_policy_template.md +++ /dev/null @@ -1,53 +0,0 @@ ---- -page_title: "rancher2_pod_security_policy_template Data Source" ---- - -# rancher2\_pod\_security\_policy\_template Data Source - -Use this data source to retrieve information about a Rancher v2 PodSecurityPolicyTemplate. - -## Example Usage - -```hcl-terraform -data "rancher2_pod_security_policy_template" "foo" { - name = "foo" -} -``` - -## Argument Reference - -* `name` - (Required) The name of the PodSecurityPolicyTemplate (string) - -## Argument Reference - -The following arguments are supported: - -Any field without a description is taken from the PodSecurityPolicy object definition in Kubernetes: [https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.11/#podsecuritypolicy-v1beta1-extensions](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.11/#podsecuritypolicy-v1beta1-extensions) - -* `name` - (Required) The name of the PodSecurityPolicyTemplate (string) -* `description` - (Optional) The PodSecurityPolicyTemplate description (string) -* `annotations` - (Optional/Computed) Annotations for PodSecurityPolicyTemplate object (map) -* `labels` - (Optional/Computed) Labels for PodSecurityPolicyTemplate object (map) -* `allow_privilege_escalation` = (Optional) -* `allowed_capabilities` - (Optional) (list) -* `allowed_csi_driver` - (Optional) (list) -* `allowed_flex_volume` - (Optional) (list) -* `allowed_host_path` - (Optional) (list) -* `allowed_proc_mount_types` - (Optional) (list) -* `allowed_unsafe_sysctls` - (Optional) (list) -* `default_add_capabilities` - (Optional) (list) -* `default_allow_privilege_escalation` - (Optional) (list) -* `forbidden_sysctls` - (Optional) (list) -* `fs_group` - (Optional) (list maxitems:1) -* `host_ipc` - (Optional) (bool) -* `host_pid` - (Optional) (bool) -* `host_port` - (Optional) (list) -* `privileged` - (Optional) (bool) -* `read_only_root_filesystem` - (Optional) (bool) -* `required_drop_capabilities` - (Optional) (list) -* `run_as_user` - (Optional) (list maxitems:1) -* `run_as_group` - (Optional) (list maxitems:1) -* `runtime_class` - (Optional) (list maxitems:1) -* `se_linux` - (Optional) (list maxitems:1) -* `supplemental_group` - (Optional) (list maxitems:1) -* `volumes` - (Optional) (list) diff --git a/docs/data-sources/project.md b/docs/data-sources/project.md index 7fadab4c..3ca97674 100644 --- a/docs/data-sources/project.md +++ b/docs/data-sources/project.md @@ -36,8 +36,6 @@ resource "kubernetes_namespace" "my_namespace" { * `id` - (Computed) Cluster-wide unique ID of the Rancher 2 project (string) * `container_resource_limit` - (Computed) Default containers resource limits on project (List maxitem:1) - * `enable_project_monitoring` - (Computed) Enable built-in project monitoring. Default `false` (bool) - * `pod_security_policy_template_id` - (Computed) Default Pod Security Policy ID for the project (string) * `resource_quota` - (Computed) Resource quota for project. Rancher v2.1.x or higher (list maxitems:1) * `uuid` - (Computed) UUID of the project as stored by Rancher 2 (string) * `description` - (Computed) The project's description (string) diff --git a/docs/data-sources/project_alert_group.md b/docs/data-sources/project_alert_group.md deleted file mode 100644 index 307bf4b8..00000000 --- a/docs/data-sources/project_alert_group.md +++ /dev/null @@ -1,32 +0,0 @@ ---- -page_title: "rancher2_project_alert_group Data Source" ---- - -# rancher2\_project\_alert\_group Data Source - -Use this data source to retrieve information about a Rancher v2 project alert group. - -## Example Usage - -``` -data "rancher2_project_alert_group" "foo" { - project_id = "" - name = "" -} -``` - -## Argument Reference - -* `project_id` - (Required) The project id where create project alert group (string) -* `name` - (Required) The project alert group name (string) - -## Attributes Reference - -* `description` - (Computed) The project alert group description (string) -* `group_interval_seconds` - (Computed) The project alert group interval seconds. Default: `180` (int) -* `group_wait_seconds` - (Computed) The project alert group wait seconds. Default: `180` (int) -* `recipients` - (Computed) The project alert group recipients (list) -* `repeat_interval_seconds` - (Computed) The project alert group wait seconds. Default: `3600` (int) -* `annotations` - (Computed) The project alert group annotations (map) -* `labels` - (Computed) The project alert group labels (map) - diff --git a/docs/data-sources/project_alert_rule.md b/docs/data-sources/project_alert_rule.md deleted file mode 100644 index 34ab4fbc..00000000 --- a/docs/data-sources/project_alert_rule.md +++ /dev/null @@ -1,36 +0,0 @@ ---- -page_title: "rancher2_project_alert_rule Data Source" ---- - -# rancher2\_project\_alert\_rule Data Source - -Use this data source to retrieve information about a Rancher v2 project alert rule. - -## Example Usage - -``` -data "rancher2_project_alert_rule" "foo" { - project_id = "" - name = "" -} -``` - -## Argument Reference - -* `project_id` - (Required) The project id where create project alert rule (string) -* `name` - (Required) The project alert rule name (string) - -## Attributes Reference - -* `group_id` - (Computed) The project alert rule alert group ID (string) -* `group_interval_seconds` - (Computed) The project alert rule group interval seconds. Default: `180` (int) -* `group_wait_seconds` - (Computed) The project alert rule group wait seconds. Default: `180` (int) -* `inherited` - (Computed) The project alert rule inherited. Default: `true` (bool) -* `metric_rule` - (Computed) The project alert rule metric rule. ConflictsWith: `"pod_rule", "workload_rule"`` (list Maxitems:1) -* `pod_rule` - (Computed) The project alert rule pod rule. ConflictsWith: `"metric_rule", "workload_rule"`` (list Maxitems:1) -* `repeat_interval_seconds` - (Computed) The project alert rule wait seconds. Default: `3600` (int) -* `severity` - (Computed) The project alert rule severity. Supported values : `"critical" | "info" | "warning"`. Default: `critical` (string) -* `workload_rule` - (Computed) The project alert rule workload rule. ConflictsWith: `"metric_rule", "pod_rule"`` (list Maxitems:1) -* `annotations` - (Computed) The project alert rule annotations (map) -* `labels` - (Computed) The project alert rule labels (map) - diff --git a/docs/resources/cluster.md b/docs/resources/cluster.md index 17a56d2c..73b78420 100644 --- a/docs/resources/cluster.md +++ b/docs/resources/cluster.md @@ -8,7 +8,7 @@ Provides a Rancher v2 Cluster resource. This can be used to create Clusters for ## Example Usage -**Note optional/computed arguments** If any `optional/computed` argument of this resource is defined by the user, removing it from tf file will NOT reset its value. To reset it, let its definition at tf file as empty/false object. Ex: `enable_cluster_monitoring = false`, `cloud_provider {}`, `name = ""` +**Note optional/computed arguments** If any `optional/computed` argument of this resource is defined by the user, removing it from tf file will NOT reset its value. To reset it, let its definition at tf file as empty/false object. Ex: `cloud_provider {}`, `name = ""` ### Creating Rancher v2 imported cluster @@ -60,9 +60,7 @@ resource "rancher2_cluster" "foo-custom" { } ``` -### Creating Rancher v2 RKE cluster enabling and customizing monitoring - -**Note** Cluster monitoring version `0.2.0` and above, can't be enabled until cluster is fully deployed as [`kubeVersion`](https://github.com/rancher/system-charts/blob/52be656700468904b9bf15c3f39cd7112e1f8c9b/charts/rancher-monitoring/v0.2.0/Chart.yaml#L12) requirement has been introduced to helm chart +### Creating Rancher v2 RKE cluster enabling ```hcl # Create a new rancher2 RKE Cluster @@ -74,34 +72,10 @@ resource "rancher2_cluster" "foo-custom" { plugin = "canal" } } - enable_cluster_monitoring = true - cluster_monitoring_input { - answers = { - "exporter-kubelets.https" = true - "exporter-node.enabled" = true - "exporter-node.ports.metrics.port" = 9796 - "exporter-node.resources.limits.cpu" = "200m" - "exporter-node.resources.limits.memory" = "200Mi" - "grafana.persistence.enabled" = false - "grafana.persistence.size" = "10Gi" - "grafana.persistence.storageClass" = "default" - "operator.resources.limits.memory" = "500Mi" - "prometheus.persistence.enabled" = "false" - "prometheus.persistence.size" = "50Gi" - "prometheus.persistence.storageClass" = "default" - "prometheus.persistent.useReleaseName" = "true" - "prometheus.resources.core.limits.cpu" = "1000m", - "prometheus.resources.core.limits.memory" = "1500Mi" - "prometheus.resources.core.requests.cpu" = "750m" - "prometheus.resources.core.requests.memory" = "750Mi" - "prometheus.retention" = "12h" - } - version = "0.1.0" - } } ``` -### Creating Rancher v2 RKE cluster enabling/customizing monitoring and istio +### Creating Rancher v2 RKE cluster enabling/customizing istio ```hcl # Create a new rancher2 RKE Cluster @@ -113,35 +87,10 @@ resource "rancher2_cluster" "foo-custom" { plugin = "canal" } } - enable_cluster_monitoring = true - cluster_monitoring_input { - answers = { - "exporter-kubelets.https" = true - "exporter-node.enabled" = true - "exporter-node.ports.metrics.port" = 9796 - "exporter-node.resources.limits.cpu" = "200m" - "exporter-node.resources.limits.memory" = "200Mi" - "grafana.persistence.enabled" = false - "grafana.persistence.size" = "10Gi" - "grafana.persistence.storageClass" = "default" - "operator.resources.limits.memory" = "500Mi" - "prometheus.persistence.enabled" = "false" - "prometheus.persistence.size" = "50Gi" - "prometheus.persistence.storageClass" = "default" - "prometheus.persistent.useReleaseName" = "true" - "prometheus.resources.core.limits.cpu" = "1000m", - "prometheus.resources.core.limits.memory" = "1500Mi" - "prometheus.resources.core.requests.cpu" = "750m" - "prometheus.resources.core.requests.memory" = "750Mi" - "prometheus.retention" = "12h" - } - version = "0.1.0" - } } # Create a new rancher2 Cluster Sync for foo-custom cluster resource "rancher2_cluster_sync" "foo-custom" { cluster_id = rancher2_cluster.foo-custom.id - wait_monitoring = rancher2_cluster.foo-custom.enable_cluster_monitoring } # Create a new rancher2 Namespace resource "rancher2_namespace" "foo-istio" { @@ -149,7 +98,7 @@ resource "rancher2_namespace" "foo-istio" { project_id = rancher2_cluster_sync.foo-custom.system_project_id description = "istio namespace" } -# Create a new rancher2 App deploying istio (should wait until monitoring is up and running) +# Create a new rancher2 App deploying istio resource "rancher2_app" "istio" { catalog_name = "system-library" name = "cluster-istio" @@ -168,7 +117,6 @@ resource "rancher2_app" "istio" { "gateways.istio-ingressgateway.resources.requests.cpu" = "100m" "gateways.istio-ingressgateway.resources.requests.memory" = "128Mi" "gateways.istio-ingressgateway.type" = "NodePort" - "global.monitoring.type" = "cluster-monitoring" "global.rancher.clusterId" = rancher2_cluster_sync.foo-custom.cluster_id "istio_cni.enabled" = "false" "istiocoredns.enabled" = "false" @@ -653,18 +601,14 @@ The following arguments are supported: * `oke_config` - (Optional) The Oracle OKE configuration for `oke` Clusters. Conflicts with `aks_config`, `aks_config_v2`, `eks_config`, `eks_config_v2`, `gke_config`, `gke_config_v2`, `k3s_config` and `rke_config` (list maxitems:1) * `description` - (Optional) The description for Cluster (string) * `cluster_auth_endpoint` - (Optional/Computed) Enabling the [local cluster authorized endpoint](https://rancher.com/docs/rancher/v2.x/en/cluster-provisioning/rke-clusters/options/#local-cluster-auth-endpoint) allows direct communication with the cluster, bypassing the Rancher API proxy. (list maxitems:1) -* `cluster_monitoring_input` - (Optional) Cluster monitoring config. Any parameter defined in [rancher-monitoring charts](https://github.com/rancher/system-charts/tree/dev/charts/rancher-monitoring) could be configured (list maxitems:1) * `cluster_template_answers` - (Optional/Computed) Cluster template answers. For Rancher v2.3.x and above (list maxitems:1) * `cluster_template_id` - (Optional) Cluster template ID. For Rancher v2.3.x and above (string) * `cluster_template_questions` - (Optional/Computed) Cluster template questions. For Rancher v2.3.x and above (list) * `cluster_template_revision_id` - (Optional) Cluster template revision ID. For Rancher v2.3.x and above (string) -* `default_pod_security_policy_template_id` - (Optional/Computed) [Default pod security policy template id](https://rancher.com/docs/rancher/v2.x/en/cluster-provisioning/rke-clusters/options/#pod-security-policy-support) (string) * `default_pod_security_admission_configuration_template_name` - (Optional/Computed) The name of the pre-defined pod security admission configuration template to be applied to the cluster. Rancher admins (or those with the right permissions) can create, manage, and edit those templates. For more information, please refer to [Rancher Documentation](https://ranchermanager.docs.rancher.com/how-to-guides/new-user-guides/authentication-permissions-and-global-configuration/psa-config-templates). The argument is available in Rancher v2.7.2 and above (string) * `desired_agent_image` - (Optional/Computed) Desired agent image. For Rancher v2.3.x and above (string) * `desired_auth_image` - (Optional/Computed) Desired auth image. For Rancher v2.3.x and above (string) * `docker_root_dir` - (Optional/Computed) Desired auth image. For Rancher v2.3.x and above (string) -* `enable_cluster_alerting` - (Optional/Computed) Enable built-in cluster alerting (bool) -* `enable_cluster_monitoring` - (Optional/Computed) Enable built-in cluster monitoring (bool) * `enable_cluster_istio` - (Deprecated) Deploy istio on `system` project and `istio-system` namespace, using rancher2_app resource instead. See above example. * `enable_network_policy` - (Optional/Computed) Enable project network isolation (bool) * `fleet_workspace_name` - (Optional/Computed) Fleet workspace name (string) @@ -1316,7 +1260,6 @@ The following attributes are exported: * `extra_binds` - (Optional) Extra binds for kube API service (list) * `extra_env` - (Optional) Extra environment for kube API service (list) * `image` - (Optional/Computed) Docker image for kube API service (string) -* `pod_security_policy` - (Optional) Pod Security Policy option for kube API service. Default `false` (bool) * `secrets_encryption_config` - (Optional) [Encrypt k8s secret data configration](https://rancher.com/docs/rke/latest/en/config-options/secrets-encryption/). (list maxitem: 1) * `service_cluster_ip_range` - (Optional/Computed) Service Cluster IP Range option for kube API service (string) * `service_node_port_range` - (Optional/Computed) Service Node Port Range option for kube API service (string) @@ -1945,13 +1888,6 @@ The following arguments are supported: * `enabled` - (Optional) Enable the authorized cluster endpoint. Default `true` (bool) * `fqdn` - (Optional) FQDN for the authorized cluster endpoint (string) -### `cluster_monitoring_input` - -#### Arguments - -* `answers` - (Optional/Computed) Key/value answers for monitor input (map) -* `version` - (Optional) rancher-monitoring chart version (string) - ### `cluster_template_answers` #### Arguments diff --git a/docs/resources/cluster_alert_group.md b/docs/resources/cluster_alert_group.md deleted file mode 100644 index f6e439d8..00000000 --- a/docs/resources/cluster_alert_group.md +++ /dev/null @@ -1,72 +0,0 @@ ---- -page_title: "rancher2_cluster_alert_group Resource" ---- - -# rancher2\_cluster\_alert\_group Resource - -Provides a Rancher v2 Cluster Alert Group resource. This can be used to create Cluster Alert Group for Rancher v2 environments and retrieve their information. - -## Example Usage - -```hcl -# Create a new Rancher2 Cluster Alert Group -resource "rancher2_cluster_alert_group" "foo" { - cluster_id = "" - name = "foo" - description = "Terraform cluster alert group" - group_interval_seconds = 300 - repeat_interval_seconds = 3600 -} -``` - -## Argument Reference - -The following arguments are supported: - -* `cluster_id` - (Required) The cluster id where create cluster alert group (string) -* `name` - (Required) The cluster alert group name (string) -* `description` - (Optional) The cluster alert group description (string) -* `group_interval_seconds` - (Optional) The cluster alert group interval seconds. Default: `180` (int) -* `group_wait_seconds` - (Optional) The cluster alert group wait seconds. Default: `180` (int) -* `recipients` - (Optional) The cluster alert group recipients (list) -* `repeat_interval_seconds` - (Optional) The cluster alert group wait seconds. Default: `3600` (int) -* `annotations` - (Optional/Computed) The cluster alert group annotations (map) -* `labels` - (Optional/Computed) The cluster alert group labels (map) - - -## Attributes Reference - -The following attributes are exported: - -* `id` - (Computed) The ID of the resource (string) - -## Nested blocks - -### `recipients` - -#### Arguments - -* `notifier_id` - (Required) Recipient notifier ID (string) -* `recipient` - (Optional/Computed) Recipient (string) -* `default_recipient` - (Optional) Use notifier default recipient, overriding `recipient` argument if set. Default: `false` (bool) - -#### Attributes - -* `notifier_type` - (Computed) Recipient notifier ID. Supported values : `"dingtalk" | "msteams" | "pagerduty" | "slack" | "email" | "webhook" | "wechat"` (string) - -## Timeouts - -`rancher2_cluster_alert_group` provides the following -[Timeouts](https://www.terraform.io/docs/configuration/resources.html#operation-timeouts) configuration options: - -- `create` - (Default `10 minutes`) Used for creating cluster alert groups. -- `update` - (Default `10 minutes`) Used for cluster alert group modifications. -- `delete` - (Default `10 minutes`) Used for deleting cluster alert groups. - -## Import - -Cluster Alert Group can be imported using the Rancher cluster alert group ID - -``` -$ terraform import rancher2_cluster_alert_group.foo <CLUSTER_ALERT_GROUP_ID> -``` diff --git a/docs/resources/cluster_alert_rule.md b/docs/resources/cluster_alert_rule.md deleted file mode 100644 index daf91a7b..00000000 --- a/docs/resources/cluster_alert_rule.md +++ /dev/null @@ -1,106 +0,0 @@ ---- -page_title: "rancher2_cluster_alert_rule Resource" ---- - -# rancher2\_cluster\_alert\_rule Resource - -Provides a Rancher v2 Cluster Alert Rule resource. This can be used to create Cluster Alert Rule for Rancher v2 environments and retrieve their information. - -## Example Usage - -```hcl -# Create a new Rancher2 Cluster Alert Group -resource "rancher2_cluster_alert_group" "foo" { - cluster_id = "" - name = "foo" - description = "Terraform cluster alert group" - group_interval_seconds = 300 - repeat_interval_seconds = 3600 -} -# Create a new Rancher2 Cluster Alert Rule -resource "rancher2_cluster_alert_rule" "foo" { - cluster_id = rancher2_cluster_alert_group.foo.cluster_id - group_id = rancher2_cluster_alert_group.foo.id - name = "foo" - group_interval_seconds = 600 - repeat_interval_seconds = 6000 -} -``` - -## Argument Reference - -The following arguments are supported: - -* `cluster_id` - (Required) The cluster id where create cluster alert rule (string) -* `group_id` - (Required) The cluster alert rule alert group ID (string) -* `name` - (Required) The cluster alert rule name (string) -* `event_rule` - (Optional) The cluster alert rule event rule. ConflictsWith: `"metric_rule", "node_rule", "system_service_rule"`` (list Maxitems:1) -* `group_interval_seconds` - (Optional) The cluster alert rule group interval seconds. Default: `180` (int) -* `group_wait_seconds` - (Optional) The cluster alert rule group wait seconds. Default: `180` (int) -* `inherited` - (Optional) The cluster alert rule inherited. Default: `true` (bool) -* `metric_rule` - (Optional) The cluster alert rule metric rule. ConflictsWith: `"event_rule", "node_rule", "system_service_rule"`` (list Maxitems:1) -* `node_rule` - (Optional) The cluster alert rule node rule. ConflictsWith: `"event_rule", "metric_rule", "system_service_rule"`` (list Maxitems:1) -* `repeat_interval_seconds` - (Optional) The cluster alert rule wait seconds. Default: `3600` (int) -* `severity` - (Optional) The cluster alert rule severity. Supported values : `"critical" | "info" | "warning"`. Default: `critical` (string) -* `system_service_rule` - (Optional) The cluster alert rule system service rule. ConflictsWith: `"event_rule", "metric_rule", "node_rule"` (list Maxitems:1) -* `annotations` - (Optional/Computed) The cluster alert rule annotations (map) -* `labels` - (Optional/Computed) The cluster alert rule labels (map) - - -## Attributes Reference - -The following attributes are exported: - -* `id` - (Computed) The ID of the resource (string) - -## Nested blocks - -### `event_rule` - -#### Arguments - -* `resource_kind` - (Required) Resource kind. Supported values : `"DaemonSet" | "Deployment" | "Node" | "Pod" | "StatefulSet"` (string) -* `event_type` - (Optional) Event type. Supported values : `"Warning" | "Normal"`. Default: `Warning` (string) - -### `metric_rule` - -#### Arguments - -* `duration` - (Required) Metric rule duration (string) -* `expression` - (Required) Metric rule expression (string) -* `threshold_value` - (Required) Metric rule threshold value (float64) -* `comparison` - (Optional) Metric rule comparison. Supported values : `"equal" | "greater-or-equal" | "greater-than" | "less-or-equal" | "less-than" | "not-equal" | "has-value"`. Default: `equal` (string) -* `description` - (Optional) Metric rule description (string) - -### `node_rule` - -#### Arguments - -* `cpu_threshold` - (Optional) Node rule cpu threshold. Default: `70` (int) -* `condition` - (Optional) Node rule condition. Supported values : `"cpu" | "mem" | "notready"`. Default: `notready` (string) -* `mem_threshold` - (Optional) Node rule mem threshold. Default: `70` (int) -* `node_id` - (Optional) Node ID (string) -* `selector` - (Optional) Node rule selector (map) - -### `system_service_rule` - -#### Arguments - -* `condition` - (Optional) System service rule condition. Supported values : `"controller-manager" | "etcd" | "scheduler"`. Default: `scheduler` (string) - -## Timeouts - -`rancher2_cluster_alert_rule` provides the following -[Timeouts](https://www.terraform.io/docs/configuration/resources.html#operation-timeouts) configuration options: - -- `create` - (Default `10 minutes`) Used for creating cluster alert rules. -- `update` - (Default `10 minutes`) Used for cluster alert rule modifications. -- `delete` - (Default `10 minutes`) Used for deleting cluster alert rules. - -## Import - -Cluster Alert Rule can be imported using the Rancher cluster alert rule ID - -``` -$ terraform import rancher2_cluster_alert_rule.foo <CLUSTER_ALERT_RULE_ID> -``` diff --git a/docs/resources/cluster_sync.md b/docs/resources/cluster_sync.md index 46421e6c..1c9ec678 100644 --- a/docs/resources/cluster_sync.md +++ b/docs/resources/cluster_sync.md @@ -86,9 +86,7 @@ The following arguments are supported: * `cluster_id` - (Required/ForceNew) The cluster ID that is syncing (string) * `node_pool_ids` - (Optional) The node pool IDs used by the cluster id (list) -* `wait_alerting` - (Optional) Wait until alerting is up and running. Default: `false` (bool) * `wait_catalogs` - (Optional) Wait until all catalogs are downloaded and active. Default: `false` (bool) -* `wait_monitoring` - (Optional) Wait until monitoring is up and running. Default: `false` (bool) * `state_confirm` - (Optional) Wait until active status is confirmed a number of times (wait interval of 5s). Default: `1` means no confirmation (int) **Note:** `state_confirm` would be useful, if you have troubles for creating/updating custom clusters that eventually are reaching `active` state before they are fully installed. For example: setting `state_confirm = 2` will assure that the cluster has been in `active` state for at least 5 seconds, `state_confirm = 3` assure at least 10 seconds, etc diff --git a/docs/resources/cluster_template.md b/docs/resources/cluster_template.md index afd84a54..3a8a7fc3 100644 --- a/docs/resources/cluster_template.md +++ b/docs/resources/cluster_template.md @@ -122,12 +122,9 @@ resource "rancher2_cluster_template" "foo" { * `cluster_auth_endpoint` - (Optional/Computed) Local cluster auth endpoint (list maxitems: 1) * `default_cluster_role_for_project_members` - (Optional/Computed) Default cluster role for project members (string) -* `default_pod_security_policy_template_id` - (Optional/Computed) Default pod security policy template ID (string) * `desired_agent_image` - (Optional/Computed) Desired agent image (string) * `desired_auth_image` - (Optional/Computed) Desired auth image (string) * `docker_root_dir` - (Optional/Computed) Desired auth image (string) -* `enable_cluster_alerting` - (Optional) Enable built-in cluster alerting. Default: `false` (bool) -* `enable_cluster_monitoring` - (Optional) Enable built-in cluster monitoring. Default: `false` (bool) * `enable_network_policy` - (Optional) Enable project network isolation. Default: `false` (bool) * `rke_config` - (Required) Rancher Kubernetes Engine Config (list maxitems: 1) * `windows_prefered_cluster` - (Optional) Windows prefered cluster. Default: `false` (bool) diff --git a/docs/resources/cluster_v2.md b/docs/resources/cluster_v2.md index 0fa99499..c4b7f567 100644 --- a/docs/resources/cluster_v2.md +++ b/docs/resources/cluster_v2.md @@ -849,7 +849,6 @@ The following arguments are supported: * `rke_config` - (Optional/computed, list, max length: 1) The RKE configuration for the cluster. * `local_auth_endpoint` - (Optional, list, max length: 1) Local auth endpoint configures the Authorized Cluster Endpoint (ACE) which can be used to directly access the Kubernetes API server, without requiring communication through Rancher. For more information, please refer to [Rancher Documentation](https://ranchermanager.docs.rancher.com/how-to-guides/new-user-guides/kubernetes-clusters-in-rancher-setup/register-existing-clusters#authorized-cluster-endpoint-support-for-rke2-and-k3s-clusters). * `cloud_credential_secret_name` - (Optional, string) Cloud credential secret name is the secret to be used when a cloud credential secret name is not specified at the machine pool level. -* `default_pod_security_policy_template_name` - (Optional, string) Default pod security policy template name specifies the default PSP for the cluster. For more information, please refer to [Rancher Documentation](https://ranchermanager.docs.rancher.com/how-to-guides/new-user-guides/authentication-permissions-and-global-configuration/create-pod-security-policies). * `default_pod_security_admission_configuration_template_name` - (Optional, string) The name of the pre-defined pod security admission configuration template to be applied to the cluster. Rancher admins (or those with the right permissions) can create, manage, and edit those templates. For more information, please refer to [Rancher Documentation](https://ranchermanager.docs.rancher.com/how-to-guides/new-user-guides/authentication-permissions-and-global-configuration/psa-config-templates). The argument is available in Rancher v2.7.2 and above. * `default_cluster_role_for_project_members` - (Optional, string) Default cluster role for project members. * `enable_network_policy` - (Optional, bool, default: false) Enable k8s network policy on the cluster. diff --git a/docs/resources/notifier.md b/docs/resources/notifier.md deleted file mode 100644 index 5cb29ea4..00000000 --- a/docs/resources/notifier.md +++ /dev/null @@ -1,127 +0,0 @@ ---- -page_title: "rancher2_notifier Resource" ---- - -# rancher2\_notifier Resource - -Provides a Rancher v2 Notifier resource. This can be used to create notifiers for Rancher v2 environments and retrieve their information. - -## Example Usage - -```hcl -# Create a new rancher2 Notifier -resource "rancher2_notifier" "foo" { - name = "foo" - cluster_id = "" - description = "Terraform notifier acceptance test" - send_resolved = "true" - pagerduty_config { - service_key = "XXXXXXXX" - proxy_url = "http://proxy.test.io" - } -} -``` - -## Argument Reference - -The following arguments are supported: - -* `name` - (Required) The name of the notifier (string) -* `cluster_id` - (Required/ForceNew) The cluster id where create notifier (string) -* `description` - (Optional) The notifier description (string) -* `send_resolved` = (Optional) Enable the notifier to send resolved notifications. Default `false` (bool) -* `dingtalk_config` - (Optional) Dingtalk config for notifier (list maxitems:1) -* `msteams_config` - (Optional) MSTeams config for notifier (list maxitems:1) -* `pagerduty_config` - (Optional) Pagerduty config for notifier (list maxitems:1) -* `slack_config` - (Optional) Slack config for notifier (list maxitems:1) -* `smtp_config` - (Optional) SMTP config for notifier (list maxitems:1) -* `webhook_config` - (Optional) Webhook config for notifier (list maxitems:1) -* `wechat_config` - (Optional) Wechat config for notifier (list maxitems:1) -* `annotations` - (Optional/Computed) Annotations for notifier object (map) -* `labels` - (Optional/Computed) Labels for notifier object (map) - -## Attributes Reference - -The following attributes are exported: - -* `id` - (Computed) The ID of the resource (string) - -## Nested blocks - -### `dingtalk_config` - -#### Arguments - -* `url` - (Required) Dingtalk url (string) -* `proxy_url` - (Optional) Dingtalk proxy url (string) -* `secret` - (Optional) Secret for url sign enable (string) - -### `msteams_config` - -#### Arguments - -* `url` - (Required) MSTeams url (string) -* `proxy_url` - (Optional) MSTeams proxy url (string) - -### `pagerduty_config` - -#### Arguments - -* `service_key` - (Required) Pagerduty service key (string) -* `proxy_url` - (Optional) Pagerduty proxy url (string) - -### `slack_config` - -#### Arguments - -* `default_recipient` - (Required) Slack default recipient (string) -* `url` - (Required) Slack url (string) -* `proxy_url` - (Optional) Slack proxy url (string) - -### `smtp_config` - -* `default_recipient` - (Required) SMTP default recipient (string) -* `host` - (Required) SMTP host (string) -* `port` - (Required) SMTP port (int) -* `sender` - (Required) SMTP sender (string) -* `password` - (Optional/Sensitive) SMTP password (string) -* `tls` - (Optional/Sensitive) SMTP tls. Default `true` (bool) -* `username` - (Optional/Sensitive) SMTP username (string) - -#### Arguments - -### `webhook_config` - -* `url` - (Required) Webhook url (string) -* `proxy_url` - (Optional) Webhook proxy url (string) - -#### Arguments - -### `wechat_config` - -#### Arguments - -* `agent` - (Required) Wechat agent ID (string) -* `corp` - (Required) Wechat corporation ID (string) -* `default_recipient` - (Required) Wechat default recipient (string) -* `secret` - (Required/Sensitive) Wechat agent ID (string) -* `proxy_url` - (Optional) Wechat proxy url (string) -* `recipient_type` - (Optional) Wechat recipient type. Allowed values: `party` | `tag` | `user` (string) - -## Timeouts - -`rancher2_notifier` provides the following -[Timeouts](https://www.terraform.io/docs/configuration/resources.html#operation-timeouts) configuration options: - -- `create` - (Default `10 minutes`) Used for creating notifiers. -- `update` - (Default `10 minutes`) Used for notifier modifications. -- `delete` - (Default `10 minutes`) Used for deleting notifiers. - -## Import - -Notifiers can be imported using the Rancher nNtifier ID - -``` -$ terraform import rancher2_notifier.foo <notifier_id> -``` - diff --git a/docs/resources/pod_security_policy_template.md b/docs/resources/pod_security_policy_template.md deleted file mode 100644 index b02f6312..00000000 --- a/docs/resources/pod_security_policy_template.md +++ /dev/null @@ -1,235 +0,0 @@ ---- -layout: "rancher2" -page_title: "Rancher2: rancher2_pod_security_policy_template" -sidebar_current: "docs-rancher2-resource-pod-security-policy-template" -description: |- - Provides a Rancher v2 PodSecurityPolicyTemplate resource. This can be used to create PodSecurityPolicyTemplates for Rancher v2 environments and retrieve their information. ---- - -# rancher2\_pod\_security\_policy\_template - -Provides a Rancher v2 PodSecurityPolicyTemplate resource. This can be used to create PodSecurityPolicyTemplates for Rancher v2 environments and retrieve their information. - -## Example Usage - -```hcl-terraform -# Create a new rancher2 PodSecurityPolicyTemplate -resource "rancher2_pod_security_policy_template" "foo" { - name = "foo" - description = "Terraform PodSecurityPolicyTemplate acceptance test - update" - allow_privilege_escalation = false - allowed_csi_driver { - name = "something" - } - allowed_csi_driver { - name = "something-else" - } - allowed_flex_volume { - driver = "something" - } - allowed_flex_volume { - driver = "something-else" - } - allowed_host_path { - path_prefix = "/" - read_only = true - } - allowed_host_path { - path_prefix = "//" - read_only = false - } - allowed_proc_mount_types = ["Default"] - default_allow_privilege_escalation = false - fs_group { - rule = "MustRunAs" - range { - min = 0 - max = 100 - } - range { - min = 0 - max = 100 - } - } - host_ipc = false - host_network = false - host_pid = false - host_port { - min = 0 - max = 65535 - } - host_port { - min = 1024 - max = 8080 - } - privileged = false - read_only_root_filesystem = false - required_drop_capabilities = ["something"] - - run_as_user { - rule = "MustRunAs" - range { - min = 1 - max = 100 - } - range { - min = 2 - max = 1024 - } - } - run_as_group { - rule = "MustRunAs" - range { - min = 1 - max = 100 - } - range { - min = 2 - max = 1024 - } - } - runtime_class { - default_runtime_class_name = "something" - allowed_runtime_class_names = ["something"] - } - se_linux { - rule = "RunAsAny" - } - supplemental_group { - rule = "RunAsAny" - } - volumes = ["azureFile"] -} -``` - -## Argument Reference - -The following arguments are supported: - -Any field without a description is taken from the PodSecurityPolicy object definition in Kubernetes: [https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.11/#podsecuritypolicy-v1beta1-extensions](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.11/#podsecuritypolicy-v1beta1-extensions) - -* `name` - (Required) The name of the PodSecurityPolicyTemplate (string) -* `description` - (Optional) The PodSecurityPolicyTemplate description (string) -* `annotations` - (Optional/Computed) Annotations for PodSecurityPolicyTemplate object (map) -* `labels` - (Optional/Computed) Labels for PodSecurityPolicyTemplate object (map) -* `allow_privilege_escalation` = (Optional) -* `allowed_capabilities` - (Optional) (list) -* `allowed_csi_driver` - (Optional) (list) -* `allowed_flex_volume` - (Optional) (list) -* `allowed_host_path` - (Optional) (list) -* `allowed_proc_mount_types` - (Optional) (list) -* `allowed_unsafe_sysctls` - (Optional) (list) -* `default_add_capabilities` - (Optional) (list) -* `default_allow_privilege_escalation` - (Optional) (list) -* `forbidden_sysctls` - (Optional) (list) -* `fs_group` - (Optional) (list maxitems:1) -* `host_ipc` - (Optional) (bool) -* `host_pid` - (Optional) (bool) -* `host_port` - (Optional) (list) -* `privileged` - (Optional) (bool) -* `read_only_root_filesystem` - (Optional) (bool) -* `required_drop_capabilities` - (Optional) (list) -* `run_as_user` - (Optional) (list maxitems:1) -* `run_as_group` - (Optional) (list maxitems:1) -* `runtime_class` - (Optional) (list maxitems:1) -* `se_linux` - (Optional) (list maxitems:1) -* `supplemental_group` - (Optional) (list maxitems:1) -* `volumes` - (Optional) (list) - - -## Attributes Reference - -The following attributes are exported: - -* `id` - (Computed) The ID of the resource (string) - -## Nested blocks - -Any field without a description is taken from the PodSecurityPolicy object definition in Kubernetes: [https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.11/#podsecuritypolicy-v1beta1-extensions](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.11/#podsecuritypolicy-v1beta1-extensions) - -### `allowed_host_path` - -#### Arguments - -* `path_prefix` - (Required) (string) -* `read_only` - (Optional) (string) - -### `fs_group` - -#### Arguments - -* `range` - (Optional) (list) -* `rule` - (Optional) (string) - -### `range` - -#### Arguments - -* `min` - (Required) (int) -* `max` - (Required) (int) - -### `host_port` - -#### Arguments - -* `min` - (Required) (int) -* `max` - (Required) (int) - -### `run_as_user` - -#### Arguments - -* `rule` - (Required) (string) -* `range` - (Optional) (list) - -### `run_as_group` - -#### Arguments - -* `rule` - (Required) (string) -* `range` - (Optional) (list) - -### `runtime_class` - -#### Arguments - -* `allowed_runtime_class_names` - (Required) (list) -* `default_runtime_class_name` - (Optional) (string) - -### `se_linux` - -#### Arguments - -* `rule` - (Required) (string) -* `se_linux_option` - (Optional) (list maxitems:1) - -### `se_linux_option` - -#### Arguments - -* `level` - (Optional) (string) -* `role` - (Optional) (string) -* `type` - (Optional) (string) -* `user` - (Optional) (string) - -### `supplemental_group` - -#### Arguments - -* `rule` - (Required) (string) -* `range` - (Optional) (list) - - -## Timeouts - -Because the `rancher2_pod_security_policy_template` API endpoint does not have a `state` field defined, this provider does -not implement timeouts, only direct API calls (without retry on failure). - -## Import - -PodSecurityPolicyTemplate can be imported using the Rancher PodSecurityPolicyTemplate Name - -``` -$ terraform import rancher2_pod_security_policy_template.foo <pod_security_policy_name> -``` - diff --git a/docs/resources/project.md b/docs/resources/project.md index 9250b76f..a5a572e1 100644 --- a/docs/resources/project.md +++ b/docs/resources/project.md @@ -35,7 +35,7 @@ resource "rancher2_project" "foo" { ``` ```hcl -# Create a new rancher2 Project enabling and customizing monitoring +# Create a new rancher2 Project resource "rancher2_project" "foo" { name = "foo" cluster_id = "" @@ -57,29 +57,6 @@ resource "rancher2_project" "foo" { requests_cpu = "1m" requests_memory = "1Mi" } - enable_project_monitoring = true - project_monitoring_input { - answers = { - "exporter-kubelets.https" = true - "exporter-node.enabled" = true - "exporter-node.ports.metrics.port" = 9796 - "exporter-node.resources.limits.cpu" = "200m" - "exporter-node.resources.limits.memory" = "200Mi" - "grafana.persistence.enabled" = false - "grafana.persistence.size" = "10Gi" - "grafana.persistence.storageClass" = "default" - "operator.resources.limits.memory" = "500Mi" - "prometheus.persistence.enabled" = "false" - "prometheus.persistence.size" = "50Gi" - "prometheus.persistence.storageClass" = "default" - "prometheus.persistent.useReleaseName" = "true" - "prometheus.resources.core.limits.cpu" = "1000m", - "prometheus.resources.core.limits.memory" = "1500Mi" - "prometheus.resources.core.requests.cpu" = "750m" - "prometheus.resources.core.requests.memory" = "750Mi" - "prometheus.retention" = "12h" - } - } } ``` @@ -91,9 +68,6 @@ The following arguments are supported: * `cluster_id` - (Required) The cluster id where create project (string) * `container_resource_limit` - (Optional) Default containers resource limits on project (List maxitem:1) * `description` - (Optional) A project description (string) -* `enable_project_monitoring` - (Optional) Enable built-in project monitoring. Default `false` (bool) -* `pod_security_policy_template_id` - (Optional) Default Pod Security Policy ID for the project (string) -* `project_monitoring_input` - (Optional) Project monitoring config. Any parameter defined in [rancher-monitoring charts](https://github.com/rancher/system-charts/tree/dev/charts/rancher-monitoring) could be configured (list maxitems:1) * `resource_quota` - (Optional) Resource quota for project. Rancher v2.1.x or higher (list maxitems:1) * `wait_for_cluster` - (Optional) Wait for cluster becomes active. Default `false` (bool) * `annotations` - (Optional/Computed) Annotations for Node Pool object (map) @@ -116,13 +90,6 @@ The following attributes are exported: * `requests_cpu` - (Optional) CPU reservation for containers (string) * `requests_memory` - (Optional) Memory reservation for containers (string) -### `project_monitoring_input` - -#### Arguments - -* `answers` - (Optional/Computed) Key/value answers for monitor input (map) -* `version` - (Optional) rancher-monitoring chart version (string) - ### `resource_quota` #### Arguments diff --git a/docs/resources/project_alert_group.md b/docs/resources/project_alert_group.md deleted file mode 100644 index f510b594..00000000 --- a/docs/resources/project_alert_group.md +++ /dev/null @@ -1,71 +0,0 @@ ---- -page_title: "rancher2_project_alert_group Resource" ---- - -# rancher2\_project\_alert\_group Resource - -Provides a Rancher v2 Project Alert Group resource. This can be used to create Project Alert Group for Rancher v2 environments and retrieve their information. - -## Example Usage - -```hcl -# Create a new Rancher2 Project Alert Group -resource "rancher2_project_alert_group" "foo" { - name = "foo" - description = "Terraform project alert group" - project_id = "" - group_interval_seconds = 300 - repeat_interval_seconds = 3600 -} -``` - -## Argument Reference - -The following arguments are supported: - -* `name` - (Required) The project alert group name (string) -* `project_id` - (Required) The project id where create project alert group (string) -* `description` - (Optional) The project alert group description (string) -* `group_interval_seconds` - (Optional) The project alert group interval seconds. Default: `180` (int) -* `group_wait_seconds` - (Optional) The project alert group wait seconds. Default: `180` (int) -* `recipients` - (Optional) The project alert group recipients (list) -* `repeat_interval_seconds` - (Optional) The project alert group wait seconds. Default: `3600` (int) -* `annotations` - (Optional/Computed) The project alert group annotations (map) -* `labels` - (Optional/Computed) The project alert group labels (map) - - -## Attributes Reference - -The following attributes are exported: - -* `id` - (Computed) The ID of the resource (string) - -## Nested blocks - -### `recipients` - -#### Arguments - -* `notifier_id` - (Required) Recipient notifier ID (string) -* `recipient` - (Optional/Computed) Recipient (string) - -#### Attributes - -* `notifier_type` - (Computed) Recipient notifier ID. Supported values : `"pagerduty" | "slack" | "email" | "webhook" | "wechat"` (string) - -## Timeouts - -`rancher2_project_alert_group` provides the following -[Timeouts](https://www.terraform.io/docs/configuration/resources.html#operation-timeouts) configuration options: - -- `create` - (Default `10 minutes`) Used for creating project alert groups. -- `update` - (Default `10 minutes`) Used for project alert group modifications. -- `delete` - (Default `10 minutes`) Used for deleting project alert groups. - -## Import - -Project Alert Group can be imported using the Rancher project alert group ID - -``` -$ terraform import rancher2_project_alert_group.foo <project_alert_group_id> -``` diff --git a/docs/resources/project_alert_rule.md b/docs/resources/project_alert_rule.md deleted file mode 100644 index 9289d7ba..00000000 --- a/docs/resources/project_alert_rule.md +++ /dev/null @@ -1,123 +0,0 @@ ---- -page_title: "rancher2_project_alert_rule Resource" ---- - -# rancher2\_project\_alert\_rule Resource - -Provides a Rancher v2 Project Alert Rule resource. This can be used to create Project Alert Rule for Rancher v2 environments and retrieve their information. - -## Example Usage - -```hcl -# Create a new Rancher2 Project -resource "rancher2_project" "foo" { - name = "foo" - cluster_id = "" - description = "Terraform project " - resource_quota { - project_limit { - limits_cpu = "2000m" - limits_memory = "2000Mi" - requests_storage = "2Gi" - } - namespace_default_limit { - limits_cpu = "500m" - limits_memory = "500Mi" - requests_storage = "1Gi" - } - } - container_resource_limit { - limits_cpu = "20m" - limits_memory = "20Mi" - requests_cpu = "1m" - requests_memory = "1Mi" - } -} -# Create a new Rancher2 Project Alert Group -resource "rancher2_project_alert_group" "foo" { - name = "foo" - description = "Terraform project alert group" - project_id = rancher2_project.foo.id - group_interval_seconds = 300 - repeat_interval_seconds = 3600 -} -# Create a new Rancher2 Project Alert Rule -resource "rancher2_project_alert_rule" "foo" { - project_id = rancher2_project_alert_group.foo.project_id - group_id = rancher2_project_alert_group.foo.id - name = "foo" - group_interval_seconds = 600 - repeat_interval_seconds = 6000 -} -``` - -## Argument Reference - -The following arguments are supported: - -* `project_id` - (Required) The project id where create project alert rule (string) -* `group_id` - (Required) The project alert rule alert group ID (string) -* `name` - (Required) The project alert rule name (string) -* `group_interval_seconds` - (Optional) The project alert rule group interval seconds. Default: `180` (int) -* `group_wait_seconds` - (Optional) The project alert rule group wait seconds. Default: `180` (int) -* `inherited` - (Optional) The project alert rule inherited. Default: `true` (bool) -* `metric_rule` - (Optional) The project alert rule metric rule. ConflictsWith: `"pod_rule", "workload_rule"`` (list Maxitems:1) -* `pod_rule` - (Optional) The project alert rule pod rule. ConflictsWith: `"metric_rule", "workload_rule"`` (list Maxitems:1) -* `repeat_interval_seconds` - (Optional) The project alert rule wait seconds. Default: `3600` (int) -* `severity` - (Optional) The project alert rule severity. Supported values : `"critical" | "info" | "warning"`. Default: `critical` (string) -* `workload_rule` - (Optional) The project alert rule workload rule. ConflictsWith: `"metric_rule", "pod_rule"`` (list Maxitems:1) -* `annotations` - (Optional/Computed) The project alert rule annotations (map) -* `labels` - (Optional/Computed) The project alert rule labels (map) - - -## Attributes Reference - -The following attributes are exported: - -* `id` - (Computed) The ID of the resource (string) - -## Nested blocks - -### `metric_rule` - -#### Arguments - -* `duration` - (Required) Metric rule duration (string) -* `expression` - (Required) Metric rule expression (string) -* `threshold_value` - (Required) Metric rule threshold value (float64) -* `comparison` - (Optional) Metric rule comparison. Supported values : `"equal" | "greater-or-equal" | "greater-than" | "less-or-equal" | "less-than" | "not-equal" | "has-value"`. Default: `equal` (string) -* `description` - (Optional) Metric rule description (string) - -### `pod_rule` - -#### Arguments - -* `pod_id` - (Required) Pod ID (string) -* `condition` - (Optional) Pod rule condition. Supported values : `"notrunning" | "notscheduled" | "restarts"`. Default: `notrunning` (string) -* `restart_interval_seconds` - (Optional) Pod rule restart interval seconds. Default: `300` (int) -* `restart_times` - (Optional) Pod rule restart times. Default: `3` (int) - -### `workload_rule` - -#### Arguments - -* `available_percentage` - (Optional) Workload rule available percentage. Default: `70` (int) -* `selector` - (Optional) Workload rule selector (map) -* `workload_id` - (Optional) Workload ID (string) - -## Timeouts - -`rancher2_project_alert_rule` provides the following -[Timeouts](https://www.terraform.io/docs/configuration/resources.html#operation-timeouts) configuration options: - -- `create` - (Default `10 minutes`) Used for creating project alert rules. -- `update` - (Default `10 minutes`) Used for project alert rule modifications. -- `delete` - (Default `10 minutes`) Used for deleting project alert rules. - -## Import - -Project Alert Rule can be imported using the Rancher project alert rule ID - -``` -$ terraform import rancher2_project_alert_rule.foo <project_alert_rule_id> -``` diff --git a/go.mod b/go.mod index 9b3b7f6b..ba5d7556 100644 --- a/go.mod +++ b/go.mod @@ -1,22 +1,24 @@ module github.com/rancher/terraform-provider-rancher2 -go 1.21 +go 1.22.0 + +toolchain go1.22.5 require ( github.com/ghodss/yaml v1.0.0 github.com/hashicorp/go-version v1.6.0 github.com/hashicorp/terraform-plugin-sdk v1.17.2 - github.com/rancher/norman v0.0.0-20240206180703-6eda4bc94b4c - github.com/rancher/rancher v0.0.0-20240618132447-2145c8e9d603 + github.com/rancher/norman v0.0.0-20240708202514-a0127673d1b9 + github.com/rancher/rancher v0.0.0-20240716141526-e0d2afd007d8 github.com/rancher/rancher/pkg/apis v0.0.0 github.com/rancher/rancher/pkg/client v0.0.0 - github.com/stretchr/testify v1.8.4 - golang.org/x/crypto v0.23.0 + github.com/stretchr/testify v1.9.0 + golang.org/x/crypto v0.25.0 golang.org/x/sync v0.7.0 gopkg.in/yaml.v2 v2.4.0 - k8s.io/api v0.28.8 - k8s.io/apimachinery v0.28.8 - k8s.io/apiserver v0.28.8 + k8s.io/api v0.30.2 + k8s.io/apimachinery v0.30.2 + k8s.io/apiserver v0.30.1 k8s.io/client-go v12.0.0+incompatible ) @@ -32,24 +34,22 @@ require ( github.com/apparentlymart/go-cidr v1.1.0 // indirect github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect github.com/armon/go-radix v1.0.0 // indirect - github.com/aws/aws-sdk-go v1.49.24 // indirect + github.com/aws/aws-sdk-go v1.50.38 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect github.com/bgentry/speakeasy v0.1.0 // indirect github.com/blang/semver v3.5.1+incompatible // indirect github.com/blang/semver/v4 v4.0.0 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect - github.com/davecgh/go-spew v1.1.1 // indirect + github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/emicklei/go-restful/v3 v3.11.0 // indirect - github.com/evanphx/json-patch v5.6.0+incompatible // indirect - github.com/evanphx/json-patch/v5 v5.6.0 // indirect - github.com/fatih/color v1.15.0 // indirect - github.com/felixge/httpsnoop v1.0.3 // indirect - github.com/fsnotify/fsnotify v1.6.0 // indirect + github.com/evanphx/json-patch v5.7.0+incompatible // indirect + github.com/fatih/color v1.16.0 // indirect + github.com/felixge/httpsnoop v1.0.4 // indirect github.com/go-logr/logr v1.4.1 // indirect github.com/go-openapi/jsonpointer v0.19.6 // indirect github.com/go-openapi/jsonreference v0.20.2 // indirect - github.com/go-openapi/swag v0.22.3 // indirect + github.com/go-openapi/swag v0.22.10 // indirect github.com/go-test/deep v1.0.7 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect @@ -60,12 +60,12 @@ require ( github.com/google/go-querystring v1.1.0 // indirect github.com/google/gofuzz v1.2.0 // indirect github.com/google/s2a-go v0.1.7 // indirect - github.com/google/uuid v1.5.0 // indirect + github.com/google/uuid v1.6.0 // indirect github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect github.com/googleapis/gax-go/v2 v2.12.0 // indirect github.com/gorilla/handlers v1.5.1 // indirect - github.com/gorilla/mux v1.8.0 // indirect - github.com/gorilla/websocket v1.5.0 // indirect + github.com/gorilla/mux v1.8.1 // indirect + github.com/gorilla/websocket v1.5.1 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/go-checkpoint v0.5.0 // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect @@ -89,12 +89,12 @@ require ( github.com/jmespath/go-jmespath v0.4.0 // indirect github.com/josharian/intern v1.0.0 // indirect github.com/json-iterator/go v1.1.12 // indirect - github.com/klauspost/compress v1.16.5 // indirect + github.com/klauspost/compress v1.17.7 // indirect github.com/mailru/easyjson v0.7.7 // indirect - github.com/matryer/moq v0.3.2 // indirect + github.com/matryer/moq v0.3.4 // indirect github.com/mattn/go-colorable v0.1.13 // indirect - github.com/mattn/go-isatty v0.0.19 // indirect - github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect + github.com/mattn/go-isatty v0.0.20 // indirect + github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect github.com/mitchellh/cli v1.1.5 // indirect github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db // indirect github.com/mitchellh/copystructure v1.2.0 // indirect @@ -111,23 +111,23 @@ require ( github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/posener/complete v1.2.3 // indirect - github.com/prometheus/client_golang v1.16.0 // indirect - github.com/prometheus/client_model v0.4.0 // indirect - github.com/prometheus/common v0.44.0 // indirect - github.com/prometheus/procfs v0.10.1 // indirect - github.com/rancher/aks-operator v1.2.2 // indirect - github.com/rancher/apiserver v0.0.0-20240207153744-69b3c2b56f3f // indirect - github.com/rancher/channelserver v0.6.1-0.20240212155841-07630c8295da // indirect - github.com/rancher/eks-operator v1.3.2 // indirect - github.com/rancher/fleet/pkg/apis v0.9.1-rc.2.0.20240213164401-2c6b1019687c // indirect - github.com/rancher/gke-operator v1.2.2 // indirect - github.com/rancher/lasso v0.0.0-20240123150939-7055397d6dfa // indirect - github.com/rancher/rke v1.5.11-rc1 // indirect - github.com/rancher/wrangler/v2 v2.1.4 // indirect + github.com/prometheus/client_golang v1.18.0 // indirect + github.com/prometheus/client_model v0.5.0 // indirect + github.com/prometheus/common v0.45.0 // indirect + github.com/prometheus/procfs v0.12.0 // indirect + github.com/rancher/aks-operator v1.9.0-rc.9 // indirect + github.com/rancher/apiserver v0.0.0-20240708202538-39a6f2535146 // indirect + github.com/rancher/channelserver v0.7.0 // indirect + github.com/rancher/eks-operator v1.9.0-rc.9 // indirect + github.com/rancher/fleet/pkg/apis v0.10.0-rc.19 // indirect + github.com/rancher/gke-operator v1.9.0-rc.8 // indirect + github.com/rancher/lasso v0.0.0-20240705194423-b2a060d103c1 // indirect + github.com/rancher/rke v1.6.0-rc9 // indirect + github.com/rancher/wrangler/v3 v3.0.0 // indirect github.com/shopspring/decimal v1.3.1 // indirect github.com/sirupsen/logrus v1.9.3 // indirect - github.com/spf13/afero v1.9.5 // indirect - github.com/spf13/cast v1.5.1 // indirect + github.com/spf13/afero v1.11.0 // indirect + github.com/spf13/cast v1.6.0 // indirect github.com/spf13/pflag v1.0.5 // indirect github.com/ulikunitz/xz v0.5.11 // indirect github.com/vmihailenco/msgpack/v5 v5.3.5 // indirect @@ -135,16 +135,15 @@ require ( github.com/zclconf/go-cty v1.13.0 // indirect github.com/zclconf/go-cty-yaml v1.0.2 // indirect go.opencensus.io v0.24.0 // indirect - golang.org/x/mod v0.17.0 // indirect - golang.org/x/net v0.25.0 // indirect - golang.org/x/oauth2 v0.20.0 // indirect - golang.org/x/sys v0.20.0 // indirect - golang.org/x/term v0.20.0 // indirect - golang.org/x/text v0.15.0 // indirect + golang.org/x/mod v0.19.0 // indirect + golang.org/x/net v0.27.0 // indirect + golang.org/x/oauth2 v0.21.0 // indirect + golang.org/x/sys v0.22.0 // indirect + golang.org/x/term v0.22.0 // indirect + golang.org/x/text v0.16.0 // indirect golang.org/x/time v0.5.0 // indirect - golang.org/x/tools v0.20.0 // indirect + golang.org/x/tools v0.23.0 // indirect golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect - gomodules.xyz/jsonpatch/v2 v2.3.0 // indirect google.golang.org/api v0.153.0 // indirect google.golang.org/genproto v0.0.0-20231106174013-bbf56f31fb17 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20231106174013-bbf56f31fb17 // indirect @@ -153,18 +152,16 @@ require ( google.golang.org/protobuf v1.33.0 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect - k8s.io/apiextensions-apiserver v0.28.8 // indirect - k8s.io/component-base v0.28.8 // indirect - k8s.io/gengo v0.0.0-20230306165830-ab3349d207d4 // indirect - k8s.io/klog/v2 v2.100.1 // indirect - k8s.io/kube-openapi v0.0.0-20230717233707-2695361300d9 // indirect - k8s.io/kubernetes v1.28.8 // indirect - k8s.io/utils v0.0.0-20230505201702-9f6742963106 // indirect - sigs.k8s.io/cli-utils v0.28.0 // indirect - sigs.k8s.io/cluster-api v1.5.5 // indirect - sigs.k8s.io/controller-runtime v0.15.3 // indirect + k8s.io/apiextensions-apiserver v0.30.1 // indirect + k8s.io/component-base v0.30.1 // indirect + k8s.io/klog/v2 v2.120.1 // indirect + k8s.io/kube-openapi v0.0.0-20240411171206-dc4e619f62f3 // indirect + k8s.io/kubernetes v1.30.1 // indirect + k8s.io/utils v0.0.0-20240102154912-e7106e64919e // indirect + sigs.k8s.io/cli-utils v0.35.0 // indirect + sigs.k8s.io/cluster-api v1.7.3 // indirect sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect - sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect + sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect sigs.k8s.io/yaml v1.4.0 // indirect ) @@ -172,36 +169,42 @@ replace ( github.com/crewjam/saml => github.com/crewjam/saml v0.4.5 github.com/docker/distribution => github.com/docker/distribution v2.8.1+incompatible github.com/docker/docker => github.com/docker/docker v20.10.17+incompatible - github.com/rancher/rancher/pkg/apis => github.com/rancher/rancher/pkg/apis v0.0.0-20240611034301-19a4362e2243 - github.com/rancher/rancher/pkg/client => github.com/rancher/rancher/pkg/client v0.0.0-20240611034301-19a4362e2243 + github.com/rancher/rancher/pkg/apis => github.com/rancher/rancher/pkg/apis v0.0.0-20240716141526-e0d2afd007d8 + github.com/rancher/rancher/pkg/client => github.com/rancher/rancher/pkg/client v0.0.0-20240716141526-e0d2afd007d8 github.com/spf13/afero => github.com/spf13/afero v1.2.2 - go.opentelemetry.io/otel/metric => go.opentelemetry.io/otel/metric v0.31.0 + go.opentelemetry.io/otel/metric => go.opentelemetry.io/otel/metric v1.19.0 + go.qase.io/client => github.com/rancher/qase-go/client v0.0.0-20231114201952-65195ec001fa helm.sh/helm/v3 => github.com/rancher/helm/v3 v3.9.0-rancher1 - k8s.io/api => k8s.io/api v0.28.6 - k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.28.6 - k8s.io/apimachinery => k8s.io/apimachinery v0.28.6 - k8s.io/apiserver => k8s.io/apiserver v0.28.6 - k8s.io/cli-runtime => k8s.io/cli-runtime v0.28.6 - k8s.io/client-go => github.com/rancher/client-go v1.28.6-rancher1 - k8s.io/cloud-provider => k8s.io/cloud-provider v0.28.6 - k8s.io/cluster-bootstrap => k8s.io/cluster-bootstrap v0.28.6 - k8s.io/code-generator => k8s.io/code-generator v0.28.6 - k8s.io/component-base => k8s.io/component-base v0.28.6 - k8s.io/component-helpers => k8s.io/component-helpers v0.28.6 - k8s.io/controller-manager => k8s.io/controller-manager v0.28.6 - k8s.io/cri-api => k8s.io/cri-api v0.28.6 - k8s.io/csi-translation-lib => k8s.io/csi-translation-lib v0.28.6 - k8s.io/kube-aggregator => k8s.io/kube-aggregator v0.28.6 - k8s.io/kube-controller-manager => k8s.io/kube-controller-manager v0.28.6 - k8s.io/kube-proxy => k8s.io/kube-proxy v0.28.6 - k8s.io/kube-scheduler => k8s.io/kube-scheduler v0.28.6 - k8s.io/kubectl => k8s.io/kubectl v0.28.6 - k8s.io/kubelet => k8s.io/kubelet v0.28.6 - k8s.io/kubernetes => k8s.io/kubernetes v1.28.6 - k8s.io/legacy-cloud-providers => k8s.io/legacy-cloud-providers v0.28.6 - k8s.io/metrics => k8s.io/metrics v0.28.6 - k8s.io/mount-utils => k8s.io/mount-utils v0.28.6 - k8s.io/pod-security-admission => k8s.io/pod-security-admission v0.28.6 - k8s.io/sample-apiserver => k8s.io/sample-apiserver v0.28.6 + + k8s.io/api => k8s.io/api v0.30.1 + k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.30.1 + k8s.io/apimachinery => k8s.io/apimachinery v0.30.1 + k8s.io/apiserver => k8s.io/apiserver v0.30.1 + k8s.io/cli-runtime => k8s.io/cli-runtime v0.30.1 + k8s.io/client-go => k8s.io/client-go v0.30.1 + k8s.io/cloud-provider => k8s.io/cloud-provider v0.30.1 + k8s.io/cluster-bootstrap => k8s.io/cluster-bootstrap v0.30.1 + k8s.io/code-generator => k8s.io/code-generator v0.30.1 + k8s.io/component-base => k8s.io/component-base v0.30.1 + k8s.io/component-helpers => k8s.io/component-helpers v0.30.1 + k8s.io/controller-manager => k8s.io/controller-manager v0.30.1 + k8s.io/cri-api => k8s.io/cri-api v0.30.1 + k8s.io/csi-translation-lib => k8s.io/csi-translation-lib v0.30.1 + k8s.io/dynamic-resource-allocation => k8s.io/dynamic-resource-allocation v0.30.1 + k8s.io/endpointslice => k8s.io/endpointslice v0.30.1 + k8s.io/kms => k8s.io/kms v0.30.1 + k8s.io/kube-aggregator => k8s.io/kube-aggregator v0.30.1 + k8s.io/kube-controller-manager => k8s.io/kube-controller-manager v0.30.1 + k8s.io/kube-openapi => k8s.io/kube-openapi v0.0.0-20230717233707-2695361300d9 + k8s.io/kube-proxy => k8s.io/kube-proxy v0.30.1 + k8s.io/kube-scheduler => k8s.io/kube-scheduler v0.30.1 + k8s.io/kubectl => k8s.io/kubectl v0.30.1 + k8s.io/kubelet => k8s.io/kubelet v0.30.1 + k8s.io/kubernetes => k8s.io/kubernetes v1.30.1 + k8s.io/legacy-cloud-providers => k8s.io/legacy-cloud-providers v0.30.1 + k8s.io/metrics => k8s.io/metrics v0.30.1 + k8s.io/mount-utils => k8s.io/mount-utils v0.30.1 + k8s.io/pod-security-admission => k8s.io/pod-security-admission v0.30.1 + k8s.io/sample-apiserver => k8s.io/sample-apiserver v0.30.1 launchpad.net/gocheck => github.com/go-check/check v0.0.0-20200227125254-8fa46927fb4f ) diff --git a/go.sum b/go.sum index c6875624..45e9b549 100644 --- a/go.sum +++ b/go.sum @@ -182,6 +182,8 @@ cloud.google.com/go/webrisk v1.4.0/go.mod h1:Hn8X6Zr+ziE2aNd8SliSDWpEnSS1u4R9+xX cloud.google.com/go/webrisk v1.5.0/go.mod h1:iPG6fr52Tv7sGk0H6qUFzmL3HHZev1htXuWDEEsqMTg= cloud.google.com/go/workflows v1.6.0/go.mod h1:6t9F5h/unJz41YqfBmqSASJSXccBLtD1Vwf+KmJENM0= cloud.google.com/go/workflows v1.7.0/go.mod h1:JhSrZuVZWuiDfKEFxU0/F1PQjmpnpcoISEXH2bcHC3M= +dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk= +dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= @@ -199,9 +201,11 @@ github.com/Masterminds/sprig/v3 v3.2.3 h1:eL2fZNezLomi0uOLqjQoN6BfsDD+fyLtgbJMAj github.com/Masterminds/sprig/v3 v3.2.3/go.mod h1:rXcFaZ2zZbLRJv/xSysmlgIM1u11eBaRMhvYXJNkGuM= github.com/Microsoft/go-winio v0.4.14/go.mod h1:qXqCSQ3Xa7+6tgxaGTIe4Kpcdsi+P8jBhyzoq1bpyYA= github.com/Microsoft/go-winio v0.4.16/go.mod h1:XB6nPKklQyQ7GC9LdcBEcBl8PF76WugXOPRXwdLnMv0= -github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow= -github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM= +github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY= +github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= +github.com/ProtonMail/go-crypto v1.0.0 h1:LRuvITjQWX+WIfr930YHG2HNfjR1uOfyf5vE0kC2U78= +github.com/ProtonMail/go-crypto v1.0.0/go.mod h1:EjAoLdwvbIOoOQr3ihjnSoLZRtE8azugULFRteWMNc0= github.com/agext/levenshtein v1.2.1/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= github.com/agext/levenshtein v1.2.2/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo= @@ -227,8 +231,8 @@ github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkY github.com/aws/aws-sdk-go v1.15.78/go.mod h1:E3/ieXAlvM0XWO57iftYVDLLvQ824smPP3ATZkfNZeM= github.com/aws/aws-sdk-go v1.37.0/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro= github.com/aws/aws-sdk-go v1.44.122/go.mod h1:y4AeaBuwd2Lk+GepC1E9v0qOiTws0MIWAX4oIKwKHZo= -github.com/aws/aws-sdk-go v1.49.24 h1:2ekq9ZvaoB2aRbTDfARzgVGUBB9N8XD2QYhFmTBlp+c= -github.com/aws/aws-sdk-go v1.49.24/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= +github.com/aws/aws-sdk-go v1.50.38 h1:h8wxaLin7sFGK4sKassc1VpNcDbgAAEQJ5PHjqLAvXQ= +github.com/aws/aws-sdk-go v1.50.38/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d h1:xDfNPAt8lFiC1UJrqV3uuy861HCTo708pDMbjHHdCas= @@ -249,6 +253,8 @@ github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWR github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/cloudflare/circl v1.3.7 h1:qlCDlTPz2n9fu58M0Nh1J/JzcFpfgkFHHX3O35r5vcU= +github.com/cloudflare/circl v1.3.7/go.mod h1:sRTcRWXGLrKw6yIGJ+l7amYJFfAXbZG0kBSc8r4zxgA= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= @@ -259,13 +265,17 @@ github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWH github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= +github.com/cyphar/filepath-securejoin v0.2.5 h1:6iR5tXJ/e6tJZzzdMc1km3Sa7RRIVBKAK32O2s7AYfo= +github.com/cyphar/filepath-securejoin v0.2.5/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= +github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/emicklei/go-restful/v3 v3.11.0 h1:rAQeMHw1c7zTmncogyy8VvRZwtkmkZ4FxERmMY4rD+g= github.com/emicklei/go-restful/v3 v3.11.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= -github.com/emirpasic/gods v1.12.0 h1:QAUIPSaCu4G+POclxeqb3F+WPpdKqFGlw36+yOzGlrg= github.com/emirpasic/gods v1.12.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3ymbK86o= +github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= +github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= @@ -276,47 +286,43 @@ github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.m github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0= github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.mod h1:KJwIaB5Mv44NWtYuAOFCVOjcI94vtpEz2JU/D2v6IjE= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/evanphx/json-patch v5.6.0+incompatible h1:jBYDEEiFBPxA0v50tFdvOzQQTCvpL6mnFh5mB2/l16U= -github.com/evanphx/json-patch v5.6.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= -github.com/evanphx/json-patch/v5 v5.6.0 h1:b91NhWfaz02IuVxO9faSllyAtNXHMPkC5J8sJCLunww= -github.com/evanphx/json-patch/v5 v5.6.0/go.mod h1:G79N1coSVB93tBe7j6PhzjmR3/2VvlbKOFpnXhI9Bw4= +github.com/evanphx/json-patch v5.7.0+incompatible h1:vgGkfT/9f8zE6tvSCe74nfpAVDQ2tG6yudJd8LBksgI= +github.com/evanphx/json-patch v5.7.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= -github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs= -github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw= +github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM= +github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE= github.com/felixge/httpsnoop v1.0.1/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= -github.com/felixge/httpsnoop v1.0.3 h1:s/nj+GCswXYzN5v2DpNMuMQYe+0DDwt5WVCU6CWBdXk= -github.com/felixge/httpsnoop v1.0.3/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= +github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg= +github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc= -github.com/frankban/quicktest v1.14.4 h1:g2rn0vABPOOXmZUj+vbmUp0lPoXEMuhTpIluN0XL9UY= -github.com/frankban/quicktest v1.14.4/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= -github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= -github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= +github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8= +github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/gliderlabs/ssh v0.2.2/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0= -github.com/go-git/gcfg v1.5.0 h1:Q5ViNfGF8zFgyJWPqYwA7qGFoMTEiBmdlkcfRmpIMa4= github.com/go-git/gcfg v1.5.0/go.mod h1:5m20vg6GwYabIxaOonVkTdrILxQMpEShl1xiMF4ua+E= +github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66DAb0lQFJrpS6731Oaa12ikc+DiI= +github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376/go.mod h1:an3vInlBmSxCcxctByoQdvwPiA7DTK7jaaFDBTtu0ic= github.com/go-git/go-billy/v5 v5.0.0/go.mod h1:pmpqyWchKfYfrkb/UVH4otLvyi/5gJlGI4Hb3ZqZ3W0= -github.com/go-git/go-billy/v5 v5.1.0 h1:4pl5BV4o7ZG/lterP4S6WzJ6xr49Ba5ET9ygheTYahk= github.com/go-git/go-billy/v5 v5.1.0/go.mod h1:pmpqyWchKfYfrkb/UVH4otLvyi/5gJlGI4Hb3ZqZ3W0= +github.com/go-git/go-billy/v5 v5.5.0 h1:yEY4yhzCDuMGSv83oGxiBotRzhwhNr8VZyphhiu+mTU= +github.com/go-git/go-billy/v5 v5.5.0/go.mod h1:hmexnoNsr2SJU1Ju67OaNz5ASJY3+sHgFRpCtpDCKow= github.com/go-git/go-git-fixtures/v4 v4.0.2-0.20200613231340-f56387b50c12/go.mod h1:m+ICp2rF3jDhFgEZ/8yziagdT1C+ZpZcrJjappBCDSw= -github.com/go-git/go-git/v5 v5.3.0 h1:8WKMtJR2j8RntEXR/uvTKagfEt4GYlwQ7mntE4+0GWc= github.com/go-git/go-git/v5 v5.3.0/go.mod h1:xdX4bWJ48aOrdhnl2XqHYstHbbp6+LFS4r4X+lNVprw= +github.com/go-git/go-git/v5 v5.12.0 h1:7Md+ndsjrzZxbddRDZjF14qK+NN56sy6wkqaVrjZtys= +github.com/go-git/go-git/v5 v5.12.0/go.mod h1:FTM9VKtnI2m65hNI/TenDDDnUf2Q9FHnXYjuz9i5OEY= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= -github.com/go-logr/logr v0.2.0/go.mod h1:z6/tIYblkpsD+a4lm/fGIIU9mZ+XfAiaFtq7xTgseGU= -github.com/go-logr/logr v1.2.0/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ= github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= -github.com/go-logr/zapr v1.2.4 h1:QHVo+6stLbfJmYGkQ7uGHUCu5hnAFAj6mDe6Ea0SeOo= -github.com/go-logr/zapr v1.2.4/go.mod h1:FyHWQIzQORZ0QVE1BtVHv3cKtNLuXsbNLtpuhNapBOA= github.com/go-openapi/jsonpointer v0.19.6 h1:eCs3fxoIi3Wh6vtgmLTOjdhSpiqphQ+DaPn38N2ZdrE= github.com/go-openapi/jsonpointer v0.19.6/go.mod h1:osyAmYz/mB/C3I+WsTTSgw1ONzaLJoLCyoi6/zppojs= github.com/go-openapi/jsonreference v0.20.2 h1:3sVjiK66+uXK/6oQ8xgcRKcFgQ5KXa2KvnJRumpMGbE= github.com/go-openapi/jsonreference v0.20.2/go.mod h1:Bl1zwGIM8/wsvqjsOQLJ/SH+En5Ap4rVB5KVcIDZG2k= -github.com/go-openapi/swag v0.22.3 h1:yMBqmnQ0gyZvEb/+KzuWZOXgllrXT4SADYbvDaXHv/g= github.com/go-openapi/swag v0.22.3/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14= +github.com/go-openapi/swag v0.22.10 h1:4y86NVn7Z2yYd6pfS4Z+Nyh3aAUL3Nul+LMbhFKy0gA= +github.com/go-openapi/swag v0.22.10/go.mod h1:Cnn8BYtRlx6BNE3DPN86f/xkapGIcLWzh3CLEb4C1jI= github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI= github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI= github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8= @@ -390,7 +396,6 @@ github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8= github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/gofuzz v1.1.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/martian v2.1.0+incompatible h1:/CP5g8u/VJHijgedC/Legn3BAbAaWPgecwXBIDzw5no= @@ -422,8 +427,8 @@ github.com/google/s2a-go v0.1.7/go.mod h1:50CgR4k1jNlWBu4UfS4AcfhVe1r6pdZPygJ3R8 github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.5.0 h1:1p67kYwdtXjb0gL0BPiP1Av9wiZPo5A8z2cWkTZ+eyU= -github.com/google/uuid v1.5.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/enterprise-certificate-proxy v0.0.0-20220520183353-fd19c99a87aa/go.mod h1:17drOmN3MwGY7t0e+Ei9b45FFGA3fBs3x36SsCg1hq8= github.com/googleapis/enterprise-certificate-proxy v0.1.0/go.mod h1:17drOmN3MwGY7t0e+Ei9b45FFGA3fBs3x36SsCg1hq8= github.com/googleapis/enterprise-certificate-proxy v0.2.0/go.mod h1:8C0jb7/mgJe/9KK8Lm7X9ctZC2t60YyIpYEI16jx0Qg= @@ -443,10 +448,10 @@ github.com/googleapis/gax-go/v2 v2.12.0/go.mod h1:y+aIqrI5eb1YGMVJfuV3185Ts/D7qK github.com/googleapis/go-type-adapters v1.0.0/go.mod h1:zHW75FOG2aur7gAO2B+MLby+cLsWGBF62rFAi7WjWO4= github.com/gorilla/handlers v1.5.1 h1:9lRY6j8DEeeBT10CvO9hGW0gmky0BprnvDI5vfhUHH4= github.com/gorilla/handlers v1.5.1/go.mod h1:t8XrUpc4KVXb7HGyJ4/cEnwQiaxrX/hz1Zv/4g96P1Q= -github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= -github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= -github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc= -github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY= +github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ= +github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY= +github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I= @@ -520,7 +525,6 @@ github.com/imdario/mergo v0.3.16 h1:wwQJbIsHYGMUyLSPrEq1CT16AhnhNJQ51+4fdHUnCl4= github.com/imdario/mergo v0.3.16/go.mod h1:WBLT9ZmE3lPoWsEzCh9LPo3TiwVN+ZKEjmz+hD27ysY= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= -github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c2EWnYs/m4= github.com/jhump/protoreflect v1.6.0 h1:h5jfMVslIg6l29nsMs0D8Wj17RDVdNYti0vDN/PZZoE= github.com/jhump/protoreflect v1.6.0/go.mod h1:eaTn3RZAmMBcV0fifFvlm6VHNz3wSkYyXYWUh7ymB74= @@ -535,18 +539,18 @@ github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnr github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= -github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351 h1:DowS9hvgyYSX4TO5NpyC606/Z4SxnNYbT+WX27or6Ck= github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM= +github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4= +github.com/kevinburke/ssh_config v1.2.0/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM= github.com/keybase/go-crypto v0.0.0-20161004153544-93f5b35093ba/go.mod h1:ghbZscTyKdM07+Fw3KSi0hcJm+AlEUWj8QLlPtijN/M= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/compress v1.11.2/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/klauspost/compress v1.15.11/go.mod h1:QPwzmACJjUTFsnSHH934V6woptycfrDDJnH7hvFVbGM= -github.com/klauspost/compress v1.16.5 h1:IFV2oUNUzZaz+XyusxpLzpzS8Pt5rh0Z16For/djlyI= -github.com/klauspost/compress v1.16.5/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= +github.com/klauspost/compress v1.17.7 h1:ehO88t2UGzQK66LMdE8tibEd1ErmzZjNEqWkjLAKQQg= +github.com/klauspost/compress v1.17.7/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= @@ -559,8 +563,8 @@ github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0 github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= -github.com/matryer/moq v0.3.2 h1:z7oltmpTxiQ9nKNg0Jc7z45TM+eO7OhCVohxRxwaudM= -github.com/matryer/moq v0.3.2/go.mod h1:RJ75ZZZD71hejp39j4crZLsEDszGk6iH4v4YsWFKH4s= +github.com/matryer/moq v0.3.4 h1:czCFIos9rI2tyOehN9ktc/6bQ76N9J4xQ2n3dk063ac= +github.com/matryer/moq v0.3.4/go.mod h1:wqm9QObyoMuUtH81zFfs3EK6mXEcByy+TjvSROOXJ2U= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ= github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= @@ -572,11 +576,11 @@ github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hd github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= -github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA= -github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= +github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= -github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo= -github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= +github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 h1:jWpvCLoY8Z/e3VKvlsiIGKtc+UG6U5vzxaoagmhXfyg= +github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0/go.mod h1:QUyp042oQthUoa9bqDv0ER0wrtXnBruoNd7aNjkbP+k= github.com/mitchellh/cli v1.1.2/go.mod h1:6iaV0fGdElS6dPBx0EApTxHrcWvmJphyh2n8YBLPPZ4= github.com/mitchellh/cli v1.1.5 h1:OxRIeJXpAMztws/XHlN2vu6imG5Dpq+j61AzAX5fLng= github.com/mitchellh/cli v1.1.5/go.mod h1:v8+iFts2sPIKUV1ltktPXMCC8fumSKFItNcD2cLtRR4= @@ -616,12 +620,13 @@ github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8m github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw= github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= -github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= -github.com/onsi/ginkgo/v2 v2.17.3 h1:oJcvKpIb7/8uLpDDtnQuf18xVnwKp8DTD7DQ6gTd/MU= -github.com/onsi/ginkgo/v2 v2.17.3/go.mod h1:nP2DPOQoNsQmsVyv5rDA8JkXQoCs6goXIvr/PRJ1eCc= +github.com/onsi/ginkgo/v2 v2.19.0 h1:9Cnnf7UHo57Hy3k6/m5k3dRfGTMXGvxhHFvkDTCTpvA= +github.com/onsi/ginkgo/v2 v2.19.0/go.mod h1:rlwLi9PilAFJ8jCg9UE1QP6VBpd6/xj3SRC0d6TU0To= github.com/onsi/gomega v1.33.1 h1:dsYjIxxSR755MDmKVsaFQTE22ChNBcuuTWgkUDSubOk= github.com/onsi/gomega v1.33.1/go.mod h1:U4R44UsT+9eLIaYRB2a5qajjtQYn0hauxvRm16AVYg0= github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= +github.com/pjbgf/sha1cd v0.3.0 h1:4D5XXmUUBUl/xQ6IjCkEAbqXskkq/4O7LmGn0AqMDs4= +github.com/pjbgf/sha1cd v0.3.0/go.mod h1:nZ1rrWOcGJ5uZgEEVL1VUM9iRQiZvWdbZjkKyFzPPsI= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -631,64 +636,65 @@ github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndr github.com/posener/complete v1.2.1/go.mod h1:6gapUrK/U1TAN7ciCoNRIdVC5sbdBTUh1DKN0g6uH7E= github.com/posener/complete v1.2.3 h1:NP0eAhjcjImqslEwo/1hq7gpajME0fTLTezBKDqfXqo= github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSgv7Sy7s/s= -github.com/prometheus/client_golang v1.16.0 h1:yk/hx9hDbrGHovbci4BY+pRMfSuuat626eFsHb7tmT8= -github.com/prometheus/client_golang v1.16.0/go.mod h1:Zsulrv/L9oM40tJ7T815tM89lFEugiJ9HzIqaAx4LKc= +github.com/prometheus/client_golang v1.18.0 h1:HzFfmkOzH5Q8L8G+kSJKUx5dtG87sewO+FoDDqP5Tbk= +github.com/prometheus/client_golang v1.18.0/go.mod h1:T+GXkCk5wSJyOqMIzVgvvjFDlkOQntgjkJWKrN5txjA= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/client_model v0.4.0 h1:5lQXD3cAg1OXBf4Wq03gTrXHeaV0TQvGfUooCfx1yqY= -github.com/prometheus/client_model v0.4.0/go.mod h1:oMQmHW1/JoDwqLtg57MGgP/Fb1CJEYF2imWWhWtMkYU= -github.com/prometheus/common v0.44.0 h1:+5BrQJwiBB9xsMygAB3TNvpQKOwlkc25LbISbrdOOfY= -github.com/prometheus/common v0.44.0/go.mod h1:ofAIvZbQ1e/nugmZGz4/qCb9Ap1VoSTIO7x0VV9VvuY= -github.com/prometheus/procfs v0.10.1 h1:kYK1Va/YMlutzCGazswoHKo//tZVlFpKYh+PymziUAg= -github.com/prometheus/procfs v0.10.1/go.mod h1:nwNm2aOCAYw8uTR/9bWRREkZFxAUcWzPHWJq+XBB/FM= -github.com/rancher/aks-operator v1.2.2 h1:OnIXmM+TYJPsfezs+8lfRQrwgdMh6stjrsP9KPHogfc= -github.com/rancher/aks-operator v1.2.2/go.mod h1:vNaRJh/cqPB19OrY14CaHzyGH3KmRv1k3LcAo+AdqQ4= -github.com/rancher/apiserver v0.0.0-20240207153744-69b3c2b56f3f h1:51aGoMMuPO+JsoglWmXYgA9xLWPv/bnpT0/6zErgaIU= -github.com/rancher/apiserver v0.0.0-20240207153744-69b3c2b56f3f/go.mod h1:RBcpQs/KjClGntgKCd5XcrUX5J2Rz9sW5DGEMd7H5bw= -github.com/rancher/channelserver v0.6.1-0.20240212155841-07630c8295da h1:M7p9bmFBw5kKgoBtkPXjDZTGoj94ZWt6NaTa/7jglB4= -github.com/rancher/channelserver v0.6.1-0.20240212155841-07630c8295da/go.mod h1:DuOeweH+bHP22OVq7mgQwDMVJjMmPNn8WzF1IHAU39U= -github.com/rancher/client-go v1.28.6-rancher1 h1:nSoGKs12BuPviZtzemO7wTX8jxABaLqfYKFLRBV8MI0= -github.com/rancher/client-go v1.28.6-rancher1/go.mod h1:+nu0Yp21Oeo/cBCsprNVXB2BfJTV51lFfe5tXl2rUL8= -github.com/rancher/eks-operator v1.3.2 h1:0FWtfAhcOFHYR/GA+LiVcvzQ1TsOmaluCEP6tEpeZcM= -github.com/rancher/eks-operator v1.3.2/go.mod h1:cnkOlgkrVal9XZtH6xUE/57VvP0psK4i7fwwfZINkrA= -github.com/rancher/fleet/pkg/apis v0.9.1-rc.2.0.20240213164401-2c6b1019687c h1:Oza71YDPN+jE9WY8xRVthD3MYkVYHHgsTOAxGSb9OLs= -github.com/rancher/fleet/pkg/apis v0.9.1-rc.2.0.20240213164401-2c6b1019687c/go.mod h1:KNDEr0BQU33vw4UEYR0v33HwIcyrykcI5UksJwJOmpM= -github.com/rancher/gke-operator v1.2.2 h1:bT8uijPD7lCdwkvclCh3CeuQPFj2vbZomKJpfRwTK/M= -github.com/rancher/gke-operator v1.2.2/go.mod h1:CNdldUK2fKZyN9jxhbnaTMigWA+rVZVzbnWfCvnhPJU= -github.com/rancher/lasso v0.0.0-20240123150939-7055397d6dfa h1:eRhvQJjIpPxJunlS3e1J3qTghUy9MIrMjQa2aXYSC3k= -github.com/rancher/lasso v0.0.0-20240123150939-7055397d6dfa/go.mod h1:utdskbIL7kdVvPCUFPEJQDWJwPHGFpUCRfVkX2G2Xxg= -github.com/rancher/norman v0.0.0-20240206180703-6eda4bc94b4c h1:ayqZqJ4AYYVaZGlBztLBij81z/QRsSFbQfxs9bzA+Tg= -github.com/rancher/norman v0.0.0-20240206180703-6eda4bc94b4c/go.mod h1:WbNpu/HwChwKk54W0rWBdioxYVVZwVVz//UX84m/NvY= -github.com/rancher/rancher v0.0.0-20240618132447-2145c8e9d603 h1:epA64furT74i2TEdHmjJ50V7biNyaqDPkfBWu81wK/4= -github.com/rancher/rancher v0.0.0-20240618132447-2145c8e9d603/go.mod h1:gYLd9oGi802+StsGyafR2l2Em8lHo3CK0ibxlWBOW30= -github.com/rancher/rancher/pkg/apis v0.0.0-20240611034301-19a4362e2243 h1:lDdMkc0klQ/0jA8l3QWRzKpK21nO6E4qIagaOBq2KdA= -github.com/rancher/rancher/pkg/apis v0.0.0-20240611034301-19a4362e2243/go.mod h1:5FRNHrG/G92wZ7XYKr9eFl/Sf2XqHown8CozHk+pmmU= -github.com/rancher/rancher/pkg/client v0.0.0-20240611034301-19a4362e2243 h1:QDsw8rmLzUz6qCXPf+2Bjq70jsVJgFVU6k06bOf6gIc= -github.com/rancher/rancher/pkg/client v0.0.0-20240611034301-19a4362e2243/go.mod h1:iZL8Yvm0q8mGUHJlkWUyw/1tyE+GP/1TZf/2JHo9R+A= -github.com/rancher/rke v1.5.11-rc1 h1:rggj6LNk06BMGQ8FFoMa5F+8m0/M11s2WdgqtXIzwgw= -github.com/rancher/rke v1.5.11-rc1/go.mod h1:/z9oyKqYpFwgRBV9rfLxqUdjydz/VMCTcjld4uUt7uM= -github.com/rancher/wrangler/v2 v2.1.4 h1:ohov0i6A9dJHHO6sjfsH4Dqv93ZTdm5lIJVJdPzVdQc= -github.com/rancher/wrangler/v2 v2.1.4/go.mod h1:af5OaGU/COgreQh1mRbKiUI64draT2NN34uk+PALFY8= +github.com/prometheus/client_model v0.5.0 h1:VQw1hfvPvk3Uv6Qf29VrPF32JB6rtbgI6cYPYQjL0Qw= +github.com/prometheus/client_model v0.5.0/go.mod h1:dTiFglRmd66nLR9Pv9f0mZi7B7fk5Pm3gvsjB5tr+kI= +github.com/prometheus/common v0.45.0 h1:2BGz0eBc2hdMDLnO/8n0jeB3oPrt2D08CekT0lneoxM= +github.com/prometheus/common v0.45.0/go.mod h1:YJmSTw9BoKxJplESWWxlbyttQR4uaEcGyv9MZjVOJsY= +github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo= +github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo= +github.com/rancher/aks-operator v1.9.0-rc.9 h1:6eIjtaNz40axGgSQLijMrSImnnPLuWdCGUONpChhmYA= +github.com/rancher/aks-operator v1.9.0-rc.9/go.mod h1:JPkilTHa1Exq8VILHOmcxapgHcr9RfPVm7BqjzveMXg= +github.com/rancher/apiserver v0.0.0-20240708202538-39a6f2535146 h1:6I4Z7PAGmned9+EYxbMS7kvajId3r8+ZwAR5wB7X3kg= +github.com/rancher/apiserver v0.0.0-20240708202538-39a6f2535146/go.mod h1:ZNk+LcRGwQYHqgbsJijRrI49KFbX31/QzoUBq4rAeV0= +github.com/rancher/channelserver v0.7.0 h1:ZN5o8aD4mD31uhjEEW2e9yQXa3eOb+4Cp6DcWm7W/Lc= +github.com/rancher/channelserver v0.7.0/go.mod h1:Mwd7hlMSu9X4FnZKj+0mA5ak8nTyJZtZsVX33G62Gzc= +github.com/rancher/eks-operator v1.9.0-rc.9 h1:dgKDUdBfctCTH+loKO2In8tBnbKR0pvJ6BbCEW+Unf0= +github.com/rancher/eks-operator v1.9.0-rc.9/go.mod h1:CaQyxLNMPkvznhgzlUG3+r5Ih02O0SQD0hE0ocMWqm4= +github.com/rancher/fleet/pkg/apis v0.10.0-rc.19 h1:/FIucfmJo78c6D52/DEONU+P2DGq867fNHsDCw31hE4= +github.com/rancher/fleet/pkg/apis v0.10.0-rc.19/go.mod h1:YmVQ8UKVM1uBgQhCKXABE0ic8p0XwPK5qmaY2UlrMj0= +github.com/rancher/gke-operator v1.9.0-rc.8 h1:KqeRL9OfjsH0jRl8cw8V5Vs2j6rPVP1uGCHcaaNXRB8= +github.com/rancher/gke-operator v1.9.0-rc.8/go.mod h1:ga8AIreFbeHyH4CZVjCpEgCzo3InS+LhAVhU6jWyDNo= +github.com/rancher/lasso v0.0.0-20240705194423-b2a060d103c1 h1:vv1jDlYbd4KhGbPNxmjs8CYgEHUrQm2bMtmULfXJ6iw= +github.com/rancher/lasso v0.0.0-20240705194423-b2a060d103c1/go.mod h1:A/y3BLQkxZXYD60MNDRwAG9WGxXfvd6Z6gWR/a8wPw8= +github.com/rancher/norman v0.0.0-20240708202514-a0127673d1b9 h1:AlRMRs5mHJcdiK83KKJyFVeybPMZ7dOUzC0l3k9aUa8= +github.com/rancher/norman v0.0.0-20240708202514-a0127673d1b9/go.mod h1:dyjfXBsNiroPWOdUZe7diUOUSLf6HQ/r2kEpwH/8zas= +github.com/rancher/rancher v0.0.0-20240716141526-e0d2afd007d8 h1:isft3hbGlfYJaM5oCRF33MPuFeq9qVCBQo9IA5wOfXE= +github.com/rancher/rancher v0.0.0-20240716141526-e0d2afd007d8/go.mod h1:k2aAbIqTi/nSYuSqUGYTZLOOQ6zCEKfbx9sKHkkU8S8= +github.com/rancher/rancher/pkg/apis v0.0.0-20240716141526-e0d2afd007d8 h1:fSlV+/76dHQ1x0CZXc+HWcPSUSuuUNrcfDxTfMWoM8A= +github.com/rancher/rancher/pkg/apis v0.0.0-20240716141526-e0d2afd007d8/go.mod h1:5ET3XVIcWarzwEl0uSCwBgkPx84zYv755akuHfWht18= +github.com/rancher/rancher/pkg/client v0.0.0-20240716141526-e0d2afd007d8 h1:QOWC6pSLFvhEFtydXLCyDn7nU2bJT2b5KCmBRDYRQwI= +github.com/rancher/rancher/pkg/client v0.0.0-20240716141526-e0d2afd007d8/go.mod h1:A+DTKG05BZs1mOoCIB6UpiKo7j0dC6kSz3mgYju9Q20= +github.com/rancher/rke v1.6.0-rc9 h1:P8EVV4hl3cG8CHDuFUEfqFK8sC92aLoemFzmeFQOCck= +github.com/rancher/rke v1.6.0-rc9/go.mod h1:5xRbf3L8PxqJRhABjYRfaBqbpVqAnqyH3maUNQEuwvk= +github.com/rancher/wrangler/v3 v3.0.0 h1:IHHCA+vrghJDPxjtLk4fmeSCFhNe9fFzLFj3m2B0YpA= +github.com/rancher/wrangler/v3 v3.0.0/go.mod h1:Dfckuuq7MJk2JWVBDywRlZXMxEyPxHy4XqGrPEzu5Eg= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= -github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= -github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA= +github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= +github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= github.com/sebdah/goldie v1.0.0/go.mod h1:jXP4hmWywNEwZzhMuv2ccnqTSFpuq8iyQhtQdkkZBH4= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= -github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ= github.com/sergi/go-diff v1.2.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= +github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 h1:n661drycOFuPLCN3Uc8sB6B/s6Z4t2xvBgU1htSHuq8= +github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3/go.mod h1:A0bzQcvG0E7Rwjx0REVgAGH58e96+X0MeOfepqsbeW4= github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8= github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= +github.com/skeema/knownhosts v1.2.2 h1:Iug2P4fLmDw9f41PB6thxUkNUkJzB5i+1/exaj40L3A= +github.com/skeema/knownhosts v1.2.2/go.mod h1:xYbVRSPxqBZFrdmDyMmsOs+uX1UZC3nTN3ThzgDxUwo= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spf13/afero v1.2.2 h1:5jhuqJyZCZf2JRofRvN/nIFgIWNzPa3/Vz8mYylgbWc= github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= -github.com/spf13/cast v1.5.1 h1:R+kOtfhWQE6TVQzY+4D7wJLBgkdVasCEFxSUBYBYIlA= -github.com/spf13/cast v1.5.1/go.mod h1:b9PdjNptOpzXr7Rq1q9gJML/2cdGQAo69NKzQ10KN48= +github.com/spf13/cast v1.6.0 h1:GEiTHELF+vaR5dhz3VqZfFSzZjYbgeKDpBxQVS4GYJ0= +github.com/spf13/cast v1.6.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo= github.com/spf13/pflag v1.0.2/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= @@ -706,8 +712,8 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/ulikunitz/xz v0.5.8/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= github.com/ulikunitz/xz v0.5.10/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= github.com/ulikunitz/xz v0.5.11 h1:kpFauv27b6ynzBNT/Xy+1k+fK4WswhN/6PN5WhFAGw8= @@ -719,8 +725,9 @@ github.com/vmihailenco/msgpack/v5 v5.3.5/go.mod h1:7xyJ9e+0+9SaZT0Wt1RGleJXzli6Q github.com/vmihailenco/tagparser v0.1.1/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI= github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g= github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds= -github.com/xanzy/ssh-agent v0.3.0 h1:wUMzuKtKilRgBAD1sUb8gOwwRr2FGoBVumcjoOACClI= github.com/xanzy/ssh-agent v0.3.0/go.mod h1:3s9xbODqPuuhK9JV1R321M/FlMZSBvE5aY6eAcqrDh0= +github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM= +github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= @@ -749,14 +756,6 @@ go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0= go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo= go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= -go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE= -go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= -go.uber.org/goleak v1.2.1 h1:NBol2c7O1ZokfZ0LEU9K6Whx/KnwvepVetCUhtKja4A= -go.uber.org/goleak v1.2.1/go.mod h1:qlT2yGI9QafXHhZZLxlSuNsMw3FFLxBr+tBRlmO1xH4= -go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= -go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= -go.uber.org/zap v1.24.0 h1:FiJd5l1UOLj0wCgbSE0rwwXHzEdAZS6hiiSnxJN/D60= -go.uber.org/zap v1.24.0/go.mod h1:2kMP+WWQ8aoFoedH3T2sq6iJ2yDWpHbP0f6MQbS9Gkg= golang.org/x/crypto v0.0.0-20190219172222-a4c6cb3142f2/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190426145343-a29dc8fdc734/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= @@ -769,8 +768,8 @@ golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.3.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= -golang.org/x/crypto v0.23.0 h1:dIJU/v2J8Mdglj/8rJ6UUOM3Zc9zLZxVZwwxMooUSAI= -golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8= +golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30= +golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -807,8 +806,8 @@ golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA= -golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/mod v0.19.0 h1:fEdghXQSo20giMthA7cd28ZC+jts4amQ3YMXiP5oMQ8= +golang.org/x/mod v0.19.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20180530234432-1e491301e022/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180811021610-c39426892332/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -861,8 +860,8 @@ golang.org/x/net v0.0.0-20220909164309-bea034e7d591/go.mod h1:YDH+HFinaLZZlnHAfS golang.org/x/net v0.0.0-20221014081412-f15817d10f9b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= -golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac= -golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM= +golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= +golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -888,8 +887,8 @@ golang.org/x/oauth2 v0.0.0-20220822191816-0ebed06d0094/go.mod h1:h4gKUeWbJ4rQPri golang.org/x/oauth2 v0.0.0-20220909003341-f21342109be1/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg= golang.org/x/oauth2 v0.0.0-20221014153046-6fdb5e3db783/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg= golang.org/x/oauth2 v0.1.0/go.mod h1:G9FE4dLTsbXUu90h/Pf85g4w1D+SSAgR+q46nJZ8M4A= -golang.org/x/oauth2 v0.20.0 h1:4mQdhULixXKP1rwYBW0vAijoXnkTG0BLCDRzfe1idMo= -golang.org/x/oauth2 v0.20.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= +golang.org/x/oauth2 v0.21.0 h1:tsimM75w1tF/uws5rbeHzIWxEqElMehnc+iW793zsZs= +golang.org/x/oauth2 v0.21.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -976,18 +975,17 @@ golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y= -golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= +golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= -golang.org/x/term v0.20.0 h1:VnkxpohqXaOBYJtBmEppKUG6mXpi+4O6purfc2+sMhw= -golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY= +golang.org/x/term v0.22.0 h1:BbsgPEJULsl2fV/AT3v15Mjva5yXKQDyKf+TbDz7QJk= +golang.org/x/term v0.22.0/go.mod h1:F3qCibpT5AMpCRfhfT53vVJwhLtIVHhB9XDjfFvnMI4= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -998,8 +996,8 @@ golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk= -golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= +golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -1039,7 +1037,6 @@ golang.org/x/tools v0.0.0-20200304193943-95d2e580d8eb/go.mod h1:o4KQGtdN14AW+yjs golang.org/x/tools v0.0.0-20200312045724-11d5b4c81c7d/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= golang.org/x/tools v0.0.0-20200331025713-a30bf2db82d4/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8= golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200505023115-26f46d2f7ef8/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= @@ -1061,8 +1058,8 @@ golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.20.0 h1:hz/CVckiOxybQvFw6h7b/q80NTr9IUQb4s1IIzW7KNY= -golang.org/x/tools v0.20.0/go.mod h1:WvitBU7JJf6A4jOdg4S1tviW9bhUxkgeCui/0JHctQg= +golang.org/x/tools v0.23.0 h1:SGsXPZ+2l4JsgaCKkx+FQ9YZ5XEtA1GZYuoDjenLjvg= +golang.org/x/tools v0.23.0/go.mod h1:pnu6ufv6vQkll6szChhK3C3L/ruaIv5eBeztNG8wtsI= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -1072,8 +1069,6 @@ golang.org/x/xerrors v0.0.0-20220517211312-f3a8303e98df/go.mod h1:K8+ghG5WaK9qNq golang.org/x/xerrors v0.0.0-20220609144429-65e65417b02f/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 h1:H2TDz8ibqkAF6YGhCdN3jS9O0/s90v0rJh3X/OLHEUk= golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= -gomodules.xyz/jsonpatch/v2 v2.3.0 h1:8NFhfS6gzxNqjLIYnZxg319wZ5Qjnx4m/CcX+Klzazc= -gomodules.xyz/jsonpatch/v2 v2.3.0/go.mod h1:AH3dM2RI6uoBZxn3LVrfvJ3E0/9dG4cSrbuBJT4moAY= google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= @@ -1326,40 +1321,36 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= -k8s.io/api v0.28.6 h1:yy6u9CuIhmg55YvF/BavPBBXB+5QicB64njJXxVnzLo= -k8s.io/api v0.28.6/go.mod h1:AM6Ys6g9MY3dl/XNaNfg/GePI0FT7WBGu8efU/lirAo= -k8s.io/apiextensions-apiserver v0.28.6 h1:myB3iG/3v3jqCg28JDbOefu4sH2/erNEXgytRzJKBOo= -k8s.io/apiextensions-apiserver v0.28.6/go.mod h1:qlp6xRKBgyRhe5AYc81TQpLx4kLNK8/sGQUOwMkVjRk= -k8s.io/apimachinery v0.28.6 h1:RsTeR4z6S07srPg6XYrwXpTJVMXsjPXn0ODakMytSW0= -k8s.io/apimachinery v0.28.6/go.mod h1:QFNX/kCl/EMT2WTSz8k4WLCv2XnkOLMaL8GAVRMdpsA= -k8s.io/apiserver v0.28.6 h1:SfS5v4I5UGvh0q/1rzvNwLFsK+r7YzcsixnUc0NwoEk= -k8s.io/apiserver v0.28.6/go.mod h1:8n0aerS3kPm9usyB8B+an6/BZ5+Fa9fNqlASFdDDVwk= -k8s.io/component-base v0.28.6 h1:G4T8VrcQ7xZou3by/fY5NU5mfxOBlWaivS2lPrEltAo= -k8s.io/component-base v0.28.6/go.mod h1:Dg62OOG3ALu2P4nAG00UdsuHoNLQJ5VsUZKQlLDcS+E= -k8s.io/gengo v0.0.0-20230306165830-ab3349d207d4 h1:aClvVG6GbX10ISHcc24J+tqbr0S7fEe1MWkFJ7cWWCI= -k8s.io/gengo v0.0.0-20230306165830-ab3349d207d4/go.mod h1:FiNAH4ZV3gBg2Kwh89tzAEV2be7d5xI0vBa/VySYy3E= -k8s.io/klog/v2 v2.2.0/go.mod h1:Od+F08eJP+W3HUb4pSrPpgp9DGU4GzlpG/TmITuYh/Y= -k8s.io/klog/v2 v2.100.1 h1:7WCHKK6K8fNhTqfBhISHQ97KrnJNFZMcQvKp7gP/tmg= -k8s.io/klog/v2 v2.100.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0= +k8s.io/api v0.30.1 h1:kCm/6mADMdbAxmIh0LBjS54nQBE+U4KmbCfIkF5CpJY= +k8s.io/api v0.30.1/go.mod h1:ddbN2C0+0DIiPntan/bye3SW3PdwLa11/0yqwvuRrJM= +k8s.io/apiextensions-apiserver v0.30.1 h1:4fAJZ9985BmpJG6PkoxVRpXv9vmPUOVzl614xarePws= +k8s.io/apiextensions-apiserver v0.30.1/go.mod h1:R4GuSrlhgq43oRY9sF2IToFh7PVlF1JjfWdoG3pixk4= +k8s.io/apimachinery v0.30.1 h1:ZQStsEfo4n65yAdlGTfP/uSHMQSoYzU/oeEbkmF7P2U= +k8s.io/apimachinery v0.30.1/go.mod h1:iexa2somDaxdnj7bha06bhb43Zpa6eWH8N8dbqVjTUc= +k8s.io/apiserver v0.30.1 h1:BEWEe8bzS12nMtDKXzCF5Q5ovp6LjjYkSp8qOPk8LZ8= +k8s.io/apiserver v0.30.1/go.mod h1:i87ZnQ+/PGAmSbD/iEKM68bm1D5reX8fO4Ito4B01mo= +k8s.io/client-go v0.30.1 h1:uC/Ir6A3R46wdkgCV3vbLyNOYyCJ8oZnjtJGKfytl/Q= +k8s.io/client-go v0.30.1/go.mod h1:wrAqLNs2trwiCH/wxxmT/x3hKVH9PuV0GGW0oDoHVqc= +k8s.io/component-base v0.30.1 h1:bvAtlPh1UrdaZL20D9+sWxsJljMi0QZ3Lmw+kmZAaxQ= +k8s.io/component-base v0.30.1/go.mod h1:e/X9kDiOebwlI41AvBHuWdqFriSRrX50CdwA9TFaHLI= +k8s.io/klog/v2 v2.120.1 h1:QXU6cPEOIslTGvZaXvFWiP9VKyeet3sawzTOvdXb4Vw= +k8s.io/klog/v2 v2.120.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= k8s.io/kube-openapi v0.0.0-20230717233707-2695361300d9 h1:LyMgNKD2P8Wn1iAwQU5OhxCKlKJy0sHc+PcDwFB24dQ= k8s.io/kube-openapi v0.0.0-20230717233707-2695361300d9/go.mod h1:wZK2AVp1uHCp4VamDVgBP2COHZjqD1T68Rf0CM3YjSM= -k8s.io/kubernetes v1.28.6 h1:Nn2fXNjaqmKyXeFq6verbdqzlj1aqUpBcyeC1OhRFa4= -k8s.io/kubernetes v1.28.6/go.mod h1:0qpyGJTR3blkbQOmZA3Z0u1VDZJNxJM8ifLUVNJN0X8= -k8s.io/utils v0.0.0-20230505201702-9f6742963106 h1:EObNQ3TW2D+WptiYXlApGNLVy0zm/JIBVY9i+M4wpAU= -k8s.io/utils v0.0.0-20230505201702-9f6742963106/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= +k8s.io/kubernetes v1.30.1 h1:XlqS6KslLEA5mQzLK2AJrhr4Z1m8oJfkhHiWJ5lue+I= +k8s.io/kubernetes v1.30.1/go.mod h1:yPbIk3MhmhGigX62FLJm+CphNtjxqCvAIFQXup6RKS0= +k8s.io/utils v0.0.0-20240102154912-e7106e64919e h1:eQ/4ljkx21sObifjzXwlPKpdGLrCfRziVtos3ofG/sQ= +k8s.io/utils v0.0.0-20240102154912-e7106e64919e/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= -sigs.k8s.io/cli-utils v0.28.0 h1:gsvwqygoXlW2y8CmKdflQJNZp1Yhi4geATW3/Ei7oYc= -sigs.k8s.io/cli-utils v0.28.0/go.mod h1:WDVRa5/eQBKntG++uyKdyT+xU7MLdCR4XsgseqL5uX4= -sigs.k8s.io/cluster-api v1.5.5 h1:MmxTGE8bJvALrJzzuTA2YEP+qKPrpxg7u8AecU93fwc= -sigs.k8s.io/cluster-api v1.5.5/go.mod h1:T50/vFznHz409V1XS74DIiPl9JDH4r2+xHiCYpYRTmc= -sigs.k8s.io/controller-runtime v0.15.3 h1:L+t5heIaI3zeejoIyyvLQs5vTVu/67IU2FfisVzFlBc= -sigs.k8s.io/controller-runtime v0.15.3/go.mod h1:kp4jckA4vTx281S/0Yk2LFEEQe67mjg+ev/yknv47Ds= +sigs.k8s.io/cli-utils v0.35.0 h1:dfSJaF1W0frW74PtjwiyoB4cwdRygbHnC7qe7HF0g/Y= +sigs.k8s.io/cli-utils v0.35.0/go.mod h1:ITitykCJxP1vaj1Cew/FZEaVJ2YsTN9Q71m02jebkoE= +sigs.k8s.io/cluster-api v1.7.3 h1:DsSRxsA+18jxLqPAo29abZ9kOPK1/xwhSuQb/MROzSs= +sigs.k8s.io/cluster-api v1.7.3/go.mod h1:V9ZhKLvQtsDODwjXOKgbitjyCmC71yMBwDcMyNNIov0= sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo= sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0= -sigs.k8s.io/structured-merge-diff/v4 v4.2.3 h1:PRbqxJClWWYMNV1dhaG4NsibJbArud9kFxnAMREiWFE= -sigs.k8s.io/structured-merge-diff/v4 v4.2.3/go.mod h1:qjx8mGObPmV2aSZepjQjbmb2ihdVs8cGKBraizNC69E= -sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc= +sigs.k8s.io/structured-merge-diff/v4 v4.4.1 h1:150L+0vs/8DA78h1u02ooW1/fFq/Lwr+sGiqlzvrtq4= +sigs.k8s.io/structured-merge-diff/v4 v4.4.1/go.mod h1:N8hJocpFajUSSeSJ9bOZ77VzejKZaXsTtZo4/u7Io08= sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E= sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY= diff --git a/rancher2/0_provider_upgrade_test.go b/rancher2/0_provider_upgrade_test.go index 66cdd7e4..10aa6f62 100644 --- a/rancher2/0_provider_upgrade_test.go +++ b/rancher2/0_provider_upgrade_test.go @@ -108,8 +108,6 @@ provider "rancher2" { ` + testAccRancher2CloudCredentialConfigOpenstack + ` ` + testAccRancher2CloudCredentialConfigVsphere + ` ` + testAccRancher2ClusterConfigRKE + ` -` + testAccRancher2ClusterAlertGroup + ` -` + testAccRancher2ClusterAlertRule + ` ` + testAccRancher2ClusterDriver + ` ` + testAccRancher2User + ` ` + testAccRancher2ClusterRoleTemplateBinding + ` @@ -130,14 +128,6 @@ provider "rancher2" { ` + testAccRancher2NodeTemplateOpennebulaConfig + ` ` + testAccRancher2NodeTemplateOpenstack + ` ` + testAccRancher2NodeTemplateVsphere + ` -` + testAccRancher2NotifierPagerduty + ` -` + testAccRancher2NotifierSlack + ` -` + testAccRancher2NotifierSMTP + ` -` + testAccRancher2NotifierWebhook + ` -` + testAccRancher2NotifierWechat + ` -` + testAccCheckRancher2PodSecurityPolicyTemplate + ` -` + testAccRancher2ProjectAlertGroupConfig + ` -` + testAccRancher2ProjectAlertRule + ` ` + testAccRancher2ProjectRoleTemplateBinding + ` ` + testAccRancher2Project + ` ` + testAccRancher2Registry + ` @@ -159,8 +149,6 @@ provider "rancher2" { ` + testAccRancher2CloudCredentialConfigOpenstack + ` ` + testAccRancher2CloudCredentialConfigVsphere + ` ` + testAccRancher2ClusterConfigRKE + ` -` + testAccRancher2ClusterAlertGroup + ` -` + testAccRancher2ClusterAlertRule + ` ` + testAccRancher2ClusterDriver + ` ` + testAccRancher2User + ` ` + testAccRancher2ClusterRoleTemplateBinding + ` @@ -181,16 +169,6 @@ provider "rancher2" { ` + testAccRancher2NodeTemplateOpennebulaConfig + ` ` + testAccRancher2NodeTemplateOpenstack + ` ` + testAccRancher2NodeTemplateVsphere + ` -` + testAccRancher2NotifierDingtalk + ` -` + testAccRancher2NotifierMSTeams + ` -` + testAccRancher2NotifierPagerduty + ` -` + testAccRancher2NotifierSlack + ` -` + testAccRancher2NotifierSMTP + ` -` + testAccRancher2NotifierWebhook + ` -` + testAccRancher2NotifierWechat + ` -` + testAccCheckRancher2PodSecurityPolicyTemplate + ` -` + testAccRancher2ProjectAlertGroupConfig + ` -` + testAccRancher2ProjectAlertRule + ` ` + testAccRancher2ProjectRoleTemplateBinding + ` ` + testAccRancher2Project + ` ` + testAccRancher2Registry + ` @@ -214,8 +192,6 @@ provider "rancher2" { ` + testAccRancher2CloudCredentialConfigOpenstack + ` ` + testAccRancher2CloudCredentialConfigVsphere + ` ` + testAccRancher2ClusterConfigRKE + ` -` + testAccRancher2ClusterAlertGroup + ` -` + testAccRancher2ClusterAlertRule + ` ` + testAccRancher2ClusterDriver + ` ` + testAccRancher2ConfigMapV2 + ` ` + testAccRancher2User + ` @@ -238,16 +214,6 @@ provider "rancher2" { ` + testAccRancher2NodeTemplateOpennebulaConfig + ` ` + testAccRancher2NodeTemplateOpenstack + ` ` + testAccRancher2NodeTemplateVsphere + ` -` + testAccRancher2NotifierDingtalk + ` -` + testAccRancher2NotifierMSTeams + ` -` + testAccRancher2NotifierPagerduty + ` -` + testAccRancher2NotifierSlack + ` -` + testAccRancher2NotifierSMTP + ` -` + testAccRancher2NotifierWebhook + ` -` + testAccRancher2NotifierWechat + ` -` + testAccCheckRancher2PodSecurityPolicyTemplate + ` -` + testAccRancher2ProjectAlertGroupConfig + ` -` + testAccRancher2ProjectAlertRule + ` ` + testAccRancher2ProjectRoleTemplateBinding + ` ` + testAccRancher2Project + ` ` + testAccRancher2Registry + ` @@ -274,8 +240,6 @@ provider "rancher2" { ` + testAccRancher2CloudCredentialConfigS3 + ` ` + testAccRancher2CloudCredentialConfigVsphere + ` ` + testAccRancher2ClusterConfigRKE + ` -` + testAccRancher2ClusterAlertGroup + ` -` + testAccRancher2ClusterAlertRule + ` ` + testAccRancher2ClusterDriver + ` ` + testAccRancher2ClusterV2 + ` ` + testAccRancher2ConfigMapV2 + ` @@ -299,16 +263,6 @@ provider "rancher2" { ` + testAccRancher2NodeTemplateOpennebulaConfig + ` ` + testAccRancher2NodeTemplateOpenstack + ` ` + testAccRancher2NodeTemplateVsphere + ` -` + testAccRancher2NotifierDingtalk + ` -` + testAccRancher2NotifierMSTeams + ` -` + testAccRancher2NotifierPagerduty + ` -` + testAccRancher2NotifierSlack + ` -` + testAccRancher2NotifierSMTP + ` -` + testAccRancher2NotifierWebhook + ` -` + testAccRancher2NotifierWechat + ` -` + testAccCheckRancher2PodSecurityPolicyTemplate + ` -` + testAccRancher2ProjectAlertGroupConfig + ` -` + testAccRancher2ProjectAlertRule + ` ` + testAccRancher2ProjectRoleTemplateBinding + ` ` + testAccRancher2Project + ` ` + testAccRancher2Registry + ` diff --git a/rancher2/config.go b/rancher2/config.go index dd09e562..cf815757 100644 --- a/rancher2/config.go +++ b/rancher2/config.go @@ -909,14 +909,6 @@ func (c *Config) isClusterConnected(id string) (bool, *managementClient.Cluster, return c.checkClusterCondition(id, clusterConnectedCondition) } -func (c *Config) isClusterMonitoringEnabledCondition(id string) (bool, *managementClient.Cluster, error) { - return c.checkClusterCondition(id, clusterMonitoringEnabledCondition) -} - -func (c *Config) isClusterAlertingEnabledCondition(id string) (bool, *managementClient.Cluster, error) { - return c.checkClusterCondition(id, clusterAlertingEnabledCondition) -} - func (c *Config) ClusterExist(id string) error { _, err := c.GetClusterByID(id) if err != nil { @@ -1835,45 +1827,3 @@ func (c *Config) DeleteCertificate(cert interface{}) error { return fmt.Errorf("[ERROR] Certificate type %s isn't supported", t) } } - -func (c *Config) GetRecipientByNotifier(id string) (*managementClient.Recipient, error) { - if len(id) == 0 { - return nil, fmt.Errorf("[ERROR] Notifier ID can't be nil") - } - - client, err := c.ManagementClient() - if err != nil { - return nil, err - } - - notifier, err := client.Notifier.ByID(id) - if err != nil { - return nil, err - } - - out := &managementClient.Recipient{} - - out.NotifierID = notifier.ID - if notifier.DingtalkConfig != nil { - out.NotifierType = recipientTypeDingtalk - } else if notifier.MSTeamsConfig != nil { - out.NotifierType = recipientTypeMsTeams - } else if notifier.PagerdutyConfig != nil { - out.NotifierType = recipientTypePagerduty - out.Recipient = notifier.PagerdutyConfig.ServiceKey - } else if notifier.SlackConfig != nil { - out.NotifierType = recipientTypeSlack - out.Recipient = notifier.SlackConfig.DefaultRecipient - } else if notifier.SMTPConfig != nil { - out.NotifierType = recipientTypeSMTP - out.Recipient = notifier.SMTPConfig.DefaultRecipient - } else if notifier.WebhookConfig != nil { - out.NotifierType = recipientTypeWebhook - out.Recipient = notifier.WebhookConfig.URL - } else if notifier.WechatConfig != nil { - out.NotifierType = recipientTypeWechat - out.Recipient = notifier.WechatConfig.DefaultRecipient - } - - return out, nil -} diff --git a/rancher2/data_source_rancher2_cluster.go b/rancher2/data_source_rancher2_cluster.go index e2765f38..2976ddb0 100644 --- a/rancher2/data_source_rancher2_cluster.go +++ b/rancher2/data_source_rancher2_cluster.go @@ -136,15 +136,6 @@ func dataSourceRancher2Cluster() *schema.Resource { Schema: clusterAuthEndpoint(), }, }, - "cluster_monitoring_input": { - Type: schema.TypeList, - MaxItems: 1, - Computed: true, - Description: "Cluster monitoring configuration", - Elem: &schema.Resource{ - Schema: monitoringInputFields(), - }, - }, "cluster_registration_token": { Type: schema.TypeList, MaxItems: 1, @@ -180,27 +171,12 @@ func dataSourceRancher2Cluster() *schema.Resource { Computed: true, Description: "Cluster template revision ID", }, - "default_pod_security_policy_template_id": { - Type: schema.TypeString, - Computed: true, - Description: "Default pod security policy template ID", - }, "default_pod_security_admission_configuration_template_name": { Type: schema.TypeString, Optional: true, Computed: true, Description: "Default pod security admission configuration template name", }, - "enable_cluster_alerting": { - Type: schema.TypeBool, - Computed: true, - Description: "Enable built-in cluster alerting", - }, - "enable_cluster_monitoring": { - Type: schema.TypeBool, - Computed: true, - Description: "Enable built-in cluster monitoring", - }, "enable_network_policy": { Type: schema.TypeBool, Computed: true, diff --git a/rancher2/data_source_rancher2_cluster_alert_group.go b/rancher2/data_source_rancher2_cluster_alert_group.go deleted file mode 100644 index c415c0f6..00000000 --- a/rancher2/data_source_rancher2_cluster_alert_group.go +++ /dev/null @@ -1,93 +0,0 @@ -package rancher2 - -import ( - "fmt" - - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" -) - -func dataSourceRancher2ClusterAlertGroup() *schema.Resource { - return &schema.Resource{ - Read: dataSourceRancher2ClusterAlertGroupRead, - - Schema: map[string]*schema.Schema{ - "cluster_id": { - Type: schema.TypeString, - Required: true, - Description: "Alert group cluster ID", - }, - "name": { - Type: schema.TypeString, - Required: true, - Description: "Alert group name", - }, - "description": { - Type: schema.TypeString, - Computed: true, - Description: "Alert group description", - }, - "group_interval_seconds": { - Type: schema.TypeInt, - Computed: true, - Description: "Alert group interval seconds", - }, - "group_wait_seconds": { - Type: schema.TypeInt, - Computed: true, - Description: "Alert group wait seconds", - }, - "recipients": { - Type: schema.TypeList, - Computed: true, - Description: "Alert group recipients", - Elem: &schema.Resource{ - Schema: recipientFields(), - }, - }, - "repeat_interval_seconds": { - Type: schema.TypeInt, - Computed: true, - Description: "Alert group repeat interval seconds", - }, - "annotations": { - Type: schema.TypeMap, - Computed: true, - }, - "labels": { - Type: schema.TypeMap, - Computed: true, - }, - }, - } -} - -func dataSourceRancher2ClusterAlertGroupRead(d *schema.ResourceData, meta interface{}) error { - client, err := meta.(*Config).ManagementClient() - if err != nil { - return err - } - - clusterID := d.Get("cluster_id").(string) - name := d.Get("name").(string) - - filters := map[string]interface{}{ - "clusterId": clusterID, - "name": name, - } - listOpts := NewListOpts(filters) - - alertGroups, err := client.ClusterAlertGroup.List(listOpts) - if err != nil { - return err - } - - count := len(alertGroups.Data) - if count <= 0 { - return fmt.Errorf("[ERROR] cluster alert group with name \"%s\" on cluster ID \"%s\" not found", name, clusterID) - } - if count > 1 { - return fmt.Errorf("[ERROR] found %d cluster alert group with name \"%s\" on cluster ID \"%s\"", count, name, clusterID) - } - - return flattenClusterAlertGroup(d, &alertGroups.Data[0]) -} diff --git a/rancher2/data_source_rancher2_cluster_alert_group_test.go b/rancher2/data_source_rancher2_cluster_alert_group_test.go deleted file mode 100644 index 8359f194..00000000 --- a/rancher2/data_source_rancher2_cluster_alert_group_test.go +++ /dev/null @@ -1,31 +0,0 @@ -package rancher2 - -import ( - "testing" - - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" -) - -func TestAccRancher2ClusterAlertGroupDataSource(t *testing.T) { - testAccCheckRancher2ClusterAlertGroupDataSourceConfig := testAccRancher2ClusterAlertGroupConfig + ` -data "` + testAccRancher2ClusterAlertGroupType + `" "foo" { - cluster_id = rancher2_cluster_alert_group.foo.cluster_id - name = rancher2_cluster_alert_group.foo.name -} -` - name := "data." + testAccRancher2ClusterAlertGroupType + ".foo" - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - Steps: []resource.TestStep{ - { - Config: testAccCheckRancher2ClusterAlertGroupDataSourceConfig, - Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr(name, "name", "foo"), - resource.TestCheckResourceAttr(name, "description", "Terraform cluster alert group acceptance test"), - resource.TestCheckResourceAttr(name, "group_interval_seconds", "300"), - ), - }, - }, - }) -} diff --git a/rancher2/data_source_rancher2_cluster_alert_rule.go b/rancher2/data_source_rancher2_cluster_alert_rule.go deleted file mode 100644 index 07ec6a1b..00000000 --- a/rancher2/data_source_rancher2_cluster_alert_rule.go +++ /dev/null @@ -1,131 +0,0 @@ -package rancher2 - -import ( - "fmt" - - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" -) - -func dataSourceRancher2ClusterAlertRule() *schema.Resource { - return &schema.Resource{ - Read: dataSourceRancher2ClusterAlertRuleRead, - - Schema: map[string]*schema.Schema{ - "cluster_id": { - Type: schema.TypeString, - Required: true, - Description: "Alert rule cluster ID", - }, - "name": { - Type: schema.TypeString, - Required: true, - Description: "Alert rule name", - }, - "event_rule": { - Type: schema.TypeList, - MaxItems: 1, - Computed: true, - Elem: &schema.Resource{ - Schema: eventRuleFields(), - }, - Description: "Alert event rule", - }, - "metric_rule": { - Type: schema.TypeList, - MaxItems: 1, - Computed: true, - Elem: &schema.Resource{ - Schema: metricRuleFields(), - }, - Description: "Alert metric rule", - }, - "node_rule": { - Type: schema.TypeList, - MaxItems: 1, - Computed: true, - Elem: &schema.Resource{ - Schema: nodeRuleFields(), - }, - Description: "Alert node rule", - }, - "system_service_rule": { - Type: schema.TypeList, - MaxItems: 1, - Computed: true, - Elem: &schema.Resource{ - Schema: systemServiceRuleFields(), - }, - Description: "Alert system service rule", - }, - "group_id": { - Type: schema.TypeString, - Computed: true, - Description: "Alert rule group ID", - }, - "group_interval_seconds": { - Type: schema.TypeInt, - Computed: true, - Description: "Alert rule interval seconds", - }, - "group_wait_seconds": { - Type: schema.TypeInt, - Computed: true, - Description: "Alert rule wait seconds", - }, - "inherited": { - Type: schema.TypeBool, - Computed: true, - Description: "Alert rule inherited", - }, - "repeat_interval_seconds": { - Type: schema.TypeInt, - Computed: true, - Description: "Alert rule repeat interval seconds", - }, - "severity": { - Type: schema.TypeString, - Computed: true, - Description: "Alert rule severity", - }, - "annotations": { - Type: schema.TypeMap, - Computed: true, - }, - "labels": { - Type: schema.TypeMap, - Optional: true, - }, - }, - } -} - -func dataSourceRancher2ClusterAlertRuleRead(d *schema.ResourceData, meta interface{}) error { - client, err := meta.(*Config).ManagementClient() - if err != nil { - return err - } - - clusterID := d.Get("cluster_id").(string) - name := d.Get("name").(string) - - filters := map[string]interface{}{ - "clusterId": clusterID, - "name": name, - } - listOpts := NewListOpts(filters) - - alertRules, err := client.ClusterAlertRule.List(listOpts) - if err != nil { - return err - } - - count := len(alertRules.Data) - if count <= 0 { - return fmt.Errorf("[ERROR] cluster alert rule with name \"%s\" on cluster ID \"%s\" not found", name, clusterID) - } - if count > 1 { - return fmt.Errorf("[ERROR] found %d cluster alert rule with name \"%s\" on cluster ID \"%s\"", count, name, clusterID) - } - - return flattenClusterAlertRule(d, &alertRules.Data[0]) -} diff --git a/rancher2/data_source_rancher2_cluster_alert_rule_test.go b/rancher2/data_source_rancher2_cluster_alert_rule_test.go deleted file mode 100644 index f616e32b..00000000 --- a/rancher2/data_source_rancher2_cluster_alert_rule_test.go +++ /dev/null @@ -1,31 +0,0 @@ -package rancher2 - -import ( - "testing" - - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" -) - -func TestAccRancher2ClusterAlertRuleDataSource(t *testing.T) { - testAccCheckRancher2ClusterAlertRuleDataSourceConfig := testAccRancher2ClusterAlertRuleConfig + ` -data "` + testAccRancher2ClusterAlertRuleType + `" "foo" { - cluster_id = rancher2_cluster_alert_rule.foo.cluster_id - name = rancher2_cluster_alert_rule.foo.name -} -` - name := "data." + testAccRancher2ClusterAlertRuleType + ".foo" - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - Steps: []resource.TestStep{ - { - Config: testAccCheckRancher2ClusterAlertRuleDataSourceConfig, - Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr(name, "name", "foo"), - resource.TestCheckResourceAttr(name, "group_interval_seconds", "300"), - resource.TestCheckResourceAttr(name, "repeat_interval_seconds", "3600"), - ), - }, - }, - }) -} diff --git a/rancher2/data_source_rancher2_cluster_v2.go b/rancher2/data_source_rancher2_cluster_v2.go index bce67d48..236137c1 100644 --- a/rancher2/data_source_rancher2_cluster_v2.go +++ b/rancher2/data_source_rancher2_cluster_v2.go @@ -46,11 +46,6 @@ func dataSourceRancher2ClusterV2() *schema.Resource { Computed: true, Description: "Cluster V2 cloud credential secret name", }, - "default_pod_security_policy_template_name": { - Type: schema.TypeString, - Computed: true, - Description: "Cluster V2 default pod security policy template name", - }, "default_pod_security_admission_configuration_template_name": { Type: schema.TypeString, Computed: true, diff --git a/rancher2/data_source_rancher2_notifier.go b/rancher2/data_source_rancher2_notifier.go deleted file mode 100644 index 7d49880a..00000000 --- a/rancher2/data_source_rancher2_notifier.go +++ /dev/null @@ -1,133 +0,0 @@ -package rancher2 - -import ( - "fmt" - - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" -) - -func dataSourceRancher2Notifier() *schema.Resource { - return &schema.Resource{ - Read: dataSourceRancher2NotifierRead, - - Schema: map[string]*schema.Schema{ - "name": { - Type: schema.TypeString, - Required: true, - Description: "Notifier name", - }, - "cluster_id": { - Type: schema.TypeString, - Required: true, - Description: "Notifier cluster ID", - }, - "description": { - Type: schema.TypeString, - Computed: true, - Description: "Notifier description", - }, - "dingtalk_config": { - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - ConflictsWith: []string{"msteams_config", "pagerduty_config", "smtp_config", "slack_config", "webhook_config", "wechat_config"}, - Elem: &schema.Resource{ - Schema: notifierDingtalkConfigFields(), - }, - }, - "msteams_config": { - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - ConflictsWith: []string{"dingtalk_config", "pagerduty_config", "smtp_config", "slack_config", "webhook_config", "wechat_config"}, - Elem: &schema.Resource{ - Schema: notifierMSTeamsConfigFields(), - }, - }, - "pagerduty_config": { - Type: schema.TypeList, - MaxItems: 1, - Computed: true, - ConflictsWith: []string{"dingtalk_config", "msteams_config", "smtp_config", "slack_config", "webhook_config", "wechat_config"}, - Elem: &schema.Resource{ - Schema: notifierPagerdutyConfigFields(), - }, - }, - "slack_config": { - Type: schema.TypeList, - MaxItems: 1, - Computed: true, - ConflictsWith: []string{"dingtalk_config", "msteams_config", "pagerduty_config", "smtp_config", "webhook_config", "wechat_config"}, - Elem: &schema.Resource{ - Schema: notifierSlackConfigFields(), - }, - }, - "smtp_config": { - Type: schema.TypeList, - MaxItems: 1, - Computed: true, - ConflictsWith: []string{"dingtalk_config", "msteams_config", "pagerduty_config", "slack_config", "webhook_config", "wechat_config"}, - Elem: &schema.Resource{ - Schema: notifierSMTPConfigFields(), - }, - }, - "webhook_config": { - Type: schema.TypeList, - MaxItems: 1, - Computed: true, - ConflictsWith: []string{"dingtalk_config", "msteams_config", "pagerduty_config", "smtp_config", "slack_config", "wechat_config"}, - Elem: &schema.Resource{ - Schema: notifierWebhookConfigFields(), - }, - }, - "wechat_config": { - Type: schema.TypeList, - MaxItems: 1, - Computed: true, - ConflictsWith: []string{"dingtalk_config", "msteams_config", "pagerduty_config", "smtp_config", "slack_config", "webhook_config"}, - Elem: &schema.Resource{ - Schema: notifierWechatConfigFields(), - }, - }, - "annotations": { - Type: schema.TypeMap, - Computed: true, - }, - "labels": { - Type: schema.TypeMap, - Computed: true, - }, - }, - } -} - -func dataSourceRancher2NotifierRead(d *schema.ResourceData, meta interface{}) error { - client, err := meta.(*Config).ManagementClient() - if err != nil { - return err - } - - name := d.Get("name").(string) - clusterID := d.Get("cluster_id").(string) - - filters := map[string]interface{}{ - "name": name, - "clusterId": clusterID, - } - listOpts := NewListOpts(filters) - - notifiers, err := client.Notifier.List(listOpts) - if err != nil { - return err - } - - count := len(notifiers.Data) - if count <= 0 { - return fmt.Errorf("[ERROR] notifier with name \"%s\" and cluster ID \"%s\" not found", name, clusterID) - } - if count > 1 { - return fmt.Errorf("[ERROR] found %d notifier with name \"%s\" and cluster ID \"%s\"", count, name, clusterID) - } - - return flattenNotifier(d, ¬ifiers.Data[0]) -} diff --git a/rancher2/data_source_rancher2_notifier_test.go b/rancher2/data_source_rancher2_notifier_test.go deleted file mode 100644 index 60079df9..00000000 --- a/rancher2/data_source_rancher2_notifier_test.go +++ /dev/null @@ -1,31 +0,0 @@ -package rancher2 - -import ( - "testing" - - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" -) - -func TestAccRancher2NotifierDataSource(t *testing.T) { - testAccCheckRancher2NotifierDataSourceConfig := testAccRancher2NotifierPagerdutyConfig + ` -data "` + testAccRancher2NotifierType + `" "foo" { - name = rancher2_notifier.foo-pagerduty.name - cluster_id = rancher2_notifier.foo-pagerduty.cluster_id -} -` - name := "data." + testAccRancher2NotifierType + ".foo" - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - Steps: []resource.TestStep{ - { - Config: testAccCheckRancher2NotifierDataSourceConfig, - Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr(name, "name", "foo-pagerduty"), - resource.TestCheckResourceAttr(name, "description", "Terraform notifier acceptance test"), - resource.TestCheckResourceAttr(name, "pagerduty_config.0.service_key", "XXXXXXXX"), - ), - }, - }, - }) -} diff --git a/rancher2/data_source_rancher2_pod_security_policy_template.go b/rancher2/data_source_rancher2_pod_security_policy_template.go deleted file mode 100644 index c1503892..00000000 --- a/rancher2/data_source_rancher2_pod_security_policy_template.go +++ /dev/null @@ -1,28 +0,0 @@ -package rancher2 - -import ( - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" -) - -func dataSourceRancher2PodSecurityPolicyTemplate() *schema.Resource { - return &schema.Resource{ - Read: dataSourceRancher2PodSecurityPolicyTemplateRead, - Schema: podSecurityPolicyTemplateFields(), - } -} - -func dataSourceRancher2PodSecurityPolicyTemplateRead(d *schema.ResourceData, meta interface{}) error { - client, err := meta.(*Config).ManagementClient() - if err != nil { - return err - } - - name := d.Get("name").(string) - - pspt, err := client.PodSecurityPolicyTemplate.ByID(name) - if err != nil { - return err - } - - return flattenPodSecurityPolicyTemplate(d, pspt) -} diff --git a/rancher2/data_source_rancher2_pod_security_policy_template_test.go b/rancher2/data_source_rancher2_pod_security_policy_template_test.go deleted file mode 100644 index 4db9eb15..00000000 --- a/rancher2/data_source_rancher2_pod_security_policy_template_test.go +++ /dev/null @@ -1,29 +0,0 @@ -package rancher2 - -import ( - "testing" - - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" -) - -func TestAccRancher2PodSecurityPolicyTemplateDataSource(t *testing.T) { - testAccCheckRancher2PodSecurityPolicyTemplateDataSourceConfig := testAccCheckRancher2PodSecurityPolicyTemplate + ` -data "` + testAccRancher2PodSecurityPolicyTemplateType + `" "foo" { - name = rancher2_pod_security_policy_template.foo.name -} -` - name := "data." + testAccRancher2PodSecurityPolicyTemplateType + ".foo" - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - Steps: []resource.TestStep{ - { - Config: testAccCheckRancher2PodSecurityPolicyTemplateDataSourceConfig, - Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr(name, "name", "foo"), - resource.TestCheckResourceAttr(name, "description", "Terraform PodSecurityPolicyTemplate acceptance test"), - ), - }, - }, - }) -} diff --git a/rancher2/data_source_rancher2_project.go b/rancher2/data_source_rancher2_project.go index d2029b37..b5cefca2 100644 --- a/rancher2/data_source_rancher2_project.go +++ b/rancher2/data_source_rancher2_project.go @@ -37,15 +37,6 @@ func dataSourceRancher2Project() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "enable_project_monitoring": { - Type: schema.TypeBool, - Computed: true, - Description: "Enable built-in project monitoring", - }, - "pod_security_policy_template_id": { - Type: schema.TypeString, - Computed: true, - }, "resource_quota": { Type: schema.TypeList, MaxItems: 1, @@ -148,8 +139,6 @@ func dataSourceRancher2ProjectRead(d *schema.ResourceData, meta interface{}) err } } - d.Set("pod_security_policy_template_id", project.PodSecurityPolicyTemplateName) - if project.ResourceQuota != nil && project.NamespaceDefaultResourceQuota != nil { resourceQuota := flattenProjectResourceQuota(project.ResourceQuota, project.NamespaceDefaultResourceQuota) err := d.Set("resource_quota", resourceQuota) diff --git a/rancher2/data_source_rancher2_project_alert_group.go b/rancher2/data_source_rancher2_project_alert_group.go deleted file mode 100644 index 1c53eefd..00000000 --- a/rancher2/data_source_rancher2_project_alert_group.go +++ /dev/null @@ -1,93 +0,0 @@ -package rancher2 - -import ( - "fmt" - - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" -) - -func dataSourceRancher2ProjectAlertGroup() *schema.Resource { - return &schema.Resource{ - Read: dataSourceRancher2ProjectAlertGroupRead, - - Schema: map[string]*schema.Schema{ - "name": { - Type: schema.TypeString, - Required: true, - Description: "Alert group name", - }, - "project_id": { - Type: schema.TypeString, - Required: true, - Description: "Alert group project ID", - }, - "description": { - Type: schema.TypeString, - Computed: true, - Description: "Alert group description", - }, - "group_interval_seconds": { - Type: schema.TypeInt, - Computed: true, - Description: "Alert group interval seconds", - }, - "group_wait_seconds": { - Type: schema.TypeInt, - Computed: true, - Description: "Alert group wait seconds", - }, - "recipients": { - Type: schema.TypeList, - Computed: true, - Description: "Alert group recipients", - Elem: &schema.Resource{ - Schema: recipientFields(), - }, - }, - "repeat_interval_seconds": { - Type: schema.TypeInt, - Computed: true, - Description: "Alert group repeat interval seconds", - }, - "annotations": { - Type: schema.TypeMap, - Computed: true, - }, - "labels": { - Type: schema.TypeMap, - Computed: true, - }, - }, - } -} - -func dataSourceRancher2ProjectAlertGroupRead(d *schema.ResourceData, meta interface{}) error { - client, err := meta.(*Config).ManagementClient() - if err != nil { - return err - } - - projectID := d.Get("project_id").(string) - name := d.Get("name").(string) - - filters := map[string]interface{}{ - "name": name, - "projectId": projectID, - } - listOpts := NewListOpts(filters) - - alertGroups, err := client.ProjectAlertGroup.List(listOpts) - if err != nil { - return err - } - - count := len(alertGroups.Data) - if count <= 0 { - return fmt.Errorf("[ERROR] project alert group with name \"%s\" on project ID \"%s\" not found", name, projectID) - } - if count > 1 { - return fmt.Errorf("[ERROR] found %d project alert group with name \"%s\" on project ID \"%s\"", count, name, projectID) - } - - return flattenProjectAlertGroup(d, &alertGroups.Data[0]) -} diff --git a/rancher2/data_source_rancher2_project_alert_group_test.go b/rancher2/data_source_rancher2_project_alert_group_test.go deleted file mode 100644 index 67154a7a..00000000 --- a/rancher2/data_source_rancher2_project_alert_group_test.go +++ /dev/null @@ -1,31 +0,0 @@ -package rancher2 - -import ( - "testing" - - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" -) - -func TestAccRancher2ProjectAlertGroupDataSource(t *testing.T) { - testAccCheckRancher2ProjectAlertGroupDataSourceConfig := testAccRancher2ProjectAlertGroupConfig + ` -data "` + testAccRancher2ProjectAlertGroupType + `" "foo" { - name = rancher2_project_alert_group.foo.name - project_id = rancher2_project_alert_group.foo.project_id -} -` - name := "data." + testAccRancher2ProjectAlertGroupType + ".foo" - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - Steps: []resource.TestStep{ - { - Config: testAccCheckRancher2ProjectAlertGroupDataSourceConfig, - Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr(name, "name", "foo"), - resource.TestCheckResourceAttr(name, "description", "Terraform project alert group acceptance test"), - resource.TestCheckResourceAttr(name, "group_interval_seconds", "300"), - ), - }, - }, - }) -} diff --git a/rancher2/data_source_rancher2_project_alert_rule.go b/rancher2/data_source_rancher2_project_alert_rule.go deleted file mode 100644 index 1c973819..00000000 --- a/rancher2/data_source_rancher2_project_alert_rule.go +++ /dev/null @@ -1,122 +0,0 @@ -package rancher2 - -import ( - "fmt" - - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" -) - -func dataSourceRancher2ProjectAlertRule() *schema.Resource { - return &schema.Resource{ - Read: dataSourceRancher2ProjectAlertRuleRead, - - Schema: map[string]*schema.Schema{ - "project_id": { - Type: schema.TypeString, - Required: true, - Description: "Alert rule project ID", - }, - "name": { - Type: schema.TypeString, - Required: true, - Description: "Alert rule name", - }, - "metric_rule": { - Type: schema.TypeList, - MaxItems: 1, - Computed: true, - Elem: &schema.Resource{ - Schema: metricRuleFields(), - }, - Description: "Alert metric rule", - }, - "pod_rule": { - Type: schema.TypeList, - MaxItems: 1, - Computed: true, - Elem: &schema.Resource{ - Schema: podRuleFields(), - }, - Description: "Alert pod rule", - }, - "workload_rule": { - Type: schema.TypeList, - MaxItems: 1, - Computed: true, - Elem: &schema.Resource{ - Schema: workloadRuleFields(), - }, - Description: "Alert workload rule", - }, - "group_id": { - Type: schema.TypeString, - Computed: true, - Description: "Alert rule group ID", - }, - "group_interval_seconds": { - Type: schema.TypeInt, - Computed: true, - Description: "Alert rule interval seconds", - }, - "group_wait_seconds": { - Type: schema.TypeInt, - Computed: true, - Description: "Alert rule wait seconds", - }, - "inherited": { - Type: schema.TypeBool, - Computed: true, - Description: "Alert rule inherited", - }, - "repeat_interval_seconds": { - Type: schema.TypeInt, - Computed: true, - Description: "Alert rule repeat interval seconds", - }, - "severity": { - Type: schema.TypeString, - Computed: true, - Description: "Alert rule severity", - }, - "annotations": { - Type: schema.TypeMap, - Computed: true, - }, - "labels": { - Type: schema.TypeMap, - Optional: true, - }, - }, - } -} - -func dataSourceRancher2ProjectAlertRuleRead(d *schema.ResourceData, meta interface{}) error { - client, err := meta.(*Config).ManagementClient() - if err != nil { - return err - } - - projectID := d.Get("project_id").(string) - name := d.Get("name").(string) - - filters := map[string]interface{}{ - "projectId": projectID, - "name": name, - } - listOpts := NewListOpts(filters) - - alertRules, err := client.ProjectAlertRule.List(listOpts) - if err != nil { - return err - } - - count := len(alertRules.Data) - if count <= 0 { - return fmt.Errorf("[ERROR] project alert rule with name \"%s\" on project ID \"%s\" not found", name, projectID) - } - if count > 1 { - return fmt.Errorf("[ERROR] found %d project alert rule with name \"%s\" on project ID \"%s\"", count, name, projectID) - } - - return flattenProjectAlertRule(d, &alertRules.Data[0]) -} diff --git a/rancher2/data_source_rancher2_project_alert_rule_test.go b/rancher2/data_source_rancher2_project_alert_rule_test.go deleted file mode 100644 index 7c956e74..00000000 --- a/rancher2/data_source_rancher2_project_alert_rule_test.go +++ /dev/null @@ -1,31 +0,0 @@ -package rancher2 - -import ( - "testing" - - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" -) - -func TestAccRancher2ProjectAlertRuleDataSource(t *testing.T) { - testAccCheckRancher2ProjectAlertRuleDataSourceConfig := testAccRancher2ProjectAlertRuleConfig + ` -data "` + testAccRancher2ProjectAlertRuleType + `" "foo" { - project_id = rancher2_project_alert_rule.foo.project_id - name = rancher2_project_alert_rule.foo.name -} -` - name := "data." + testAccRancher2ProjectAlertRuleType + ".foo" - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - Steps: []resource.TestStep{ - { - Config: testAccCheckRancher2ProjectAlertRuleDataSourceConfig, - Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr(name, "name", "foo"), - resource.TestCheckResourceAttr(name, "group_interval_seconds", "300"), - resource.TestCheckResourceAttr(name, "repeat_interval_seconds", "3600"), - ), - }, - }, - }) -} diff --git a/rancher2/import_rancher2_cluster_alert_group.go b/rancher2/import_rancher2_cluster_alert_group.go deleted file mode 100644 index 7e479524..00000000 --- a/rancher2/import_rancher2_cluster_alert_group.go +++ /dev/null @@ -1,14 +0,0 @@ -package rancher2 - -import ( - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" -) - -func resourceRancher2ClusterAlertGroupImport(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { - err := resourceRancher2ClusterAlertGroupRead(d, meta) - if err != nil { - return []*schema.ResourceData{}, err - } - - return []*schema.ResourceData{d}, nil -} diff --git a/rancher2/import_rancher2_cluster_alert_rule.go b/rancher2/import_rancher2_cluster_alert_rule.go deleted file mode 100644 index 62912b42..00000000 --- a/rancher2/import_rancher2_cluster_alert_rule.go +++ /dev/null @@ -1,14 +0,0 @@ -package rancher2 - -import ( - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" -) - -func resourceRancher2ClusterAlertRuleImport(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { - err := resourceRancher2ClusterAlertRuleRead(d, meta) - if err != nil { - return []*schema.ResourceData{}, err - } - - return []*schema.ResourceData{d}, nil -} diff --git a/rancher2/import_rancher2_notifier.go b/rancher2/import_rancher2_notifier.go deleted file mode 100644 index ec6bedff..00000000 --- a/rancher2/import_rancher2_notifier.go +++ /dev/null @@ -1,14 +0,0 @@ -package rancher2 - -import ( - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" -) - -func resourceRancher2NotifierImport(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { - err := resourceRancher2NotifierRead(d, meta) - if err != nil { - return []*schema.ResourceData{}, err - } - - return []*schema.ResourceData{d}, nil -} diff --git a/rancher2/import_rancher2_pod_security_policy_template.go b/rancher2/import_rancher2_pod_security_policy_template.go deleted file mode 100644 index 5daee7a5..00000000 --- a/rancher2/import_rancher2_pod_security_policy_template.go +++ /dev/null @@ -1,14 +0,0 @@ -package rancher2 - -import ( - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" -) - -func resourceRancher2PodSecurityPolicyTemplateImport(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { - err := resourceRancher2PodSecurityPolicyTemplateRead(d, meta) - if err != nil { - return []*schema.ResourceData{}, err - } - - return []*schema.ResourceData{d}, nil -} diff --git a/rancher2/import_rancher2_project_alert_group.go b/rancher2/import_rancher2_project_alert_group.go deleted file mode 100644 index b77362ae..00000000 --- a/rancher2/import_rancher2_project_alert_group.go +++ /dev/null @@ -1,14 +0,0 @@ -package rancher2 - -import ( - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" -) - -func resourceRancher2ProjectAlertGroupImport(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { - err := resourceRancher2ProjectAlertGroupRead(d, meta) - if err != nil { - return []*schema.ResourceData{}, err - } - - return []*schema.ResourceData{d}, nil -} diff --git a/rancher2/import_rancher2_project_alert_rule.go b/rancher2/import_rancher2_project_alert_rule.go deleted file mode 100644 index f482ab5e..00000000 --- a/rancher2/import_rancher2_project_alert_rule.go +++ /dev/null @@ -1,14 +0,0 @@ -package rancher2 - -import ( - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" -) - -func resourceRancher2ProjectAlertRuleImport(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { - err := resourceRancher2ProjectAlertRuleRead(d, meta) - if err != nil { - return []*schema.ResourceData{}, err - } - - return []*schema.ResourceData{d}, nil -} diff --git a/rancher2/provider.go b/rancher2/provider.go index 9ca0868e..6e3f19b6 100644 --- a/rancher2/provider.go +++ b/rancher2/provider.go @@ -125,8 +125,6 @@ func Provider() terraform.ResourceProvider { "rancher2_cloud_credential": resourceRancher2CloudCredential(), "rancher2_cluster": resourceRancher2Cluster(), "rancher2_cluster_v2": resourceRancher2ClusterV2(), - "rancher2_cluster_alert_group": resourceRancher2ClusterAlertGroup(), - "rancher2_cluster_alert_rule": resourceRancher2ClusterAlertRule(), "rancher2_cluster_driver": resourceRancher2ClusterDriver(), "rancher2_cluster_role_template_binding": resourceRancher2ClusterRoleTemplateBinding(), "rancher2_cluster_sync": resourceRancher2ClusterSync(), @@ -145,12 +143,8 @@ func Provider() terraform.ResourceProvider { "rancher2_node_driver": resourceRancher2NodeDriver(), "rancher2_node_pool": resourceRancher2NodePool(), "rancher2_node_template": resourceRancher2NodeTemplate(), - "rancher2_notifier": resourceRancher2Notifier(), "rancher2_pod_security_admission_configuration_template": resourceRancher2PodSecurityAdmissionConfigurationTemplate(), - "rancher2_pod_security_policy_template": resourceRancher2PodSecurityPolicyTemplate(), "rancher2_project": resourceRancher2Project(), - "rancher2_project_alert_group": resourceRancher2ProjectAlertGroup(), - "rancher2_project_alert_rule": resourceRancher2ProjectAlertRule(), "rancher2_project_role_template_binding": resourceRancher2ProjectRoleTemplateBinding(), "rancher2_registry": resourceRancher2Registry(), "rancher2_role_template": resourceRancher2RoleTemplate(), @@ -170,8 +164,6 @@ func Provider() terraform.ResourceProvider { "rancher2_cloud_credential": dataSourceRancher2CloudCredential(), "rancher2_cluster": dataSourceRancher2Cluster(), "rancher2_cluster_v2": dataSourceRancher2ClusterV2(), - "rancher2_cluster_alert_group": dataSourceRancher2ClusterAlertGroup(), - "rancher2_cluster_alert_rule": dataSourceRancher2ClusterAlertRule(), "rancher2_cluster_driver": dataSourceRancher2ClusterDriver(), "rancher2_cluster_role_template_binding": dataSourceRancher2ClusterRoleTemplateBinding(), "rancher2_cluster_template": dataSourceRancher2ClusterTemplate(), @@ -185,13 +177,9 @@ func Provider() terraform.ResourceProvider { "rancher2_node_driver": dataSourceRancher2NodeDriver(), "rancher2_node_pool": dataSourceRancher2NodePool(), "rancher2_node_template": dataSourceRancher2NodeTemplate(), - "rancher2_notifier": dataSourceRancher2Notifier(), "rancher2_pod_security_admission_configuration_template": dataSourceRancher2PodSecurityAdmissionConfigurationTemplate(), - "rancher2_pod_security_policy_template": dataSourceRancher2PodSecurityPolicyTemplate(), "rancher2_principal": dataSourceRancher2Principal(), "rancher2_project": dataSourceRancher2Project(), - "rancher2_project_alert_group": dataSourceRancher2ProjectAlertGroup(), - "rancher2_project_alert_rule": dataSourceRancher2ProjectAlertRule(), "rancher2_project_role_template_binding": dataSourceRancher2ProjectRoleTemplateBinding(), "rancher2_registry": dataSourceRancher2Registry(), "rancher2_role_template": dataSourceRancher2RoleTemplate(), diff --git a/rancher2/resource_rancher2_cluster.go b/rancher2/resource_rancher2_cluster.go index 3b7ab2ff..f2deaa34 100644 --- a/rancher2/resource_rancher2_cluster.go +++ b/rancher2/resource_rancher2_cluster.go @@ -11,7 +11,6 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/schema" norman "github.com/rancher/norman/types" managementClient "github.com/rancher/rancher/pkg/client/generated/management/v3" - projectClient "github.com/rancher/rancher/pkg/client/generated/project/v3" "k8s.io/client-go/kubernetes" "k8s.io/client-go/tools/clientcmd" ) @@ -145,7 +144,6 @@ func resourceRancher2ClusterCreate(d *schema.ResourceData, meta interface{}) err } // Creating cluster with monitoring disabled - cluster.EnableClusterMonitoring = false newCluster := &Cluster{} if cluster.EKSConfig != nil && !cluster.EKSConfig.Imported { if !checkClusterEKSConfigV2NodeGroupsDesiredSize(cluster) { @@ -167,7 +165,6 @@ func resourceRancher2ClusterCreate(d *schema.ResourceData, meta interface{}) err return err } - newCluster.EnableClusterMonitoring = d.Get("enable_cluster_monitoring").(bool) d.SetId(newCluster.ID) stateConf := &resource.StateChangeConf{ @@ -183,39 +180,6 @@ func resourceRancher2ClusterCreate(d *schema.ResourceData, meta interface{}) err return fmt.Errorf("[ERROR] waiting for cluster (%s) to be created: %s", newCluster.ID, waitErr) } - monitoringInput := expandMonitoringInput(d.Get("cluster_monitoring_input").([]interface{})) - if newCluster.EnableClusterMonitoring { - if len(newCluster.Actions[monitoringActionEnable]) == 0 { - err = client.APIBaseClient.ByID(managementClient.ClusterType, newCluster.ID, newCluster) - if err != nil { - return err - } - } - clusterResource := &norman.Resource{ - ID: newCluster.ID, - Type: newCluster.Type, - Links: newCluster.Links, - Actions: newCluster.Actions, - } - // Retry enable monitoring until timeout if got api error 500 - ctx, cancel := context.WithTimeout(context.Background(), meta.(*Config).Timeout) - defer cancel() - for { - err = client.APIBaseClient.Action(managementClient.ClusterType, monitoringActionEnable, clusterResource, monitoringInput, nil) - if err == nil { - return resourceRancher2ClusterRead(d, meta) - } - if !IsServerError(err) { - return err - } - select { - case <-time.After(rancher2RetriesWait * time.Second): - case <-ctx.Done(): - break - } - } - } - return resourceRancher2ClusterRead(d, meta) } @@ -254,24 +218,13 @@ func resourceRancher2ClusterRead(d *schema.ResourceData, meta interface{}) error return resource.NonRetryableError(err) } - var monitoringInput *managementClient.MonitoringInput - if len(cluster.Annotations[monitoringInputAnnotation]) > 0 { - monitoringInput = &managementClient.MonitoringInput{} - err = jsonToInterface(cluster.Annotations[monitoringInputAnnotation], monitoringInput) - if err != nil { - return resource.NonRetryableError(err) - } - - } - if err = flattenCluster( d, cluster, clusterRegistrationToken, kubeConfig, defaultProjectID, - systemProjectID, - monitoringInput); err != nil { + systemProjectID); err != nil { return resource.NonRetryableError(err) } @@ -310,14 +263,11 @@ func resourceRancher2ClusterUpdate(d *schema.ResourceData, meta interface{}) err "clusterAgentDeploymentCustomization": clusterAgentDeploymentCustomization, "fleetAgentDeploymentCustomization": fleetAgentDeploymentCustomization, "description": d.Get("description").(string), - "defaultPodSecurityPolicyTemplateId": d.Get("default_pod_security_policy_template_id").(string), "defaultPodSecurityAdmissionConfigurationTemplateName": d.Get("default_pod_security_admission_configuration_template_name").(string), "desiredAgentImage": d.Get("desired_agent_image").(string), "desiredAuthImage": d.Get("desired_auth_image").(string), "dockerRootDir": d.Get("docker_root_dir").(string), "fleetWorkspaceName": d.Get("fleet_workspace_name").(string), - "enableClusterAlerting": d.Get("enable_cluster_alerting").(bool), - "enableClusterMonitoring": d.Get("enable_cluster_monitoring").(bool), "enableNetworkPolicy": &enableNetworkPolicy, "istioEnabled": d.Get("enable_cluster_istio").(bool), "localClusterAuthEndpoint": expandClusterAuthEndpoint(d.Get("cluster_auth_endpoint").([]interface{})), @@ -325,11 +275,6 @@ func resourceRancher2ClusterUpdate(d *schema.ResourceData, meta interface{}) err "labels": toMapString(d.Get("labels").(map[string]interface{})), } - // cluster_monitoring is not updated here. Setting old `enable_cluster_monitoring` value if it was updated - if d.HasChange("enable_cluster_monitoring") { - update["enableClusterMonitoring"] = !d.Get("enable_cluster_monitoring").(bool) - } - if clusterTemplateID, ok := d.Get("cluster_template_id").(string); ok && len(clusterTemplateID) > 0 { update["clusterTemplateId"] = clusterTemplateID if clusterTemplateRevisionID, ok := d.Get("cluster_template_revision_id").(string); ok && len(clusterTemplateRevisionID) > 0 { @@ -420,17 +365,6 @@ func resourceRancher2ClusterUpdate(d *schema.ResourceData, meta interface{}) err return resource.NonRetryableError(fmt.Errorf("[ERROR] waiting for cluster (%s) to be updated: %s", newCluster.ID, waitErr)) } - // update cluster monitoring if it has changed - if d.HasChange("enable_cluster_monitoring") || d.HasChange("cluster_monitoring_input") { - err = updateClusterMonitoring(client, d, meta, *newCluster) - if err != nil { - if IsServerError(err) { - return resource.RetryableError(err) - } - return resource.NonRetryableError(err) - } - } - d.SetId(newCluster.ID) // read cluster after update. If an error is returned then the read failed and is non retryable, else @@ -732,100 +666,3 @@ func getClusterKubeconfig(c *Config, id, origconfig string) (*managementClient.G } } } - -func updateClusterMonitoring(client *managementClient.Client, d *schema.ResourceData, meta interface{}, newCluster Cluster) error { - clusterResource := &norman.Resource{ - ID: newCluster.ID, - Type: newCluster.Type, - Links: newCluster.Links, - Actions: newCluster.Actions, - } - enableMonitoring := d.Get("enable_cluster_monitoring").(bool) - - if enableMonitoring { - monitoringInput := expandMonitoringInput(d.Get("cluster_monitoring_input").([]interface{})) - if len(newCluster.Actions[monitoringActionEnable]) > 0 { - err := client.APIBaseClient.Action(managementClient.ClusterType, monitoringActionEnable, clusterResource, monitoringInput, nil) - if err != nil { - return err - } - } else { - monitorVersionChanged := false - if d.HasChange("cluster_monitoring_input") { - old, new := d.GetChange("cluster_monitoring_input") - oldInput := old.([]interface{}) - oldInputLen := len(oldInput) - oldVersion := "" - if oldInputLen > 0 { - oldRow, oldOK := oldInput[0].(map[string]interface{}) - if oldOK { - oldVersion = oldRow["version"].(string) - } - } - newInput := new.([]interface{}) - newInputLen := len(newInput) - newVersion := "" - if newInputLen > 0 { - newRow, newOK := newInput[0].(map[string]interface{}) - if newOK { - newVersion = newRow["version"].(string) - } - } - if oldVersion != newVersion { - monitorVersionChanged = true - } - } - if monitorVersionChanged && monitoringInput != nil { - err := updateClusterMonitoringApps(meta, d.Get("system_project_id").(string), monitoringInput.Version) - if err != nil { - return err - } - } - err := client.APIBaseClient.Action(managementClient.ClusterType, monitoringActionEdit, clusterResource, monitoringInput, nil) - if err != nil { - return err - } - } - } else if len(newCluster.Actions[monitoringActionDisable]) > 0 { - err := client.APIBaseClient.Action(managementClient.ClusterType, monitoringActionDisable, clusterResource, nil, nil) - if err != nil { - return err - } - } - return nil -} - -func updateClusterMonitoringApps(meta interface{}, systemProjectID, version string) error { - cliProject, err := meta.(*Config).ProjectClient(systemProjectID) - if err != nil { - return err - } - - filters := map[string]interface{}{ - "targetNamespace": clusterMonitoringV1Namespace, - } - - listOpts := NewListOpts(filters) - - apps, err := cliProject.App.List(listOpts) - if err != nil { - return err - } - - for _, a := range apps.Data { - if a.Name == "cluster-monitoring" || a.Name == "monitoring-operator" { - externalID := updateVersionExternalID(a.ExternalID, version) - upgrade := &projectClient.AppUpgradeConfig{ - Answers: a.Answers, - ExternalID: externalID, - ForceUpgrade: true, - } - - err = cliProject.App.ActionUpgrade(&a, upgrade) - if err != nil { - return err - } - } - } - return nil -} diff --git a/rancher2/resource_rancher2_cluster_alert_group.go b/rancher2/resource_rancher2_cluster_alert_group.go deleted file mode 100644 index 0e409ea4..00000000 --- a/rancher2/resource_rancher2_cluster_alert_group.go +++ /dev/null @@ -1,233 +0,0 @@ -package rancher2 - -import ( - "fmt" - "log" - "time" - - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - managementClient "github.com/rancher/rancher/pkg/client/generated/management/v3" -) - -func resourceRancher2ClusterAlertGroup() *schema.Resource { - return &schema.Resource{ - Create: resourceRancher2ClusterAlertGroupCreate, - Read: resourceRancher2ClusterAlertGroupRead, - Update: resourceRancher2ClusterAlertGroupUpdate, - Delete: resourceRancher2ClusterAlertGroupDelete, - Importer: &schema.ResourceImporter{ - State: resourceRancher2ClusterAlertGroupImport, - }, - Schema: clusterAlertGroupFields(), - Timeouts: &schema.ResourceTimeout{ - Create: schema.DefaultTimeout(10 * time.Minute), - Update: schema.DefaultTimeout(10 * time.Minute), - Delete: schema.DefaultTimeout(10 * time.Minute), - }, - } -} - -func resourceRancher2ClusterAlertGroupCreate(d *schema.ResourceData, meta interface{}) error { - err := resourceRancher2ClusterAlertGroupRecients(d, meta) - if err != nil { - return err - } - clusterAlertGroup := expandClusterAlertGroup(d) - - log.Printf("[INFO] Creating Cluster Alert Group %s", clusterAlertGroup.Name) - - client, err := meta.(*Config).ManagementClient() - if err != nil { - return err - } - - newClusterAlertGroup, err := client.ClusterAlertGroup.Create(clusterAlertGroup) - if err != nil { - return err - } - - d.SetId(newClusterAlertGroup.ID) - - stateConf := &resource.StateChangeConf{ - Pending: []string{}, - Target: []string{"active"}, - Refresh: clusterAlertGroupStateRefreshFunc(client, newClusterAlertGroup.ID), - Timeout: d.Timeout(schema.TimeoutCreate), - Delay: 1 * time.Second, - MinTimeout: 3 * time.Second, - } - _, waitErr := stateConf.WaitForState() - if waitErr != nil { - return fmt.Errorf("[ERROR] waiting for cluster alert group (%s) to be created: %s", newClusterAlertGroup.ID, waitErr) - } - - return resourceRancher2ClusterAlertGroupRead(d, meta) -} - -func resourceRancher2ClusterAlertGroupRead(d *schema.ResourceData, meta interface{}) error { - log.Printf("[INFO] Refreshing Cluster Alert Group ID %s", d.Id()) - client, err := meta.(*Config).ManagementClient() - if err != nil { - return err - } - - return resource.Retry(d.Timeout(schema.TimeoutRead), func() *resource.RetryError { - clusterAlertGroup, err := client.ClusterAlertGroup.ByID(d.Id()) - if err != nil { - if IsNotFound(err) || IsForbidden(err) { - log.Printf("[INFO] Cluster Alert Group ID %s not found.", d.Id()) - d.SetId("") - return nil - } - } - - if err = flattenClusterAlertGroup(d, clusterAlertGroup); err != nil { - return resource.NonRetryableError(err) - } - - return nil - }) -} - -func resourceRancher2ClusterAlertGroupUpdate(d *schema.ResourceData, meta interface{}) error { - log.Printf("[INFO] Updating Cluster Alert Group ID %s", d.Id()) - client, err := meta.(*Config).ManagementClient() - if err != nil { - return err - } - - clusterAlertGroup, err := client.ClusterAlertGroup.ByID(d.Id()) - if err != nil { - return err - } - - if d.HasChange("recipients") { - err = resourceRancher2ClusterAlertGroupRecients(d, meta) - if err != nil { - return err - } - } - - update := map[string]interface{}{ - "clusterId": d.Get("cluster_id").(string), - "description": d.Get("description").(string), - "groupIntervalSeconds": int64(d.Get("group_interval_seconds").(int)), - "groupWaitSeconds": int64(d.Get("group_wait_seconds").(int)), - "name": d.Get("name").(string), - "recipients": expandRecipients(d.Get("recipients").([]interface{})), - "repeatIntervalSeconds": int64(d.Get("repeat_interval_seconds").(int)), - "annotations": toMapString(d.Get("annotations").(map[string]interface{})), - "labels": toMapString(d.Get("labels").(map[string]interface{})), - } - - newClusterAlertGroup, err := client.ClusterAlertGroup.Update(clusterAlertGroup, update) - if err != nil { - return err - } - - stateConf := &resource.StateChangeConf{ - Pending: []string{}, - Target: []string{"active"}, - Refresh: clusterAlertGroupStateRefreshFunc(client, newClusterAlertGroup.ID), - Timeout: d.Timeout(schema.TimeoutUpdate), - Delay: 1 * time.Second, - MinTimeout: 3 * time.Second, - } - _, waitErr := stateConf.WaitForState() - if waitErr != nil { - return fmt.Errorf( - "[ERROR] waiting for cluster alert group (%s) to be updated: %s", newClusterAlertGroup.ID, waitErr) - } - - return resourceRancher2ClusterAlertGroupRead(d, meta) -} - -func resourceRancher2ClusterAlertGroupDelete(d *schema.ResourceData, meta interface{}) error { - log.Printf("[INFO] Deleting Cluster Alert Group ID %s", d.Id()) - id := d.Id() - client, err := meta.(*Config).ManagementClient() - if err != nil { - return err - } - - clusterAlertGroup, err := client.ClusterAlertGroup.ByID(id) - if err != nil { - if IsNotFound(err) || IsForbidden(err) { - log.Printf("[INFO] Cluster Alert Group ID %s not found.", id) - d.SetId("") - return nil - } - return err - } - - err = client.ClusterAlertGroup.Delete(clusterAlertGroup) - if err != nil { - return fmt.Errorf("Error removing Cluster Alert Group: %s", err) - } - - log.Printf("[DEBUG] Waiting for cluster alert group (%s) to be removed", id) - - stateConf := &resource.StateChangeConf{ - Pending: []string{"removing"}, - Target: []string{"removed"}, - Refresh: clusterAlertGroupStateRefreshFunc(client, id), - Timeout: d.Timeout(schema.TimeoutDelete), - Delay: 1 * time.Second, - MinTimeout: 3 * time.Second, - } - - _, waitErr := stateConf.WaitForState() - if waitErr != nil { - return fmt.Errorf( - "[ERROR] waiting for cluster alert group (%s) to be removed: %s", id, waitErr) - } - - d.SetId("") - return nil -} - -func resourceRancher2ClusterAlertGroupRecients(d *schema.ResourceData, meta interface{}) error { - recipients, ok := d.Get("recipients").([]interface{}) - if !ok { - return fmt.Errorf("[ERROR] Getting Cluster Alert Group Recipients") - } - - if len(recipients) > 0 { - log.Printf("[INFO] Getting Cluster Alert Group Recipients") - - for i := range recipients { - in := recipients[i].(map[string]interface{}) - - recipient, err := meta.(*Config).GetRecipientByNotifier(in["notifier_id"].(string)) - if err != nil { - return err - } - - in["notifier_type"] = recipient.NotifierType - if v, ok := in["default_recipient"].(bool); ok && v { - in["recipient"] = recipient.Recipient - } - - recipients[i] = in - } - d.Set("recipients", recipients) - } - - return nil -} - -// clusterAlertGroupStateRefreshFunc returns a resource.StateRefreshFunc, used to watch a Rancher ClusterAlertGroup. -func clusterAlertGroupStateRefreshFunc(client *managementClient.Client, clusterAlertGroupID string) resource.StateRefreshFunc { - return func() (interface{}, string, error) { - obj, err := client.ClusterAlertGroup.ByID(clusterAlertGroupID) - if err != nil { - if IsNotFound(err) || IsForbidden(err) { - return obj, "removed", nil - } - return nil, "", err - } - - return obj, obj.State, nil - } -} diff --git a/rancher2/resource_rancher2_cluster_alert_group_test.go b/rancher2/resource_rancher2_cluster_alert_group_test.go deleted file mode 100644 index 055245ff..00000000 --- a/rancher2/resource_rancher2_cluster_alert_group_test.go +++ /dev/null @@ -1,203 +0,0 @@ -package rancher2 - -import ( - "fmt" - "testing" - "time" - - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/terraform" - managementClient "github.com/rancher/rancher/pkg/client/generated/management/v3" -) - -const ( - testAccRancher2ClusterAlertGroupType = "rancher2_cluster_alert_group" -) - -var ( - testAccRancher2ClusterAlertGroup string - testAccRancher2ClusterAlertGroupUpdate string - testAccRancher2ClusterAlertGroupConfig string - testAccRancher2ClusterAlertGroupUpdateConfig string -) - -func init() { - testAccRancher2ClusterAlertGroup = ` -resource "` + testAccRancher2ClusterAlertGroupType + `" "foo" { - name = "foo" - description = "Terraform cluster alert group acceptance test" - cluster_id = rancher2_cluster_sync.testacc.cluster_id - group_interval_seconds = 300 - repeat_interval_seconds = 3600 -} -` - testAccRancher2ClusterAlertGroupUpdate = ` -resource "` + testAccRancher2ClusterAlertGroupType + `" "foo" { - name = "foo" - description = "Terraform cluster alert group acceptance test - updated" - cluster_id = rancher2_cluster_sync.testacc.cluster_id - group_interval_seconds = 600 - repeat_interval_seconds = 6000 -} - ` - testAccRancher2ClusterAlertGroupConfig = testAccCheckRancher2ClusterSyncTestacc + testAccRancher2ClusterAlertGroup - testAccRancher2ClusterAlertGroupUpdateConfig = testAccCheckRancher2ClusterSyncTestacc + testAccRancher2ClusterAlertGroupUpdate -} - -func TestAccRancher2ClusterAlertGroup_basic(t *testing.T) { - var ag *managementClient.ClusterAlertGroup - - resource.Test(t, resource.TestCase{ - Providers: testAccProviders, - CheckDestroy: testAccCheckRancher2ClusterAlertGroupDestroy, - Steps: []resource.TestStep{ - { - Config: testAccRancher2ClusterAlertGroupConfig, - Check: resource.ComposeTestCheckFunc( - testAccCheckRancher2ClusterAlertGroupExists(testAccRancher2ClusterAlertGroupType+".foo", ag), - resource.TestCheckResourceAttr(testAccRancher2ClusterAlertGroupType+".foo", "name", "foo"), - resource.TestCheckResourceAttr(testAccRancher2ClusterAlertGroupType+".foo", "description", "Terraform cluster alert group acceptance test"), - resource.TestCheckResourceAttr(testAccRancher2ClusterAlertGroupType+".foo", "group_interval_seconds", "300"), - resource.TestCheckResourceAttr(testAccRancher2ClusterAlertGroupType+".foo", "repeat_interval_seconds", "3600"), - ), - }, - { - Config: testAccRancher2ClusterAlertGroupUpdateConfig, - Check: resource.ComposeTestCheckFunc( - testAccCheckRancher2ClusterAlertGroupExists(testAccRancher2ClusterAlertGroupType+".foo", ag), - resource.TestCheckResourceAttr(testAccRancher2ClusterAlertGroupType+".foo", "name", "foo"), - resource.TestCheckResourceAttr(testAccRancher2ClusterAlertGroupType+".foo", "description", "Terraform cluster alert group acceptance test - updated"), - resource.TestCheckResourceAttr(testAccRancher2ClusterAlertGroupType+".foo", "group_interval_seconds", "600"), - resource.TestCheckResourceAttr(testAccRancher2ClusterAlertGroupType+".foo", "repeat_interval_seconds", "6000"), - ), - }, - { - Config: testAccRancher2ClusterAlertGroupConfig, - Check: resource.ComposeTestCheckFunc( - testAccCheckRancher2ClusterAlertGroupExists(testAccRancher2ClusterAlertGroupType+".foo", ag), - resource.TestCheckResourceAttr(testAccRancher2ClusterAlertGroupType+".foo", "name", "foo"), - resource.TestCheckResourceAttr(testAccRancher2ClusterAlertGroupType+".foo", "description", "Terraform cluster alert group acceptance test"), - resource.TestCheckResourceAttr(testAccRancher2ClusterAlertGroupType+".foo", "group_interval_seconds", "300"), - resource.TestCheckResourceAttr(testAccRancher2ClusterAlertGroupType+".foo", "repeat_interval_seconds", "3600"), - ), - }, - }, - }) -} - -func TestAccRancher2ClusterAlertGroup_disappears(t *testing.T) { - var ag *managementClient.ClusterAlertGroup - - resource.Test(t, resource.TestCase{ - Providers: testAccProviders, - CheckDestroy: testAccCheckRancher2ClusterAlertGroupDestroy, - Steps: []resource.TestStep{ - { - Config: testAccRancher2ClusterAlertGroupConfig, - Check: resource.ComposeTestCheckFunc( - testAccCheckRancher2ClusterAlertGroupExists(testAccRancher2ClusterAlertGroupType+".foo", ag), - testAccRancher2ClusterAlertGroupDisappears(ag), - ), - ExpectNonEmptyPlan: true, - }, - }, - }) -} - -func testAccRancher2ClusterAlertGroupDisappears(ag *managementClient.ClusterAlertGroup) resource.TestCheckFunc { - return func(s *terraform.State) error { - for _, rs := range s.RootModule().Resources { - if rs.Type != testAccRancher2ClusterAlertGroupType { - continue - } - client, err := testAccProvider.Meta().(*Config).ManagementClient() - if err != nil { - return err - } - - ag, err = client.ClusterAlertGroup.ByID(rs.Primary.ID) - if err != nil { - if IsNotFound(err) { - return nil - } - return err - } - - err = client.ClusterAlertGroup.Delete(ag) - if err != nil { - return fmt.Errorf("Error removing Cluster Alert Group: %s", err) - } - - stateConf := &resource.StateChangeConf{ - Pending: []string{"removing"}, - Target: []string{"removed"}, - Refresh: clusterAlertGroupStateRefreshFunc(client, rs.Primary.ID), - Timeout: 10 * time.Minute, - Delay: 1 * time.Second, - MinTimeout: 3 * time.Second, - } - - _, waitErr := stateConf.WaitForState() - if waitErr != nil { - return fmt.Errorf( - "[ERROR] waiting for cluster alert group (%s) to be removed: %s", rs.Primary.ID, waitErr) - } - } - return nil - - } -} - -func testAccCheckRancher2ClusterAlertGroupExists(n string, ag *managementClient.ClusterAlertGroup) resource.TestCheckFunc { - return func(s *terraform.State) error { - rs, ok := s.RootModule().Resources[n] - - if !ok { - return fmt.Errorf("Not found: %s", n) - } - - if rs.Primary.ID == "" { - return fmt.Errorf("No cluster alert group ID is set") - } - - client, err := testAccProvider.Meta().(*Config).ManagementClient() - if err != nil { - return err - } - - foundAg, err := client.ClusterAlertGroup.ByID(rs.Primary.ID) - if err != nil { - if IsNotFound(err) { - return fmt.Errorf("Cluster Alert Group not found") - } - return err - } - - ag = foundAg - - return nil - } -} - -func testAccCheckRancher2ClusterAlertGroupDestroy(s *terraform.State) error { - for _, rs := range s.RootModule().Resources { - if rs.Type != testAccRancher2ClusterAlertGroupType { - continue - } - - client, err := testAccProvider.Meta().(*Config).ManagementClient() - if err != nil { - return err - } - - _, err = client.ClusterAlertGroup.ByID(rs.Primary.ID) - if err != nil { - if IsNotFound(err) { - return nil - } - return err - } - return fmt.Errorf("Cluster Alert Group still exists") - } - return nil -} diff --git a/rancher2/resource_rancher2_cluster_alert_rule.go b/rancher2/resource_rancher2_cluster_alert_rule.go deleted file mode 100644 index b88d7025..00000000 --- a/rancher2/resource_rancher2_cluster_alert_rule.go +++ /dev/null @@ -1,212 +0,0 @@ -package rancher2 - -import ( - "fmt" - "log" - "time" - - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - managementClient "github.com/rancher/rancher/pkg/client/generated/management/v3" -) - -func resourceRancher2ClusterAlertRule() *schema.Resource { - return &schema.Resource{ - Create: resourceRancher2ClusterAlertRuleCreate, - Read: resourceRancher2ClusterAlertRuleRead, - Update: resourceRancher2ClusterAlertRuleUpdate, - Delete: resourceRancher2ClusterAlertRuleDelete, - Importer: &schema.ResourceImporter{ - State: resourceRancher2ClusterAlertRuleImport, - }, - Schema: clusterAlertRuleFields(), - Timeouts: &schema.ResourceTimeout{ - Create: schema.DefaultTimeout(10 * time.Minute), - Update: schema.DefaultTimeout(10 * time.Minute), - Delete: schema.DefaultTimeout(10 * time.Minute), - }, - } -} - -func resourceRancher2ClusterAlertRuleCreate(d *schema.ResourceData, meta interface{}) error { - clusterAlertRule := expandClusterAlertRule(d) - - log.Printf("[INFO] Creating Cluster Alert Rule %s", clusterAlertRule.Name) - - client, err := meta.(*Config).ManagementClient() - if err != nil { - return err - } - - newClusterAlertRule, err := client.ClusterAlertRule.Create(clusterAlertRule) - if err != nil { - return err - } - - d.SetId(newClusterAlertRule.ID) - - stateConf := &resource.StateChangeConf{ - Pending: []string{}, - Target: []string{"active"}, - Refresh: clusterAlertRuleStateRefreshFunc(client, newClusterAlertRule.ID), - Timeout: d.Timeout(schema.TimeoutCreate), - Delay: 1 * time.Second, - MinTimeout: 3 * time.Second, - } - _, waitErr := stateConf.WaitForState() - if waitErr != nil { - return fmt.Errorf("[ERROR] waiting for cluster alert rule (%s) to be created: %s", newClusterAlertRule.ID, waitErr) - } - - return resourceRancher2ClusterAlertRuleRead(d, meta) -} - -func resourceRancher2ClusterAlertRuleRead(d *schema.ResourceData, meta interface{}) error { - log.Printf("[INFO] Refreshing Cluster Alert Rule ID %s", d.Id()) - client, err := meta.(*Config).ManagementClient() - if err != nil { - return err - } - - return resource.Retry(d.Timeout(schema.TimeoutRead), func() *resource.RetryError { - clusterAlertRule, err := client.ClusterAlertRule.ByID(d.Id()) - if err != nil { - if IsNotFound(err) || IsForbidden(err) { - log.Printf("[INFO] Cluster Alert Rule ID %s not found.", d.Id()) - d.SetId("") - return nil - } - - return resource.NonRetryableError(err) - } - - if err = flattenClusterAlertRule(d, clusterAlertRule); err != nil { - return resource.NonRetryableError(err) - } - - return nil - }) -} - -func resourceRancher2ClusterAlertRuleUpdate(d *schema.ResourceData, meta interface{}) error { - log.Printf("[INFO] Updating Cluster Alert Rule ID %s", d.Id()) - client, err := meta.(*Config).ManagementClient() - if err != nil { - return err - } - - clusterAlertRule, err := client.ClusterAlertRule.ByID(d.Id()) - if err != nil { - return err - } - - inherited := d.Get("inherited").(bool) - update := map[string]interface{}{ - "clusterId": d.Get("cluster_id").(string), - "groupId": d.Get("group_id").(string), - "groupIntervalSeconds": int64(d.Get("group_interval_seconds").(int)), - "groupWaitSeconds": int64(d.Get("group_wait_seconds").(int)), - "inherited": &inherited, - "name": d.Get("name").(string), - "repeatIntervalSeconds": int64(d.Get("repeat_interval_seconds").(int)), - "severity": d.Get("severity").(string), - "annotations": toMapString(d.Get("annotations").(map[string]interface{})), - "labels": toMapString(d.Get("labels").(map[string]interface{})), - } - - if v, ok := d.Get("event_rule").([]interface{}); ok && len(v) > 0 { - update["eventRule"] = expandEventRule(v) - } - - if v, ok := d.Get("metric_rule").([]interface{}); ok && len(v) > 0 { - update["metricRule"] = expandMetricRule(v) - } - - if v, ok := d.Get("node_rule").([]interface{}); ok && len(v) > 0 { - update["nodeRule"] = expandNodeRule(v) - } - - if v, ok := d.Get("system_service_rule").([]interface{}); ok && len(v) > 0 { - update["systemServiceRule"] = expandSystemServiceRule(v) - } - - newClusterAlertRule, err := client.ClusterAlertRule.Update(clusterAlertRule, update) - if err != nil { - return err - } - - stateConf := &resource.StateChangeConf{ - Pending: []string{}, - Target: []string{"active"}, - Refresh: clusterAlertRuleStateRefreshFunc(client, newClusterAlertRule.ID), - Timeout: d.Timeout(schema.TimeoutUpdate), - Delay: 1 * time.Second, - MinTimeout: 3 * time.Second, - } - _, waitErr := stateConf.WaitForState() - if waitErr != nil { - return fmt.Errorf( - "[ERROR] waiting for cluster alert rule (%s) to be updated: %s", newClusterAlertRule.ID, waitErr) - } - - return resourceRancher2ClusterAlertRuleRead(d, meta) -} - -func resourceRancher2ClusterAlertRuleDelete(d *schema.ResourceData, meta interface{}) error { - log.Printf("[INFO] Deleting Cluster Alert Rule ID %s", d.Id()) - id := d.Id() - client, err := meta.(*Config).ManagementClient() - if err != nil { - return err - } - - clusterAlertRule, err := client.ClusterAlertRule.ByID(id) - if err != nil { - if IsNotFound(err) || IsForbidden(err) { - log.Printf("[INFO] Cluster Alert Rule ID %s not found.", id) - d.SetId("") - return nil - } - return err - } - - err = client.ClusterAlertRule.Delete(clusterAlertRule) - if err != nil { - return fmt.Errorf("Error removing Cluster Alert Rule: %s", err) - } - - log.Printf("[DEBUG] Waiting for cluster alert rule (%s) to be removed", id) - - stateConf := &resource.StateChangeConf{ - Pending: []string{"removing"}, - Target: []string{"removed"}, - Refresh: clusterAlertRuleStateRefreshFunc(client, id), - Timeout: d.Timeout(schema.TimeoutDelete), - Delay: 1 * time.Second, - MinTimeout: 3 * time.Second, - } - - _, waitErr := stateConf.WaitForState() - if waitErr != nil { - return fmt.Errorf( - "[ERROR] waiting for cluster alert rule (%s) to be removed: %s", id, waitErr) - } - - d.SetId("") - return nil -} - -// clusterAlertRuleStateRefreshFunc returns a resource.StateRefreshFunc, used to watch a Rancher ClusterAlertRule. -func clusterAlertRuleStateRefreshFunc(client *managementClient.Client, clusterAlertRuleID string) resource.StateRefreshFunc { - return func() (interface{}, string, error) { - obj, err := client.ClusterAlertRule.ByID(clusterAlertRuleID) - if err != nil { - if IsNotFound(err) || IsForbidden(err) { - return obj, "removed", nil - } - return nil, "", err - } - - return obj, obj.State, nil - } -} diff --git a/rancher2/resource_rancher2_cluster_alert_rule_test.go b/rancher2/resource_rancher2_cluster_alert_rule_test.go deleted file mode 100644 index 495af7e7..00000000 --- a/rancher2/resource_rancher2_cluster_alert_rule_test.go +++ /dev/null @@ -1,204 +0,0 @@ -package rancher2 - -import ( - "fmt" - "testing" - "time" - - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/terraform" - managementClient "github.com/rancher/rancher/pkg/client/generated/management/v3" -) - -const ( - testAccRancher2ClusterAlertRuleType = "rancher2_cluster_alert_rule" -) - -var ( - testAccRancher2ClusterAlertRuleGroup string - testAccRancher2ClusterAlertRule string - testAccRancher2ClusterAlertRuleUpdate string - testAccRancher2ClusterAlertRuleConfig string - testAccRancher2ClusterAlertRuleUpdateConfig string -) - -func init() { - testAccRancher2ClusterAlertRule = ` -resource "` + testAccRancher2ClusterAlertRuleType + `" "foo" { - cluster_id = rancher2_cluster_sync.testacc.cluster_id - group_id = rancher2_cluster_alert_group.foo.id - name = "foo" - group_interval_seconds = 300 - repeat_interval_seconds = 3600 -} -` - testAccRancher2ClusterAlertRuleUpdate = ` -resource "` + testAccRancher2ClusterAlertRuleType + `" "foo" { - cluster_id = rancher2_cluster_sync.testacc.cluster_id - group_id = rancher2_cluster_alert_group.foo.id - name = "foo" - group_interval_seconds = 600 - repeat_interval_seconds = 6000 -} -` - testAccRancher2ClusterAlertRuleConfig = testAccRancher2ClusterAlertGroupConfig + testAccRancher2ClusterAlertRule - testAccRancher2ClusterAlertRuleUpdateConfig = testAccRancher2ClusterAlertGroupConfig + testAccRancher2ClusterAlertRuleUpdate -} - -func TestAccRancher2ClusterAlertRule_basic(t *testing.T) { - var ar *managementClient.ClusterAlertRule - - resource.Test(t, resource.TestCase{ - Providers: testAccProviders, - CheckDestroy: testAccCheckRancher2ClusterAlertRuleDestroy, - Steps: []resource.TestStep{ - { - Config: testAccRancher2ClusterAlertRuleConfig, - Check: resource.ComposeTestCheckFunc( - testAccCheckRancher2ClusterAlertRuleExists(testAccRancher2ClusterAlertRuleType+".foo", ar), - resource.TestCheckResourceAttr(testAccRancher2ClusterAlertRuleType+".foo", "name", "foo"), - resource.TestCheckResourceAttr(testAccRancher2ClusterAlertRuleType+".foo", "group_interval_seconds", "300"), - resource.TestCheckResourceAttr(testAccRancher2ClusterAlertRuleType+".foo", "severity", alertRuleSeverityCritical), - resource.TestCheckResourceAttr(testAccRancher2ClusterAlertRuleType+".foo", "repeat_interval_seconds", "3600"), - ), - }, - { - Config: testAccRancher2ClusterAlertRuleUpdateConfig, - Check: resource.ComposeTestCheckFunc( - testAccCheckRancher2ClusterAlertRuleExists(testAccRancher2ClusterAlertRuleType+".foo", ar), - resource.TestCheckResourceAttr(testAccRancher2ClusterAlertRuleType+".foo", "name", "foo"), - resource.TestCheckResourceAttr(testAccRancher2ClusterAlertRuleType+".foo", "group_interval_seconds", "600"), - resource.TestCheckResourceAttr(testAccRancher2ClusterAlertRuleType+".foo", "severity", alertRuleSeverityCritical), - resource.TestCheckResourceAttr(testAccRancher2ClusterAlertRuleType+".foo", "repeat_interval_seconds", "6000"), - ), - }, - { - Config: testAccRancher2ClusterAlertRuleConfig, - Check: resource.ComposeTestCheckFunc( - testAccCheckRancher2ClusterAlertRuleExists(testAccRancher2ClusterAlertRuleType+".foo", ar), - resource.TestCheckResourceAttr(testAccRancher2ClusterAlertRuleType+".foo", "name", "foo"), - resource.TestCheckResourceAttr(testAccRancher2ClusterAlertRuleType+".foo", "group_interval_seconds", "300"), - resource.TestCheckResourceAttr(testAccRancher2ClusterAlertRuleType+".foo", "severity", alertRuleSeverityCritical), - resource.TestCheckResourceAttr(testAccRancher2ClusterAlertRuleType+".foo", "repeat_interval_seconds", "3600"), - ), - }, - }, - }) -} - -func TestAccRancher2ClusterAlertRule_disappears(t *testing.T) { - var ar *managementClient.ClusterAlertRule - - resource.Test(t, resource.TestCase{ - Providers: testAccProviders, - CheckDestroy: testAccCheckRancher2ClusterAlertRuleDestroy, - Steps: []resource.TestStep{ - { - Config: testAccRancher2ClusterAlertRuleConfig, - Check: resource.ComposeTestCheckFunc( - testAccCheckRancher2ClusterAlertRuleExists(testAccRancher2ClusterAlertRuleType+".foo", ar), - testAccRancher2ClusterAlertRuleDisappears(ar), - ), - ExpectNonEmptyPlan: true, - }, - }, - }) -} - -func testAccRancher2ClusterAlertRuleDisappears(ar *managementClient.ClusterAlertRule) resource.TestCheckFunc { - return func(s *terraform.State) error { - for _, rs := range s.RootModule().Resources { - if rs.Type != testAccRancher2ClusterAlertRuleType { - continue - } - client, err := testAccProvider.Meta().(*Config).ManagementClient() - if err != nil { - return err - } - - ar, err = client.ClusterAlertRule.ByID(rs.Primary.ID) - if err != nil { - if IsNotFound(err) { - return nil - } - return err - } - - err = client.ClusterAlertRule.Delete(ar) - if err != nil { - return fmt.Errorf("Error removing Cluster Alert Rule: %s", err) - } - - stateConf := &resource.StateChangeConf{ - Pending: []string{"removing"}, - Target: []string{"removed"}, - Refresh: clusterAlertRuleStateRefreshFunc(client, rs.Primary.ID), - Timeout: 10 * time.Minute, - Delay: 1 * time.Second, - MinTimeout: 3 * time.Second, - } - - _, waitErr := stateConf.WaitForState() - if waitErr != nil { - return fmt.Errorf( - "[ERROR] waiting for cluster alert rule (%s) to be removed: %s", rs.Primary.ID, waitErr) - } - } - return nil - - } -} - -func testAccCheckRancher2ClusterAlertRuleExists(n string, ar *managementClient.ClusterAlertRule) resource.TestCheckFunc { - return func(s *terraform.State) error { - rs, ok := s.RootModule().Resources[n] - - if !ok { - return fmt.Errorf("Not found: %s", n) - } - - if rs.Primary.ID == "" { - return fmt.Errorf("No cluster alert rule ID is set") - } - - client, err := testAccProvider.Meta().(*Config).ManagementClient() - if err != nil { - return err - } - - foundAr, err := client.ClusterAlertRule.ByID(rs.Primary.ID) - if err != nil { - if IsNotFound(err) { - return fmt.Errorf("Cluster Alert Rule not found") - } - return err - } - - ar = foundAr - - return nil - } -} - -func testAccCheckRancher2ClusterAlertRuleDestroy(s *terraform.State) error { - for _, rs := range s.RootModule().Resources { - if rs.Type != testAccRancher2ClusterAlertRuleType { - continue - } - - client, err := testAccProvider.Meta().(*Config).ManagementClient() - if err != nil { - return err - } - - _, err = client.ClusterAlertRule.ByID(rs.Primary.ID) - if err != nil { - if IsNotFound(err) { - return nil - } - return err - } - return fmt.Errorf("Cluster Alert Rule still exists") - } - return nil -} diff --git a/rancher2/resource_rancher2_cluster_sync.go b/rancher2/resource_rancher2_cluster_sync.go index cb8f10f9..bc6d7d4c 100644 --- a/rancher2/resource_rancher2_cluster_sync.go +++ b/rancher2/resource_rancher2_cluster_sync.go @@ -2,10 +2,11 @@ package rancher2 import ( "fmt" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "log" "time" + "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" ) @@ -54,20 +55,6 @@ func resourceRancher2ClusterSyncCreate(d *schema.ResourceData, meta interface{}) } } - if cluster.EnableClusterMonitoring && d.Get("wait_monitoring").(bool) { - _, err := meta.(*Config).WaitForClusterState(clusterID, clusterMonitoringEnabledCondition, d.Timeout(schema.TimeoutCreate)) - if err != nil { - return fmt.Errorf("[ERROR] waiting for cluster ID (%s) monitoring to be running: %v", clusterID, err) - } - } - - if cluster.EnableClusterAlerting && d.Get("wait_alerting").(bool) { - _, err := meta.(*Config).WaitForClusterState(clusterID, clusterAlertingEnabledCondition, d.Timeout(schema.TimeoutCreate)) - if err != nil { - return fmt.Errorf("[ERROR] waiting for cluster ID (%s) alerting to be running: %v", clusterID, err) - } - } - if d.Get("wait_catalogs").(bool) { _, err := waitAllCatalogV2Downloaded(meta.(*Config), clusterID) if err != nil { @@ -127,28 +114,6 @@ func resourceRancher2ClusterSyncRead(d *schema.ResourceData, meta interface{}) e } d.Set("nodes", flattenClusterNodes(nodes)) - if clus.EnableClusterMonitoring && d.Get("wait_monitoring").(bool) { - monitor, _, err := meta.(*Config).isClusterMonitoringEnabledCondition(clusterID) - if err != nil { - return resource.NonRetryableError(err) - } - if !monitor { - d.Set("synced", false) - return nil - } - } - - if clus.EnableClusterAlerting && d.Get("wait_alerting").(bool) { - alert, _, err := meta.(*Config).isClusterAlertingEnabledCondition(clusterID) - if err != nil { - return resource.NonRetryableError(err) - } - if !alert { - d.Set("synced", false) - return nil - } - } - if d.Get("wait_catalogs").(bool) { _, err := waitAllCatalogV2Downloaded(meta.(*Config), clusterID) if err != nil { diff --git a/rancher2/resource_rancher2_cluster_template_test.go b/rancher2/resource_rancher2_cluster_template_test.go index d7c2afd6..ca376b48 100644 --- a/rancher2/resource_rancher2_cluster_template_test.go +++ b/rancher2/resource_rancher2_cluster_template_test.go @@ -26,8 +26,6 @@ resource "` + testAccRancher2ClusterTemplateType + `" "foo" { cluster_auth_endpoint { enabled = true } - enable_cluster_alerting = false - enable_cluster_monitoring = true enable_network_policy = false rke_config { ignore_docker_version = true @@ -67,7 +65,6 @@ resource "` + testAccRancher2ClusterTemplateType + `" "foo" { } kube_api { service_node_port_range = "30000-32767" - pod_security_policy = false always_pull_images = false } } @@ -104,8 +101,6 @@ resource "` + testAccRancher2ClusterTemplateType + `" "foo" { cluster_auth_endpoint { enabled = true } - enable_cluster_alerting = false - enable_cluster_monitoring = true enable_network_policy = false rke_config { ignore_docker_version = true @@ -145,7 +140,6 @@ resource "` + testAccRancher2ClusterTemplateType + `" "foo" { } kube_api { service_node_port_range = "30000-32767" - pod_security_policy = false always_pull_images = false } } diff --git a/rancher2/resource_rancher2_notifier.go b/rancher2/resource_rancher2_notifier.go deleted file mode 100644 index d24d94f0..00000000 --- a/rancher2/resource_rancher2_notifier.go +++ /dev/null @@ -1,191 +0,0 @@ -package rancher2 - -import ( - "fmt" - "log" - "time" - - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - managementClient "github.com/rancher/rancher/pkg/client/generated/management/v3" -) - -func resourceRancher2Notifier() *schema.Resource { - return &schema.Resource{ - Create: resourceRancher2NotifierCreate, - Read: resourceRancher2NotifierRead, - Update: resourceRancher2NotifierUpdate, - Delete: resourceRancher2NotifierDelete, - Importer: &schema.ResourceImporter{ - State: resourceRancher2NotifierImport, - }, - - Schema: notifierFields(), - Timeouts: &schema.ResourceTimeout{ - Create: schema.DefaultTimeout(10 * time.Minute), - Update: schema.DefaultTimeout(10 * time.Minute), - Delete: schema.DefaultTimeout(10 * time.Minute), - }, - } -} - -func resourceRancher2NotifierCreate(d *schema.ResourceData, meta interface{}) error { - notifier, err := expandNotifier(d) - if err != nil { - return err - } - - log.Printf("[INFO] Creating Notifier %s", notifier.Name) - - client, err := meta.(*Config).ManagementClient() - if err != nil { - return err - } - - newNotifier, err := client.Notifier.Create(notifier) - if err != nil { - return err - } - - d.SetId(newNotifier.ID) - - stateConf := &resource.StateChangeConf{ - Pending: []string{}, - Target: []string{"active"}, - Refresh: notifierStateRefreshFunc(client, newNotifier.ID), - Timeout: d.Timeout(schema.TimeoutCreate), - Delay: 1 * time.Second, - MinTimeout: 3 * time.Second, - } - _, waitErr := stateConf.WaitForState() - if waitErr != nil { - return fmt.Errorf( - "[ERROR] waiting for notifier (%s) to be created: %s", newNotifier.ID, waitErr) - } - - return resourceRancher2NotifierRead(d, meta) -} - -func resourceRancher2NotifierRead(d *schema.ResourceData, meta interface{}) error { - log.Printf("[INFO] Refreshing Notifier ID %s", d.Id()) - client, err := meta.(*Config).ManagementClient() - if err != nil { - return err - } - - return resource.Retry(d.Timeout(schema.TimeoutRead), func() *resource.RetryError { - notifier, err := client.Notifier.ByID(d.Id()) - if err != nil { - if IsNotFound(err) || IsForbidden(err) { - log.Printf("[INFO] Notifier ID %s not found.", d.Id()) - d.SetId("") - return nil - } - return resource.NonRetryableError(err) - } - - if err = flattenNotifier(d, notifier); err != nil { - return resource.NonRetryableError(err) - } - - return nil - }) -} - -func resourceRancher2NotifierUpdate(d *schema.ResourceData, meta interface{}) error { - log.Printf("[INFO] Updating Notifier ID %s", d.Id()) - client, err := meta.(*Config).ManagementClient() - if err != nil { - return err - } - - notifier, err := client.Notifier.ByID(d.Id()) - if err != nil { - return err - } - - newNotifier, err := expandNotifier(d) - if err != nil { - return err - } - newNotifier.Links = notifier.Links - newNotifier, err = client.Notifier.Replace(newNotifier) - if err != nil { - return err - } - - stateConf := &resource.StateChangeConf{ - Pending: []string{"active"}, - Target: []string{"active"}, - Refresh: notifierStateRefreshFunc(client, newNotifier.ID), - Timeout: d.Timeout(schema.TimeoutUpdate), - Delay: 1 * time.Second, - MinTimeout: 3 * time.Second, - } - _, waitErr := stateConf.WaitForState() - if waitErr != nil { - return fmt.Errorf( - "[ERROR] waiting for notifier (%s) to be updated: %s", newNotifier.ID, waitErr) - } - - return resourceRancher2NotifierRead(d, meta) -} - -func resourceRancher2NotifierDelete(d *schema.ResourceData, meta interface{}) error { - log.Printf("[INFO] Deleting Notifier ID %s", d.Id()) - id := d.Id() - client, err := meta.(*Config).ManagementClient() - if err != nil { - return err - } - - notifier, err := client.Notifier.ByID(id) - if err != nil { - if IsNotFound(err) || IsForbidden(err) { - log.Printf("[INFO] Notifier ID %s not found.", d.Id()) - d.SetId("") - return nil - } - return err - } - - err = client.Notifier.Delete(notifier) - if err != nil { - return fmt.Errorf("Error removing Notifier: %s", err) - } - - log.Printf("[DEBUG] Waiting for notifier (%s) to be removed", id) - - stateConf := &resource.StateChangeConf{ - Pending: []string{"removing"}, - Target: []string{"removed"}, - Refresh: notifierStateRefreshFunc(client, id), - Timeout: d.Timeout(schema.TimeoutDelete), - Delay: 1 * time.Second, - MinTimeout: 3 * time.Second, - } - - _, waitErr := stateConf.WaitForState() - if waitErr != nil { - return fmt.Errorf( - "[ERROR] waiting for notifier (%s) to be removed: %s", id, waitErr) - } - - d.SetId("") - return nil -} - -// notifierStateRefreshFunc returns a resource.StateRefreshFunc, used to watch a Rancher Notifier. -func notifierStateRefreshFunc(client *managementClient.Client, notifierID string) resource.StateRefreshFunc { - return func() (interface{}, string, error) { - obj, err := client.Notifier.ByID(notifierID) - if err != nil { - if IsNotFound(err) || IsForbidden(err) { - return obj, "removed", nil - } - return nil, "", err - } - - return obj, obj.State, nil - } -} diff --git a/rancher2/resource_rancher2_notifier_test.go b/rancher2/resource_rancher2_notifier_test.go deleted file mode 100644 index 66c66ee2..00000000 --- a/rancher2/resource_rancher2_notifier_test.go +++ /dev/null @@ -1,799 +0,0 @@ -package rancher2 - -import ( - "fmt" - "testing" - "time" - - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/terraform" - managementClient "github.com/rancher/rancher/pkg/client/generated/management/v3" -) - -const ( - testAccRancher2NotifierType = "rancher2_notifier" -) - -var ( - testAccRancher2NotifierDingtalk string - testAccRancher2NotifierDingtalkUpdate string - testAccRancher2NotifierDingtalkConfig string - testAccRancher2NotifierDingtalkUpdateConfig string - testAccRancher2NotifierMSTeams string - testAccRancher2NotifierMSTeamsUpdate string - testAccRancher2NotifierMSTeamsConfig string - testAccRancher2NotifierMSTeamsUpdateConfig string - testAccRancher2NotifierPagerduty string - testAccRancher2NotifierPagerdutyUpdate string - testAccRancher2NotifierPagerdutyConfig string - testAccRancher2NotifierPagerdutyUpdateConfig string - testAccRancher2NotifierSlack string - testAccRancher2NotifierSlackUpdate string - testAccRancher2NotifierSlackConfig string - testAccRancher2NotifierSlackUpdateConfig string - testAccRancher2NotifierSMTP string - testAccRancher2NotifierSMTPUpdate string - testAccRancher2NotifierSMTPConfig string - testAccRancher2NotifierSMTPUpdateConfig string - testAccRancher2NotifierWebhook string - testAccRancher2NotifierWebhookUpdate string - testAccRancher2NotifierWebhookConfig string - testAccRancher2NotifierWebhookUpdateConfig string - testAccRancher2NotifierWechat string - testAccRancher2NotifierWechatUpdate string - testAccRancher2NotifierWechatConfig string - testAccRancher2NotifierWechatUpdateConfig string -) - -func init() { - testAccRancher2NotifierDingtalk = ` -resource "` + testAccRancher2NotifierType + `" "foo-dingtalk" { - name = "foo-dingtalk" - cluster_id = rancher2_cluster_sync.testacc.cluster_id - send_resolved = "true" - description = "Terraform notifier acceptance test" - dingtalk_config { - url = "http://url.test.io" - proxy_url = "http://proxy.test.io" - } -} -` - testAccRancher2NotifierDingtalkUpdate = ` -resource "` + testAccRancher2NotifierType + `" "foo-dingtalk" { - name = "foo-dingtalk" - cluster_id = rancher2_cluster_sync.testacc.cluster_id - send_resolved = "false" - description = "Terraform notifier acceptance test - updated" - dingtalk_config { - url = "http://url2.test.io" - proxy_url = "http://proxy2.test.io" - } -} -` - testAccRancher2NotifierDingtalkConfig = testAccCheckRancher2ClusterSyncTestacc + testAccRancher2NotifierDingtalk - testAccRancher2NotifierDingtalkUpdateConfig = testAccCheckRancher2ClusterSyncTestacc + testAccRancher2NotifierDingtalkUpdate - testAccRancher2NotifierMSTeams = ` -resource "` + testAccRancher2NotifierType + `" "foo-msteams" { - name = "foo-msteams" - cluster_id = rancher2_cluster_sync.testacc.cluster_id - send_resolved = "true" - description = "Terraform notifier acceptance test" - msteams_config { - url = "http://url.test.io" - proxy_url = "http://proxy.test.io" - } -} -` - testAccRancher2NotifierMSTeamsUpdate = ` -resource "` + testAccRancher2NotifierType + `" "foo-msteams" { - name = "foo-msteams" - cluster_id = rancher2_cluster_sync.testacc.cluster_id - send_resolved = "false" - description = "Terraform notifier acceptance test - updated" - msteams_config { - url = "http://url2.test.io" - proxy_url = "http://proxy2.test.io" - } -} -` - testAccRancher2NotifierMSTeamsConfig = testAccCheckRancher2ClusterSyncTestacc + testAccRancher2NotifierMSTeams - testAccRancher2NotifierMSTeamsUpdateConfig = testAccCheckRancher2ClusterSyncTestacc + testAccRancher2NotifierMSTeamsUpdate - testAccRancher2NotifierPagerduty = ` -resource "` + testAccRancher2NotifierType + `" "foo-pagerduty" { - name = "foo-pagerduty" - cluster_id = rancher2_cluster_sync.testacc.cluster_id - send_resolved = "true" - description = "Terraform notifier acceptance test" - pagerduty_config { - service_key = "XXXXXXXX" - proxy_url = "http://proxy.test.io" - } -} -` - testAccRancher2NotifierPagerdutyUpdate = ` -resource "` + testAccRancher2NotifierType + `" "foo-pagerduty" { - name = "foo-pagerduty" - cluster_id = rancher2_cluster_sync.testacc.cluster_id - send_resolved = "false" - description = "Terraform notifier acceptance test - updated" - pagerduty_config { - service_key = "YYYYYYYY" - proxy_url = "http://proxy2.test.io" - } -} -` - testAccRancher2NotifierPagerdutyConfig = testAccCheckRancher2ClusterSyncTestacc + testAccRancher2NotifierPagerduty - testAccRancher2NotifierPagerdutyUpdateConfig = testAccCheckRancher2ClusterSyncTestacc + testAccRancher2NotifierPagerdutyUpdate - testAccRancher2NotifierSlack = ` -resource "` + testAccRancher2NotifierType + `" "foo-slack" { - name = "foo-slack" - cluster_id = rancher2_cluster_sync.testacc.cluster_id - send_resolved = "true" - description = "Terraform notifier acceptance test" - slack_config { - default_recipient = "XXXXXXXX" - url = "http://url.test.io" - proxy_url = "http://proxy.test.io" - } -} -` - testAccRancher2NotifierSlackUpdate = ` -resource "` + testAccRancher2NotifierType + `" "foo-slack" { - name = "foo-slack" - cluster_id = rancher2_cluster_sync.testacc.cluster_id - send_resolved = "false" - description = "Terraform notifier acceptance test - updated" - slack_config { - default_recipient = "YYYYYYYY" - url = "http://url2.test.io" - proxy_url = "http://proxy2.test.io" - } -} -` - testAccRancher2NotifierSlackConfig = testAccCheckRancher2ClusterSyncTestacc + testAccRancher2NotifierSlack - testAccRancher2NotifierSlackUpdateConfig = testAccCheckRancher2ClusterSyncTestacc + testAccRancher2NotifierSlackUpdate - testAccRancher2NotifierSMTP = ` -resource "` + testAccRancher2NotifierType + `" "foo-smtp" { - name = "foo-smtp" - cluster_id = rancher2_cluster_sync.testacc.cluster_id - send_resolved = "true" - description = "Terraform notifier acceptance test" - smtp_config { - default_recipient = "XXXXXXXX" - host = "host.test.io" - port = 25 - sender = "sender@test.io" - tls = "true" - } -} -` - testAccRancher2NotifierSMTPUpdate = ` -resource "` + testAccRancher2NotifierType + `" "foo-smtp" { - name = "foo-smtp" - cluster_id = rancher2_cluster_sync.testacc.cluster_id - send_resolved = "false" - description = "Terraform notifier acceptance test - updated" - smtp_config { - default_recipient = "YYYYYYYY" - host = "host2.test.io" - port = 25 - sender = "sender2@test.io" - tls = "true" - } -} -` - testAccRancher2NotifierSMTPConfig = testAccCheckRancher2ClusterSyncTestacc + testAccRancher2NotifierSMTP - testAccRancher2NotifierSMTPUpdateConfig = testAccCheckRancher2ClusterSyncTestacc + testAccRancher2NotifierSMTPUpdate - testAccRancher2NotifierWebhook = ` -resource "` + testAccRancher2NotifierType + `" "foo-webhook" { - name = "foo-webhook" - cluster_id = rancher2_cluster_sync.testacc.cluster_id - send_resolved = "true" - description = "Terraform notifier acceptance test" - webhook_config { - url = "http://url.test.io" - proxy_url = "http://proxy.test.io" - } -} -` - testAccRancher2NotifierWebhookUpdate = ` -resource "` + testAccRancher2NotifierType + `" "foo-webhook" { - name = "foo-webhook" - cluster_id = rancher2_cluster_sync.testacc.cluster_id - send_resolved = "false" - description = "Terraform notifier acceptance test - updated" - webhook_config { - url = "http://url2.test.io" - proxy_url = "http://proxy2.test.io" - } -} -` - testAccRancher2NotifierWebhookConfig = testAccCheckRancher2ClusterSyncTestacc + testAccRancher2NotifierWebhook - testAccRancher2NotifierWebhookUpdateConfig = testAccCheckRancher2ClusterSyncTestacc + testAccRancher2NotifierWebhookUpdate - testAccRancher2NotifierWechat = ` -resource "` + testAccRancher2NotifierType + `" "foo-wechat" { - name = "foo-wechat" - cluster_id = rancher2_cluster_sync.testacc.cluster_id - send_resolved = "true" - description = "Terraform notifier acceptance test" - wechat_config { - agent = "agent_id" - corp = "corp_id" - default_recipient = "XXXXXXXX" - secret = "XXXXXXXX" - proxy_url = "http://proxy.test.io" - } -} -` - testAccRancher2NotifierWechatUpdate = ` -resource "` + testAccRancher2NotifierType + `" "foo-wechat" { - name = "foo-wechat" - cluster_id = rancher2_cluster_sync.testacc.cluster_id - send_resolved = "false" - description = "Terraform notifier acceptance test - updated" - wechat_config { - agent = "agent_id" - corp = "corp_id" - default_recipient = "YYYYYYYY" - secret = "YYYYYYYY" - proxy_url = "http://proxy2.test.io" - } -} -` - testAccRancher2NotifierWechatConfig = testAccCheckRancher2ClusterSyncTestacc + testAccRancher2NotifierWechat - testAccRancher2NotifierWechatUpdateConfig = testAccCheckRancher2ClusterSyncTestacc + testAccRancher2NotifierWechatUpdate -} - -func TestAccRancher2Notifier_basic_Dingtalk(t *testing.T) { - var notifier *managementClient.Notifier - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckRancher2NotifierDestroy, - Steps: []resource.TestStep{ - { - Config: testAccRancher2NotifierDingtalkConfig, - Check: resource.ComposeTestCheckFunc( - testAccCheckRancher2NotifierExists(testAccRancher2NotifierType+".foo-dingtalk", notifier), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-dingtalk", "name", "foo-dingtalk"), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-dingtalk", "description", "Terraform notifier acceptance test"), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-dingtalk", "send_resolved", "true"), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-dingtalk", "dingtalk_config.0.url", "http://url.test.io"), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-dingtalk", "dingtalk_config.0.proxy_url", "http://proxy.test.io"), - ), - }, - { - Config: testAccRancher2NotifierDingtalkUpdateConfig, - Check: resource.ComposeTestCheckFunc( - testAccCheckRancher2NotifierExists(testAccRancher2NotifierType+".foo-dingtalk", notifier), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-dingtalk", "name", "foo-dingtalk"), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-dingtalk", "description", "Terraform notifier acceptance test - updated"), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-dingtalk", "send_resolved", "false"), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-dingtalk", "dingtalk_config.0.url", "http://url2.test.io"), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-dingtalk", "dingtalk_config.0.proxy_url", "http://proxy2.test.io"), - ), - }, - { - Config: testAccRancher2NotifierDingtalkConfig, - Check: resource.ComposeTestCheckFunc( - testAccCheckRancher2NotifierExists(testAccRancher2NotifierType+".foo-dingtalk", notifier), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-dingtalk", "name", "foo-dingtalk"), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-dingtalk", "description", "Terraform notifier acceptance test"), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-dingtalk", "send_resolved", "true"), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-dingtalk", "dingtalk_config.0.url", "http://url.test.io"), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-dingtalk", "dingtalk_config.0.proxy_url", "http://proxy.test.io"), - ), - }, - }, - }) -} - -func TestAccRancher2Notifier_disappears_Dingtalk(t *testing.T) { - var notifier *managementClient.Notifier - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckRancher2NotifierDestroy, - Steps: []resource.TestStep{ - { - Config: testAccRancher2NotifierDingtalkConfig, - Check: resource.ComposeTestCheckFunc( - testAccCheckRancher2NotifierExists(testAccRancher2NotifierType+".foo-dingtalk", notifier), - testAccRancher2NotifierDisappears(notifier), - ), - ExpectNonEmptyPlan: true, - }, - }, - }) -} - -func TestAccRancher2Notifier_basic_MSTeams(t *testing.T) { - var notifier *managementClient.Notifier - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckRancher2NotifierDestroy, - Steps: []resource.TestStep{ - { - Config: testAccRancher2NotifierMSTeamsConfig, - Check: resource.ComposeTestCheckFunc( - testAccCheckRancher2NotifierExists(testAccRancher2NotifierType+".foo-msteams", notifier), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-msteams", "name", "foo-msteams"), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-msteams", "description", "Terraform notifier acceptance test"), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-msteams", "send_resolved", "true"), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-msteams", "msteams_config.0.url", "http://url.test.io"), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-msteams", "msteams_config.0.proxy_url", "http://proxy.test.io"), - ), - }, - { - Config: testAccRancher2NotifierMSTeamsUpdateConfig, - Check: resource.ComposeTestCheckFunc( - testAccCheckRancher2NotifierExists(testAccRancher2NotifierType+".foo-msteams", notifier), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-msteams", "name", "foo-msteams"), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-msteams", "description", "Terraform notifier acceptance test - updated"), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-msteams", "send_resolved", "false"), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-msteams", "msteams_config.0.url", "http://url2.test.io"), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-msteams", "msteams_config.0.proxy_url", "http://proxy2.test.io"), - ), - }, - { - Config: testAccRancher2NotifierMSTeamsConfig, - Check: resource.ComposeTestCheckFunc( - testAccCheckRancher2NotifierExists(testAccRancher2NotifierType+".foo-msteams", notifier), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-msteams", "name", "foo-msteams"), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-msteams", "description", "Terraform notifier acceptance test"), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-msteams", "send_resolved", "true"), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-msteams", "msteams_config.0.url", "http://url.test.io"), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-msteams", "msteams_config.0.proxy_url", "http://proxy.test.io"), - ), - }, - }, - }) -} - -func TestAccRancher2Notifier_disappears_MSTeams(t *testing.T) { - var notifier *managementClient.Notifier - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckRancher2NotifierDestroy, - Steps: []resource.TestStep{ - { - Config: testAccRancher2NotifierMSTeamsConfig, - Check: resource.ComposeTestCheckFunc( - testAccCheckRancher2NotifierExists(testAccRancher2NotifierType+".foo-msteams", notifier), - testAccRancher2NotifierDisappears(notifier), - ), - ExpectNonEmptyPlan: true, - }, - }, - }) -} - -func TestAccRancher2Notifier_basic_Pagerduty(t *testing.T) { - var notifier *managementClient.Notifier - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckRancher2NotifierDestroy, - Steps: []resource.TestStep{ - { - Config: testAccRancher2NotifierPagerdutyConfig, - Check: resource.ComposeTestCheckFunc( - testAccCheckRancher2NotifierExists(testAccRancher2NotifierType+".foo-pagerduty", notifier), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-pagerduty", "name", "foo-pagerduty"), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-pagerduty", "description", "Terraform notifier acceptance test"), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-pagerduty", "send_resolved", "true"), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-pagerduty", "pagerduty_config.0.service_key", "XXXXXXXX"), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-pagerduty", "pagerduty_config.0.proxy_url", "http://proxy.test.io"), - ), - }, - { - Config: testAccRancher2NotifierPagerdutyUpdateConfig, - Check: resource.ComposeTestCheckFunc( - testAccCheckRancher2NotifierExists(testAccRancher2NotifierType+".foo-pagerduty", notifier), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-pagerduty", "name", "foo-pagerduty"), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-pagerduty", "description", "Terraform notifier acceptance test - updated"), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-pagerduty", "send_resolved", "false"), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-pagerduty", "pagerduty_config.0.proxy_url", "http://proxy2.test.io"), - ), - }, - { - Config: testAccRancher2NotifierPagerdutyConfig, - Check: resource.ComposeTestCheckFunc( - testAccCheckRancher2NotifierExists(testAccRancher2NotifierType+".foo-pagerduty", notifier), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-pagerduty", "name", "foo-pagerduty"), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-pagerduty", "description", "Terraform notifier acceptance test"), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-pagerduty", "send_resolved", "true"), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-pagerduty", "pagerduty_config.0.service_key", "XXXXXXXX"), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-pagerduty", "pagerduty_config.0.proxy_url", "http://proxy.test.io"), - ), - }, - }, - }) -} - -func TestAccRancher2Notifier_disappears_Pagerduty(t *testing.T) { - var notifier *managementClient.Notifier - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckRancher2NotifierDestroy, - Steps: []resource.TestStep{ - { - Config: testAccRancher2NotifierPagerdutyConfig, - Check: resource.ComposeTestCheckFunc( - testAccCheckRancher2NotifierExists(testAccRancher2NotifierType+".foo-pagerduty", notifier), - testAccRancher2NotifierDisappears(notifier), - ), - ExpectNonEmptyPlan: true, - }, - }, - }) -} - -func TestAccRancher2Notifier_basic_Slack(t *testing.T) { - var notifier *managementClient.Notifier - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckRancher2NotifierDestroy, - Steps: []resource.TestStep{ - { - Config: testAccRancher2NotifierSlackConfig, - Check: resource.ComposeTestCheckFunc( - testAccCheckRancher2NotifierExists(testAccRancher2NotifierType+".foo-slack", notifier), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-slack", "name", "foo-slack"), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-slack", "description", "Terraform notifier acceptance test"), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-slack", "send_resolved", "true"), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-slack", "slack_config.0.default_recipient", "XXXXXXXX"), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-slack", "slack_config.0.url", "http://url.test.io"), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-slack", "slack_config.0.proxy_url", "http://proxy.test.io"), - ), - }, - { - Config: testAccRancher2NotifierSlackUpdateConfig, - Check: resource.ComposeTestCheckFunc( - testAccCheckRancher2NotifierExists(testAccRancher2NotifierType+".foo-slack", notifier), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-slack", "name", "foo-slack"), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-slack", "slack_config.0.default_recipient", "YYYYYYYY"), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-slack", "slack_config.0.url", "http://url2.test.io"), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-slack", "slack_config.0.proxy_url", "http://proxy2.test.io"), - ), - }, - { - Config: testAccRancher2NotifierSlackConfig, - Check: resource.ComposeTestCheckFunc( - testAccCheckRancher2NotifierExists(testAccRancher2NotifierType+".foo-slack", notifier), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-slack", "name", "foo-slack"), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-slack", "description", "Terraform notifier acceptance test"), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-slack", "send_resolved", "true"), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-slack", "slack_config.0.default_recipient", "XXXXXXXX"), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-slack", "slack_config.0.url", "http://url.test.io"), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-slack", "slack_config.0.proxy_url", "http://proxy.test.io"), - ), - }, - }, - }) -} - -func TestAccRancher2Notifier_disappears_Slack(t *testing.T) { - var notifier *managementClient.Notifier - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckRancher2NotifierDestroy, - Steps: []resource.TestStep{ - { - Config: testAccRancher2NotifierSlackConfig, - Check: resource.ComposeTestCheckFunc( - testAccCheckRancher2NotifierExists(testAccRancher2NotifierType+".foo-slack", notifier), - testAccRancher2NotifierDisappears(notifier), - ), - ExpectNonEmptyPlan: true, - }, - }, - }) -} - -func TestAccRancher2Notifier_basic_SMTP(t *testing.T) { - var notifier *managementClient.Notifier - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckRancher2NotifierDestroy, - Steps: []resource.TestStep{ - { - Config: testAccRancher2NotifierSMTPConfig, - Check: resource.ComposeTestCheckFunc( - testAccCheckRancher2NotifierExists(testAccRancher2NotifierType+".foo-smtp", notifier), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-smtp", "name", "foo-smtp"), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-smtp", "description", "Terraform notifier acceptance test"), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-smtp", "send_resolved", "true"), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-smtp", "smtp_config.0.default_recipient", "XXXXXXXX"), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-smtp", "smtp_config.0.host", "host.test.io"), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-smtp", "smtp_config.0.sender", "sender@test.io"), - ), - }, - { - Config: testAccRancher2NotifierSMTPUpdateConfig, - Check: resource.ComposeTestCheckFunc( - testAccCheckRancher2NotifierExists(testAccRancher2NotifierType+".foo-smtp", notifier), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-smtp", "name", "foo-smtp"), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-smtp", "smtp_config.0.default_recipient", "YYYYYYYY"), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-smtp", "smtp_config.0.host", "host2.test.io"), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-smtp", "smtp_config.0.sender", "sender2@test.io"), - ), - }, - { - Config: testAccRancher2NotifierSMTPConfig, - Check: resource.ComposeTestCheckFunc( - testAccCheckRancher2NotifierExists(testAccRancher2NotifierType+".foo-smtp", notifier), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-smtp", "name", "foo-smtp"), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-smtp", "description", "Terraform notifier acceptance test"), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-smtp", "send_resolved", "true"), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-smtp", "smtp_config.0.default_recipient", "XXXXXXXX"), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-smtp", "smtp_config.0.host", "host.test.io"), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-smtp", "smtp_config.0.sender", "sender@test.io"), - ), - }, - }, - }) -} - -func TestAccRancher2Notifier_disappears_SMTP(t *testing.T) { - var notifier *managementClient.Notifier - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckRancher2NotifierDestroy, - Steps: []resource.TestStep{ - { - Config: testAccRancher2NotifierSMTPConfig, - Check: resource.ComposeTestCheckFunc( - testAccCheckRancher2NotifierExists(testAccRancher2NotifierType+".foo-smtp", notifier), - testAccRancher2NotifierDisappears(notifier), - ), - ExpectNonEmptyPlan: true, - }, - }, - }) -} - -func TestAccRancher2Notifier_basic_Webhook(t *testing.T) { - var notifier *managementClient.Notifier - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckRancher2NotifierDestroy, - Steps: []resource.TestStep{ - { - Config: testAccRancher2NotifierWebhookConfig, - Check: resource.ComposeTestCheckFunc( - testAccCheckRancher2NotifierExists(testAccRancher2NotifierType+".foo-webhook", notifier), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-webhook", "name", "foo-webhook"), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-webhook", "description", "Terraform notifier acceptance test"), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-webhook", "send_resolved", "true"), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-webhook", "webhook_config.0.url", "http://url.test.io"), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-webhook", "webhook_config.0.proxy_url", "http://proxy.test.io"), - ), - }, - { - Config: testAccRancher2NotifierWebhookUpdateConfig, - Check: resource.ComposeTestCheckFunc( - testAccCheckRancher2NotifierExists(testAccRancher2NotifierType+".foo-webhook", notifier), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-webhook", "name", "foo-webhook"), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-webhook", "webhook_config.0.url", "http://url2.test.io"), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-webhook", "webhook_config.0.proxy_url", "http://proxy2.test.io"), - ), - }, - { - Config: testAccRancher2NotifierWebhookConfig, - Check: resource.ComposeTestCheckFunc( - testAccCheckRancher2NotifierExists(testAccRancher2NotifierType+".foo-webhook", notifier), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-webhook", "name", "foo-webhook"), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-webhook", "description", "Terraform notifier acceptance test"), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-webhook", "send_resolved", "true"), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-webhook", "webhook_config.0.url", "http://url.test.io"), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-webhook", "webhook_config.0.proxy_url", "http://proxy.test.io"), - ), - }, - }, - }) -} - -func TestAccRancher2Notifier_disappears_Webhook(t *testing.T) { - var notifier *managementClient.Notifier - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckRancher2NotifierDestroy, - Steps: []resource.TestStep{ - { - Config: testAccRancher2NotifierWebhookConfig, - Check: resource.ComposeTestCheckFunc( - testAccCheckRancher2NotifierExists(testAccRancher2NotifierType+".foo-webhook", notifier), - testAccRancher2NotifierDisappears(notifier), - ), - ExpectNonEmptyPlan: true, - }, - }, - }) -} - -func TestAccRancher2Notifier_basic_Wechat(t *testing.T) { - var notifier *managementClient.Notifier - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckRancher2NotifierDestroy, - Steps: []resource.TestStep{ - { - Config: testAccRancher2NotifierWechatConfig, - Check: resource.ComposeTestCheckFunc( - testAccCheckRancher2NotifierExists(testAccRancher2NotifierType+".foo-wechat", notifier), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-wechat", "name", "foo-wechat"), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-wechat", "description", "Terraform notifier acceptance test"), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-wechat", "send_resolved", "true"), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-wechat", "wechat_config.0.default_recipient", "XXXXXXXX"), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-wechat", "wechat_config.0.secret", "XXXXXXXX"), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-wechat", "wechat_config.0.proxy_url", "http://proxy.test.io"), - ), - }, - { - Config: testAccRancher2NotifierWechatUpdateConfig, - Check: resource.ComposeTestCheckFunc( - testAccCheckRancher2NotifierExists(testAccRancher2NotifierType+".foo-wechat", notifier), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-wechat", "name", "foo-wechat"), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-wechat", "wechat_config.0.default_recipient", "YYYYYYYY"), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-wechat", "wechat_config.0.secret", "YYYYYYYY"), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-wechat", "wechat_config.0.proxy_url", "http://proxy2.test.io"), - ), - }, - { - Config: testAccRancher2NotifierWechatConfig, - Check: resource.ComposeTestCheckFunc( - testAccCheckRancher2NotifierExists(testAccRancher2NotifierType+".foo-wechat", notifier), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-wechat", "name", "foo-wechat"), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-wechat", "description", "Terraform notifier acceptance test"), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-wechat", "send_resolved", "true"), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-wechat", "wechat_config.0.default_recipient", "XXXXXXXX"), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-wechat", "wechat_config.0.secret", "XXXXXXXX"), - resource.TestCheckResourceAttr(testAccRancher2NotifierType+".foo-wechat", "wechat_config.0.proxy_url", "http://proxy.test.io"), - ), - }, - }, - }) -} - -func TestAccRancher2Notifier_disappears_Wechat(t *testing.T) { - var notifier *managementClient.Notifier - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckRancher2NotifierDestroy, - Steps: []resource.TestStep{ - { - Config: testAccRancher2NotifierWechatConfig, - Check: resource.ComposeTestCheckFunc( - testAccCheckRancher2NotifierExists(testAccRancher2NotifierType+".foo-wechat", notifier), - testAccRancher2NotifierDisappears(notifier), - ), - ExpectNonEmptyPlan: true, - }, - }, - }) -} - -func testAccRancher2NotifierDisappears(notifier *managementClient.Notifier) resource.TestCheckFunc { - return func(s *terraform.State) error { - for _, rs := range s.RootModule().Resources { - if rs.Type != testAccRancher2NotifierType { - continue - } - - client, err := testAccProvider.Meta().(*Config).ManagementClient() - if err != nil { - return err - } - - notifier, err = client.Notifier.ByID(rs.Primary.ID) - if err != nil { - if IsNotFound(err) { - return nil - } - return err - } - - err = client.Notifier.Delete(notifier) - if err != nil { - return fmt.Errorf("Error removing Notifier: %s", err) - } - - stateConf := &resource.StateChangeConf{ - Pending: []string{"active"}, - Target: []string{"removed"}, - Refresh: notifierStateRefreshFunc(client, rs.Primary.ID), - Timeout: 10 * time.Minute, - Delay: 1 * time.Second, - MinTimeout: 3 * time.Second, - } - - _, waitErr := stateConf.WaitForState() - if waitErr != nil { - return fmt.Errorf( - "[ERROR] waiting for notifier (%s) to be removed: %s", rs.Primary.ID, waitErr) - } - } - return nil - - } -} - -func testAccCheckRancher2NotifierExists(n string, notifier *managementClient.Notifier) resource.TestCheckFunc { - return func(s *terraform.State) error { - rs, ok := s.RootModule().Resources[n] - - if !ok { - return fmt.Errorf("Not found: %s", n) - } - - if rs.Primary.ID == "" { - return fmt.Errorf("No notifier ID is set") - } - - client, err := testAccProvider.Meta().(*Config).ManagementClient() - if err != nil { - return err - } - - foundNot, err := client.Notifier.ByID(rs.Primary.ID) - if err != nil { - if IsNotFound(err) { - return fmt.Errorf("Notifier not found") - } - return err - } - - notifier = foundNot - - return nil - } -} - -func testAccCheckRancher2NotifierDestroy(s *terraform.State) error { - for _, rs := range s.RootModule().Resources { - if rs.Type != testAccRancher2NotifierType { - continue - } - client, err := testAccProvider.Meta().(*Config).ManagementClient() - if err != nil { - return err - } - - _, err = client.Notifier.ByID(rs.Primary.ID) - if err != nil { - if IsNotFound(err) { - return nil - } - return err - } - - return fmt.Errorf("Notifier still exists") - } - return nil -} diff --git a/rancher2/resource_rancher2_pod_security_admission_configuration_template.go b/rancher2/resource_rancher2_pod_security_admission_configuration_template.go index 69abc26d..3700f69d 100644 --- a/rancher2/resource_rancher2_pod_security_admission_configuration_template.go +++ b/rancher2/resource_rancher2_pod_security_admission_configuration_template.go @@ -149,14 +149,6 @@ func resourceRancher2PodSecurityAdmissionConfigurationTemplateDelete(d *schema.R // a Rancher PodSecurityAdmissionConfiguration Template func podSecurityAdmissionConfigurationTemplateStateRefreshFunc(client *managementClient.Client, pspID string) resource.StateRefreshFunc { return func() (interface{}, string, error) { - obj, err := client.PodSecurityPolicyTemplate.ByID(pspID) - if err != nil { - if IsNotFound(err) || IsForbidden(err) { - return obj, "removed", nil - } - return nil, "", err - } - - return obj, "active", nil + return nil, "active", nil } } diff --git a/rancher2/resource_rancher2_pod_security_policy_template.go b/rancher2/resource_rancher2_pod_security_policy_template.go deleted file mode 100644 index 915232dc..00000000 --- a/rancher2/resource_rancher2_pod_security_policy_template.go +++ /dev/null @@ -1,155 +0,0 @@ -package rancher2 - -import ( - "fmt" - "log" - "time" - - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - managementClient "github.com/rancher/rancher/pkg/client/generated/management/v3" -) - -func resourceRancher2PodSecurityPolicyTemplate() *schema.Resource { - return &schema.Resource{ - Create: resourceRancher2PodSecurityPolicyTemplateCreate, - Read: resourceRancher2PodSecurityPolicyTemplateRead, - Update: resourceRancher2PodSecurityPolicyTemplateUpdate, - Delete: resourceRancher2PodSecurityPolicyTemplateDelete, - Importer: &schema.ResourceImporter{ - State: resourceRancher2PodSecurityPolicyTemplateImport, - }, - - Schema: podSecurityPolicyTemplateFields(), - Timeouts: &schema.ResourceTimeout{ - Create: schema.DefaultTimeout(10 * time.Minute), - Update: schema.DefaultTimeout(10 * time.Minute), - Delete: schema.DefaultTimeout(10 * time.Minute), - }, - } -} - -func resourceRancher2PodSecurityPolicyTemplateCreate(d *schema.ResourceData, meta interface{}) error { - podSecurityPolicyTemplate := expandPodSecurityPolicyTemplate(d) - - log.Printf("[INFO] Creating PodSecurityPolicyTemplate %s", podSecurityPolicyTemplate.Name) - - client, err := meta.(*Config).ManagementClient() - if err != nil { - return err - } - - newPodSecurityPolicyTemplate, err := client.PodSecurityPolicyTemplate.Create(podSecurityPolicyTemplate) - if err != nil { - return err - } - - d.SetId(newPodSecurityPolicyTemplate.ID) - - return resourceRancher2PodSecurityPolicyTemplateRead(d, meta) -} - -func resourceRancher2PodSecurityPolicyTemplateRead(d *schema.ResourceData, meta interface{}) error { - log.Printf("[INFO] Refreshing PodSecurityPolicyTemplate with ID %s", d.Id()) - client, err := meta.(*Config).ManagementClient() - if err != nil { - return err - } - - return resource.Retry(d.Timeout(schema.TimeoutRead), func() *resource.RetryError { - pspt, err := client.PodSecurityPolicyTemplate.ByID(d.Id()) - if err != nil { - if IsNotFound(err) || IsForbidden(err) { - log.Printf("[INFO] PodSecurityPolicyTemplate with ID %s not found.", d.Id()) - d.SetId("") - return nil - } - return resource.NonRetryableError(err) - } - - if err = flattenPodSecurityPolicyTemplate(d, pspt); err != nil { - return resource.NonRetryableError(err) - } - - return nil - }) -} - -func resourceRancher2PodSecurityPolicyTemplateUpdate(d *schema.ResourceData, meta interface{}) error { - log.Printf("[INFO] Updating PodSecurityPolicyTemplate with ID %s", d.Id()) - client, err := meta.(*Config).ManagementClient() - if err != nil { - return err - } - - pspt, err := client.PodSecurityPolicyTemplate.ByID(d.Id()) - if err != nil { - return err - } - - update := expandPodSecurityPolicyTemplate(d) - - _, err = client.PodSecurityPolicyTemplate.Update(pspt, update) - if err != nil { - return err - } - - return resourceRancher2PodSecurityPolicyTemplateRead(d, meta) -} - -func resourceRancher2PodSecurityPolicyTemplateDelete(d *schema.ResourceData, meta interface{}) error { - id := d.Id() - log.Printf("[INFO] Deleting PodSecurityPolicyTemplate with ID %s", id) - client, err := meta.(*Config).ManagementClient() - if err != nil { - return err - } - - pspt, err := client.PodSecurityPolicyTemplate.ByID(id) - if err != nil { - if IsNotFound(err) || IsForbidden(err) { - log.Printf("[INFO] PodSecurityPolicyTemplate with ID %s not found.", id) - d.SetId("") - return nil - } - return err - } - - err = client.PodSecurityPolicyTemplate.Delete(pspt) - if err != nil { - return fmt.Errorf("[ERROR] removing PodSecurityPolicyTemplate: %s", err) - } - - stateConf := &resource.StateChangeConf{ - Pending: []string{"active"}, - Target: []string{"removed"}, - Refresh: podSecurityPolicyTemplateStateRefreshFunc(client, id), - Timeout: d.Timeout(schema.TimeoutDelete), - Delay: 1 * time.Second, - MinTimeout: 3 * time.Second, - } - - _, waitErr := stateConf.WaitForState() - if waitErr != nil { - return fmt.Errorf( - "[ERROR] waiting for PodSecurityPolicyTemplate (%s) to be removed: %s", id, waitErr) - } - - d.SetId("") - return nil -} - -// podSecurityPolicyTemplateStateRefreshFunc returns a resource.StateRefreshFunc, used to watch a Rancher PodSecurityPolicyTemplate -func podSecurityPolicyTemplateStateRefreshFunc(client *managementClient.Client, pspID string) resource.StateRefreshFunc { - return func() (interface{}, string, error) { - obj, err := client.PodSecurityPolicyTemplate.ByID(pspID) - if err != nil { - if IsNotFound(err) || IsForbidden(err) { - return obj, "removed", nil - } - return nil, "", err - } - - return obj, "active", nil - } -} diff --git a/rancher2/resource_rancher2_pod_security_policy_template_test.go b/rancher2/resource_rancher2_pod_security_policy_template_test.go deleted file mode 100644 index 66da5a67..00000000 --- a/rancher2/resource_rancher2_pod_security_policy_template_test.go +++ /dev/null @@ -1,275 +0,0 @@ -package rancher2 - -import ( - "fmt" - "testing" - - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/terraform" - managementClient "github.com/rancher/rancher/pkg/client/generated/management/v3" -) - -const testAccRancher2PodSecurityPolicyTemplateType = "rancher2_pod_security_policy_template" - -var ( - testAccCheckRancher2PodSecurityPolicyTemplate = ` -resource "` + testAccRancher2PodSecurityPolicyTemplateType + `" "foo" { - name = "foo" - description = "Terraform PodSecurityPolicyTemplate acceptance test" - allow_privilege_escalation = false - allowed_csi_driver { - name = "something" - } - allowed_csi_driver { - name = "something-else" - } - allowed_flex_volume { - driver = "something" - } - allowed_flex_volume { - driver = "something-else" - } - allowed_host_path { - path_prefix = "/" - read_only = true - } - allowed_host_path { - path_prefix = "//" - read_only = false - } - allowed_proc_mount_types = ["Default"] - default_allow_privilege_escalation = false - fs_group { - rule = "MustRunAs" - range { - min = 0 - max = 100 - } - range { - min = 0 - max = 100 - } - } - host_ipc = false - host_network = false - host_pid = false - host_port { - min = 0 - max = 65535 - } - host_port { - min = 1024 - max = 8080 - } - privileged = false - read_only_root_filesystem = false - required_drop_capabilities = ["something"] - - run_as_user { - rule = "MustRunAs" - range { - min = 1 - max = 100 - } - range { - min = 2 - max = 1024 - } - } - run_as_group { - rule = "MustRunAs" - range { - min = 1 - max = 100 - } - range { - min = 2 - max = 1024 - } - } - runtime_class { - default_runtime_class_name = "something" - allowed_runtime_class_names = ["something"] - } - se_linux { - rule = "RunAsAny" - } - supplemental_group { - rule = "RunAsAny" - } - volumes = ["azureFile"] -} -` - testAccCheckRancher2PodSecurityPolicyTemplateUpdate = ` -resource "` + testAccRancher2PodSecurityPolicyTemplateType + `" "foo" { - name = "foo" - description = "Terraform PodSecurityPolicyTemplate acceptance test - updated" - allow_privilege_escalation = false - allowed_csi_driver { - name = "something" - } - allowed_csi_driver { - name = "something-else" - } - allowed_flex_volume { - driver = "something" - } - allowed_flex_volume { - driver = "something-else" - } - allowed_host_path { - path_prefix = "/" - read_only = true - } - allowed_host_path { - path_prefix = "//" - read_only = false - } - allowed_proc_mount_types = ["Default"] - default_allow_privilege_escalation = false - fs_group { - rule = "MustRunAs" - range { - min = 0 - max = 100 - } - range { - min = 0 - max = 100 - } - } - host_ipc = false - host_network = false - host_pid = false - host_port { - min = 0 - max = 65535 - } - host_port { - min = 1024 - max = 8080 - } - privileged = false - read_only_root_filesystem = false - required_drop_capabilities = ["something"] - - run_as_user { - rule = "MustRunAs" - range { - min = 1 - max = 100 - } - range { - min = 2 - max = 1024 - } - } - run_as_group { - rule = "MustRunAs" - range { - min = 1 - max = 100 - } - range { - min = 2 - max = 1024 - } - } - runtime_class { - default_runtime_class_name = "something" - allowed_runtime_class_names = ["something"] - } - se_linux { - rule = "RunAsAny" - } - supplemental_group { - rule = "RunAsAny" - } - volumes = ["azureFile"] -} -` -) - -func init() {} - -func TestAccRancher2PodSecurityPolicyTemplate_Basic(t *testing.T) { - var pspTemplate *managementClient.PodSecurityPolicyTemplate - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckRancher2PodSecurityPolicyTemplateDestroy, - Steps: []resource.TestStep{ - { - Config: testAccCheckRancher2PodSecurityPolicyTemplate, - Check: resource.ComposeTestCheckFunc( - testAccCheckRancher2NPodSecurityPolicyTemplateExists(testAccRancher2PodSecurityPolicyTemplateType+".foo", pspTemplate), - resource.TestCheckResourceAttr(testAccRancher2PodSecurityPolicyTemplateType+".foo", "name", "foo"), - resource.TestCheckResourceAttr(testAccRancher2PodSecurityPolicyTemplateType+".foo", "description", "Terraform PodSecurityPolicyTemplate acceptance test"), - ), - }, - { - Config: testAccCheckRancher2PodSecurityPolicyTemplateUpdate, - Check: resource.ComposeTestCheckFunc( - testAccCheckRancher2NPodSecurityPolicyTemplateExists(testAccRancher2PodSecurityPolicyTemplateType+".foo", pspTemplate), - resource.TestCheckResourceAttr(testAccRancher2PodSecurityPolicyTemplateType+".foo", "name", "foo"), - resource.TestCheckResourceAttr(testAccRancher2PodSecurityPolicyTemplateType+".foo", "description", "Terraform PodSecurityPolicyTemplate acceptance test - updated"), - ), - }, - }, - }) -} - -func testAccCheckRancher2NPodSecurityPolicyTemplateExists(n string, pspTemplate *managementClient.PodSecurityPolicyTemplate) resource.TestCheckFunc { - return func(s *terraform.State) error { - rs, ok := s.RootModule().Resources[n] - - if !ok { - return fmt.Errorf("Not found: %s", n) - } - - if rs.Primary.ID == "" { - return fmt.Errorf("No PodSecurityPolicyTemplate ID is set") - } - - client, err := testAccProvider.Meta().(*Config).ManagementClient() - if err != nil { - return err - } - - foundPSP, err := client.PodSecurityPolicyTemplate.ByID(rs.Primary.ID) - if err != nil { - if IsNotFound(err) { - return fmt.Errorf("PodSecurityPolicyTemplate not found") - } - return err - } - - pspTemplate = foundPSP - - return nil - } -} - -func testAccCheckRancher2PodSecurityPolicyTemplateDestroy(s *terraform.State) error { - for _, rs := range s.RootModule().Resources { - if rs.Type != "rancher2_pod_security_policy_template" { - continue - } - client, err := testAccProvider.Meta().(*Config).ManagementClient() - if err != nil { - return err - } - - _, err = client.PodSecurityPolicyTemplate.ByID(rs.Primary.ID) - if err != nil { - if IsNotFound(err) { - return nil - } - return err - } - - return fmt.Errorf("PodSecurityPolicyTemplate still exists") - } - return nil -} diff --git a/rancher2/resource_rancher2_project.go b/rancher2/resource_rancher2_project.go index 326ae4bb..8fa64959 100644 --- a/rancher2/resource_rancher2_project.go +++ b/rancher2/resource_rancher2_project.go @@ -8,7 +8,6 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" managementClient "github.com/rancher/rancher/pkg/client/generated/management/v3" - projectClient "github.com/rancher/rancher/pkg/client/generated/project/v3" ) func resourceRancher2Project() *schema.Resource { @@ -58,12 +57,10 @@ func resourceRancher2ProjectCreate(d *schema.ResourceData, meta interface{}) err log.Printf("[INFO] Creating Project %s on Cluster ID %s", project.Name, project.ClusterID) // Creating cluster with monitoring disabled - project.EnableProjectMonitoring = false newProject, err := client.Project.Create(project) if err != nil { return err } - newProject.EnableProjectMonitoring = d.Get("enable_project_monitoring").(bool) d.SetId(newProject.ID) stateConf := &resource.StateChangeConf{ @@ -80,46 +77,6 @@ func resourceRancher2ProjectCreate(d *schema.ResourceData, meta interface{}) err "[ERROR] waiting for project (%s) to be created: %s", newProject.ID, waitErr) } - monitoringInput := expandMonitoringInput(d.Get("project_monitoring_input").([]interface{})) - if newProject.EnableProjectMonitoring { - if len(newProject.Actions[monitoringActionEnable]) == 0 { - newProject, err = client.Project.ByID(newProject.ID) - if err != nil { - return err - } - } - err = client.Project.ActionEnableMonitoring(newProject, monitoringInput) - if err != nil { - return err - } - } - - if pspID, ok := d.Get("pod_security_policy_template_id").(string); ok && len(pspID) > 0 { - pspInput := &managementClient.SetPodSecurityPolicyTemplateInput{ - PodSecurityPolicyTemplateName: pspID, - } - err = resource.Retry(3*time.Second, func() *resource.RetryError { - newProject, err = client.Project.ByID(newProject.ID) - if err != nil { - return resource.NonRetryableError(err) - } - _, err = client.Project.ActionSetpodsecuritypolicytemplate(newProject, pspInput) - if err != nil { - if IsConflict(err) || IsForbidden(err) { - return resource.RetryableError(err) - } - // Checking error due to ActionSetpodsecuritypolicytemplate() issue - if error.Error(err) != "unexpected end of JSON input" { - return resource.NonRetryableError(err) - } - } - return nil - }) - if err != nil { - return fmt.Errorf("[ERROR] waiting for pod_security_policy_template_id (%s) to be set on project (%s): %s", pspID, newProject.ID, err) - } - } - return resourceRancher2ProjectRead(d, meta) } @@ -141,17 +98,7 @@ func resourceRancher2ProjectRead(d *schema.ResourceData, meta interface{}) error return resource.NonRetryableError(err) } - var monitoringInput *managementClient.MonitoringInput - if len(project.Annotations[monitoringInputAnnotation]) > 0 { - monitoringInput = &managementClient.MonitoringInput{} - err = jsonToInterface(project.Annotations[monitoringInputAnnotation], monitoringInput) - if err != nil { - return resource.NonRetryableError(err) - } - - } - - if err = flattenProject(d, project, monitoringInput); err != nil { + if err = flattenProject(d, project); err != nil { return resource.NonRetryableError(err) } @@ -192,74 +139,6 @@ func resourceRancher2ProjectUpdate(d *schema.ResourceData, meta interface{}) err "[ERROR] waiting for project (%s) to be updated: %s", newProject.ID, waitErr) } - if d.HasChange("pod_security_policy_template_id") { - pspInput := &managementClient.SetPodSecurityPolicyTemplateInput{ - PodSecurityPolicyTemplateName: d.Get("pod_security_policy_template_id").(string), - } - _, err = client.Project.ActionSetpodsecuritypolicytemplate(newProject, pspInput) - if err != nil { - // Checking error due to ActionSetpodsecuritypolicytemplate() issue - if error.Error(err) != "unexpected end of JSON input" { - return err - } - } - } - - if d.HasChange("enable_project_monitoring") || d.HasChange("project_monitoring_input") { - enableMonitoring := d.Get("enable_project_monitoring").(bool) - if !enableMonitoring && len(newProject.Actions[monitoringActionDisable]) > 0 { - err = client.Project.ActionDisableMonitoring(newProject) - if err != nil { - return err - } - } - if enableMonitoring { - monitoringInput := expandMonitoringInput(d.Get("project_monitoring_input").([]interface{})) - if len(newProject.Actions[monitoringActionEnable]) > 0 { - err = client.Project.ActionEnableMonitoring(newProject, monitoringInput) - if err != nil { - return err - } - } else { - monitorVersionChanged := false - if d.HasChange("project_monitoring_input") { - old, new := d.GetChange("project_monitoring_input") - oldInput := old.([]interface{}) - oldInputLen := len(oldInput) - oldVersion := "" - if oldInputLen > 0 { - oldRow, oldOK := oldInput[0].(map[string]interface{}) - if oldOK { - oldVersion = oldRow["version"].(string) - } - } - newInput := new.([]interface{}) - newInputLen := len(newInput) - newVersion := "" - if newInputLen > 0 { - newRow, newOK := newInput[0].(map[string]interface{}) - if newOK { - newVersion = newRow["version"].(string) - } - } - if oldVersion != newVersion { - monitorVersionChanged = true - } - } - if monitorVersionChanged && monitoringInput != nil { - err = updateProjectMonitoringApps(meta, newProject.ID, monitoringInput.Version) - if err != nil { - return err - } - } - err = client.Project.ActionEditMonitoring(newProject, monitoringInput) - if err != nil { - return err - } - } - } - } - return resourceRancher2ProjectRead(d, meta) } @@ -321,36 +200,3 @@ func projectStateRefreshFunc(client *managementClient.Client, projectID string) return obj, obj.State, nil } } - -func updateProjectMonitoringApps(meta interface{}, projectID, version string) error { - cliProject, err := meta.(*Config).ProjectClient(projectID) - if err != nil { - return err - } - - filters := map[string]interface{}{ - "name": "project-monitoring", - } - - listOpts := NewListOpts(filters) - - apps, err := cliProject.App.List(listOpts) - if err != nil { - return err - } - - for _, a := range apps.Data { - externalID := updateVersionExternalID(a.ExternalID, version) - upgrade := &projectClient.AppUpgradeConfig{ - Answers: a.Answers, - ExternalID: externalID, - ForceUpgrade: true, - } - - err = cliProject.App.ActionUpgrade(&a, upgrade) - if err != nil { - return err - } - } - return nil -} diff --git a/rancher2/resource_rancher2_project_alert_group.go b/rancher2/resource_rancher2_project_alert_group.go deleted file mode 100644 index 8c4e0adc..00000000 --- a/rancher2/resource_rancher2_project_alert_group.go +++ /dev/null @@ -1,234 +0,0 @@ -package rancher2 - -import ( - "fmt" - "log" - "time" - - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - managementClient "github.com/rancher/rancher/pkg/client/generated/management/v3" -) - -func resourceRancher2ProjectAlertGroup() *schema.Resource { - return &schema.Resource{ - Create: resourceRancher2ProjectAlertGroupCreate, - Read: resourceRancher2ProjectAlertGroupRead, - Update: resourceRancher2ProjectAlertGroupUpdate, - Delete: resourceRancher2ProjectAlertGroupDelete, - Importer: &schema.ResourceImporter{ - State: resourceRancher2ProjectAlertGroupImport, - }, - Schema: projectAlertGroupFields(), - Timeouts: &schema.ResourceTimeout{ - Create: schema.DefaultTimeout(10 * time.Minute), - Update: schema.DefaultTimeout(10 * time.Minute), - Delete: schema.DefaultTimeout(10 * time.Minute), - }, - } -} - -func resourceRancher2ProjectAlertGroupCreate(d *schema.ResourceData, meta interface{}) error { - err := resourceRancher2ProjectAlertGroupRecients(d, meta) - if err != nil { - return err - } - projectAlertGroup := expandProjectAlertGroup(d) - - log.Printf("[INFO] Creating Project Alert Group %s", projectAlertGroup.Name) - - client, err := meta.(*Config).ManagementClient() - if err != nil { - return err - } - - newProjectAlertGroup, err := client.ProjectAlertGroup.Create(projectAlertGroup) - if err != nil { - return err - } - - d.SetId(newProjectAlertGroup.ID) - - stateConf := &resource.StateChangeConf{ - Pending: []string{}, - Target: []string{"active"}, - Refresh: projectAlertGroupStateRefreshFunc(client, newProjectAlertGroup.ID), - Timeout: d.Timeout(schema.TimeoutCreate), - Delay: 1 * time.Second, - MinTimeout: 3 * time.Second, - } - _, waitErr := stateConf.WaitForState() - if waitErr != nil { - return fmt.Errorf("[ERROR] waiting for project alert group (%s) to be created: %s", newProjectAlertGroup.ID, waitErr) - } - - return resourceRancher2ProjectAlertGroupRead(d, meta) -} - -func resourceRancher2ProjectAlertGroupRead(d *schema.ResourceData, meta interface{}) error { - log.Printf("[INFO] Refreshing Project Alert Group ID %s", d.Id()) - client, err := meta.(*Config).ManagementClient() - if err != nil { - return err - } - - return resource.Retry(d.Timeout(schema.TimeoutRead), func() *resource.RetryError { - projectAlertGroup, err := client.ProjectAlertGroup.ByID(d.Id()) - if err != nil { - if IsNotFound(err) || IsForbidden(err) { - log.Printf("[INFO] Project Alert Group ID %s not found.", d.Id()) - d.SetId("") - return nil - } - return resource.NonRetryableError(err) - } - - if err = flattenProjectAlertGroup(d, projectAlertGroup); err != nil { - return resource.NonRetryableError(err) - } - - return nil - }) -} - -func resourceRancher2ProjectAlertGroupUpdate(d *schema.ResourceData, meta interface{}) error { - log.Printf("[INFO] Updating Project Alert Group ID %s", d.Id()) - client, err := meta.(*Config).ManagementClient() - if err != nil { - return err - } - - projectAlertGroup, err := client.ProjectAlertGroup.ByID(d.Id()) - if err != nil { - return err - } - - if d.HasChange("recipients") { - err = resourceRancher2ProjectAlertGroupRecients(d, meta) - if err != nil { - return err - } - } - - update := map[string]interface{}{ - "description": d.Get("description").(string), - "groupIntervalSeconds": int64(d.Get("group_interval_seconds").(int)), - "groupWaitSeconds": int64(d.Get("group_wait_seconds").(int)), - "name": d.Get("name").(string), - "projectId": d.Get("project_id").(string), - "recipients": expandRecipients(d.Get("recipients").([]interface{})), - "repeatIntervalSeconds": int64(d.Get("repeat_interval_seconds").(int)), - "annotations": toMapString(d.Get("annotations").(map[string]interface{})), - "labels": toMapString(d.Get("labels").(map[string]interface{})), - } - - newProjectAlertGroup, err := client.ProjectAlertGroup.Update(projectAlertGroup, update) - if err != nil { - return err - } - - stateConf := &resource.StateChangeConf{ - Pending: []string{}, - Target: []string{"active"}, - Refresh: projectAlertGroupStateRefreshFunc(client, newProjectAlertGroup.ID), - Timeout: d.Timeout(schema.TimeoutUpdate), - Delay: 1 * time.Second, - MinTimeout: 3 * time.Second, - } - _, waitErr := stateConf.WaitForState() - if waitErr != nil { - return fmt.Errorf( - "[ERROR] waiting for project alert group (%s) to be updated: %s", newProjectAlertGroup.ID, waitErr) - } - - return resourceRancher2ProjectAlertGroupRead(d, meta) -} - -func resourceRancher2ProjectAlertGroupDelete(d *schema.ResourceData, meta interface{}) error { - log.Printf("[INFO] Deleting Project Alert Group ID %s", d.Id()) - id := d.Id() - client, err := meta.(*Config).ManagementClient() - if err != nil { - return err - } - - projectAlertGroup, err := client.ProjectAlertGroup.ByID(id) - if err != nil { - if IsNotFound(err) || IsForbidden(err) { - log.Printf("[INFO] Project Alert Group ID %s not found.", id) - d.SetId("") - return nil - } - return err - } - - err = client.ProjectAlertGroup.Delete(projectAlertGroup) - if err != nil { - return fmt.Errorf("Error removing Project Alert Group: %s", err) - } - - log.Printf("[DEBUG] Waiting for project alert group (%s) to be removed", id) - - stateConf := &resource.StateChangeConf{ - Pending: []string{"removing"}, - Target: []string{"removed"}, - Refresh: projectAlertGroupStateRefreshFunc(client, id), - Timeout: d.Timeout(schema.TimeoutDelete), - Delay: 1 * time.Second, - MinTimeout: 3 * time.Second, - } - - _, waitErr := stateConf.WaitForState() - if waitErr != nil { - return fmt.Errorf( - "[ERROR] waiting for project alert group (%s) to be removed: %s", id, waitErr) - } - - d.SetId("") - return nil -} - -func resourceRancher2ProjectAlertGroupRecients(d *schema.ResourceData, meta interface{}) error { - recipients, ok := d.Get("recipients").([]interface{}) - if !ok { - return fmt.Errorf("[ERROR] Getting Project Alert Group Recipients") - } - - if len(recipients) > 0 { - log.Printf("[INFO] Getting Project Alert Group Recipients") - - for i := range recipients { - in := recipients[i].(map[string]interface{}) - - recipient, err := meta.(*Config).GetRecipientByNotifier(in["notifier_id"].(string)) - if err != nil { - return err - } - - in["notifier_type"] = recipient.NotifierType - if v, ok := in["default_recipient"].(bool); ok && v { - in["recipient"] = recipient.Recipient - } - - recipients[i] = in - } - d.Set("recipients", recipients) - } - - return nil -} - -// projectAlertGroupStateRefreshFunc returns a resource.StateRefreshFunc, used to watch a Rancher ProjectAlertGroup. -func projectAlertGroupStateRefreshFunc(client *managementClient.Client, projectAlertGroupID string) resource.StateRefreshFunc { - return func() (interface{}, string, error) { - obj, err := client.ProjectAlertGroup.ByID(projectAlertGroupID) - if err != nil { - if IsNotFound(err) || IsForbidden(err) { - return obj, "removed", nil - } - return nil, "", err - } - - return obj, obj.State, nil - } -} diff --git a/rancher2/resource_rancher2_project_alert_group_test.go b/rancher2/resource_rancher2_project_alert_group_test.go deleted file mode 100644 index 438c2729..00000000 --- a/rancher2/resource_rancher2_project_alert_group_test.go +++ /dev/null @@ -1,203 +0,0 @@ -package rancher2 - -import ( - "fmt" - "testing" - "time" - - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/terraform" - managementClient "github.com/rancher/rancher/pkg/client/generated/management/v3" -) - -const ( - testAccRancher2ProjectAlertGroupType = "rancher2_project_alert_group" -) - -var ( - testAccRancher2ProjectAlertGroup string - testAccRancher2ProjectAlertGroupUpdate string - testAccRancher2ProjectAlertGroupConfig string - testAccRancher2ProjectAlertGroupUpdateConfig string -) - -func init() { - testAccRancher2ProjectAlertGroup = ` -resource "` + testAccRancher2ProjectAlertGroupType + `" "foo" { - name = "foo" - description = "Terraform project alert group acceptance test" - project_id = rancher2_cluster_sync.testacc.default_project_id - group_interval_seconds = 300 - repeat_interval_seconds = 3600 -} -` - testAccRancher2ProjectAlertGroupUpdate = ` -resource "` + testAccRancher2ProjectAlertGroupType + `" "foo" { - name = "foo" - description = "Terraform project alert group acceptance test - updated" - project_id = rancher2_cluster_sync.testacc.default_project_id - group_interval_seconds = 600 - repeat_interval_seconds = 6000 -} -` - testAccRancher2ProjectAlertGroupConfig = testAccCheckRancher2ClusterSyncTestacc + testAccRancher2ProjectAlertGroup - testAccRancher2ProjectAlertGroupUpdateConfig = testAccCheckRancher2ClusterSyncTestacc + testAccRancher2ProjectAlertGroupUpdate -} - -func TestAccRancher2ProjectAlertGroup_basic(t *testing.T) { - var ag *managementClient.ProjectAlertGroup - - resource.Test(t, resource.TestCase{ - Providers: testAccProviders, - CheckDestroy: testAccCheckRancher2ProjectAlertGroupDestroy, - Steps: []resource.TestStep{ - { - Config: testAccRancher2ProjectAlertGroupConfig, - Check: resource.ComposeTestCheckFunc( - testAccCheckRancher2ProjectAlertGroupExists(testAccRancher2ProjectAlertGroupType+".foo", ag), - resource.TestCheckResourceAttr(testAccRancher2ProjectAlertGroupType+".foo", "name", "foo"), - resource.TestCheckResourceAttr(testAccRancher2ProjectAlertGroupType+".foo", "description", "Terraform project alert group acceptance test"), - resource.TestCheckResourceAttr(testAccRancher2ProjectAlertGroupType+".foo", "group_interval_seconds", "300"), - resource.TestCheckResourceAttr(testAccRancher2ProjectAlertGroupType+".foo", "repeat_interval_seconds", "3600"), - ), - }, - { - Config: testAccRancher2ProjectAlertGroupUpdateConfig, - Check: resource.ComposeTestCheckFunc( - testAccCheckRancher2ProjectAlertGroupExists(testAccRancher2ProjectAlertGroupType+".foo", ag), - resource.TestCheckResourceAttr(testAccRancher2ProjectAlertGroupType+".foo", "name", "foo"), - resource.TestCheckResourceAttr(testAccRancher2ProjectAlertGroupType+".foo", "description", "Terraform project alert group acceptance test - updated"), - resource.TestCheckResourceAttr(testAccRancher2ProjectAlertGroupType+".foo", "group_interval_seconds", "600"), - resource.TestCheckResourceAttr(testAccRancher2ProjectAlertGroupType+".foo", "repeat_interval_seconds", "6000"), - ), - }, - { - Config: testAccRancher2ProjectAlertGroupConfig, - Check: resource.ComposeTestCheckFunc( - testAccCheckRancher2ProjectAlertGroupExists(testAccRancher2ProjectAlertGroupType+".foo", ag), - resource.TestCheckResourceAttr(testAccRancher2ProjectAlertGroupType+".foo", "name", "foo"), - resource.TestCheckResourceAttr(testAccRancher2ProjectAlertGroupType+".foo", "description", "Terraform project alert group acceptance test"), - resource.TestCheckResourceAttr(testAccRancher2ProjectAlertGroupType+".foo", "group_interval_seconds", "300"), - resource.TestCheckResourceAttr(testAccRancher2ProjectAlertGroupType+".foo", "repeat_interval_seconds", "3600"), - ), - }, - }, - }) -} - -func TestAccRancher2ProjectAlertGroup_disappears(t *testing.T) { - var ag *managementClient.ProjectAlertGroup - - resource.Test(t, resource.TestCase{ - Providers: testAccProviders, - CheckDestroy: testAccCheckRancher2ProjectAlertGroupDestroy, - Steps: []resource.TestStep{ - { - Config: testAccRancher2ProjectAlertGroupConfig, - Check: resource.ComposeTestCheckFunc( - testAccCheckRancher2ProjectAlertGroupExists(testAccRancher2ProjectAlertGroupType+".foo", ag), - testAccRancher2ProjectAlertGroupDisappears(ag), - ), - ExpectNonEmptyPlan: true, - }, - }, - }) -} - -func testAccRancher2ProjectAlertGroupDisappears(ag *managementClient.ProjectAlertGroup) resource.TestCheckFunc { - return func(s *terraform.State) error { - for _, rs := range s.RootModule().Resources { - if rs.Type != testAccRancher2ProjectAlertGroupType { - continue - } - client, err := testAccProvider.Meta().(*Config).ManagementClient() - if err != nil { - return err - } - - ag, err = client.ProjectAlertGroup.ByID(rs.Primary.ID) - if err != nil { - if IsNotFound(err) { - return nil - } - return err - } - - err = client.ProjectAlertGroup.Delete(ag) - if err != nil { - return fmt.Errorf("Error removing Project Alert Group: %s", err) - } - - stateConf := &resource.StateChangeConf{ - Pending: []string{"removing"}, - Target: []string{"removed"}, - Refresh: projectAlertGroupStateRefreshFunc(client, rs.Primary.ID), - Timeout: 10 * time.Minute, - Delay: 1 * time.Second, - MinTimeout: 3 * time.Second, - } - - _, waitErr := stateConf.WaitForState() - if waitErr != nil { - return fmt.Errorf( - "[ERROR] waiting for project alert group (%s) to be removed: %s", rs.Primary.ID, waitErr) - } - } - return nil - - } -} - -func testAccCheckRancher2ProjectAlertGroupExists(n string, ag *managementClient.ProjectAlertGroup) resource.TestCheckFunc { - return func(s *terraform.State) error { - rs, ok := s.RootModule().Resources[n] - - if !ok { - return fmt.Errorf("Not found: %s", n) - } - - if rs.Primary.ID == "" { - return fmt.Errorf("No project alert group ID is set") - } - - client, err := testAccProvider.Meta().(*Config).ManagementClient() - if err != nil { - return err - } - - foundAg, err := client.ProjectAlertGroup.ByID(rs.Primary.ID) - if err != nil { - if IsNotFound(err) { - return fmt.Errorf("Project Alert Group not found") - } - return err - } - - ag = foundAg - - return nil - } -} - -func testAccCheckRancher2ProjectAlertGroupDestroy(s *terraform.State) error { - for _, rs := range s.RootModule().Resources { - if rs.Type != testAccRancher2ProjectAlertGroupType { - continue - } - - client, err := testAccProvider.Meta().(*Config).ManagementClient() - if err != nil { - return err - } - - _, err = client.ProjectAlertGroup.ByID(rs.Primary.ID) - if err != nil { - if IsNotFound(err) { - return nil - } - return err - } - return fmt.Errorf("Project Alert Group still exists") - } - return nil -} diff --git a/rancher2/resource_rancher2_project_alert_rule.go b/rancher2/resource_rancher2_project_alert_rule.go deleted file mode 100644 index 6ec6ae96..00000000 --- a/rancher2/resource_rancher2_project_alert_rule.go +++ /dev/null @@ -1,207 +0,0 @@ -package rancher2 - -import ( - "fmt" - "log" - "time" - - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - managementClient "github.com/rancher/rancher/pkg/client/generated/management/v3" -) - -func resourceRancher2ProjectAlertRule() *schema.Resource { - return &schema.Resource{ - Create: resourceRancher2ProjectAlertRuleCreate, - Read: resourceRancher2ProjectAlertRuleRead, - Update: resourceRancher2ProjectAlertRuleUpdate, - Delete: resourceRancher2ProjectAlertRuleDelete, - Importer: &schema.ResourceImporter{ - State: resourceRancher2ProjectAlertRuleImport, - }, - Schema: projectAlertRuleFields(), - Timeouts: &schema.ResourceTimeout{ - Create: schema.DefaultTimeout(10 * time.Minute), - Update: schema.DefaultTimeout(10 * time.Minute), - Delete: schema.DefaultTimeout(10 * time.Minute), - }, - } -} - -func resourceRancher2ProjectAlertRuleCreate(d *schema.ResourceData, meta interface{}) error { - projectAlertRule := expandProjectAlertRule(d) - - log.Printf("[INFO] Creating Project Alert Rule %s", projectAlertRule.Name) - - client, err := meta.(*Config).ManagementClient() - if err != nil { - return err - } - - newProjectAlertRule, err := client.ProjectAlertRule.Create(projectAlertRule) - if err != nil { - return err - } - - d.SetId(newProjectAlertRule.ID) - - stateConf := &resource.StateChangeConf{ - Pending: []string{}, - Target: []string{"active"}, - Refresh: projectAlertRuleStateRefreshFunc(client, newProjectAlertRule.ID), - Timeout: d.Timeout(schema.TimeoutCreate), - Delay: 1 * time.Second, - MinTimeout: 3 * time.Second, - } - _, waitErr := stateConf.WaitForState() - if waitErr != nil { - return fmt.Errorf("[ERROR] waiting for project alert rule (%s) to be created: %s", newProjectAlertRule.ID, waitErr) - } - - return resourceRancher2ProjectAlertRuleRead(d, meta) -} - -func resourceRancher2ProjectAlertRuleRead(d *schema.ResourceData, meta interface{}) error { - log.Printf("[INFO] Refreshing Project Alert Rule ID %s", d.Id()) - client, err := meta.(*Config).ManagementClient() - if err != nil { - return err - } - - return resource.Retry(d.Timeout(schema.TimeoutRead), func() *resource.RetryError { - projectAlertRule, err := client.ProjectAlertRule.ByID(d.Id()) - if err != nil { - if IsNotFound(err) || IsForbidden(err) { - log.Printf("[INFO] Project Alert Rule ID %s not found.", d.Id()) - d.SetId("") - return nil - } - return resource.NonRetryableError(err) - } - - if err = flattenProjectAlertRule(d, projectAlertRule); err != nil { - return resource.NonRetryableError(err) - } - - return nil - }) -} - -func resourceRancher2ProjectAlertRuleUpdate(d *schema.ResourceData, meta interface{}) error { - log.Printf("[INFO] Updating Project Alert Rule ID %s", d.Id()) - client, err := meta.(*Config).ManagementClient() - if err != nil { - return err - } - - projectAlertRule, err := client.ProjectAlertRule.ByID(d.Id()) - if err != nil { - return err - } - - inherited := d.Get("inherited").(bool) - update := map[string]interface{}{ - "projectId": d.Get("project_id").(string), - "groupId": d.Get("group_id").(string), - "groupIntervalSeconds": int64(d.Get("group_interval_seconds").(int)), - "groupWaitSeconds": int64(d.Get("group_wait_seconds").(int)), - "inherited": &inherited, - "name": d.Get("name").(string), - "repeatIntervalSeconds": int64(d.Get("repeat_interval_seconds").(int)), - "severity": d.Get("severity").(string), - "annotations": toMapString(d.Get("annotations").(map[string]interface{})), - "labels": toMapString(d.Get("labels").(map[string]interface{})), - } - - if v, ok := d.Get("metric_rule").([]interface{}); ok && len(v) > 0 { - update["metricRule"] = expandMetricRule(v) - } - - if v, ok := d.Get("pod_rule").([]interface{}); ok && len(v) > 0 { - update["podRule"] = expandPodRule(v) - } - - if v, ok := d.Get("workload_rule").([]interface{}); ok && len(v) > 0 { - update["workloadRule"] = expandWorkloadRule(v) - } - - newProjectAlertRule, err := client.ProjectAlertRule.Update(projectAlertRule, update) - if err != nil { - return err - } - - stateConf := &resource.StateChangeConf{ - Pending: []string{}, - Target: []string{"active"}, - Refresh: projectAlertRuleStateRefreshFunc(client, newProjectAlertRule.ID), - Timeout: d.Timeout(schema.TimeoutUpdate), - Delay: 1 * time.Second, - MinTimeout: 3 * time.Second, - } - _, waitErr := stateConf.WaitForState() - if waitErr != nil { - return fmt.Errorf( - "[ERROR] waiting for project alert rule (%s) to be updated: %s", newProjectAlertRule.ID, waitErr) - } - - return resourceRancher2ProjectAlertRuleRead(d, meta) -} - -func resourceRancher2ProjectAlertRuleDelete(d *schema.ResourceData, meta interface{}) error { - log.Printf("[INFO] Deleting Project Alert Rule ID %s", d.Id()) - id := d.Id() - client, err := meta.(*Config).ManagementClient() - if err != nil { - return err - } - - projectAlertRule, err := client.ProjectAlertRule.ByID(id) - if err != nil { - if IsNotFound(err) || IsForbidden(err) { - log.Printf("[INFO] Project Alert Rule ID %s not found.", id) - d.SetId("") - return nil - } - return err - } - - err = client.ProjectAlertRule.Delete(projectAlertRule) - if err != nil { - return fmt.Errorf("Error removing Project Alert Rule: %s", err) - } - - log.Printf("[DEBUG] Waiting for project alert rule (%s) to be removed", id) - - stateConf := &resource.StateChangeConf{ - Pending: []string{"removing"}, - Target: []string{"removed"}, - Refresh: projectAlertRuleStateRefreshFunc(client, id), - Timeout: d.Timeout(schema.TimeoutDelete), - Delay: 1 * time.Second, - MinTimeout: 3 * time.Second, - } - - _, waitErr := stateConf.WaitForState() - if waitErr != nil { - return fmt.Errorf( - "[ERROR] waiting for project alert rule (%s) to be removed: %s", id, waitErr) - } - - d.SetId("") - return nil -} - -// projectAlertRuleStateRefreshFunc returns a resource.StateRefreshFunc, used to watch a Rancher ProjectAlertRule. -func projectAlertRuleStateRefreshFunc(client *managementClient.Client, projectAlertRuleID string) resource.StateRefreshFunc { - return func() (interface{}, string, error) { - obj, err := client.ProjectAlertRule.ByID(projectAlertRuleID) - if err != nil { - if IsNotFound(err) || IsForbidden(err) { - return obj, "removed", nil - } - return nil, "", err - } - - return obj, obj.State, nil - } -} diff --git a/rancher2/resource_rancher2_project_alert_rule_test.go b/rancher2/resource_rancher2_project_alert_rule_test.go deleted file mode 100644 index 4f0896a4..00000000 --- a/rancher2/resource_rancher2_project_alert_rule_test.go +++ /dev/null @@ -1,203 +0,0 @@ -package rancher2 - -import ( - "fmt" - "testing" - "time" - - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/terraform" - managementClient "github.com/rancher/rancher/pkg/client/generated/management/v3" -) - -const ( - testAccRancher2ProjectAlertRuleType = "rancher2_project_alert_rule" -) - -var ( - testAccRancher2ProjectAlertRule string - testAccRancher2ProjectAlertRuleUpdate string - testAccRancher2ProjectAlertRuleConfig string - testAccRancher2ProjectAlertRuleUpdateConfig string -) - -func init() { - testAccRancher2ProjectAlertRule = ` -resource "` + testAccRancher2ProjectAlertRuleType + `" "foo" { - project_id = rancher2_cluster_sync.testacc.default_project_id - group_id = rancher2_project_alert_group.foo.id - name = "foo" - group_interval_seconds = 300 - repeat_interval_seconds = 3600 -} -` - testAccRancher2ProjectAlertRuleUpdate = ` -resource "` + testAccRancher2ProjectAlertRuleType + `" "foo" { - project_id = rancher2_cluster_sync.testacc.default_project_id - group_id = rancher2_project_alert_group.foo.id - name = "foo" - group_interval_seconds = 600 - repeat_interval_seconds = 6000 -} -` - testAccRancher2ProjectAlertRuleConfig = testAccRancher2ProjectAlertGroupConfig + testAccRancher2ProjectAlertRule - testAccRancher2ProjectAlertRuleUpdateConfig = testAccRancher2ProjectAlertGroupConfig + testAccRancher2ProjectAlertRuleUpdate -} - -func TestAccRancher2ProjectAlertRule_basic(t *testing.T) { - var ar *managementClient.ProjectAlertRule - - resource.Test(t, resource.TestCase{ - Providers: testAccProviders, - CheckDestroy: testAccCheckRancher2ProjectAlertRuleDestroy, - Steps: []resource.TestStep{ - { - Config: testAccRancher2ProjectAlertRuleConfig, - Check: resource.ComposeTestCheckFunc( - testAccCheckRancher2ProjectAlertRuleExists(testAccRancher2ProjectAlertRuleType+".foo", ar), - resource.TestCheckResourceAttr(testAccRancher2ProjectAlertRuleType+".foo", "name", "foo"), - resource.TestCheckResourceAttr(testAccRancher2ProjectAlertRuleType+".foo", "group_interval_seconds", "300"), - resource.TestCheckResourceAttr(testAccRancher2ProjectAlertRuleType+".foo", "severity", alertRuleSeverityCritical), - resource.TestCheckResourceAttr(testAccRancher2ProjectAlertRuleType+".foo", "repeat_interval_seconds", "3600"), - ), - }, - { - Config: testAccRancher2ProjectAlertRuleUpdateConfig, - Check: resource.ComposeTestCheckFunc( - testAccCheckRancher2ProjectAlertRuleExists(testAccRancher2ProjectAlertRuleType+".foo", ar), - resource.TestCheckResourceAttr(testAccRancher2ProjectAlertRuleType+".foo", "name", "foo"), - resource.TestCheckResourceAttr(testAccRancher2ProjectAlertRuleType+".foo", "group_interval_seconds", "600"), - resource.TestCheckResourceAttr(testAccRancher2ProjectAlertRuleType+".foo", "severity", alertRuleSeverityCritical), - resource.TestCheckResourceAttr(testAccRancher2ProjectAlertRuleType+".foo", "repeat_interval_seconds", "6000"), - ), - }, - { - Config: testAccRancher2ProjectAlertRuleConfig, - Check: resource.ComposeTestCheckFunc( - testAccCheckRancher2ProjectAlertRuleExists(testAccRancher2ProjectAlertRuleType+".foo", ar), - resource.TestCheckResourceAttr(testAccRancher2ProjectAlertRuleType+".foo", "name", "foo"), - resource.TestCheckResourceAttr(testAccRancher2ProjectAlertRuleType+".foo", "group_interval_seconds", "300"), - resource.TestCheckResourceAttr(testAccRancher2ProjectAlertRuleType+".foo", "severity", alertRuleSeverityCritical), - resource.TestCheckResourceAttr(testAccRancher2ProjectAlertRuleType+".foo", "repeat_interval_seconds", "3600"), - ), - }, - }, - }) -} - -func TestAccRancher2ProjectAlertRule_disappears(t *testing.T) { - var ar *managementClient.ProjectAlertRule - - resource.Test(t, resource.TestCase{ - Providers: testAccProviders, - CheckDestroy: testAccCheckRancher2ProjectAlertRuleDestroy, - Steps: []resource.TestStep{ - { - Config: testAccRancher2ProjectAlertRuleConfig, - Check: resource.ComposeTestCheckFunc( - testAccCheckRancher2ProjectAlertRuleExists(testAccRancher2ProjectAlertRuleType+".foo", ar), - testAccRancher2ProjectAlertRuleDisappears(ar), - ), - ExpectNonEmptyPlan: true, - }, - }, - }) -} - -func testAccRancher2ProjectAlertRuleDisappears(ar *managementClient.ProjectAlertRule) resource.TestCheckFunc { - return func(s *terraform.State) error { - for _, rs := range s.RootModule().Resources { - if rs.Type != testAccRancher2ProjectAlertRuleType { - continue - } - client, err := testAccProvider.Meta().(*Config).ManagementClient() - if err != nil { - return err - } - - ar, err = client.ProjectAlertRule.ByID(rs.Primary.ID) - if err != nil { - if IsNotFound(err) { - return nil - } - return err - } - - err = client.ProjectAlertRule.Delete(ar) - if err != nil { - return fmt.Errorf("Error removing Project Alert Rule: %s", err) - } - - stateConf := &resource.StateChangeConf{ - Pending: []string{"removing"}, - Target: []string{"removed"}, - Refresh: projectAlertRuleStateRefreshFunc(client, rs.Primary.ID), - Timeout: 10 * time.Minute, - Delay: 1 * time.Second, - MinTimeout: 3 * time.Second, - } - - _, waitErr := stateConf.WaitForState() - if waitErr != nil { - return fmt.Errorf( - "[ERROR] waiting for project alert rule (%s) to be removed: %s", rs.Primary.ID, waitErr) - } - } - return nil - - } -} - -func testAccCheckRancher2ProjectAlertRuleExists(n string, ar *managementClient.ProjectAlertRule) resource.TestCheckFunc { - return func(s *terraform.State) error { - rs, ok := s.RootModule().Resources[n] - - if !ok { - return fmt.Errorf("Not found: %s", n) - } - - if rs.Primary.ID == "" { - return fmt.Errorf("No project alert rule ID is set") - } - - client, err := testAccProvider.Meta().(*Config).ManagementClient() - if err != nil { - return err - } - - foundAr, err := client.ProjectAlertRule.ByID(rs.Primary.ID) - if err != nil { - if IsNotFound(err) { - return fmt.Errorf("Project Alert Rule not found") - } - return err - } - - ar = foundAr - - return nil - } -} - -func testAccCheckRancher2ProjectAlertRuleDestroy(s *terraform.State) error { - for _, rs := range s.RootModule().Resources { - if rs.Type != testAccRancher2ProjectAlertRuleType { - continue - } - - client, err := testAccProvider.Meta().(*Config).ManagementClient() - if err != nil { - return err - } - - _, err = client.ProjectAlertRule.ByID(rs.Primary.ID) - if err != nil { - if IsNotFound(err) { - return nil - } - return err - } - return fmt.Errorf("Project Alert Rule still exists") - } - return nil -} diff --git a/rancher2/schema_alert_group.go b/rancher2/schema_alert_group.go deleted file mode 100644 index 9e481ce1..00000000 --- a/rancher2/schema_alert_group.go +++ /dev/null @@ -1,54 +0,0 @@ -package rancher2 - -import ( - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" -) - -//Schemas - -func alertGroupFields() map[string]*schema.Schema { - s := map[string]*schema.Schema{ - "name": { - Type: schema.TypeString, - Required: true, - Description: "Alert group name", - }, - "description": { - Type: schema.TypeString, - Optional: true, - Description: "Alert group description", - }, - "group_interval_seconds": { - Type: schema.TypeInt, - Optional: true, - Default: 180, - Description: "Alert group interval seconds", - }, - "group_wait_seconds": { - Type: schema.TypeInt, - Optional: true, - Default: 180, - Description: "Alert group wait seconds", - }, - "recipients": { - Type: schema.TypeList, - Optional: true, - Description: "Alert group recipients", - Elem: &schema.Resource{ - Schema: recipientFields(), - }, - }, - "repeat_interval_seconds": { - Type: schema.TypeInt, - Optional: true, - Default: 3600, - Description: "Alert group repeat interval seconds", - }, - } - - for k, v := range commonAnnotationLabelFields() { - s[k] = v - } - - return s -} diff --git a/rancher2/schema_alert_rule.go b/rancher2/schema_alert_rule.go deleted file mode 100644 index 2ed30c4c..00000000 --- a/rancher2/schema_alert_rule.go +++ /dev/null @@ -1,282 +0,0 @@ -package rancher2 - -import ( - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - "github.com/hashicorp/terraform-plugin-sdk/helper/validation" -) - -const ( - alertRuleSeverityCritical = "critical" - alertRuleSeverityInfo = "info" - alertRuleSeverityWarning = "warning" - eventRuleTypeWarning = "Warning" - eventRuleTypeNormal = "Normal" - eventRuleResourceKindDaemondSet = "DaemonSet" - eventRuleResourceKindDeployment = "Deployment" - eventRuleResourceKindNode = "Node" - eventRuleResourceKindPod = "Pod" - eventRuleResourceKindStatefulSet = "StatefulSet" - metricRuleComparisonEqual = "equal" - metricRuleComparisonGreaterOrEqual = "greater-or-equal" - metricRuleComparisonGreaterThan = "greater-than" - metricRuleComparisonLessOrEqual = "less-or-equal" - metricRuleComparisonLessThan = "less-than" - metricRuleComparisonNotEqual = "not-equal" - metricRuleComparisonNotNull = "has-value" - nodeRuleConditionCPU = "cpu" - nodeRuleConditionMem = "mem" - nodeRuleConditionNotReady = "notready" - podRuleConditionNotRunning = "notrunning" - podRuleConditionNotScheduled = "notscheduled" - podRuleConditionRestarts = "restarts" - systemServiceRuleConditionControllerManager = "controller-manager" - systemServiceRuleConditionEtcd = "etcd" - systemServiceRuleConditionScheduler = "scheduler" -) - -var ( - alertRuleSeverityTypes = []string{alertRuleSeverityCritical, alertRuleSeverityInfo, alertRuleSeverityWarning} - eventRuleTypes = []string{eventRuleTypeNormal, eventRuleTypeWarning} - eventRuleResourceKinds = []string{ - eventRuleResourceKindDaemondSet, - eventRuleResourceKindDeployment, - eventRuleResourceKindNode, - eventRuleResourceKindPod, - eventRuleResourceKindStatefulSet, - } - metricRuleComparisons = []string{ - metricRuleComparisonEqual, - metricRuleComparisonGreaterOrEqual, - metricRuleComparisonGreaterThan, - metricRuleComparisonLessOrEqual, - metricRuleComparisonLessThan, - metricRuleComparisonNotEqual, - metricRuleComparisonNotNull, - } - nodeRuleConditions = []string{ - nodeRuleConditionCPU, - nodeRuleConditionMem, - nodeRuleConditionNotReady, - } - podRuleConditions = []string{ - podRuleConditionNotRunning, - podRuleConditionNotScheduled, - podRuleConditionRestarts, - } - systemServiceRuleConditions = []string{ - systemServiceRuleConditionControllerManager, - systemServiceRuleConditionEtcd, - systemServiceRuleConditionScheduler, - } -) - -//Schemas - -func alertRuleFields() map[string]*schema.Schema { - s := map[string]*schema.Schema{ - "group_id": { - Type: schema.TypeString, - Required: true, - Description: "Alert rule group ID", - }, - "name": { - Type: schema.TypeString, - Required: true, - Description: "Alert rule name", - }, - "group_interval_seconds": { - Type: schema.TypeInt, - Optional: true, - Default: 180, - Description: "Alert rule interval seconds", - }, - "group_wait_seconds": { - Type: schema.TypeInt, - Optional: true, - Default: 180, - Description: "Alert rule wait seconds", - }, - "inherited": { - Type: schema.TypeBool, - Optional: true, - Default: true, - Description: "Alert rule inherited", - }, - "repeat_interval_seconds": { - Type: schema.TypeInt, - Optional: true, - Default: 3600, - Description: "Alert rule repeat interval seconds", - }, - "severity": { - Type: schema.TypeString, - Optional: true, - Default: alertRuleSeverityCritical, - Description: "Alert rule severity", - ValidateFunc: validation.StringInSlice(alertRuleSeverityTypes, true), - }, - } - - for k, v := range commonAnnotationLabelFields() { - s[k] = v - } - - return s -} - -func eventRuleFields() map[string]*schema.Schema { - s := map[string]*schema.Schema{ - "event_type": { - Type: schema.TypeString, - Optional: true, - Default: eventRuleTypeWarning, - Description: "Event type", - ValidateFunc: validation.StringInSlice(eventRuleTypes, true), - }, - "resource_kind": { - Type: schema.TypeString, - Required: true, - Description: "Resource kind", - ValidateFunc: validation.StringInSlice(eventRuleResourceKinds, true), - }, - } - return s -} - -func metricRuleFields() map[string]*schema.Schema { - s := map[string]*schema.Schema{ - "comparison": { - Type: schema.TypeString, - Optional: true, - Default: metricRuleComparisonEqual, - Description: "Metric rule comparison", - ValidateFunc: validation.StringInSlice(metricRuleComparisons, true), - }, - "duration": { - Type: schema.TypeString, - Required: true, - Description: "Metric rule duration", - }, - "expression": { - Type: schema.TypeString, - Required: true, - Description: "Metric rule expression", - }, - "threshold_value": { - Type: schema.TypeFloat, - Required: true, - Description: "Metric rule threshold value", - }, - "description": { - Type: schema.TypeString, - Optional: true, - Description: "Metric rule description", - }, - } - return s -} - -func nodeRuleFields() map[string]*schema.Schema { - s := map[string]*schema.Schema{ - "cpu_threshold": { - Type: schema.TypeInt, - Optional: true, - Default: 70, - Description: "Node rule cpu threshold", - ValidateFunc: validation.IntBetween(1, 100), - }, - "condition": { - Type: schema.TypeString, - Optional: true, - Default: nodeRuleConditionNotReady, - Description: "Node rule condition", - ValidateFunc: validation.StringInSlice(nodeRuleConditions, true), - }, - "mem_threshold": { - Type: schema.TypeInt, - Optional: true, - Default: 70, - Description: "Node rule mem threshold", - ValidateFunc: validation.IntBetween(1, 100), - }, - "node_id": { - Type: schema.TypeString, - Optional: true, - Description: "Node ID", - }, - "selector": { - Type: schema.TypeMap, - Optional: true, - Description: "Node rule selector", - }, - } - return s -} - -func podRuleFields() map[string]*schema.Schema { - s := map[string]*schema.Schema{ - "pod_id": { - Type: schema.TypeString, - Required: true, - Description: "Pod ID", - }, - "condition": { - Type: schema.TypeString, - Optional: true, - Default: podRuleConditionNotRunning, - Description: "Pod rule condition", - ValidateFunc: validation.StringInSlice(podRuleConditions, true), - }, - "restart_interval_seconds": { - Type: schema.TypeInt, - Optional: true, - Default: 300, - Description: "Pod rule restart interval seconds", - ValidateFunc: validation.IntAtLeast(1), - }, - "restart_times": { - Type: schema.TypeInt, - Optional: true, - Default: 3, - Description: "Pod rule restart times", - ValidateFunc: validation.IntAtLeast(1), - }, - } - return s -} - -func systemServiceRuleFields() map[string]*schema.Schema { - s := map[string]*schema.Schema{ - "condition": { - Type: schema.TypeString, - Optional: true, - Default: systemServiceRuleConditionScheduler, - Description: "System service rule condition", - ValidateFunc: validation.StringInSlice(systemServiceRuleConditions, true), - }, - } - return s -} - -func workloadRuleFields() map[string]*schema.Schema { - s := map[string]*schema.Schema{ - "available_percentage": { - Type: schema.TypeInt, - Optional: true, - Default: 70, - Description: "Workload rule available percentage", - ValidateFunc: validation.IntBetween(1, 100), - }, - "selector": { - Type: schema.TypeMap, - Optional: true, - Description: "Workload rule selector", - }, - "workload_id": { - Type: schema.TypeString, - Optional: true, - Description: "Workload ID", - }, - } - return s -} diff --git a/rancher2/schema_cluster.go b/rancher2/schema_cluster.go index 07d9272c..383fbb73 100644 --- a/rancher2/schema_cluster.go +++ b/rancher2/schema_cluster.go @@ -7,13 +7,10 @@ import ( ) const ( - clusterDriverImported = "imported" - clusterRegistrationTokenName = "default-token" - clusterMonitoringV1Namespace = "cattle-prometheus" - clusterActiveCondition = "Updated" - clusterConnectedCondition = "Connected" - clusterMonitoringEnabledCondition = "MonitoringEnabled" - clusterAlertingEnabledCondition = "AlertingEnabled" + clusterDriverImported = "imported" + clusterRegistrationTokenName = "default-token" + clusterActiveCondition = "Updated" + clusterConnectedCondition = "Connected" ) var ( @@ -194,15 +191,6 @@ func clusterFieldsV0() map[string]*schema.Schema { Schema: clusterAuthEndpoint(), }, }, - "cluster_monitoring_input": { - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Description: "Cluster monitoring configuration", - Elem: &schema.Resource{ - Schema: monitoringInputFields(), - }, - }, "cluster_registration_token": { Type: schema.TypeList, MaxItems: 1, @@ -239,12 +227,6 @@ func clusterFieldsV0() map[string]*schema.Schema { Optional: true, Description: "Cluster template revision ID", }, - "default_pod_security_policy_template_id": { - Type: schema.TypeString, - Optional: true, - Computed: true, - Description: "Default pod security policy template ID", - }, "default_pod_security_admission_configuration_template_name": { Type: schema.TypeString, Optional: true, @@ -266,18 +248,6 @@ func clusterFieldsV0() map[string]*schema.Schema { Optional: true, Computed: true, }, - "enable_cluster_alerting": { - Type: schema.TypeBool, - Optional: true, - Computed: true, - Description: "Enable built-in cluster alerting", - }, - "enable_cluster_monitoring": { - Type: schema.TypeBool, - Optional: true, - Computed: true, - Description: "Enable built-in cluster monitoring", - }, "enable_cluster_istio": { Type: schema.TypeBool, Computed: true, @@ -472,15 +442,6 @@ func clusterFields() map[string]*schema.Schema { Schema: clusterAuthEndpoint(), }, }, - "cluster_monitoring_input": { - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Description: "Cluster monitoring configuration", - Elem: &schema.Resource{ - Schema: monitoringInputFields(), - }, - }, "cluster_registration_token": { Type: schema.TypeList, MaxItems: 1, @@ -518,12 +479,6 @@ func clusterFields() map[string]*schema.Schema { Optional: true, Description: "Cluster template revision ID", }, - "default_pod_security_policy_template_id": { - Type: schema.TypeString, - Optional: true, - Computed: true, - Description: "Default pod security policy template ID", - }, "default_pod_security_admission_configuration_template_name": { Type: schema.TypeString, Optional: true, @@ -545,18 +500,6 @@ func clusterFields() map[string]*schema.Schema { Optional: true, Computed: true, }, - "enable_cluster_alerting": { - Type: schema.TypeBool, - Optional: true, - Computed: true, - Description: "Enable built-in cluster alerting", - }, - "enable_cluster_monitoring": { - Type: schema.TypeBool, - Optional: true, - Computed: true, - Description: "Enable built-in cluster monitoring", - }, "enable_cluster_istio": { Type: schema.TypeBool, Computed: true, diff --git a/rancher2/schema_cluster_alert_group.go b/rancher2/schema_cluster_alert_group.go deleted file mode 100644 index 31419509..00000000 --- a/rancher2/schema_cluster_alert_group.go +++ /dev/null @@ -1,23 +0,0 @@ -package rancher2 - -import ( - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" -) - -//Schemas - -func clusterAlertGroupFields() map[string]*schema.Schema { - s := map[string]*schema.Schema{ - "cluster_id": { - Type: schema.TypeString, - Required: true, - Description: "Alert group Cluster ID", - }, - } - - for k, v := range alertGroupFields() { - s[k] = v - } - - return s -} diff --git a/rancher2/schema_cluster_alert_rule.go b/rancher2/schema_cluster_alert_rule.go deleted file mode 100644 index ad96dd6b..00000000 --- a/rancher2/schema_cluster_alert_rule.go +++ /dev/null @@ -1,63 +0,0 @@ -package rancher2 - -import ( - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" -) - -//Schemas - -func clusterAlertRuleFields() map[string]*schema.Schema { - s := map[string]*schema.Schema{ - "cluster_id": { - Type: schema.TypeString, - Required: true, - Description: "Alert rule cluster ID", - }, - "event_rule": { - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - ConflictsWith: []string{"metric_rule", "node_rule", "system_service_rule"}, - Elem: &schema.Resource{ - Schema: eventRuleFields(), - }, - Description: "Alert event rule", - }, - "metric_rule": { - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - ConflictsWith: []string{"event_rule", "node_rule", "system_service_rule"}, - Elem: &schema.Resource{ - Schema: metricRuleFields(), - }, - Description: "Alert metric rule", - }, - "node_rule": { - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - ConflictsWith: []string{"event_rule", "metric_rule", "system_service_rule"}, - Elem: &schema.Resource{ - Schema: nodeRuleFields(), - }, - Description: "Alert node rule", - }, - "system_service_rule": { - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - ConflictsWith: []string{"event_rule", "metric_rule", "node_rule"}, - Elem: &schema.Resource{ - Schema: systemServiceRuleFields(), - }, - Description: "Alert system service rule", - }, - } - - for k, v := range alertRuleFields() { - s[k] = v - } - - return s -} diff --git a/rancher2/schema_cluster_rke_config_services_kube_api.go b/rancher2/schema_cluster_rke_config_services_kube_api.go index 9153716a..c74dd125 100644 --- a/rancher2/schema_cluster_rke_config_services_kube_api.go +++ b/rancher2/schema_cluster_rke_config_services_kube_api.go @@ -536,11 +536,6 @@ func clusterRKEConfigServicesKubeAPIFieldsV0() map[string]*schema.Schema { Optional: true, Computed: true, }, - "pod_security_policy": { - Type: schema.TypeBool, - Optional: true, - Default: false, - }, "secrets_encryption_config": { Type: schema.TypeList, MaxItems: 1, @@ -619,11 +614,6 @@ func clusterRKEConfigServicesKubeAPIFields() map[string]*schema.Schema { Optional: true, Computed: true, }, - "pod_security_policy": { - Type: schema.TypeBool, - Optional: true, - Default: false, - }, "secrets_encryption_config": { Type: schema.TypeList, MaxItems: 1, @@ -703,11 +693,6 @@ func clusterRKEConfigServicesKubeAPIFieldsData() map[string]*schema.Schema { Optional: true, Computed: true, }, - "pod_security_policy": { - Type: schema.TypeBool, - Optional: true, - Default: false, - }, "secrets_encryption_config": { Type: schema.TypeList, MaxItems: 1, diff --git a/rancher2/schema_cluster_sync.go b/rancher2/schema_cluster_sync.go index e6310cc4..a117c1ca 100644 --- a/rancher2/schema_cluster_sync.go +++ b/rancher2/schema_cluster_sync.go @@ -28,18 +28,6 @@ func clusterSyncFields() map[string]*schema.Schema { Default: false, Description: "Wait until all catalogs are downloaded and active", }, - "wait_alerting": { - Type: schema.TypeBool, - Optional: true, - Default: false, - Description: "Wait until alerting is up and running", - }, - "wait_monitoring": { - Type: schema.TypeBool, - Optional: true, - Default: false, - Description: "Wait until monitoring is up and running", - }, "node_pool_ids": { Type: schema.TypeList, Optional: true, diff --git a/rancher2/schema_cluster_template.go b/rancher2/schema_cluster_template.go index 7466e2d1..52f0dd6d 100644 --- a/rancher2/schema_cluster_template.go +++ b/rancher2/schema_cluster_template.go @@ -66,12 +66,6 @@ func clusterSpecBaseFieldsV0() map[string]*schema.Schema { Computed: true, Description: "Default cluster role for project members", }, - "default_pod_security_policy_template_id": { - Type: schema.TypeString, - Optional: true, - Computed: true, - Description: "Default pod security policy template ID", - }, "default_pod_security_admission_configuration_template_name": { Type: schema.TypeString, Optional: true, @@ -96,18 +90,6 @@ func clusterSpecBaseFieldsV0() map[string]*schema.Schema { Computed: true, Description: "Docker Root Dir", }, - "enable_cluster_alerting": { - Type: schema.TypeBool, - Optional: true, - Default: false, - Description: "Enable built-in cluster alerting", - }, - "enable_cluster_monitoring": { - Type: schema.TypeBool, - Optional: true, - Default: false, - Description: "Enable built-in cluster monitoring", - }, "enable_network_policy": { Type: schema.TypeBool, Optional: true, @@ -152,12 +134,6 @@ func clusterSpecBaseFields() map[string]*schema.Schema { Computed: true, Description: "Default cluster role for project members", }, - "default_pod_security_policy_template_id": { - Type: schema.TypeString, - Optional: true, - Computed: true, - Description: "Default pod security policy template ID", - }, "default_pod_security_admission_configuration_template_name": { Type: schema.TypeString, Optional: true, @@ -182,18 +158,6 @@ func clusterSpecBaseFields() map[string]*schema.Schema { Computed: true, Description: "Docker Root Dir", }, - "enable_cluster_alerting": { - Type: schema.TypeBool, - Optional: true, - Default: false, - Description: "Enable built-in cluster alerting", - }, - "enable_cluster_monitoring": { - Type: schema.TypeBool, - Optional: true, - Default: false, - Description: "Enable built-in cluster monitoring", - }, "enable_network_policy": { Type: schema.TypeBool, Optional: true, @@ -239,12 +203,6 @@ func clusterSpecBaseFieldsData() map[string]*schema.Schema { Computed: true, Description: "Default cluster role for project members", }, - "default_pod_security_policy_template_id": { - Type: schema.TypeString, - Optional: true, - Computed: true, - Description: "Default pod security policy template ID", - }, "default_pod_security_admission_configuration_template_name": { Type: schema.TypeString, Optional: true, @@ -269,18 +227,6 @@ func clusterSpecBaseFieldsData() map[string]*schema.Schema { Computed: true, Description: "Docker Root Dir", }, - "enable_cluster_alerting": { - Type: schema.TypeBool, - Optional: true, - Default: false, - Description: "Enable built-in cluster alerting", - }, - "enable_cluster_monitoring": { - Type: schema.TypeBool, - Optional: true, - Default: false, - Description: "Enable built-in cluster monitoring", - }, "enable_network_policy": { Type: schema.TypeBool, Optional: true, diff --git a/rancher2/schema_cluster_v2.go b/rancher2/schema_cluster_v2.go index 5fedda4a..cab606cb 100644 --- a/rancher2/schema_cluster_v2.go +++ b/rancher2/schema_cluster_v2.go @@ -71,11 +71,6 @@ func clusterV2FieldsV0() map[string]*schema.Schema { Schema: agentDeploymentCustomizationFields(), }, }, - "default_pod_security_policy_template_name": { - Type: schema.TypeString, - Optional: true, - Description: "Cluster V2 default pod security policy template name", - }, "default_pod_security_admission_configuration_template_name": { Type: schema.TypeString, Optional: true, @@ -191,11 +186,6 @@ func clusterV2Fields() map[string]*schema.Schema { Schema: agentDeploymentCustomizationFields(), }, }, - "default_pod_security_policy_template_name": { - Type: schema.TypeString, - Optional: true, - Description: "Cluster V2 default pod security policy template name", - }, "default_pod_security_admission_configuration_template_name": { Type: schema.TypeString, Optional: true, diff --git a/rancher2/schema_monitoring_input.go b/rancher2/schema_monitoring_input.go deleted file mode 100644 index 19f2628d..00000000 --- a/rancher2/schema_monitoring_input.go +++ /dev/null @@ -1,24 +0,0 @@ -package rancher2 - -import ( - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" -) - -//Schemas - -func monitoringInputFields() map[string]*schema.Schema { - s := map[string]*schema.Schema{ - "answers": { - Type: schema.TypeMap, - Optional: true, - Description: "Answers for monitor input", - }, - "version": { - Type: schema.TypeString, - Optional: true, - Description: "Monitoring version", - }, - } - - return s -} diff --git a/rancher2/schema_notifier.go b/rancher2/schema_notifier.go deleted file mode 100644 index 9a5746aa..00000000 --- a/rancher2/schema_notifier.go +++ /dev/null @@ -1,103 +0,0 @@ -package rancher2 - -import ( - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" -) - -// Schemas - -func notifierFields() map[string]*schema.Schema { - s := map[string]*schema.Schema{ - "name": { - Type: schema.TypeString, - Required: true, - Description: "Notifier name", - }, - "cluster_id": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - Description: "Notifier cluster ID", - }, - "description": { - Type: schema.TypeString, - Optional: true, - Description: "Notifier description", - }, - "send_resolved": { - Type: schema.TypeBool, - Optional: true, - Description: "Notifier send resolved", - Default: false, - }, - "dingtalk_config": { - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - ConflictsWith: []string{"msteams_config", "pagerduty_config", "smtp_config", "slack_config", "webhook_config", "wechat_config"}, - Elem: &schema.Resource{ - Schema: notifierDingtalkConfigFields(), - }, - }, - "msteams_config": { - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - ConflictsWith: []string{"dingtalk_config", "pagerduty_config", "smtp_config", "slack_config", "webhook_config", "wechat_config"}, - Elem: &schema.Resource{ - Schema: notifierMSTeamsConfigFields(), - }, - }, - "pagerduty_config": { - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - ConflictsWith: []string{"dingtalk_config", "msteams_config", "smtp_config", "slack_config", "webhook_config", "wechat_config"}, - Elem: &schema.Resource{ - Schema: notifierPagerdutyConfigFields(), - }, - }, - "slack_config": { - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - ConflictsWith: []string{"dingtalk_config", "msteams_config", "pagerduty_config", "smtp_config", "webhook_config", "wechat_config"}, - Elem: &schema.Resource{ - Schema: notifierSlackConfigFields(), - }, - }, - "smtp_config": { - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - ConflictsWith: []string{"dingtalk_config", "msteams_config", "pagerduty_config", "slack_config", "webhook_config", "wechat_config"}, - Elem: &schema.Resource{ - Schema: notifierSMTPConfigFields(), - }, - }, - "webhook_config": { - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - ConflictsWith: []string{"dingtalk_config", "msteams_config", "pagerduty_config", "smtp_config", "slack_config", "wechat_config"}, - Elem: &schema.Resource{ - Schema: notifierWebhookConfigFields(), - }, - }, - "wechat_config": { - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - ConflictsWith: []string{"dingtalk_config", "msteams_config", "pagerduty_config", "smtp_config", "slack_config", "webhook_config"}, - Elem: &schema.Resource{ - Schema: notifierWechatConfigFields(), - }, - }, - } - - for k, v := range commonAnnotationLabelFields() { - s[k] = v - } - - return s -} diff --git a/rancher2/schema_notifier_dingtalk_config.go b/rancher2/schema_notifier_dingtalk_config.go deleted file mode 100644 index 81efe0dc..00000000 --- a/rancher2/schema_notifier_dingtalk_config.go +++ /dev/null @@ -1,30 +0,0 @@ -package rancher2 - -import ( - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" -) - -// Schemas - -func notifierDingtalkConfigFields() map[string]*schema.Schema { - s := map[string]*schema.Schema{ - "url": { - Type: schema.TypeString, - Required: true, - Description: "Webhook URL", - }, - "proxy_url": { - Type: schema.TypeString, - Optional: true, - Description: "Dingtalk proxy URL", - }, - "secret": { - Type: schema.TypeString, - Optional: true, - Sensitive: true, - Description: "Required for webhook with sign enabled", - }, - } - - return s -} diff --git a/rancher2/schema_notifier_msteams_config.go b/rancher2/schema_notifier_msteams_config.go deleted file mode 100644 index 1816c08a..00000000 --- a/rancher2/schema_notifier_msteams_config.go +++ /dev/null @@ -1,24 +0,0 @@ -package rancher2 - -import ( - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" -) - -// Schemas - -func notifierMSTeamsConfigFields() map[string]*schema.Schema { - s := map[string]*schema.Schema{ - "url": { - Type: schema.TypeString, - Required: true, - Description: "Webhook URL", - }, - "proxy_url": { - Type: schema.TypeString, - Optional: true, - Description: "MS teams proxy URL", - }, - } - - return s -} diff --git a/rancher2/schema_notifier_pagerduty_config.go b/rancher2/schema_notifier_pagerduty_config.go deleted file mode 100644 index 17e07bfa..00000000 --- a/rancher2/schema_notifier_pagerduty_config.go +++ /dev/null @@ -1,24 +0,0 @@ -package rancher2 - -import ( - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" -) - -// Schemas - -func notifierPagerdutyConfigFields() map[string]*schema.Schema { - s := map[string]*schema.Schema{ - "service_key": { - Type: schema.TypeString, - Required: true, - Description: "Pagerduty service key", - }, - "proxy_url": { - Type: schema.TypeString, - Optional: true, - Description: "Pagerduty proxy URL", - }, - } - - return s -} diff --git a/rancher2/schema_notifier_slack_config.go b/rancher2/schema_notifier_slack_config.go deleted file mode 100644 index 59eed8d6..00000000 --- a/rancher2/schema_notifier_slack_config.go +++ /dev/null @@ -1,29 +0,0 @@ -package rancher2 - -import ( - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" -) - -// Schemas - -func notifierSlackConfigFields() map[string]*schema.Schema { - s := map[string]*schema.Schema{ - "default_recipient": { - Type: schema.TypeString, - Required: true, - Description: "Slack default channel", - }, - "url": { - Type: schema.TypeString, - Required: true, - Description: "Slack URL", - }, - "proxy_url": { - Type: schema.TypeString, - Optional: true, - Description: "Slack proxy URL", - }, - } - - return s -} diff --git a/rancher2/schema_notifier_smtp_config.go b/rancher2/schema_notifier_smtp_config.go deleted file mode 100644 index 6e29112d..00000000 --- a/rancher2/schema_notifier_smtp_config.go +++ /dev/null @@ -1,51 +0,0 @@ -package rancher2 - -import ( - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" -) - -// Schemas - -func notifierSMTPConfigFields() map[string]*schema.Schema { - s := map[string]*schema.Schema{ - "default_recipient": { - Type: schema.TypeString, - Required: true, - Description: "SMTP default recipient address", - }, - "host": { - Type: schema.TypeString, - Required: true, - Description: "SMTP host", - }, - "port": { - Type: schema.TypeInt, - Required: true, - Description: "SMTP port", - }, - "sender": { - Type: schema.TypeString, - Required: true, - Description: "SMTP sender", - }, - "password": { - Type: schema.TypeString, - Optional: true, - Sensitive: true, - Description: "SMTP password", - }, - "tls": { - Type: schema.TypeBool, - Optional: true, - Default: true, - Description: "SMTP TLS", - }, - "username": { - Type: schema.TypeString, - Optional: true, - Description: "SMTP username", - }, - } - - return s -} diff --git a/rancher2/schema_notifier_webhook_config.go b/rancher2/schema_notifier_webhook_config.go deleted file mode 100644 index 532f3878..00000000 --- a/rancher2/schema_notifier_webhook_config.go +++ /dev/null @@ -1,24 +0,0 @@ -package rancher2 - -import ( - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" -) - -// Schemas - -func notifierWebhookConfigFields() map[string]*schema.Schema { - s := map[string]*schema.Schema{ - "url": { - Type: schema.TypeString, - Required: true, - Description: "Webhook URL", - }, - "proxy_url": { - Type: schema.TypeString, - Optional: true, - Description: "Webhook proxy URL", - }, - } - - return s -} diff --git a/rancher2/schema_notifier_wechat_config.go b/rancher2/schema_notifier_wechat_config.go deleted file mode 100644 index 14dededf..00000000 --- a/rancher2/schema_notifier_wechat_config.go +++ /dev/null @@ -1,58 +0,0 @@ -package rancher2 - -import ( - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - "github.com/hashicorp/terraform-plugin-sdk/helper/validation" -) - -const ( - notifierWechatRecipientTypeParty = "party" - notifierWechatRecipientTypeTag = "tag" - notifierWechatRecipientTypeUser = "user" -) - -var ( - notifierWechatRecipientTypes = []string{notifierWechatRecipientTypeParty, notifierWechatRecipientTypeTag, notifierWechatRecipientTypeUser} -) - -// Schemas - -func notifierWechatConfigFields() map[string]*schema.Schema { - s := map[string]*schema.Schema{ - "agent": { - Type: schema.TypeString, - Required: true, - Description: "Wechat application agent ID", - }, - "corp": { - Type: schema.TypeString, - Required: true, - Description: "Wechat corporation ID", - }, - "default_recipient": { - Type: schema.TypeString, - Required: true, - Description: "Wechat default channel", - }, - "secret": { - Type: schema.TypeString, - Required: true, - Sensitive: true, - Description: "Wechat application secret", - }, - "proxy_url": { - Type: schema.TypeString, - Optional: true, - Description: "Wechat proxy URL", - }, - "recipient_type": { - Type: schema.TypeString, - Optional: true, - Default: notifierWechatRecipientTypeParty, - Description: "Wechat recipient type", - ValidateFunc: validation.StringInSlice(notifierWechatRecipientTypes, true), - }, - } - - return s -} diff --git a/rancher2/schema_project.go b/rancher2/schema_project.go index 85f81f2d..8d63492d 100644 --- a/rancher2/schema_project.go +++ b/rancher2/schema_project.go @@ -116,25 +116,6 @@ func projectFields() map[string]*schema.Schema { Type: schema.TypeString, Optional: true, }, - "enable_project_monitoring": { - Type: schema.TypeBool, - Optional: true, - Default: false, - Description: "Enable built-in project monitoring", - }, - "pod_security_policy_template_id": { - Type: schema.TypeString, - Optional: true, - }, - "project_monitoring_input": { - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Description: "Cluster monitoring configuration", - Elem: &schema.Resource{ - Schema: monitoringInputFields(), - }, - }, "resource_quota": { Type: schema.TypeList, MaxItems: 1, diff --git a/rancher2/schema_project_alert_group.go b/rancher2/schema_project_alert_group.go deleted file mode 100644 index aad60329..00000000 --- a/rancher2/schema_project_alert_group.go +++ /dev/null @@ -1,23 +0,0 @@ -package rancher2 - -import ( - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" -) - -//Schemas - -func projectAlertGroupFields() map[string]*schema.Schema { - s := map[string]*schema.Schema{ - "project_id": { - Type: schema.TypeString, - Required: true, - Description: "Alert group Project ID", - }, - } - - for k, v := range alertGroupFields() { - s[k] = v - } - - return s -} diff --git a/rancher2/schema_project_alert_rule.go b/rancher2/schema_project_alert_rule.go deleted file mode 100644 index 65ce73c4..00000000 --- a/rancher2/schema_project_alert_rule.go +++ /dev/null @@ -1,53 +0,0 @@ -package rancher2 - -import ( - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" -) - -//Schemas - -func projectAlertRuleFields() map[string]*schema.Schema { - s := map[string]*schema.Schema{ - "project_id": { - Type: schema.TypeString, - Required: true, - Description: "Alert rule Project ID", - }, - "metric_rule": { - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - ConflictsWith: []string{"pod_rule", "workload_rule"}, - Elem: &schema.Resource{ - Schema: metricRuleFields(), - }, - Description: "Alert metric rule", - }, - "pod_rule": { - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - ConflictsWith: []string{"metric_rule", "workload_rule"}, - Elem: &schema.Resource{ - Schema: podRuleFields(), - }, - Description: "Alert pod rule", - }, - "workload_rule": { - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - ConflictsWith: []string{"metric_rule", "pod_rule"}, - Elem: &schema.Resource{ - Schema: workloadRuleFields(), - }, - Description: "Alert workload rule", - }, - } - - for k, v := range alertRuleFields() { - s[k] = v - } - - return s -} diff --git a/rancher2/schema_recipient.go b/rancher2/schema_recipient.go deleted file mode 100644 index 4a8839fa..00000000 --- a/rancher2/schema_recipient.go +++ /dev/null @@ -1,45 +0,0 @@ -package rancher2 - -import ( - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" -) - -const ( - recipientTypeDingtalk = "dingtalk" - recipientTypeMsTeams = "msteams" - recipientTypePagerduty = "pagerduty" - recipientTypeSlack = "slack" - recipientTypeSMTP = "email" - recipientTypeWebhook = "webhook" - recipientTypeWechat = "wechat" -) - -//Schemas - -func recipientFields() map[string]*schema.Schema { - s := map[string]*schema.Schema{ - "notifier_id": { - Type: schema.TypeString, - Required: true, - Description: "Recipient notifier ID", - }, - "notifier_type": { - Type: schema.TypeString, - Computed: true, - Description: "Recipient notifier type", - }, - "recipient": { - Type: schema.TypeString, - Optional: true, - Computed: true, - Description: "Recipient", - }, - "default_recipient": { - Type: schema.TypeBool, - Optional: true, - Default: false, - Description: "Use notifier default recipient", - }, - } - return s -} diff --git a/rancher2/structure_alert_rule.go b/rancher2/structure_alert_rule.go deleted file mode 100644 index 9469f9d2..00000000 --- a/rancher2/structure_alert_rule.go +++ /dev/null @@ -1,295 +0,0 @@ -package rancher2 - -import ( - managementClient "github.com/rancher/rancher/pkg/client/generated/management/v3" -) - -// Flatteners - -func flattenEventRule(in *managementClient.EventRule) []interface{} { - obj := map[string]interface{}{} - - if in == nil { - return []interface{}{} - } - - if len(in.EventType) > 0 { - obj["event_type"] = in.EventType - } - - if len(in.ResourceKind) > 0 { - obj["resource_kind"] = in.ResourceKind - } - - return []interface{}{obj} -} - -func flattenMetricRule(in *managementClient.MetricRule) []interface{} { - obj := map[string]interface{}{} - - if in == nil { - return []interface{}{} - } - - if len(in.Comparison) > 0 { - obj["comparison"] = in.Comparison - } - - if len(in.Duration) > 0 { - obj["duration"] = in.Duration - } - - if len(in.Expression) > 0 { - obj["expression"] = in.Expression - } - - if in.ThresholdValue > 0 { - obj["threshold_value"] = in.ThresholdValue - } - - if len(in.Description) > 0 { - obj["description"] = in.Description - } - - return []interface{}{obj} -} - -func flattenNodeRule(in *managementClient.NodeRule) []interface{} { - obj := map[string]interface{}{} - - if in == nil { - return []interface{}{} - } - - if in.CPUThreshold > 0 { - obj["cpu_threshold"] = int(in.CPUThreshold) - } - - if len(in.Condition) > 0 { - obj["condition"] = in.Condition - } - - if in.MemThreshold > 0 { - obj["mem_threshold"] = int(in.MemThreshold) - } - - if len(in.NodeID) > 0 { - obj["node_id"] = in.NodeID - } - - if len(in.Selector) > 0 { - obj["selector"] = toMapInterface(in.Selector) - } - - return []interface{}{obj} -} - -func flattenPodRule(in *managementClient.PodRule) []interface{} { - obj := map[string]interface{}{} - - if in == nil { - return []interface{}{} - } - - if len(in.Condition) > 0 { - obj["condition"] = in.Condition - } - - if len(in.PodID) > 0 { - obj["pod_id"] = in.PodID - } - - if in.RestartIntervalSeconds > 0 { - obj["restart_interval_seconds"] = int(in.RestartIntervalSeconds) - } - - if in.RestartTimes > 0 { - obj["restart_times"] = int(in.RestartTimes) - } - - return []interface{}{obj} -} - -func flattenSystemServiceRule(in *managementClient.SystemServiceRule) []interface{} { - obj := map[string]interface{}{} - - if in == nil { - return []interface{}{} - } - - if len(in.Condition) > 0 { - obj["condition"] = in.Condition - } - - return []interface{}{obj} -} - -func flattenWorkloadRule(in *managementClient.WorkloadRule) []interface{} { - obj := map[string]interface{}{} - - if in == nil { - return []interface{}{} - } - - if in.AvailablePercentage > 0 { - obj["available_percentage"] = int(in.AvailablePercentage) - } - - if len(in.Selector) > 0 { - obj["selector"] = toMapInterface(in.Selector) - } - - if len(in.WorkloadID) > 0 { - obj["workload_id"] = in.WorkloadID - } - - return []interface{}{obj} -} - -// Expanders - -func expandEventRule(p []interface{}) *managementClient.EventRule { - obj := &managementClient.EventRule{} - - if len(p) == 0 || p[0] == nil { - return obj - } - in := p[0].(map[string]interface{}) - - if v, ok := in["event_type"].(string); ok && len(v) > 0 { - obj.EventType = v - } - - if v, ok := in["resource_kind"].(string); ok && len(v) > 0 { - obj.ResourceKind = v - } - - return obj -} - -func expandMetricRule(p []interface{}) *managementClient.MetricRule { - obj := &managementClient.MetricRule{} - - if len(p) == 0 || p[0] == nil { - return obj - } - in := p[0].(map[string]interface{}) - - if v, ok := in["comparison"].(string); ok && len(v) > 0 { - obj.Comparison = v - } - - if v, ok := in["duration"].(string); ok && len(v) > 0 { - obj.Duration = v - } - - if v, ok := in["expression"].(string); ok && len(v) > 0 { - obj.Expression = v - } - - if v, ok := in["threshold_value"].(float64); ok && v > 0 { - obj.ThresholdValue = v - } - - if v, ok := in["description"].(string); ok && len(v) > 0 { - obj.Description = v - } - - return obj -} - -func expandNodeRule(p []interface{}) *managementClient.NodeRule { - obj := &managementClient.NodeRule{} - - if len(p) == 0 || p[0] == nil { - return obj - } - in := p[0].(map[string]interface{}) - - if v, ok := in["cpu_threshold"].(int); ok && v > 0 { - obj.CPUThreshold = int64(v) - } - - if v, ok := in["condition"].(string); ok && len(v) > 0 { - obj.Condition = v - } - - if v, ok := in["mem_threshold"].(int); ok && v > 0 { - obj.MemThreshold = int64(v) - } - - if v, ok := in["node_id"].(string); ok && len(v) > 0 { - obj.NodeID = v - } - - if v, ok := in["selector"].(map[string]interface{}); ok && len(v) > 0 { - obj.Selector = toMapString(v) - } - - return obj -} - -func expandPodRule(p []interface{}) *managementClient.PodRule { - obj := &managementClient.PodRule{} - - if len(p) == 0 || p[0] == nil { - return obj - } - in := p[0].(map[string]interface{}) - - if v, ok := in["condition"].(string); ok && len(v) > 0 { - obj.Condition = v - } - - if v, ok := in["pod_id"].(string); ok && len(v) > 0 { - obj.PodID = v - } - - if v, ok := in["restart_interval_seconds"].(int); ok && v > 0 { - obj.RestartIntervalSeconds = int64(v) - } - - if v, ok := in["restart_times"].(int); ok && v > 0 { - obj.RestartTimes = int64(v) - } - - return obj -} - -func expandSystemServiceRule(p []interface{}) *managementClient.SystemServiceRule { - obj := &managementClient.SystemServiceRule{} - - if len(p) == 0 || p[0] == nil { - return obj - } - in := p[0].(map[string]interface{}) - - if v, ok := in["condition"].(string); ok && len(v) > 0 { - obj.Condition = v - } - - return obj -} - -func expandWorkloadRule(p []interface{}) *managementClient.WorkloadRule { - obj := &managementClient.WorkloadRule{} - - if len(p) == 0 || p[0] == nil { - return obj - } - in := p[0].(map[string]interface{}) - - if v, ok := in["available_percentage"].(int); ok && v > 0 { - obj.AvailablePercentage = int64(v) - } - - if v, ok := in["selector"].(map[string]interface{}); ok && len(v) > 0 { - obj.Selector = toMapString(v) - } - - if v, ok := in["workload_id"].(string); ok && len(v) > 0 { - obj.WorkloadID = v - } - - return obj -} diff --git a/rancher2/structure_alert_rule_test.go b/rancher2/structure_alert_rule_test.go deleted file mode 100644 index a507bab1..00000000 --- a/rancher2/structure_alert_rule_test.go +++ /dev/null @@ -1,330 +0,0 @@ -package rancher2 - -import ( - "testing" - - managementClient "github.com/rancher/rancher/pkg/client/generated/management/v3" - "github.com/stretchr/testify/assert" -) - -var ( - testAlertEventRuleConf *managementClient.EventRule - testAlertEventRuleInterface []interface{} - testAlertMetricRuleConf *managementClient.MetricRule - testAlertMetricRuleInterface []interface{} - testAlertNodeRuleConf *managementClient.NodeRule - testAlertNodeRuleInterface []interface{} - testAlertPodRuleConf *managementClient.PodRule - testAlertPodRuleInterface []interface{} - testAlertSystemServiceRuleConf *managementClient.SystemServiceRule - testAlertSystemServiceRuleInterface []interface{} - testAlertWorkloadRuleConf *managementClient.WorkloadRule - testAlertWorkloadRuleInterface []interface{} -) - -func init() { - testAlertEventRuleConf = &managementClient.EventRule{ - EventType: eventRuleTypeWarning, - ResourceKind: eventRuleResourceKindNode, - } - testAlertEventRuleInterface = []interface{}{ - map[string]interface{}{ - "event_type": eventRuleTypeWarning, - "resource_kind": eventRuleResourceKindNode, - }, - } - testAlertMetricRuleConf = &managementClient.MetricRule{ - Comparison: metricRuleComparisonEqual, - Duration: "30", - Expression: "expression", - ThresholdValue: float64(3.5), - Description: "description", - } - testAlertMetricRuleInterface = []interface{}{ - map[string]interface{}{ - "comparison": metricRuleComparisonEqual, - "duration": "30", - "expression": "expression", - "threshold_value": float64(3.5), - "description": "description", - }, - } - testAlertNodeRuleConf = &managementClient.NodeRule{ - CPUThreshold: int64(70), - Condition: nodeRuleConditionNotReady, - MemThreshold: int64(70), - NodeID: "node_id", - Selector: map[string]string{ - "selector1": "selector1", - "selector2": "selector2", - }, - } - testAlertNodeRuleInterface = []interface{}{ - map[string]interface{}{ - "cpu_threshold": 70, - "condition": nodeRuleConditionNotReady, - "mem_threshold": 70, - "node_id": "node_id", - "selector": map[string]interface{}{ - "selector1": "selector1", - "selector2": "selector2", - }, - }, - } - testAlertPodRuleConf = &managementClient.PodRule{ - Condition: podRuleConditionNotRunning, - PodID: "pod_id", - RestartIntervalSeconds: int64(70), - RestartTimes: int64(5), - } - testAlertPodRuleInterface = []interface{}{ - map[string]interface{}{ - "condition": podRuleConditionNotRunning, - "pod_id": "pod_id", - "restart_interval_seconds": 70, - "restart_times": 5, - }, - } - testAlertSystemServiceRuleConf = &managementClient.SystemServiceRule{ - Condition: systemServiceRuleConditionScheduler, - } - testAlertSystemServiceRuleInterface = []interface{}{ - map[string]interface{}{ - "condition": systemServiceRuleConditionScheduler, - }, - } - testAlertWorkloadRuleConf = &managementClient.WorkloadRule{ - AvailablePercentage: int64(70), - Selector: map[string]string{ - "selector1": "selector1", - "selector2": "selector2", - }, - WorkloadID: "workload_id", - } - testAlertWorkloadRuleInterface = []interface{}{ - map[string]interface{}{ - "available_percentage": 70, - "selector": map[string]interface{}{ - "selector1": "selector1", - "selector2": "selector2", - }, - "workload_id": "workload_id", - }, - } -} - -func TestFlattenEventRule(t *testing.T) { - - cases := []struct { - Input *managementClient.EventRule - ExpectedOutput []interface{} - }{ - { - testAlertEventRuleConf, - testAlertEventRuleInterface, - }, - } - - for _, tc := range cases { - output := flattenEventRule(tc.Input) - assert.Equal(t, tc.ExpectedOutput, output, "Unexpected output from flattener.") - } -} - -func TestFlattenMetricRule(t *testing.T) { - - cases := []struct { - Input *managementClient.MetricRule - ExpectedOutput []interface{} - }{ - { - testAlertMetricRuleConf, - testAlertMetricRuleInterface, - }, - } - - for _, tc := range cases { - output := flattenMetricRule(tc.Input) - assert.Equal(t, tc.ExpectedOutput, output, "Unexpected output from flattener.") - } -} - -func TestFlattenNodeRule(t *testing.T) { - - cases := []struct { - Input *managementClient.NodeRule - ExpectedOutput []interface{} - }{ - { - testAlertNodeRuleConf, - testAlertNodeRuleInterface, - }, - } - - for _, tc := range cases { - output := flattenNodeRule(tc.Input) - assert.Equal(t, tc.ExpectedOutput, output, "Unexpected output from flattener.") - } -} - -func TestFlattenPodRule(t *testing.T) { - - cases := []struct { - Input *managementClient.PodRule - ExpectedOutput []interface{} - }{ - { - testAlertPodRuleConf, - testAlertPodRuleInterface, - }, - } - - for _, tc := range cases { - output := flattenPodRule(tc.Input) - assert.Equal(t, tc.ExpectedOutput, output, "Unexpected output from flattener.") - } -} - -func TestFlattenSystemServiceRule(t *testing.T) { - - cases := []struct { - Input *managementClient.SystemServiceRule - ExpectedOutput []interface{} - }{ - { - testAlertSystemServiceRuleConf, - testAlertSystemServiceRuleInterface, - }, - } - - for _, tc := range cases { - output := flattenSystemServiceRule(tc.Input) - assert.Equal(t, tc.ExpectedOutput, output, "Unexpected output from flattener.") - } -} - -func TestFlattenWorkloadRule(t *testing.T) { - - cases := []struct { - Input *managementClient.WorkloadRule - ExpectedOutput []interface{} - }{ - { - testAlertWorkloadRuleConf, - testAlertWorkloadRuleInterface, - }, - } - - for _, tc := range cases { - output := flattenWorkloadRule(tc.Input) - assert.Equal(t, tc.ExpectedOutput, output, "Unexpected output from flattener.") - } -} - -func TestExpandEventRule(t *testing.T) { - - cases := []struct { - Input []interface{} - ExpectedOutput *managementClient.EventRule - }{ - { - testAlertEventRuleInterface, - testAlertEventRuleConf, - }, - } - - for _, tc := range cases { - output := expandEventRule(tc.Input) - assert.Equal(t, tc.ExpectedOutput, output, "Unexpected output from expander.") - } -} - -func TestExpandMetricRule(t *testing.T) { - - cases := []struct { - Input []interface{} - ExpectedOutput *managementClient.MetricRule - }{ - { - testAlertMetricRuleInterface, - testAlertMetricRuleConf, - }, - } - - for _, tc := range cases { - output := expandMetricRule(tc.Input) - assert.Equal(t, tc.ExpectedOutput, output, "Unexpected output from expander.") - } -} - -func TestExpandNodeRule(t *testing.T) { - - cases := []struct { - Input []interface{} - ExpectedOutput *managementClient.NodeRule - }{ - { - testAlertNodeRuleInterface, - testAlertNodeRuleConf, - }, - } - - for _, tc := range cases { - output := expandNodeRule(tc.Input) - assert.Equal(t, tc.ExpectedOutput, output, "Unexpected output from expander.") - } -} - -func TestExpandPodRule(t *testing.T) { - - cases := []struct { - Input []interface{} - ExpectedOutput *managementClient.PodRule - }{ - { - testAlertPodRuleInterface, - testAlertPodRuleConf, - }, - } - - for _, tc := range cases { - output := expandPodRule(tc.Input) - assert.Equal(t, tc.ExpectedOutput, output, "Unexpected output from expander.") - } -} - -func TestExpandSystemServiceRule(t *testing.T) { - - cases := []struct { - Input []interface{} - ExpectedOutput *managementClient.SystemServiceRule - }{ - { - testAlertSystemServiceRuleInterface, - testAlertSystemServiceRuleConf, - }, - } - - for _, tc := range cases { - output := expandSystemServiceRule(tc.Input) - assert.Equal(t, tc.ExpectedOutput, output, "Unexpected output from expander.") - } -} - -func TestExpandWorkloadRule(t *testing.T) { - - cases := []struct { - Input []interface{} - ExpectedOutput *managementClient.WorkloadRule - }{ - { - testAlertWorkloadRuleInterface, - testAlertWorkloadRuleConf, - }, - } - - for _, tc := range cases { - output := expandWorkloadRule(tc.Input) - assert.Equal(t, tc.ExpectedOutput, output, "Unexpected output from expander.") - } -} diff --git a/rancher2/structure_cluster.go b/rancher2/structure_cluster.go index 687125a0..45a3c46d 100644 --- a/rancher2/structure_cluster.go +++ b/rancher2/structure_cluster.go @@ -45,7 +45,7 @@ func flattenClusterAuthEndpoint(in *managementClient.LocalClusterAuthEndpoint) [ return []interface{}{obj} } -func flattenCluster(d *schema.ResourceData, in *Cluster, clusterRegToken *managementClient.ClusterRegistrationToken, kubeConfig *managementClient.GenerateKubeConfigOutput, defaultProjectID, systemProjectID string, monitoringInput *managementClient.MonitoringInput) error { +func flattenCluster(d *schema.ResourceData, in *Cluster, clusterRegToken *managementClient.ClusterRegistrationToken, kubeConfig *managementClient.GenerateKubeConfigOutput, defaultProjectID, systemProjectID string) error { if in == nil { return fmt.Errorf("[ERROR] flattening cluster: Input cluster is nil") } @@ -100,10 +100,6 @@ func flattenCluster(d *schema.ResourceData, in *Cluster, clusterRegToken *manage } - if len(in.DefaultPodSecurityPolicyTemplateID) > 0 { - d.Set("default_pod_security_policy_template_id", in.DefaultPodSecurityPolicyTemplateID) - } - if len(in.DefaultPodSecurityAdmissionConfigurationTemplateName) > 0 { d.Set("default_pod_security_admission_configuration_template_name", in.DefaultPodSecurityAdmissionConfigurationTemplateName) } @@ -124,8 +120,6 @@ func flattenCluster(d *schema.ResourceData, in *Cluster, clusterRegToken *manage d.Set("fleet_workspace_name", in.FleetWorkspaceName) } - d.Set("enable_cluster_alerting", in.EnableClusterAlerting) - d.Set("enable_cluster_monitoring", in.EnableClusterMonitoring) d.Set("istio_enabled", in.IstioEnabled) if in.EnableNetworkPolicy != nil { @@ -149,11 +143,6 @@ func flattenCluster(d *schema.ResourceData, in *Cluster, clusterRegToken *manage return err } - err = d.Set("cluster_monitoring_input", flattenMonitoringInput(monitoringInput)) - if err != nil { - return err - } - if len(in.CACert) > 0 { d.Set("ca_cert", in.CACert) } @@ -462,10 +451,6 @@ func expandCluster(in *schema.ResourceData) (*Cluster, error) { } } - if v, ok := in.Get("default_pod_security_policy_template_id").(string); ok && len(v) > 0 { - obj.DefaultPodSecurityPolicyTemplateID = v - } - if v, ok := in.Get("default_pod_security_admission_configuration_template_name").(string); ok && len(v) > 0 { obj.DefaultPodSecurityAdmissionConfigurationTemplateName = v } @@ -482,14 +467,6 @@ func expandCluster(in *schema.ResourceData) (*Cluster, error) { obj.DockerRootDir = v } - if v, ok := in.Get("enable_cluster_alerting").(bool); ok { - obj.EnableClusterAlerting = v - } - - if v, ok := in.Get("enable_cluster_monitoring").(bool); ok { - obj.EnableClusterMonitoring = v - } - if v, ok := in.Get("enable_network_policy").(bool); ok { obj.EnableNetworkPolicy = &v } diff --git a/rancher2/structure_cluster_alert_group.go b/rancher2/structure_cluster_alert_group.go deleted file mode 100644 index af85c343..00000000 --- a/rancher2/structure_cluster_alert_group.go +++ /dev/null @@ -1,77 +0,0 @@ -package rancher2 - -import ( - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - managementClient "github.com/rancher/rancher/pkg/client/generated/management/v3" -) - -// Flatteners - -func flattenClusterAlertGroup(d *schema.ResourceData, in *managementClient.ClusterAlertGroup) error { - if in == nil { - return nil - } - - d.SetId(in.ID) - d.Set("name", in.Name) - d.Set("cluster_id", in.ClusterID) - - if len(in.Description) > 0 { - d.Set("description", in.Description) - } - - d.Set("group_interval_seconds", int(in.GroupIntervalSeconds)) - d.Set("group_wait_seconds", int(in.GroupWaitSeconds)) - d.Set("recipients", flattenRecipients(in.Recipients)) - d.Set("repeat_interval_seconds", int(in.RepeatIntervalSeconds)) - - err := d.Set("annotations", toMapInterface(in.Annotations)) - if err != nil { - return err - } - - err = d.Set("labels", toMapInterface(in.Labels)) - if err != nil { - return err - } - return nil -} - -// Expanders - -func expandClusterAlertGroup(in *schema.ResourceData) *managementClient.ClusterAlertGroup { - obj := &managementClient.ClusterAlertGroup{} - if in == nil { - return nil - } - - if v := in.Id(); len(v) > 0 { - obj.ID = v - } - - obj.Name = in.Get("name").(string) - obj.ClusterID = in.Get("cluster_id").(string) - - if v, ok := in.Get("description").(string); ok && len(v) > 0 { - obj.Description = v - } - - obj.GroupIntervalSeconds = int64(in.Get("group_interval_seconds").(int)) - obj.GroupWaitSeconds = int64(in.Get("group_wait_seconds").(int)) - - if v, ok := in.Get("recipients").([]interface{}); ok && len(v) > 0 { - obj.Recipients = expandRecipients(v) - } - - obj.RepeatIntervalSeconds = int64(in.Get("repeat_interval_seconds").(int)) - - if v, ok := in.Get("annotations").(map[string]interface{}); ok && len(v) > 0 { - obj.Annotations = toMapString(v) - } - - if v, ok := in.Get("labels").(map[string]interface{}); ok && len(v) > 0 { - obj.Labels = toMapString(v) - } - - return obj -} diff --git a/rancher2/structure_cluster_alert_group_test.go b/rancher2/structure_cluster_alert_group_test.go deleted file mode 100644 index 8ac20d7a..00000000 --- a/rancher2/structure_cluster_alert_group_test.go +++ /dev/null @@ -1,101 +0,0 @@ -package rancher2 - -import ( - "reflect" - "testing" - - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - managementClient "github.com/rancher/rancher/pkg/client/generated/management/v3" - "github.com/stretchr/testify/assert" -) - -var ( - testClusterAlertGroupRecipientsConf []managementClient.Recipient - testClusterAlertGroupRecipientsInterface []interface{} - testClusterAlertGroupConf *managementClient.ClusterAlertGroup - testClusterAlertGroupInterface map[string]interface{} -) - -func init() { - testClusterAlertGroupRecipientsConf = []managementClient.Recipient{ - { - NotifierID: "notifier_id", - NotifierType: "webhook", - Recipient: "recipient", - }, - } - testClusterAlertGroupRecipientsInterface = []interface{}{ - map[string]interface{}{ - "notifier_id": "notifier_id", - "notifier_type": "webhook", - "recipient": "recipient", - "default_recipient": false, - }, - } - testClusterAlertGroupConf = &managementClient.ClusterAlertGroup{ - Name: "name", - ClusterID: "cluster_id", - Description: "description", - GroupIntervalSeconds: 300, - GroupWaitSeconds: 300, - Recipients: testClusterAlertGroupRecipientsConf, - RepeatIntervalSeconds: 6000, - } - testClusterAlertGroupInterface = map[string]interface{}{ - "name": "name", - "cluster_id": "cluster_id", - "description": "description", - "group_interval_seconds": 300, - "group_wait_seconds": 300, - "recipients": testClusterAlertGroupRecipientsInterface, - "repeat_interval_seconds": 6000, - } -} - -func TestFlattenClusterAlertGroup(t *testing.T) { - - cases := []struct { - Input *managementClient.ClusterAlertGroup - ExpectedOutput map[string]interface{} - }{ - { - testClusterAlertGroupConf, - testClusterAlertGroupInterface, - }, - } - - for _, tc := range cases { - output := schema.TestResourceDataRaw(t, clusterAlertGroupFields(), map[string]interface{}{}) - err := flattenClusterAlertGroup(output, tc.Input) - if err != nil { - assert.FailNow(t, "[ERROR] on flattener: %#v", err) - } - expectedOutput := map[string]interface{}{} - for k := range tc.ExpectedOutput { - expectedOutput[k] = output.Get(k) - } - if !reflect.DeepEqual(expectedOutput, tc.ExpectedOutput) { - assert.FailNow(t, "Unexpected output from flattener.\nExpected: %#v\nGiven: %#v", - expectedOutput, tc.ExpectedOutput) - } - } -} - -func TestExpandClusterAlertGroup(t *testing.T) { - - cases := []struct { - Input map[string]interface{} - ExpectedOutput *managementClient.ClusterAlertGroup - }{ - { - testClusterAlertGroupInterface, - testClusterAlertGroupConf, - }, - } - - for _, tc := range cases { - inputResourceData := schema.TestResourceDataRaw(t, clusterAlertGroupFields(), tc.Input) - output := expandClusterAlertGroup(inputResourceData) - assert.Equal(t, tc.ExpectedOutput, output, "Unexpected output from expander.") - } -} diff --git a/rancher2/structure_cluster_alert_rule.go b/rancher2/structure_cluster_alert_rule.go deleted file mode 100644 index 968a9550..00000000 --- a/rancher2/structure_cluster_alert_rule.go +++ /dev/null @@ -1,130 +0,0 @@ -package rancher2 - -import ( - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - managementClient "github.com/rancher/rancher/pkg/client/generated/management/v3" -) - -// Flatteners - -func flattenClusterAlertRule(d *schema.ResourceData, in *managementClient.ClusterAlertRule) error { - if in == nil { - return nil - } - - if len(in.ID) > 0 { - d.SetId(in.ID) - } - - d.Set("name", in.Name) - d.Set("cluster_id", in.ClusterID) - - if in.EventRule != nil { - err := d.Set("event_rule", flattenEventRule(in.EventRule)) - if err != nil { - return err - } - } - - d.Set("group_id", in.GroupID) - d.Set("group_interval_seconds", int(in.GroupIntervalSeconds)) - d.Set("group_wait_seconds", int(in.GroupWaitSeconds)) - - if in.Inherited != nil { - d.Set("inherited", *in.Inherited) - } - - if in.MetricRule != nil { - err := d.Set("metric_rule", flattenMetricRule(in.MetricRule)) - if err != nil { - return err - } - } - - if in.NodeRule != nil { - err := d.Set("node_rule", flattenNodeRule(in.NodeRule)) - if err != nil { - return err - } - } - - d.Set("repeat_interval_seconds", int(in.RepeatIntervalSeconds)) - - if len(in.Severity) > 0 { - d.Set("severity", in.Severity) - } - - if in.SystemServiceRule != nil { - err := d.Set("system_service_rule", flattenSystemServiceRule(in.SystemServiceRule)) - if err != nil { - return err - } - } - - err := d.Set("annotations", toMapInterface(in.Annotations)) - if err != nil { - return err - } - - err = d.Set("labels", toMapInterface(in.Labels)) - if err != nil { - return err - } - return nil -} - -// Expanders - -func expandClusterAlertRule(in *schema.ResourceData) *managementClient.ClusterAlertRule { - obj := &managementClient.ClusterAlertRule{} - if in == nil { - return nil - } - - if v := in.Id(); len(v) > 0 { - obj.ID = v - } - - obj.Name = in.Get("name").(string) - obj.ClusterID = in.Get("cluster_id").(string) - - if v, ok := in.Get("event_rule").([]interface{}); ok && len(v) > 0 { - obj.EventRule = expandEventRule(v) - } - - obj.GroupID = in.Get("group_id").(string) - obj.GroupIntervalSeconds = int64(in.Get("group_interval_seconds").(int)) - obj.GroupWaitSeconds = int64(in.Get("group_wait_seconds").(int)) - - if v, ok := in.Get("inherited").(bool); ok { - obj.Inherited = &v - } - - if v, ok := in.Get("metric_rule").([]interface{}); ok && len(v) > 0 { - obj.MetricRule = expandMetricRule(v) - } - - if v, ok := in.Get("node_rule").([]interface{}); ok && len(v) > 0 { - obj.NodeRule = expandNodeRule(v) - } - - obj.RepeatIntervalSeconds = int64(in.Get("repeat_interval_seconds").(int)) - - if v, ok := in.Get("severity").(string); ok { - obj.Severity = v - } - - if v, ok := in.Get("system_service_rule").([]interface{}); ok && len(v) > 0 { - obj.SystemServiceRule = expandSystemServiceRule(v) - } - - if v, ok := in.Get("annotations").(map[string]interface{}); ok && len(v) > 0 { - obj.Annotations = toMapString(v) - } - - if v, ok := in.Get("labels").(map[string]interface{}); ok && len(v) > 0 { - obj.Labels = toMapString(v) - } - - return obj -} diff --git a/rancher2/structure_cluster_alert_rule_test.go b/rancher2/structure_cluster_alert_rule_test.go deleted file mode 100644 index 4866a466..00000000 --- a/rancher2/structure_cluster_alert_rule_test.go +++ /dev/null @@ -1,158 +0,0 @@ -package rancher2 - -import ( - "reflect" - "testing" - - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - managementClient "github.com/rancher/rancher/pkg/client/generated/management/v3" - "github.com/stretchr/testify/assert" -) - -var ( - testClusterAlertEventRuleConf *managementClient.EventRule - testClusterAlertEventRuleInterface []interface{} - testClusterAlertMetricRuleConf *managementClient.MetricRule - testClusterAlertMetricRuleInterface []interface{} - testClusterAlertNodeRuleConf *managementClient.NodeRule - testClusterAlertNodeRuleInterface []interface{} - testClusterAlertSystemServiceRuleConf *managementClient.SystemServiceRule - testClusterAlertSystemServiceRuleInterface []interface{} - testClusterAlertRuleConf *managementClient.ClusterAlertRule - testClusterAlertRuleInterface map[string]interface{} -) - -func init() { - testClusterAlertEventRuleConf = &managementClient.EventRule{ - EventType: eventRuleTypeWarning, - ResourceKind: eventRuleResourceKindNode, - } - testClusterAlertEventRuleInterface = []interface{}{ - map[string]interface{}{ - "event_type": eventRuleTypeWarning, - "resource_kind": eventRuleResourceKindNode, - }, - } - testClusterAlertMetricRuleConf = &managementClient.MetricRule{ - Comparison: metricRuleComparisonEqual, - Duration: "30", - Expression: "expression", - ThresholdValue: float64(3.5), - Description: "description", - } - testClusterAlertMetricRuleInterface = []interface{}{ - map[string]interface{}{ - "comparison": metricRuleComparisonEqual, - "duration": "30", - "expression": "expression", - "threshold_value": float64(3.5), - "description": "description", - }, - } - testClusterAlertNodeRuleConf = &managementClient.NodeRule{ - CPUThreshold: int64(70), - Condition: nodeRuleConditionNotReady, - MemThreshold: int64(70), - NodeID: "node_id", - Selector: map[string]string{ - "selector1": "selector1", - "selector2": "selector2", - }, - } - testClusterAlertNodeRuleInterface = []interface{}{ - map[string]interface{}{ - "cpu_threshold": 70, - "condition": nodeRuleConditionNotReady, - "mem_threshold": 70, - "node_id": "node_id", - "selector": map[string]interface{}{ - "selector1": "selector1", - "selector2": "selector2", - }, - }, - } - testClusterAlertSystemServiceRuleConf = &managementClient.SystemServiceRule{ - Condition: systemServiceRuleConditionScheduler, - } - testClusterAlertSystemServiceRuleInterface = []interface{}{ - map[string]interface{}{ - "condition": systemServiceRuleConditionScheduler, - }, - } - testClusterAlertRuleConf = &managementClient.ClusterAlertRule{ - Name: "name", - ClusterID: "cluster_id", - EventRule: testClusterAlertEventRuleConf, - GroupID: "group_id", - GroupIntervalSeconds: 300, - GroupWaitSeconds: 300, - Inherited: newTrue(), - MetricRule: testClusterAlertMetricRuleConf, - NodeRule: testClusterAlertNodeRuleConf, - RepeatIntervalSeconds: 6000, - Severity: alertRuleSeverityCritical, - SystemServiceRule: testClusterAlertSystemServiceRuleConf, - } - testClusterAlertRuleInterface = map[string]interface{}{ - "name": "name", - "cluster_id": "cluster_id", - "event_rule": testClusterAlertEventRuleInterface, - "group_id": "group_id", - "group_interval_seconds": 300, - "group_wait_seconds": 300, - "inherited": true, - "metric_rule": testClusterAlertMetricRuleInterface, - "node_rule": testClusterAlertNodeRuleInterface, - "repeat_interval_seconds": 6000, - "severity": alertRuleSeverityCritical, - "system_service_rule": testClusterAlertSystemServiceRuleInterface, - } -} - -func TestFlattenClusterAlertRule(t *testing.T) { - - cases := []struct { - Input *managementClient.ClusterAlertRule - ExpectedOutput map[string]interface{} - }{ - { - testClusterAlertRuleConf, - testClusterAlertRuleInterface, - }, - } - - for _, tc := range cases { - output := schema.TestResourceDataRaw(t, clusterAlertRuleFields(), map[string]interface{}{}) - err := flattenClusterAlertRule(output, tc.Input) - if err != nil { - assert.FailNow(t, "[ERROR] on flattener: %#v", err) - } - expectedOutput := map[string]interface{}{} - for k := range tc.ExpectedOutput { - expectedOutput[k] = output.Get(k) - } - if !reflect.DeepEqual(expectedOutput, tc.ExpectedOutput) { - assert.FailNow(t, "Unexpected output from flattener.\nExpected: %#v\nGiven: %#v", - expectedOutput, tc.ExpectedOutput) - } - } -} - -func TestExpandClusterAlertRule(t *testing.T) { - - cases := []struct { - Input map[string]interface{} - ExpectedOutput *managementClient.ClusterAlertRule - }{ - { - testClusterAlertRuleInterface, - testClusterAlertRuleConf, - }, - } - - for _, tc := range cases { - inputResourceData := schema.TestResourceDataRaw(t, clusterAlertRuleFields(), tc.Input) - output := expandClusterAlertRule(inputResourceData) - assert.Equal(t, tc.ExpectedOutput, output, "Unexpected output from expander.") - } -} diff --git a/rancher2/structure_cluster_rke_config_services_kube_api.go b/rancher2/structure_cluster_rke_config_services_kube_api.go index 8614b257..bc1f043f 100644 --- a/rancher2/structure_cluster_rke_config_services_kube_api.go +++ b/rancher2/structure_cluster_rke_config_services_kube_api.go @@ -179,8 +179,6 @@ func flattenClusterRKEConfigServicesKubeAPI(in *managementClient.KubeAPIService) obj["image"] = in.Image } - obj["pod_security_policy"] = in.PodSecurityPolicy - if in.SecretsEncryptionConfig != nil { customConfig, err := flattenClusterRKEConfigServicesKubeAPISecretsEncryptionConfig(in.SecretsEncryptionConfig) if err != nil { @@ -404,10 +402,6 @@ func expandClusterRKEConfigServicesKubeAPI(p []interface{}) (*managementClient.K obj.Image = v } - if v, ok := in["pod_security_policy"].(bool); ok { - obj.PodSecurityPolicy = v - } - if v, ok := in["secrets_encryption_config"].([]interface{}); ok && len(v) > 0 { obj.SecretsEncryptionConfig = expandClusterRKEConfigServicesKubeAPISecretsEncryptionConfig(v) } diff --git a/rancher2/structure_cluster_rke_config_services_kube_api_test.go b/rancher2/structure_cluster_rke_config_services_kube_api_test.go index 5aa1deb9..94c410e3 100644 --- a/rancher2/structure_cluster_rke_config_services_kube_api_test.go +++ b/rancher2/structure_cluster_rke_config_services_kube_api_test.go @@ -129,7 +129,6 @@ func init() { ExtraBinds: []string{"bind_one", "bind_two"}, ExtraEnv: []string{"env_one", "env_two"}, Image: "image", - PodSecurityPolicy: true, SecretsEncryptionConfig: testClusterRKEConfigServicesKubeAPISecretsEncryptionConfigConf, ServiceClusterIPRange: "10.43.0.0/16", ServiceNodePortRange: "30000-32000", @@ -147,7 +146,6 @@ func init() { "extra_binds": []interface{}{"bind_one", "bind_two"}, "extra_env": []interface{}{"env_one", "env_two"}, "image": "image", - "pod_security_policy": true, "secrets_encryption_config": testClusterRKEConfigServicesKubeAPISecretsEncryptionConfigInterface, "service_cluster_ip_range": "10.43.0.0/16", "service_node_port_range": "30000-32000", diff --git a/rancher2/structure_cluster_template.go b/rancher2/structure_cluster_template.go index bf214314..c0764c95 100644 --- a/rancher2/structure_cluster_template.go +++ b/rancher2/structure_cluster_template.go @@ -60,10 +60,6 @@ func flattenClusterSpecBase(in *managementClient.ClusterSpecBase, p []interface{ obj["default_cluster_role_for_project_members"] = in.DefaultClusterRoleForProjectMembers } - if len(in.DefaultPodSecurityPolicyTemplateID) > 0 { - obj["default_pod_security_policy_template_id"] = in.DefaultPodSecurityPolicyTemplateID - } - if len(in.DefaultPodSecurityAdmissionConfigurationTemplateName) > 0 { obj["default_pod_security_admission_configuration_template_name"] = in.DefaultPodSecurityAdmissionConfigurationTemplateName } @@ -80,8 +76,6 @@ func flattenClusterSpecBase(in *managementClient.ClusterSpecBase, p []interface{ obj["docker_root_dir"] = in.DockerRootDir } - obj["enable_cluster_alerting"] = in.EnableClusterAlerting - obj["enable_cluster_monitoring"] = in.EnableClusterMonitoring obj["enable_network_policy"] = *in.EnableNetworkPolicy if in.RancherKubernetesEngineConfig != nil { @@ -296,10 +290,6 @@ func expandClusterSpecBase(p []interface{}) (*managementClient.ClusterSpecBase, obj.DefaultClusterRoleForProjectMembers = v } - if v, ok := in["default_pod_security_policy_template_id"].(string); ok && len(v) > 0 { - obj.DefaultPodSecurityPolicyTemplateID = v - } - if v, ok := in["default_pod_security_admission_configuration_template_name"].(string); ok && len(v) > 0 { obj.DefaultPodSecurityAdmissionConfigurationTemplateName = v } @@ -316,14 +306,6 @@ func expandClusterSpecBase(p []interface{}) (*managementClient.ClusterSpecBase, obj.DockerRootDir = v } - if v, ok := in["enable_cluster_alerting"].(bool); ok { - obj.EnableClusterAlerting = v - } - - if v, ok := in["enable_cluster_monitoring"].(bool); ok { - obj.EnableClusterMonitoring = v - } - if v, ok := in["enable_network_policy"].(bool); ok { obj.EnableNetworkPolicy = &v } diff --git a/rancher2/structure_cluster_template_test.go b/rancher2/structure_cluster_template_test.go index 13d10262..9cca45b1 100644 --- a/rancher2/structure_cluster_template_test.go +++ b/rancher2/structure_cluster_template_test.go @@ -103,28 +103,22 @@ func testClusterTemplate() { } testClusterTemplateRevisionsConfigConf = &managementClient.ClusterSpecBase{ DefaultClusterRoleForProjectMembers: "default_cluster_role_for_project_members", - DefaultPodSecurityPolicyTemplateID: "default_pod_security_policy_template_id", DefaultPodSecurityAdmissionConfigurationTemplateName: "default_pod_security_admission_configuration_template_name", - DesiredAgentImage: "desired_agent_image", - DesiredAuthImage: "desired_auth_image", - DockerRootDir: "docker_root_dir", - EnableClusterAlerting: true, - EnableClusterMonitoring: true, - EnableNetworkPolicy: newTrue(), - LocalClusterAuthEndpoint: testClusterTemplateRevisionsConfigAuthEndpointConf, - RancherKubernetesEngineConfig: testClusterTemplateRevisionsConfigRKEConf, - WindowsPreferedCluster: true, + DesiredAgentImage: "desired_agent_image", + DesiredAuthImage: "desired_auth_image", + DockerRootDir: "docker_root_dir", + EnableNetworkPolicy: newTrue(), + LocalClusterAuthEndpoint: testClusterTemplateRevisionsConfigAuthEndpointConf, + RancherKubernetesEngineConfig: testClusterTemplateRevisionsConfigRKEConf, + WindowsPreferedCluster: true, } testClusterTemplateRevisionsConfigInterface = []interface{}{ map[string]interface{}{ "cluster_auth_endpoint": testClusterTemplateRevisionsConfigAuthEndpointInterface, "default_cluster_role_for_project_members": "default_cluster_role_for_project_members", - "default_pod_security_policy_template_id": "default_pod_security_policy_template_id", "desired_agent_image": "desired_agent_image", "desired_auth_image": "desired_auth_image", "docker_root_dir": "docker_root_dir", - "enable_cluster_alerting": true, - "enable_cluster_monitoring": true, "enable_network_policy": true, "rke_config": testClusterTemplateRevisionsConfigRKEInterface, "windows_prefered_cluster": true, diff --git a/rancher2/structure_cluster_test.go b/rancher2/structure_cluster_test.go index 4e425f15..70080fef 100644 --- a/rancher2/structure_cluster_test.go +++ b/rancher2/structure_cluster_test.go @@ -265,9 +265,7 @@ func testCluster() { testClusterConfAKS.Description = "description" testClusterConfAKS.Driver = clusterDriverAKS testClusterConfAKS.AgentEnvVars = testClusterEnvVarsConf - testClusterConfAKS.DefaultPodSecurityPolicyTemplateID = "default_pod_security_policy_template_id" testClusterConfAKS.DefaultPodSecurityAdmissionConfigurationTemplateName = "default_pod_security_admission_configuration_template_name" - testClusterConfAKS.EnableClusterMonitoring = true testClusterConfAKS.EnableNetworkPolicy = newTrue() testClusterConfAKS.LocalClusterAuthEndpoint = testLocalClusterAuthEndpointConf testClusterInterfaceAKS = map[string]interface{}{ @@ -278,14 +276,12 @@ func testCluster() { "description": "description", "cluster_auth_endpoint": testLocalClusterAuthEndpointInterface, "cluster_registration_token": testClusterRegistrationTokenInterface, - "default_pod_security_policy_template_id": "default_pod_security_policy_template_id", "default_pod_security_admission_configuration_template_name": "default_pod_security_admission_configuration_template_name", - "enable_cluster_monitoring": true, - "enable_network_policy": true, - "kube_config": "kube_config", - "driver": clusterDriverAKS, - "aks_config": testClusterAKSConfigInterface, - "system_project_id": "system_project_id", + "enable_network_policy": true, + "kube_config": "kube_config", + "driver": clusterDriverAKS, + "aks_config": testClusterAKSConfigInterface, + "system_project_id": "system_project_id", } testClusterConfEKS = &Cluster{ AmazonElasticContainerServiceConfig: testClusterEKSConfigConf, @@ -294,9 +290,7 @@ func testCluster() { testClusterConfEKS.Description = "description" testClusterConfEKS.Driver = clusterDriverEKS testClusterConfEKS.AgentEnvVars = testClusterEnvVarsConf - testClusterConfEKS.DefaultPodSecurityPolicyTemplateID = "default_pod_security_policy_template_id" testClusterConfEKS.DefaultPodSecurityAdmissionConfigurationTemplateName = "default_pod_security_admission_configuration_template_name" - testClusterConfEKS.EnableClusterMonitoring = true testClusterConfEKS.EnableNetworkPolicy = newTrue() testClusterConfEKS.LocalClusterAuthEndpoint = testLocalClusterAuthEndpointConf testClusterInterfaceEKS = map[string]interface{}{ @@ -307,14 +301,12 @@ func testCluster() { "description": "description", "cluster_auth_endpoint": testLocalClusterAuthEndpointInterface, "cluster_registration_token": testClusterRegistrationTokenInterface, - "default_pod_security_policy_template_id": "default_pod_security_policy_template_id", "default_pod_security_admission_configuration_template_name": "default_pod_security_admission_configuration_template_name", - "enable_cluster_monitoring": true, - "enable_network_policy": true, - "kube_config": "kube_config", - "driver": clusterDriverEKS, - "eks_config": testClusterEKSConfigInterface, - "system_project_id": "system_project_id", + "enable_network_policy": true, + "kube_config": "kube_config", + "driver": clusterDriverEKS, + "eks_config": testClusterEKSConfigInterface, + "system_project_id": "system_project_id", } testClusterConfEKSV2 = &Cluster{} testClusterConfEKSV2.EKSConfig = testClusterEKSConfigV2Conf @@ -324,29 +316,25 @@ func testCluster() { testClusterConfEKSV2.AgentEnvVars = testClusterEnvVarsConf testClusterConfEKSV2.ClusterAgentDeploymentCustomization = testClusterAgentDeploymentCustomizationConf testClusterConfEKSV2.FleetAgentDeploymentCustomization = testClusterAgentDeploymentCustomizationConf - testClusterConfEKSV2.DefaultPodSecurityPolicyTemplateID = "default_pod_security_policy_template_id" testClusterConfEKSV2.DefaultPodSecurityAdmissionConfigurationTemplateName = "default_pod_security_admission_configuration_template_name" - testClusterConfEKSV2.EnableClusterMonitoring = true testClusterConfEKSV2.EnableNetworkPolicy = newTrue() testClusterConfEKSV2.LocalClusterAuthEndpoint = testLocalClusterAuthEndpointConf testClusterInterfaceEKSV2 = map[string]interface{}{ - "id": "id", - "name": "test", - "agent_env_vars": testClusterEnvVarsInterface, - "cluster_agent_deployment_customization": testClusterAgentDeploymentCustomizationInterface, - "fleet_agent_deployment_customization": testClusterAgentDeploymentCustomizationInterface, - "default_project_id": "default_project_id", - "description": "description", - "cluster_auth_endpoint": testLocalClusterAuthEndpointInterface, - "cluster_registration_token": testClusterRegistrationTokenInterface, - "default_pod_security_policy_template_id": "default_pod_security_policy_template_id", + "id": "id", + "name": "test", + "agent_env_vars": testClusterEnvVarsInterface, + "cluster_agent_deployment_customization": testClusterAgentDeploymentCustomizationInterface, + "fleet_agent_deployment_customization": testClusterAgentDeploymentCustomizationInterface, + "default_project_id": "default_project_id", + "description": "description", + "cluster_auth_endpoint": testLocalClusterAuthEndpointInterface, + "cluster_registration_token": testClusterRegistrationTokenInterface, "default_pod_security_admission_configuration_template_name": "default_pod_security_admission_configuration_template_name", - "enable_cluster_monitoring": true, - "enable_network_policy": true, - "kube_config": "kube_config", - "driver": clusterDriverEKSV2, - "eks_config_v2": testClusterEKSConfigV2Interface, - "system_project_id": "system_project_id", + "enable_network_policy": true, + "kube_config": "kube_config", + "driver": clusterDriverEKSV2, + "eks_config_v2": testClusterEKSConfigV2Interface, + "system_project_id": "system_project_id", } testClusterConfGKE = &Cluster{ GoogleKubernetesEngineConfig: testClusterGKEConfigConf, @@ -355,9 +343,7 @@ func testCluster() { testClusterConfGKE.Description = "description" testClusterConfGKE.Driver = clusterDriverGKE testClusterConfGKE.AgentEnvVars = testClusterEnvVarsConf - testClusterConfGKE.DefaultPodSecurityPolicyTemplateID = "default_pod_security_policy_template_id" testClusterConfGKE.DefaultPodSecurityAdmissionConfigurationTemplateName = "default_pod_security_admission_configuration_template_name" - testClusterConfGKE.EnableClusterMonitoring = true testClusterConfGKE.EnableNetworkPolicy = newTrue() testClusterConfGKE.LocalClusterAuthEndpoint = testLocalClusterAuthEndpointConf testClusterInterfaceGKE = map[string]interface{}{ @@ -368,14 +354,12 @@ func testCluster() { "description": "description", "cluster_auth_endpoint": testLocalClusterAuthEndpointInterface, "cluster_registration_token": testClusterRegistrationTokenInterface, - "default_pod_security_policy_template_id": "default_pod_security_policy_template_id", "default_pod_security_admission_configuration_template_name": "default_pod_security_admission_configuration_template_name", - "enable_cluster_monitoring": true, - "enable_network_policy": true, - "kube_config": "kube_config", - "driver": clusterDriverGKE, - "gke_config": testClusterGKEConfigInterface, - "system_project_id": "system_project_id", + "enable_network_policy": true, + "kube_config": "kube_config", + "driver": clusterDriverGKE, + "gke_config": testClusterGKEConfigInterface, + "system_project_id": "system_project_id", } testClusterConfK3S = &Cluster{} testClusterConfK3S.Name = "test" @@ -383,9 +367,7 @@ func testCluster() { testClusterConfK3S.K3sConfig = testClusterK3SConfigConf testClusterConfK3S.Driver = clusterDriverK3S testClusterConfK3S.AgentEnvVars = testClusterEnvVarsConf - testClusterConfK3S.DefaultPodSecurityPolicyTemplateID = "default_pod_security_policy_template_id" testClusterConfK3S.DefaultPodSecurityAdmissionConfigurationTemplateName = "default_pod_security_admission_configuration_template_name" - testClusterConfK3S.EnableClusterMonitoring = true testClusterConfK3S.EnableNetworkPolicy = newTrue() testClusterConfK3S.LocalClusterAuthEndpoint = testLocalClusterAuthEndpointConf testClusterInterfaceK3S = map[string]interface{}{ @@ -396,15 +378,13 @@ func testCluster() { "description": "description", "cluster_auth_endpoint": testLocalClusterAuthEndpointInterface, "cluster_registration_token": testClusterRegistrationTokenInterface, - "default_pod_security_policy_template_id": "default_pod_security_policy_template_id", "default_pod_security_admission_configuration_template_name": "default_pod_security_admission_configuration_template_name", - "enable_cluster_monitoring": true, - "enable_network_policy": true, - "kube_config": "kube_config", - "driver": clusterDriverK3S, - "k3s_config": testClusterK3SConfigInterface, - "system_project_id": "system_project_id", - "windows_prefered_cluster": false, + "enable_network_policy": true, + "kube_config": "kube_config", + "driver": clusterDriverK3S, + "k3s_config": testClusterK3SConfigInterface, + "system_project_id": "system_project_id", + "windows_prefered_cluster": false, } testClusterConfGKEV2 = &Cluster{} testClusterConfGKEV2.GKEConfig = testClusterGKEConfigV2Conf @@ -412,9 +392,7 @@ func testCluster() { testClusterConfGKEV2.Description = "description" testClusterConfGKEV2.Driver = clusterDriverGKEV2 testClusterConfGKEV2.AgentEnvVars = testClusterEnvVarsConf - testClusterConfGKEV2.DefaultPodSecurityPolicyTemplateID = "default_pod_security_policy_template_id" testClusterConfGKEV2.DefaultPodSecurityAdmissionConfigurationTemplateName = "default_pod_security_admission_configuration_template_name" - testClusterConfGKEV2.EnableClusterMonitoring = true testClusterConfGKEV2.EnableNetworkPolicy = newTrue() testClusterConfGKEV2.LocalClusterAuthEndpoint = testLocalClusterAuthEndpointConf testClusterInterfaceGKEV2 = map[string]interface{}{ @@ -425,14 +403,12 @@ func testCluster() { "description": "description", "cluster_auth_endpoint": testLocalClusterAuthEndpointInterface, "cluster_registration_token": testClusterRegistrationTokenInterface, - "default_pod_security_policy_template_id": "default_pod_security_policy_template_id", "default_pod_security_admission_configuration_template_name": "default_pod_security_admission_configuration_template_name", - "enable_cluster_monitoring": true, - "enable_network_policy": true, - "kube_config": "kube_config", - "driver": clusterDriverGKEV2, - "gke_config_v2": testClusterGKEConfigV2Interface, - "system_project_id": "system_project_id", + "enable_network_policy": true, + "kube_config": "kube_config", + "driver": clusterDriverGKEV2, + "gke_config_v2": testClusterGKEConfigV2Interface, + "system_project_id": "system_project_id", } testClusterConfOKE = &Cluster{ OracleKubernetesEngineConfig: testClusterOKEConfigConf, @@ -441,9 +417,7 @@ func testCluster() { testClusterConfOKE.Description = "description" testClusterConfOKE.Driver = clusterOKEKind testClusterConfOKE.AgentEnvVars = testClusterEnvVarsConf - testClusterConfOKE.DefaultPodSecurityPolicyTemplateID = "default_pod_security_policy_template_id" testClusterConfOKE.DefaultPodSecurityAdmissionConfigurationTemplateName = "default_pod_security_admission_configuration_template_name" - testClusterConfOKE.EnableClusterMonitoring = true testClusterConfOKE.EnableNetworkPolicy = newTrue() testClusterConfOKE.LocalClusterAuthEndpoint = testLocalClusterAuthEndpointConf testClusterInterfaceOKE = map[string]interface{}{ @@ -454,14 +428,12 @@ func testCluster() { "description": "description", "cluster_auth_endpoint": testLocalClusterAuthEndpointInterface, "cluster_registration_token": testClusterRegistrationTokenInterface, - "default_pod_security_policy_template_id": "default_pod_security_policy_template_id", "default_pod_security_admission_configuration_template_name": "default_pod_security_admission_configuration_template_name", - "enable_cluster_monitoring": true, - "enable_network_policy": true, - "kube_config": "kube_config", - "driver": clusterOKEKind, - "oke_config": testClusterOKEConfigInterface, - "system_project_id": "system_project_id", + "enable_network_policy": true, + "kube_config": "kube_config", + "driver": clusterOKEKind, + "oke_config": testClusterOKEConfigInterface, + "system_project_id": "system_project_id", } testClusterConfRKE = &Cluster{} testClusterConfRKE.Name = "test" @@ -471,32 +443,28 @@ func testCluster() { testClusterConfRKE.AgentEnvVars = testClusterEnvVarsConf testClusterConfRKE.ClusterAgentDeploymentCustomization = testClusterAgentDeploymentCustomizationConf testClusterConfRKE.FleetAgentDeploymentCustomization = testClusterAgentDeploymentCustomizationConf - testClusterConfRKE.DefaultPodSecurityPolicyTemplateID = "default_pod_security_policy_template_id" testClusterConfRKE.DefaultPodSecurityAdmissionConfigurationTemplateName = "default_pod_security_admission_configuration_template_name" testClusterConfRKE.FleetWorkspaceName = "fleet-test" - testClusterConfRKE.EnableClusterMonitoring = true testClusterConfRKE.EnableNetworkPolicy = newTrue() testClusterConfRKE.LocalClusterAuthEndpoint = testLocalClusterAuthEndpointConf testClusterInterfaceRKE = map[string]interface{}{ - "id": "id", - "name": "test", - "agent_env_vars": testClusterEnvVarsInterface, - "cluster_agent_deployment_customization": testClusterAgentDeploymentCustomizationInterface, - "fleet_agent_deployment_customization": testClusterAgentDeploymentCustomizationInterface, - "default_project_id": "default_project_id", - "description": "description", - "cluster_auth_endpoint": testLocalClusterAuthEndpointInterface, - "cluster_registration_token": testClusterRegistrationTokenInterface, - "default_pod_security_policy_template_id": "default_pod_security_policy_template_id", + "id": "id", + "name": "test", + "agent_env_vars": testClusterEnvVarsInterface, + "cluster_agent_deployment_customization": testClusterAgentDeploymentCustomizationInterface, + "fleet_agent_deployment_customization": testClusterAgentDeploymentCustomizationInterface, + "default_project_id": "default_project_id", + "description": "description", + "cluster_auth_endpoint": testLocalClusterAuthEndpointInterface, + "cluster_registration_token": testClusterRegistrationTokenInterface, "default_pod_security_admission_configuration_template_name": "default_pod_security_admission_configuration_template_name", - "enable_cluster_monitoring": true, - "enable_network_policy": true, - "fleet_workspace_name": "fleet-test", - "kube_config": "kube_config", - "driver": clusterDriverRKE, - "rke_config": testClusterRKEConfigInterface, - "system_project_id": "system_project_id", - "windows_prefered_cluster": false, + "enable_network_policy": true, + "fleet_workspace_name": "fleet-test", + "kube_config": "kube_config", + "driver": clusterDriverRKE, + "rke_config": testClusterRKEConfigInterface, + "system_project_id": "system_project_id", + "windows_prefered_cluster": false, } testClusterConfRKE2 = &Cluster{} testClusterConfRKE2.Name = "test" @@ -506,30 +474,26 @@ func testCluster() { testClusterConfRKE2.AgentEnvVars = testClusterEnvVarsConf testClusterConfRKE2.ClusterAgentDeploymentCustomization = testClusterAgentDeploymentCustomizationConf testClusterConfRKE2.FleetAgentDeploymentCustomization = testClusterAgentDeploymentCustomizationConf - testClusterConfRKE2.DefaultPodSecurityPolicyTemplateID = "default_pod_security_policy_template_id" testClusterConfRKE2.DefaultPodSecurityAdmissionConfigurationTemplateName = "default_pod_security_admission_configuration_template_name" - testClusterConfRKE2.EnableClusterMonitoring = true testClusterConfRKE2.EnableNetworkPolicy = newTrue() testClusterConfRKE2.LocalClusterAuthEndpoint = testLocalClusterAuthEndpointConf testClusterInterfaceRKE2 = map[string]interface{}{ - "id": "id", - "name": "test", - "agent_env_vars": testClusterEnvVarsInterface, - "cluster_agent_deployment_customization": testClusterAgentDeploymentCustomizationInterface, - "fleet_agent_deployment_customization": testClusterAgentDeploymentCustomizationInterface, - "default_project_id": "default_project_id", - "description": "description", - "cluster_auth_endpoint": testLocalClusterAuthEndpointInterface, - "cluster_registration_token": testClusterRegistrationTokenInterface, - "default_pod_security_policy_template_id": "default_pod_security_policy_template_id", + "id": "id", + "name": "test", + "agent_env_vars": testClusterEnvVarsInterface, + "cluster_agent_deployment_customization": testClusterAgentDeploymentCustomizationInterface, + "fleet_agent_deployment_customization": testClusterAgentDeploymentCustomizationInterface, + "default_project_id": "default_project_id", + "description": "description", + "cluster_auth_endpoint": testLocalClusterAuthEndpointInterface, + "cluster_registration_token": testClusterRegistrationTokenInterface, "default_pod_security_admission_configuration_template_name": "default_pod_security_admission_configuration_template_name", - "enable_cluster_monitoring": true, - "enable_network_policy": true, - "kube_config": "kube_config", - "driver": clusterDriverRKE2, - "rke2_config": testClusterRKE2ConfigInterface, - "system_project_id": "system_project_id", - "windows_prefered_cluster": false, + "enable_network_policy": true, + "kube_config": "kube_config", + "driver": clusterDriverRKE2, + "rke2_config": testClusterRKE2ConfigInterface, + "system_project_id": "system_project_id", + "windows_prefered_cluster": false, } testClusterConfTemplate = &Cluster{} testClusterConfTemplate.Name = "test" @@ -540,10 +504,7 @@ func testCluster() { testClusterConfTemplate.ClusterTemplateRevisionID = "cluster_template_revision_id" testClusterConfTemplate.Driver = clusterDriverRKE testClusterConfTemplate.AgentEnvVars = testClusterEnvVarsConf - testClusterConfTemplate.DefaultPodSecurityPolicyTemplateID = "default_pod_security_policy_template_id" testClusterConfTemplate.DefaultPodSecurityAdmissionConfigurationTemplateName = "default_pod_security_admission_configuration_template_name" - testClusterConfTemplate.EnableClusterAlerting = true - testClusterConfTemplate.EnableClusterMonitoring = true testClusterConfTemplate.EnableNetworkPolicy = newTrue() testClusterConfTemplate.LocalClusterAuthEndpoint = testLocalClusterAuthEndpointConf testClusterInterfaceTemplate = map[string]interface{}{ @@ -554,20 +515,17 @@ func testCluster() { "description": "description", "cluster_auth_endpoint": testLocalClusterAuthEndpointInterface, "cluster_registration_token": testClusterRegistrationTokenInterface, - "default_pod_security_policy_template_id": "default_pod_security_policy_template_id", "default_pod_security_admission_configuration_template_name": "default_pod_security_admission_configuration_template_name", - "enable_cluster_alerting": true, - "enable_cluster_monitoring": true, - "enable_network_policy": true, - "kube_config": "kube_config", - "driver": clusterDriverRKE, - "cluster_template_answers": testClusterAnswersInterface, - "cluster_template_id": "cluster_template_id", - "cluster_template_questions": testClusterQuestionsInterface, - "cluster_template_revision_id": "cluster_template_revision_id", - "rke_config": []interface{}{}, - "system_project_id": "system_project_id", - "windows_prefered_cluster": false, + "enable_network_policy": true, + "kube_config": "kube_config", + "driver": clusterDriverRKE, + "cluster_template_answers": testClusterAnswersInterface, + "cluster_template_id": "cluster_template_id", + "cluster_template_questions": testClusterQuestionsInterface, + "cluster_template_revision_id": "cluster_template_revision_id", + "rke_config": []interface{}{}, + "system_project_id": "system_project_id", + "windows_prefered_cluster": false, } } @@ -659,7 +617,7 @@ func TestFlattenCluster(t *testing.T) { for _, tc := range cases { output := schema.TestResourceDataRaw(t, clusterFields(), map[string]interface{}{}) tc.InputToken.ID = "id" - err := flattenCluster(output, tc.Input, tc.InputToken, tc.InputKube, tc.ExpectedOutput["default_project_id"].(string), tc.ExpectedOutput["system_project_id"].(string), nil) + err := flattenCluster(output, tc.Input, tc.InputToken, tc.InputKube, tc.ExpectedOutput["default_project_id"].(string), tc.ExpectedOutput["system_project_id"].(string)) if err != nil { assert.FailNow(t, "[ERROR] on flattener: %#v", err) } @@ -808,7 +766,7 @@ func TestFlattenClusterWithPreservedClusterTemplateAnswers(t *testing.T) { }, }) tc.InputToken.ID = "id" - err := flattenCluster(output, tc.Input, tc.InputToken, tc.InputKube, tc.ExpectedOutput["default_project_id"].(string), tc.ExpectedOutput["system_project_id"].(string), nil) + err := flattenCluster(output, tc.Input, tc.InputToken, tc.InputKube, tc.ExpectedOutput["default_project_id"].(string), tc.ExpectedOutput["system_project_id"].(string)) if err != nil { assert.FailNow(t, "[ERROR] on flattener: %#v", err) } diff --git a/rancher2/structure_cluster_v2.go b/rancher2/structure_cluster_v2.go index 41cc36c0..3444e33d 100644 --- a/rancher2/structure_cluster_v2.go +++ b/rancher2/structure_cluster_v2.go @@ -65,9 +65,6 @@ func flattenClusterV2(d *schema.ResourceData, in *ClusterV2) error { if in.Spec.FleetAgentDeploymentCustomization != nil { d.Set("fleet_agent_deployment_customization", flattenAgentDeploymentCustomizationV2(in.Spec.FleetAgentDeploymentCustomization)) } - 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) } @@ -142,9 +139,6 @@ func expandClusterV2(in *schema.ResourceData) (*ClusterV2, error) { if v, ok := in.Get("cloud_credential_secret_name").(string); ok && len(v) > 0 { obj.Spec.CloudCredentialSecretName = v } - 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 } diff --git a/rancher2/structure_cluster_v2_test.go b/rancher2/structure_cluster_v2_test.go index 72974241..3988ce42 100644 --- a/rancher2/structure_cluster_v2_test.go +++ b/rancher2/structure_cluster_v2_test.go @@ -61,7 +61,6 @@ func init() { testClusterV2Conf.Spec.RKEConfig = testClusterV2RKEConfigConf 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() @@ -153,16 +152,15 @@ func init() { } testClusterV2Interface = map[string]interface{}{ - "name": "name", - "fleet_namespace": "fleet_namespace", - "kubernetes_version": "kubernetes_version", - "local_auth_endpoint": testClusterV2LocalAuthEndpointInterface, - "rke_config": testClusterV2RKEConfigInterface, - "agent_env_vars": testClusterV2EnvVarInterface, - "cluster_agent_deployment_customization": testClusterV2AgentCustomizationInterface, - "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", + "name": "name", + "fleet_namespace": "fleet_namespace", + "kubernetes_version": "kubernetes_version", + "local_auth_endpoint": testClusterV2LocalAuthEndpointInterface, + "rke_config": testClusterV2RKEConfigInterface, + "agent_env_vars": testClusterV2EnvVarInterface, + "cluster_agent_deployment_customization": testClusterV2AgentCustomizationInterface, + "fleet_agent_deployment_customization": testClusterV2AgentCustomizationInterface, + "cloud_credential_secret_name": "cloud_credential_secret_name", "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, diff --git a/rancher2/structure_monitoring_input.go b/rancher2/structure_monitoring_input.go deleted file mode 100644 index 04866d66..00000000 --- a/rancher2/structure_monitoring_input.go +++ /dev/null @@ -1,53 +0,0 @@ -package rancher2 - -import ( - "reflect" - - managementClient "github.com/rancher/rancher/pkg/client/generated/management/v3" -) - -const ( - monitoringInputAnnotation = "field.cattle.io/overwriteAppAnswers" - monitoringActionDisable = "disableMonitoring" - monitoringActionEdit = "editMonitoring" - monitoringActionEnable = "enableMonitoring" -) - -// Flatteners - -func flattenMonitoringInput(in *managementClient.MonitoringInput) []interface{} { - if in == nil || reflect.DeepEqual(in, &managementClient.MonitoringInput{}) { - return []interface{}{} - } - obj := map[string]interface{}{} - - if len(in.Answers) > 0 { - obj["answers"] = toMapInterface(in.Answers) - } - - if len(in.Version) > 0 { - obj["version"] = in.Version - } - - return []interface{}{obj} -} - -// Expanders - -func expandMonitoringInput(p []interface{}) *managementClient.MonitoringInput { - if len(p) == 0 || p[0] == nil { - return nil - } - obj := &managementClient.MonitoringInput{} - in := p[0].(map[string]interface{}) - - if v, ok := in["answers"].(map[string]interface{}); ok && len(v) > 0 { - obj.Answers = toMapString(v) - } - - if v, ok := in["version"].(string); ok && len(v) > 0 { - obj.Version = v - } - - return obj -} diff --git a/rancher2/structure_monitoring_input_test.go b/rancher2/structure_monitoring_input_test.go deleted file mode 100644 index 8f118a14..00000000 --- a/rancher2/structure_monitoring_input_test.go +++ /dev/null @@ -1,64 +0,0 @@ -package rancher2 - -import ( - "testing" - - managementClient "github.com/rancher/rancher/pkg/client/generated/management/v3" - "github.com/stretchr/testify/assert" -) - -var ( - testMonitoringInputConf *managementClient.MonitoringInput - testMonitoringInputInterface []interface{} -) - -func init() { - testMonitoringInputConf = &managementClient.MonitoringInput{ - Answers: map[string]string{ - "answer_one": "one", - "answer_two": "two", - }, - } - testMonitoringInputInterface = []interface{}{ - map[string]interface{}{ - "answers": map[string]interface{}{ - "answer_one": "one", - "answer_two": "two", - }, - }, - } -} - -func TestFlattenMonitoringInput(t *testing.T) { - - cases := []struct { - Input *managementClient.MonitoringInput - ExpectedOutput []interface{} - }{ - { - testMonitoringInputConf, - testMonitoringInputInterface, - }, - } - for _, tc := range cases { - output := flattenMonitoringInput(tc.Input) - assert.Equal(t, tc.ExpectedOutput, output, "Unexpected output from flattener.") - } -} - -func TestExpandMonitoringInput(t *testing.T) { - - cases := []struct { - Input []interface{} - ExpectedOutput *managementClient.MonitoringInput - }{ - { - testMonitoringInputInterface, - testMonitoringInputConf, - }, - } - for _, tc := range cases { - output := expandMonitoringInput(tc.Input) - assert.Equal(t, tc.ExpectedOutput, output, "Unexpected output from expander.") - } -} diff --git a/rancher2/structure_notifier.go b/rancher2/structure_notifier.go deleted file mode 100644 index 3d8ce77e..00000000 --- a/rancher2/structure_notifier.go +++ /dev/null @@ -1,164 +0,0 @@ -package rancher2 - -import ( - "fmt" - - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - managementClient "github.com/rancher/rancher/pkg/client/generated/management/v3" -) - -// Flatteners - -func flattenNotifier(d *schema.ResourceData, in *managementClient.Notifier) error { - if in == nil { - return nil - } - - d.SetId(in.ID) - d.Set("cluster_id", in.ClusterID) - d.Set("name", in.Name) - - if len(in.Description) > 0 { - d.Set("description", in.Description) - } - - d.Set("send_resolved", in.SendResolved) - - if in.DingtalkConfig != nil { - v, ok := d.Get("dingtalk_config").([]interface{}) - if !ok { - v = []interface{}{} - } - - d.Set("dingtalk_config", flattenNotifierDingtalkConfig(in.DingtalkConfig, v)) - } - - if in.MSTeamsConfig != nil { - v, ok := d.Get("msteams_config").([]interface{}) - if !ok { - v = []interface{}{} - } - - d.Set("msteams_config", flattenNotifierMSTeamsConfig(in.MSTeamsConfig, v)) - } - - if in.PagerdutyConfig != nil { - v, ok := d.Get("pagerduty_config").([]interface{}) - if !ok { - v = []interface{}{} - } - - d.Set("pagerduty_config", flattenNotifierPagerdutyConfig(in.PagerdutyConfig, v)) - } - - if in.SlackConfig != nil { - v, ok := d.Get("slack_config").([]interface{}) - if !ok { - v = []interface{}{} - } - - d.Set("slack_config", flattenNotifierSlackConfig(in.SlackConfig, v)) - } - - if in.SMTPConfig != nil { - v, ok := d.Get("smtp_config").([]interface{}) - if !ok { - v = []interface{}{} - } - - d.Set("smtp_config", flattenNotifierSMTPConfig(in.SMTPConfig, v)) - } - - if in.WebhookConfig != nil { - v, ok := d.Get("webhook_config").([]interface{}) - if !ok { - v = []interface{}{} - } - - d.Set("webhook_config", flattenNotifierWebhookConfig(in.WebhookConfig, v)) - } - - if in.WechatConfig != nil { - v, ok := d.Get("wechat_config").([]interface{}) - if !ok { - v = []interface{}{} - } - - d.Set("wechat_config", flattenNotifierWechatConfig(in.WechatConfig, v)) - } - - err := d.Set("annotations", toMapInterface(in.Annotations)) - if err != nil { - return err - } - - err = d.Set("labels", toMapInterface(in.Labels)) - if err != nil { - return err - } - - return nil - -} - -// Expanders - -func expandNotifier(in *schema.ResourceData) (*managementClient.Notifier, error) { - obj := &managementClient.Notifier{} - if in == nil { - return nil, fmt.Errorf("[ERROR] Expanding notifier: Schema Resource data is nil") - } - - if v := in.Id(); len(v) > 0 { - obj.ID = v - } - - obj.ClusterID = in.Get("cluster_id").(string) - obj.Name = in.Get("name").(string) - - if v, ok := in.Get("description").(string); ok && len(v) > 0 { - obj.Description = v - } - - if v, ok := in.Get("send_resolved").(bool); ok { - obj.SendResolved = v - } - - if v, ok := in.Get("dingtalk_config").([]interface{}); ok && len(v) > 0 { - obj.DingtalkConfig = expandNotifierDingtalkConfig(v) - } - - if v, ok := in.Get("msteams_config").([]interface{}); ok && len(v) > 0 { - obj.MSTeamsConfig = expandNotifierMSTeamsConfig(v) - } - - if v, ok := in.Get("pagerduty_config").([]interface{}); ok && len(v) > 0 { - obj.PagerdutyConfig = expandNotifierPagerdutyConfig(v) - } - - if v, ok := in.Get("slack_config").([]interface{}); ok && len(v) > 0 { - obj.SlackConfig = expandNotifierSlackConfig(v) - } - - if v, ok := in.Get("smtp_config").([]interface{}); ok && len(v) > 0 { - obj.SMTPConfig = expandNotifierSMTPConfig(v) - } - - if v, ok := in.Get("webhook_config").([]interface{}); ok && len(v) > 0 { - obj.WebhookConfig = expandNotifierWebhookConfig(v) - } - - if v, ok := in.Get("wechat_config").([]interface{}); ok && len(v) > 0 { - obj.WechatConfig = expandNotifierWechatConfig(v) - } - - if v, ok := in.Get("annotations").(map[string]interface{}); ok && len(v) > 0 { - obj.Annotations = toMapString(v) - } - - if v, ok := in.Get("labels").(map[string]interface{}); ok && len(v) > 0 { - obj.Labels = toMapString(v) - } - - return obj, nil -} diff --git a/rancher2/structure_notifier_dingtalk_config.go b/rancher2/structure_notifier_dingtalk_config.go deleted file mode 100644 index 673b2e4d..00000000 --- a/rancher2/structure_notifier_dingtalk_config.go +++ /dev/null @@ -1,56 +0,0 @@ -package rancher2 - -import ( - managementClient "github.com/rancher/rancher/pkg/client/generated/management/v3" -) - -// Flatteners - -func flattenNotifierDingtalkConfig(in *managementClient.DingtalkConfig, p []interface{}) []interface{} { - var obj map[string]interface{} - if len(p) == 0 || p[0] == nil { - obj = make(map[string]interface{}) - } else { - obj = p[0].(map[string]interface{}) - } - - if in == nil { - return []interface{}{} - } - - obj["url"] = in.URL - - if len(in.ProxyURL) > 0 { - obj["proxy_url"] = in.ProxyURL - } - - if len(in.Secret) > 0 { - obj["secret"] = in.Secret - } - - return []interface{}{obj} - -} - -// Expanders - -func expandNotifierDingtalkConfig(p []interface{}) *managementClient.DingtalkConfig { - obj := &managementClient.DingtalkConfig{} - - if len(p) == 0 || p[0] == nil { - return obj - } - in := p[0].(map[string]interface{}) - - obj.URL = in["url"].(string) - - if v, ok := in["proxy_url"].(string); ok && len(v) > 0 { - obj.ProxyURL = v - } - - if v, ok := in["secret"].(string); ok && len(v) > 0 { - obj.Secret = v - } - - return obj -} diff --git a/rancher2/structure_notifier_dingtalk_config_test.go b/rancher2/structure_notifier_dingtalk_config_test.go deleted file mode 100644 index 11a5c8b2..00000000 --- a/rancher2/structure_notifier_dingtalk_config_test.go +++ /dev/null @@ -1,63 +0,0 @@ -package rancher2 - -import ( - "testing" - - managementClient "github.com/rancher/rancher/pkg/client/generated/management/v3" - "github.com/stretchr/testify/assert" -) - -var ( - testNotifierDingtalkConfigConf *managementClient.DingtalkConfig - testNotifierDingtalkConfigInterface []interface{} -) - -func init() { - testNotifierDingtalkConfigConf = &managementClient.DingtalkConfig{ - URL: "url", - ProxyURL: "proxy_url", - Secret: "secret", - } - testNotifierDingtalkConfigInterface = []interface{}{ - map[string]interface{}{ - "url": "url", - "proxy_url": "proxy_url", - "secret": "secret", - }, - } -} - -func TestFlattenNotifierDingtalkConfig(t *testing.T) { - - cases := []struct { - Input *managementClient.DingtalkConfig - ExpectedOutput []interface{} - }{ - { - testNotifierDingtalkConfigConf, - testNotifierDingtalkConfigInterface, - }, - } - for _, tc := range cases { - output := flattenNotifierDingtalkConfig(tc.Input, tc.ExpectedOutput) - assert.Equal(t, tc.ExpectedOutput, output, "Unexpected output from flattener.") - } -} - -func TestExpandNotifierDingtalkConfig(t *testing.T) { - - cases := []struct { - Input []interface{} - ExpectedOutput *managementClient.DingtalkConfig - }{ - { - testNotifierDingtalkConfigInterface, - testNotifierDingtalkConfigConf, - }, - } - - for _, tc := range cases { - output := expandNotifierDingtalkConfig(tc.Input) - assert.Equal(t, tc.ExpectedOutput, output, "Unexpected output from expander.") - } -} diff --git a/rancher2/structure_notifier_msteams_config.go b/rancher2/structure_notifier_msteams_config.go deleted file mode 100644 index 97b2a6c7..00000000 --- a/rancher2/structure_notifier_msteams_config.go +++ /dev/null @@ -1,48 +0,0 @@ -package rancher2 - -import ( - managementClient "github.com/rancher/rancher/pkg/client/generated/management/v3" -) - -// Flatteners - -func flattenNotifierMSTeamsConfig(in *managementClient.MSTeamsConfig, p []interface{}) []interface{} { - var obj map[string]interface{} - if len(p) == 0 || p[0] == nil { - obj = make(map[string]interface{}) - } else { - obj = p[0].(map[string]interface{}) - } - - if in == nil { - return []interface{}{} - } - - obj["url"] = in.URL - - if len(in.ProxyURL) > 0 { - obj["proxy_url"] = in.ProxyURL - } - - return []interface{}{obj} - -} - -// Expanders - -func expandNotifierMSTeamsConfig(p []interface{}) *managementClient.MSTeamsConfig { - obj := &managementClient.MSTeamsConfig{} - - if len(p) == 0 || p[0] == nil { - return obj - } - in := p[0].(map[string]interface{}) - - obj.URL = in["url"].(string) - - if v, ok := in["proxy_url"].(string); ok && len(v) > 0 { - obj.ProxyURL = v - } - - return obj -} diff --git a/rancher2/structure_notifier_msteams_config_test.go b/rancher2/structure_notifier_msteams_config_test.go deleted file mode 100644 index 9f6d6e9f..00000000 --- a/rancher2/structure_notifier_msteams_config_test.go +++ /dev/null @@ -1,62 +0,0 @@ -package rancher2 - -import ( - "testing" - - managementClient "github.com/rancher/rancher/pkg/client/generated/management/v3" - "github.com/stretchr/testify/assert" -) - -var ( - testNotifierMSTeamsConfigConf *managementClient.MSTeamsConfig - testNotifierMSTeamsConfigInterface []interface{} -) - -func init() { - testNotifierMSTeamsConfigConf = &managementClient.MSTeamsConfig{ - URL: "url", - ProxyURL: "proxy_url", - } - testNotifierMSTeamsConfigInterface = []interface{}{ - map[string]interface{}{ - "url": "url", - "proxy_url": "proxy_url", - }, - } -} - -func TestFlattenNotifierMSTeamsConfig(t *testing.T) { - - cases := []struct { - Input *managementClient.MSTeamsConfig - ExpectedOutput []interface{} - }{ - { - testNotifierMSTeamsConfigConf, - testNotifierMSTeamsConfigInterface, - }, - } - - for _, tc := range cases { - output := flattenNotifierMSTeamsConfig(tc.Input, tc.ExpectedOutput) - assert.Equal(t, tc.ExpectedOutput, output, "Unexpected output from flattener.") - } -} - -func TestExpandNotifierMSTeamsConfig(t *testing.T) { - - cases := []struct { - Input []interface{} - ExpectedOutput *managementClient.MSTeamsConfig - }{ - { - testNotifierMSTeamsConfigInterface, - testNotifierMSTeamsConfigConf, - }, - } - - for _, tc := range cases { - output := expandNotifierMSTeamsConfig(tc.Input) - assert.Equal(t, tc.ExpectedOutput, output, "Unexpected output from expander.") - } -} diff --git a/rancher2/structure_notifier_pagerduty_config.go b/rancher2/structure_notifier_pagerduty_config.go deleted file mode 100644 index 78a62622..00000000 --- a/rancher2/structure_notifier_pagerduty_config.go +++ /dev/null @@ -1,48 +0,0 @@ -package rancher2 - -import ( - managementClient "github.com/rancher/rancher/pkg/client/generated/management/v3" -) - -// Flatteners - -func flattenNotifierPagerdutyConfig(in *managementClient.PagerdutyConfig, p []interface{}) []interface{} { - var obj map[string]interface{} - if len(p) == 0 || p[0] == nil { - obj = make(map[string]interface{}) - } else { - obj = p[0].(map[string]interface{}) - } - - if in == nil { - return []interface{}{} - } - - obj["service_key"] = in.ServiceKey - - if len(in.ProxyURL) > 0 { - obj["proxy_url"] = in.ProxyURL - } - - return []interface{}{obj} - -} - -// Expanders - -func expandNotifierPagerdutyConfig(p []interface{}) *managementClient.PagerdutyConfig { - obj := &managementClient.PagerdutyConfig{} - - if len(p) == 0 || p[0] == nil { - return obj - } - in := p[0].(map[string]interface{}) - - obj.ServiceKey = in["service_key"].(string) - - if v, ok := in["proxy_url"].(string); ok && len(v) > 0 { - obj.ProxyURL = v - } - - return obj -} diff --git a/rancher2/structure_notifier_pagerduty_config_test.go b/rancher2/structure_notifier_pagerduty_config_test.go deleted file mode 100644 index 98f1289a..00000000 --- a/rancher2/structure_notifier_pagerduty_config_test.go +++ /dev/null @@ -1,62 +0,0 @@ -package rancher2 - -import ( - "testing" - - managementClient "github.com/rancher/rancher/pkg/client/generated/management/v3" - "github.com/stretchr/testify/assert" -) - -var ( - testNotifierPagerdutyConfigConf *managementClient.PagerdutyConfig - testNotifierPagerdutyConfigInterface []interface{} -) - -func init() { - testNotifierPagerdutyConfigConf = &managementClient.PagerdutyConfig{ - ServiceKey: "service_key", - ProxyURL: "proxy_url", - } - testNotifierPagerdutyConfigInterface = []interface{}{ - map[string]interface{}{ - "service_key": "service_key", - "proxy_url": "proxy_url", - }, - } -} - -func TestFlattenNotifierPagerdutyConfig(t *testing.T) { - - cases := []struct { - Input *managementClient.PagerdutyConfig - ExpectedOutput []interface{} - }{ - { - testNotifierPagerdutyConfigConf, - testNotifierPagerdutyConfigInterface, - }, - } - - for _, tc := range cases { - output := flattenNotifierPagerdutyConfig(tc.Input, testNotifierPagerdutyConfigInterface) - assert.Equal(t, tc.ExpectedOutput, output, "Unexpected output from flattener.") - } -} - -func TestExpandNotifierPagerdutyConfig(t *testing.T) { - - cases := []struct { - Input []interface{} - ExpectedOutput *managementClient.PagerdutyConfig - }{ - { - testNotifierPagerdutyConfigInterface, - testNotifierPagerdutyConfigConf, - }, - } - - for _, tc := range cases { - output := expandNotifierPagerdutyConfig(tc.Input) - assert.Equal(t, tc.ExpectedOutput, output, "Unexpected output from expander.") - } -} diff --git a/rancher2/structure_notifier_slack_config.go b/rancher2/structure_notifier_slack_config.go deleted file mode 100644 index 261d46b7..00000000 --- a/rancher2/structure_notifier_slack_config.go +++ /dev/null @@ -1,50 +0,0 @@ -package rancher2 - -import ( - managementClient "github.com/rancher/rancher/pkg/client/generated/management/v3" -) - -// Flatteners - -func flattenNotifierSlackConfig(in *managementClient.SlackConfig, p []interface{}) []interface{} { - var obj map[string]interface{} - if len(p) == 0 || p[0] == nil { - obj = make(map[string]interface{}) - } else { - obj = p[0].(map[string]interface{}) - } - - if in == nil { - return []interface{}{} - } - - obj["default_recipient"] = in.DefaultRecipient - obj["url"] = in.URL - - if len(in.ProxyURL) > 0 { - obj["proxy_url"] = in.ProxyURL - } - - return []interface{}{obj} - -} - -// Expanders - -func expandNotifierSlackConfig(p []interface{}) *managementClient.SlackConfig { - obj := &managementClient.SlackConfig{} - - if len(p) == 0 || p[0] == nil { - return obj - } - in := p[0].(map[string]interface{}) - - obj.DefaultRecipient = in["default_recipient"].(string) - obj.URL = in["url"].(string) - - if v, ok := in["proxy_url"].(string); ok && len(v) > 0 { - obj.ProxyURL = v - } - - return obj -} diff --git a/rancher2/structure_notifier_slack_config_test.go b/rancher2/structure_notifier_slack_config_test.go deleted file mode 100644 index 26e173a2..00000000 --- a/rancher2/structure_notifier_slack_config_test.go +++ /dev/null @@ -1,64 +0,0 @@ -package rancher2 - -import ( - "testing" - - managementClient "github.com/rancher/rancher/pkg/client/generated/management/v3" - "github.com/stretchr/testify/assert" -) - -var ( - testNotifierSlackConfigConf *managementClient.SlackConfig - testNotifierSlackConfigInterface []interface{} -) - -func init() { - testNotifierSlackConfigConf = &managementClient.SlackConfig{ - DefaultRecipient: "default_recipient", - URL: "url", - ProxyURL: "proxy_url", - } - testNotifierSlackConfigInterface = []interface{}{ - map[string]interface{}{ - "default_recipient": "default_recipient", - "url": "url", - "proxy_url": "proxy_url", - }, - } -} - -func TestFlattenNotifierSlackConfig(t *testing.T) { - - cases := []struct { - Input *managementClient.SlackConfig - ExpectedOutput []interface{} - }{ - { - testNotifierSlackConfigConf, - testNotifierSlackConfigInterface, - }, - } - - for _, tc := range cases { - output := flattenNotifierSlackConfig(tc.Input, testNotifierSlackConfigInterface) - assert.Equal(t, tc.ExpectedOutput, output, "Unexpected output from flattener.") - } -} - -func TestExpandNotifierSlackConfig(t *testing.T) { - - cases := []struct { - Input []interface{} - ExpectedOutput *managementClient.SlackConfig - }{ - { - testNotifierSlackConfigInterface, - testNotifierSlackConfigConf, - }, - } - - for _, tc := range cases { - output := expandNotifierSlackConfig(tc.Input) - assert.Equal(t, tc.ExpectedOutput, output, "Unexpected output from expander.") - } -} diff --git a/rancher2/structure_notifier_smtp_config.go b/rancher2/structure_notifier_smtp_config.go deleted file mode 100644 index 049ed6f2..00000000 --- a/rancher2/structure_notifier_smtp_config.go +++ /dev/null @@ -1,68 +0,0 @@ -package rancher2 - -import ( - managementClient "github.com/rancher/rancher/pkg/client/generated/management/v3" -) - -// Flatteners - -func flattenNotifierSMTPConfig(in *managementClient.SMTPConfig, p []interface{}) []interface{} { - var obj map[string]interface{} - if len(p) == 0 || p[0] == nil { - obj = make(map[string]interface{}) - } else { - obj = p[0].(map[string]interface{}) - } - - if in == nil { - return []interface{}{} - } - - obj["default_recipient"] = in.DefaultRecipient - obj["host"] = in.Host - obj["port"] = int(in.Port) - obj["sender"] = in.Sender - - if len(in.Password) > 0 { - obj["password"] = in.Password - } - - obj["tls"] = *in.TLS - - if len(in.Username) > 0 { - obj["username"] = in.Username - } - - return []interface{}{obj} - -} - -// Expanders - -func expandNotifierSMTPConfig(p []interface{}) *managementClient.SMTPConfig { - obj := &managementClient.SMTPConfig{} - - if len(p) == 0 || p[0] == nil { - return obj - } - in := p[0].(map[string]interface{}) - - obj.DefaultRecipient = in["default_recipient"].(string) - obj.Host = in["host"].(string) - obj.Port = int64(in["port"].(int)) - obj.Sender = in["sender"].(string) - - if v, ok := in["password"].(string); ok && len(v) > 0 { - obj.Password = v - } - - if v, ok := in["tls"].(bool); ok { - obj.TLS = &v - } - - if v, ok := in["username"].(string); ok && len(v) > 0 { - obj.Username = v - } - - return obj -} diff --git a/rancher2/structure_notifier_smtp_config_test.go b/rancher2/structure_notifier_smtp_config_test.go deleted file mode 100644 index f5367b2c..00000000 --- a/rancher2/structure_notifier_smtp_config_test.go +++ /dev/null @@ -1,72 +0,0 @@ -package rancher2 - -import ( - "testing" - - managementClient "github.com/rancher/rancher/pkg/client/generated/management/v3" - "github.com/stretchr/testify/assert" -) - -var ( - testNotifierSMTPConfigConf *managementClient.SMTPConfig - testNotifierSMTPConfigInterface []interface{} -) - -func init() { - testNotifierSMTPConfigConf = &managementClient.SMTPConfig{ - DefaultRecipient: "default_recipient", - Host: "url", - Port: int64(25), - Sender: "sender", - Password: "password", - TLS: newTrue(), - Username: "username", - } - testNotifierSMTPConfigInterface = []interface{}{ - map[string]interface{}{ - "default_recipient": "default_recipient", - "host": "host", - "port": 25, - "sender": "sender", - "password": "password", - "tls": newTrue(), - "username": "username", - }, - } -} - -func TestFlattenNotifierSMTPConfig(t *testing.T) { - - cases := []struct { - Input *managementClient.SMTPConfig - ExpectedOutput []interface{} - }{ - { - testNotifierSMTPConfigConf, - testNotifierSMTPConfigInterface, - }, - } - - for _, tc := range cases { - output := flattenNotifierSMTPConfig(tc.Input, testNotifierSMTPConfigInterface) - assert.Equal(t, tc.ExpectedOutput, output, "Unexpected output from flattener.") - } -} - -func TestExpandNotifierSMTPConfig(t *testing.T) { - - cases := []struct { - Input []interface{} - ExpectedOutput *managementClient.SMTPConfig - }{ - { - testNotifierSMTPConfigInterface, - testNotifierSMTPConfigConf, - }, - } - - for _, tc := range cases { - output := expandNotifierSMTPConfig(tc.Input) - assert.Equal(t, tc.ExpectedOutput, output, "Unexpected output from expander.") - } -} diff --git a/rancher2/structure_notifier_webhook_config.go b/rancher2/structure_notifier_webhook_config.go deleted file mode 100644 index caa65a25..00000000 --- a/rancher2/structure_notifier_webhook_config.go +++ /dev/null @@ -1,48 +0,0 @@ -package rancher2 - -import ( - managementClient "github.com/rancher/rancher/pkg/client/generated/management/v3" -) - -// Flatteners - -func flattenNotifierWebhookConfig(in *managementClient.WebhookConfig, p []interface{}) []interface{} { - var obj map[string]interface{} - if len(p) == 0 || p[0] == nil { - obj = make(map[string]interface{}) - } else { - obj = p[0].(map[string]interface{}) - } - - if in == nil { - return []interface{}{} - } - - obj["url"] = in.URL - - if len(in.ProxyURL) > 0 { - obj["proxy_url"] = in.ProxyURL - } - - return []interface{}{obj} - -} - -// Expanders - -func expandNotifierWebhookConfig(p []interface{}) *managementClient.WebhookConfig { - obj := &managementClient.WebhookConfig{} - - if len(p) == 0 || p[0] == nil { - return obj - } - in := p[0].(map[string]interface{}) - - obj.URL = in["url"].(string) - - if v, ok := in["proxy_url"].(string); ok && len(v) > 0 { - obj.ProxyURL = v - } - - return obj -} diff --git a/rancher2/structure_notifier_webhook_config_test.go b/rancher2/structure_notifier_webhook_config_test.go deleted file mode 100644 index c79282cf..00000000 --- a/rancher2/structure_notifier_webhook_config_test.go +++ /dev/null @@ -1,62 +0,0 @@ -package rancher2 - -import ( - "testing" - - managementClient "github.com/rancher/rancher/pkg/client/generated/management/v3" - "github.com/stretchr/testify/assert" -) - -var ( - testNotifierWebhookConfigConf *managementClient.WebhookConfig - testNotifierWebhookConfigInterface []interface{} -) - -func init() { - testNotifierWebhookConfigConf = &managementClient.WebhookConfig{ - URL: "url", - ProxyURL: "proxy_url", - } - testNotifierWebhookConfigInterface = []interface{}{ - map[string]interface{}{ - "url": "url", - "proxy_url": "proxy_url", - }, - } -} - -func TestFlattenNotifierWebhookConfig(t *testing.T) { - - cases := []struct { - Input *managementClient.WebhookConfig - ExpectedOutput []interface{} - }{ - { - testNotifierWebhookConfigConf, - testNotifierWebhookConfigInterface, - }, - } - - for _, tc := range cases { - output := flattenNotifierWebhookConfig(tc.Input, testNotifierWebhookConfigInterface) - assert.Equal(t, tc.ExpectedOutput, output, "Unexpected output from flattener.") - } -} - -func TestExpandNotifierWebhookConfig(t *testing.T) { - - cases := []struct { - Input []interface{} - ExpectedOutput *managementClient.WebhookConfig - }{ - { - testNotifierWebhookConfigInterface, - testNotifierWebhookConfigConf, - }, - } - - for _, tc := range cases { - output := expandNotifierWebhookConfig(tc.Input) - assert.Equal(t, tc.ExpectedOutput, output, "Unexpected output from expander.") - } -} diff --git a/rancher2/structure_notifier_wechat_config.go b/rancher2/structure_notifier_wechat_config.go deleted file mode 100644 index 129dd172..00000000 --- a/rancher2/structure_notifier_wechat_config.go +++ /dev/null @@ -1,61 +0,0 @@ -package rancher2 - -import ( - managementClient "github.com/rancher/rancher/pkg/client/generated/management/v3" -) - -// Flatteners - -func flattenNotifierWechatConfig(in *managementClient.WechatConfig, p []interface{}) []interface{} { - var obj map[string]interface{} - if len(p) == 0 || p[0] == nil { - obj = make(map[string]interface{}) - } else { - obj = p[0].(map[string]interface{}) - } - - if in == nil { - return []interface{}{} - } - - obj["agent"] = in.Agent - obj["corp"] = in.Corp - obj["default_recipient"] = in.DefaultRecipient - - if len(in.Secret) > 0 { - obj["secret"] = in.Secret - } - - if len(in.ProxyURL) > 0 { - obj["proxy_url"] = in.ProxyURL - } - - obj["recipient_type"] = in.RecipientType - - return []interface{}{obj} - -} - -// Expanders - -func expandNotifierWechatConfig(p []interface{}) *managementClient.WechatConfig { - obj := &managementClient.WechatConfig{} - - if len(p) == 0 || p[0] == nil { - return obj - } - in := p[0].(map[string]interface{}) - - obj.Agent = in["agent"].(string) - obj.Corp = in["corp"].(string) - obj.DefaultRecipient = in["default_recipient"].(string) - obj.Secret = in["secret"].(string) - - if v, ok := in["proxy_url"].(string); ok && len(v) > 0 { - obj.ProxyURL = v - } - - obj.RecipientType = in["recipient_type"].(string) - - return obj -} diff --git a/rancher2/structure_notifier_wechat_config_test.go b/rancher2/structure_notifier_wechat_config_test.go deleted file mode 100644 index 89d180c6..00000000 --- a/rancher2/structure_notifier_wechat_config_test.go +++ /dev/null @@ -1,70 +0,0 @@ -package rancher2 - -import ( - "testing" - - managementClient "github.com/rancher/rancher/pkg/client/generated/management/v3" - "github.com/stretchr/testify/assert" -) - -var ( - testNotifierWechatConfigConf *managementClient.WechatConfig - testNotifierWechatConfigInterface []interface{} -) - -func init() { - testNotifierWechatConfigConf = &managementClient.WechatConfig{ - Agent: "agent", - Corp: "corp", - DefaultRecipient: "default_recipient", - Secret: "secret", - ProxyURL: "proxy_url", - RecipientType: "recipient_type", - } - testNotifierWechatConfigInterface = []interface{}{ - map[string]interface{}{ - "agent": "agent", - "corp": "corp", - "default_recipient": "default_recipient", - "secret": "secret", - "proxy_url": "proxy_url", - "recipient_type": "recipient_type", - }, - } -} - -func TestFlattenNotifierWechatConfig(t *testing.T) { - - cases := []struct { - Input *managementClient.WechatConfig - ExpectedOutput []interface{} - }{ - { - testNotifierWechatConfigConf, - testNotifierWechatConfigInterface, - }, - } - - for _, tc := range cases { - output := flattenNotifierWechatConfig(tc.Input, testNotifierWechatConfigInterface) - assert.Equal(t, tc.ExpectedOutput, output, "Unexpected output from flattener.") - } -} - -func TestExpandNotifierWechatConfig(t *testing.T) { - - cases := []struct { - Input []interface{} - ExpectedOutput *managementClient.WechatConfig - }{ - { - testNotifierWechatConfigInterface, - testNotifierWechatConfigConf, - }, - } - - for _, tc := range cases { - output := expandNotifierWechatConfig(tc.Input) - assert.Equal(t, tc.ExpectedOutput, output, "Unexpected output from expander.") - } -} diff --git a/rancher2/structure_notifier_z_test.go b/rancher2/structure_notifier_z_test.go deleted file mode 100644 index e86e6ee4..00000000 --- a/rancher2/structure_notifier_z_test.go +++ /dev/null @@ -1,213 +0,0 @@ -package rancher2 - -import ( - "reflect" - "testing" - - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - managementClient "github.com/rancher/rancher/pkg/client/generated/management/v3" - "github.com/stretchr/testify/assert" -) - -var ( - testNotifierDingtalkConf *managementClient.Notifier - testNotifierDingtalkInterface map[string]interface{} - testNotifierMSTeamsConf *managementClient.Notifier - testNotifierMSTeamsInterface map[string]interface{} - testNotifierPagerdutyConf *managementClient.Notifier - testNotifierPagerdutyInterface map[string]interface{} - testNotifierSlackConf *managementClient.Notifier - testNotifierSlackInterface map[string]interface{} - testNotifierSMTPConf *managementClient.Notifier - testNotifierSMTPInterface map[string]interface{} - testNotifierWebhookConf *managementClient.Notifier - testNotifierWebhookInterface map[string]interface{} - testNotifierWechatConf *managementClient.Notifier - testNotifierWechatInterface map[string]interface{} -) - -func init() { - testNotifierDingtalkConf = &managementClient.Notifier{ - Name: "name", - ClusterID: "cluster_id", - Description: "description", - DingtalkConfig: testNotifierDingtalkConfigConf, - } - testNotifierDingtalkInterface = map[string]interface{}{ - "name": "name", - "cluster_id": "cluster_id", - "description": "description", - "dingtalk_config": testNotifierDingtalkConfigInterface, - } - testNotifierMSTeamsConf = &managementClient.Notifier{ - Name: "name", - ClusterID: "cluster_id", - Description: "description", - MSTeamsConfig: testNotifierMSTeamsConfigConf, - } - testNotifierMSTeamsInterface = map[string]interface{}{ - "name": "name", - "cluster_id": "cluster_id", - "description": "description", - "msteams_config": testNotifierMSTeamsConfigInterface, - } - testNotifierPagerdutyConf = &managementClient.Notifier{ - Name: "name", - ClusterID: "cluster_id", - Description: "description", - PagerdutyConfig: testNotifierPagerdutyConfigConf, - } - testNotifierPagerdutyInterface = map[string]interface{}{ - "name": "name", - "cluster_id": "cluster_id", - "description": "description", - "pagerduty_config": testNotifierPagerdutyConfigInterface, - } - testNotifierSlackConf = &managementClient.Notifier{ - Name: "name", - ClusterID: "cluster_id", - Description: "description", - SlackConfig: testNotifierSlackConfigConf, - } - testNotifierSlackInterface = map[string]interface{}{ - "name": "name", - "cluster_id": "cluster_id", - "description": "description", - "slack_config": testNotifierSlackConfigInterface, - } - testNotifierSMTPConf = &managementClient.Notifier{ - Name: "name", - ClusterID: "cluster_id", - Description: "description", - SMTPConfig: testNotifierSMTPConfigConf, - } - testNotifierSMTPInterface = map[string]interface{}{ - "name": "name", - "cluster_id": "cluster_id", - "description": "description", - "smtp_config": testNotifierSMTPConfigInterface, - } - testNotifierWebhookConf = &managementClient.Notifier{ - Name: "name", - ClusterID: "cluster_id", - Description: "description", - WebhookConfig: testNotifierWebhookConfigConf, - } - testNotifierWebhookInterface = map[string]interface{}{ - "name": "name", - "cluster_id": "cluster_id", - "description": "description", - "webhook_config": testNotifierWebhookConfigInterface, - } - testNotifierWechatConf = &managementClient.Notifier{ - Name: "name", - ClusterID: "cluster_id", - Description: "description", - WechatConfig: testNotifierWechatConfigConf, - } - testNotifierWechatInterface = map[string]interface{}{ - "name": "name", - "cluster_id": "cluster_id", - "description": "description", - "wechat_config": testNotifierWechatConfigInterface, - } -} - -func TestFlattenNotifier(t *testing.T) { - - cases := []struct { - Input *managementClient.Notifier - ExpectedOutput map[string]interface{} - }{ - { - testNotifierDingtalkConf, - testNotifierDingtalkInterface, - }, - { - testNotifierMSTeamsConf, - testNotifierMSTeamsInterface, - }, - { - testNotifierPagerdutyConf, - testNotifierPagerdutyInterface, - }, - { - testNotifierSlackConf, - testNotifierSlackInterface, - }, - { - testNotifierSMTPConf, - testNotifierSMTPInterface, - }, - { - testNotifierWebhookConf, - testNotifierWebhookInterface, - }, - { - testNotifierWechatConf, - testNotifierWechatInterface, - }, - } - - for _, tc := range cases { - output := schema.TestResourceDataRaw(t, notifierFields(), map[string]interface{}{}) - err := flattenNotifier(output, tc.Input) - if err != nil { - assert.FailNow(t, "[ERROR] on flattener: %#v", err) - } - expectedOutput := map[string]interface{}{} - for k := range tc.ExpectedOutput { - expectedOutput[k] = output.Get(k) - } - if !reflect.DeepEqual(expectedOutput, tc.ExpectedOutput) { - assert.FailNow(t, "Unexpected output from flattener.\nExpected: %#v\nGiven: %#v", - tc.ExpectedOutput, expectedOutput) - } - } -} - -func TestExpandNotifier(t *testing.T) { - - cases := []struct { - Input map[string]interface{} - ExpectedOutput *managementClient.Notifier - }{ - { - testNotifierDingtalkInterface, - testNotifierDingtalkConf, - }, - { - testNotifierMSTeamsInterface, - testNotifierMSTeamsConf, - }, - { - testNotifierPagerdutyInterface, - testNotifierPagerdutyConf, - }, - { - testNotifierSlackInterface, - testNotifierSlackConf, - }, - { - testNotifierSMTPInterface, - testNotifierSMTPConf, - }, - { - testNotifierWebhookInterface, - testNotifierWebhookConf, - }, - { - testNotifierWechatInterface, - testNotifierWechatConf, - }, - } - - for _, tc := range cases { - inputResourceData := schema.TestResourceDataRaw(t, notifierFields(), tc.Input) - output, err := expandNotifier(inputResourceData) - if err != nil { - assert.FailNow(t, "[ERROR] on expander: %#v", err) - } - assert.Equal(t, tc.ExpectedOutput, output, "Unexpected output from expander.") - } -} diff --git a/rancher2/structure_pod_security_policy_allowed_csi_drivers.go b/rancher2/structure_pod_security_policy_allowed_csi_drivers.go deleted file mode 100644 index 0f34b405..00000000 --- a/rancher2/structure_pod_security_policy_allowed_csi_drivers.go +++ /dev/null @@ -1,47 +0,0 @@ -package rancher2 - -import ( - managementClient "github.com/rancher/rancher/pkg/client/generated/management/v3" -) - -// Flatteners - -func flattenPodSecurityPolicyAllowedCSIDrivers(in []managementClient.AllowedCSIDriver) []interface{} { - - if len(in) == 0 { - return []interface{}{} - } - - out := make([]interface{}, len(in)) - - for i, v := range in { - obj := make(map[string]interface{}) - - obj["name"] = v.Name - - out[i] = obj - } - - return out -} - -// Expanders - -func expandPodSecurityPolicyAllowedCSIDrivers(in []interface{}) []managementClient.AllowedCSIDriver { - - if len(in) == 0 || in[0] == nil { - return []managementClient.AllowedCSIDriver{} - } - - obj := make([]managementClient.AllowedCSIDriver, len(in)) - - for i, v := range in { - if m, ok := v.(map[string]interface{}); ok { - obj[i] = managementClient.AllowedCSIDriver{ - Name: m["name"].(string), - } - } - } - - return obj -} diff --git a/rancher2/structure_pod_security_policy_allowed_csi_drivers_test.go b/rancher2/structure_pod_security_policy_allowed_csi_drivers_test.go deleted file mode 100644 index 799bd9c8..00000000 --- a/rancher2/structure_pod_security_policy_allowed_csi_drivers_test.go +++ /dev/null @@ -1,74 +0,0 @@ -package rancher2 - -import ( - "testing" - - managementClient "github.com/rancher/rancher/pkg/client/generated/management/v3" - "github.com/stretchr/testify/assert" -) - -var ( - testPodSecurityPolicyAllowedCSIDriversConf []managementClient.AllowedCSIDriver - testPodSecurityPolicyAllowedCSIDriversInterface []interface{} - testEmptyPodSecurityPolicyAllowedCSIDriversConf []managementClient.AllowedCSIDriver - testEmptyPodSecurityPolicyAllowedCSIDriversInterface []interface{} -) - -func init() { - testPodSecurityPolicyAllowedCSIDriversConf = []managementClient.AllowedCSIDriver{ - { - Name: "foo", - }, - { - Name: "bar", - }, - } - testPodSecurityPolicyAllowedCSIDriversInterface = []interface{}{ - map[string]interface{}{ - "name": "foo", - }, - map[string]interface{}{ - "name": "bar", - }, - } - testEmptyPodSecurityPolicyAllowedCSIDriversInterface = []interface{}{} -} - -func TestFlattenPodSecurityPolicyAllowedCSIDrivers(t *testing.T) { - - cases := []struct { - Input []managementClient.AllowedCSIDriver - ExpectedOutput []interface{} - }{ - { - testPodSecurityPolicyAllowedCSIDriversConf, - testPodSecurityPolicyAllowedCSIDriversInterface, - }, - { - testEmptyPodSecurityPolicyAllowedCSIDriversConf, - testEmptyPodSecurityPolicyAllowedCSIDriversInterface, - }, - } - - for _, tc := range cases { - output := flattenPodSecurityPolicyAllowedCSIDrivers(tc.Input) - assert.Equal(t, tc.ExpectedOutput, output, "Unexpected output from flattener.") - } -} - -func TestExpandPodSecurityPolicyAllowedCSIDrivers(t *testing.T) { - - cases := []struct { - Input []interface{} - ExpectedOutput []managementClient.AllowedCSIDriver - }{ - { - testPodSecurityPolicyAllowedCSIDriversInterface, - testPodSecurityPolicyAllowedCSIDriversConf, - }, - } - for _, tc := range cases { - output := expandPodSecurityPolicyAllowedCSIDrivers(tc.Input) - assert.Equal(t, tc.ExpectedOutput, output, "Unexpected output from expander.") - } -} diff --git a/rancher2/structure_pod_security_policy_allowed_flex_volumes.go b/rancher2/structure_pod_security_policy_allowed_flex_volumes.go deleted file mode 100644 index 29ecd49d..00000000 --- a/rancher2/structure_pod_security_policy_allowed_flex_volumes.go +++ /dev/null @@ -1,47 +0,0 @@ -package rancher2 - -import ( - managementClient "github.com/rancher/rancher/pkg/client/generated/management/v3" -) - -// Flatteners - -func flattenPodSecurityPolicyAllowedFlexVolumes(in []managementClient.AllowedFlexVolume) []interface{} { - - if len(in) == 0 { - return []interface{}{} - } - - out := make([]interface{}, len(in)) - - for i, v := range in { - obj := make(map[string]interface{}) - - obj["driver"] = v.Driver - - out[i] = obj - } - - return out -} - -// Expanders - -func expandPodSecurityPolicyAllowedFlexVolumes(in []interface{}) []managementClient.AllowedFlexVolume { - - if len(in) == 0 || in[0] == nil { - return []managementClient.AllowedFlexVolume{} - } - - obj := make([]managementClient.AllowedFlexVolume, len(in)) - - for i, v := range in { - if m, ok := v.(map[string]interface{}); ok { - obj[i] = managementClient.AllowedFlexVolume{ - Driver: m["driver"].(string), - } - } - } - - return obj -} diff --git a/rancher2/structure_pod_security_policy_allowed_flex_volumes_test.go b/rancher2/structure_pod_security_policy_allowed_flex_volumes_test.go deleted file mode 100644 index 3f2dc7fd..00000000 --- a/rancher2/structure_pod_security_policy_allowed_flex_volumes_test.go +++ /dev/null @@ -1,74 +0,0 @@ -package rancher2 - -import ( - "testing" - - managementClient "github.com/rancher/rancher/pkg/client/generated/management/v3" - "github.com/stretchr/testify/assert" -) - -var ( - testPodSecurityPolicyAllowedFlexVolumesConf []managementClient.AllowedFlexVolume - testPodSecurityPolicyAllowedFlexVolumesInterface []interface{} - testEmptyPodSecurityPolicyAllowedFlexVolumesConf []managementClient.AllowedFlexVolume - testEmptyPodSecurityPolicyAllowedFlexVolumesInterface []interface{} -) - -func init() { - testPodSecurityPolicyAllowedFlexVolumesConf = []managementClient.AllowedFlexVolume{ - { - Driver: "foo", - }, - { - Driver: "bar", - }, - } - testPodSecurityPolicyAllowedFlexVolumesInterface = []interface{}{ - map[string]interface{}{ - "driver": "foo", - }, - map[string]interface{}{ - "driver": "bar", - }, - } - testEmptyPodSecurityPolicyAllowedFlexVolumesInterface = []interface{}{} -} - -func TestFlattenPodSecurityPolicyAllowedFlexVolumes(t *testing.T) { - - cases := []struct { - Input []managementClient.AllowedFlexVolume - ExpectedOutput []interface{} - }{ - { - testPodSecurityPolicyAllowedFlexVolumesConf, - testPodSecurityPolicyAllowedFlexVolumesInterface, - }, - { - testEmptyPodSecurityPolicyAllowedFlexVolumesConf, - testEmptyPodSecurityPolicyAllowedFlexVolumesInterface, - }, - } - - for _, tc := range cases { - output := flattenPodSecurityPolicyAllowedFlexVolumes(tc.Input) - assert.Equal(t, tc.ExpectedOutput, output, "Unexpected output from flattener.") - } -} - -func TestExpandPodSecurityPolicyAllowedFlexVolumes(t *testing.T) { - - cases := []struct { - Input []interface{} - ExpectedOutput []managementClient.AllowedFlexVolume - }{ - { - testPodSecurityPolicyAllowedFlexVolumesInterface, - testPodSecurityPolicyAllowedFlexVolumesConf, - }, - } - for _, tc := range cases { - output := expandPodSecurityPolicyAllowedFlexVolumes(tc.Input) - assert.Equal(t, tc.ExpectedOutput, output, "Unexpected output from expander.") - } -} diff --git a/rancher2/structure_pod_security_policy_allowed_host_paths.go b/rancher2/structure_pod_security_policy_allowed_host_paths.go deleted file mode 100644 index e2492c46..00000000 --- a/rancher2/structure_pod_security_policy_allowed_host_paths.go +++ /dev/null @@ -1,54 +0,0 @@ -package rancher2 - -import ( - managementClient "github.com/rancher/rancher/pkg/client/generated/management/v3" -) - -// Flatteners - -func flattenPodSecurityPolicyAllowedHostPaths(in []managementClient.AllowedHostPath) []interface{} { - - if len(in) == 0 { - return []interface{}{} - } - - out := make([]interface{}, len(in)) - - for i, v := range in { - obj := make(map[string]interface{}) - - obj["path_prefix"] = v.PathPrefix - obj["read_only"] = v.ReadOnly - - out[i] = obj - } - - return out -} - -// Expanders - -func expandPodSecurityPolicyAllowedHostPaths(in []interface{}) []managementClient.AllowedHostPath { - - if len(in) == 0 || in[0] == nil { - return []managementClient.AllowedHostPath{} - } - - obj := make([]managementClient.AllowedHostPath, len(in)) - - for i, v := range in { - if m, ok := v.(map[string]interface{}); ok { - hp := managementClient.AllowedHostPath{ - PathPrefix: m["path_prefix"].(string), - } - - if ro, ok := m["read_only"].(bool); ok { - hp.ReadOnly = ro - } - - obj[i] = hp - } - } - - return obj -} diff --git a/rancher2/structure_pod_security_policy_allowed_host_paths_test.go b/rancher2/structure_pod_security_policy_allowed_host_paths_test.go deleted file mode 100644 index 5ebbed7d..00000000 --- a/rancher2/structure_pod_security_policy_allowed_host_paths_test.go +++ /dev/null @@ -1,77 +0,0 @@ -package rancher2 - -import ( - "testing" - - managementClient "github.com/rancher/rancher/pkg/client/generated/management/v3" - "github.com/stretchr/testify/assert" -) - -var ( - testPodSecurityPolicyAllowedHostPathsConf []managementClient.AllowedHostPath - testPodSecurityPolicyAllowedHostPathsInterface []interface{} - testEmptyPodSecurityPolicyAllowedHostPathsConf []managementClient.AllowedHostPath - testEmptyPodSecurityPolicyAllowedHostPathsInterface []interface{} -) - -func init() { - testPodSecurityPolicyAllowedHostPathsConf = []managementClient.AllowedHostPath{ - { - PathPrefix: "/var/lib", - ReadOnly: true, - }, - { - PathPrefix: "/tmp", - }, - } - testPodSecurityPolicyAllowedHostPathsInterface = []interface{}{ - map[string]interface{}{ - "path_prefix": "/var/lib", - "read_only": true, - }, - map[string]interface{}{ - "path_prefix": "/tmp", - "read_only": false, - }, - } - testEmptyPodSecurityPolicyAllowedHostPathsInterface = []interface{}{} -} - -func TestFlattenPodSecurityPolicyAllowedHostPaths(t *testing.T) { - - cases := []struct { - Input []managementClient.AllowedHostPath - ExpectedOutput []interface{} - }{ - { - testPodSecurityPolicyAllowedHostPathsConf, - testPodSecurityPolicyAllowedHostPathsInterface, - }, - { - testEmptyPodSecurityPolicyAllowedHostPathsConf, - testEmptyPodSecurityPolicyAllowedHostPathsInterface, - }, - } - - for _, tc := range cases { - output := flattenPodSecurityPolicyAllowedHostPaths(tc.Input) - assert.Equal(t, tc.ExpectedOutput, output, "Unexpected output from flattener.") - } -} - -func TestExpandPodSecurityPolicyAllowedHostPaths(t *testing.T) { - - cases := []struct { - Input []interface{} - ExpectedOutput []managementClient.AllowedHostPath - }{ - { - testPodSecurityPolicyAllowedHostPathsInterface, - testPodSecurityPolicyAllowedHostPathsConf, - }, - } - for _, tc := range cases { - output := expandPodSecurityPolicyAllowedHostPaths(tc.Input) - assert.Equal(t, tc.ExpectedOutput, output, "Unexpected output from expander.") - } -} diff --git a/rancher2/structure_pod_security_policy_fs_group.go b/rancher2/structure_pod_security_policy_fs_group.go deleted file mode 100644 index c2ae6d4b..00000000 --- a/rancher2/structure_pod_security_policy_fs_group.go +++ /dev/null @@ -1,48 +0,0 @@ -package rancher2 - -import ( - managementClient "github.com/rancher/rancher/pkg/client/generated/management/v3" -) - -// Flatteners - -func flattenPodSecurityPolicyFSGroup(in *managementClient.FSGroupStrategyOptions) []interface{} { - - if in == nil { - return []interface{}{} - } - - obj := make(map[string]interface{}) - - if len(in.Rule) > 0 { - obj["rule"] = in.Rule - } - if len(in.Ranges) > 0 { - obj["range"] = flattenPodSecurityPolicyIDRanges(in.Ranges) - } - - return []interface{}{obj} -} - -// Expanders - -func expandPodSecurityPolicyFSGroup(in []interface{}) *managementClient.FSGroupStrategyOptions { - - obj := &managementClient.FSGroupStrategyOptions{} - - if len(in) == 0 || in[0] == nil { - return obj - } - - m := in[0].(map[string]interface{}) - - if v, ok := m["rule"].(string); ok { - obj.Rule = v - } - - if v, ok := m["range"].([]interface{}); ok && len(v) > 0 { - obj.Ranges = expandPodSecurityPolicyIDRanges(v) - } - - return obj -} diff --git a/rancher2/structure_pod_security_policy_fs_group_test.go b/rancher2/structure_pod_security_policy_fs_group_test.go deleted file mode 100644 index e9a9df35..00000000 --- a/rancher2/structure_pod_security_policy_fs_group_test.go +++ /dev/null @@ -1,91 +0,0 @@ -package rancher2 - -import ( - "testing" - - managementClient "github.com/rancher/rancher/pkg/client/generated/management/v3" - "github.com/stretchr/testify/assert" -) - -var ( - testPodSecurityPolicyFSGroupConf *managementClient.FSGroupStrategyOptions - testPodSecurityPolicyFSGroupInterface []interface{} - testPodSecurityPolicyFSGroupIDRangesConf []managementClient.IDRange - testPodSecurityPolicyFSGroupIDRangesInterface []interface{} - testNilPodSecurityPolicyFSGroupConf *managementClient.FSGroupStrategyOptions - testEmptyPodSecurityPolicyFSGroupInterface []interface{} -) - -func init() { - testPodSecurityPolicyFSGroupIDRangesConf = []managementClient.IDRange{ - { - Min: int64(1), - Max: int64(3000), - }, - { - Min: int64(0), - Max: int64(5000), - }, - } - testPodSecurityPolicyFSGroupIDRangesInterface = []interface{}{ - map[string]interface{}{ - "min": 1, - "max": 3000, - }, - map[string]interface{}{ - "min": 0, - "max": 5000, - }, - } - testPodSecurityPolicyFSGroupConf = &managementClient.FSGroupStrategyOptions{ - Rule: "RunAsAny", - Ranges: testPodSecurityPolicyFSGroupIDRangesConf, - } - testPodSecurityPolicyFSGroupInterface = []interface{}{ - map[string]interface{}{ - "rule": "RunAsAny", - "range": testPodSecurityPolicyFSGroupIDRangesInterface, - }, - } - testEmptyPodSecurityPolicyFSGroupInterface = []interface{}{} -} - -func TestFlattenPodSecurityPolicyFSGroup(t *testing.T) { - - cases := []struct { - Input *managementClient.FSGroupStrategyOptions - ExpectedOutput []interface{} - }{ - { - testPodSecurityPolicyFSGroupConf, - testPodSecurityPolicyFSGroupInterface, - }, - { - testNilPodSecurityPolicyFSGroupConf, - testEmptyPodSecurityPolicyFSGroupInterface, - }, - } - - for _, tc := range cases { - output := flattenPodSecurityPolicyFSGroup(tc.Input) - assert.Equal(t, tc.ExpectedOutput, output, "Unexpected output from flattener.") - } -} - -func TestExpandPodSecurityPolicyFSGroup(t *testing.T) { - - cases := []struct { - Input []interface{} - ExpectedOutput *managementClient.FSGroupStrategyOptions - }{ - { - testPodSecurityPolicyFSGroupInterface, - testPodSecurityPolicyFSGroupConf, - }, - } - - for _, tc := range cases { - output := expandPodSecurityPolicyFSGroup(tc.Input) - assert.Equal(t, tc.ExpectedOutput, output, "Unexpected output from expander.") - } -} diff --git a/rancher2/structure_pod_security_policy_host_port_range.go b/rancher2/structure_pod_security_policy_host_port_range.go deleted file mode 100644 index 71dc808b..00000000 --- a/rancher2/structure_pod_security_policy_host_port_range.go +++ /dev/null @@ -1,49 +0,0 @@ -package rancher2 - -import ( - managementClient "github.com/rancher/rancher/pkg/client/generated/management/v3" -) - -// Flatteners - -func flattenPodSecurityPolicyHostPortRanges(in []managementClient.HostPortRange) []interface{} { - - if len(in) == 0 { - return []interface{}{} - } - - out := make([]interface{}, len(in)) - - for i, v := range in { - out[i] = map[string]interface{}{ - "min": int(v.Min), - "max": int(v.Max), - } - } - - return out - -} - -// Expanders - -func expandPodSecurityPolicyHostPortRanges(in []interface{}) []managementClient.HostPortRange { - - if len(in) == 0 || in[0] == nil { - return []managementClient.HostPortRange{} - } - - obj := make([]managementClient.HostPortRange, len(in)) - - for i, v := range in { - if m, ok := v.(map[string]interface{}); ok { - obj[i] = managementClient.HostPortRange{ - Min: int64(m["min"].(int)), - Max: int64(m["max"].(int)), - } - } - } - - return obj - -} diff --git a/rancher2/structure_pod_security_policy_host_port_range_test.go b/rancher2/structure_pod_security_policy_host_port_range_test.go deleted file mode 100644 index 4f369fc0..00000000 --- a/rancher2/structure_pod_security_policy_host_port_range_test.go +++ /dev/null @@ -1,78 +0,0 @@ -package rancher2 - -import ( - "testing" - - managementClient "github.com/rancher/rancher/pkg/client/generated/management/v3" - "github.com/stretchr/testify/assert" -) - -var ( - testPodSecurityPolicyHostPortRangesConf []managementClient.HostPortRange - testPodSecurityPolicyHostPortRangesInterface []interface{} - testEmptyPodSecurityPolicyHostPortRangesConf []managementClient.HostPortRange - testEmptyPodSecurityPolicyHostPortRangesInterface []interface{} -) - -func init() { - testPodSecurityPolicyHostPortRangesConf = []managementClient.HostPortRange{ - { - Min: 1, - Max: 3000, - }, - { - Min: 2, - Max: 4000, - }, - } - testPodSecurityPolicyHostPortRangesInterface = []interface{}{ - map[string]interface{}{ - "min": 1, - "max": 3000, - }, - map[string]interface{}{ - "min": 2, - "max": 4000, - }, - } - testEmptyPodSecurityPolicyHostPortRangesInterface = []interface{}{} -} - -func TestFlattenPodSecurityPolicyHostPortRanges(t *testing.T) { - - cases := []struct { - Input []managementClient.HostPortRange - ExpectedOutput []interface{} - }{ - { - testPodSecurityPolicyHostPortRangesConf, - testPodSecurityPolicyHostPortRangesInterface, - }, - { - testEmptyPodSecurityPolicyHostPortRangesConf, - testEmptyPodSecurityPolicyHostPortRangesInterface, - }, - } - - for _, tc := range cases { - output := flattenPodSecurityPolicyHostPortRanges(tc.Input) - assert.Equal(t, tc.ExpectedOutput, output, "Unexpected output from flattener.") - } -} - -func TestExpandPodSecurityPolicyHostPortRanges(t *testing.T) { - - cases := []struct { - Input []interface{} - ExpectedOutput []managementClient.HostPortRange - }{ - { - testPodSecurityPolicyHostPortRangesInterface, - testPodSecurityPolicyHostPortRangesConf, - }, - } - for _, tc := range cases { - output := expandPodSecurityPolicyHostPortRanges(tc.Input) - assert.Equal(t, tc.ExpectedOutput, output, "Unexpected output from expander.") - } -} diff --git a/rancher2/structure_pod_security_policy_id_ranges.go b/rancher2/structure_pod_security_policy_id_ranges.go deleted file mode 100644 index a9a5fd78..00000000 --- a/rancher2/structure_pod_security_policy_id_ranges.go +++ /dev/null @@ -1,47 +0,0 @@ -package rancher2 - -import ( - managementClient "github.com/rancher/rancher/pkg/client/generated/management/v3" -) - -// Flatteners - -func flattenPodSecurityPolicyIDRanges(in []managementClient.IDRange) []interface{} { - - if len(in) == 0 { - return []interface{}{} - } - - out := make([]interface{}, len(in)) - - for i, v := range in { - out[i] = map[string]interface{}{ - "min": int(v.Min), - "max": int(v.Max), - } - } - - return out -} - -// Expanders - -func expandPodSecurityPolicyIDRanges(in []interface{}) []managementClient.IDRange { - - if len(in) == 0 || in[0] == nil { - return []managementClient.IDRange{} - } - - obj := make([]managementClient.IDRange, len(in)) - - for i, v := range in { - if m, ok := v.(map[string]interface{}); ok { - obj[i] = managementClient.IDRange{ - Min: int64(m["min"].(int)), - Max: int64(m["max"].(int)), - } - } - } - - return obj -} diff --git a/rancher2/structure_pod_security_policy_id_ranges_test.go b/rancher2/structure_pod_security_policy_id_ranges_test.go deleted file mode 100644 index 5ac74fa3..00000000 --- a/rancher2/structure_pod_security_policy_id_ranges_test.go +++ /dev/null @@ -1,79 +0,0 @@ -package rancher2 - -import ( - "testing" - - managementClient "github.com/rancher/rancher/pkg/client/generated/management/v3" - "github.com/stretchr/testify/assert" -) - -var ( - testPodSecurityPolicyIDRangesConf []managementClient.IDRange - testPodSecurityPolicyIDRangesInterface []interface{} - testEmptyPodSecurityPolicyIDRangesConf []managementClient.IDRange - testEmptyPodSecurityPolicyIDRangesInterface []interface{} -) - -func init() { - testPodSecurityPolicyIDRangesConf = []managementClient.IDRange{ - { - Min: int64(1), - Max: int64(3000), - }, - { - Min: int64(0), - Max: int64(5000), - }, - } - testPodSecurityPolicyIDRangesInterface = []interface{}{ - map[string]interface{}{ - "min": 1, - "max": 3000, - }, - map[string]interface{}{ - "min": 0, - "max": 5000, - }, - } - testEmptyPodSecurityPolicyIDRangesInterface = []interface{}{} -} - -func TestFlattenPodSecurityPolicyIDRanges(t *testing.T) { - - cases := []struct { - Input []managementClient.IDRange - ExpectedOutput []interface{} - }{ - { - testPodSecurityPolicyIDRangesConf, - testPodSecurityPolicyIDRangesInterface, - }, - { - testEmptyPodSecurityPolicyIDRangesConf, - testEmptyPodSecurityPolicyIDRangesInterface, - }, - } - - for _, tc := range cases { - output := flattenPodSecurityPolicyIDRanges(tc.Input) - assert.Equal(t, tc.ExpectedOutput, output, "Unexpected output from flattener.") - } -} - -func TestExpandPodSecurityPolicyIDRanges(t *testing.T) { - - cases := []struct { - Input []interface{} - ExpectedOutput []managementClient.IDRange - }{ - { - testPodSecurityPolicyIDRangesInterface, - testPodSecurityPolicyIDRangesConf, - }, - } - - for _, tc := range cases { - output := expandPodSecurityPolicyIDRanges(tc.Input) - assert.Equal(t, tc.ExpectedOutput, output, "Unexpected output from expander.") - } -} diff --git a/rancher2/structure_pod_security_policy_run_as_group.go b/rancher2/structure_pod_security_policy_run_as_group.go deleted file mode 100644 index 226f830a..00000000 --- a/rancher2/structure_pod_security_policy_run_as_group.go +++ /dev/null @@ -1,48 +0,0 @@ -package rancher2 - -import ( - managementClient "github.com/rancher/rancher/pkg/client/generated/management/v3" -) - -// Flatteners - -func flattenPodSecurityPolicyRunAsGroup(in *managementClient.RunAsGroupStrategyOptions) []interface{} { - - if in == nil { - return []interface{}{} - } - - obj := make(map[string]interface{}) - - if len(in.Rule) > 0 { - obj["rule"] = in.Rule - } - if len(in.Ranges) > 0 { - obj["range"] = flattenPodSecurityPolicyIDRanges(in.Ranges) - } - - return []interface{}{obj} -} - -// Expanders - -func expandPodSecurityPolicyRunAsGroup(in []interface{}) *managementClient.RunAsGroupStrategyOptions { - - obj := &managementClient.RunAsGroupStrategyOptions{} - - if len(in) == 0 || in[0] == nil { - return obj - } - - m := in[0].(map[string]interface{}) - - if v, ok := m["rule"].(string); ok { - obj.Rule = v - } - - if v, ok := m["range"].([]interface{}); ok && len(v) > 0 { - obj.Ranges = expandPodSecurityPolicyIDRanges(v) - } - - return obj -} diff --git a/rancher2/structure_pod_security_policy_run_as_group_test.go b/rancher2/structure_pod_security_policy_run_as_group_test.go deleted file mode 100644 index 95e84949..00000000 --- a/rancher2/structure_pod_security_policy_run_as_group_test.go +++ /dev/null @@ -1,68 +0,0 @@ -package rancher2 - -import ( - "testing" - - managementClient "github.com/rancher/rancher/pkg/client/generated/management/v3" - "github.com/stretchr/testify/assert" -) - -var ( - testPodSecurityPolicyRunAsGroupConf *managementClient.RunAsGroupStrategyOptions - testPodSecurityPolicyRunAsGroupInterface []interface{} - testNilPodSecurityPolicyRunAsGroupConf *managementClient.RunAsGroupStrategyOptions - testEmptyPodSecurityPolicyRunAsGroupInterface []interface{} -) - -func init() { - testPodSecurityPolicyRunAsGroupConf = &managementClient.RunAsGroupStrategyOptions{ - Rule: "RunAsAny", - Ranges: testPodSecurityPolicyIDRangesConf, - } - testPodSecurityPolicyRunAsGroupInterface = []interface{}{ - map[string]interface{}{ - "rule": "RunAsAny", - "range": testPodSecurityPolicyIDRangesInterface, - }, - } - testEmptyPodSecurityPolicyRunAsGroupInterface = []interface{}{} -} - -func TestFlattenPodSecurityPolicyRunAsGroup(t *testing.T) { - - cases := []struct { - Input *managementClient.RunAsGroupStrategyOptions - ExpectedOutput []interface{} - }{ - { - testPodSecurityPolicyRunAsGroupConf, - testPodSecurityPolicyRunAsGroupInterface, - }, - { - testNilPodSecurityPolicyRunAsGroupConf, - testEmptyPodSecurityPolicyRunAsGroupInterface, - }, - } - for _, tc := range cases { - output := flattenPodSecurityPolicyRunAsGroup(tc.Input) - assert.Equal(t, tc.ExpectedOutput, output, "Unexpected output from flattener.") - } -} - -func TestExpandPodSecurityPolicyRunAsGroup(t *testing.T) { - - cases := []struct { - Input []interface{} - ExpectedOutput *managementClient.RunAsGroupStrategyOptions - }{ - { - testPodSecurityPolicyRunAsGroupInterface, - testPodSecurityPolicyRunAsGroupConf, - }, - } - - for _, tc := range cases { - output := expandPodSecurityPolicyRunAsGroup(tc.Input) - assert.Equal(t, tc.ExpectedOutput, output, "Unexpected output from expander.") - } -} diff --git a/rancher2/structure_pod_security_policy_run_as_user.go b/rancher2/structure_pod_security_policy_run_as_user.go deleted file mode 100644 index 2b1e601a..00000000 --- a/rancher2/structure_pod_security_policy_run_as_user.go +++ /dev/null @@ -1,48 +0,0 @@ -package rancher2 - -import ( - managementClient "github.com/rancher/rancher/pkg/client/generated/management/v3" -) - -// Flatteners - -func flattenPodSecurityPolicyRunAsUser(in *managementClient.RunAsUserStrategyOptions) []interface{} { - - if in == nil { - return []interface{}{} - } - - obj := make(map[string]interface{}) - - if len(in.Rule) > 0 { - obj["rule"] = string(in.Rule) - } - if len(in.Ranges) > 0 { - obj["range"] = flattenPodSecurityPolicyIDRanges(in.Ranges) - } - - return []interface{}{obj} -} - -// Expanders - -func expandPodSecurityPolicyRunAsUser(in []interface{}) *managementClient.RunAsUserStrategyOptions { - - obj := &managementClient.RunAsUserStrategyOptions{} - - if len(in) == 0 || in[0] == nil { - return obj - } - - m := in[0].(map[string]interface{}) - - if v, ok := m["rule"].(string); ok { - obj.Rule = v - } - - if v, ok := m["range"].([]interface{}); ok && len(v) > 0 { - obj.Ranges = expandPodSecurityPolicyIDRanges(v) - } - - return obj -} diff --git a/rancher2/structure_pod_security_policy_run_as_user_test.go b/rancher2/structure_pod_security_policy_run_as_user_test.go deleted file mode 100644 index b89eab87..00000000 --- a/rancher2/structure_pod_security_policy_run_as_user_test.go +++ /dev/null @@ -1,69 +0,0 @@ -package rancher2 - -import ( - "testing" - - managementClient "github.com/rancher/rancher/pkg/client/generated/management/v3" - "github.com/stretchr/testify/assert" -) - -var ( - testPodSecurityPolicyRunAsUserConf *managementClient.RunAsUserStrategyOptions - testPodSecurityPolicyRunAsUserInterface []interface{} - testNilPodSecurityPolicyRunAsUserConf *managementClient.RunAsUserStrategyOptions - testEmptyPodSecurityPolicyRunAsUserInterface []interface{} -) - -func init() { - testPodSecurityPolicyRunAsUserConf = &managementClient.RunAsUserStrategyOptions{ - Rule: "RunAsAny", - Ranges: testPodSecurityPolicyIDRangesConf, - } - testPodSecurityPolicyRunAsUserInterface = []interface{}{ - map[string]interface{}{ - "rule": "RunAsAny", - "range": testPodSecurityPolicyIDRangesInterface, - }, - } - testEmptyPodSecurityPolicyRunAsUserInterface = []interface{}{} -} - -func TestFlattenPodSecurityPolicyRunAsUser(t *testing.T) { - - cases := []struct { - Input *managementClient.RunAsUserStrategyOptions - ExpectedOutput []interface{} - }{ - { - testPodSecurityPolicyRunAsUserConf, - testPodSecurityPolicyRunAsUserInterface, - }, - { - testNilPodSecurityPolicyRunAsUserConf, - testEmptyPodSecurityPolicyRunAsUserInterface, - }, - } - - for _, tc := range cases { - output := flattenPodSecurityPolicyRunAsUser(tc.Input) - assert.Equal(t, tc.ExpectedOutput, output, "Unexpected output from flattener.") - } -} - -func TestExpandPodSecurityPolicyRunAsUser(t *testing.T) { - - cases := []struct { - Input []interface{} - ExpectedOutput *managementClient.RunAsUserStrategyOptions - }{ - { - testPodSecurityPolicyRunAsUserInterface, - testPodSecurityPolicyRunAsUserConf, - }, - } - - for _, tc := range cases { - output := expandPodSecurityPolicyRunAsUser(tc.Input) - assert.Equal(t, tc.ExpectedOutput, output, "Unexpected output from expander.") - } -} diff --git a/rancher2/structure_pod_security_policy_runtime_class_strategy.go b/rancher2/structure_pod_security_policy_runtime_class_strategy.go deleted file mode 100644 index b0d1c3eb..00000000 --- a/rancher2/structure_pod_security_policy_runtime_class_strategy.go +++ /dev/null @@ -1,48 +0,0 @@ -package rancher2 - -import ( - managementClient "github.com/rancher/rancher/pkg/client/generated/management/v3" -) - -// Flatteners - -func flattenPodSecurityPolicyRuntimeClassStrategy(in *managementClient.RuntimeClassStrategyOptions) []interface{} { - - if in == nil { - return []interface{}{} - } - - obj := make(map[string]interface{}) - - if len(in.AllowedRuntimeClassNames) > 0 { - obj["allowed_runtime_class_names"] = toArrayInterface(in.AllowedRuntimeClassNames) - } - if len(in.DefaultRuntimeClassName) > 0 { - obj["default_runtime_class_name"] = in.DefaultRuntimeClassName - } - - return []interface{}{obj} -} - -// Expanders - -func expandPodSecurityPolicyRuntimeClassStrategy(in []interface{}) *managementClient.RuntimeClassStrategyOptions { - - obj := &managementClient.RuntimeClassStrategyOptions{} - - if len(in) == 0 || in[0] == nil { - return obj - } - - m := in[0].(map[string]interface{}) - - if v, ok := m["allowed_runtime_class_names"].([]interface{}); ok { - obj.AllowedRuntimeClassNames = toArrayString(v) - } - - if v, ok := m["default_runtime_class_name"].(string); ok { - obj.DefaultRuntimeClassName = v - } - - return obj -} diff --git a/rancher2/structure_pod_security_policy_runtime_class_strategy_test.go b/rancher2/structure_pod_security_policy_runtime_class_strategy_test.go deleted file mode 100644 index 22c04b9a..00000000 --- a/rancher2/structure_pod_security_policy_runtime_class_strategy_test.go +++ /dev/null @@ -1,69 +0,0 @@ -package rancher2 - -import ( - "testing" - - managementClient "github.com/rancher/rancher/pkg/client/generated/management/v3" - "github.com/stretchr/testify/assert" -) - -var ( - testPodSecurityPolicyRuntimeClassStrategyConf *managementClient.RuntimeClassStrategyOptions - testPodSecurityPolicyRuntimeClassStrategyInterface []interface{} - testNilPodSecurityPolicyRuntimeClassStrategyConf *managementClient.RuntimeClassStrategyOptions - testEmptyPodSecurityPolicyRuntimeClassStrategyInterface []interface{} -) - -func init() { - testPodSecurityPolicyRuntimeClassStrategyConf = &managementClient.RuntimeClassStrategyOptions{ - AllowedRuntimeClassNames: []string{"foo", "bar"}, - DefaultRuntimeClassName: "foo", - } - testPodSecurityPolicyRuntimeClassStrategyInterface = []interface{}{ - map[string]interface{}{ - "allowed_runtime_class_names": toArrayInterface([]string{"foo", "bar"}), - "default_runtime_class_name": "foo", - }, - } - testEmptyPodSecurityPolicyRuntimeClassStrategyInterface = []interface{}{} -} - -func TestFlattenPodSecurityPolicyRuntimeClassStrategy(t *testing.T) { - - cases := []struct { - Input *managementClient.RuntimeClassStrategyOptions - ExpectedOutput []interface{} - }{ - { - testPodSecurityPolicyRuntimeClassStrategyConf, - testPodSecurityPolicyRuntimeClassStrategyInterface, - }, - { - testNilPodSecurityPolicyRuntimeClassStrategyConf, - testEmptyPodSecurityPolicyRuntimeClassStrategyInterface, - }, - } - - for _, tc := range cases { - output := flattenPodSecurityPolicyRuntimeClassStrategy(tc.Input) - assert.Equal(t, tc.ExpectedOutput, output, "Unexpected output from flattener.") - } -} - -func TestExpandPodSecurityPolicyRuntimeClassStrategy(t *testing.T) { - - cases := []struct { - Input []interface{} - ExpectedOutput *managementClient.RuntimeClassStrategyOptions - }{ - { - testPodSecurityPolicyRuntimeClassStrategyInterface, - testPodSecurityPolicyRuntimeClassStrategyConf, - }, - } - - for _, tc := range cases { - output := expandPodSecurityPolicyRuntimeClassStrategy(tc.Input) - assert.Equal(t, tc.ExpectedOutput, output, "Unexpected output from expander.") - } -} diff --git a/rancher2/structure_pod_security_policy_se_linux_options.go b/rancher2/structure_pod_security_policy_se_linux_options.go deleted file mode 100644 index d7c8e1c5..00000000 --- a/rancher2/structure_pod_security_policy_se_linux_options.go +++ /dev/null @@ -1,65 +0,0 @@ -package rancher2 - -import ( - managementClient "github.com/rancher/rancher/pkg/client/generated/management/v3" -) - -// Flatteners - -func flattenPodSecurityPolicySELinuxOptions(in *managementClient.SELinuxOptions) []interface{} { - - if in == nil { - return []interface{}{} - } - - obj := make(map[string]interface{}) - - if len(in.User) > 0 { - obj["user"] = in.User - } - - if len(in.Role) > 0 { - obj["role"] = in.Role - } - - if len(in.Type) > 0 { - obj["type"] = in.Type - } - - if len(in.Level) > 0 { - obj["level"] = in.Level - } - - return []interface{}{obj} -} - -// Expanders - -func expandPodSecurityPolicySELinuxOptions(in []interface{}) *managementClient.SELinuxOptions { - - obj := &managementClient.SELinuxOptions{} - - if len(in) == 0 || in[0] == nil { - return obj - } - - m := in[0].(map[string]interface{}) - - if v, ok := m["user"].(string); ok { - obj.User = v - } - - if v, ok := m["role"].(string); ok { - obj.Role = v - } - - if v, ok := m["type"].(string); ok { - obj.Type = v - } - - if v, ok := m["level"].(string); ok { - obj.Level = v - } - - return obj -} diff --git a/rancher2/structure_pod_security_policy_se_linux_options_test.go b/rancher2/structure_pod_security_policy_se_linux_options_test.go deleted file mode 100644 index 4315fdea..00000000 --- a/rancher2/structure_pod_security_policy_se_linux_options_test.go +++ /dev/null @@ -1,72 +0,0 @@ -package rancher2 - -import ( - "testing" - - managementClient "github.com/rancher/rancher/pkg/client/generated/management/v3" - "github.com/stretchr/testify/assert" -) - -var ( - testPodSecurityPolicySELinuxOptionsConf *managementClient.SELinuxOptions - testPodSecurityPolicySELinuxOptionsInterface []interface{} - testNilPodSecurityPolicySELinuxOptionsConf *managementClient.SELinuxOptions - testEmptyPodSecurityPolicySELinuxOptionsInterface []interface{} -) - -func init() { - testPodSecurityPolicySELinuxOptionsConf = &managementClient.SELinuxOptions{ - User: "user", - Role: "role", - Type: "type", - Level: "level", - } - testPodSecurityPolicySELinuxOptionsInterface = []interface{}{ - map[string]interface{}{ - "user": "user", - "role": "role", - "type": "type", - "level": "level", - }, - } - testEmptyPodSecurityPolicySELinuxOptionsInterface = []interface{}{} -} - -func TestFlattenPodSecurityPolicySELinuxOptions(t *testing.T) { - - cases := []struct { - Input *managementClient.SELinuxOptions - ExpectedOutput []interface{} - }{ - { - testPodSecurityPolicySELinuxOptionsConf, - testPodSecurityPolicySELinuxOptionsInterface, - }, - { - testNilPodSecurityPolicySELinuxOptionsConf, - testEmptyPodSecurityPolicySELinuxOptionsInterface, - }, - } - - for _, tc := range cases { - output := flattenPodSecurityPolicySELinuxOptions(tc.Input) - assert.Equal(t, tc.ExpectedOutput, output, "Unexpected output from flattener.") - } -} - -func TestExpandPodSecurityPolicySELinuxOptions(t *testing.T) { - - cases := []struct { - Input []interface{} - ExpectedOutput *managementClient.SELinuxOptions - }{ - { - testPodSecurityPolicySELinuxOptionsInterface, - testPodSecurityPolicySELinuxOptionsConf, - }, - } - for _, tc := range cases { - output := expandPodSecurityPolicySELinuxOptions(tc.Input) - assert.Equal(t, tc.ExpectedOutput, output, "Unexpected output from expander.") - } -} diff --git a/rancher2/structure_pod_security_policy_se_linux_strategy.go b/rancher2/structure_pod_security_policy_se_linux_strategy.go deleted file mode 100644 index b361576a..00000000 --- a/rancher2/structure_pod_security_policy_se_linux_strategy.go +++ /dev/null @@ -1,48 +0,0 @@ -package rancher2 - -import ( - managementClient "github.com/rancher/rancher/pkg/client/generated/management/v3" -) - -// Flatteners - -func flattenPodSecurityPolicySELinuxStrategy(in *managementClient.SELinuxStrategyOptions) []interface{} { - - if in == nil { - return []interface{}{} - } - - obj := make(map[string]interface{}) - - if len(in.Rule) > 0 { - obj["rule"] = in.Rule - } - if in.SELinuxOptions != nil { - obj["se_linux_option"] = flattenPodSecurityPolicySELinuxOptions(in.SELinuxOptions) - } - - return []interface{}{obj} -} - -// Expanders - -func expandPodSecurityPolicySELinuxStrategy(in []interface{}) *managementClient.SELinuxStrategyOptions { - - obj := &managementClient.SELinuxStrategyOptions{} - - if len(in) == 0 || in[0] == nil { - return obj - } - - m := in[0].(map[string]interface{}) - - if v, ok := m["rule"].(string); ok { - obj.Rule = v - } - - if v, ok := m["se_linux_option"].([]interface{}); ok && len(v) > 0 { - obj.SELinuxOptions = expandPodSecurityPolicySELinuxOptions(v) - } - - return obj -} diff --git a/rancher2/structure_pod_security_policy_se_linux_strategy_test.go b/rancher2/structure_pod_security_policy_se_linux_strategy_test.go deleted file mode 100644 index a9531156..00000000 --- a/rancher2/structure_pod_security_policy_se_linux_strategy_test.go +++ /dev/null @@ -1,69 +0,0 @@ -package rancher2 - -import ( - "testing" - - managementClient "github.com/rancher/rancher/pkg/client/generated/management/v3" - "github.com/stretchr/testify/assert" -) - -var ( - testPodSecurityPolicySELinuxStrategyConf *managementClient.SELinuxStrategyOptions - testPodSecurityPolicySELinuxStrategyInterface []interface{} - testNilPodSecurityPolicySELinuxStrategyConf *managementClient.SELinuxStrategyOptions - testEmptyPodSecurityPolicySELinuxStrategyInterface []interface{} -) - -func init() { - testPodSecurityPolicySELinuxStrategyConf = &managementClient.SELinuxStrategyOptions{ - Rule: "RunAsAny", - SELinuxOptions: testPodSecurityPolicySELinuxOptionsConf, - } - testPodSecurityPolicySELinuxStrategyInterface = []interface{}{ - map[string]interface{}{ - "rule": "RunAsAny", - "se_linux_option": testPodSecurityPolicySELinuxOptionsInterface, - }, - } - testEmptyPodSecurityPolicySELinuxStrategyInterface = []interface{}{} -} - -func TestFlattenPodSecurityPolicySELinuxStrategy(t *testing.T) { - - cases := []struct { - Input *managementClient.SELinuxStrategyOptions - ExpectedOutput []interface{} - }{ - { - testPodSecurityPolicySELinuxStrategyConf, - testPodSecurityPolicySELinuxStrategyInterface, - }, - { - testNilPodSecurityPolicySELinuxStrategyConf, - testEmptyPodSecurityPolicySELinuxStrategyInterface, - }, - } - - for _, tc := range cases { - output := flattenPodSecurityPolicySELinuxStrategy(tc.Input) - assert.Equal(t, tc.ExpectedOutput, output, "Unexpected output from flattener.") - } -} - -func TestExpandPodSecurityPolicySELinuxStrategy(t *testing.T) { - - cases := []struct { - Input []interface{} - ExpectedOutput *managementClient.SELinuxStrategyOptions - }{ - { - testPodSecurityPolicySELinuxStrategyInterface, - testPodSecurityPolicySELinuxStrategyConf, - }, - } - - for _, tc := range cases { - output := expandPodSecurityPolicySELinuxStrategy(tc.Input) - assert.Equal(t, tc.ExpectedOutput, output, "Unexpected output from expander.") - } -} diff --git a/rancher2/structure_pod_security_policy_supplemental_groups.go b/rancher2/structure_pod_security_policy_supplemental_groups.go deleted file mode 100644 index 2b0a3eee..00000000 --- a/rancher2/structure_pod_security_policy_supplemental_groups.go +++ /dev/null @@ -1,48 +0,0 @@ -package rancher2 - -import ( - managementClient "github.com/rancher/rancher/pkg/client/generated/management/v3" -) - -// Flatteners - -func flattenPodSecurityPolicySupplementalGroups(in *managementClient.SupplementalGroupsStrategyOptions) []interface{} { - - if in == nil { - return []interface{}{} - } - - obj := make(map[string]interface{}) - - if len(in.Rule) > 0 { - obj["rule"] = in.Rule - } - if len(in.Ranges) > 0 { - obj["range"] = flattenPodSecurityPolicyIDRanges(in.Ranges) - } - - return []interface{}{obj} -} - -// Expanders - -func expandPodSecurityPolicySupplementalGroups(in []interface{}) *managementClient.SupplementalGroupsStrategyOptions { - - obj := &managementClient.SupplementalGroupsStrategyOptions{} - - if len(in) == 0 || in[0] == nil { - return obj - } - - m := in[0].(map[string]interface{}) - - if v, ok := m["rule"].(string); ok { - obj.Rule = v - } - - if v, ok := m["range"].([]interface{}); ok && len(v) > 0 { - obj.Ranges = expandPodSecurityPolicyIDRanges(v) - } - - return obj -} diff --git a/rancher2/structure_pod_security_policy_supplemental_groups_test.go b/rancher2/structure_pod_security_policy_supplemental_groups_test.go deleted file mode 100644 index bd6cd24f..00000000 --- a/rancher2/structure_pod_security_policy_supplemental_groups_test.go +++ /dev/null @@ -1,69 +0,0 @@ -package rancher2 - -import ( - "testing" - - managementClient "github.com/rancher/rancher/pkg/client/generated/management/v3" - "github.com/stretchr/testify/assert" -) - -var ( - testPodSecurityPolicySupplementalGroupsConf *managementClient.SupplementalGroupsStrategyOptions - testPodSecurityPolicySupplementalGroupsInterface []interface{} - testNilPodSecurityPolicySupplementalGroupsConf *managementClient.SupplementalGroupsStrategyOptions - testEmptyPodSecurityPolicySupplementalGroupsInterface []interface{} -) - -func init() { - testPodSecurityPolicySupplementalGroupsConf = &managementClient.SupplementalGroupsStrategyOptions{ - Rule: "RunAsAny", - Ranges: testPodSecurityPolicyIDRangesConf, - } - testPodSecurityPolicySupplementalGroupsInterface = []interface{}{ - map[string]interface{}{ - "rule": "RunAsAny", - "range": testPodSecurityPolicyIDRangesInterface, - }, - } - testEmptyPodSecurityPolicySupplementalGroupsInterface = []interface{}{} -} - -func TestFlattenPodSecurityPolicySupplementalGroups(t *testing.T) { - - cases := []struct { - Input *managementClient.SupplementalGroupsStrategyOptions - ExpectedOutput []interface{} - }{ - { - testPodSecurityPolicySupplementalGroupsConf, - testPodSecurityPolicySupplementalGroupsInterface, - }, - { - testNilPodSecurityPolicySupplementalGroupsConf, - testEmptyPodSecurityPolicySupplementalGroupsInterface, - }, - } - - for _, tc := range cases { - output := flattenPodSecurityPolicySupplementalGroups(tc.Input) - assert.Equal(t, tc.ExpectedOutput, output, "Unexpected output from flattener.") - } -} - -func TestExpandPodSecurityPolicySupplementalGroups(t *testing.T) { - - cases := []struct { - Input []interface{} - ExpectedOutput *managementClient.SupplementalGroupsStrategyOptions - }{ - { - testPodSecurityPolicySupplementalGroupsInterface, - testPodSecurityPolicySupplementalGroupsConf, - }, - } - - for _, tc := range cases { - output := expandPodSecurityPolicySupplementalGroups(tc.Input) - assert.Equal(t, tc.ExpectedOutput, output, "Unexpected output from expander.") - } -} diff --git a/rancher2/structure_pod_security_policy_template.go b/rancher2/structure_pod_security_policy_template.go deleted file mode 100644 index e8950440..00000000 --- a/rancher2/structure_pod_security_policy_template.go +++ /dev/null @@ -1,229 +0,0 @@ -package rancher2 - -import ( - "fmt" - - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - managementClient "github.com/rancher/rancher/pkg/client/generated/management/v3" -) - -// Flatteners - -func flattenPodSecurityPolicyTemplate(d *schema.ResourceData, in *managementClient.PodSecurityPolicyTemplate) error { - if in == nil { - return fmt.Errorf("[ERROR] flattening pod security policy template: Input setting is nil") - } - - d.SetId(in.ID) - d.Set("name", in.Name) - - if len(in.Description) > 0 { - d.Set("description", in.Description) - } - - err := d.Set("annotations", toMapInterface(in.Annotations)) - if err != nil { - return err - } - - err = d.Set("labels", toMapInterface(in.Labels)) - if err != nil { - return err - } - - if in.AllowPrivilegeEscalation != nil { - d.Set("allow_privilege_escalation", *in.AllowPrivilegeEscalation) - } - - if len(in.AllowedCapabilities) > 0 { - d.Set("allowed_capabilities", toArrayInterface(in.AllowedCapabilities)) - } - - if len(in.AllowedCSIDrivers) > 0 { - d.Set("allowed_csi_driver", flattenPodSecurityPolicyAllowedCSIDrivers(in.AllowedCSIDrivers)) - } - - if len(in.AllowedFlexVolumes) > 0 { - d.Set("allowed_flex_volume", flattenPodSecurityPolicyAllowedFlexVolumes(in.AllowedFlexVolumes)) - } - - if len(in.AllowedHostPaths) > 0 { - d.Set("allowed_host_path", flattenPodSecurityPolicyAllowedHostPaths(in.AllowedHostPaths)) - } - - if len(in.AllowedProcMountTypes) > 0 { - d.Set("allowed_proc_mount_types", toArrayInterface(in.AllowedProcMountTypes)) - } - - if len(in.AllowedUnsafeSysctls) > 0 { - d.Set("allowed_unsafe_sysctls", toArrayInterface(in.AllowedUnsafeSysctls)) - } - - if len(in.DefaultAddCapabilities) > 0 { - d.Set("default_add_capabilities", toArrayInterface(in.DefaultAddCapabilities)) - } - - if in.DefaultAllowPrivilegeEscalation != nil { - d.Set("default_allow_privilege_escalation", *in.DefaultAllowPrivilegeEscalation) - } - - if len(in.ForbiddenSysctls) > 0 { - d.Set("forbidden_sysctls", toArrayInterface(in.ForbiddenSysctls)) - } - - d.Set("fs_group", flattenPodSecurityPolicyFSGroup(in.FSGroup)) - d.Set("host_ipc", in.HostIPC) - d.Set("host_network", in.HostNetwork) - d.Set("host_pid", in.HostPID) - - if len(in.HostPorts) > 0 { - d.Set("host_port", flattenPodSecurityPolicyHostPortRanges(in.HostPorts)) - } - - d.Set("privileged", in.Privileged) - d.Set("read_only_root_filesystem", in.ReadOnlyRootFilesystem) - - if len(in.RequiredDropCapabilities) > 0 { - d.Set("required_drop_capabilities", toArrayInterface(in.RequiredDropCapabilities)) - } - - d.Set("run_as_user", flattenPodSecurityPolicyRunAsUser(in.RunAsUser)) - - if in.RunAsGroup != nil { - d.Set("run_as_group", flattenPodSecurityPolicyRunAsGroup(in.RunAsGroup)) - } - - d.Set("runtime_class", flattenPodSecurityPolicyRuntimeClassStrategy(in.RuntimeClass)) - d.Set("se_linux", flattenPodSecurityPolicySELinuxStrategy(in.SELinux)) - d.Set("supplemental_group", flattenPodSecurityPolicySupplementalGroups(in.SupplementalGroups)) - d.Set("volumes", toArrayInterface(in.Volumes)) - - return nil -} - -func expandPodSecurityPolicyTemplate(in *schema.ResourceData) *managementClient.PodSecurityPolicyTemplate { - - if in == nil { - return nil - } - - obj := &managementClient.PodSecurityPolicyTemplate{} - - if v := in.Id(); len(v) > 0 { - obj.ID = v - } - - if v, ok := in.Get("name").(string); ok && len(v) > 0 { - obj.Name = v - } - - if v, ok := in.Get("description").(string); ok && len(v) > 0 { - obj.Description = v - } - - if v, ok := in.Get("annotations").(map[string]interface{}); ok && len(v) > 0 { - obj.Annotations = toMapString(v) - } - - if v, ok := in.Get("labels").(map[string]interface{}); ok && len(v) > 0 { - obj.Labels = toMapString(v) - } - - if v, ok := in.Get("allow_privilege_escalation").(bool); ok { - obj.AllowPrivilegeEscalation = &v - } - - if v, ok := in.Get("allowed_capabilities").([]interface{}); ok && len(v) > 0 { - obj.AllowedCapabilities = toArrayString(v) - } - - if v, ok := in.Get("allowed_csi_driver").([]interface{}); ok && len(v) > 0 { - obj.AllowedCSIDrivers = expandPodSecurityPolicyAllowedCSIDrivers(v) - } - - if v, ok := in.Get("allowed_flex_volume").([]interface{}); ok && len(v) > 0 { - obj.AllowedFlexVolumes = expandPodSecurityPolicyAllowedFlexVolumes(v) - } - - if v, ok := in.Get("allowed_host_path").([]interface{}); ok && len(v) > 0 { - obj.AllowedHostPaths = expandPodSecurityPolicyAllowedHostPaths(v) - } - - if v, ok := in.Get("allowed_proc_mount_types").([]interface{}); ok && len(v) > 0 { - obj.AllowedProcMountTypes = toArrayString(v) - } - - if v, ok := in.Get("allowed_unsafe_sysctls").([]interface{}); ok && len(v) > 0 { - obj.AllowedUnsafeSysctls = toArrayString(v) - } - - if v, ok := in.Get("default_add_capabilities").([]interface{}); ok && len(v) > 0 { - obj.DefaultAddCapabilities = toArrayString(v) - } - - if v, ok := in.Get("default_allow_privilege_escalation").(bool); ok { - obj.DefaultAllowPrivilegeEscalation = &v - } - - if v, ok := in.Get("forbidden_sysctls").([]interface{}); ok && len(v) > 0 { - obj.ForbiddenSysctls = toArrayString(v) - } - - if v, ok := in.Get("fs_group").([]interface{}); ok && len(v) > 0 { - obj.FSGroup = expandPodSecurityPolicyFSGroup(v) - } - - if v, ok := in.Get("host_ipc").(bool); ok { - obj.HostIPC = v - } - - if v, ok := in.Get("host_network").(bool); ok { - obj.HostNetwork = v - } - - if v, ok := in.Get("host_pid").(bool); ok { - obj.HostPID = v - } - - if v, ok := in.Get("host_port").([]interface{}); ok && len(v) > 0 { - obj.HostPorts = expandPodSecurityPolicyHostPortRanges(v) - } - - if v, ok := in.Get("privileged").(bool); ok { - obj.Privileged = v - } - - if v, ok := in.Get("read_only_root_filesystem").(bool); ok { - obj.ReadOnlyRootFilesystem = v - } - - if v, ok := in.Get("required_drop_capabilities").([]interface{}); ok && len(v) > 0 { - obj.RequiredDropCapabilities = toArrayString(v) - } - - if v, ok := in.Get("run_as_user").([]interface{}); ok && len(v) > 0 { - obj.RunAsUser = expandPodSecurityPolicyRunAsUser(v) - } - - if v, ok := in.Get("run_as_group").([]interface{}); ok && len(v) > 0 { - obj.RunAsGroup = expandPodSecurityPolicyRunAsGroup(v) - } - - if v, ok := in.Get("runtime_class").([]interface{}); ok && len(v) > 0 { - obj.RuntimeClass = expandPodSecurityPolicyRuntimeClassStrategy(v) - } - - if v, ok := in.Get("se_linux").([]interface{}); ok && len(v) > 0 { - obj.SELinux = expandPodSecurityPolicySELinuxStrategy(v) - } - - if v, ok := in.Get("supplemental_group").([]interface{}); ok && len(v) > 0 { - obj.SupplementalGroups = expandPodSecurityPolicySupplementalGroups(v) - } - - if v, ok := in.Get("volumes").([]interface{}); ok && len(v) > 0 { - obj.Volumes = toArrayString(v) - } - - return obj -} diff --git a/rancher2/structure_pod_security_policy_template_test.go b/rancher2/structure_pod_security_policy_template_test.go deleted file mode 100644 index f59d5eec..00000000 --- a/rancher2/structure_pod_security_policy_template_test.go +++ /dev/null @@ -1,140 +0,0 @@ -package rancher2 - -import ( - "reflect" - "testing" - - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - managementClient "github.com/rancher/rancher/pkg/client/generated/management/v3" - "github.com/stretchr/testify/assert" -) - -var ( - testPodSecurityPolicyBool bool - testPodSecurityPolicyTemplateConf *managementClient.PodSecurityPolicyTemplate - testPodSecurityPolicyTemplateInterface map[string]interface{} -) - -func init() { - testPodSecurityPolicyBool = true - testPodSecurityPolicyTemplateConf = &managementClient.PodSecurityPolicyTemplate{ - Name: "name", - Description: "description", - Annotations: map[string]string{ - "node_one": "one", - "node_two": "two", - }, - Labels: map[string]string{ - "option1": "value1", - "option2": "value2", - }, - Privileged: true, - DefaultAddCapabilities: []string{"NET_ADMIN"}, - RequiredDropCapabilities: []string{"NET_ADMIN"}, - AllowedCapabilities: []string{"NET_ADMIN"}, - Volumes: []string{"hostPath", "emptyDir"}, - HostNetwork: true, - HostPorts: testPodSecurityPolicyHostPortRangesConf, - HostPID: false, - HostIPC: true, - SELinux: testPodSecurityPolicySELinuxStrategyConf, - RunAsUser: testPodSecurityPolicyRunAsUserConf, - RunAsGroup: testPodSecurityPolicyRunAsGroupConf, - SupplementalGroups: testPodSecurityPolicySupplementalGroupsConf, - FSGroup: testPodSecurityPolicyFSGroupConf, - ReadOnlyRootFilesystem: false, - DefaultAllowPrivilegeEscalation: &testPodSecurityPolicyBool, - AllowPrivilegeEscalation: &testPodSecurityPolicyBool, - AllowedHostPaths: testPodSecurityPolicyAllowedHostPathsConf, - AllowedFlexVolumes: testPodSecurityPolicyAllowedFlexVolumesConf, - AllowedCSIDrivers: testPodSecurityPolicyAllowedCSIDriversConf, - AllowedUnsafeSysctls: []string{"foo", "bar"}, - ForbiddenSysctls: []string{"foo", "bar"}, - AllowedProcMountTypes: []string{"Default", "Unmasked"}, - RuntimeClass: testPodSecurityPolicyRuntimeClassStrategyConf, - } - testPodSecurityPolicyTemplateInterface = map[string]interface{}{ - "name": "name", - "description": "description", - "annotations": map[string]interface{}{ - "node_one": "one", - "node_two": "two", - }, - "labels": map[string]interface{}{ - "option1": "value1", - "option2": "value2", - }, - "privileged": true, - "default_add_capabilities": toArrayInterface([]string{"NET_ADMIN"}), - "required_drop_capabilities": toArrayInterface([]string{"NET_ADMIN"}), - "allowed_capabilities": toArrayInterface([]string{"NET_ADMIN"}), - "volumes": toArrayInterface([]string{"hostPath", "emptyDir"}), - "host_network": true, - "host_port": testPodSecurityPolicyHostPortRangesInterface, - "host_pid": false, - "host_ipc": true, - "se_linux": testPodSecurityPolicySELinuxStrategyInterface, - "run_as_user": testPodSecurityPolicyRunAsUserInterface, - "run_as_group": testPodSecurityPolicyRunAsGroupInterface, - "supplemental_group": testPodSecurityPolicySupplementalGroupsInterface, - "fs_group": testPodSecurityPolicyFSGroupInterface, - "read_only_root_filesystem": false, - "default_allow_privilege_escalation": testPodSecurityPolicyBool, - "allow_privilege_escalation": testPodSecurityPolicyBool, - "allowed_host_path": testPodSecurityPolicyAllowedHostPathsInterface, - "allowed_flex_volume": testPodSecurityPolicyAllowedFlexVolumesInterface, - "allowed_csi_driver": testPodSecurityPolicyAllowedCSIDriversInterface, - "allowed_unsafe_sysctls": toArrayInterface([]string{"foo", "bar"}), - "forbidden_sysctls": toArrayInterface([]string{"foo", "bar"}), - "allowed_proc_mount_types": toArrayInterface([]string{"Default", "Unmasked"}), - "runtime_class": testPodSecurityPolicyRuntimeClassStrategyInterface, - } -} - -func TestFlattenPodSecurityPolicyTemplate(t *testing.T) { - - cases := []struct { - Input *managementClient.PodSecurityPolicyTemplate - ExpectedOutput map[string]interface{} - }{ - { - testPodSecurityPolicyTemplateConf, - testPodSecurityPolicyTemplateInterface, - }, - } - - for _, tc := range cases { - output := schema.TestResourceDataRaw(t, podSecurityPolicyTemplateFields(), map[string]interface{}{}) - err := flattenPodSecurityPolicyTemplate(output, tc.Input) - if err != nil { - assert.FailNow(t, "[ERROR] on flattener: %#v", err) - } - given := map[string]interface{}{} - for k := range tc.ExpectedOutput { - given[k] = output.Get(k) - } - if !reflect.DeepEqual(given, tc.ExpectedOutput) { - assert.FailNow(t, "Unexpected output from flattener.\nExpected: %#v\nGiven: %#v", - tc.ExpectedOutput, given) - } - } -} - -func TestExpandPodSecurityPolicyTemplate(t *testing.T) { - - cases := []struct { - Input map[string]interface{} - ExpectedOutput *managementClient.PodSecurityPolicyTemplate - }{ - { - testPodSecurityPolicyTemplateInterface, - testPodSecurityPolicyTemplateConf, - }, - } - - for _, tc := range cases { - inputResourceData := schema.TestResourceDataRaw(t, podSecurityPolicyTemplateFields(), tc.Input) - output := expandPodSecurityPolicyTemplate(inputResourceData) - assert.Equal(t, tc.ExpectedOutput, output, "Unexpected output from expander.") - } -} diff --git a/rancher2/structure_project.go b/rancher2/structure_project.go index af9683cb..223204e4 100644 --- a/rancher2/structure_project.go +++ b/rancher2/structure_project.go @@ -109,7 +109,7 @@ func flattenProjectResourceQuota(pQuota *managementClient.ProjectResourceQuota, return []interface{}{obj} } -func flattenProject(d *schema.ResourceData, in *managementClient.Project, monitoringInput *managementClient.MonitoringInput) error { +func flattenProject(d *schema.ResourceData, in *managementClient.Project) error { if in == nil { return nil } @@ -118,7 +118,6 @@ func flattenProject(d *schema.ResourceData, in *managementClient.Project, monito d.Set("cluster_id", in.ClusterID) d.Set("name", in.Name) d.Set("description", in.Description) - d.Set("enable_project_monitoring", in.EnableProjectMonitoring) if in.ContainerDefaultResourceLimit != nil { containerLimit := flattenProjectContainerResourceLimit(in.ContainerDefaultResourceLimit) @@ -128,8 +127,6 @@ func flattenProject(d *schema.ResourceData, in *managementClient.Project, monito } } - d.Set("pod_security_policy_template_id", in.PodSecurityPolicyTemplateName) - if in.ResourceQuota != nil && in.NamespaceDefaultResourceQuota != nil { resourceQuota := flattenProjectResourceQuota(in.ResourceQuota, in.NamespaceDefaultResourceQuota) err := d.Set("resource_quota", resourceQuota) @@ -138,12 +135,7 @@ func flattenProject(d *schema.ResourceData, in *managementClient.Project, monito } } - err := d.Set("project_monitoring_input", flattenMonitoringInput(monitoringInput)) - if err != nil { - return err - } - - err = d.Set("annotations", toMapInterface(in.Annotations)) + err := d.Set("annotations", toMapInterface(in.Annotations)) if err != nil { return err } @@ -286,12 +278,6 @@ func expandProject(in *schema.ResourceData) *managementClient.Project { obj.ContainerDefaultResourceLimit = containerLimit } - if v, ok := in.Get("enable_project_monitoring").(bool); ok { - obj.EnableProjectMonitoring = v - } - - obj.PodSecurityPolicyTemplateName = in.Get("pod_security_policy_template_id").(string) - if v, ok := in.Get("resource_quota").([]interface{}); ok && len(v) > 0 { resourceQuota, nsResourceQuota := expandProjectResourceQuota(v) obj.ResourceQuota = resourceQuota diff --git a/rancher2/structure_project_alert_group.go b/rancher2/structure_project_alert_group.go deleted file mode 100644 index 64ef9f9e..00000000 --- a/rancher2/structure_project_alert_group.go +++ /dev/null @@ -1,77 +0,0 @@ -package rancher2 - -import ( - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - managementClient "github.com/rancher/rancher/pkg/client/generated/management/v3" -) - -// Flatteners - -func flattenProjectAlertGroup(d *schema.ResourceData, in *managementClient.ProjectAlertGroup) error { - if in == nil { - return nil - } - - d.SetId(in.ID) - d.Set("name", in.Name) - d.Set("project_id", in.ProjectID) - - if len(in.Description) > 0 { - d.Set("description", in.Description) - } - - d.Set("group_interval_seconds", int(in.GroupIntervalSeconds)) - d.Set("group_wait_seconds", int(in.GroupWaitSeconds)) - d.Set("recipients", flattenRecipients(in.Recipients)) - d.Set("repeat_interval_seconds", int(in.RepeatIntervalSeconds)) - - err := d.Set("annotations", toMapInterface(in.Annotations)) - if err != nil { - return err - } - - err = d.Set("labels", toMapInterface(in.Labels)) - if err != nil { - return err - } - return nil -} - -// Expanders - -func expandProjectAlertGroup(in *schema.ResourceData) *managementClient.ProjectAlertGroup { - obj := &managementClient.ProjectAlertGroup{} - if in == nil { - return nil - } - - if v := in.Id(); len(v) > 0 { - obj.ID = v - } - - obj.Name = in.Get("name").(string) - obj.ProjectID = in.Get("project_id").(string) - - if v, ok := in.Get("description").(string); ok && len(v) > 0 { - obj.Description = v - } - - obj.GroupIntervalSeconds = int64(in.Get("group_interval_seconds").(int)) - obj.GroupWaitSeconds = int64(in.Get("group_wait_seconds").(int)) - - if v, ok := in.Get("recipients").([]interface{}); ok && len(v) > 0 { - obj.Recipients = expandRecipients(v) - } - - obj.RepeatIntervalSeconds = int64(in.Get("repeat_interval_seconds").(int)) - - if v, ok := in.Get("annotations").(map[string]interface{}); ok && len(v) > 0 { - obj.Annotations = toMapString(v) - } - - if v, ok := in.Get("labels").(map[string]interface{}); ok && len(v) > 0 { - obj.Labels = toMapString(v) - } - - return obj -} diff --git a/rancher2/structure_project_alert_group_test.go b/rancher2/structure_project_alert_group_test.go deleted file mode 100644 index d56ca3de..00000000 --- a/rancher2/structure_project_alert_group_test.go +++ /dev/null @@ -1,97 +0,0 @@ -package rancher2 - -import ( - "testing" - - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - managementClient "github.com/rancher/rancher/pkg/client/generated/management/v3" - "github.com/stretchr/testify/assert" -) - -var ( - testProjectAlertGroupRecipientsConf []managementClient.Recipient - testProjectAlertGroupRecipientsInterface []interface{} - testProjectAlertGroupConf *managementClient.ProjectAlertGroup - testProjectAlertGroupInterface map[string]interface{} -) - -func init() { - testProjectAlertGroupRecipientsConf = []managementClient.Recipient{ - { - NotifierID: "notifier_id", - NotifierType: "webhook", - Recipient: "recipient", - }, - } - testProjectAlertGroupRecipientsInterface = []interface{}{ - map[string]interface{}{ - "notifier_id": "notifier_id", - "notifier_type": "webhook", - "recipient": "recipient", - "default_recipient": false, - }, - } - testProjectAlertGroupConf = &managementClient.ProjectAlertGroup{ - Name: "name", - ProjectID: "project_id", - Description: "description", - GroupIntervalSeconds: 300, - GroupWaitSeconds: 300, - Recipients: testProjectAlertGroupRecipientsConf, - RepeatIntervalSeconds: 6000, - } - testProjectAlertGroupInterface = map[string]interface{}{ - "name": "name", - "project_id": "project_id", - "description": "description", - "group_interval_seconds": 300, - "group_wait_seconds": 300, - "recipients": testProjectAlertGroupRecipientsInterface, - "repeat_interval_seconds": 6000, - } -} - -func TestFlattenProjectAlertGroup(t *testing.T) { - - cases := []struct { - Input *managementClient.ProjectAlertGroup - ExpectedOutput map[string]interface{} - }{ - { - testProjectAlertGroupConf, - testProjectAlertGroupInterface, - }, - } - - for _, tc := range cases { - output := schema.TestResourceDataRaw(t, projectAlertGroupFields(), map[string]interface{}{}) - err := flattenProjectAlertGroup(output, tc.Input) - if err != nil { - assert.FailNow(t, "[ERROR] on flattener: %#v", err) - } - expectedOutput := map[string]interface{}{} - for k := range tc.ExpectedOutput { - expectedOutput[k] = output.Get(k) - } - assert.Equal(t, tc.ExpectedOutput, expectedOutput, "Unexpected output from flattener.") - } -} - -func TestExpandProjectAlertGroup(t *testing.T) { - - cases := []struct { - Input map[string]interface{} - ExpectedOutput *managementClient.ProjectAlertGroup - }{ - { - testProjectAlertGroupInterface, - testProjectAlertGroupConf, - }, - } - - for _, tc := range cases { - inputResourceData := schema.TestResourceDataRaw(t, projectAlertGroupFields(), tc.Input) - output := expandProjectAlertGroup(inputResourceData) - assert.Equal(t, tc.ExpectedOutput, output, "Unexpected output from expander.") - } -} diff --git a/rancher2/structure_project_alert_rule.go b/rancher2/structure_project_alert_rule.go deleted file mode 100644 index 4271c956..00000000 --- a/rancher2/structure_project_alert_rule.go +++ /dev/null @@ -1,114 +0,0 @@ -package rancher2 - -import ( - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - managementClient "github.com/rancher/rancher/pkg/client/generated/management/v3" -) - -// Flatteners - -func flattenProjectAlertRule(d *schema.ResourceData, in *managementClient.ProjectAlertRule) error { - if in == nil { - return nil - } - - d.SetId(in.ID) - d.Set("name", in.Name) - d.Set("project_id", in.ProjectID) - d.Set("group_id", in.GroupID) - d.Set("group_interval_seconds", int(in.GroupIntervalSeconds)) - d.Set("group_wait_seconds", int(in.GroupWaitSeconds)) - - if in.Inherited != nil { - d.Set("inherited", *in.Inherited) - } - - if in.MetricRule != nil { - err := d.Set("metric_rule", flattenMetricRule(in.MetricRule)) - if err != nil { - return err - } - } - - if in.PodRule != nil { - err := d.Set("pod_rule", flattenPodRule(in.PodRule)) - if err != nil { - return err - } - } - - d.Set("repeat_interval_seconds", int(in.RepeatIntervalSeconds)) - - if len(in.Severity) > 0 { - d.Set("severity", in.Severity) - } - - if in.WorkloadRule != nil { - err := d.Set("workload_rule", flattenWorkloadRule(in.WorkloadRule)) - if err != nil { - return err - } - } - - err := d.Set("annotations", toMapInterface(in.Annotations)) - if err != nil { - return err - } - - err = d.Set("labels", toMapInterface(in.Labels)) - if err != nil { - return err - } - return nil -} - -// Expanders - -func expandProjectAlertRule(in *schema.ResourceData) *managementClient.ProjectAlertRule { - obj := &managementClient.ProjectAlertRule{} - if in == nil { - return nil - } - - if v := in.Id(); len(v) > 0 { - obj.ID = v - } - - obj.Name = in.Get("name").(string) - obj.ProjectID = in.Get("project_id").(string) - obj.GroupID = in.Get("group_id").(string) - obj.GroupIntervalSeconds = int64(in.Get("group_interval_seconds").(int)) - obj.GroupWaitSeconds = int64(in.Get("group_wait_seconds").(int)) - - if v, ok := in.Get("inherited").(bool); ok { - obj.Inherited = &v - } - - if v, ok := in.Get("metric_rule").([]interface{}); ok && len(v) > 0 { - obj.MetricRule = expandMetricRule(v) - } - - if v, ok := in.Get("pod_rule").([]interface{}); ok && len(v) > 0 { - obj.PodRule = expandPodRule(v) - } - - obj.RepeatIntervalSeconds = int64(in.Get("repeat_interval_seconds").(int)) - - if v, ok := in.Get("severity").(string); ok { - obj.Severity = v - } - - if v, ok := in.Get("workload_rule").([]interface{}); ok && len(v) > 0 { - obj.WorkloadRule = expandWorkloadRule(v) - } - - if v, ok := in.Get("annotations").(map[string]interface{}); ok && len(v) > 0 { - obj.Annotations = toMapString(v) - } - - if v, ok := in.Get("labels").(map[string]interface{}); ok && len(v) > 0 { - obj.Labels = toMapString(v) - } - - return obj -} diff --git a/rancher2/structure_project_alert_rule_test.go b/rancher2/structure_project_alert_rule_test.go deleted file mode 100644 index faa126ec..00000000 --- a/rancher2/structure_project_alert_rule_test.go +++ /dev/null @@ -1,142 +0,0 @@ -package rancher2 - -import ( - "testing" - - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - managementClient "github.com/rancher/rancher/pkg/client/generated/management/v3" - "github.com/stretchr/testify/assert" -) - -var ( - testProjectAlertMetricRuleConf *managementClient.MetricRule - testProjectAlertMetricRuleInterface []interface{} - testProjectAlertPodRuleConf *managementClient.PodRule - testProjectAlertPodRuleInterface []interface{} - testProjectAlertWorkloadRuleConf *managementClient.WorkloadRule - testProjectAlertWorkloadRuleInterface []interface{} - testProjectAlertRuleConf *managementClient.ProjectAlertRule - testProjectAlertRuleInterface map[string]interface{} -) - -func init() { - testProjectAlertMetricRuleConf = &managementClient.MetricRule{ - Comparison: metricRuleComparisonEqual, - Duration: "30", - Expression: "expression", - ThresholdValue: float64(3.5), - Description: "description", - } - testProjectAlertMetricRuleInterface = []interface{}{ - map[string]interface{}{ - "comparison": metricRuleComparisonEqual, - "duration": "30", - "expression": "expression", - "threshold_value": float64(3.5), - "description": "description", - }, - } - testProjectAlertPodRuleConf = &managementClient.PodRule{ - Condition: podRuleConditionNotRunning, - PodID: "pod_id", - RestartIntervalSeconds: int64(70), - RestartTimes: int64(5), - } - testProjectAlertPodRuleInterface = []interface{}{ - map[string]interface{}{ - "condition": podRuleConditionNotRunning, - "pod_id": "pod_id", - "restart_interval_seconds": 70, - "restart_times": 5, - }, - } - testProjectAlertWorkloadRuleConf = &managementClient.WorkloadRule{ - AvailablePercentage: int64(70), - Selector: map[string]string{ - "selector1": "selector1", - "selector2": "selector2", - }, - WorkloadID: "workload_id", - } - testProjectAlertWorkloadRuleInterface = []interface{}{ - map[string]interface{}{ - "available_percentage": 70, - "selector": map[string]interface{}{ - "selector1": "selector1", - "selector2": "selector2", - }, - "workload_id": "workload_id", - }, - } - testProjectAlertRuleConf = &managementClient.ProjectAlertRule{ - Name: "name", - ProjectID: "project_id", - GroupID: "group_id", - GroupIntervalSeconds: 300, - GroupWaitSeconds: 300, - Inherited: newTrue(), - MetricRule: testProjectAlertMetricRuleConf, - PodRule: testProjectAlertPodRuleConf, - RepeatIntervalSeconds: 6000, - Severity: alertRuleSeverityCritical, - WorkloadRule: testProjectAlertWorkloadRuleConf, - } - testProjectAlertRuleInterface = map[string]interface{}{ - "name": "name", - "project_id": "project_id", - "group_id": "group_id", - "group_interval_seconds": 300, - "group_wait_seconds": 300, - "inherited": true, - "metric_rule": testProjectAlertMetricRuleInterface, - "pod_rule": testProjectAlertPodRuleInterface, - "repeat_interval_seconds": 6000, - "severity": alertRuleSeverityCritical, - "workload_rule": testProjectAlertWorkloadRuleInterface, - } -} - -func TestFlattenProjectAlertRule(t *testing.T) { - - cases := []struct { - Input *managementClient.ProjectAlertRule - ExpectedOutput map[string]interface{} - }{ - { - testProjectAlertRuleConf, - testProjectAlertRuleInterface, - }, - } - - for _, tc := range cases { - output := schema.TestResourceDataRaw(t, projectAlertRuleFields(), map[string]interface{}{}) - err := flattenProjectAlertRule(output, tc.Input) - if err != nil { - assert.FailNow(t, "[ERROR] on flattener: %#v", err) - } - expectedOutput := map[string]interface{}{} - for k := range tc.ExpectedOutput { - expectedOutput[k] = output.Get(k) - } - assert.Equal(t, tc.ExpectedOutput, expectedOutput, "Unexpected output from flattener.") - } -} - -func TestExpandProjectAlertRule(t *testing.T) { - - cases := []struct { - Input map[string]interface{} - ExpectedOutput *managementClient.ProjectAlertRule - }{ - { - testProjectAlertRuleInterface, - testProjectAlertRuleConf, - }, - } - - for _, tc := range cases { - inputResourceData := schema.TestResourceDataRaw(t, projectAlertRuleFields(), tc.Input) - output := expandProjectAlertRule(inputResourceData) - assert.Equal(t, tc.ExpectedOutput, output, "Unexpected output from expander.") - } -} diff --git a/rancher2/structure_project_test.go b/rancher2/structure_project_test.go index 37192bc4..03d20bb2 100644 --- a/rancher2/structure_project_test.go +++ b/rancher2/structure_project_test.go @@ -119,19 +119,15 @@ func init() { Name: "test", ContainerDefaultResourceLimit: testProjectContainerResourceLimitConf, Description: "description", - EnableProjectMonitoring: true, - PodSecurityPolicyTemplateName: "pod_security_policy_template_id", ResourceQuota: testProjectResourceQuotaConf, NamespaceDefaultResourceQuota: testProjectNamespaceResourceQuotaConf, } testProjectInterface = map[string]interface{}{ - "cluster_id": "cluster-test", - "name": "test", - "container_resource_limit": testProjectContainerResourceLimitInterface, - "description": "description", - "enable_project_monitoring": true, - "pod_security_policy_template_id": "pod_security_policy_template_id", - "resource_quota": testProjectResourceQuotaInterface, + "cluster_id": "cluster-test", + "name": "test", + "container_resource_limit": testProjectContainerResourceLimitInterface, + "description": "description", + "resource_quota": testProjectResourceQuotaInterface, } } @@ -205,7 +201,7 @@ func TestFlattenProject(t *testing.T) { for _, tc := range cases { output := schema.TestResourceDataRaw(t, projectFields(), map[string]interface{}{}) - err := flattenProject(output, tc.Input, nil) + err := flattenProject(output, tc.Input) if err != nil { assert.FailNow(t, "[ERROR] on flattener: %#v", err) } diff --git a/rancher2/structure_recipient.go b/rancher2/structure_recipient.go deleted file mode 100644 index 18f577b5..00000000 --- a/rancher2/structure_recipient.go +++ /dev/null @@ -1,52 +0,0 @@ -package rancher2 - -import ( - managementClient "github.com/rancher/rancher/pkg/client/generated/management/v3" -) - -// Flatteners - -func flattenRecipients(p []managementClient.Recipient) []interface{} { - if len(p) == 0 { - return []interface{}{} - } - - out := make([]interface{}, len(p)) - for i, in := range p { - obj := make(map[string]interface{}) - - obj["notifier_id"] = in.NotifierID - - if len(in.NotifierType) > 0 { - obj["notifier_type"] = in.NotifierType - } - - if len(in.Recipient) > 0 { - obj["recipient"] = in.Recipient - } - - out[i] = obj - } - - return out -} - -// Expanders - -func expandRecipients(p []interface{}) []managementClient.Recipient { - if len(p) == 0 || p[0] == nil { - return []managementClient.Recipient{} - } - - obj := make([]managementClient.Recipient, len(p)) - - for i := range p { - in := p[i].(map[string]interface{}) - - obj[i].NotifierID = in["notifier_id"].(string) - obj[i].NotifierType = in["notifier_type"].(string) - obj[i].Recipient = in["recipient"].(string) - } - - return obj -} diff --git a/rancher2/structure_recipient_test.go b/rancher2/structure_recipient_test.go deleted file mode 100644 index b6a21309..00000000 --- a/rancher2/structure_recipient_test.go +++ /dev/null @@ -1,66 +0,0 @@ -package rancher2 - -import ( - "testing" - - managementClient "github.com/rancher/rancher/pkg/client/generated/management/v3" - "github.com/stretchr/testify/assert" -) - -var ( - testRecipientsConf []managementClient.Recipient - testRecipientsInterface []interface{} -) - -func init() { - testRecipientsConf = []managementClient.Recipient{ - { - NotifierID: "notifier_id", - NotifierType: "webhook", - Recipient: "recipient", - }, - } - testRecipientsInterface = []interface{}{ - map[string]interface{}{ - "notifier_id": "notifier_id", - "notifier_type": "webhook", - "recipient": "recipient", - }, - } -} - -func TestFlattenRecipients(t *testing.T) { - - cases := []struct { - Input []managementClient.Recipient - ExpectedOutput []interface{} - }{ - { - testRecipientsConf, - testRecipientsInterface, - }, - } - - for _, tc := range cases { - output := flattenRecipients(tc.Input) - assert.Equal(t, tc.ExpectedOutput, output, "Unexpected output from flattener.") - } -} - -func TestExpandRecipients(t *testing.T) { - - cases := []struct { - Input []interface{} - ExpectedOutput []managementClient.Recipient - }{ - { - testRecipientsInterface, - testRecipientsConf, - }, - } - - for _, tc := range cases { - output := expandRecipients(tc.Input) - assert.Equal(t, tc.ExpectedOutput, output, "Unexpected output from expander.") - } -} diff --git a/website/rancher2.erb b/website/rancher2.erb index 06c3634d..2f7544fe 100644 --- a/website/rancher2.erb +++ b/website/rancher2.erb @@ -28,12 +28,6 @@ > rancher2_cluster - > - rancher2_cluster_alert_group - - > - rancher2_cluster_alert_rule - > rancher2_cluster_driver @@ -73,18 +67,9 @@ > rancher2_node_template - > - rancher2_notifier - > rancher2_project - > - rancher2_project_alert_group - - > - rancher2_project_alert_rule - > rancher2_project_logging @@ -157,12 +142,6 @@ > rancher2_cluster - > - rancher2_cluster_alert_group - - > - rancher2_cluster_alert_rule - > rancher2_cluster_driver @@ -205,18 +184,9 @@ > rancher2_node_template - > - rancher2_notifier - > rancher2_project - > - rancher2_project_alert_group - - > - rancher2_project_alert_rule - > rancher2_project_logging