Repository: cloudflare/cloudflare-go
Pull request #1489 (2024-01-30 08:07:22)

Add support for build_caching of Pages Project
<!-- 
Provide a general summary of your changes in the title above. You should
remove this overview, any sections and any section descriptions you
don't need below before submitting. There isn't a strict requirement to
use this template if you can structure your description and still cover
these points. 
-->

## Description

Fixes: https://github.com/cloudflare/cloudflare-go/issues/1488

<!--
Describe your changes in detail through motivation and context. Why is
this change required? What problem does it solve? If it fixes an open
issue, link to the issue using GitHub's closing issues keywords[1].
-->
## Has your change been tested?

I have fixed and passed the current unit tests.

<!--
Explain how the change has been tested and what you ran to confirm your
change affects other parts of the code. Automated tests are generally
expected and changes without tests should explain why they aren't
required.
-->

## Types of changes

What sort of change does your code introduce/modify?

- [ ] Bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)

## Checklist:

- [x] My code follows the code style of this project.
- [ ] My change requires a change to the documentation.
- [ ] I have updated the documentation accordingly.
- [x] I have added tests to cover my changes.
- [x] All new and existing tests passed.
- [x] This change is using publicly documented in [cloudflare/api-schemas](https://github.com/cloudflare/api-schemas) 
      and relies on stable APIs.

[1]: https://help.github.com/articles/closing-issues-using-keywords/



Patch:
diff --git a/.changelog/1489.txt b/.changelog/1489.txt
new file mode 100644
index 000000000..00fd540ec
--- /dev/null
+++ b/.changelog/1489.txt
@@ -0,0 +1,3 @@
+```release-note:enhancement
+pages_project: Add `build_caching` attribute
+```
diff --git a/pages_project.go b/pages_project.go
index 0aa7eeee8..202846158 100644
--- a/pages_project.go
+++ b/pages_project.go
@@ -53,6 +53,7 @@ type PagesProjectSourceConfig struct {
 
 // PagesProjectBuildConfig represents the configuration of a Pages project build process.
 type PagesProjectBuildConfig struct {
+	BuildCaching      *bool  `json:"build_caching,omitempty"`
 	BuildCommand      string `json:"build_command"`
 	DestinationDir    string `json:"destination_dir"`
 	RootDir           string `json:"root_dir"`


Test patch:
diff --git a/pages_project_test.go b/pages_project_test.go
index 3c4b7ecc0..49861c069 100644
--- a/pages_project_test.go
+++ b/pages_project_test.go
@@ -44,6 +44,7 @@ const (
           }
         },
         "build_config": {
+          "build_caching": true,
           "build_command": "npm run build",
           "destination_dir": "build",
           "root_dir": "/",
@@ -178,6 +179,7 @@ const (
             }
           ],
           "build_config": {
+            "build_caching": true,
             "build_command": "npm run build",
             "destination_dir": "build",
             "root_dir": "/",
@@ -269,6 +271,7 @@ const (
             }
           ],
           "build_config": {
+            "build_caching": true,
             "build_command": "npm run build",
             "destination_dir": "build",
             "root_dir": "/",
@@ -399,6 +402,7 @@ var (
 	}
 
 	expectedPagesProjectBuildConfig = &PagesProjectBuildConfig{
+		BuildCaching:      BoolPtr(true),
 		BuildCommand:      "npm run build",
 		DestinationDir:    "build",
 		RootDir:           "/",