@@ -61,23 +61,26 @@ ifneq ($(SKIP_CLEAN),)
6161 endif
6262endif
6363
64- terraform build provider : validate_environment clean-provider mmv1 tpgtools
64+ TEMP_DIR := $(shell mktemp -d)
65+ export TEMP_DIR
66+
67+ terraform build provider : validate_environment clean-provider mmv1 tpgtools clean-temp
6568 @echo " Provider generation process finished for $( VERSION) in $( OUTPUT_PATH) "
6669
6770
68- mmv1 :
71+ mmv1 : prepare-temp
6972 @echo " Executing mmv1 build for $( OUTPUT_PATH) " ;
70- @cd mmv1; \
73+ @cd $( TEMP_DIR ) / mmv1; \
7174 if [ " $( VERSION) " = " ga" ]; then \
7275 go run . --output $(OUTPUT_PATH ) --version ga --no-docs $(mmv1_compile ) \
7376 && go run . --output $(OUTPUT_PATH ) --version beta --no-code $(mmv1_compile ) ; \
7477 else \
7578 go run . --output $(OUTPUT_PATH ) --version $(VERSION ) $(mmv1_compile ) ; \
7679 fi
7780
78- tpgtools : serialize
81+ tpgtools : prepare-temp serialize
7982 @echo " Executing tpgtools build for $( OUTPUT_PATH) " ;
80- @cd tpgtools; \
83+ @cd $( TEMP_DIR ) / tpgtools; \
8184 go run . --output $(OUTPUT_PATH ) --version $(VERSION ) $(tpgtools_compile ) ; \
8285 rm serialization.go
8386
@@ -137,7 +140,7 @@ test:
137140 go test ./...
138141
139142serialize :
140- cd tpgtools; \
143+ cd $( TEMP_DIR ) / tpgtools; \
141144 cp -f serialization.go.base serialization.go && \
142145 go run . $(serialize_compile ) --mode " serialization" > temp.serial && \
143146 mv -f temp.serial serialization.go
@@ -175,4 +178,36 @@ check_safe_build:
175178doctor :
176179 ./scripts/doctor
177180
178- .PHONY : mmv1 tpgtools test clean-provider validate_environment serialize doctor
181+
182+ prepare-temp :
183+
184+ @echo "Setting up temporary workspace for conversion at $(TEMP_DIR)..."
185+ @rm -rf $(TEMP_DIR)
186+ @mkdir -p $(TEMP_DIR)/mmv1 $(TEMP_DIR)/tpgtools $(TEMP_DIR)/tools
187+ @cp -R ./mmv1/ $(TEMP_DIR)/mmv1/
188+ @cp -R ./tpgtools/ $(TEMP_DIR)/tpgtools/
189+ @cp -R ./tools/ $(TEMP_DIR)/tools/
190+ @echo "Building and running resource template converter in temp..."
191+ @echo "Building resource template converter in temp..."
192+ cd $(TEMP_DIR)/tools/resource-template-converter && go env -w GO111MODULE=on && go mod tidy && go build -v -o $(TEMP_DIR)/tools/convert-resource-template .
193+ @echo "Build finished, running converter..."
194+ @ls -la $(TEMP_DIR)/tools/convert-resource-template
195+ @$(TEMP_DIR)/tools/convert-resource-template convert-resource-template $(TEMP_DIR)
196+ @echo "Temporary workspace setup complete."
197+
198+ test-convert :
199+ @echo $(TEMP_DIR )
200+
201+ clean-temp :
202+ @echo " Cleaning up temporary workspace $( TEMP_DIR) ..."
203+ @rm -rf $(TEMP_DIR )
204+
205+ convert-templates :
206+ @echo " Checking and running resource template converter..."
207+ @if [ ! -f ./convert-resource-template ]; then \
208+ echo " Building convert-resource-template tool..." ; \
209+ (cd tools/resource-template-converter && go build -o ../../convert-resource-template); \
210+ fi
211+ @./convert-resource-template convert-resource-template .
212+
213+ .PHONY : mmv1 tpgtools test clean-provider validate_environment serialize doctor convert-templates prepare-temp clean-temp
0 commit comments