Repository: sacloud/usacloud
Pull request #1113 (2024-04-02 00:27:50)

go: bump github.com/itchyny/gojq from 0.12.14 to 0.12.15
Bumps [github.com/itchyny/gojq](https://github.com/itchyny/gojq) from 0.12.14 to 0.12.15.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/itchyny/gojq/releases">github.com/itchyny/gojq's releases</a>.</em></p>
<blockquote>
<h2>Release v0.12.15</h2>
<ul>
<li>implement <code>ltrim</code>, <code>rtrim</code>, and <code>trim</code> functions</li>
<li>implement <code>gojq.ParseError</code> for getting the offset and token of query parsing error</li>
<li>implement <code>gojq.HaltError</code> for detecting halt errors and stopping outer iteration</li>
<li>fix object construction with duplicate keys (<code>{x:0,y:1} | {a:.x,a:.y}</code>)</li>
<li>fix <code>halt</code> and <code>halt_error</code> functions to stop the command execution immediately</li>
<li>fix variable scope of binding syntax (<code>&quot;a&quot; as $v | def f: $v; &quot;b&quot; as $v | f</code>)</li>
<li>fix pre-defined variables to be available in initial modules (<code>$ARGS</code> in <code>~/.jq</code>)</li>
<li>fix <code>ltrimstr</code> and <code>rtrimstr</code> functions to emit error on non-string input</li>
<li>fix <code>nearbyint</code> and <code>rint</code> functions to round ties to even</li>
<li>improve parser to allow <code>reduce</code>, <code>foreach</code>, <code>if</code>, <code>try</code>-<code>catch</code> syntax as object values</li>
<li>remove <code>pow10</code> in favor of <code>exp10</code>, define <code>scalbn</code> and <code>scalbln</code> by <code>ldexp</code></li>
</ul>
</blockquote>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a href="https://github.com/itchyny/gojq/blob/main/CHANGELOG.md">github.com/itchyny/gojq's changelog</a>.</em></p>
<blockquote>
<h2><a href="https://github.com/itchyny/gojq/compare/v0.12.14..v0.12.15">v0.12.15</a> (2024-04-01)</h2>
<ul>
<li>implement <code>ltrim</code>, <code>rtrim</code>, and <code>trim</code> functions</li>
<li>implement <code>gojq.ParseError</code> for getting the offset and token of query parsing error</li>
<li>implement <code>gojq.HaltError</code> for detecting halt errors and stopping outer iteration</li>
<li>fix object construction with duplicate keys (<code>{x:0,y:1} | {a:.x,a:.y}</code>)</li>
<li>fix <code>halt</code> and <code>halt_error</code> functions to stop the command execution immediately</li>
<li>fix variable scope of binding syntax (<code>&quot;a&quot; as $v | def f: $v; &quot;b&quot; as $v | f</code>)</li>
<li>fix pre-defined variables to be available in initial modules (<code>$ARGS</code> in <code>~/.jq</code>)</li>
<li>fix <code>ltrimstr</code> and <code>rtrimstr</code> functions to emit error on non-string input</li>
<li>fix <code>nearbyint</code> and <code>rint</code> functions to round ties to even</li>
<li>improve parser to allow <code>reduce</code>, <code>foreach</code>, <code>if</code>, <code>try</code>-<code>catch</code> syntax as object values</li>
<li>remove <code>pow10</code> in favor of <code>exp10</code>, define <code>scalbn</code> and <code>scalbln</code> by <code>ldexp</code></li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/itchyny/gojq/commit/ca9fd97cd6247319f0bf999a670814bc1a3b071f"><code>ca9fd97</code></a> bump up version to 0.12.15</li>
<li><a href="https://github.com/itchyny/gojq/commit/3b43597c280e00fa4893b4db686a15666b53d0b8"><code>3b43597</code></a> update CHANGELOG.md for v0.12.15</li>
<li><a href="https://github.com/itchyny/gojq/commit/88cca901830ded08488195172fca4e313b553a42"><code>88cca90</code></a> update jq differences to clarify regular expression differences</li>
<li><a href="https://github.com/itchyny/gojq/commit/79e6f53f49be4a9bf1b6b64eb81dc769bad22804"><code>79e6f53</code></a> add document comments to methods of HaltError</li>
<li><a href="https://github.com/itchyny/gojq/commit/13da5a1e1ff5b900b21e3bb1becb8499af6231a8"><code>13da5a1</code></a> login to Docker registries only when pushing a tag</li>
<li><a href="https://github.com/itchyny/gojq/commit/e7e015b76e260ab5c333d0d5f384921b92dfe990"><code>e7e015b</code></a> update dependencies</li>
<li><a href="https://github.com/itchyny/gojq/commit/2cc65b621eba3357cad1b2d6d93f53ede6c13e27"><code>2cc65b6</code></a> improve .gitattributes to mark generated files</li>
<li><a href="https://github.com/itchyny/gojq/commit/bbbbe84b10fe3f67feda3cacf4cde89b46ff511d"><code>bbbbe84</code></a> export HaltError struct type not interface</li>
<li><a href="https://github.com/itchyny/gojq/commit/c8171c6b148dd6fbc2d4d5494f225ecb85294054"><code>c8171c6</code></a> align caret in error messages using width specifier</li>
<li><a href="https://github.com/itchyny/gojq/commit/57cf5532430f18acabdc0783499d3cf71024eb52"><code>57cf553</code></a> move Parse to query.go to enable document comments</li>
<li>Additional commits viewable in <a href="https://github.com/itchyny/gojq/compare/v0.12.14...v0.12.15">compare view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=github.com/itchyny/gojq&package-manager=go_modules&previous-version=0.12.14&new-version=0.12.15)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)


