refactor: modernize, remove AsPtr (#300)

modernize missed this in #278, but AsPtr can also be removed here and
replace with new()

Signed-off-by: Miek Gieben <miek@miek.nl>
This commit is contained in:
Miek Gieben
2026-04-03 09:41:16 +10:00
committed by GitHub
parent 7ec8879af3
commit 4b34c42b76
2 changed files with 3 additions and 10 deletions
-7
View File
@@ -60,10 +60,3 @@ type VolumeClient interface {
ListVolumes(ctx context.Context, filter *VolumeFilter) ([]MachineVolume, error) ListVolumes(ctx context.Context, filter *VolumeFilter) ([]MachineVolume, error)
RemoveVolume(ctx context.Context, machineNameOrID, volumeName string, force bool) error RemoveVolume(ctx context.Context, machineNameOrID, volumeName string, force bool) error
} }
// AsPtr returns a pointer to the given value. Useful for optional fields in API structs.
//
//go:fix inline
func AsPtr[T any](v T) *T {
return new(v)
}
+3 -3
View File
@@ -968,7 +968,7 @@ services:
monitor: 10s monitor: 10s
`, `,
expected: api.UpdateConfig{ expected: api.UpdateConfig{
MonitorPeriod: api.AsPtr(10 * time.Second), MonitorPeriod: new(10 * time.Second),
}, },
}, },
{ {
@@ -984,7 +984,7 @@ services:
`, `,
expected: api.UpdateConfig{ expected: api.UpdateConfig{
Order: api.UpdateOrderStartFirst, Order: api.UpdateOrderStartFirst,
MonitorPeriod: api.AsPtr(30 * time.Second), MonitorPeriod: new(30 * time.Second),
}, },
}, },
{ {
@@ -998,7 +998,7 @@ services:
monitor: 0s monitor: 0s
`, `,
expected: api.UpdateConfig{ expected: api.UpdateConfig{
MonitorPeriod: api.AsPtr(time.Duration(0)), MonitorPeriod: new(time.Duration(0)),
}, },
}, },
} }