-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: restore pg cluster implementation
- Loading branch information
1 parent
b045931
commit 85bede1
Showing
4 changed files
with
213 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package models | ||
|
||
import ( | ||
commonApi "github.com/EnterpriseDB/terraform-provider-biganimal/pkg/models/common/api" | ||
) | ||
|
||
type RestoreCluster struct { | ||
AllowedIpRanges *[]AllowedIpRange `json:"allowedIpRanges,omitempty"` | ||
BackupRetentionPeriod *string `json:"backupRetentionPeriod,omitempty"` | ||
ClusterArchitecture *Architecture `json:"clusterArchitecture,omitempty" mapstructure:"cluster_architecture"` | ||
ClusterName *string `json:"clusterName,omitempty"` | ||
ClusterType *string `json:"clusterType,omitempty"` | ||
CSPAuth *bool `json:"cspAuth,omitempty"` | ||
InstanceType *InstanceType `json:"instanceType,omitempty"` | ||
Password *string `json:"password,omitempty"` | ||
PgConfig *[]KeyValue `json:"pgConfig,omitempty"` | ||
Phase *string `json:"phase,omitempty"` | ||
ReadOnlyConnections *bool `json:"readOnlyConnections,omitempty"` | ||
Region *Region `json:"region,omitempty"` | ||
ResizingPvc []string `json:"resizingPvc,omitempty"` | ||
Storage *Storage `json:"storage,omitempty"` | ||
MaintenanceWindow *commonApi.MaintenanceWindow `json:"maintenanceWindow,omitempty"` | ||
ServiceAccountIds *[]string `json:"serviceAccountIds,omitempty"` | ||
PeAllowedPrincipalIds *[]string `json:"peAllowedPrincipalIds,omitempty"` | ||
SuperuserAccess *bool `json:"superuserAccess,omitempty"` | ||
RestorePoint *string `json:"selectedRestorePointInTime,omitempty"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package plan_modifier | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" | ||
) | ||
|
||
// CustomRestoreClusterId returns a plan modifier that copies a known prior state | ||
// value into the planned value. Use this when it is known that an unconfigured | ||
// value will remain the same after a resource update. | ||
// | ||
// To prevent Terraform errors, the framework automatically sets unconfigured | ||
// and Computed attributes to an unknown value "(known after apply)" on update. | ||
// Using this plan modifier will instead display the prior state value in the | ||
// plan, unless a prior plan modifier adjusts the value. | ||
func CustomRestoreClusterId() planmodifier.String { | ||
return customRestoreClusterIdModifier{} | ||
} | ||
|
||
// customRestoreClusterIdModifier implements the plan modifier. | ||
type customRestoreClusterIdModifier struct{} | ||
|
||
// Description returns a human-readable description of the plan modifier. | ||
func (m customRestoreClusterIdModifier) Description(_ context.Context) string { | ||
return "Once set, the value of this attribute in state will not change." | ||
} | ||
|
||
// MarkdownDescription returns a markdown description of the plan modifier. | ||
func (m customRestoreClusterIdModifier) MarkdownDescription(_ context.Context) string { | ||
return "Once set, the value of this attribute in state will not change." | ||
} | ||
|
||
// PlanModifyString implements the plan modification logic. | ||
func (m customRestoreClusterIdModifier) PlanModifyString(ctx context.Context, req planmodifier.StringRequest, resp *planmodifier.StringResponse) { | ||
if !req.PlanValue.IsNull() { | ||
resp.Diagnostics.AddWarning( | ||
"You are restoring cluster", | ||
fmt.Sprint("You are restoring a cluster. After restoring the cluster, please remove field 'restore_cluster_id' and optionally remove fields 'restore_from_deleted' and 'restore_point' from the config"), | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters