Skip to content

Commit

Permalink
fix: update makefile to execute build_schema twice (#164)
Browse files Browse the repository at this point in the history
Changes:
- duplicate build_schema target (build and build_schema_post_examples)
to be able to execute it twice (it didn't work even adding build_schema
in PHONY). I was debugging leaving some traces to check that now it is
executed twice, as expected.
- Check that the pulumi cli installed version is the same as the one
defined in provider/go.mod
- Add `export PATH := $(BIN_DIR):$(PATH)`. The pulumi converter command
uses several plugins, on the one hand the source converter (yaml and
terraform plugins in our case) and on the other hand the sdk of the
language to which it is being converted, pulumi-language-python /
pulumi-language-go / etc. Although the correct Pulumi CLI binary was
being used with `.pulumi/bin/pulumi convert ...` it was taking the
language binary from $PATH, so in my case `/opt/homebrew/bin/` which
corresponded to the Pulumi v3.122.0 version instead of the new installed
v3.128.0

_Originally added to #161
and opening a new PR as per
#161 (comment)
suggestion_
  • Loading branch information
ocobles authored Aug 21, 2024
2 parents 54ceac9 + 54f6761 commit 02c05cc
Show file tree
Hide file tree
Showing 180 changed files with 3,493 additions and 3,494 deletions.
30 changes: 18 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
PROJECT_NAME := equinix Package

WORKING_DIR := $(shell pwd)
BIN_DIR := $(WORKING_DIR)/.pulumi/bin
PULUMICTL_BIN := $(BIN_DIR)/pulumictl
export PATH := $(BIN_DIR):$(PATH)

PULUMICTL_VERSION := v0.0.46

SHELL := /bin/bash
PACK := equinix
ORG := equinix
Expand All @@ -17,10 +24,6 @@ JAVA_GROUP_ID := com.${ORG}.pulumi
JAVA_ARTIFACT_ID := ${PACK}
TESTPARALLELISM := 4

WORKING_DIR := $(shell pwd)
BIN_DIR := $(WORKING_DIR)/.pulumi/bin
PULUMICTL_BIN := $(BIN_DIR)/pulumictl

OS := $(shell uname | tr '[:upper:]' '[:lower:]')
ARCH := $(shell uname -m)
ifeq ($(ARCH),x86_64)
Expand All @@ -29,8 +32,6 @@ endif

EMPTY_TO_AVOID_SED := ""

PULUMICTL_VERSION := v0.0.46

# estimated target version of the plugin that is currently being generated
VERSION = $(shell $(PULUMICTL_BIN) get version)
PACKAGE_VERSION = $(shell $(PULUMICTL_BIN) get version --language generic)
Expand All @@ -48,11 +49,11 @@ only_tfgen: install_plugins upstream build_schema
tfgen: only_tfgen generate_examples

# Generate examples after the schema is generated
generate_examples: examples build_schema
generate_examples: examples build_schema_post_examples

# Build the tfgen binary and generate the schema
build_schema: $(PULUMICTL_BIN)
build_schema:
build_schema build_schema_post_examples: $(PULUMICTL_BIN)
build_schema build_schema_post_examples:
(cd provider && go build -o $(WORKING_DIR)/bin/${TFGEN} -ldflags "-X ${PROJECT}/${VERSION_PATH}=${VERSION}" ${PROJECT}/${PROVIDER_PATH}/cmd/${TFGEN})
$(WORKING_DIR)/bin/${TFGEN} schema --out provider/cmd/${PROVIDER}
(cd provider && VERSION=$(VERSION) go generate cmd/${PROVIDER}/main.go)
Expand Down Expand Up @@ -214,7 +215,12 @@ upstream.rebase:
scripts/upstream_old.sh "$@" start_rebase

.pulumi/bin/pulumi: .pulumi/version
curl -fsSL https://get.pulumi.com | HOME=$(WORKING_DIR) sh -s -- --version $(cat .pulumi/version)
@if [ -x .pulumi/bin/pulumi ] && [ "v$$(cat .pulumi/version)" = "$$(.pulumi/bin/pulumi version)" ]; then \
echo "pulumi/bin/pulumi version: v$$(cat .pulumi/version)"; \
else \
curl -fsSL https://get.pulumi.com | \
HOME=$(WORKING_DIR) sh -s -- --version "$$(cat .pulumi/version)"; \
fi

$(PULUMICTL_BIN):
@mkdir -p $(BIN_DIR)
Expand All @@ -226,8 +232,8 @@ examples: install_equinix_plugin $(PULUMICTL_BIN)
scripts/generate_examples.sh

# Compute the version of Pulumi to use by inspecting the Go dependencies of the provider.
.pulumi/version:
.pulumi/version: provider/go.mod
@mkdir -p .pulumi
@cd provider && go list -f "{{slice .Version 1}}" -m github.com/pulumi/pulumi/pkg/v3 | tee ../$@

.PHONY: development build build_sdks install_go_sdk install_java_sdk install_python_sdk install_sdks only_build build_dotnet build_go build_java build_nodejs build_python clean cleanup help install_dotnet_sdk install_nodejs_sdk install_equinix_plugin uninstall_equinix_plugin install_plugins lint_provider provider test tfgen upstream upstream.finalize upstream.rebase test_provider examples examples_check
.PHONY: development build build_schema build_schema_post_examples build_sdks install_go_sdk install_java_sdk install_python_sdk install_sdks only_build build_dotnet build_go build_java build_nodejs build_python clean cleanup help install_dotnet_sdk install_nodejs_sdk install_equinix_plugin uninstall_equinix_plugin install_plugins lint_provider provider test tfgen upstream upstream.finalize upstream.rebase test_provider examples examples_check
38 changes: 19 additions & 19 deletions docs/resource/equinix_fabric_cloud_router.examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,28 +38,28 @@ import pulumi_equinix as equinix
new_cloud_router = equinix.fabric.CloudRouter("newCloudRouter",
name="Router-SV",
type="XF_ROUTER",
notifications=[equinix.fabric.CloudRouterNotificationArgs(
type="ALL",
emails=[
notifications=[{
"type": "ALL",
"emails": [
"[email protected]",
"[email protected]",
],
)],
order=equinix.fabric.CloudRouterOrderArgs(
purchase_order_number="1-323292",
),
location=equinix.fabric.CloudRouterLocationArgs(
metro_code="SV",
),
package=equinix.fabric.CloudRouterPackageArgs(
code="STANDARD",
),
project=equinix.fabric.CloudRouterProjectArgs(
project_id="776847000642406",
),
account=equinix.fabric.CloudRouterAccountArgs(
account_number=203612,
))
}],
order={
"purchase_order_number": "1-323292",
},
location={
"metro_code": "SV",
},
package={
"code": "STANDARD",
},
project={
"project_id": "776847000642406",
},
account={
"account_number": 203612,
})
```
```go
package main
Expand Down
Loading

0 comments on commit 02c05cc

Please sign in to comment.