Skip to content

Commit

Permalink
upgrade java gen, pulumi sdk, tf upstream, add patch for user agent
Browse files Browse the repository at this point in the history
Signed-off-by: ocobleseqx <[email protected]>
  • Loading branch information
ocobleseqx committed Nov 3, 2023
1 parent 6eb2267 commit d9dfd66
Show file tree
Hide file tree
Showing 372 changed files with 4,915 additions and 17,985 deletions.
1 change: 1 addition & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ builds:
ldflags:
# The line below MUST align with the module in current provider/go.mod
- -X github.com/equinix/pulumi-equinix/provider/pkg/version.Version={{.Tag }}
- -X github.com/equinix/terraform-provider-equinix/version.ProviderVersion|={{.Tag}}
main: ./cmd/pulumi-resource-equinix/
changelog:
skip: true
Expand Down
2 changes: 1 addition & 1 deletion .upgrade-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
upstream-provider-name: terraform-provider-equinix
remove-plugins: true
pr-reviewers: equinix/governor-devrel-engineering
javaVersion: "v0.9.5"
javaVersion: "v0.9.8"
54 changes: 24 additions & 30 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ TFGEN := pulumi-tfgen-${PACK}
PROVIDER := pulumi-resource-${PACK}
VERSION := $(shell pulumictl get version)
JAVA_GEN := pulumi-java-gen
JAVA_GEN_VERSION := v0.7.1
JAVA_GEN_VERSION := v0.9.8
JAVA_GROUP_ID := com.${ORG}.pulumi
JAVA_ARTIFACT_ID := ${PACK}
TESTPARALLELISM := 4
Expand All @@ -40,29 +40,27 @@ bin/pulumi-java-gen:
pulumictl download-binary -n pulumi-language-java -v $(JAVA_GEN_VERSION) -r pulumi/pulumi-java

provider: tfgen install_plugins # build the provider binary
(cd provider && go build -o $(WORKING_DIR)/bin/${PROVIDER} -ldflags "-X ${PROJECT}/${VERSION_PATH}=${VERSION}" ${PROJECT}/${PROVIDER_PATH}/cmd/${PROVIDER})
(cd provider && go build -o $(WORKING_DIR)/bin/${PROVIDER} -ldflags "-X ${PROJECT}/${VERSION_PATH}=${VERSION} -X github.com/equinix/terraform-provider-equinix/version.ProviderVersion=${VERSION}" ${PROJECT}/${PROVIDER_PATH}/cmd/${PROVIDER})

build_sdks: build_nodejs build_python build_go build_dotnet build_java # build all the sdks

build_nodejs: VERSION := $(shell pulumictl get version --language javascript)
build_nodejs: upstream
$(WORKING_DIR)/bin/$(TFGEN) nodejs --overlays provider/overlays/nodejs --out sdk/nodejs/
build_nodejs: patch_nodejs # fix generated files
build_nodejs:
echo "patch_nodejs: find and replace wrong imports in examples" && \
find ./sdk/nodejs/ -type f -name "*.ts" -not \( -path "*/bin/*" -o -path "*/node_modules/*" -o -path "*/@types/*" \) -print -exec sed -i.bak 's/import \* as ${PACK} from "@pulumi\/${PACK}"/import \* as ${PACK} from "@${ORG}-labs\/${NODE_PACK}"/g; s/import \* as ${NODE_PACK_ALIAS} from "@${ORG}\/${NODE_PACK}"/import \* as ${PACK} from "@${ORG}-labs\/${NODE_PACK}"/g' {} \;
echo "patch_nodejs: delete duplicate imports in examples" && \
find ./sdk/nodejs/ -type f -name "*.ts" -not \( -path "*/bin/*" -o -path "*/node_modules/*" -o -path "*/@types/*" \) -exec sed -i.bak '/@${ORG}-labs\/${NODE_PACK}/N;/^\(.*\)\n\1$$/!P; D' {} \;
echo "patch_nodejs: remove backup files" && \
find ./sdk/nodejs/ -type f -name "*.ts.bak" -not \( -path "*/bin/*" -o -path "*/node_modules/*" -o -path "*/@types/*" \) -print -exec /bin/rm {} \;
cd sdk/nodejs/ && \
printf "module fake_nodejs_module // Exclude this directory from Go tools\n\ngo 1.17\n" > go.mod && \
yarn install && \
yarn run tsc && \
cp ../../README.md ../../LICENSE package.json yarn.lock ./bin/ && \
sed -i.bak -e "s/\$${VERSION}/$(VERSION)/g" ./bin/package.json

