From 0d526fb56665783025c14ea0a21a4e461fdf379c Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 9 Nov 2024 06:12:10 +0000 Subject: [PATCH 1/3] chore: rebuild project due to codegen change (#6) --- .github/workflows/create-releases.yml | 28 ------------------- .../handle-release-pr-title-edit.yml | 25 ----------------- internal/apijson/encoder.go | 13 +++++++-- internal/apijson/json_test.go | 5 ++-- 4 files changed, 13 insertions(+), 58 deletions(-) delete mode 100644 .github/workflows/create-releases.yml delete mode 100644 .github/workflows/handle-release-pr-title-edit.yml diff --git a/.github/workflows/create-releases.yml b/.github/workflows/create-releases.yml deleted file mode 100644 index b7a3ff7..0000000 --- a/.github/workflows/create-releases.yml +++ /dev/null @@ -1,28 +0,0 @@ -name: Create releases -on: - schedule: - - cron: '0 5 * * *' # every day at 5am UTC - push: - branches: - - main - -jobs: - release: - name: release - if: github.ref == 'refs/heads/main' && github.repository == 'brevdev/nvcf-go' - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - - uses: stainless-api/trigger-release-please@v1 - id: release - with: - repo: ${{ github.event.repository.full_name }} - stainless-api-key: ${{ secrets.STAINLESS_API_KEY }} - - - name: Generate godocs - if: ${{ steps.release.outputs.releases_created }} - run: | - version=$(jq -r '. | to_entries[0] | .value' .release-please-manifest.json) - curl -X POST https://pkg.go.dev/fetch/github.com/brevdev/nvcf-go@v${version} diff --git a/.github/workflows/handle-release-pr-title-edit.yml b/.github/workflows/handle-release-pr-title-edit.yml deleted file mode 100644 index 8bd4ee1..0000000 --- a/.github/workflows/handle-release-pr-title-edit.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: Handle release PR title edits -on: - pull_request: - types: - - edited - - unlabeled - -jobs: - update_pr_content: - name: Update pull request content - if: | - ((github.event.action == 'edited' && github.event.changes.title.from != github.event.pull_request.title) || - (github.event.action == 'unlabeled' && github.event.label.name == 'autorelease: custom version')) && - startsWith(github.event.pull_request.head.ref, 'release-please--') && - github.event.pull_request.state == 'open' && - github.event.sender.login != 'stainless-bot' && - github.event.sender.login != 'stainless-app' && - github.repository == 'brevdev/nvcf-go' - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: stainless-api/trigger-release-please@v1 - with: - repo: ${{ github.event.repository.full_name }} - stainless-api-key: ${{ secrets.STAINLESS_API_KEY }} diff --git a/internal/apijson/encoder.go b/internal/apijson/encoder.go index 227a839..d4af568 100644 --- a/internal/apijson/encoder.go +++ b/internal/apijson/encoder.go @@ -7,6 +7,7 @@ import ( "reflect" "sort" "strconv" + "strings" "sync" "time" @@ -342,16 +343,18 @@ func (e *encoder) encodeMapEntries(json []byte, v reflect.Value) ([]byte, error) iter := v.MapRange() for iter.Next() { - var encodedKey []byte + var encodedKeyString string if iter.Key().Type().Kind() == reflect.String { - encodedKey = []byte(iter.Key().String()) + encodedKeyString = iter.Key().String() } else { var err error - encodedKey, err = keyEncoder(iter.Key()) + encodedKeyBytes, err := keyEncoder(iter.Key()) if err != nil { return nil, err } + encodedKeyString = string(encodedKeyBytes) } + encodedKey := []byte(sjsonReplacer.Replace(encodedKeyString)) pairs = append(pairs, mapPair{key: encodedKey, value: iter.Value()}) } @@ -389,3 +392,7 @@ func (e *encoder) newMapEncoder(t reflect.Type) encoderFunc { return json, nil } } + +// If we want to set a literal key value into JSON using sjson, we need to make sure it doesn't have +// special characters that sjson interprets as a path. +var sjsonReplacer *strings.Replacer = strings.NewReplacer(".", "\\.", ":", "\\:", "*", "\\*") diff --git a/internal/apijson/json_test.go b/internal/apijson/json_test.go index 85cd2b5..e656344 100644 --- a/internal/apijson/json_test.go +++ b/internal/apijson/json_test.go @@ -361,8 +361,9 @@ var tests = map[string]struct { "date_time_missing_timezone_colon_coerce": {`"2007-03-01T13:03:05-1200"`, time.Date(2007, time.March, 1, 13, 3, 5, 0, time.FixedZone("", -12*60*60))}, "date_time_nano_missing_t_coerce": {`"2007-03-01 13:03:05.123456789Z"`, time.Date(2007, time.March, 1, 13, 3, 5, 123456789, time.UTC)}, - "map_string": {`{"foo":"bar"}`, map[string]string{"foo": "bar"}}, - "map_interface": {`{"a":1,"b":"str","c":false}`, map[string]interface{}{"a": float64(1), "b": "str", "c": false}}, + "map_string": {`{"foo":"bar"}`, map[string]string{"foo": "bar"}}, + "map_string_with_sjson_path_chars": {`{":a.b.c*:d*-1e.f":"bar"}`, map[string]string{":a.b.c*:d*-1e.f": "bar"}}, + "map_interface": {`{"a":1,"b":"str","c":false}`, map[string]interface{}{"a": float64(1), "b": "str", "c": false}}, "primitive_struct": { `{"a":false,"b":237628372683,"c":654,"d":9999.43,"e":43.76,"f":[1,2,3,4]}`, From b1eb526234b098ea6633874aa8a12a05d46bfeab Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 12 Nov 2024 04:35:26 +0000 Subject: [PATCH 2/3] chore: rebuild project due to codegen change (#7) --- internal/requestconfig/requestconfig.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/internal/requestconfig/requestconfig.go b/internal/requestconfig/requestconfig.go index 14471ee..87d5bb9 100644 --- a/internal/requestconfig/requestconfig.go +++ b/internal/requestconfig/requestconfig.go @@ -298,6 +298,10 @@ func retryDelay(res *http.Response, retryCount int) time.Duration { } func (cfg *RequestConfig) Execute() (err error) { + if cfg.BaseURL == nil { + return fmt.Errorf("requestconfig: base url is not set") + } + cfg.Request.URL, err = cfg.BaseURL.Parse(strings.TrimLeft(cfg.Request.URL.String(), "/")) if err != nil { return err From d1fee91a2a797bbcf5dce5736ea784b4ee9e719f Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 12 Nov 2024 04:35:40 +0000 Subject: [PATCH 3/3] release: 0.1.0-alpha.1 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 15 +++++++++++++++ README.md | 2 +- internal/version.go | 2 +- 4 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 CHANGELOG.md diff --git a/.release-please-manifest.json b/.release-please-manifest.json index c476280..ba6c348 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.0.1-alpha.0" + ".": "0.1.0-alpha.1" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..1ef41c5 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,15 @@ +# Changelog + +## 0.1.0-alpha.1 (2024-11-12) + +Full Changelog: [v0.0.1-alpha.0...v0.1.0-alpha.1](https://github.com/brevdev/nvcf-go/compare/v0.0.1-alpha.0...v0.1.0-alpha.1) + +### Features + +* **api:** api update ([c1759d5](https://github.com/brevdev/nvcf-go/commit/c1759d5dbeecd97f1899f7db70dd1371caf27478)) + + +### Chores + +* rebuild project due to codegen change ([#6](https://github.com/brevdev/nvcf-go/issues/6)) ([0d526fb](https://github.com/brevdev/nvcf-go/commit/0d526fb56665783025c14ea0a21a4e461fdf379c)) +* rebuild project due to codegen change ([#7](https://github.com/brevdev/nvcf-go/issues/7)) ([b1eb526](https://github.com/brevdev/nvcf-go/commit/b1eb526234b098ea6633874aa8a12a05d46bfeab)) diff --git a/README.md b/README.md index 7c3c6fc..43d680b 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ Or to pin the version: ```sh -go get -u 'github.com/brevdev/nvcf-go@v0.0.1-alpha.0' +go get -u 'github.com/brevdev/nvcf-go@v0.1.0-alpha.1' ``` diff --git a/internal/version.go b/internal/version.go index 4ff68e4..5ed22d7 100644 --- a/internal/version.go +++ b/internal/version.go @@ -2,4 +2,4 @@ package internal -const PackageVersion = "0.0.1-alpha.0" // x-release-please-version +const PackageVersion = "0.1.0-alpha.1" // x-release-please-version