Skip to content

Commit

Permalink
Export patches to local repo (#2414)
Browse files Browse the repository at this point in the history
* Export patches to local repo

Skip running upstream patch export if shallow:
- Git will fail if our upstream checkout is shallow (e.g. in CI).
- Refactor exporting upstream patches into its own target.

* Generate initial patches
  • Loading branch information
danielrbradley committed Apr 12, 2023
1 parent 24437c0 commit e466d93
Show file tree
Hide file tree
Showing 28 changed files with 10,872 additions and 1 deletion.
12 changes: 11 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,17 @@ init_upstream:
(cd upstream && git submodule update --init && git remote add source git@github.com:hashicorp/terraform-provider-aws.git) ; \
fi; \

patch_upstream: init_upstream
export_upstream_patches: init_upstream
ifeq ($(shell cd upstream && git rev-parse --is-shallow-repository), false)
find upstream-patches -type f -delete
cd upstream && \
# Find the most recent tag before the current checkout - don't abbreviate the tag name
LAST_TAG=$$(git describe --abbrev=0 --tags) && \
# Create patch files for each commit since the last tag
git format-patch -o ../upstream-patches --minimal --no-signature HEAD...$${LAST_TAG}
endif

patch_upstream: init_upstream export_upstream_patches
@# Ensure tool is installed
cd upstream-tools && yarn install --frozen-lockfile
@# Reset all changes in the submodule so we're starting from a clean slate
Expand Down
25 changes: 25 additions & 0 deletions upstream-patches/0001-Add-TagsSchemaTrulyComputed-definition.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
From 37903a1ae190d03d0020cf884295dcb15c5357b4 Mon Sep 17 00:00:00 2001
From: Daniel Bradley <daniel@pulumi.com>
Date: Fri, 4 Nov 2022 16:49:08 +0000
Subject: [PATCH 01/27] Add TagsSchemaTrulyComputed definition

---
internal/tags/tags.go | 8 ++++++++
1 file changed, 8 insertions(+)

diff --git a/internal/tags/tags.go b/internal/tags/tags.go
index 30b491fc7a..ea00250a50 100644
--- a/internal/tags/tags.go
+++ b/internal/tags/tags.go
@@ -39,3 +39,11 @@ func TagsSchemaForceNew() *schema.Schema {
Elem: &schema.Schema{Type: schema.TypeString},
}
}
+
+func TagsSchemaTrulyComputed() *schema.Schema {
+ return &schema.Schema{
+ Type: schema.TypeMap,
+ Computed: true,
+ Elem: &schema.Schema{Type: schema.TypeString},
+ }
+}
37 changes: 37 additions & 0 deletions upstream-patches/0002-Conns-user-agent.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
From b244c2ee2834b692433a165dfbd16296bec36398 Mon Sep 17 00:00:00 2001
From: Daniel Bradley <daniel@pulumi.com>
Date: Fri, 4 Nov 2022 17:03:31 +0000
Subject: [PATCH 02/27] Conns user agent

Replace the useragent used for AWS client connections with a
Pulumi-flavoured one.
---
internal/conns/conns.go | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/internal/conns/conns.go b/internal/conns/conns.go
index eeba6699b4..9fd480f5cd 100644
--- a/internal/conns/conns.go
+++ b/internal/conns/conns.go
@@ -9,7 +9,6 @@ import (
awsbase "github.com/hashicorp/aws-sdk-go-base/v2"
awsbasev1 "github.com/hashicorp/aws-sdk-go-base/v2/awsv1shim/v2"
"github.com/hashicorp/terraform-provider-aws/internal/types"
- "github.com/hashicorp/terraform-provider-aws/version"
)

// ServicePackage is the minimal interface exported from each AWS service package.
@@ -66,10 +65,10 @@ func NewSessionForRegion(cfg *aws.Config, region, terraformVersion string) (*ses

func StdUserAgentProducts(terraformVersion string) *awsbase.APNInfo {
return &awsbase.APNInfo{
- PartnerName: "HashiCorp",
+ PartnerName: "Pulumi",
Products: []awsbase.UserAgentProduct{
- {Name: "Terraform", Version: terraformVersion, Comment: "+https://www.terraform.io"},
- {Name: "terraform-provider-aws", Version: version.ProviderVersion, Comment: "+https://registry.terraform.io/providers/hashicorp/aws"},
+ {Name: "Pulumi", Version: "1.0"},
+ {Name: "Pulumi-Aws", Version: terraformVersion, Comment: "+https://www.pulumi.com"},
},
}
}

0 comments on commit e466d93

Please sign in to comment.