patch_nodejs:
echo "patch_nodejs: find and replace wrong imports in examples" && \
find ./sdk/nodejs/ -type f -name "*.ts" -not \( -path "*/bin/*" -o -path "*/node_modules/*" -o -path "*/@types/*" \) -print -exec sed -i.bak 's/import \* as ${PACK} from "@pulumi\/${PACK}"/import \* as ${PACK} from "@${ORG}-labs\/${NODE_PACK}"/g; s/import \* as ${NODE_PACK_ALIAS} from "@${ORG}\/${NODE_PACK}"/import \* as ${PACK} from "@${ORG}-labs\/${NODE_PACK}"/g' {} \;
echo "patch_nodejs: delete duplicate imports in examples" && \
find ./sdk/nodejs/ -type f -name "*.ts" -not \( -path "*/bin/*" -o -path "*/node_modules/*" -o -path "*/@types/*" \) -exec sed -i.bak '/@${ORG}-labs\/${NODE_PACK}/N;/^\(.*\)\n\1$$/!P; D' {} \;
echo "patch_nodejs: remove backup files" && \
find ./sdk/nodejs/ -type f -name "*.ts.bak" -not \( -path "*/bin/*" -o -path "*/node_modules/*" -o -path "*/@types/*" \) -print -exec /bin/rm {} \;


build_python: PYPI_VERSION := $(shell pulumictl get version --language python)
build_python: upstream
Expand Down Expand Up @@ -93,29 +91,10 @@ build_java: PACKAGE_VERSION := $(shell pulumictl get version --language generic)
build_java: bin/pulumi-java-gen patch_java_schema upstream
$(WORKING_DIR)/bin/$(JAVA_GEN) generate --schema provider/cmd/$(PROVIDER)/schema-java.json --out sdk/java --build gradle-nexus
rm -f ./provider/cmd/$(PROVIDER)/schema-java.json
build_java: patch_java
cd sdk/java/ && \
printf "module fake_java_module // Exclude this directory from Go tools\n\ngo 1.17\n" > go.mod && \
gradle --console=plain build

patch_java_schema:
echo "patch_java_schema: copy schema.json to schema-java.json " && \
cp provider/cmd/$(PROVIDER)/schema.json provider/cmd/$(PROVIDER)/schema-java.json
echo "patch_java_schema: update schema-java.json to generate the SDK with pulumi as root package" && \
sed -i.bak -e 's/"name": "equinix",/"name": "pulumi",/g' \
-e 's/equinix:index/pulumi:index/g' \
-e 's/"equinix": "Equinix",/"pulumi": "Pulumi",/g' \
-e 's/equinix:metal/pulumi:metal/g' \
-e 's/equinix:fabric/pulumi:fabric/g' \
-e 's/equinix:networkedge/pulumi:networkedge/g' ./provider/cmd/$(PROVIDER)/schema-java.json && \
rm -f ./provider/cmd/$(PROVIDER)/schema-java.json.bak

patch_java:
echo "patch_java: find and replace invocations of pulumi:fabric/metal/networkedge" && \
find ./sdk/java/src/main/java/com/equinix/pulumi -type f -name "*.java" -print -exec sed -i.bak 's/pulumi:fabric/equinix:fabric/g; s/pulumi:metal/equinix:metal/g; s/pulumi:networkedge/equinix:networkedge/g' {} \;
echo "patch_java: remove backup files" && \
find ./sdk/java/src/main/java/com/equinix/pulumi -type f -name "*.java.bak" -exec /bin/rm {} \;

