Skip to content
Merged
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
4 changes: 4 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,15 @@ linters:
- builtin$
- examples$
formatters:
settings:
golines:
max-len: 160
enable:
- gci
- gofmt
- gofumpt
- goimports
- golines
exclusions:
generated: lax
paths:
Expand Down
6 changes: 5 additions & 1 deletion monitor_services_create_token.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ type MonitorTokenCreateOptions struct {
}

// CreateMonitorServiceTokenForServiceType to create token for a given serviceType
func (c *Client) CreateMonitorServiceTokenForServiceType(ctx context.Context, serviceType string, opts MonitorTokenCreateOptions) (*MonitorServiceToken, error) {
func (c *Client) CreateMonitorServiceTokenForServiceType(
ctx context.Context,
serviceType string,
opts MonitorTokenCreateOptions,
) (*MonitorServiceToken, error) {
e := formatAPIPath("monitor/services/%s/token", serviceType)
return doPOSTRequest[MonitorServiceToken](ctx, c, e, opts)
}
8 changes: 7 additions & 1 deletion nodebalancer_config_nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,13 @@ func (c *Client) CreateNodeBalancerNode(ctx context.Context, nodebalancerID int,
}

// UpdateNodeBalancerNode updates the NodeBalancerNode with the specified id
func (c *Client) UpdateNodeBalancerNode(ctx context.Context, nodebalancerID int, configID int, nodeID int, opts NodeBalancerNodeUpdateOptions) (*NodeBalancerNode, error) {
func (c *Client) UpdateNodeBalancerNode(
ctx context.Context,
nodebalancerID int,
configID int,
nodeID int,
opts NodeBalancerNodeUpdateOptions,
) (*NodeBalancerNode, error) {
e := formatAPIPath("nodebalancers/%d/configs/%d/nodes/%d", nodebalancerID, configID, nodeID)
return doPUTRequest[NodeBalancerNode](ctx, c, e, opts)
}
Expand Down
14 changes: 12 additions & 2 deletions nodebalancer_configs.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,12 @@ func (c *Client) CreateNodeBalancerConfig(ctx context.Context, nodebalancerID in
}

// UpdateNodeBalancerConfig updates the NodeBalancerConfig with the specified id
func (c *Client) UpdateNodeBalancerConfig(ctx context.Context, nodebalancerID int, configID int, opts NodeBalancerConfigUpdateOptions) (*NodeBalancerConfig, error) {
func (c *Client) UpdateNodeBalancerConfig(
ctx context.Context,
nodebalancerID int,
configID int,
opts NodeBalancerConfigUpdateOptions,
) (*NodeBalancerConfig, error) {
e := formatAPIPath("nodebalancers/%d/configs/%d", nodebalancerID, configID)
return doPUTRequest[NodeBalancerConfig](ctx, c, e, opts)
}
Expand All @@ -276,7 +281,12 @@ func (c *Client) DeleteNodeBalancerConfig(ctx context.Context, nodebalancerID in
}

// RebuildNodeBalancerConfig updates the NodeBalancer with the specified id
func (c *Client) RebuildNodeBalancerConfig(ctx context.Context, nodeBalancerID int, configID int, opts NodeBalancerConfigRebuildOptions) (*NodeBalancerConfig, error) {
func (c *Client) RebuildNodeBalancerConfig(
ctx context.Context,
nodeBalancerID int,
configID int,
opts NodeBalancerConfigRebuildOptions,
) (*NodeBalancerConfig, error) {
e := formatAPIPath("nodebalancers/%d/configs/%d/rebuild", nodeBalancerID, configID)
return doPOSTRequest[NodeBalancerConfig](ctx, c, e, opts)
}
12 changes: 10 additions & 2 deletions object_storage_bucket_certs.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ type ObjectStorageBucketCertUploadOptions struct {

// UploadObjectStorageBucketCert uploads a TLS/SSL Cert to be used with an Object Storage Bucket.
// Deprecated: Please use UploadObjectStorageBucketCertV2 for all new implementations.
func (c *Client) UploadObjectStorageBucketCert(ctx context.Context, clusterOrRegionID, bucket string, opts ObjectStorageBucketCertUploadOptions) (*ObjectStorageBucketCert, error) {
func (c *Client) UploadObjectStorageBucketCert(
ctx context.Context,
clusterOrRegionID, bucket string,
opts ObjectStorageBucketCertUploadOptions,
) (*ObjectStorageBucketCert, error) {
e := formatAPIPath("object-storage/buckets/%s/%s/ssl", clusterOrRegionID, bucket)
return doPOSTRequest[ObjectStorageBucketCert](ctx, c, e, opts)
}
Expand All @@ -33,7 +37,11 @@ func (c *Client) GetObjectStorageBucketCert(ctx context.Context, clusterOrRegion
}

// UploadObjectStorageBucketCert uploads a TLS/SSL Cert to be used with an Object Storage Bucket.
func (c *Client) UploadObjectStorageBucketCertV2(ctx context.Context, clusterOrRegionID, bucket string, opts ObjectStorageBucketCertUploadOptions) (*ObjectStorageBucketCertV2, error) {
func (c *Client) UploadObjectStorageBucketCertV2(
ctx context.Context,
clusterOrRegionID, bucket string,
opts ObjectStorageBucketCertUploadOptions,
) (*ObjectStorageBucketCertV2, error) {
e := formatAPIPath("object-storage/buckets/%s/%s/ssl", clusterOrRegionID, bucket)
return doPOSTRequest[ObjectStorageBucketCertV2](ctx, c, e, opts)
}
Expand Down
6 changes: 5 additions & 1 deletion object_storage_buckets.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,11 @@ func (c *Client) DeleteObjectStorageBucket(ctx context.Context, clusterOrRegionI
}

// Lists the contents of the specified ObjectStorageBucket
func (c *Client) ListObjectStorageBucketContents(ctx context.Context, clusterOrRegionID, label string, params *ObjectStorageBucketListContentsParams) (*ObjectStorageBucketContent, error) {
func (c *Client) ListObjectStorageBucketContents(
ctx context.Context,
clusterOrRegionID, label string,
params *ObjectStorageBucketListContentsParams,
) (*ObjectStorageBucketContent, error) {
basePath := formatAPIPath("object-storage/buckets/%s/%s/object-list", clusterOrRegionID, label)

queryString := ""
Expand Down
18 changes: 15 additions & 3 deletions object_storage_object.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ type ObjectStorageObjectACLConfigUpdateOptions struct {
ACL string `json:"acl"`
}

func (c *Client) CreateObjectStorageObjectURL(ctx context.Context, objectID, label string, opts ObjectStorageObjectURLCreateOptions) (*ObjectStorageObjectURL, error) {
func (c *Client) CreateObjectStorageObjectURL(
ctx context.Context,
objectID, label string,
opts ObjectStorageObjectURLCreateOptions,
) (*ObjectStorageObjectURL, error) {
e := formatAPIPath("object-storage/buckets/%s/%s/object-url", objectID, label)
return doPOSTRequest[ObjectStorageObjectURL](ctx, c, e, opts)
}
Expand All @@ -45,7 +49,11 @@ func (c *Client) GetObjectStorageObjectACLConfig(ctx context.Context, objectID,
}

// Deprecated: use UpdateObjectStorageObjectACLConfigV2 for new implementations
func (c *Client) UpdateObjectStorageObjectACLConfig(ctx context.Context, objectID, label string, opts ObjectStorageObjectACLConfigUpdateOptions) (*ObjectStorageObjectACLConfig, error) {
func (c *Client) UpdateObjectStorageObjectACLConfig(
ctx context.Context,
objectID, label string,
opts ObjectStorageObjectACLConfigUpdateOptions,
) (*ObjectStorageObjectACLConfig, error) {
e := formatAPIPath("object-storage/buckets/%s/%s/object-acl", objectID, label)
return doPUTRequest[ObjectStorageObjectACLConfig](ctx, c, e, opts)
}
Expand All @@ -55,7 +63,11 @@ func (c *Client) GetObjectStorageObjectACLConfigV2(ctx context.Context, objectID
return doGETRequest[ObjectStorageObjectACLConfigV2](ctx, c, e)
}

func (c *Client) UpdateObjectStorageObjectACLConfigV2(ctx context.Context, objectID, label string, opts ObjectStorageObjectACLConfigUpdateOptions) (*ObjectStorageObjectACLConfigV2, error) {
func (c *Client) UpdateObjectStorageObjectACLConfigV2(
ctx context.Context,
objectID, label string,
opts ObjectStorageObjectACLConfigUpdateOptions,
) (*ObjectStorageObjectACLConfigV2, error) {
e := formatAPIPath("object-storage/buckets/%s/%s/object-acl", objectID, label)
return doPUTRequest[ObjectStorageObjectACLConfigV2](ctx, c, e, opts)
}
6 changes: 2 additions & 4 deletions request_helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@ import (
"strconv"
"testing"

"github.com/stretchr/testify/require"

"github.com/linode/linodego/internal/testutil"

"github.com/google/go-cmp/cmp"
"github.com/jarcoal/httpmock"
"github.com/linode/linodego/internal/testutil"
"github.com/stretchr/testify/require"
)

type testResultNestedType struct {
Expand Down
9 changes: 6 additions & 3 deletions test/integration/account_oauth_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ import (
"context"
"testing"

"github.com/stretchr/testify/assert"

"github.com/linode/linodego"
. "github.com/linode/linodego"
"github.com/stretchr/testify/assert"
)

func TestOAuthClient_GetMissing(t *testing.T) {
Expand Down Expand Up @@ -89,7 +88,11 @@ func TestOAuthClients_Reset(t *testing.T) {
assert.NotEqual(t, oauthClient.Secret, oauthClientAfterReset.Secret, "Secret should have been reset")
}

func setupOAuthClient(t *testing.T, createOpts linodego.OAuthClientCreateOptions, fixturesYaml string) (*linodego.Client, *linodego.OAuthClient, func(), error) {
func setupOAuthClient(
t *testing.T,
createOpts linodego.OAuthClientCreateOptions,
fixturesYaml string,
) (*linodego.Client, *linodego.OAuthClient, func(), error) {
t.Helper()
client, fixtureTeardown := createTestClient(t, fixturesYaml)
oauthClient, err := client.CreateOAuthClient(context.Background(), createOpts)
Expand Down
5 changes: 2 additions & 3 deletions test/integration/images_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ import (
"slices"
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/dnaeon/go-vcr/recorder"
. "github.com/linode/linodego"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

// testImageBytes is a minimal Gzipped image.
Expand Down
6 changes: 5 additions & 1 deletion test/integration/instance_firewalls_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ func TestInstanceFirewalls_List(t *testing.T) {
}
}

func setupInstanceFirewall(t *testing.T, firewallModifiers []firewallModifier, fixturesYaml string) (*linodego.Client, *linodego.Instance, *linodego.Firewall, error) {
func setupInstanceFirewall(
t *testing.T,
firewallModifiers []firewallModifier,
fixturesYaml string,
) (*linodego.Client, *linodego.Instance, *linodego.Firewall, error) {
t.Helper()
client, firewall, firewallTeardown, err := setupFirewall(t, firewallModifiers, fixturesYaml)

Expand Down
25 changes: 20 additions & 5 deletions test/integration/instances_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,9 +353,14 @@ func TestInstance_Disks_List(t *testing.T) {
}

func TestInstance_Disks_List_WithEncryption(t *testing.T) {
client, instance, teardown, err := setupInstance(t, "fixtures/TestInstance_Disks_List_WithEncryption", true, func(c *linodego.Client, ico *linodego.InstanceCreateOptions) {
ico.Region = getRegionsWithCaps(t, c, []string{"Disk Encryption"})[0]
})
client, instance, teardown, err := setupInstance(
t,
"fixtures/TestInstance_Disks_List_WithEncryption",
true,
func(c *linodego.Client, ico *linodego.InstanceCreateOptions) {
ico.Region = getRegionsWithCaps(t, c, []string{"Disk Encryption"})[0]
},
)
defer teardown()
if err != nil {
t.Error(err)
Expand Down Expand Up @@ -941,7 +946,12 @@ func createInstance(t *testing.T, client *linodego.Client, enableCloudFirewall b
return client.CreateInstance(context.Background(), createOpts)
}

func setupInstance(t *testing.T, fixturesYaml string, EnableCloudFirewall bool, modifiers ...instanceModifier) (*linodego.Client, *linodego.Instance, func(), error) {
func setupInstance(
t *testing.T,
fixturesYaml string,
EnableCloudFirewall bool,
modifiers ...instanceModifier,
) (*linodego.Client, *linodego.Instance, func(), error) {
if t != nil {
t.Helper()
}
Expand Down Expand Up @@ -1008,7 +1018,12 @@ func createInstanceWithoutDisks(
return instance, config, teardown, err
}

func setupInstanceWithoutDisks(t *testing.T, fixturesYaml string, enableCloudFirewall bool, modifiers ...instanceModifier) (*linodego.Client, *linodego.Instance, *linodego.InstanceConfig, func(), error) {
func setupInstanceWithoutDisks(
t *testing.T,
fixturesYaml string,
enableCloudFirewall bool,
modifiers ...instanceModifier,
) (*linodego.Client, *linodego.Instance, *linodego.InstanceConfig, func(), error) {
t.Helper()
client, fixtureTeardown := createTestClient(t, fixturesYaml)
instance, config, instanceTeardown, err := createInstanceWithoutDisks(t, client, enableCloudFirewall, modifiers...)
Expand Down
3 changes: 1 addition & 2 deletions test/integration/integration_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@ import (
"testing"
"time"

"github.com/stretchr/testify/require"

"github.com/dnaeon/go-vcr/cassette"
"github.com/dnaeon/go-vcr/recorder"
"github.com/linode/linodego"
"github.com/stretchr/testify/require"
"golang.org/x/oauth2"
"k8s.io/client-go/transport"
)
Expand Down
3 changes: 1 addition & 2 deletions test/integration/lke_clusters_acl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ import (
"context"
"testing"

"github.com/linode/linodego"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/linode/linodego"
)

func TestLKECluster_withACL(t *testing.T) {
Expand Down
15 changes: 11 additions & 4 deletions test/integration/lke_node_pools_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ import (
"context"
"testing"

k8scondition "github.com/linode/linodego/k8s/pkg/condition"

"github.com/google/go-cmp/cmp"
"github.com/linode/linodego"
k8scondition "github.com/linode/linodego/k8s/pkg/condition"
)

var testLKENodePoolCreateOpts = linodego.LKENodePoolCreateOptions{
Expand Down Expand Up @@ -288,7 +287,11 @@ func TestLKENodePool_CreateWithLabelsAndTaints(t *testing.T) {
}
}

func setupLKENodePool(t *testing.T, fixturesYaml string, nodePoolCreateOpts *linodego.LKENodePoolCreateOptions) (*linodego.Client, *linodego.LKECluster, *linodego.LKENodePool, func(), error) {
func setupLKENodePool(
t *testing.T,
fixturesYaml string,
nodePoolCreateOpts *linodego.LKENodePoolCreateOptions,
) (*linodego.Client, *linodego.LKECluster, *linodego.LKENodePool, func(), error) {
t.Helper()
var fixtureTeardown func()
client, lkeCluster, fixtureTeardown, err := setupLKECluster(t, []clusterModifier{func(createOpts *linodego.LKEClusterCreateOptions) {
Expand Down Expand Up @@ -359,7 +362,11 @@ func TestLKEEnterpriseNodePoolK8sUpgrade_Update(t *testing.T) {
}
}

func setupLKEEnterpriseNodePool(t *testing.T, fixturesYaml string, nodePoolCreateOpts *linodego.LKENodePoolCreateOptions) (*linodego.Client, *linodego.LKECluster, *linodego.LKENodePool, func(), error) {
func setupLKEEnterpriseNodePool(
t *testing.T,
fixturesYaml string,
nodePoolCreateOpts *linodego.LKENodePoolCreateOptions,
) (*linodego.Client, *linodego.LKECluster, *linodego.LKENodePool, func(), error) {
t.Helper()
var fixtureTeardown func()
client, lkeCluster, fixtureTeardown, err := setupLKECluster(t, []clusterModifier{func(createOpts *linodego.LKEClusterCreateOptions) {
Expand Down
6 changes: 5 additions & 1 deletion test/integration/monitor_metrics_definitions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ func TestMonitorMetricDefinitions_Get_smoke(t *testing.T) {
}

// Get the metric-definitions by serviceType for the filter "is_alertable":false
monitorMetricDefinitionsClientListFilter, listErr := client.ListMonitorMetricsDefinitionByServiceType(context.Background(), "dbaas", linodego.NewListOptions(0, "{\"is_alertable\":false}"))
monitorMetricDefinitionsClientListFilter, listErr := client.ListMonitorMetricsDefinitionByServiceType(
context.Background(),
"dbaas",
linodego.NewListOptions(0, "{\"is_alertable\":false}"),
)
if listErr != nil {
t.Errorf("Error listing monitor metrics:%s", listErr)
}
Expand Down
Loading
Loading