Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(deps): update module github.com/golangci/golangci-lint (v1.61.0 → v1.62.0) in /tools #1634

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ linters:
enable-all: true
disable:
# deprecated
- execinquery
- exportloopref
- gocyclo
- rowserrcheck
Expand All @@ -72,7 +71,6 @@ linters:
- exhaustruct
- gci
- err113
- gomnd
- ireturn
- maintidx
- mnd
Expand Down
12 changes: 6 additions & 6 deletions fwprovider/types/nodes/apt/standard_repo_handle.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/

package apt

Expand Down Expand Up @@ -133,8 +133,8 @@ func (t StandardRepoHandleType) ValueType(_ context.Context) attr.Value {

// CephVersionName returns the corresponding Ceph major version name.
// Note that the version will be [apitypes.CephVersionNameUnknown] when not a Ceph specific handle!
func (v StandardRepoHandleValue) CephVersionName() apitypes.CephVersionName {
return v.cvn
func (v StandardRepoHandleValue) CephVersionName() *apitypes.CephVersionName {
return &v.cvn
}

// ComponentName returns the corresponding component name.
Expand Down
4 changes: 2 additions & 2 deletions fwprovider/types/nodes/apt/standard_repo_handle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func TestStandardRepoHandleValueFromTerraform(t *testing.T) {
val: tftypes.NewValue(tftypes.String, "ceph-quincy-enterprise"),
expected: func(val StandardRepoHandleValue) bool {
return val.kind == apitypes.StandardRepoHandleKindEnterprise &&
val.CephVersionName() == apitypes.CephVersionNameQuincy &&
*val.CephVersionName() == apitypes.CephVersionNameQuincy &&
val.IsCephHandle() &&
val.IsSupportedFilePath(apitypes.StandardRepoFilePathCeph) &&
val.ComponentName() == "enterprise" &&
Expand All @@ -60,7 +60,7 @@ func TestStandardRepoHandleValueFromTerraform(t *testing.T) {
val: tftypes.NewValue(tftypes.String, "ceph-reef-test"),
expected: func(val StandardRepoHandleValue) bool {
return val.kind == apitypes.StandardRepoHandleKindTest &&
val.CephVersionName() == apitypes.CephVersionNameReef &&
*val.CephVersionName() == apitypes.CephVersionNameReef &&
val.IsCephHandle() &&
val.IsSupportedFilePath(apitypes.StandardRepoFilePathCeph) &&
val.ComponentName() == "test" &&
Expand Down
10 changes: 7 additions & 3 deletions proxmox/cluster/acme/plugins/acme_plugins_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,14 @@ type ACMEPluginsUpdateRequestBody struct {
type DNSPluginData map[string]string

// EncodeValues encodes the DNSPluginData into the URL values.
func (d DNSPluginData) EncodeValues(key string, v *url.Values) error {
values := make([]string, 0, len(d))
func (d *DNSPluginData) EncodeValues(key string, v *url.Values) error {
if d == nil {
return nil
}

values := make([]string, 0, len(*d))

for key, value := range d {
for key, value := range *d {
values = append(values, fmt.Sprintf("%s=%s", key, value))
}

Expand Down
43 changes: 30 additions & 13 deletions proxmox/types/ha_resource_id.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@ func ParseHAResourceID(input string) (HAResourceID, error) {
if resType == HAResourceTypeVM || resType == HAResourceTypeContainer {
id, err := strconv.Atoi(inParts[1])
if err != nil {
return resID, fmt.Errorf("invalid %s HA resource name '%s': %w", resType, inParts[1], err)
return resID, fmt.Errorf("invalid %v HA resource name '%s': %w", resType, inParts[1], err)
}

if id < 100 {
return resID, fmt.Errorf("invalid %s HA resource name '%s': minimum value is 100", resType, inParts[1])
return resID, fmt.Errorf("invalid %v HA resource name '%s': minimum value is 100", resType, inParts[1])
}

if id > 999_999_999 {
return resID, fmt.Errorf("invalid %s HA resource name '%s': maximum value is 999999999", resType, inParts[1])
return resID, fmt.Errorf("invalid %v HA resource name '%s': maximum value is 999999999", resType, inParts[1])
}
}

Expand All @@ -72,13 +72,21 @@ func ParseHAResourceID(input string) (HAResourceID, error) {
}

// String converts a HAResourceID value into a string.
func (rid HAResourceID) String() string {
return fmt.Sprintf("%s:%s", rid.Type, rid.Name)
func (i *HAResourceID) String() string {
if i == nil {
return ""
}

return fmt.Sprintf("%v:%s", i.Type, i.Name)
}

// MarshalJSON marshals a HA resource identifier into JSON value.
func (rid HAResourceID) MarshalJSON() ([]byte, error) {
bytes, err := json.Marshal(rid.String())
func (i *HAResourceID) MarshalJSON() ([]byte, error) {
if i == nil {
return []byte("null"), nil
}

bytes, err := json.Marshal(i.String())
if err != nil {
return nil, fmt.Errorf("cannot marshal HA resource identifier: %w", err)
}
Expand All @@ -87,7 +95,7 @@ func (rid HAResourceID) MarshalJSON() ([]byte, error) {
}

// UnmarshalJSON unmarshals a Proxmox HA resource identifier.
func (rid *HAResourceID) UnmarshalJSON(b []byte) error {
func (i *HAResourceID) UnmarshalJSON(b []byte) error {
var ridString string

err := json.Unmarshal(b, &ridString)
Expand All @@ -97,19 +105,28 @@ func (rid *HAResourceID) UnmarshalJSON(b []byte) error {

resType, err := ParseHAResourceID(ridString)
if err == nil {
*rid = resType
*i = resType
}

return err
}

// EncodeValues encodes a HA resource ID field into an URL-encoded set of values.
func (rid HAResourceID) EncodeValues(key string, v *url.Values) error {
v.Add(key, rid.String())
func (i *HAResourceID) EncodeValues(key string, v *url.Values) error {
if i == nil {
return nil
}

v.Add(key, i.String())

return nil
}

// ToValue converts a HA resource ID into a Terraform value.
func (rid HAResourceID) ToValue() types.String {
return types.StringValue(rid.String())
func (i *HAResourceID) ToValue() types.String {
if i == nil {
return types.StringNull()
}

return types.StringValue(i.String())
}
27 changes: 22 additions & 5 deletions proxmox/types/ha_resource_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,12 @@ func ParseHAResourceState(input string) (HAResourceState, error) {
}

// String converts a HAResourceState value into a string.
func (s HAResourceState) String() string {
switch s {
func (s *HAResourceState) String() string {
if s == nil {
return ""
}

switch *s {
case HAResourceStateStarted:
return "started"
case HAResourceStateStopped:
Expand All @@ -81,7 +85,11 @@ func (s HAResourceState) String() string {
}

// MarshalJSON marshals a HA resource state into JSON value.
func (s HAResourceState) MarshalJSON() ([]byte, error) {
func (s *HAResourceState) MarshalJSON() ([]byte, error) {
if s == nil {
return []byte("null"), nil
}

bytes, err := json.Marshal(s.String())
if err != nil {
return nil, fmt.Errorf("cannot marshal HA resource state: %w", err)
Expand All @@ -108,12 +116,21 @@ func (s *HAResourceState) UnmarshalJSON(b []byte) error {
}

// EncodeValues encodes a HA resource state field into an URL-encoded set of values.
func (s HAResourceState) EncodeValues(key string, v *url.Values) error {
func (s *HAResourceState) EncodeValues(key string, v *url.Values) error {
if s == nil {
return nil
}

v.Add(key, s.String())

return nil
}

// ToValue converts a HA resource state into a Terraform value.
func (s HAResourceState) ToValue() types.String {
func (s *HAResourceState) ToValue() types.String {
if s == nil {
return types.StringNull()
}

return types.StringValue(s.String())
}
29 changes: 23 additions & 6 deletions proxmox/types/ha_resource_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,12 @@ func ParseHAResourceType(input string) (HAResourceType, error) {
}

// String converts a HAResourceType value into a string.
func (t HAResourceType) String() string {
switch t {
func (t *HAResourceType) String() string {
if t == nil {
return ""
}

switch *t {
case HAResourceTypeVM:
return "vm"
case HAResourceTypeContainer:
Expand All @@ -62,7 +66,11 @@ func (t HAResourceType) String() string {
}

// MarshalJSON marshals a HA resource type into JSON value.
func (t HAResourceType) MarshalJSON() ([]byte, error) {
func (t *HAResourceType) MarshalJSON() ([]byte, error) {
if t == nil {
return []byte("null"), nil
}

bytes, err := json.Marshal(t.String())
if err != nil {
return nil, fmt.Errorf("cannot marshal HA resource type: %w", err)
Expand All @@ -71,7 +79,7 @@ func (t HAResourceType) MarshalJSON() ([]byte, error) {
return bytes, nil
}

// UnmarshalJSON unmarshals a Proxmox HA resource type.
// UnmarshalJSON unmarshal a Proxmox HA resource type.
func (t *HAResourceType) UnmarshalJSON(b []byte) error {
var rtString string

Expand All @@ -89,12 +97,21 @@ func (t *HAResourceType) UnmarshalJSON(b []byte) error {
}

// EncodeValues encodes a HA resource type field into an URL-encoded set of values.
func (t HAResourceType) EncodeValues(key string, v *url.Values) error {
func (t *HAResourceType) EncodeValues(key string, v *url.Values) error {
if t == nil {
return nil
}

v.Add(key, t.String())

return nil
}

// ToValue converts a HA resource type into a Terraform value.
func (t HAResourceType) ToValue() types.String {
func (t *HAResourceType) ToValue() types.String {
if t == nil {
return types.StringNull()
}

return types.StringValue(t.String())
}
44 changes: 30 additions & 14 deletions proxmox/types/hardwaremapping/device_id.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/

package hardwaremapping

Expand Down Expand Up @@ -57,15 +57,23 @@ var (
type DeviceID string

// EncodeValues encodes a hardware mapping device ID field into a URL-encoded set of values.
func (did DeviceID) EncodeValues(key string, v *url.Values) error {
v.Add(key, did.String())
func (d *DeviceID) EncodeValues(key string, v *url.Values) error {
if d == nil {
return nil
}

v.Add(key, d.String())

return nil
}

// MarshalJSON marshals a hardware mapping device ID into JSON value.
func (did DeviceID) MarshalJSON() ([]byte, error) {
bytes, err := json.Marshal(did)
func (d *DeviceID) MarshalJSON() ([]byte, error) {
if d == nil {
return []byte("null"), nil
}

bytes, err := json.Marshal(d)
if err != nil {
return nil, errors.Join(ErrDeviceIDMarshal, err)
}
Expand All @@ -74,17 +82,25 @@ func (did DeviceID) MarshalJSON() ([]byte, error) {
}

// String converts a DeviceID value into a string.
func (did DeviceID) String() string {
return string(did)
func (d *DeviceID) String() string {
if d == nil {
return ""
}

return string(*d)
}

// ToValue converts a hardware mapping device ID into a Terraform value.
func (did DeviceID) ToValue() types.String {
return types.StringValue(did.String())
func (d *DeviceID) ToValue() types.String {
if d == nil {
return types.StringNull()
}

return types.StringValue(d.String())
}

// UnmarshalJSON unmarshals a hardware mapping device ID.
func (did *DeviceID) UnmarshalJSON(b []byte) error {
func (d *DeviceID) UnmarshalJSON(b []byte) error {
var pciMapID string

err := json.Unmarshal(b, &pciMapID)
Expand All @@ -94,7 +110,7 @@ func (did *DeviceID) UnmarshalJSON(b []byte) error {

resType, err := ParseDeviceID(pciMapID)
if err == nil {
*did = resType
*d = resType
}

return err
Expand Down
Loading
Loading