Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix NOTEs on BucketReplicationConfigRules #5112

Merged
merged 5 commits into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions provider/cmd/pulumi-resource-aws/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -352139,7 +352139,7 @@
"items": {
"$ref": "#/types/aws:s3/BucketReplicationConfigRule:BucketReplicationConfigRule"
},
"description": "List of configuration blocks describing the rules managing the replication. See below.\n"
"description": "List of configuration blocks describing the rules managing the replication. See below.\n\u003e **NOTE:** Replication to multiple destination buckets requires that `priority` is specified in the `rule` object. If the corresponding rule requires no filter, an empty configuration block `filter {}` must be specified.\n\n\u003e **NOTE:** Amazon S3's latest version of the replication configuration is V2, which includes the `filter` attribute for replication rules.\n\n\u003e **NOTE:** The `existingObjectReplication` parameter is not supported by Amazon S3 at this time and should not be included in your `rule` configurations. Specifying this parameter will result in `MalformedXML` errors.\nTo replicate existing objects, please refer to the [Replicating existing objects with S3 Batch Replication](https://docs.aws.amazon.com/AmazonS3/latest/userguide/s3-batch-replication-batch.html) documentation in the Amazon S3 User Guide.\n"
},
"token": {
"type": "string",
Expand Down Expand Up @@ -352167,7 +352167,7 @@
"items": {
"$ref": "#/types/aws:s3/BucketReplicationConfigRule:BucketReplicationConfigRule"
},
"description": "List of configuration blocks describing the rules managing the replication. See below.\n"
"description": "List of configuration blocks describing the rules managing the replication. See below.\n\u003e **NOTE:** Replication to multiple destination buckets requires that `priority` is specified in the `rule` object. If the corresponding rule requires no filter, an empty configuration block `filter {}` must be specified.\n\n\u003e **NOTE:** Amazon S3's latest version of the replication configuration is V2, which includes the `filter` attribute for replication rules.\n\n\u003e **NOTE:** The `existingObjectReplication` parameter is not supported by Amazon S3 at this time and should not be included in your `rule` configurations. Specifying this parameter will result in `MalformedXML` errors.\nTo replicate existing objects, please refer to the [Replicating existing objects with S3 Batch Replication](https://docs.aws.amazon.com/AmazonS3/latest/userguide/s3-batch-replication-batch.html) documentation in the Amazon S3 User Guide.\n"
},
"token": {
"type": "string",
Expand Down Expand Up @@ -352197,7 +352197,7 @@
"items": {
"$ref": "#/types/aws:s3/BucketReplicationConfigRule:BucketReplicationConfigRule"
},
"description": "List of configuration blocks describing the rules managing the replication. See below.\n"
"description": "List of configuration blocks describing the rules managing the replication. See below.\n\u003e **NOTE:** Replication to multiple destination buckets requires that `priority` is specified in the `rule` object. If the corresponding rule requires no filter, an empty configuration block `filter {}` must be specified.\n\n\u003e **NOTE:** Amazon S3's latest version of the replication configuration is V2, which includes the `filter` attribute for replication rules.\n\n\u003e **NOTE:** The `existingObjectReplication` parameter is not supported by Amazon S3 at this time and should not be included in your `rule` configurations. Specifying this parameter will result in `MalformedXML` errors.\nTo replicate existing objects, please refer to the [Replicating existing objects with S3 Batch Replication](https://docs.aws.amazon.com/AmazonS3/latest/userguide/s3-batch-replication-batch.html) documentation in the Amazon S3 User Guide.\n"
},
"token": {
"type": "string",
Expand Down
72 changes: 71 additions & 1 deletion provider/doc_edits.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ func editRules(defaults []tfbridge.DocsEdit) []tfbridge.DocsEdit {
fixUpCloudFrontPublicKey,
fixUpEcsServiceNameTrigger,
fixUpEcsServiceNameForceNewDeployment,
fixUpBucketReplicationConfig,
// This fixes up strings such as:
//
// name = "terraform-kinesis-firehose-os",
Expand Down Expand Up @@ -68,7 +69,7 @@ func editRules(defaults []tfbridge.DocsEdit) []tfbridge.DocsEdit {
" `pulumi up --refresh`."+
" See [#4766](https://github.com/pulumi/pulumi-aws/issues/4766)"+
" for tracking making this work with regular `pulumi up`"),

targetedSimpleReplace("iam_policy_attachment.html.markdown", "Terraform", "Pulumi"),
)
}
Expand Down Expand Up @@ -108,6 +109,26 @@ func targetedSimpleReplace(filePath, from, to string) tfbridge.DocsEdit {
}
}

