Skip to content

Commit 97b5675

Browse files
committed
logging: support UploadPeriodMinutes and CompressionFormat parameters
Updates tailscale/corp#26860 Signed-off-by: Percy Wegmann <[email protected]>
1 parent b9e1df8 commit 97b5675

File tree

3 files changed

+32
-4
lines changed

3 files changed

+32
-4
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
echo "module=$(go env GOMODCACHE)" | tee -a $GITHUB_OUTPUT
2121
2222
- name: Set up cache
23-
uses: actions/cache@v2
23+
uses: actions/cache@v4
2424
with:
2525
path: |
2626
${{ steps.cache.outputs.build }}

logging.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ const (
2828
LogTypeNetwork LogType = "network"
2929
)
3030

31+
const (
32+
CompressionFormatNone CompressionFormat = "none"
33+
CompressionFormatZstd CompressionFormat = "zstd"
34+
CompressionFormatGzip CompressionFormat = "gzip"
35+
)
36+
3137
const (
3238
S3AccessKeyAuthentication S3AuthenticationType = "accesskey"
3339
S3RoleARNAuthentication S3AuthenticationType = "rolearn"
@@ -39,6 +45,8 @@ type LogstreamConfiguration struct {
3945
DestinationType LogstreamEndpointType `json:"destinationType,omitempty"`
4046
URL string `json:"url,omitempty"`
4147
User string `json:"user,omitempty"`
48+
UploadPeriodMinutes int `json:"uploadPeriodMinutes,omitempty"`
49+
CompressionFormat CompressionFormat `json:"compressionFormat,omitempty"`
4250
S3Bucket string `json:"s3Bucket,omitempty"`
4351
S3Region string `json:"s3Region,omitempty"`
4452
S3KeyPrefix string `json:"s3KeyPrefix,omitempty"`
@@ -54,6 +62,8 @@ type SetLogstreamConfigurationRequest struct {
5462
URL string `json:"url,omitempty"`
5563
User string `json:"user,omitempty"`
5664
Token string `json:"token,omitempty"`
65+
UploadPeriodMinutes int `json:"uploadPeriodMinutes,omitempty"`
66+
CompressionFormat CompressionFormat `json:"compressionFormat,omitempty"`
5767
S3Bucket string `json:"s3Bucket,omitempty"`
5868
S3Region string `json:"s3Region,omitempty"`
5969
S3KeyPrefix string `json:"s3KeyPrefix,omitempty"`
@@ -70,6 +80,9 @@ type LogstreamEndpointType string
7080
// LogType describes the type of logging.
7181
type LogType string
7282

83+
// CompressionFormat specifies what kind of compression to use on logs.
84+
type CompressionFormat string
85+
7386
// S3AuthenticationType describes the type of authentication used to stream logs to a LogstreamS3Endpoint.
7487
type S3AuthenticationType string
7588

logging_test.go

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,27 @@ func TestClient_LogstreamConfiguration(t *testing.T) {
1818
client, server := NewTestHarness(t)
1919
server.ResponseCode = http.StatusOK
2020

21-
expectedLogstream := &LogstreamConfiguration{}
21+
expectedLogstream := &LogstreamConfiguration{
22+
DestinationType: LogstreamCriblEndpoint,
23+
URL: "http://example.com",
24+
User: "my-user",
25+
UploadPeriodMinutes: 5,
26+
CompressionFormat: CompressionFormatZstd,
27+
S3Bucket: "my-bucket",
28+
S3Region: "us-west-2",
29+
S3KeyPrefix: "logs/",
30+
S3AuthenticationType: S3AccessKeyAuthentication,
31+
S3AccessKeyID: "my-access-key-id",
32+
S3RoleARN: "my-role-arn",
33+
S3ExternalID: "my-external-id",
34+
}
2235
server.ResponseBody = expectedLogstream
2336

24-
actualWebhook, err := client.Logging().LogstreamConfiguration(context.Background(), LogTypeConfig)
37+
actualLogstream, err := client.Logging().LogstreamConfiguration(context.Background(), LogTypeConfig)
2538
assert.NoError(t, err)
2639
assert.Equal(t, http.MethodGet, server.Method)
2740
assert.Equal(t, "/api/v2/tailnet/example.com/logging/configuration/stream", server.Path)
28-
assert.Equal(t, expectedLogstream, actualWebhook)
41+
assert.Equal(t, expectedLogstream, actualLogstream)
2942
}
3043

3144
func TestClient_SetLogstreamConfiguration(t *testing.T) {
@@ -39,6 +52,8 @@ func TestClient_SetLogstreamConfiguration(t *testing.T) {
3952
URL: "http://example.com",
4053
User: "my-user",
4154
Token: "my-token",
55+
UploadPeriodMinutes: 5,
56+
CompressionFormat: CompressionFormatZstd,
4257
S3Bucket: "my-bucket",
4358
S3Region: "us-west-2",
4459
S3KeyPrefix: "logs/",

0 commit comments

Comments
 (0)