From 0d652a0925ffd4c63def5207bb04e506f8745608 Mon Sep 17 00:00:00 2001 From: Cory Hall <43035978+corymhall@users.noreply.github.com> Date: Tue, 19 Mar 2024 09:43:57 -0400 Subject: [PATCH] chore: add commands for debugging tfgen (#851) This PR adds two commands to make debugging `tfgen` for bridged providers easier. 1. `tfgen_build_only`: Only builds to `tfgen` binary, doesn't run generate. When debugging if you need to rebuild tfgen, you don't need to re-run all the other stuff too. 2. `debug_tfgen`: Starts `tfgen` as a debug server. Instructions on how to debug `tfgen` are being added to the docs in https://github.com/pulumi/pulumi-hugo/pull/4067 --- .../internal/pkg/templates/bridged-provider/Makefile | 9 ++++++++- provider-ci/test-workflows/aws/Makefile | 9 ++++++++- provider-ci/test-workflows/cloudflare/Makefile | 9 ++++++++- provider-ci/test-workflows/docker/Makefile | 9 ++++++++- 4 files changed, 32 insertions(+), 4 deletions(-) diff --git a/provider-ci/internal/pkg/templates/bridged-provider/Makefile b/provider-ci/internal/pkg/templates/bridged-provider/Makefile index 51770a7d17..f28cbaaa25 100644 --- a/provider-ci/internal/pkg/templates/bridged-provider/Makefile +++ b/provider-ci/internal/pkg/templates/bridged-provider/Makefile @@ -160,6 +160,9 @@ tfgen: install_plugins upstream#{{ if .Config.docsCmd }}# docs#{{ end }}# PULUMI_CONVERT=$(PULUMI_CONVERT) PULUMI_DISABLE_AUTOMATIC_PLUGIN_ACQUISITION=$(PULUMI_CONVERT) $(WORKING_DIR)/bin/$(TFGEN) schema --out provider/cmd/$(PROVIDER) (cd provider && VERSION=$(VERSION) go generate cmd/$(PROVIDER)/main.go) +tfgen_build_only: + (cd provider && go build $(PULUMI_PROVIDER_BUILD_PARALLELISM) -o $(WORKING_DIR)/bin/$(TFGEN) -ldflags "-X $(PROJECT)/$(VERSION_PATH)=$(VERSION)" $(PROJECT)/$(PROVIDER_PATH)/cmd/$(TFGEN)) + upstream: ifneq ("$(wildcard upstream)","") scripts/upstream.sh "$@" apply @@ -204,4 +207,8 @@ ci-mgmt: .ci-mgmt.yaml @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#{{ if .Config.docsCmd }}# docs#{{end}}# help install_dotnet_sdk install_nodejs_sdk install_plugins lint_provider provider provider_no_deps test tfgen upstream upstream.finalize upstream.rebase ci-mgmt test_provider +# Start debug server for tfgen +debug_tfgen: + dlv --listen=:2345 --headless=true --api-version=2 exec $(WORKING_DIR)/bin/$(TFGEN) -- schema --out provider/cmd/$(PROVIDER) + +.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#{{ if .Config.docsCmd }}# docs#{{end}}# help install_dotnet_sdk install_nodejs_sdk install_plugins lint_provider provider provider_no_deps test tfgen upstream upstream.finalize upstream.rebase ci-mgmt test_provider debug_tfgen tfgen_build_only diff --git a/provider-ci/test-workflows/aws/Makefile b/provider-ci/test-workflows/aws/Makefile index dadfae6aa9..855eac14c7 100644 --- a/provider-ci/test-workflows/aws/Makefile +++ b/provider-ci/test-workflows/aws/Makefile @@ -147,6 +147,9 @@ tfgen: install_plugins upstream PULUMI_CONVERT=$(PULUMI_CONVERT) PULUMI_DISABLE_AUTOMATIC_PLUGIN_ACQUISITION=$(PULUMI_CONVERT) $(WORKING_DIR)/bin/$(TFGEN) schema --out provider/cmd/$(PROVIDER) (cd provider && VERSION=$(VERSION) go generate cmd/$(PROVIDER)/main.go) +tfgen_build_only: + (cd provider && go build $(PULUMI_PROVIDER_BUILD_PARALLELISM) -o $(WORKING_DIR)/bin/$(TFGEN) -ldflags "-X $(PROJECT)/$(VERSION_PATH)=$(VERSION)" $(PROJECT)/$(PROVIDER_PATH)/cmd/$(TFGEN)) + upstream: ifneq ("$(wildcard upstream)","") scripts/upstream.sh "$@" apply @@ -187,4 +190,8 @@ ci-mgmt: .ci-mgmt.yaml @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_plugins lint_provider provider provider_no_deps test tfgen upstream upstream.finalize upstream.rebase ci-mgmt test_provider +# Start debug server for tfgen +debug_tfgen: + dlv --listen=:2345 --headless=true --api-version=2 exec $(WORKING_DIR)/bin/$(TFGEN) -- schema --out provider/cmd/$(PROVIDER) + +.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_plugins lint_provider provider provider_no_deps test tfgen upstream upstream.finalize upstream.rebase ci-mgmt test_provider debug_tfgen tfgen_build_only diff --git a/provider-ci/test-workflows/cloudflare/Makefile b/provider-ci/test-workflows/cloudflare/Makefile index 8286cb0c68..3ddc2baa10 100644 --- a/provider-ci/test-workflows/cloudflare/Makefile +++ b/provider-ci/test-workflows/cloudflare/Makefile @@ -142,6 +142,9 @@ tfgen: install_plugins upstream PULUMI_CONVERT=$(PULUMI_CONVERT) PULUMI_DISABLE_AUTOMATIC_PLUGIN_ACQUISITION=$(PULUMI_CONVERT) $(WORKING_DIR)/bin/$(TFGEN) schema --out provider/cmd/$(PROVIDER) (cd provider && VERSION=$(VERSION) go generate cmd/$(PROVIDER)/main.go) +tfgen_build_only: + (cd provider && go build $(PULUMI_PROVIDER_BUILD_PARALLELISM) -o $(WORKING_DIR)/bin/$(TFGEN) -ldflags "-X $(PROJECT)/$(VERSION_PATH)=$(VERSION)" $(PROJECT)/$(PROVIDER_PATH)/cmd/$(TFGEN)) + upstream: ifneq ("$(wildcard upstream)","") scripts/upstream.sh "$@" apply @@ -177,4 +180,8 @@ ci-mgmt: .ci-mgmt.yaml @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_plugins lint_provider provider provider_no_deps test tfgen upstream upstream.finalize upstream.rebase ci-mgmt test_provider +# Start debug server for tfgen +debug_tfgen: + dlv --listen=:2345 --headless=true --api-version=2 exec $(WORKING_DIR)/bin/$(TFGEN) -- schema --out provider/cmd/$(PROVIDER) + +.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_plugins lint_provider provider provider_no_deps test tfgen upstream upstream.finalize upstream.rebase ci-mgmt test_provider debug_tfgen tfgen_build_only diff --git a/provider-ci/test-workflows/docker/Makefile b/provider-ci/test-workflows/docker/Makefile index 40f0960a24..ed1df53e8c 100644 --- a/provider-ci/test-workflows/docker/Makefile +++ b/provider-ci/test-workflows/docker/Makefile @@ -144,6 +144,9 @@ tfgen: install_plugins upstream docs PULUMI_CONVERT=$(PULUMI_CONVERT) PULUMI_DISABLE_AUTOMATIC_PLUGIN_ACQUISITION=$(PULUMI_CONVERT) $(WORKING_DIR)/bin/$(TFGEN) schema --out provider/cmd/$(PROVIDER) (cd provider && VERSION=$(VERSION) go generate cmd/$(PROVIDER)/main.go) +tfgen_build_only: + (cd provider && go build $(PULUMI_PROVIDER_BUILD_PARALLELISM) -o $(WORKING_DIR)/bin/$(TFGEN) -ldflags "-X $(PROJECT)/$(VERSION_PATH)=$(VERSION)" $(PROJECT)/$(PROVIDER_PATH)/cmd/$(TFGEN)) + upstream: ifneq ("$(wildcard upstream)","") scripts/upstream.sh "$@" apply @@ -179,4 +182,8 @@ ci-mgmt: .ci-mgmt.yaml @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 docs help install_dotnet_sdk install_nodejs_sdk install_plugins lint_provider provider provider_no_deps test tfgen upstream upstream.finalize upstream.rebase ci-mgmt test_provider +# Start debug server for tfgen +debug_tfgen: + dlv --listen=:2345 --headless=true --api-version=2 exec $(WORKING_DIR)/bin/$(TFGEN) -- schema --out provider/cmd/$(PROVIDER) + +.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 docs help install_dotnet_sdk install_nodejs_sdk install_plugins lint_provider provider provider_no_deps test tfgen upstream upstream.finalize upstream.rebase ci-mgmt test_provider debug_tfgen tfgen_build_only