func (r *PostgreSqlReconciler) ProvisioningStorageBucket(dir string, bucket *sqlv1alpha1.PostgreSql, ctx context.Context) error {
	err := terraform.Init(filepath.Join(dir, "bucket"))
	if err != nil {
		initMsg := fmt.Sprintf("initializing storage bucket failed %v", bucket.Spec.BucketConfig.Name)
		r.Log.Error(err, initMsg)

		errUp := r.UpdateStatus(ctx, bucket, sqlv1alpha1.PhaseFailed)
		r.Recorder.Eventf(bucket, kubeApiV1.EventTypeWarning, "InitializeFailed ", "failed to initialize storage bucket %q", bucket.Spec.BucketConfig.Name)
		if errUp != nil {
			return errUp
		}
		return err
	}
	err = terraform.Apply(filepath.Join(dir, "bucket"))
	if err != nil {
		applyMsg := fmt.Sprintf("provisioning storage bucket failed %v", bucket.Spec.BucketConfig.Name)
		r.Log.Error(err, applyMsg)
		errUp := r.UpdateStatus(ctx, bucket, sqlv1alpha1.PhaseFailed)

		r.Recorder.Eventf(bucket, kubeApiV1.EventTypeWarning, "ApplyingFailed ", "failed to provision storage bucket %q - bucket names must be unique", bucket.Spec.BucketConfig.Name)
		if errUp != nil {
			return errUp
		}
		return err
	}
	return nil
}
//ProvisioningStorageBucket provision storage bucket based on generated tf
ProvisioningStorageBucket provision storage bucket based on generated tf
// ProvisioningStorageBucket provision storage bucket based on generated tf
func (r *PostgreSqlReconciler) ProvisioningStorageBucket(dir string, bucket *sqlv1alpha1.PostgreSql, ctx context.Context) error {
	err := terraform.Init(filepath.Join(dir, "bucket"))
	if err != nil {
		initMsg := fmt.Sprintf("initializing storage bucket failed %v", bucket.Spec.BucketConfig.Name)
		r.Log.Error(err, initMsg)
		errUp := r.UpdateStatus(ctx, bucket, sqlv1alpha1.PhaseFailed)
		r.Recorder.Eventf(bucket, kubeApiV1.EventTypeWarning, "InitializeFailed ", "failed to initialize storage bucket %q", bucket.Spec.BucketConfig.Name)
		if errUp != nil {
			return errUp
		}
		return err
	}
	err = terraform.Apply(filepath.Join(dir, "bucket"))
	if err != nil {
		applyMsg := fmt.Sprintf("provisioning storage bucket failed %v", bucket.Spec.BucketConfig.Name)
		r.Log.Error(err, applyMsg)
		errUp := r.UpdateStatus(ctx, bucket, sqlv1alpha1.PhaseFailed)
		r.Recorder.Eventf(bucket, kubeApiV1.EventTypeWarning, "ApplyingFailed ", "failed to provision storage bucket %q - bucket names must be unique", bucket.Spec.BucketConfig.Name)
		if errUp != nil {
			return errUp
		}
		return err
	}
	return nil
}
func ( r * PostgreSqlReconciler ) ProvisioningStorageBucket ( dir string , bucket * sqlv1alpha1 . PostgreSql , ctx context . Context ) error { err := terraform . Init ( filepath . Join ( dir , " " ) ) if err != nil { initMsg := fmt . Sprintf ( " " , bucket . Spec . BucketConfig . Name ) r . Log . Error ( err , initMsg ) errUp := r . UpdateStatus ( ctx , bucket , sqlv1alpha1 . PhaseFailed ) r . Recorder . Eventf ( bucket , kubeApiV1 . EventTypeWarning , " " , " " , bucket . Spec . BucketConfig . Name ) if errUp != nil { return errUp } return err } err = terraform . Apply ( filepath . Join ( dir , " " ) ) if err != nil { applyMsg := fmt . Sprintf ( " " , bucket . Spec . BucketConfig . Name ) r . Log . Error ( err , applyMsg ) errUp := r . UpdateStatus ( ctx , bucket , sqlv1alpha1 . PhaseFailed ) r . Recorder . Eventf ( bucket , kubeApiV1 . EventTypeWarning , " " , " " , bucket . Spec . BucketConfig . Name ) if errUp != nil { return errUp } return err } return nil }
ProvisioningStorageBucket provision storage bucket based on generated tf
ProvisioningStorageBucket provision storage bucket based on generated tf