</details>


Patch:
diff --git a/go.mod b/go.mod
index 6889390f..0cb85e13 100644
--- a/go.mod
+++ b/go.mod
@@ -11,7 +11,7 @@ require (
 	github.com/hashicorp/go-version v1.6.0
 	github.com/hokaccha/go-prettyjson v0.0.0-20210113012101-fb4e108d2519
 	github.com/huandu/xstrings v1.4.0
-	github.com/itchyny/gojq v0.12.14
+	github.com/itchyny/gojq v0.12.15
 	github.com/jmespath/go-jmespath v0.4.0
 	github.com/mattn/go-colorable v0.1.13
 	github.com/mattn/go-isatty v0.0.20
@@ -58,7 +58,7 @@ require (
 	github.com/mattn/go-runewidth v0.0.15 // indirect
 	github.com/mitchellh/mapstructure v1.5.0 // indirect
 	github.com/pmezard/go-difflib v1.0.0 // indirect
-	github.com/rivo/uniseg v0.4.4 // indirect
+	github.com/rivo/uniseg v0.4.7 // indirect
 	github.com/sacloud/ftps v1.2.0 // indirect
 	github.com/tcnksm/go-gitconfig v0.1.2 // indirect
 	github.com/ulikunitz/xz v0.5.9 // indirect
diff --git a/go.sum b/go.sum
index d52e4919..13f0675c 100644
--- a/go.sum
+++ b/go.sum
@@ -182,8 +182,8 @@ github.com/inconshreveable/go-update v0.0.0-20160112193335-8152e7eb6ccf h1:WfD7V
 github.com/inconshreveable/go-update v0.0.0-20160112193335-8152e7eb6ccf/go.mod h1:hyb9oH7vZsitZCiBt0ZvifOrB+qc8PS5IiilCIb87rg=
 github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
 github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
-github.com/itchyny/gojq v0.12.14 h1:6k8vVtsrhQSYgSGg827AD+PVVaB1NLXEdX+dda2oZCc=
-github.com/itchyny/gojq v0.12.14/go.mod h1:y1G7oO7XkcR1LPZO59KyoCRy08T3j9vDYRV0GgYSS+s=
+github.com/itchyny/gojq v0.12.15 h1:WC1Nxbx4Ifw5U2oQWACYz32JK8G9qxNtHzrvW4KEcqI=
+github.com/itchyny/gojq v0.12.15/go.mod h1:uWAHCbCIla1jiNxmeT5/B5mOjSdfkCq6p8vxWg+BM10=
 github.com/itchyny/timefmt-go v0.1.5 h1:G0INE2la8S6ru/ZI5JecgyzbbJNs5lG1RcBqa7Jm6GE=
 github.com/itchyny/timefmt-go v0.1.5/go.mod h1:nEP7L+2YmAbT2kZ2HfSs1d8Xtw9LY8D2stDBckWakZ8=
 github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A=
@@ -231,8 +231,8 @@ github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:
 github.com/rhysd/go-github-selfupdate v1.2.3 h1:iaa+J202f+Nc+A8zi75uccC8Wg3omaM7HDeimXA22Ag=
 github.com/rhysd/go-github-selfupdate v1.2.3/go.mod h1:mp/N8zj6jFfBQy/XMYoWsmfzxazpPAODuqarmPDe2Rg=
 github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
-github.com/rivo/uniseg v0.4.4 h1:8TfxU8dW6PdqD27gjM8MVNuicgxIjxpm4K7x4jp8sis=
-github.com/rivo/uniseg v0.4.4/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
+github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
+github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
 github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
 github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8=
 github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE=
diff --git a/pkg/commands/iaas/vpcrouter/router_setting_update.go b/pkg/commands/iaas/vpcrouter/router_setting_update.go
index 91b11d0f..ecf8b8d1 100644
--- a/pkg/commands/iaas/vpcrouter/router_setting_update.go
+++ b/pkg/commands/iaas/vpcrouter/router_setting_update.go
@@ -123,7 +123,7 @@ func (r *routerSettingUpdate) Customize(_ cli.Context) error {
 		if err := util.MarshalJSONFromPathOrContent(r.DNSForwardingData, &df); err != nil {
 			return err
 		}
-		*r.DNSForwarding = df
+		r.DNSForwarding = &df
 	}
 
 	if r.PPTPServerData != "" {
@@ -131,7 +131,7 @@ func (r *routerSettingUpdate) Customize(_ cli.Context) error {
 		if err := util.MarshalJSONFromPathOrContent(r.PPTPServerData, &pptp); err != nil {
 			return err
 		}
-		*r.PPTPServer = pptp
+		r.PPTPServer = &pptp
 	}
 
 	if r.L2TPIPsecServerData != "" {
@@ -139,14 +139,14 @@ func (r *routerSettingUpdate) Customize(_ cli.Context) error {
 		if err := util.MarshalJSONFromPathOrContent(r.L2TPIPsecServerData, &l2tp); err != nil {
 			return err
 		}
-		*r.L2TPIPsecServer = l2tp
+		r.L2TPIPsecServer = &l2tp
 	}
 	if r.WireGuardData != "" {
 		var wireGuard iaas.VPCRouterWireGuard
 		if err := util.MarshalJSONFromPathOrContent(r.WireGuardData, &wireGuard); err != nil {
 			return err
 		}
-		*r.WireGuard = wireGuard
+		r.WireGuard = &wireGuard
 	}
 
 	if r.RemoteAccessUsersData != "" {
@@ -165,7 +165,7 @@ func (r *routerSettingUpdate) Customize(_ cli.Context) error {
 		if err := util.MarshalJSONFromPathOrContent(r.SiteToSiteIPsecVPNData, &s2s); err != nil {
 			return err
 		}
-		*r.SiteToSiteIPsecVPN = s2s
+		r.SiteToSiteIPsecVPN = &s2s
 	}
 
 	if r.StaticRouteData != "" {


Test patch:
diff --git a/pkg/commands/iaas/vpcrouter/router_setting_update_test.go b/pkg/commands/iaas/vpcrouter/router_setting_update_test.go
new file mode 100644
index 00000000..4e1095a5
--- /dev/null
+++ b/pkg/commands/iaas/vpcrouter/router_setting_update_test.go
@@ -0,0 +1,85 @@
+// Copyright 2017-2023 The sacloud/usacloud Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package vpcrouter
+
+import (
+	"reflect"
+	"testing"
+
+	"github.com/sacloud/iaas-api-go"
+)
+
+func Test_routerSettingUpdate_Customize(t *testing.T) {
+	tests := []struct {
+		name     string
+		settings routerSettingUpdate
+		wantErr  bool
+		want     routerSettingUpdate
+	}{
+		{
+			name:     "empty",
+			settings: routerSettingUpdate{},
+			wantErr:  false,
+			want:     routerSettingUpdate{},
+		},
+		{
+			name: "with wireguard json",
+			settings: routerSettingUpdate{
+				WireGuardData: `{"IPAddress":"192.0.2.1/24","Peers":[{"IPAddress":"192.0.2.11","Name":"example","PublicKey":"your-key"}]}`,
+			},
+			wantErr: false,
+			want: routerSettingUpdate{
+				WireGuardData: `{"IPAddress":"192.0.2.1/24","Peers":[{"IPAddress":"192.0.2.11","Name":"example","PublicKey":"your-key"}]}`,
+				WireGuard: &iaas.VPCRouterWireGuard{
+					IPAddress: "192.0.2.1/24",
+					Peers: []*iaas.VPCRouterWireGuardPeer{
+						{
+							Name:      "example",
+							IPAddress: "192.0.2.11",
+							PublicKey: "your-key",
+						},
+					},
+				},
+			},
+		},
+		{
+			name: "with static nat json",
+			settings: routerSettingUpdate{
+				StaticNATData: `[{"GlobalAddress":"192.0.2.1","PrivateAddress":"192.0.2.2"}]`,
+			},
+			wantErr: false,
+			want: routerSettingUpdate{
+				StaticNATData: `[{"GlobalAddress":"192.0.2.1","PrivateAddress":"192.0.2.2"}]`,
+				StaticNAT: &[]*iaas.VPCRouterStaticNAT{
+					{
+						GlobalAddress:  "192.0.2.1",
+						PrivateAddress: "192.0.2.2",
+						Description:    "",
+					},
+				},
+			},
+		},
+	}
+	for _, tt := range tests {
+		t.Run(tt.name, func(t *testing.T) {
+			if err := tt.settings.Customize(nil); (err != nil) != tt.wantErr {
+				t.Errorf("Customize() error = %v, wantErr %v", err, tt.wantErr)
+			}
+			if !reflect.DeepEqual(tt.settings, tt.want) {
+				t.Errorf("unexpected router setting state: got = %v, actual = %v", tt.settings, tt.want)
+			}
+		})
+	}
+}