-
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.
Merge branch 'main' into ww-scheduled-backup-time
# Conflicts: # pkg/models/cluster.go # pkg/models/pgd/api/data_group.go # pkg/models/pgd/terraform/data_group.go # pkg/provider/common.go # pkg/provider/data_source_cluster.go # pkg/provider/data_source_fareplica.go # pkg/provider/data_source_pgd.go # pkg/provider/resource_cluster.go # pkg/provider/resource_fareplica.go # pkg/provider/resource_pgd.go
- Loading branch information
Showing
29 changed files
with
327 additions
and
25 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
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
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
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
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
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
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
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
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
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,59 @@ | ||
package plan_modifier | ||
|
||
import ( | ||
"context" | ||
"strings" | ||
|
||
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" | ||
"github.com/hashicorp/terraform-plugin-go/tftypes" | ||
) | ||
|
||
func CustomClusterCloudProvider() planmodifier.String { | ||
return customCloudProviderModifier{} | ||
} | ||
|
||
type customCloudProviderModifier struct{} | ||
|
||
func (m customCloudProviderModifier) Description(_ context.Context) string { | ||
return "Once set, the value of this attribute in state will not change." | ||
} | ||
|
||
func (m customCloudProviderModifier) MarkdownDescription(_ context.Context) string { | ||
return "Once set, the value of this attribute in state will not change." | ||
} | ||
|
||
func (m customCloudProviderModifier) PlanModifyString(ctx context.Context, req planmodifier.StringRequest, resp *planmodifier.StringResponse) { | ||
cloudProviderConfig := req.ConfigValue.ValueString() | ||
var configObject map[string]tftypes.Value | ||
|
||
err := req.Config.Raw.As(&configObject) | ||
if err != nil { | ||
resp.Diagnostics.AddError("Mapping config object in custom cloud provider modifier error", err.Error()) | ||
return | ||
} | ||
|
||
if !strings.Contains(cloudProviderConfig, "bah") { | ||
peIds, ok := configObject["pe_allowed_principal_ids"] | ||
if ok && !peIds.IsNull() { | ||
resp.Diagnostics.AddError("your cloud account 'pe_allowed_principal_ids' field not allowed error", | ||
"field 'pe_allowed_principal_ids' should only be set if you are using BigAnimal's cloud account e.g. 'bah:aws', please remove 'pe_allowed_principal_ids'") | ||
return | ||
} | ||
|
||
saIds, ok := configObject["service_account_ids"] | ||
if ok && !saIds.IsNull() { | ||
resp.Diagnostics.AddError("your cloud account 'service_account_ids' field not allowed error", | ||
"field 'service_account_ids' should only be set if you are using BigAnimal's cloud account 'bah:gcp', please remove 'service_account_ids'") | ||
return | ||
} | ||
} | ||
|
||
if strings.Contains(cloudProviderConfig, "bah") && !strings.Contains(cloudProviderConfig, "bah:gcp") { | ||
saIds, ok := configObject["service_account_ids"] | ||
if ok && !saIds.IsNull() { | ||
resp.Diagnostics.AddError("your cloud account 'service_account_ids' field not allowed error", | ||
"you are not using cloud provider 'bah:gcp', field 'service_account_ids' should only be set if you are using cloud provider 'bah:gcp', please remove 'service_account_ids'") | ||
return | ||
} | ||
} | ||
} |
Oops, something went wrong.