echo "patch_java: replace pulumi provider refs added in patch_java_schema" && \
cd sdk/java/src/main/java/com/equinix/pulumi/ && \
sed -i.bak -e 's/pulumi:providers:pulumi/pulumi:providers:equinix/g' \
Expand All @@ -136,6 +115,21 @@ patch_java:
-e 's/description = .*/description = "A Pulumi package for creating and managing equinix cloud resources."/g' ./build.gradle && \
sed -i.bak -E '/inceptionYear/,/packaging/s/(name = ).*/\1"$(PACK)"/' ./build.gradle && \
rm -f build.gradle.bak
cd sdk/java/ && \
printf "module fake_java_module // Exclude this directory from Go tools\n\ngo 1.17\n" > go.mod && \
gradle --console=plain build

patch_java_schema:
echo "patch_java_schema: copy schema.json to schema-java.json " && \
cp provider/cmd/$(PROVIDER)/schema.json provider/cmd/$(PROVIDER)/schema-java.json
echo "patch_java_schema: update schema-java.json to generate the SDK with pulumi as root package" && \
sed -i.bak -e 's/"name": "equinix",/"name": "pulumi",/g' \
-e 's/equinix:index/pulumi:index/g' \
-e 's/"equinix": "Equinix",/"pulumi": "Pulumi",/g' \
-e 's/equinix:metal/pulumi:metal/g' \
-e 's/equinix:fabric/pulumi:fabric/g' \
-e 's/equinix:networkedge/pulumi:networkedge/g' ./provider/cmd/$(PROVIDER)/schema-java.json && \
rm -f ./provider/cmd/$(PROVIDER)/schema-java.json.bak