func targetedReplace(filePath, from, to string) tfbridge.DocsEdit {
fromBytes, toBytes := []byte(from), []byte(to)
return tfbridge.DocsEdit{
Path: filePath,
Edit: func(_ string, content []byte) ([]byte, error) {
if bytes.Contains(content, fromBytes) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately this does not ensure that toBytes does not digress, and yet we copied it from the source material. IN this case the toBytes is the bit that contains the notes we're copying.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're totally right. The new check is more specific to the situation and checks that both the added text and the fromBytes have not changed, else it errors.

content = bytes.ReplaceAll(
content,
fromBytes,
toBytes)
} else {
// Hard error to ensure we keep this content up to date
return nil, fmt.Errorf("could not find text in upstream %s, "+
"please verify replace content in doc_edits.go: %s", filePath, string(fromBytes))
}
return content, nil
},
}
}

var fixUpCloudFrontPublicKey = targetedSimpleReplace("cloudfront_public_key.html.markdown",
"* `name` - (Optional) The name for the public key. By default generated by this provider.",
"* `name` - (Optional) The name for the public key. By default generated by this provider. "+
Expand All @@ -134,6 +155,55 @@ var fixUpEcsServiceNameForceNewDeployment = targetedSimpleReplace(
"(e.g., `myimage:latest`), roll Fargate tasks onto a newer platform version, or immediately deploy "+
"`ordered_placement_strategy` and `placement_constraints` updates.\n"+
"When using the forceNewDeployment property you also need to configure the triggers property.\n")
var fixUpBucketReplicationConfig = tfbridge.DocsEdit{
Path: "s3_bucket_replication_configuration.html.markdown",
Edit: func(path string, content []byte) ([]byte, error) {
fromBytes := []byte(
"* `rule` - (Required) List of configuration blocks describing the rules managing the replication. " +
"[See below](#rule).\n")
toBytes := []byte(
"* `rule` - (Required) List of configuration blocks describing the rules managing the replication. " +
"[See below](#rule).\n" +
"~> **NOTE:** Replication to multiple destination buckets requires that `priority` is specified " +
"in the `rule` object. If the corresponding rule requires no filter, an empty configuration block " +
"`filter {}` must be specified." +
"\n\n~> **NOTE:** Amazon S3's latest version of the replication configuration is V2, " +
"which includes the `filter` attribute for replication rules.\n\n" +
"~> **NOTE:** The `existingObjectReplication` parameter is not supported by Amazon S3 at this time " +
"and should not be included in your `rule` configurations. " +
"Specifying this parameter will result in `MalformedXML` errors.\n" +
"To replicate existing objects, please refer to the " +
"[Replicating existing objects with S3 Batch Replication]" +
"(https://docs.aws.amazon.com/AmazonS3/latest/userguide/s3-batch-replication-batch.html) " +
"documentation in the Amazon S3 User Guide.\n",
)
noteBytes := []byte(
"~> **NOTE:** Replication to multiple destination buckets requires that `priority` is specified " +
"in the `rule` object. If the corresponding rule requires no filter, an empty configuration block " +
"`filter {}` must be specified." +
"\n\n~> **NOTE:** Amazon S3's latest version of the replication configuration is V2, " +
"which includes the `filter` attribute for replication rules.\n\n" +
"~> **NOTE:** The `existing_object_replication` parameter is not supported by Amazon S3 at this time " +
"and should not be included in your `rule` configurations. " +
"Specifying this parameter will result in `MalformedXML` errors.\n" +
"To replicate existing objects, please refer to the [Replicating existing objects with S3 Batch Replication]" +
"(https://docs.aws.amazon.com/AmazonS3/latest/userguide/s3-batch-replication-batch.html) " +
"documentation in the Amazon S3 User Guide.\n",
)

if bytes.Contains(content, noteBytes) && bytes.Contains(content, fromBytes) {
content = bytes.ReplaceAll(
content,
fromBytes,
toBytes)
} else {
// Hard error to ensure we keep this content up to date
return nil, fmt.Errorf("could not find NOTE snippets in upstream %s, "+
"please verify replace content in doc_edits.go: %s", path, string(noteBytes))
}
return content, nil
},
}

func reReplace(from string, to string) tfbridge.DocsEdit {
fromR, toB := regexp.MustCompile(from), []byte(to)
Expand Down
18 changes: 18 additions & 0 deletions sdk/dotnet/S3/BucketReplicationConfig.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading