Skip to content

Commit b5acbc1

Browse files
committed
Replace yaml.v2 with goccy/go-yaml
`github.com/goccy/go-yaml` is active, stable, fast and no additional dependencies on others except go std. Signed-off-by: JUN JIE NAN <[email protected]>
1 parent faa4880 commit b5acbc1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+140
-80
lines changed

cmd/incus-agent/templates.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"path/filepath"
99
"strconv"
1010

11-
"gopkg.in/yaml.v2"
11+
"github.com/goccy/go-yaml"
1212

1313
"github.com/lxc/incus/v6/shared/api"
1414
"github.com/lxc/incus/v6/shared/util"

cmd/incus-migrate/main_migrate.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ import (
1414
"sort"
1515
"strings"
1616

17+
"github.com/goccy/go-yaml"
1718
"github.com/spf13/cobra"
1819
"golang.org/x/sys/unix"
19-
"gopkg.in/yaml.v2"
2020

2121
incus "github.com/lxc/incus/v6/client"
2222
cli "github.com/lxc/incus/v6/internal/cmd"

cmd/incus-simplestreams/main_add.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
"time"
1515

1616
"github.com/spf13/cobra"
17-
"gopkg.in/yaml.v2"
17+
"github.com/goccy/go-yaml"
1818

1919
cli "github.com/lxc/incus/v6/internal/cmd"
2020
internalUtil "github.com/lxc/incus/v6/internal/util"

cmd/incus-simplestreams/main_generate_metadata.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import (
99
"os/exec"
1010
"time"
1111

12+
"github.com/goccy/go-yaml"
1213
"github.com/spf13/cobra"
13-
yaml "gopkg.in/yaml.v2"
1414

1515
cli "github.com/lxc/incus/v6/internal/cmd"
1616
"github.com/lxc/incus/v6/shared/api"

cmd/incus/admin_init_dump.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ package main
55
import (
66
"fmt"
77

8-
yaml "gopkg.in/yaml.v2"
8+
"github.com/goccy/go-yaml"
99

1010
incus "github.com/lxc/incus/v6/client"
1111
"github.com/lxc/incus/v6/internal/i18n"

cmd/incus/admin_init_interactive.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ import (
1414
"strconv"
1515
"strings"
1616

17+
"github.com/goccy/go-yaml"
1718
"github.com/spf13/cobra"
1819
"golang.org/x/sys/unix"
19-
"gopkg.in/yaml.v2"
2020

2121
incus "github.com/lxc/incus/v6/client"
2222
"github.com/lxc/incus/v6/internal/i18n"

cmd/incus/admin_init_preseed.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"io"
88
"os"
99

10-
"gopkg.in/yaml.v2"
10+
"github.com/goccy/go-yaml"
1111

1212
"github.com/lxc/incus/v6/internal/i18n"
1313
"github.com/lxc/incus/v6/shared/api"
@@ -24,7 +24,7 @@ func (c *cmdAdminInit) RunPreseed() (*api.InitPreseed, error) {
2424
// Parse the YAML
2525
config := api.InitPreseed{}
2626
// Use strict checking to notify about unknown keys.
27-
err = yaml.UnmarshalStrict(bytes, &config)
27+
err = yaml.UnmarshalWithOptions(bytes, &config, yaml.Strict())
2828
if err != nil {
2929
return nil, fmt.Errorf(i18n.G("Failed to parse the preseed: %w"), err)
3030
}

cmd/incus/cluster.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import (
1010
"sort"
1111
"strings"
1212

13+
"github.com/goccy/go-yaml"
1314
"github.com/spf13/cobra"
14-
yaml "gopkg.in/yaml.v2"
1515

1616
cli "github.com/lxc/incus/v6/internal/cmd"
1717
"github.com/lxc/incus/v6/internal/i18n"

cmd/incus/cluster_group.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import (
99
"sort"
1010
"strings"
1111

12+
"github.com/goccy/go-yaml"
1213
"github.com/spf13/cobra"
13-
yaml "gopkg.in/yaml.v2"
1414

1515
cli "github.com/lxc/incus/v6/internal/cmd"
1616
"github.com/lxc/incus/v6/internal/i18n"

cmd/incus/config.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import (
77
"os"
88
"strings"
99

10+
"github.com/goccy/go-yaml"
1011
"github.com/spf13/cobra"
11-
"gopkg.in/yaml.v2"
1212

1313
incus "github.com/lxc/incus/v6/client"
1414
cli "github.com/lxc/incus/v6/internal/cmd"

cmd/incus/config_device.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import (
55
"fmt"
66
"strings"
77

8+
"github.com/goccy/go-yaml"
89
"github.com/spf13/cobra"
9-
"gopkg.in/yaml.v2"
1010

1111
cli "github.com/lxc/incus/v6/internal/cmd"
1212
"github.com/lxc/incus/v6/internal/i18n"

cmd/incus/config_metadata.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import (
66
"io"
77
"os"
88

9+
"github.com/goccy/go-yaml"
910
"github.com/spf13/cobra"
10-
"gopkg.in/yaml.v2"
1111

1212
cli "github.com/lxc/incus/v6/internal/cmd"
1313
"github.com/lxc/incus/v6/internal/i18n"

cmd/incus/config_trust.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import (
1313
"sort"
1414
"strings"
1515

16+
"github.com/goccy/go-yaml"
1617
"github.com/spf13/cobra"
17-
"gopkg.in/yaml.v2"
1818

1919
cli "github.com/lxc/incus/v6/internal/cmd"
2020
"github.com/lxc/incus/v6/internal/i18n"

cmd/incus/create.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"strings"
1111

1212
"github.com/spf13/cobra"
13-
"gopkg.in/yaml.v2"
13+
"github.com/goccy/go-yaml"
1414

1515
incus "github.com/lxc/incus/v6/client"
1616
cli "github.com/lxc/incus/v6/internal/cmd"

cmd/incus/image.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import (
1212
"sort"
1313
"strings"
1414

15+
"github.com/goccy/go-yaml"
1516
"github.com/spf13/cobra"
16-
"gopkg.in/yaml.v2"
1717

1818
incus "github.com/lxc/incus/v6/client"
1919
cli "github.com/lxc/incus/v6/internal/cmd"

cmd/incus/info.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import (
88
"sort"
99
"strings"
1010

11+
"github.com/goccy/go-yaml"
1112
"github.com/spf13/cobra"
12-
"gopkg.in/yaml.v2"
1313

1414
incus "github.com/lxc/incus/v6/client"
1515
cli "github.com/lxc/incus/v6/internal/cmd"

cmd/incus/monitor.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ import (
77
"os"
88
"slices"
99

10+
"github.com/goccy/go-yaml"
1011
"github.com/sirupsen/logrus"
1112
"github.com/spf13/cobra"
12-
"gopkg.in/yaml.v2"
1313

1414
incus "github.com/lxc/incus/v6/client"
1515
cli "github.com/lxc/incus/v6/internal/cmd"

cmd/incus/network.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import (
88
"sort"
99
"strings"
1010

11+
"github.com/goccy/go-yaml"
1112
"github.com/spf13/cobra"
12-
"gopkg.in/yaml.v2"
1313

1414
cli "github.com/lxc/incus/v6/internal/cmd"
1515
"github.com/lxc/incus/v6/internal/i18n"

cmd/incus/network_acl.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import (
99
"sort"
1010
"strings"
1111

12+
"github.com/goccy/go-yaml"
1213
"github.com/spf13/cobra"
13-
"gopkg.in/yaml.v2"
1414

1515
cli "github.com/lxc/incus/v6/internal/cmd"
1616
"github.com/lxc/incus/v6/internal/i18n"
@@ -443,7 +443,7 @@ func (c *cmdNetworkACLCreate) Run(cmd *cobra.Command, args []string) error {
443443
return err
444444
}
445445

446-
err = yaml.UnmarshalStrict(contents, &aclPut)
446+
err = yaml.UnmarshalWithOptions(contents, &aclPut, yaml.Strict())
447447
if err != nil {
448448
return err
449449
}
@@ -706,7 +706,7 @@ func (c *cmdNetworkACLEdit) Run(cmd *cobra.Command, args []string) error {
706706
// Allow output of `incus network acl show` command to be passed in here, but only take the contents
707707
// of the NetworkACLPut fields when updating the ACL. The other fields are silently discarded.
708708
newdata := api.NetworkACL{}
709-
err = yaml.UnmarshalStrict(contents, &newdata)
709+
err = yaml.UnmarshalWithOptions(contents, &newdata, yaml.Strict())
710710
if err != nil {
711711
return err
712712
}
@@ -734,7 +734,7 @@ func (c *cmdNetworkACLEdit) Run(cmd *cobra.Command, args []string) error {
734734
for {
735735
// Parse the text received from the editor.
736736
newdata := api.NetworkACL{} // We show the full ACL info, but only send the writable fields.
737-
err = yaml.UnmarshalStrict(content, &newdata)
737+
err = yaml.UnmarshalWithOptions(content, &newdata, yaml.Strict())
738738
if err == nil {
739739
err = resource.server.UpdateNetworkACL(resource.name, newdata.Writable(), etag)
740740
}

cmd/incus/network_address_set.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import (
88
"sort"
99
"strings"
1010

11+
"github.com/goccy/go-yaml"
1112
"github.com/spf13/cobra"
12-
"gopkg.in/yaml.v2"
1313

1414
cli "github.com/lxc/incus/v6/internal/cmd"
1515
"github.com/lxc/incus/v6/internal/i18n"
@@ -287,7 +287,7 @@ func (c *cmdNetworkAddressSetCreate) Run(cmd *cobra.Command, args []string) erro
287287
return err
288288
}
289289

290-
err = yaml.UnmarshalStrict(contents, &asPut)
290+
err = yaml.UnmarshalWithOptions(contents, &asPut, yaml.Strict())
291291
if err != nil {
292292
return err
293293
}
@@ -525,7 +525,7 @@ func (c *cmdNetworkAddressSetEdit) Run(cmd *cobra.Command, args []string) error
525525
}
526526

527527
newdata := api.NetworkAddressSet{}
528-
err = yaml.UnmarshalStrict(contents, &newdata)
528+
err = yaml.UnmarshalWithOptions(contents, &newdata, yaml.Strict())
529529
if err != nil {
530530
return err
531531
}
@@ -551,7 +551,7 @@ func (c *cmdNetworkAddressSetEdit) Run(cmd *cobra.Command, args []string) error
551551

552552
for {
553553
newdata := api.NetworkAddressSet{}
554-
err = yaml.UnmarshalStrict(content, &newdata)
554+
err = yaml.UnmarshalWithOptions(content, &newdata, yaml.Strict())
555555
if err == nil {
556556
err = resource.server.UpdateNetworkAddressSet(resource.name, newdata.Writable(), etag)
557557
}

cmd/incus/network_forward.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import (
88
"sort"
99
"strings"
1010

11+
"github.com/goccy/go-yaml"
1112
"github.com/spf13/cobra"
12-
"gopkg.in/yaml.v2"
1313

1414
cli "github.com/lxc/incus/v6/internal/cmd"
1515
"github.com/lxc/incus/v6/internal/i18n"
@@ -380,7 +380,7 @@ func (c *cmdNetworkForwardCreate) Run(cmd *cobra.Command, args []string) error {
380380
return err
381381
}
382382

383-
err = yaml.UnmarshalStrict(contents, &forwardPut)
383+
err = yaml.UnmarshalWithOptions(contents, &forwardPut, yaml.Strict())
384384
if err != nil {
385385
return err
386386
}
@@ -776,7 +776,7 @@ func (c *cmdNetworkForwardEdit) Run(cmd *cobra.Command, args []string) error {
776776
// Allow output of `incus network forward show` command to be passed in here, but only take the
777777
// contents of the NetworkForwardPut fields when updating. The other fields are silently discarded.
778778
newData := api.NetworkForward{}
779-
err = yaml.UnmarshalStrict(contents, &newData)
779+
err = yaml.UnmarshalWithOptions(contents, &newData, yaml.Strict())
780780
if err != nil {
781781
return err
782782
}
@@ -806,7 +806,7 @@ func (c *cmdNetworkForwardEdit) Run(cmd *cobra.Command, args []string) error {
806806
for {
807807
// Parse the text received from the editor.
808808
newData := api.NetworkForward{} // We show the full info, but only send the writable fields.
809-
err = yaml.UnmarshalStrict(content, &newData)
809+
err = yaml.UnmarshalWithOptions(content, &newData, yaml.Strict())
810810
if err == nil {
811811
newData.Normalise()
812812
err = client.UpdateNetworkForward(resource.name, args[1], newData.Writable(), etag)

cmd/incus/network_integration.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import (
88
"sort"
99
"strings"
1010

11+
"github.com/goccy/go-yaml"
1112
"github.com/spf13/cobra"
12-
"gopkg.in/yaml.v2"
1313

1414
cli "github.com/lxc/incus/v6/internal/cmd"
1515
"github.com/lxc/incus/v6/internal/i18n"

cmd/incus/network_load_balancer.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import (
88
"sort"
99
"strings"
1010

11+
"github.com/goccy/go-yaml"
1112
"github.com/spf13/cobra"
12-
"gopkg.in/yaml.v2"
1313

1414
cli "github.com/lxc/incus/v6/internal/cmd"
1515
"github.com/lxc/incus/v6/internal/i18n"
@@ -383,7 +383,7 @@ func (c *cmdNetworkLoadBalancerCreate) Run(cmd *cobra.Command, args []string) er
383383
return err
384384
}
385385

386-
err = yaml.UnmarshalStrict(contents, &loadBalancerPut)
386+
err = yaml.UnmarshalWithOptions(contents, &loadBalancerPut, yaml.Strict())
387387
if err != nil {
388388
return err
389389
}
@@ -756,7 +756,7 @@ func (c *cmdNetworkLoadBalancerEdit) Run(cmd *cobra.Command, args []string) erro
756756
// contents of the NetworkLoadBalancerPut fields when updating.
757757
// The other fields are silently discarded.
758758
newData := api.NetworkLoadBalancer{}
759-
err = yaml.UnmarshalStrict(contents, &newData)
759+
err = yaml.UnmarshalWithOptions(contents, &newData, yaml.Strict())
760760
if err != nil {
761761
return err
762762
}
@@ -786,7 +786,7 @@ func (c *cmdNetworkLoadBalancerEdit) Run(cmd *cobra.Command, args []string) erro
786786
for {
787787
// Parse the text received from the editor.
788788
newData := api.NetworkLoadBalancer{} // We show the full info, but only send the writable fields.
789-
err = yaml.UnmarshalStrict(content, &newData)
789+
err = yaml.UnmarshalWithOptions(content, &newData, yaml.Strict())
790790
if err == nil {
791791
newData.Normalise()
792792
err = client.UpdateNetworkLoadBalancer(resource.name, args[1], newData.Writable(), etag)

cmd/incus/network_peer.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"strings"
1111

1212
"github.com/spf13/cobra"
13-
"gopkg.in/yaml.v2"
13+
"github.com/goccy/go-yaml"
1414

1515
cli "github.com/lxc/incus/v6/internal/cmd"
1616
"github.com/lxc/incus/v6/internal/i18n"
@@ -406,7 +406,7 @@ func (c *cmdNetworkPeerCreate) Run(cmd *cobra.Command, args []string) error {
406406
return err
407407
}
408408

409-
err = yaml.UnmarshalStrict(contents, &peerPut)
409+
err = yaml.UnmarshalWithOptions(contents, &peerPut, yaml.Strict())
410410
if err != nil {
411411
return err
412412
}
@@ -794,7 +794,7 @@ func (c *cmdNetworkPeerEdit) Run(cmd *cobra.Command, args []string) error {
794794
// Allow output of `incus network peer show` command to be passed in here, but only take the contents
795795
// of the NetworkPeerPut fields when updating. The other fields are silently discarded.
796796
newData := api.NetworkPeer{}
797-
err = yaml.UnmarshalStrict(contents, &newData)
797+
err = yaml.UnmarshalWithOptions(contents, &newData, yaml.Strict())
798798
if err != nil {
799799
return err
800800
}
@@ -822,7 +822,7 @@ func (c *cmdNetworkPeerEdit) Run(cmd *cobra.Command, args []string) error {
822822
for {
823823
// Parse the text received from the editor.
824824
newData := api.NetworkPeer{} // We show the full info, but only send the writable fields.
825-
err = yaml.UnmarshalStrict(content, &newData)
825+
err = yaml.UnmarshalWithOptions(content, &newData, yaml.Strict())
826826
if err == nil {
827827
err = client.UpdateNetworkPeer(resource.name, args[1], newData.Writable(), etag)
828828
}

0 commit comments

Comments
 (0)