lint_provider: provider # lint the provider code
cd provider && golangci-lint run -c ../.golangci.yml
Expand Down
10 changes: 9 additions & 1 deletion go.work.sum
Original file line number Diff line number Diff line change
Expand Up @@ -123,17 +123,19 @@ github.com/creack/pty v1.1.17/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr
github.com/creack/pty v1.1.18/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4=
github.com/dlclark/regexp2 v1.4.0/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc=
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
github.com/frankban/quicktest v1.14.3/go.mod h1:mgiwOwqx65TmIk1wJ6Q7wvnVMocbUorkibMOrVTHZps=
github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
github.com/golang-jwt/jwt v3.2.1+incompatible h1:73Z+4BJcrTC+KczS6WvTPvRGOp1WmfEP4Q1lOd9Z/+c=
github.com/google/pprof v0.0.0-20230406165453-00490a63f317/go.mod h1:79YE0hCXdHag9sBkw2o+N/YnZtTkXi0UT9Nnixa5eYk=
github.com/gorilla/css v1.0.0/go.mod h1:Dn721qIggHpt4+EFCcTLTU/vk5ySda2ReITrtgBl60c=
github.com/gruntwork-io/terratest v0.43.0/go.mod h1:vZO4J6UW023NDvl1vI+twZk9r//+QEaNT6MfkheH7z0=
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 h1:1/D3zfFHttUKaCaGKZ/dR2roBXv0vKbSCnssIldfQdI=
github.com/hinshun/vt10x v0.0.0-20220119200601-820417d04eec/go.mod h1:Q48J4R4DvxnHolD5P8pOtXigYlRuPLGl6moFx3ulM68=
github.com/hinshun/vt10x v0.0.0-20220301184237-5011da428d02/go.mod h1:Q48J4R4DvxnHolD5P8pOtXigYlRuPLGl6moFx3ulM68=
github.com/ijc/Gotty v0.0.0-20170406111628-a8b993ba6abd/go.mod h1:3LVOLeyx9XVvwPgrt2be44XgSqndprz1G18rSk8KD84=
github.com/jinzhu/copier v0.0.0-20190924061706-b57f9002281a/go.mod h1:yL958EeXv8Ylng6IfnvG4oflryUi3vgA3xPs9hmII1s=
github.com/liquidgecka/testlib v0.0.0-20180123051607-561e6b271c63/go.mod h1:vwMPvLIhXhkJaBfsk/6l+eDuiQaIVHC0b6eCvUVBsB0=
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I=
github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/mattn/go-zglob v0.0.2-0.20190814121620-e3c945676326/go.mod h1:9fxibJccNxU2cnpIKLRRFA7zX7qhkJIQWBb449FYHOo=
Expand All @@ -148,10 +150,16 @@ github.com/petar-dambovaliev/aho-corasick v0.0.0-20230725210150-fb29fc3c913e/go.
github.com/pgavlin/diff v0.0.0-20230503175810-113847418e2e/go.mod h1:WGwlmuPAiQTGQUjxyAfP7j4JgbgiFvFpI/qRtsQtS/4=
github.com/pgavlin/text v0.0.0-20230428184845-84c285f11d2f/go.mod h1:fk4+YyTLi0Ap0CsL1HA70/tAs6evqw3hbPGdR8rD/3E=
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE=
github.com/pulumi/pulumi-terraform-bridge/v3 v3.63.0/go.mod h1:6YVbDo019OeHkQWo9MnUbBy6cCgCQeoXZDjmR9SYmUA=
github.com/pulumi/pulumi/pkg/v3 v3.78.2-0.20231010213836-fd8c4dd81928/go.mod h1:6Fcjl5pVXv4ctBuluuDIYdq8DHc9da3erQJ1NI+ha94=
github.com/pulumi/pulumi/pkg/v3 v3.90.1/go.mod h1:J+WbfN30g3FfQifpLjQPI0UhPsC9ASEePLK8Nix06A8=
github.com/pulumi/pulumi/pkg/v3 v3.91.0/go.mod h1:sbx8Y+s6PJAronV8cs+V2OuRmUPGBLZzn9ciHumm9kw=
github.com/pulumi/pulumi/sdk/v3 v3.88.1-0.20231010213836-fd8c4dd81928/go.mod h1:M2j1xLl93+NYHtyprVK9Tdyxbnjs4AivPuAKqm5goCo=
github.com/pulumi/pulumi/sdk/v3 v3.90.1/go.mod h1:zYaQQibB2pYKy/uG4c4YkX7lQIBpZ0KsuMaq/3HsIBQ=
github.com/pulumi/pulumi/sdk/v3 v3.91.0/go.mod h1:zYaQQibB2pYKy/uG4c4YkX7lQIBpZ0KsuMaq/3HsIBQ=
github.com/russross/blackfriday v1.6.0 h1:KqfZb0pUVN2lYqZUYRddxF4OR8ZMURnJIG5Y3VRLtww=
github.com/shirou/gopsutil/v3 v3.22.3/go.mod h1:D01hZJ4pVHPpCTZ3m3T2+wDF2YAGfd+H4ifUguaQzHM=
github.com/spf13/cast v1.4.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
github.com/tklauser/go-sysconf v0.3.10/go.mod h1:C8XykCvCb+Gn0oNCWPIlcb0RuglQTYaQ2hGm7jmxEFk=
github.com/tklauser/numcpus v0.4.0/go.mod h1:1+UI3pD8NW14VMwdgJNJ1ESk2UnwhAnz5hMwiKKqXCQ=
github.com/tmccombs/hcl2json v0.3.3/go.mod h1:Y2chtz2x9bAeRTvSibVRVgbLJhLJXKlUeIvjeVdnm4w=
Expand Down
49 changes: 49 additions & 0 deletions patches/0001-user-agent.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
From 66f7739b91be84f7034d8232078d8313ec9be094 Mon Sep 17 00:00:00 2001
From: ocobleseqx <[email protected]>
Date: Tue, 31 Oct 2023 17:13:45 +0100
Subject: [PATCH] user agent

Signed-off-by: ocobleseqx <[email protected]>
---
equinix/config.go | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/equinix/config.go b/equinix/config.go
index 085100e..ebe0192 100644
--- a/equinix/config.go
+++ b/equinix/config.go
@@ -23,7 +23,6 @@ import (
"github.com/hashicorp/go-retryablehttp"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/logging"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
- "github.com/hashicorp/terraform-plugin-sdk/v2/meta"
"github.com/packethost/packngo"
xoauth2 "golang.org/x/oauth2"
)
@@ -266,9 +265,8 @@ func MetalRetryPolicy(ctx context.Context, resp *http.Response, err error) (bool
return false, nil
}

