Skip to content

Commit abdeb07

Browse files
authored
Merge pull request #18 from imagekit-developer/release-please--branches--master--changes--next
release: 2.5.0
2 parents 296ff56 + 3f686f2 commit abdeb07

21 files changed

Lines changed: 193 additions & 130 deletions

.github/workflows/ci.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ jobs:
2626
github.repository == 'stainless-sdks/imagekit-go' &&
2727
(github.event_name == 'push' || github.event.pull_request.head.repo.fork) && (github.event_name != 'push' || github.event.head_commit.message != 'codegen metadata')
2828
steps:
29-
- uses: actions/checkout@v6
29+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
3030

3131
- name: Get GitHub OIDC Token
3232
if: |-
3333
github.repository == 'stainless-sdks/imagekit-go' &&
3434
!startsWith(github.ref, 'refs/heads/stl/')
3535
id: github-oidc
36-
uses: actions/github-script@v8
36+
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
3737
with:
3838
script: core.setOutput('github_token', await core.getIDToken());
3939

@@ -53,10 +53,10 @@ jobs:
5353
if: github.event_name == 'push' || github.event.pull_request.head.repo.fork
5454

5555
steps:
56-
- uses: actions/checkout@v6
56+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
5757

5858
- name: Setup go
59-
uses: actions/setup-go@v5
59+
uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5.6.0
6060
with:
6161
go-version-file: ./go.mod
6262

