@@ -11,8 +11,6 @@ import (
1111 "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
1212 "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
1313 "github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
14- admissionregistrationv1 "k8s.io/api/admissionregistration/v1"
15- admissionregistrationv1beta1 "k8s.io/api/admissionregistration/v1beta1"
1614 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1715
1816 "k8s.io/apimachinery/pkg/api/errors"
@@ -188,70 +186,6 @@ func testAccCheckKubernetesValidatingWebhookConfigurationExists(n string) resour
188186 }
189187}
190188
191- func testAccCheckKubernetesValidatingWebhookGetObjectV1 (n string , obj * admissionregistrationv1.ValidatingWebhookConfiguration ) resource.TestCheckFunc {
192- return func (s * terraform.State ) error {
193- rs , ok := s .RootModule ().Resources [n ]
194- if ! ok {
195- return fmt .Errorf ("Not found: %s" , n )
196- }
197- conn , err := testAccProvider .Meta ().(KubeClientsets ).MainClientset ()
198- if err != nil {
199- return err
200- }
201- ctx := context .TODO ()
202- name := rs .Primary .ID
203- obj , err = conn .AdmissionregistrationV1 ().ValidatingWebhookConfigurations ().Get (ctx , name , metav1.GetOptions {})
204- return nil
205- }
206- }
207-
208- func testAccCheckKubernetesValidatingWebhookGetObjectV1Beta1 (n string , obj * admissionregistrationv1beta1.ValidatingWebhookConfiguration ) resource.TestCheckFunc {
209- return func (s * terraform.State ) error {
210- rs , ok := s .RootModule ().Resources [n ]
211- if ! ok {
212- return fmt .Errorf ("Not found: %s" , n )
213- }
214- conn , err := testAccProvider .Meta ().(KubeClientsets ).MainClientset ()
215- if err != nil {
216- return err
217- }
218- ctx := context .TODO ()
219- name := rs .Primary .ID
220- obj , err = conn .AdmissionregistrationV1beta1 ().ValidatingWebhookConfigurations ().Get (ctx , name , metav1.GetOptions {})
221- return nil
222- }
223- }
224-
225- func testAccCheckKubernetesValidatingWebhookConfigV1ForceNew (old , new * admissionregistrationv1.ValidatingWebhookConfiguration , wantNew bool ) resource.TestCheckFunc {
226- return func (s * terraform.State ) error {
227- if wantNew {
228- if old .ObjectMeta .UID == new .ObjectMeta .UID {
229- return fmt .Errorf ("Expecting new resource for ValidatingWebhookConfiguration %s" , old .ObjectMeta .UID )
230- }
231- } else {
232- if old .ObjectMeta .UID != new .ObjectMeta .UID {
233- return fmt .Errorf ("Expecting ValidatingWebhookConfiguration UIDs to be the same: expected %s got %s" , old .ObjectMeta .UID , new .ObjectMeta .UID )
234- }
235- }
236- return nil
237- }
238- }
239-
240- func testAccCheckKubernetesValidatingWebhookConfigV1Beta1ForceNew (old , new * admissionregistrationv1beta1.ValidatingWebhookConfiguration , wantNew bool ) resource.TestCheckFunc {
241- return func (s * terraform.State ) error {
242- if wantNew {
243- if old .ObjectMeta .UID == new .ObjectMeta .UID {
244- return fmt .Errorf ("Expecting new resource for ValidatingWebhookConfiguration %s" , old .ObjectMeta .UID )
245- }
246- } else {
247- if old .ObjectMeta .UID != new .ObjectMeta .UID {
248- return fmt .Errorf ("Expecting ValidatingWebhookConfiguration UIDs to be the same: expected %s got %s" , old .ObjectMeta .UID , new .ObjectMeta .UID )
249- }
250- }
251- return nil
252- }
253- }
254-
255189func testAccKubernetesValidatingWebhookConfigurationConfig_basic (name string ) string {
256190 return fmt .Sprintf (`
257191resource "kubernetes_validating_webhook_configuration" "test" {
@@ -345,60 +279,6 @@ resource "kubernetes_validating_webhook_configuration" "test" {
345279` , name , name )
346280}
347281
348- func testAccKubernetesValidatingWebhookConfigurationConfig_without_rules (name string ) string {
349- return fmt .Sprintf (`
350- resource "kubernetes_validating_webhook_configuration_v1" "test" {
351- metadata {
352- name = %q
353- }
354-
355- webhook {
356- name = %q
357-
358- failure_policy = "Ignore"
359- match_policy = "Exact"
360-
361- admission_review_versions = [
362- "v1",
363- "v1beta1"
364- ]
365-
366- client_config {
367- service {
368- namespace = "example-namespace"
369- name = "example-service"
370- }
371-
372- ca_bundle = "test"
373- }
374-
375- object_selector {
376- match_labels = {
377- app = "test"
378- }
379- }
380-
381- side_effects = "NoneOnDryRun"
382- timeout_seconds = 5
383- }
384- }
385- ` , name , name )
386- }
387-
388- func skipIfNotAdmissionRegistrationV1Beta1 (t * testing.T ) {
389- conn , err := testAccProvider .Meta ().(KubeClientsets ).MainClientset ()
390- if err != nil {
391- t .Fatal (err )
392- }
393- useadmissionregistrationv1beta1 , err := useAdmissionregistrationV1beta1 (conn )
394- if err != nil {
395- t .Fatal (err )
396- }
397- if ! useadmissionregistrationv1beta1 {
398- t .Skip ("The Kubernetes endpoint is not using admissionregistrationv1beta1 - skipping." )
399- }
400- }
401-
402282func skipIfNotAdmissionRegistrationV1 (t * testing.T ) {
403283 conn , err := testAccProvider .Meta ().(KubeClientsets ).MainClientset ()
404284 if err != nil {
0 commit comments