-func terraformUserAgent(version string) string {
- ua := fmt.Sprintf("HashiCorp Terraform/%s (+https://www.terraform.io) Terraform Plugin SDK/%s",
- version, meta.SDKVersionString())
+func pulumiUserAgent(version string) string {
+ ua := fmt.Sprintf("Pulumi/%s (+https://www.pulumi.com)", version)

if add := os.Getenv(uaEnvVar); add != "" {
add = strings.TrimSpace(add)
@@ -323,7 +321,9 @@ func generateModuleUserAgentString(d *schema.ResourceData, baseUserAgent string)
}

func (c *Config) fullUserAgent(suffix string) string {
- tfUserAgent := terraformUserAgent(c.terraformVersion)
- userAgent := fmt.Sprintf("%s terraform-provider-equinix/%s %s", tfUserAgent, version.ProviderVersion, suffix)
+ // FORK: this gives us the ability to add a Pulumi Specific user agent
+ // TODO (ocobles) override pulumi sdk version with ldflags
+ pulumiUserAgent := pulumiUserAgent("3.0")
+ userAgent := fmt.Sprintf("%s pulumi-equinix/%s %s", pulumiUserAgent, version.ProviderVersion, suffix)
return strings.TrimSpace(userAgent)
}
--
2.39.1

Empty file removed patches/README.md
Empty file.
18 changes: 18 additions & 0 deletions provider/cmd/pulumi-resource-equinix/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -7468,6 +7468,9 @@
"type": "string",
"secret": true
},
"sosHostname": {
"type": "string"
},
"sshKeyIds": {
"type": "array",
"items": {
Expand Down Expand Up @@ -7508,6 +7511,7 @@
"ports",
"projectId",
"rootPassword",
"sosHostname",
"sshKeyIds",
"state",
"storage",
Expand Down Expand Up @@ -10926,6 +10930,10 @@
"description": "Root password to the server (disabled after 24 hours).\n",
"secret": true
},
"sosHostname": {
"type": "string",
"description": "The hostname to use for [Serial over SSH](https://deploy.equinix.com/developers/docs/metal/resilience-recovery/serial-over-ssh/) access to the device\n"
},
"sshKeyIds": {
"type": "array",
"items": {
Expand Down Expand Up @@ -10990,6 +10998,7 @@
"ports",
"projectId",
"rootPassword",
"sosHostname",
"sshKeyIds",
"state",
"updated"
Expand Down Expand Up @@ -11343,6 +11352,10 @@
"description": "Root password to the server (disabled after 24 hours).\n",
"secret": true
},
"sosHostname": {
"type": "string",
"description": "The hostname to use for [Serial over SSH](https://deploy.equinix.com/developers/docs/metal/resilience-recovery/serial-over-ssh/) access to the device\n"
},
"sshKeyIds": {
"type": "array",
"items": {
Expand Down Expand Up @@ -16063,6 +16076,10 @@
"description": "Root password to the server (if still available).\n",
"secret": true
},
"sosHostname": {
"type": "string",
"description": "The hostname to use for [Serial over SSH](https://deploy.equinix.com/developers/docs/metal/resilience-recovery/serial-over-ssh/) access to the device\n"
},
"sshKeyIds": {
"type": "array",
"items": {
Expand Down Expand Up @@ -16106,6 +16123,7 @@
"ports",
"projectId",
"rootPassword",
"sosHostname",
"sshKeyIds",
"state",
"storage",
Expand Down
10 changes: 5 additions & 5 deletions provider/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ module github.com/equinix/pulumi-equinix/provider
go 1.21

replace (
github.com/equinix/terraform-provider-equinix => ../upstream
github.com/hashicorp/go-cty => github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320
github.com/hashicorp/terraform-plugin-sdk/v2 => github.com/pulumi/terraform-plugin-sdk/v2 v2.0.0-20230912190043-e6d96b3b8f7e
github.com/equinix/terraform-provider-equinix => ../upstream
)

require (
github.com/equinix/terraform-provider-equinix v1.18.0
github.com/pulumi/pulumi-terraform-bridge/v3 v3.62.0
github.com/pulumi/pulumi/pkg/v3 v3.90.0
github.com/pulumi/pulumi/sdk/v3 v3.90.0
github.com/equinix/terraform-provider-equinix v1.18.2
github.com/pulumi/pulumi-terraform-bridge/v3 v3.63.2
github.com/pulumi/pulumi/pkg/v3 v3.91.1
github.com/pulumi/pulumi/sdk/v3 v3.91.1
)

require (
Expand Down
Loading

0 comments on commit d9dfd66

Please sign in to comment.