Skip to content

Commit

Permalink
Make patch to get new version of project settings before updating
Browse files Browse the repository at this point in the history
  • Loading branch information
jwdb committed Mar 20, 2024
1 parent 1b70c5d commit fca3092
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ development:: install_plugins provider lint_provider build_sdks install_sdks cle
build:: install_plugins provider build_sdks install_sdks
only_build:: build

tfgen:: install_plugins
tfgen:: install_plugins patch
touch $(WORKING_DIR)/provider/cmd/pulumi-resource-commercetools/schema-embed.json
(cd provider && go build -buildvcs=false -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}
Expand Down Expand Up @@ -121,3 +121,7 @@ install_sdks:: install_dotnet_sdk install_python_sdk install_nodejs_sdk

test::
cd examples && go test -v -tags=all -parallel ${TESTPARALLELISM} -timeout 2h

patch::
cp $(WORKING_DIR)/upstream_patches/* $(WORKING_DIR)/upstream/
find $(WORKING_DIR)/upstream/. -name "*.patch" -exec bash -c "cd $(WORKING_DIR)/upstream/ && git apply --whitespace=fix {}" \;
31 changes: 31 additions & 0 deletions upstream_patches/project_settings_state.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
diff --git a/internal/resources/project/resource.go b/internal/resources/project/resource.go
index 9c5ca44..73dac82 100644
--- a/internal/resources/project/resource.go
+++ b/internal/resources/project/resource.go
@@ -361,7 +361,25 @@ func (r *ProjectResource) Update(ctx context.Context, req resource.UpdateRequest
return
}

- input := state.updateActions(plan)
+ resState, errState := r.client.Get().Execute(ctx)
+ if errState != nil {
+ resp.Diagnostics.AddError(
+ "Error reading project",
+ "Could not retrieve project, unexpected error: "+errState.Error(),
+ )
+ return
+ }
+ current := NewProjectFromNative(resState)
+ current.setStateData(state)
+
+ // Set refreshed state
+ diags = resp.State.Set(ctx, current)
+ resp.Diagnostics.Append(diags...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ input := current.updateActions(plan)

var res *platform.Project
err := sdk_resource.RetryContext(ctx, 5*time.Second, func() *sdk_resource.RetryError {

0 comments on commit fca3092

Please sign in to comment.