@@ -68,10 +68,10 @@ jobs:
6868
runs-on: ${{ github.repository == 'stainless-sdks/imagekit-go' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
6969
if: github.event_name == 'push' || github.event.pull_request.head.repo.fork
7070
steps:
71-
- uses: actions/checkout@v6
71+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
7272

7373
- name: Setup go
74-
uses: actions/setup-go@v5
74+
uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5.6.0
7575
with:
7676
go-version-file: ./go.mod
7777

.release-please-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
".": "2.4.0"
2+
".": "2.5.0"
33
}

.stats.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 48
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-70c42eda2bee929830b2537f758400a58dded1f1ef5686a286e2469c35a041a0.yml
3-
openapi_spec_hash: cdaeed824e91657b45092765cf55eb42
4-
config_hash: e3c2679d25f6235381dfb11962fbf3d9
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc/imagekit-ad6dd3b4acf289708568a12574b997503059a47c4a4ca5ffefe64f40f3d3dbf3.yml
3+
openapi_spec_hash: 7c103e2dff0edcbeea82057e62f58d4d
4+
config_hash: 94f48fd13b7d41b8b6a203a3a8cee9ed

CHANGELOG.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,42 @@
11
# Changelog
22

3+
## 2.5.0 (2026-05-13)
4+
5+
Full Changelog: [v2.4.0...v2.5.0](https://github.com/imagekit-developer/imagekit-go/compare/v2.4.0...v2.5.0)
6+
7+
### Features
8+
9+
* **api:** add no-enlarge crop modes and colorize transformation ([ad25990](https://github.com/imagekit-developer/imagekit-go/commit/ad259909e99498bfda6beada5eaff2e87ffb2e54))
10+
* **api:** manual updates ([791dd8c](https://github.com/imagekit-developer/imagekit-go/commit/791dd8c9fa7b8e9ee247918f6aceffc77ad7f8cf))
11+
* **client:** add compatibility aliases for old type names ([b238a42](https://github.com/imagekit-developer/imagekit-go/commit/b238a423928c3f00584a4894bc1759e21bafb33d))
12+
* **go:** add default http client with timeout ([f4d5e6b](https://github.com/imagekit-developer/imagekit-go/commit/f4d5e6bc9096d5e51368b2aa8810c22352900643))
13+
* **helper:** add colorize transformation support and update tests ([53b441a](https://github.com/imagekit-developer/imagekit-go/commit/53b441a512d73384714df827ad202fb678d73a5e))
14+
* support setting headers via env ([3872a5e](https://github.com/imagekit-developer/imagekit-go/commit/3872a5eb58f1c091b8be08183dd4c972e8a68f75))
15+
* **tests:** comment update ([4bef04e](https://github.com/imagekit-developer/imagekit-go/commit/4bef04e89c89449faff1e6bf642ccc7158070790))
16+
17+
18+
### Bug Fixes
19+
20+
* **go:** avoid panic when http.DefaultTransport is wrapped ([c762867](https://github.com/imagekit-developer/imagekit-go/commit/c7628672829b9037cdae1851a93bb8f1304a9c86))
21+
22+
23+
### Chores
24+
25+
* avoid embedding reflect.Type for dead code elimination ([a8ce4c3](https://github.com/imagekit-developer/imagekit-go/commit/a8ce4c343ff55b3f698e96438167f340cddfc4c2))
26+
* configure new SDK language ([0951290](https://github.com/imagekit-developer/imagekit-go/commit/0951290e27f1568894dd90e717fc49612e24bedd))
27+
* **internal:** codegen related update ([1622f80](https://github.com/imagekit-developer/imagekit-go/commit/1622f80e1bae58177eae2b260e269e5b1b32de9a))
28+
* **internal:** codegen related update ([56516d9](https://github.com/imagekit-developer/imagekit-go/commit/56516d9f70279d35c597800d8c580ed18650e6d7))
29+
* **internal:** codegen related update ([14d3582](https://github.com/imagekit-developer/imagekit-go/commit/14d3582a90625f39b54ffb31000db0e35a849027))
30+
* **internal:** codegen related update ([904d9f3](https://github.com/imagekit-developer/imagekit-go/commit/904d9f3ebf4291f4142dcd99db48b832761fba7f))
31+
* **internal:** more robust bootstrap script ([5888120](https://github.com/imagekit-developer/imagekit-go/commit/5888120dc9032b1826cc0b7018f53f34db89666e))
32+
* **internal:** simplify release-please config ([48c9497](https://github.com/imagekit-developer/imagekit-go/commit/48c949735a94871559549cd63d9dd9bad83f4241))
33+
* redact api-key headers in debug logs ([add677a](https://github.com/imagekit-developer/imagekit-go/commit/add677afd39e072a7f0ef313f2a0f7d6ceff1f19))
34+
35+
36+
### Documentation
37+
38+
* remove example code for verifying webhook signatures ([799e47c](https://github.com/imagekit-developer/imagekit-go/commit/799e47c306c5f681891804c6e3ca738b0b2c053c))
39+
340
## 2.4.0 (2026-04-13)
441

542
Full Changelog: [v2.3.0...v2.4.0](https://github.com/imagekit-developer/imagekit-go/compare/v2.3.0...v2.4.0)

README.md

Lines changed: 3 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ Or to pin the version:
5959
<!-- x-release-please-start-version -->
6060

6161
```sh
62-
go get -u 'github.com/imagekit-developer/imagekit-go/v2@v2.4.0'
62+
go get -u 'github.com/imagekit-developer/imagekit-go/v2@v2.5.0'
6363
```
6464

6565
<!-- x-release-please-end -->
@@ -759,100 +759,10 @@ These authentication parameters can be used in client-side upload forms to secur
759759

760760
The ImageKit SDK provides utilities to verify webhook signatures for secure event handling. This ensures that webhook requests are actually coming from ImageKit and haven't been tampered with.
761761

762-
### Verifying webhook signatures
763-
764-
```go
765-
package main
766-
767-
import (
768-
"fmt"
769-
"io"
770-
"log"
771-
"net/http"
772-
"os"
773-
774-
"github.com/imagekit-developer/imagekit-go/v2"
775-
"github.com/imagekit-developer/imagekit-go/v2/option"
776-
)
777-
778-
func main() {
779-
client := imagekit.NewClient(
780-
option.WithPrivateKey("your_private_key"),
781-
option.WithWebhookSecret("whsec_..."), // Copy from ImageKit dashboard
782-
)
783-
784-
// Webhook handler with proper request body handling
785-
http.HandleFunc("/webhook", func(w http.ResponseWriter, req *http.Request) {
786-
// Limit request body size to prevent abuse (64KB should be sufficient for most webhooks)
787-
const MaxBodyBytes = int64(65536)
788-
req.Body = http.MaxBytesReader(w, req.Body, MaxBodyBytes)
789-
790-
// Read the raw webhook payload
791-
payload, err := io.ReadAll(req.Body)
792-
if err != nil {
793-
fmt.Fprintf(os.Stderr, "Error reading request body: %v\n", err)
794-
w.WriteHeader(http.StatusServiceUnavailable)
795-
return
796-
}
797-
798-
// Verify and unwrap webhook payload
799-
event, err := client.Webhooks.Unwrap(payload, req.Header)
800-
if err != nil {
801-
fmt.Fprintf(os.Stderr, "Invalid webhook signature or malformed payload: %v\n", err)
802-
w.WriteHeader(http.StatusUnauthorized)
803-
return
804-
}
805-
806-
fmt.Printf("Verified webhook event: %s\n", event.Type)
807-
808-
// Handle different event types with full type safety
809-
switch event.Type {
810-
case "video.transformation.accepted":
811-
videoEvent := event.AsVideoTransformationAcceptedEvent()
812-
fmt.Printf("Video transformation accepted: %s\n", videoEvent.Data.Asset.URL)
813-
// Debugging: Track transformation requests
814-
// handleVideoTransformationAccepted(videoEvent)
815-
816-
case "video.transformation.ready":
817-
videoEvent := event.AsVideoTransformationReadyEvent()
818-
fmt.Printf("Video transformation ready: %s\n", videoEvent.Data.Transformation.Output.URL)
819-
// Update your database/CMS to show the transformed video
820-
// handleVideoTransformationReady(videoEvent)
821-
822-
case "video.transformation.error":
823-
videoEvent := event.AsVideoTransformationErrorEvent()
824-
fmt.Printf("Video transformation error: %s\n", videoEvent.Data.Transformation.Error.Reason)
825-
// Log error and check your origin/URL endpoint settings
826-
// handleVideoTransformationError(videoEvent)
827-
828-
case "upload.pre-transform.success":
829-
uploadEvent := event.AsUploadPreTransformSuccessEvent()
830-
fmt.Printf("Pre-transform success: %s\n", uploadEvent.Data.FileID)
831-
// File uploaded and pre-transformation completed
832-
// handleUploadPreTransformSuccess(uploadEvent)
833-
834-
case "upload.post-transform.success":
835-
postEvent := event.AsUploadPostTransformSuccessEvent()
836-
fmt.Printf("Post-transform success: %s\n", postEvent.Data.Name)
837-
// Additional transformation completed
838-
// handleUploadPostTransformSuccess(postEvent)
839-
840-
// Handle other event types as needed
841-
default:
842-
fmt.Printf("Unhandled event type: %s\n", event.Type)
843-
}
844-
845-
w.WriteHeader(http.StatusOK)
846-
})
847-
848-
// Start the server
849-
fmt.Println("Webhook server listening on :8080")
850-
log.Fatal(http.ListenAndServe(":8080", nil))
851-
}
852-
```
853-
854762
For detailed information about webhook setup, signature verification, and handling different webhook events, refer to the [ImageKit webhook documentation](https://imagekit.io/docs/webhooks#verify-webhook-signature).
855763

764+
## Advanced Usage
765+
856766
### Errors
857767

858768
When the API returns a non-success status code, we return an error with type

aliases.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -831,6 +831,9 @@ const TransformationCropAtLeast = shared.TransformationCropAtLeast
831831
// Equals "maintain_ratio"
832832
const TransformationCropMaintainRatio = shared.TransformationCropMaintainRatio
833833

834+
// Equals "maintain_ratio_no_enlarge"
835+
const TransformationCropMaintainRatioNoEnlarge = shared.TransformationCropMaintainRatioNoEnlarge
836+
834837
// Additional crop modes for image resizing. See
835838
// [Crop modes & focus](https://imagekit.io/docs/image-resize-and-crop#crop-crop-modes--focus).
836839
//
@@ -846,6 +849,12 @@ const TransformationCropModeExtract = shared.TransformationCropModeExtract
846849
// Equals "pad_extract"
847850
const TransformationCropModePadExtract = shared.TransformationCropModePadExtract
848851

852+
// Equals "pad_resize_no_enlarge"
853+
const TransformationCropModePadResizeNoEnlarge = shared.TransformationCropModePadResizeNoEnlarge
854+
855+
// Equals "pad_extract_no_shrink"
856+
const TransformationCropModePadExtractNoShrink = shared.TransformationCropModePadExtractNoShrink
857+
849858
// Specifies the duration (in seconds) for trimming videos, e.g., `5` or `10.5`.
850859
// Typically used with startOffset to indicate the length from the start offset.
851860
// Arithmetic expressions are supported. See

client.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"net/http"
88
"os"
99
"slices"
10+
"strings"
1011

1112
"github.com/imagekit-developer/imagekit-go/v2/internal/requestconfig"
1213
"github.com/imagekit-developer/imagekit-go/v2/lib"
@@ -35,7 +36,7 @@ type Client struct {
3536
// OPTIONAL_IMAGEKIT_IGNORES_THIS, IMAGEKIT_WEBHOOK_SECRET, IMAGE_KIT_BASE_URL).
3637
// This should be used to initialize new clients.
3738
func DefaultClientOptions() []option.RequestOption {
38-
defaults := []option.RequestOption{option.WithEnvironmentProduction()}
39+
defaults := []option.RequestOption{option.WithHTTPClient(defaultHTTPClient()), option.WithEnvironmentProduction()}
3940
if o, ok := os.LookupEnv("IMAGE_KIT_BASE_URL"); ok {
4041
defaults = append(defaults, option.WithBaseURL(o))
4142
}
@@ -49,6 +50,14 @@ func DefaultClientOptions() []option.RequestOption {
4950
if o, ok := os.LookupEnv("IMAGEKIT_WEBHOOK_SECRET"); ok {
5051
defaults = append(defaults, option.WithWebhookSecret(o))
5152
}
53+
if o, ok := os.LookupEnv("IMAGE_KIT_CUSTOM_HEADERS"); ok {
54+
for _, line := range strings.Split(o, "\n") {
55+
colon := strings.Index(line, ":")
56+
if colon >= 0 {
57+
defaults = append(defaults, option.WithHeader(strings.TrimSpace(line[:colon]), strings.TrimSpace(line[colon+1:])))
58+
}
59+
}
60+
}
5261
return defaults
5362
}
5463

default_http_client.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
package imagekit
4+
5+
import (
6+
"net/http"
7+
"time"
8+
)
9+
10+
// defaultResponseHeaderTimeout bounds the time between a fully written request
11+
// and the server's response headers. It does not apply to the response body,
12+
// so long-running streams are unaffected. Without this, a server that accepts
13+
// the connection but never responds would hang the request indefinitely.
14+
const defaultResponseHeaderTimeout = 10 * time.Minute
15+
16+
// defaultHTTPClient returns an [*http.Client] used when the caller does not
17+
// supply one via [option.WithHTTPClient]. When [http.DefaultTransport] is the
18+
// stdlib [*http.Transport], it is cloned and a [http.Transport.ResponseHeaderTimeout]
19+
// is set so stuck connections fail fast instead of compounding across retries.
20+
// If [http.DefaultTransport] has been wrapped (for example by otelhttp for
21+
// distributed tracing), the wrapping is preserved and the header timeout is
22+
// skipped.
23+
func defaultHTTPClient() *http.Client {
24+
if t, ok := http.DefaultTransport.(*http.Transport); ok {
25+
t = t.Clone()
26+
t.ResponseHeaderTimeout = defaultResponseHeaderTimeout
27+
return &http.Client{Transport: t}
28+
}
29+
return &http.Client{Transport: http.DefaultTransport}
30+
}

dummy_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ func TestDummyNewWithOptionalParams(t *testing.T) {
174174
Background: imagekit.String("red"),
175175
Blur: imagekit.Float(10),
176176
Border: imagekit.String("5_FF0000"),
177+
Colorize: imagekit.String("colorize"),
177178
ColorProfile: imagekit.Bool(true),
178179
ColorReplace: imagekit.String("colorReplace"),
179180
ContrastStretch: true,
@@ -370,6 +371,7 @@ func TestDummyNewWithOptionalParams(t *testing.T) {
370371
Background: imagekit.String("red"),
371372
Blur: imagekit.Float(10),
372373
Border: imagekit.String("5_FF0000"),
374+
Colorize: imagekit.String("colorize"),
373375
ColorProfile: imagekit.Bool(true),
374376
ColorReplace: imagekit.String("colorReplace"),
375377
ContrastStretch: true,
@@ -713,6 +715,7 @@ func TestDummyNewWithOptionalParams(t *testing.T) {
713715
Background: imagekit.String("red"),
714716
Blur: imagekit.Float(10),
715717
Border: imagekit.String("5_FF0000"),
718+
Colorize: imagekit.String("colorize"),
716719
ColorProfile: imagekit.Bool(true),
717720
ColorReplace: imagekit.String("colorReplace"),
718721
ContrastStretch: true,
@@ -1012,6 +1015,7 @@ func TestDummyNewWithOptionalParams(t *testing.T) {
10121015
Background: imagekit.String("red"),
10131016
Blur: imagekit.Float(10),
10141017
Border: imagekit.String("5_FF0000"),
1018+
Colorize: imagekit.String("colorize"),
10151019
ColorProfile: imagekit.Bool(true),
10161020
ColorReplace: imagekit.String("colorReplace"),
10171021
ContrastStretch: true,
@@ -1202,6 +1206,7 @@ func TestDummyNewWithOptionalParams(t *testing.T) {
12021206
Background: imagekit.String("red"),
12031207
Blur: imagekit.Float(10),
12041208
Border: imagekit.String("5_FF0000"),
1209+
Colorize: imagekit.String("colorize"),
12051210
ColorProfile: imagekit.Bool(true),
12061211
ColorReplace: imagekit.String("colorReplace"),
12071212
ContrastStretch: true,

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module github.com/imagekit-developer/imagekit-go/v2
33
go 1.22
44

55
require (
6-
github.com/standard-webhooks/standard-webhooks/libraries v0.0.0-20260309172517-425968d811b9
6+
github.com/standard-webhooks/standard-webhooks/libraries v0.0.1
77
github.com/tidwall/gjson v1.18.0
88
github.com/tidwall/sjson v1.2.5
99
)

0 commit comments

Comments
 (0)