From 80b9e2b14e06850bda8d96cb4bdbcc611d9684d8 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 17 Jun 2025 05:17:19 +0000 Subject: [PATCH 1/9] feat(client): add debug log helper --- option/middleware.go | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 option/middleware.go diff --git a/option/middleware.go b/option/middleware.go new file mode 100644 index 0000000..8ec9dd6 --- /dev/null +++ b/option/middleware.go @@ -0,0 +1,38 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +package option + +import ( + "log" + "net/http" + "net/http/httputil" +) + +// WithDebugLog logs the HTTP request and response content. +// If the logger parameter is nil, it uses the default logger. +// +// WithDebugLog is for debugging and development purposes only. +// It should not be used in production code. The behavior and interface +// of WithDebugLog is not guaranteed to be stable. +func WithDebugLog(logger *log.Logger) RequestOption { + return WithMiddleware(func(req *http.Request, nxt MiddlewareNext) (*http.Response, error) { + if logger == nil { + logger = log.Default() + } + + if reqBytes, err := httputil.DumpRequest(req, true); err == nil { + logger.Printf("Request Content:\n%s\n", reqBytes) + } + + resp, err := nxt(req) + if err != nil { + return resp, err + } + + if respBytes, err := httputil.DumpResponse(resp, true); err == nil { + logger.Printf("Response Content:\n%s\n", respBytes) + } + + return resp, err + }) +} From 2c731e32d19595c013749cea2a7a8c50603aa0a4 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 17 Jun 2025 06:41:45 +0000 Subject: [PATCH 2/9] chore(ci): enable for pull requests --- .github/workflows/ci.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f7a52ab..105b972 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,6 +7,10 @@ on: - 'integrated/**' - 'stl-preview-head/**' - 'stl-preview-base/**' + pull_request: + branches-ignore: + - 'stl-preview-head/**' + - 'stl-preview-base/**' jobs: lint: From 8d9d6fb9ca5a3913d0400620dd18686290f8e57d Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 27 Jun 2025 06:36:39 +0000 Subject: [PATCH 3/9] fix(pagination): check if page data is empty in GetNextPage --- packages/pagination/pagination.go | 63 +++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/packages/pagination/pagination.go b/packages/pagination/pagination.go index ad46709..88ab34c 100644 --- a/packages/pagination/pagination.go +++ b/packages/pagination/pagination.go @@ -60,6 +60,9 @@ func (r domainVerificationsPageJSON) RawJSON() string { // there is no next page, this function will return a 'nil' for the page value, but // will not return an error func (r *DomainVerificationsPage[T]) GetNextPage() (res *DomainVerificationsPage[T], err error) { + if len(r.DomainVerifications) == 0 { + return nil, nil + } next := r.Pagination.NextToken if len(next) == 0 { return nil, nil @@ -181,6 +184,9 @@ func (r editorsPageJSON) RawJSON() string { // there is no next page, this function will return a 'nil' for the page value, but // will not return an error func (r *EditorsPage[T]) GetNextPage() (res *EditorsPage[T], err error) { + if len(r.Editors) == 0 { + return nil, nil + } next := r.Pagination.NextToken if len(next) == 0 { return nil, nil @@ -302,6 +308,9 @@ func (r entriesPageJSON) RawJSON() string { // there is no next page, this function will return a 'nil' for the page value, but // will not return an error func (r *EntriesPage[T]) GetNextPage() (res *EntriesPage[T], err error) { + if len(r.Entries) == 0 { + return nil, nil + } next := r.Pagination.NextToken if len(next) == 0 { return nil, nil @@ -424,6 +433,9 @@ func (r environmentClassesPageJSON) RawJSON() string { // there is no next page, this function will return a 'nil' for the page value, but // will not return an error func (r *EnvironmentClassesPage[T]) GetNextPage() (res *EnvironmentClassesPage[T], err error) { + if len(r.EnvironmentClasses) == 0 { + return nil, nil + } next := r.Pagination.NextToken if len(next) == 0 { return nil, nil @@ -546,6 +558,9 @@ func (r environmentsPageJSON) RawJSON() string { // there is no next page, this function will return a 'nil' for the page value, but // will not return an error func (r *EnvironmentsPage[T]) GetNextPage() (res *EnvironmentsPage[T], err error) { + if len(r.Environments) == 0 { + return nil, nil + } next := r.Pagination.NextToken if len(next) == 0 { return nil, nil @@ -667,6 +682,9 @@ func (r gatewaysPageJSON) RawJSON() string { // there is no next page, this function will return a 'nil' for the page value, but // will not return an error func (r *GatewaysPage[T]) GetNextPage() (res *GatewaysPage[T], err error) { + if len(r.Gateways) == 0 { + return nil, nil + } next := r.Pagination.NextToken if len(next) == 0 { return nil, nil @@ -788,6 +806,9 @@ func (r groupsPageJSON) RawJSON() string { // there is no next page, this function will return a 'nil' for the page value, but // will not return an error func (r *GroupsPage[T]) GetNextPage() (res *GroupsPage[T], err error) { + if len(r.Groups) == 0 { + return nil, nil + } next := r.Pagination.NextToken if len(next) == 0 { return nil, nil @@ -910,6 +931,9 @@ func (r integrationsPageJSON) RawJSON() string { // there is no next page, this function will return a 'nil' for the page value, but // will not return an error func (r *IntegrationsPage[T]) GetNextPage() (res *IntegrationsPage[T], err error) { + if len(r.Integrations) == 0 { + return nil, nil + } next := r.Pagination.NextToken if len(next) == 0 { return nil, nil @@ -1032,6 +1056,9 @@ func (r loginProvidersPageJSON) RawJSON() string { // there is no next page, this function will return a 'nil' for the page value, but // will not return an error func (r *LoginProvidersPage[T]) GetNextPage() (res *LoginProvidersPage[T], err error) { + if len(r.LoginProviders) == 0 { + return nil, nil + } next := r.Pagination.NextToken if len(next) == 0 { return nil, nil @@ -1153,6 +1180,9 @@ func (r membersPageJSON) RawJSON() string { // there is no next page, this function will return a 'nil' for the page value, but // will not return an error func (r *MembersPage[T]) GetNextPage() (res *MembersPage[T], err error) { + if len(r.Members) == 0 { + return nil, nil + } next := r.Pagination.NextToken if len(next) == 0 { return nil, nil @@ -1275,6 +1305,9 @@ func (r personalAccessTokensPageJSON) RawJSON() string { // there is no next page, this function will return a 'nil' for the page value, but // will not return an error func (r *PersonalAccessTokensPage[T]) GetNextPage() (res *PersonalAccessTokensPage[T], err error) { + if len(r.PersonalAccessTokens) == 0 { + return nil, nil + } next := r.Pagination.NextToken if len(next) == 0 { return nil, nil @@ -1396,6 +1429,9 @@ func (r policiesPageJSON) RawJSON() string { // there is no next page, this function will return a 'nil' for the page value, but // will not return an error func (r *PoliciesPage[T]) GetNextPage() (res *PoliciesPage[T], err error) { + if len(r.Policies) == 0 { + return nil, nil + } next := r.Pagination.NextToken if len(next) == 0 { return nil, nil @@ -1517,6 +1553,9 @@ func (r projectsPageJSON) RawJSON() string { // there is no next page, this function will return a 'nil' for the page value, but // will not return an error func (r *ProjectsPage[T]) GetNextPage() (res *ProjectsPage[T], err error) { + if len(r.Projects) == 0 { + return nil, nil + } next := r.Pagination.NextToken if len(next) == 0 { return nil, nil @@ -1638,6 +1677,9 @@ func (r recordsPageJSON) RawJSON() string { // there is no next page, this function will return a 'nil' for the page value, but // will not return an error func (r *RecordsPage[T]) GetNextPage() (res *RecordsPage[T], err error) { + if len(r.Records) == 0 { + return nil, nil + } next := r.Pagination.NextToken if len(next) == 0 { return nil, nil @@ -1759,6 +1801,9 @@ func (r runnersPageJSON) RawJSON() string { // there is no next page, this function will return a 'nil' for the page value, but // will not return an error func (r *RunnersPage[T]) GetNextPage() (res *RunnersPage[T], err error) { + if len(r.Runners) == 0 { + return nil, nil + } next := r.Pagination.NextToken if len(next) == 0 { return nil, nil @@ -1880,6 +1925,9 @@ func (r secretsPageJSON) RawJSON() string { // there is no next page, this function will return a 'nil' for the page value, but // will not return an error func (r *SecretsPage[T]) GetNextPage() (res *SecretsPage[T], err error) { + if len(r.Secrets) == 0 { + return nil, nil + } next := r.Pagination.NextToken if len(next) == 0 { return nil, nil @@ -2001,6 +2049,9 @@ func (r servicesPageJSON) RawJSON() string { // there is no next page, this function will return a 'nil' for the page value, but // will not return an error func (r *ServicesPage[T]) GetNextPage() (res *ServicesPage[T], err error) { + if len(r.Services) == 0 { + return nil, nil + } next := r.Pagination.NextToken if len(next) == 0 { return nil, nil @@ -2123,6 +2174,9 @@ func (r ssoConfigurationsPageJSON) RawJSON() string { // there is no next page, this function will return a 'nil' for the page value, but // will not return an error func (r *SSOConfigurationsPage[T]) GetNextPage() (res *SSOConfigurationsPage[T], err error) { + if len(r.SSOConfigurations) == 0 { + return nil, nil + } next := r.Pagination.NextToken if len(next) == 0 { return nil, nil @@ -2245,6 +2299,9 @@ func (r taskExecutionsPageJSON) RawJSON() string { // there is no next page, this function will return a 'nil' for the page value, but // will not return an error func (r *TaskExecutionsPage[T]) GetNextPage() (res *TaskExecutionsPage[T], err error) { + if len(r.TaskExecutions) == 0 { + return nil, nil + } next := r.Pagination.NextToken if len(next) == 0 { return nil, nil @@ -2366,6 +2423,9 @@ func (r tasksPageJSON) RawJSON() string { // there is no next page, this function will return a 'nil' for the page value, but // will not return an error func (r *TasksPage[T]) GetNextPage() (res *TasksPage[T], err error) { + if len(r.Tasks) == 0 { + return nil, nil + } next := r.Pagination.NextToken if len(next) == 0 { return nil, nil @@ -2487,6 +2547,9 @@ func (r tokensPageJSON) RawJSON() string { // there is no next page, this function will return a 'nil' for the page value, but // will not return an error func (r *TokensPage[T]) GetNextPage() (res *TokensPage[T], err error) { + if len(r.Tokens) == 0 { + return nil, nil + } next := r.Pagination.NextToken if len(next) == 0 { return nil, nil From 52bb01f2bc2aae5736c292faf09d98a515be2a08 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 28 Jun 2025 04:01:00 +0000 Subject: [PATCH 4/9] fix: don't try to deserialize as json when ResponseBodyInto is []byte --- internal/requestconfig/requestconfig.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/internal/requestconfig/requestconfig.go b/internal/requestconfig/requestconfig.go index 66ccdd5..61c4c15 100644 --- a/internal/requestconfig/requestconfig.go +++ b/internal/requestconfig/requestconfig.go @@ -539,15 +539,15 @@ func (cfg *RequestConfig) Execute() (err error) { return nil } - // If the response happens to be a byte array, deserialize the body as-is. switch dst := cfg.ResponseBodyInto.(type) { + // If the response happens to be a byte array, deserialize the body as-is. case *[]byte: *dst = contents - } - - err = json.NewDecoder(bytes.NewReader(contents)).Decode(cfg.ResponseBodyInto) - if err != nil { - return fmt.Errorf("error parsing response json: %w", err) + default: + err = json.NewDecoder(bytes.NewReader(contents)).Decode(cfg.ResponseBodyInto) + if err != nil { + return fmt.Errorf("error parsing response json: %w", err) + } } return nil From 5214c8625e015da0f06ab2f817c96a31346475ec Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 28 Jun 2025 09:01:07 +0000 Subject: [PATCH 5/9] chore(ci): only run for pushes and fork pull requests --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 105b972..846bc19 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,6 +17,7 @@ jobs: timeout-minutes: 10 name: lint runs-on: ${{ github.repository == 'stainless-sdks/gitpod-go' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} + if: github.event_name == 'push' || github.event.pull_request.head.repo.fork steps: - uses: actions/checkout@v4 @@ -32,6 +33,7 @@ jobs: timeout-minutes: 10 name: test runs-on: ${{ github.repository == 'stainless-sdks/gitpod-go' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} + if: github.event_name == 'push' || github.event.pull_request.head.repo.fork steps: - uses: actions/checkout@v4 From 1bba1075657651b1ac7b261bbd9c2fcd3fc08fdd Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 8 Jul 2025 03:13:15 +0000 Subject: [PATCH 6/9] chore: lint tests --- scripts/lint | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/lint b/scripts/lint index fa7ba1f..c10fa02 100755 --- a/scripts/lint +++ b/scripts/lint @@ -5,4 +5,7 @@ set -e cd "$(dirname "$0")/.." echo "==> Running Go build" -go build ./... +go build . + +# Compile the tests but don't run them +go test -c . From 076dd1d2cef96adf0c5b21e4413387307f52971d Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 9 Jul 2025 02:15:38 +0000 Subject: [PATCH 7/9] chore(internal): fix lint script for tests --- scripts/lint | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/lint b/scripts/lint index c10fa02..9f37abf 100755 --- a/scripts/lint +++ b/scripts/lint @@ -7,5 +7,5 @@ cd "$(dirname "$0")/.." echo "==> Running Go build" go build . -# Compile the tests but don't run them -go test -c . +echo "==> Checking tests compile" +go test -run=^$ . From 7c466c272c807ecda01497bd3565408e973cc177 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 11 Jul 2025 04:38:42 +0000 Subject: [PATCH 8/9] chore: lint tests in subpackages --- scripts/lint | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/lint b/scripts/lint index 9f37abf..7e03a7b 100755 --- a/scripts/lint +++ b/scripts/lint @@ -5,7 +5,7 @@ set -e cd "$(dirname "$0")/.." echo "==> Running Go build" -go build . +go build ./... echo "==> Checking tests compile" -go test -run=^$ . +go test -run=^$ ./... From bbd052a78a2c0bdabc7760ce59f3da6a20ee33ad Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 11 Jul 2025 04:38:57 +0000 Subject: [PATCH 9/9] release: 0.6.0 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 23 +++++++++++++++++++++++ README.md | 2 +- internal/version.go | 2 +- 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 2aca35a..4208b5c 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.5.0" + ".": "0.6.0" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 853c2d7..4c7c7c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,28 @@ # Changelog +## 0.6.0 (2025-07-11) + +Full Changelog: [v0.5.0...v0.6.0](https://github.com/gitpod-io/gitpod-sdk-go/compare/v0.5.0...v0.6.0) + +### Features + +* **client:** add debug log helper ([80b9e2b](https://github.com/gitpod-io/gitpod-sdk-go/commit/80b9e2b14e06850bda8d96cb4bdbcc611d9684d8)) + + +### Bug Fixes + +* don't try to deserialize as json when ResponseBodyInto is []byte ([52bb01f](https://github.com/gitpod-io/gitpod-sdk-go/commit/52bb01f2bc2aae5736c292faf09d98a515be2a08)) +* **pagination:** check if page data is empty in GetNextPage ([8d9d6fb](https://github.com/gitpod-io/gitpod-sdk-go/commit/8d9d6fb9ca5a3913d0400620dd18686290f8e57d)) + + +### Chores + +* **ci:** enable for pull requests ([2c731e3](https://github.com/gitpod-io/gitpod-sdk-go/commit/2c731e32d19595c013749cea2a7a8c50603aa0a4)) +* **ci:** only run for pushes and fork pull requests ([5214c86](https://github.com/gitpod-io/gitpod-sdk-go/commit/5214c8625e015da0f06ab2f817c96a31346475ec)) +* **internal:** fix lint script for tests ([076dd1d](https://github.com/gitpod-io/gitpod-sdk-go/commit/076dd1d2cef96adf0c5b21e4413387307f52971d)) +* lint tests ([1bba107](https://github.com/gitpod-io/gitpod-sdk-go/commit/1bba1075657651b1ac7b261bbd9c2fcd3fc08fdd)) +* lint tests in subpackages ([7c466c2](https://github.com/gitpod-io/gitpod-sdk-go/commit/7c466c272c807ecda01497bd3565408e973cc177)) + ## 0.5.0 (2025-06-06) Full Changelog: [v0.4.0...v0.5.0](https://github.com/gitpod-io/gitpod-sdk-go/compare/v0.4.0...v0.5.0) diff --git a/README.md b/README.md index ef33925..cdfe377 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ Or to pin the version: ```sh -go get -u 'github.com/gitpod-io/gitpod-sdk-go@v0.5.0' +go get -u 'github.com/gitpod-io/gitpod-sdk-go@v0.6.0' ``` diff --git a/internal/version.go b/internal/version.go index 67c4d40..577a4dc 100644 --- a/internal/version.go +++ b/internal/version.go @@ -2,4 +2,4 @@ package internal -const PackageVersion = "0.5.0" // x-release-please-version +const PackageVersion = "0.6.0" // x-release-please-version