diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index aeb063e..160cc69 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -46,11 +46,11 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v7 # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@v2 + uses: github/codeql-action/init@v4 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. @@ -64,7 +64,7 @@ jobs: # Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift). # If this step fails, then you should remove it and run the build manually (see below) - name: Autobuild - uses: github/codeql-action/autobuild@v2 + uses: github/codeql-action/autobuild@v4 # â„šī¸ Command-line programs to run using the OS shell. # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun @@ -77,6 +77,6 @@ jobs: # ./location_of_script_within_repo/buildscript.sh - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 + uses: github/codeql-action/analyze@v4 with: category: "/language:${{matrix.language}}" diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index e9c83af..4559ced 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -4,11 +4,11 @@ jobs: lint: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - uses: actions/setup-go@v5 + - uses: actions/checkout@v7 + - uses: actions/setup-go@v6 with: - go-version: 1.23.x + go-version: 1.26.x - name: golangci-lint - uses: golangci/golangci-lint-action@v6 + uses: golangci/golangci-lint-action@v9 with: - version: v1.63 \ No newline at end of file + version: v2.12.2 \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 321269f..cbe20f7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -8,25 +8,25 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v7 with: fetch-depth: 0 - name: Set up Go - uses: actions/setup-go@v5 + uses: actions/setup-go@v6 with: - go-version: 1.23.x + go-version: 1.26.x - name: Set up QEMU - uses: docker/setup-qemu-action@v3 + uses: docker/setup-qemu-action@v4 - name: Setup Docker Buildx - uses: docker/setup-buildx-action@v3 + uses: docker/setup-buildx-action@v4 - name: Login to GHCR - uses: docker/login-action@v3 + uses: docker/login-action@v4 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Run GoReleaser - uses: goreleaser/goreleaser-action@v6 + uses: goreleaser/goreleaser-action@v7 with: distribution: goreleaser version: '~> v2' diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d3dc54a..1fbb23d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -4,11 +4,11 @@ jobs: test: strategy: matrix: - go: [1.22.x, 1.23.x] + go: [1.26.x] runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - uses: actions/setup-go@v5 + - uses: actions/checkout@v7 + - uses: actions/setup-go@v6 with: go-version: ${{ matrix.go }} - name: Test diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..1e70133 --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,8 @@ +version: "2" +linters: + settings: + errcheck: + exclude-functions: + - fmt.Fprintf + - fmt.Fprintln + - fmt.Fprint diff --git a/cmd/base/utils.go b/cmd/base/utils.go index 47903a4..a826045 100644 --- a/cmd/base/utils.go +++ b/cmd/base/utils.go @@ -81,9 +81,9 @@ func SetupProxy(cmd *cobra.Command, manager *config.Manager) { } if proxy != "" { if strings.HasPrefix(proxy, "https") { - os.Setenv("HTTPS_PROXY", proxy) + _ = os.Setenv("HTTPS_PROXY", proxy) } else { - os.Setenv("HTTP_PROXY", proxy) + _ = os.Setenv("HTTP_PROXY", proxy) } } } @@ -98,7 +98,7 @@ func ReadInputJSON(path string, in io.Reader, input any) error { if err != nil { return fmt.Errorf("failed to open file: %w", err) } - defer file.Close() + defer file.Close() //nolint:errcheck inputReader = file } else { inputReader = in diff --git a/cmd/config/update.go b/cmd/config/update.go index 20e3d8f..7e7a45c 100644 --- a/cmd/config/update.go +++ b/cmd/config/update.go @@ -54,8 +54,8 @@ func newUpdateCmd(cmdContext *base.CmdContext) *cobra.Command { // fillConfigOptions adds cmd flag to configOptions only if flag exists in KnownConfigFlags func fillConfigOptions(cmd *cobra.Command, f *pflag.Flag, configOptions map[string]any) { - if strings.HasPrefix(f.Name, "no-") { - optionName := strings.TrimPrefix(f.Name, "no-") + if after, ok := strings.CutPrefix(f.Name, "no-"); ok { + optionName := after configOptions[optionName] = nil return } diff --git a/cmd/entities/cloud-instances/cloud_instances_test.go b/cmd/entities/cloud-instances/cloud_instances_test.go index e632a63..471bc68 100644 --- a/cmd/entities/cloud-instances/cloud_instances_test.go +++ b/cmd/entities/cloud-instances/cloud_instances_test.go @@ -29,11 +29,11 @@ var ( FlavorID: "flavor-1", FlavorName: "m1.small", ImageID: "image-1", - ImageName: stringPtr("Ubuntu 20.04"), - PublicIPv4Address: stringPtr("1.2.3.4"), - PrivateIPv4Address: stringPtr("10.0.0.1"), - LocalIPv4Address: stringPtr("192.168.0.1"), - PublicIPv6Address: stringPtr("2001:db8::1"), + ImageName: new("Ubuntu 20.04"), + PublicIPv4Address: new("1.2.3.4"), + PrivateIPv4Address: new("10.0.0.1"), + LocalIPv4Address: new("192.168.0.1"), + PublicIPv6Address: new("2001:db8::1"), GPNEnabled: true, IPv6Enabled: true, BackupCopies: 2, @@ -52,11 +52,11 @@ var ( FlavorID: "flavor-1", FlavorName: "m1.small", ImageID: "image-1", - ImageName: stringPtr("Ubuntu 20.04"), - PublicIPv4Address: stringPtr("1.2.3.4"), - PrivateIPv4Address: stringPtr("10.0.0.1"), - LocalIPv4Address: stringPtr("192.168.0.1"), - PublicIPv6Address: stringPtr("2001:db8::1"), + ImageName: new("Ubuntu 20.04"), + PublicIPv4Address: new("1.2.3.4"), + PrivateIPv4Address: new("10.0.0.1"), + LocalIPv4Address: new("192.168.0.1"), + PublicIPv6Address: new("2001:db8::1"), GPNEnabled: true, IPv6Enabled: true, BackupCopies: 2, @@ -67,10 +67,6 @@ var ( } ) -func stringPtr(s string) *string { - return &s -} - func TestListCloudInstancesCmd(t *testing.T) { testInstance1 := testCloudInstance testInstance2 := testCloudInstance2 diff --git a/cmd/entities/cloud-volumes/cloud_volumes_test.go b/cmd/entities/cloud-volumes/cloud_volumes_test.go index b203502..5dbe8d5 100644 --- a/cmd/entities/cloud-volumes/cloud_volumes_test.go +++ b/cmd/entities/cloud-volumes/cloud_volumes_test.go @@ -26,7 +26,7 @@ var ( RegionID: 1, RegionCode: testRegionCode, Size: 100, - Description: testutils.PtrString("Test volume"), + Description: new("Test volume"), Labels: map[string]string{"foo": "bar"}, Created: &fixedTime, } diff --git a/cmd/entities/hosts/hosts_test.go b/cmd/entities/hosts/hosts_test.go index a5bd03b..1df8c34 100644 --- a/cmd/entities/hosts/hosts_test.go +++ b/cmd/entities/hosts/hosts_test.go @@ -33,16 +33,16 @@ var ( } testConfigDetails = serverscom.ConfigurationDetails{ RAMSize: 2, - ServerModelID: testutils.PtrInt64(1), - ServerModelName: testutils.PtrString("server-model-123"), - PublicUplinkID: testutils.PtrInt64(2), - PublicUplinkName: testutils.PtrString("Public 1 Gbps without redundancy"), - PrivateUplinkID: testutils.PtrInt64(3), - PrivateUplinkName: testutils.PtrString("Private 1 Gbps without redundancy"), - BandwidthID: testutils.PtrInt64(4), - BandwidthName: testutils.PtrString("20000 GB"), - OperatingSystemID: testutils.PtrInt64(5), - OperatingSystemFullName: testutils.PtrString("CentOS 7 x86_64"), + ServerModelID: new(int64(1)), + ServerModelName: new("server-model-123"), + PublicUplinkID: new(int64(2)), + PublicUplinkName: new("Public 1 Gbps without redundancy"), + PrivateUplinkID: new(int64(3)), + PrivateUplinkName: new("Private 1 Gbps without redundancy"), + BandwidthID: new(int64(4)), + BandwidthName: new("20000 GB"), + OperatingSystemID: new(int64(5)), + OperatingSystemFullName: new("CentOS 7 x86_64"), } testDS = serverscom.DedicatedServer{ ID: testId, @@ -259,23 +259,23 @@ func TestAddEBMCmd(t *testing.T) { Slots: []serverscom.DedicatedServerSlotInput{ { Position: 1, - DriveModelID: testutils.PtrInt64(3456), + DriveModelID: new(int64(3456)), }, { Position: 2, - DriveModelID: testutils.PtrInt64(3456), + DriveModelID: new(int64(3456)), }, }, Layout: []serverscom.DedicatedServerLayoutInput{ { SlotPositions: []int{1, 2}, - Raid: testutils.PtrInt(1), + Raid: new(1), Partitions: []serverscom.DedicatedServerLayoutPartitionInput{ { Target: "/boot", Size: 500, Fill: false, - Fs: testutils.PtrString("ext4"), + Fs: new("ext4"), }, }, }, @@ -284,8 +284,8 @@ func TestAddEBMCmd(t *testing.T) { Hosts: []serverscom.DedicatedServerHostInput{ { Hostname: "example.aa", - PublicIPv4NetworkID: testutils.PtrString("PublicNet123"), - PrivateIPv4NetworkID: testutils.PtrString("PrivateNet456"), + PublicIPv4NetworkID: new("PublicNet123"), + PrivateIPv4NetworkID: new("PrivateNet456"), Labels: map[string]string{ "environment": "testing", }, @@ -325,13 +325,13 @@ func TestAddEBMCmd(t *testing.T) { input := expectedInput input.Drives.Layout = append(input.Drives.Layout, serverscom.DedicatedServerLayoutInput{ SlotPositions: []int{3, 4}, - Raid: testutils.PtrInt(0), + Raid: new(0), Partitions: []serverscom.DedicatedServerLayoutPartitionInput{ { Target: "/boot", Size: 500, Fill: false, - Fs: testutils.PtrString("ext4"), + Fs: new("ext4"), }, }, }) @@ -364,7 +364,7 @@ func TestAddEBMCmd(t *testing.T) { configureMock: func(mock *mocks.MockHostsService) { input := expectedInput input.Features = []string{"public_ipxe_boot"} - input.IPXEConfig = testutils.PtrString("#!ipxe\nboot") + input.IPXEConfig = new("#!ipxe\nboot") mock.EXPECT(). CreateDedicatedServers(gomock.Any(), input). Return([]serverscom.DedicatedServer{testDS}, nil) @@ -380,7 +380,7 @@ func TestAddEBMCmd(t *testing.T) { }, configureMock: func(mock *mocks.MockHostsService) { input := expectedInput - input.IPXEConfig = testutils.PtrString("#!ipxe\nboot") + input.IPXEConfig = new("#!ipxe\nboot") mock.EXPECT(). CreateDedicatedServers(gomock.Any(), input). Return([]serverscom.DedicatedServer{testDS}, nil) @@ -395,7 +395,7 @@ func TestAddEBMCmd(t *testing.T) { }, configureMock: func(mock *mocks.MockHostsService) { input := expectedInput - input.IPXEConfig = testutils.PtrString("#!ipxe\nboot") + input.IPXEConfig = new("#!ipxe\nboot") mock.EXPECT(). CreateDedicatedServers(gomock.Any(), input). Return([]serverscom.DedicatedServer{testDS}, nil) @@ -474,8 +474,8 @@ func TestAddSBMCmd(t *testing.T) { Hosts: []serverscom.SBMServerHostInput{ { Hostname: "example.aa", - PublicIPv4NetworkID: testutils.PtrString("PublicNetTest123"), - PrivateIPv4NetworkID: testutils.PtrString("PrivateNetTest456"), + PublicIPv4NetworkID: new("PublicNetTest123"), + PrivateIPv4NetworkID: new("PrivateNetTest456"), Labels: map[string]string{ "environment": "testing", }, diff --git a/cmd/entities/hosts/utils.go b/cmd/entities/hosts/utils.go index 2a1f197..948aeb3 100644 --- a/cmd/entities/hosts/utils.go +++ b/cmd/entities/hosts/utils.go @@ -38,9 +38,9 @@ func parseLayout(layouts []string) ([]serverscom.DedicatedServerLayoutInput, err for _, l := range layouts { var lInput serverscom.DedicatedServerLayoutInput - parts := strings.Split(l, ",") + parts := strings.SplitSeq(l, ",") - for _, part := range parts { + for part := range parts { pair := strings.SplitN(part, "=", 2) if len(pair) != 2 { continue @@ -80,9 +80,9 @@ func parsePartitions(partitions []string) ([]parsedPartition, error) { for _, p := range partitions { var pp parsedPartition - parts := strings.Split(p, ",") + parts := strings.SplitSeq(p, ",") - for _, part := range parts { + for part := range parts { pair := strings.SplitN(part, "=", 2) if len(pair) != 2 { continue diff --git a/cmd/entities/l2_segments/add.go b/cmd/entities/l2_segments/add.go index f297f20..d34e06d 100644 --- a/cmd/entities/l2_segments/add.go +++ b/cmd/entities/l2_segments/add.go @@ -116,9 +116,9 @@ func parseMembers(members []string) ([]serverscom.L2SegmentMemberInput, error) { for _, member := range members { m := serverscom.L2SegmentMemberInput{} - parts := strings.Split(member, ",") + parts := strings.SplitSeq(member, ",") - for _, p := range parts { + for p := range parts { props := strings.SplitN(p, "=", 2) if len(props) != 2 { return nil, fmt.Errorf("invalid member format: %s", p) diff --git a/cmd/login/login.go b/cmd/login/login.go index b124d61..a115b3b 100644 --- a/cmd/login/login.go +++ b/cmd/login/login.go @@ -36,11 +36,11 @@ Example: srvctl login context-name`, RunE: func(cmd *cobra.Command, args []string) error { // login only if SC_TOKEN env is not set if os.Getenv("SC_TOKEN") != "" { - return errors.New("SC_TOKEN env is set. Please unset it before using login command.") + return errors.New("SC_TOKEN env is set. Please unset it before using login command") } if !term.IsTerminal(int(os.Stdout.Fd())) { - return errors.New("TTY required to enter the token.") + return errors.New("TTY required to enter the token") } manager := cmdContext.GetManager() diff --git a/cmd/login/login_test.go b/cmd/login/login_test.go index 610242d..2b0711a 100644 --- a/cmd/login/login_test.go +++ b/cmd/login/login_test.go @@ -109,8 +109,8 @@ func TestLoginCmd(t *testing.T) { if err != nil { t.Fatalf("failed to open pty: %v", err) } - defer ptmx.Close() - defer tty.Close() + defer ptmx.Close() //nolint:errcheck + defer tty.Close() //nolint:errcheck oldStdout := os.Stdout defer func() { os.Stdout = oldStdout }() diff --git a/cmd/testutils/command.go b/cmd/testutils/command.go index f657b98..c4494b4 100644 --- a/cmd/testutils/command.go +++ b/cmd/testutils/command.go @@ -76,15 +76,3 @@ func NewTestCmdContext(scClient *serverscom.Client) *base.CmdContext { cli := client.NewWithClient(scClient) return base.NewCmdContext(manager, cli) } - -func PtrInt64(i int64) *int64 { - return &i -} - -func PtrInt(i int) *int { - return &i -} - -func PtrString(s string) *string { - return &s -} diff --git a/go.mod b/go.mod index aaac418..e878ff5 100644 --- a/go.mod +++ b/go.mod @@ -1,36 +1,37 @@ module github.com/serverscom/srvctl -go 1.23.0 +go 1.26 require ( github.com/cpuguy83/go-md2man/v2 v2.0.7 github.com/creack/pty v1.1.24 github.com/jmespath/go-jmespath v0.4.0 - github.com/onsi/gomega v1.38.0 - github.com/serverscom/serverscom-go-client v1.0.32 - github.com/spf13/cobra v1.9.1 - github.com/spf13/pflag v1.0.7 - github.com/spf13/viper v1.20.1 + github.com/onsi/gomega v1.42.1 + github.com/serverscom/serverscom-go-client v1.0.33 + github.com/spf13/cobra v1.10.2 + github.com/spf13/pflag v1.0.10 + github.com/spf13/viper v1.21.0 github.com/stoewer/go-strcase v1.3.1 - go.uber.org/mock v0.5.2 - golang.org/x/term v0.34.0 - golang.org/x/text v0.28.0 + go.uber.org/mock v0.6.0 + golang.org/x/term v0.45.0 + golang.org/x/text v0.40.0 gopkg.in/yaml.v3 v3.0.1 ) require ( - github.com/fsnotify/fsnotify v1.9.0 // indirect - github.com/go-resty/resty/v2 v2.16.5 // indirect - github.com/go-viper/mapstructure/v2 v2.4.0 // indirect + github.com/fsnotify/fsnotify v1.10.1 // indirect + github.com/go-resty/resty/v2 v2.17.2 // indirect + github.com/go-viper/mapstructure/v2 v2.5.0 // indirect github.com/google/go-cmp v0.7.0 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect - github.com/pelletier/go-toml/v2 v2.2.4 // indirect + github.com/pelletier/go-toml/v2 v2.4.3 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect - github.com/sagikazarmark/locafero v0.10.0 // indirect - github.com/sourcegraph/conc v0.3.1-0.20240121214520-5f936abd7ae8 // indirect - github.com/spf13/afero v1.14.0 // indirect - github.com/spf13/cast v1.9.2 // indirect + github.com/sagikazarmark/locafero v0.12.0 // indirect + github.com/spf13/afero v1.15.0 // indirect + github.com/spf13/cast v1.10.0 // indirect github.com/subosito/gotenv v1.6.0 // indirect - golang.org/x/net v0.43.0 // indirect - golang.org/x/sys v0.35.0 // indirect + go.yaml.in/yaml/v3 v3.0.4 // indirect + golang.org/x/net v0.57.0 // indirect + golang.org/x/sys v0.47.0 // indirect + gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect ) diff --git a/go.sum b/go.sum index 7cdcc3a..f7105f8 100644 --- a/go.sum +++ b/go.sum @@ -8,20 +8,14 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8= github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= -github.com/fsnotify/fsnotify v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S9k= -github.com/fsnotify/fsnotify v1.9.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0= -github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= -github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= -github.com/go-resty/resty/v2 v2.16.5 h1:hBKqmWrr7uRc3euHVqmh1HTHcKn99Smr7o5spptdhTM= -github.com/go-resty/resty/v2 v2.16.5/go.mod h1:hkJtXbA2iKHzJheXYvQ8snQES5ZLGKMwQ07xAwp/fiA= -github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI= -github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8= -github.com/go-viper/mapstructure/v2 v2.4.0 h1:EBsztssimR/CONLSZZ04E8qAkxNYq4Qp9LvH92wZUgs= -github.com/go-viper/mapstructure/v2 v2.4.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM= +github.com/fsnotify/fsnotify v1.10.1 h1:b0/UzAf9yR5rhf3RPm9gf3ehBPpf0oZKIjtpKrx59Ho= +github.com/fsnotify/fsnotify v1.10.1/go.mod h1:TLheqan6HD6GBK6PrDWyDPBaEV8LspOxvPSjC+bVfgo= +github.com/go-resty/resty/v2 v2.17.2 h1:FQW5oHYcIlkCNrMD2lloGScxcHJ0gkjshV3qcQAyHQk= +github.com/go-resty/resty/v2 v2.17.2/go.mod h1:kCKZ3wWmwJaNc7S29BRtUhJwy7iqmn+2mLtQrOyQlVA= +github.com/go-viper/mapstructure/v2 v2.5.0 h1:vM5IJoUAy3d7zRSVtIwQgBj7BiWtMPfmPEgAXnvj1Ro= +github.com/go-viper/mapstructure/v2 v2.5.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= -github.com/google/pprof v0.0.0-20250403155104-27863c87afa6 h1:BHT72Gu3keYf3ZEu2J0b1vyeLSOYI8bm5wbJM/8yDe8= -github.com/google/pprof v0.0.0-20250403155104-27863c87afa6/go.mod h1:boTsfXsheKC2y+lKOCMpSfarhxDeIzfZG1jqGcPl3cA= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg= @@ -32,35 +26,31 @@ github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/onsi/ginkgo/v2 v2.23.4 h1:ktYTpKJAVZnDT4VjxSbiBenUjmlL/5QkBEocaWXiQus= -github.com/onsi/ginkgo/v2 v2.23.4/go.mod h1:Bt66ApGPBFzHyR+JO10Zbt0Gsp4uWxu5mIOTusL46e8= -github.com/onsi/gomega v1.38.0 h1:c/WX+w8SLAinvuKKQFh77WEucCnPk4j2OTUr7lt7BeY= -github.com/onsi/gomega v1.38.0/go.mod h1:OcXcwId0b9QsE7Y49u+BTrL4IdKOBOKnD6VQNTJEB6o= -github.com/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0t5Ec4= -github.com/pelletier/go-toml/v2 v2.2.4/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY= +github.com/onsi/gomega v1.42.1 h1:iN1rCUX+44NZ1Dc97MPoeFYbFR0vh8zxoxMFwKdyZ6I= +github.com/onsi/gomega v1.42.1/go.mod h1:REff/hsDsodHoKlWsP2mAPhu1+5/6hVYNf9rIEBpeSg= +github.com/pelletier/go-toml/v2 v2.4.3 h1:GTRvJQutkOSftxIFD5xw9aepkYNuPWmVJpffdDPYVpY= +github.com/pelletier/go-toml/v2 v2.4.3/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/sagikazarmark/locafero v0.10.0 h1:FM8Cv6j2KqIhM2ZK7HZjm4mpj9NBktLgowT1aN9q5Cc= -github.com/sagikazarmark/locafero v0.10.0/go.mod h1:Ieo3EUsjifvQu4NZwV5sPd4dwvu0OCgEQV7vjc9yDjw= -github.com/serverscom/serverscom-go-client v1.0.32 h1:7pW3TJN4x7vF5QPSjBxQ3IKEr656LSaLgAZ3/09395k= -github.com/serverscom/serverscom-go-client v1.0.32/go.mod h1:/Nf+XygKOxm19Sl2gvMzT55O4X+tWDkj/UM4mjzfKgM= -github.com/sourcegraph/conc v0.3.1-0.20240121214520-5f936abd7ae8 h1:+jumHNA0Wrelhe64i8F6HNlS8pkoyMv5sreGx2Ry5Rw= -github.com/sourcegraph/conc v0.3.1-0.20240121214520-5f936abd7ae8/go.mod h1:3n1Cwaq1E1/1lhQhtRK2ts/ZwZEhjcQeJQ1RuC6Q/8U= -github.com/spf13/afero v1.14.0 h1:9tH6MapGnn/j0eb0yIXiLjERO8RB6xIVZRDCX7PtqWA= -github.com/spf13/afero v1.14.0/go.mod h1:acJQ8t0ohCGuMN3O+Pv0V0hgMxNYDlvdk+VTfyZmbYo= -github.com/spf13/cast v1.9.2 h1:SsGfm7M8QOFtEzumm7UZrZdLLquNdzFYfIbEXntcFbE= -github.com/spf13/cast v1.9.2/go.mod h1:jNfB8QC9IA6ZuY2ZjDp0KtFO2LZZlg4S/7bzP6qqeHo= -github.com/spf13/cobra v1.9.1 h1:CXSaggrXdbHK9CF+8ywj8Amf7PBRmPCOJugH954Nnlo= -github.com/spf13/cobra v1.9.1/go.mod h1:nDyEzZ8ogv936Cinf6g1RU9MRY64Ir93oCnqb9wxYW0= -github.com/spf13/pflag v1.0.6/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= -github.com/spf13/pflag v1.0.7 h1:vN6T9TfwStFPFM5XzjsvmzZkLuaLX+HS+0SeFLRgU6M= -github.com/spf13/pflag v1.0.7/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= -github.com/spf13/viper v1.20.1 h1:ZMi+z/lvLyPSCoNtFCpqjy0S4kPbirhpTMwl8BkW9X4= -github.com/spf13/viper v1.20.1/go.mod h1:P9Mdzt1zoHIG8m2eZQinpiBjo6kCmZSKBClNNqjJvu4= +github.com/sagikazarmark/locafero v0.12.0 h1:/NQhBAkUb4+fH1jivKHWusDYFjMOOKU88eegjfxfHb4= +github.com/sagikazarmark/locafero v0.12.0/go.mod h1:sZh36u/YSZ918v0Io+U9ogLYQJ9tLLBmM4eneO6WwsI= +github.com/serverscom/serverscom-go-client v1.0.33 h1:JdpzoJnOjUEappDxxGSzhHC4At7RaZItrg7o7wVQZpg= +github.com/serverscom/serverscom-go-client v1.0.33/go.mod h1:/Nf+XygKOxm19Sl2gvMzT55O4X+tWDkj/UM4mjzfKgM= +github.com/spf13/afero v1.15.0 h1:b/YBCLWAJdFWJTN9cLhiXXcD7mzKn9Dm86dNnfyQw1I= +github.com/spf13/afero v1.15.0/go.mod h1:NC2ByUVxtQs4b3sIUphxK0NioZnmxgyCrfzeuq8lxMg= +github.com/spf13/cast v1.10.0 h1:h2x0u2shc1QuLHfxi+cTJvs30+ZAHOGRic8uyGTDWxY= +github.com/spf13/cast v1.10.0/go.mod h1:jNfB8QC9IA6ZuY2ZjDp0KtFO2LZZlg4S/7bzP6qqeHo= +github.com/spf13/cobra v1.10.2 h1:DMTTonx5m65Ic0GOoRY2c16WCbHxOOw6xxezuLaBpcU= +github.com/spf13/cobra v1.10.2/go.mod h1:7C1pvHqHw5A4vrJfjNwvOdzYu0Gml16OCs2GRiTUUS4= +github.com/spf13/pflag v1.0.9/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +github.com/spf13/pflag v1.0.10 h1:4EBh2KAYBwaONj6b2Ye1GiHfwjqyROoF4RwYO+vPwFk= +github.com/spf13/pflag v1.0.10/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +github.com/spf13/viper v1.21.0 h1:x5S+0EU27Lbphp4UKm1C+1oQO+rKx36vfCoaVebLFSU= +github.com/spf13/viper v1.21.0/go.mod h1:P0lhsswPGWD/1lZJ9ny3fYnVqxiegrlNrEmgLjbTCAY= github.com/stoewer/go-strcase v1.3.1 h1:iS0MdW+kVTxgMoE1LAZyMiYJFKlOzLooE4MxjirtkAs= github.com/stoewer/go-strcase v1.3.1/go.mod h1:fAH5hQ5pehh+j3nZfvwdk2RgEgQjAoM8wodgtPmh1xo= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= @@ -69,26 +59,24 @@ github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpE github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= -github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= +github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= -go.uber.org/automaxprocs v1.6.0 h1:O3y2/QNTOdbF+e/dpXNNW7Rx2hZ4sTIPyybbxyNqTUs= -go.uber.org/automaxprocs v1.6.0/go.mod h1:ifeIMSnPZuznNm6jmdzmU3/bfk01Fe2fotchwEFJ8r8= -go.uber.org/mock v0.5.2 h1:LbtPTcP8A5k9WPXj54PPPbjcI4Y6lhyOZXn+VS7wNko= -go.uber.org/mock v0.5.2/go.mod h1:wLlUxC2vVTPTaE3UD51E0BGOAElKrILxhVSDYQLld5o= -golang.org/x/net v0.43.0 h1:lat02VYK2j4aLzMzecihNvTlJNQUq316m2Mr9rnM6YE= -golang.org/x/net v0.43.0/go.mod h1:vhO1fvI4dGsIjh73sWfUVjj3N7CA9WkKJNQm2svM6Jg= -golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI= -golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= -golang.org/x/term v0.34.0 h1:O/2T7POpk0ZZ7MAzMeWFSg6S5IpWd/RXDlM9hgM3DR4= -golang.org/x/term v0.34.0/go.mod h1:5jC53AEywhIVebHgPVeg0mj8OD3VO9OzclacVrqpaAw= -golang.org/x/text v0.28.0 h1:rhazDwis8INMIwQ4tpjLDzUhx6RlXqZNPEM0huQojng= -golang.org/x/text v0.28.0/go.mod h1:U8nCwOR8jO/marOQ0QbDiOngZVEBB7MAiitBuMjXiNU= -golang.org/x/time v0.6.0 h1:eTDhh4ZXt5Qf0augr54TN6suAUudPcawVZeIAPU7D4U= -golang.org/x/time v0.6.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= -golang.org/x/tools v0.35.0 h1:mBffYraMEf7aa0sB+NuKnuCy8qI/9Bughn8dC2Gu5r0= -golang.org/x/tools v0.35.0/go.mod h1:NKdj5HkL/73byiZSJjqJgKn3ep7KjFkBOkR/Hps3VPw= +go.uber.org/mock v0.6.0 h1:hyF9dfmbgIX5EfOdasqLsWD6xqpNZlXblLB/Dbnwv3Y= +go.uber.org/mock v0.6.0/go.mod h1:KiVJ4BqZJaMj4svdfmHM0AUx4NJYO8ZNpPnZn1Z+BBU= +go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc= +go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg= +golang.org/x/net v0.57.0 h1:K5+3DljvIuDG9/Jv9rvyMywYNFCQ9RSUY6OOTTkT+tE= +golang.org/x/net v0.57.0/go.mod h1:KpXc8iv+r3XplLAG/f7Jsf9RPszJzdR0f58q9vGOuEU= +golang.org/x/sys v0.47.0 h1:o7XGOvZQCADBQQ4Y7VNq2dRWQR7JmOUW8Kxx4ZsNgWs= +golang.org/x/sys v0.47.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw= +golang.org/x/term v0.45.0 h1:NwWyBmoJCbfTHpxrWoZ9C6/VxOf7ic219I8xZZFdrf0= +golang.org/x/term v0.45.0/go.mod h1:9aqxs0blBcrm/n0L9QW0aRVD+ktan8ssZromtqJC43w= +golang.org/x/text v0.40.0 h1:Ub2Z6/xjgF1WrYQz2nuITOEegKFtiIy+rieRJ5lHZKs= +golang.org/x/text v0.40.0/go.mod h1:hpnzDAfGV753zIKo+wk3u1bVKCGPbrnF7+7LBF/UHVY= +golang.org/x/time v0.12.0 h1:ScB/8o8olJvc+CQPWrK3fPZNfh7qgwCrY0zJmoEQLSE= +golang.org/x/time v0.12.0/go.mod h1:CDIdPxbZBQxdj6cxyCIdrNogrJKMJ7pr37NYpMcMDSg= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/internal/output/entities/accounts.go b/internal/output/entities/accounts.go index 2749ea1..5f66c6a 100644 --- a/internal/output/entities/accounts.go +++ b/internal/output/entities/accounts.go @@ -8,7 +8,7 @@ import ( ) var ( - AccountBalanceType = reflect.TypeOf(serverscom.AccountBalance{}) + AccountBalanceType = reflect.TypeFor[serverscom.AccountBalance]() ) func RegisterAccountDefinition() { diff --git a/internal/output/entities/cloud_backups.go b/internal/output/entities/cloud_backups.go index f33e5c6..133dfc4 100644 --- a/internal/output/entities/cloud_backups.go +++ b/internal/output/entities/cloud_backups.go @@ -8,7 +8,7 @@ import ( ) var ( - CloudBlockStorageBackupType = reflect.TypeOf(serverscom.CloudBlockStorageBackup{}) + CloudBlockStorageBackupType = reflect.TypeFor[serverscom.CloudBlockStorageBackup]() CloudBlockStorageBackupListDefaultFields = []string{"ID", "Name", "Status", "Size", "RegionCode"} ) diff --git a/internal/output/entities/cloud_instances.go b/internal/output/entities/cloud_instances.go index e960ec5..13d3183 100644 --- a/internal/output/entities/cloud_instances.go +++ b/internal/output/entities/cloud_instances.go @@ -8,7 +8,7 @@ import ( ) var ( - CloudComputingInstanceType = reflect.TypeOf(serverscom.CloudComputingInstance{}) + CloudComputingInstanceType = reflect.TypeFor[serverscom.CloudComputingInstance]() CloudComputingInstanceListDefaultFields = []string{"ID", "Name", "RegionCode", "Status", "PublicIPv4Address"} ) diff --git a/internal/output/entities/cloud_regions.go b/internal/output/entities/cloud_regions.go index 5a522ba..b881913 100644 --- a/internal/output/entities/cloud_regions.go +++ b/internal/output/entities/cloud_regions.go @@ -8,15 +8,15 @@ import ( ) var ( - CloudComputingRegionType = reflect.TypeOf(serverscom.CloudComputingRegion{}) + CloudComputingRegionType = reflect.TypeFor[serverscom.CloudComputingRegion]() CloudComputingRegionListDefaultFields = []string{"ID", "Name", "Code"} - CloudComputingImageType = reflect.TypeOf(serverscom.CloudComputingImage{}) + CloudComputingImageType = reflect.TypeFor[serverscom.CloudComputingImage]() CloudComputingImageListDefaultFields = []string{"ID", "Name"} - CloudComputingFlavorType = reflect.TypeOf(serverscom.CloudComputingFlavor{}) + CloudComputingFlavorType = reflect.TypeFor[serverscom.CloudComputingFlavor]() CloudComputingFlavorListDefaultFields = []string{"ID", "Name"} - CloudSnapshotType = reflect.TypeOf(serverscom.CloudSnapshot{}) + CloudSnapshotType = reflect.TypeFor[serverscom.CloudSnapshot]() CloudSnapshotListDefaultFields = []string{"ID", "Name", "ImageSize", "MinDisk", "Status", "IsBackup", "FileURL"} - CloudComputingRegionCredentialsType = reflect.TypeOf(serverscom.CloudComputingRegionCredentials{}) + CloudComputingRegionCredentialsType = reflect.TypeFor[serverscom.CloudComputingRegionCredentials]() ) func RegisterCloudComputingRegionDefinitions() { diff --git a/internal/output/entities/cloud_volumes.go b/internal/output/entities/cloud_volumes.go index f072bde..6699028 100644 --- a/internal/output/entities/cloud_volumes.go +++ b/internal/output/entities/cloud_volumes.go @@ -8,7 +8,7 @@ import ( ) var ( - CloudVolumeType = reflect.TypeOf(serverscom.CloudBlockStorageVolume{}) + CloudVolumeType = reflect.TypeFor[serverscom.CloudBlockStorageVolume]() CloudVolumeListDefaultFields = []string{"ID", "Name", "RegionID", "RegionCode", "Size", "Description"} ) diff --git a/internal/output/entities/drivemodels.go b/internal/output/entities/drivemodels.go index 1864d53..2c3ba4f 100644 --- a/internal/output/entities/drivemodels.go +++ b/internal/output/entities/drivemodels.go @@ -8,7 +8,7 @@ import ( ) var ( - DriveModelOptionType = reflect.TypeOf(serverscom.DriveModel{}) + DriveModelOptionType = reflect.TypeFor[serverscom.DriveModel]() ) func RegisterDriveModelOptionDefinition() { diff --git a/internal/output/entities/handlers.go b/internal/output/entities/handlers.go index 48b166d..6603fc8 100644 --- a/internal/output/entities/handlers.go +++ b/internal/output/entities/handlers.go @@ -25,7 +25,7 @@ func stringHandler(w io.Writer, v any, indent string, _ *Field) error { } val := reflect.ValueOf(v) - if val.Kind() == reflect.Ptr { + if val.Kind() == reflect.Pointer { if val.IsNil() { fmt.Fprintf(w, "%s", indent) return nil diff --git a/internal/output/entities/hosts.go b/internal/output/entities/hosts.go index c66af91..73e95b6 100644 --- a/internal/output/entities/hosts.go +++ b/internal/output/entities/hosts.go @@ -8,18 +8,18 @@ import ( ) var ( - HostType = reflect.TypeOf(serverscom.Host{}) - DedicatedServerType = reflect.TypeOf(serverscom.DedicatedServer{}) - KubernetesBaremetalNodeType = reflect.TypeOf(serverscom.KubernetesBaremetalNode{}) - SBMServerType = reflect.TypeOf(serverscom.SBMServer{}) - HostConnectionType = reflect.TypeOf(serverscom.HostConnection{}) - HostPowerFeedType = reflect.TypeOf(serverscom.HostPowerFeed{}) - HostDriveSlotType = reflect.TypeOf(serverscom.HostDriveSlot{}) - HostPTRRecordType = reflect.TypeOf(serverscom.PTRRecord{}) - HostNetworkType = reflect.TypeOf(serverscom.Network{}) - HostFeatureType = reflect.TypeOf(serverscom.DedicatedServerFeature{}) - HostServiceType = reflect.TypeOf(serverscom.DedicatedServerService{}) - HostOOBCredsType = reflect.TypeOf(serverscom.DedicatedServerOOBCredentials{}) + HostType = reflect.TypeFor[serverscom.Host]() + DedicatedServerType = reflect.TypeFor[serverscom.DedicatedServer]() + KubernetesBaremetalNodeType = reflect.TypeFor[serverscom.KubernetesBaremetalNode]() + SBMServerType = reflect.TypeFor[serverscom.SBMServer]() + HostConnectionType = reflect.TypeFor[serverscom.HostConnection]() + HostPowerFeedType = reflect.TypeFor[serverscom.HostPowerFeed]() + HostDriveSlotType = reflect.TypeFor[serverscom.HostDriveSlot]() + HostPTRRecordType = reflect.TypeFor[serverscom.PTRRecord]() + HostNetworkType = reflect.TypeFor[serverscom.Network]() + HostFeatureType = reflect.TypeFor[serverscom.DedicatedServerFeature]() + HostServiceType = reflect.TypeFor[serverscom.DedicatedServerService]() + HostOOBCredsType = reflect.TypeFor[serverscom.DedicatedServerOOBCredentials]() HostListDefaultFields = []string{"ID", "Type", "Title", "LocationCode", "Status", "PublicIPv4Address"} DedicatedServerListDefaultFields = []string{"ID", "Title", "RackID", "LocationCode", "Status", "PublicIPv4Address"} KubernetesBaremetalNodeListDefaultFields = []string{"ID", "KubernetesClusterNodeNumber", "Title", "LocationCode", "Status", "PublicIPv4Address"} diff --git a/internal/output/entities/interface.go b/internal/output/entities/interface.go index 86595e6..0e4f11a 100644 --- a/internal/output/entities/interface.go +++ b/internal/output/entities/interface.go @@ -83,7 +83,7 @@ func (r *EntityRegistry) Register(entity EntityInterface) error { // GetEntityFromValue returns the entity interface from a given value func (r *EntityRegistry) GetEntityFromValue(v any) (EntityInterface, error) { t := reflect.TypeOf(v) - for t.Kind() == reflect.Ptr || t.Kind() == reflect.Slice { + for t.Kind() == reflect.Pointer || t.Kind() == reflect.Slice { t = t.Elem() } diff --git a/internal/output/entities/invoices.go b/internal/output/entities/invoices.go index a3db987..7b153e9 100644 --- a/internal/output/entities/invoices.go +++ b/internal/output/entities/invoices.go @@ -8,8 +8,8 @@ import ( ) var ( - InvoiceType = reflect.TypeOf(serverscom.Invoice{}) - InvoiceListType = reflect.TypeOf(serverscom.InvoiceList{}) + InvoiceType = reflect.TypeFor[serverscom.Invoice]() + InvoiceListType = reflect.TypeFor[serverscom.InvoiceList]() ) func RegisterInvoiceDefinition() { diff --git a/internal/output/entities/k8s.go b/internal/output/entities/k8s.go index 013fad0..99e092b 100644 --- a/internal/output/entities/k8s.go +++ b/internal/output/entities/k8s.go @@ -8,8 +8,8 @@ import ( ) var ( - KubernetesClusterType = reflect.TypeOf(serverscom.KubernetesCluster{}) - KubernetesClusterNodeType = reflect.TypeOf(serverscom.KubernetesClusterNode{}) + KubernetesClusterType = reflect.TypeFor[serverscom.KubernetesCluster]() + KubernetesClusterNodeType = reflect.TypeFor[serverscom.KubernetesClusterNode]() KubernetesClusterListDefaultFields = []string{"ID", "Name", "Status", "LocationID", "LocationCode"} KubernetesClusterNodeListDefaultFields = []string{"ID", "Number", "Hostname", "Type", "Role", "Status", "PrivateIPv4Address", "PublicIPv4Address"} ) diff --git a/internal/output/entities/l2_segments.go b/internal/output/entities/l2_segments.go index 6c96629..b2d4f4a 100644 --- a/internal/output/entities/l2_segments.go +++ b/internal/output/entities/l2_segments.go @@ -8,10 +8,10 @@ import ( ) var ( - L2SegmentType = reflect.TypeOf(serverscom.L2Segment{}) - L2SegmentLocationGroupType = reflect.TypeOf(serverscom.L2LocationGroup{}) - L2SegmentMemberType = reflect.TypeOf(serverscom.L2Member{}) - L2SegmentNetworkType = reflect.TypeOf(serverscom.Network{}) + L2SegmentType = reflect.TypeFor[serverscom.L2Segment]() + L2SegmentLocationGroupType = reflect.TypeFor[serverscom.L2LocationGroup]() + L2SegmentMemberType = reflect.TypeFor[serverscom.L2Member]() + L2SegmentNetworkType = reflect.TypeFor[serverscom.Network]() L2SegmentListDefaultFields = []string{"ID", "Name", "Type", "Status", "LocationGroupID", "LocationGroupCode"} L2SegmentMemberListDefaultFields = []string{"ID", "Title", "Mode", "VLAN", "Status"} ) diff --git a/internal/output/entities/load_balancer_clusters.go b/internal/output/entities/load_balancer_clusters.go index 69a00f0..672f243 100644 --- a/internal/output/entities/load_balancer_clusters.go +++ b/internal/output/entities/load_balancer_clusters.go @@ -8,7 +8,7 @@ import ( ) var ( - LoadBalancerClusterType = reflect.TypeOf(serverscom.LoadBalancerCluster{}) + LoadBalancerClusterType = reflect.TypeFor[serverscom.LoadBalancerCluster]() ) func RegisterLoadBalancerClusterDefinition() { diff --git a/internal/output/entities/load_balancers.go b/internal/output/entities/load_balancers.go index ef94fac..0bdabb8 100644 --- a/internal/output/entities/load_balancers.go +++ b/internal/output/entities/load_balancers.go @@ -8,9 +8,9 @@ import ( ) var ( - LoadBalancerType = reflect.TypeOf(serverscom.LoadBalancer{}) - L4LoadBalancerType = reflect.TypeOf(serverscom.L4LoadBalancer{}) - L7LoadBalancerType = reflect.TypeOf(serverscom.L7LoadBalancer{}) + LoadBalancerType = reflect.TypeFor[serverscom.LoadBalancer]() + L4LoadBalancerType = reflect.TypeFor[serverscom.L4LoadBalancer]() + L7LoadBalancerType = reflect.TypeFor[serverscom.L7LoadBalancer]() LoadBalancerListDefaultFields = []string{"ID", "Name", "Type", "Status", "LocationID", "LocationCode", "ClusterID"} ) diff --git a/internal/output/entities/location.go b/internal/output/entities/location.go index fc55977..e5e84c8 100644 --- a/internal/output/entities/location.go +++ b/internal/output/entities/location.go @@ -8,7 +8,7 @@ import ( ) var ( - LocationType = reflect.TypeOf(serverscom.Location{}) + LocationType = reflect.TypeFor[serverscom.Location]() ) func RegisterLocationDefinition() { diff --git a/internal/output/entities/network_pools.go b/internal/output/entities/network_pools.go index 5760a8d..dd14b3f 100644 --- a/internal/output/entities/network_pools.go +++ b/internal/output/entities/network_pools.go @@ -8,10 +8,10 @@ import ( ) var ( - NetworkPoolType = reflect.TypeOf(serverscom.NetworkPool{}) + NetworkPoolType = reflect.TypeFor[serverscom.NetworkPool]() NetworkPoolListDefaultFields = []string{"ID", "Title", "CIDR", "Type", "LocationCodes"} - SubnetworkType = reflect.TypeOf(serverscom.Subnetwork{}) + SubnetworkType = reflect.TypeFor[serverscom.Subnetwork]() SubnetworkListDefaultFields = []string{"ID", "Title", "CIDR", "Attached", "InterfaceType"} ) diff --git a/internal/output/entities/os_options.go b/internal/output/entities/os_options.go index a26485b..c77aa87 100644 --- a/internal/output/entities/os_options.go +++ b/internal/output/entities/os_options.go @@ -8,7 +8,7 @@ import ( ) var ( - OperatingSystemOptionType = reflect.TypeOf(serverscom.OperatingSystemOption{}) + OperatingSystemOptionType = reflect.TypeFor[serverscom.OperatingSystemOption]() ) func RegisterOperatingSystemOptionDefinition() { diff --git a/internal/output/entities/rack.go b/internal/output/entities/rack.go index 039a48b..8bddc4e 100644 --- a/internal/output/entities/rack.go +++ b/internal/output/entities/rack.go @@ -8,7 +8,7 @@ import ( ) var ( - RackType = reflect.TypeOf(serverscom.Rack{}) + RackType = reflect.TypeFor[serverscom.Rack]() ) func RegisterRackDefinition() { diff --git a/internal/output/entities/ram_options.go b/internal/output/entities/ram_options.go index 0d2e1db..f3d4d73 100644 --- a/internal/output/entities/ram_options.go +++ b/internal/output/entities/ram_options.go @@ -8,7 +8,7 @@ import ( ) var ( - RAMOptionType = reflect.TypeOf(serverscom.RAMOption{}) + RAMOptionType = reflect.TypeFor[serverscom.RAMOption]() ) func RegisterRAMOptionDefinition() { diff --git a/internal/output/entities/rbs_credentials.go b/internal/output/entities/rbs_credentials.go index 9dbba80..2082383 100644 --- a/internal/output/entities/rbs_credentials.go +++ b/internal/output/entities/rbs_credentials.go @@ -8,7 +8,7 @@ import ( ) var ( - RBSVolumeCredentialsType = reflect.TypeOf(serverscom.RemoteBlockStorageVolumeCredentials{}) + RBSVolumeCredentialsType = reflect.TypeFor[serverscom.RemoteBlockStorageVolumeCredentials]() ) func RegisterRbsVolumeCredentialsDefinition() { diff --git a/internal/output/entities/rbs_volumes.go b/internal/output/entities/rbs_volumes.go index abf2402..e9b7a6d 100644 --- a/internal/output/entities/rbs_volumes.go +++ b/internal/output/entities/rbs_volumes.go @@ -8,7 +8,7 @@ import ( ) var ( - RBSVolumeType = reflect.TypeOf(serverscom.RemoteBlockStorageVolume{}) + RBSVolumeType = reflect.TypeFor[serverscom.RemoteBlockStorageVolume]() ) func RegisterRbsVolumeDefinitions() { diff --git a/internal/output/entities/sbm_models.go b/internal/output/entities/sbm_models.go index 2d31978..24c6b79 100644 --- a/internal/output/entities/sbm_models.go +++ b/internal/output/entities/sbm_models.go @@ -8,7 +8,7 @@ import ( ) var ( - SBMFlavorType = reflect.TypeOf(serverscom.SBMFlavor{}) + SBMFlavorType = reflect.TypeFor[serverscom.SBMFlavor]() ) func RegisterSBMModelOptionDefinition() { diff --git a/internal/output/entities/server_models.go b/internal/output/entities/server_models.go index 9a29b9e..41f5914 100644 --- a/internal/output/entities/server_models.go +++ b/internal/output/entities/server_models.go @@ -8,8 +8,8 @@ import ( ) var ( - ServerModelOptionType = reflect.TypeOf(serverscom.ServerModelOption{}) - ServerModelOptionDetailType = reflect.TypeOf(serverscom.ServerModelOptionDetail{}) + ServerModelOptionType = reflect.TypeFor[serverscom.ServerModelOption]() + ServerModelOptionDetailType = reflect.TypeFor[serverscom.ServerModelOptionDetail]() ) func getServerModelDriveSlotsField() Field { diff --git a/internal/output/entities/ssh_keys.go b/internal/output/entities/ssh_keys.go index e1d01e9..20b8b7e 100644 --- a/internal/output/entities/ssh_keys.go +++ b/internal/output/entities/ssh_keys.go @@ -8,7 +8,7 @@ import ( ) var ( - SSHKeyType = reflect.TypeOf(serverscom.SSHKey{}) + SSHKeyType = reflect.TypeFor[serverscom.SSHKey]() SSHKeyListDefaultFields = []string{"Name", "Fingerprint"} ) diff --git a/internal/output/entities/ssl.go b/internal/output/entities/ssl.go index 125727e..2c4bf16 100644 --- a/internal/output/entities/ssl.go +++ b/internal/output/entities/ssl.go @@ -8,9 +8,9 @@ import ( ) var ( - SSLCertType = reflect.TypeOf(serverscom.SSLCertificate{}) - SSLCertCustomType = reflect.TypeOf(serverscom.SSLCertificateCustom{}) - SSLCertLeType = reflect.TypeOf(serverscom.SSLCertificateLE{}) + SSLCertType = reflect.TypeFor[serverscom.SSLCertificate]() + SSLCertCustomType = reflect.TypeFor[serverscom.SSLCertificateCustom]() + SSLCertLeType = reflect.TypeFor[serverscom.SSLCertificateLE]() SSLCertListDefaultFields = []string{"ID", "Name", "Type", "Fingerprint"} ) diff --git a/internal/output/entities/uplink_bandwidths.go b/internal/output/entities/uplink_bandwidths.go index f6ce3a3..9ce54a8 100644 --- a/internal/output/entities/uplink_bandwidths.go +++ b/internal/output/entities/uplink_bandwidths.go @@ -8,7 +8,7 @@ import ( ) var ( - BandwidthOptionType = reflect.TypeOf(serverscom.BandwidthOption{}) + BandwidthOptionType = reflect.TypeFor[serverscom.BandwidthOption]() ) func RegisterBandwidthOptionDefinition() { diff --git a/internal/output/entities/uplink_models.go b/internal/output/entities/uplink_models.go index ee5a250..ea1a24e 100644 --- a/internal/output/entities/uplink_models.go +++ b/internal/output/entities/uplink_models.go @@ -8,7 +8,7 @@ import ( ) var ( - UplinkOptionType = reflect.TypeOf(serverscom.UplinkOption{}) + UplinkOptionType = reflect.TypeFor[serverscom.UplinkOption]() ) func RegisterUplinkOptionDefinition() { diff --git a/internal/output/utils.go b/internal/output/utils.go index d8cc1e0..fa4000f 100644 --- a/internal/output/utils.go +++ b/internal/output/utils.go @@ -18,7 +18,7 @@ func (f *Formatter) ListEntityFields(fields []entities.Field) { for _, field := range fields { f.printField(w, field) } - w.Flush() + _ = w.Flush() } // printField prints a single field to the writer @@ -94,7 +94,7 @@ func (f *Formatter) formatText(v any) error { } w := tabwriter.NewWriter(f.writer, 0, 0, 3, ' ', 0) - defer w.Flush() + defer w.Flush() //nolint:errcheck orderedFields := f.getOrderedFields(entity) @@ -114,7 +114,7 @@ func (f *Formatter) formatText(v any) error { // processValue processes the value of a field and applies any necessary formatting or processing. func processValue(value reflect.Value, processor func(any) error) error { - if value.Kind() == reflect.Ptr { + if value.Kind() == reflect.Pointer { value = value.Elem() } @@ -162,12 +162,12 @@ func (f *Formatter) formatPageView(v any, entity entities.EntityInterface) error orderedFields := f.getOrderedFields(entity) value := reflect.ValueOf(v) - if value.Kind() == reflect.Ptr { + if value.Kind() == reflect.Pointer { value = value.Elem() } w := tabwriter.NewWriter(f.writer, 0, 0, 2, ' ', 0) - defer w.Flush() + defer w.Flush() //nolint:errcheck switch value.Kind() { case reflect.Slice: @@ -177,7 +177,7 @@ func (f *Formatter) formatPageView(v any, entity entities.EntityInterface) error } if i < value.Len()-1 { fmt.Fprintln(w, "---") - w.Flush() + _ = w.Flush() } } default: