diff --git a/internal/provider/cloudinitsecret/resource_cloudinitsecret.go b/internal/provider/cloudinitsecret/resource_cloudinitsecret.go index f920ec30..8d26f859 100644 --- a/internal/provider/cloudinitsecret/resource_cloudinitsecret.go +++ b/internal/provider/cloudinitsecret/resource_cloudinitsecret.go @@ -3,12 +3,10 @@ package cloudinitsecret import ( "context" "encoding/base64" - "errors" "fmt" "time" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" corev1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" @@ -111,18 +109,6 @@ func resourceCloudInitSecretDelete(ctx context.Context, d *schema.ResourceData, return diag.FromErr(err) } - stateConf := &resource.StateChangeConf{ - Pending: []string{constants.StateImageTerminating, constants.StateCommonActive}, - Target: []string{constants.StateCommonRemoved}, - Refresh: resourceCloudInitSecretRefresh(ctx, d, meta), - Timeout: d.Timeout(schema.TimeoutDelete), - Delay: 1 * time.Second, - MinTimeout: 3 * time.Second, - } - _, err = stateConf.WaitForStateContext(ctx) - if err != nil { - return diag.FromErr(err) - } d.SetId("") return nil } @@ -152,30 +138,3 @@ func resourceCloudInitSecretImport(d *schema.ResourceData, obj *corev1.Secret) e return util.ResourceStatesSet(d, stateGetter) } - -func resourceCloudInitSecretRefresh(ctx context.Context, d *schema.ResourceData, meta interface{}) resource.StateRefreshFunc { - return func() (interface{}, string, error) { - c := meta.(*client.Client) - namespace := d.Get(constants.FieldCommonNamespace).(string) - name := d.Get(constants.FieldCommonName).(string) - - obj, err := c.KubeClient.CoreV1().Secrets(namespace).Get(ctx, name, metav1.GetOptions{}) - if err != nil { - if apierrors.IsNotFound(err) { - return obj, constants.StateCommonRemoved, nil - } - return obj, constants.StateCommonError, err - } - - if err = resourceCloudInitSecretImport(d, obj); err != nil { - return obj, constants.StateCommonError, err - } - - state := d.Get(constants.FieldCommonState).(string) - if state == constants.StateCommonFailed { - message := d.Get(constants.FieldCommonMessage).(string) - return obj, state, errors.New(message) - } - return obj, state, err - } -}