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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
echo "module=$(go env GOMODCACHE)" | tee -a $GITHUB_OUTPUT

- name: Set up cache
uses: actions/cache@v2
uses: actions/cache@v4
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Drive-by to make GitHub happy.

with:
path: |
${{ steps.cache.outputs.build }}
Expand Down
13 changes: 13 additions & 0 deletions logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ const (
LogTypeNetwork LogType = "network"
)

const (
CompressionFormatNone CompressionFormat = "none"
CompressionFormatZstd CompressionFormat = "zstd"
CompressionFormatGzip CompressionFormat = "gzip"
)

const (
S3AccessKeyAuthentication S3AuthenticationType = "accesskey"
S3RoleARNAuthentication S3AuthenticationType = "rolearn"
Expand All @@ -39,6 +45,8 @@ type LogstreamConfiguration struct {
DestinationType LogstreamEndpointType `json:"destinationType,omitempty"`
URL string `json:"url,omitempty"`
User string `json:"user,omitempty"`
UploadPeriodMinutes int `json:"uploadPeriodMinutes,omitempty"`
CompressionFormat CompressionFormat `json:"compressionFormat,omitempty"`
S3Bucket string `json:"s3Bucket,omitempty"`
S3Region string `json:"s3Region,omitempty"`
S3KeyPrefix string `json:"s3KeyPrefix,omitempty"`
Expand All @@ -54,6 +62,8 @@ type SetLogstreamConfigurationRequest struct {
URL string `json:"url,omitempty"`
User string `json:"user,omitempty"`
Token string `json:"token,omitempty"`
UploadPeriodMinutes int `json:"uploadPeriodMinutes,omitempty"`
CompressionFormat CompressionFormat `json:"compressionFormat,omitempty"`
S3Bucket string `json:"s3Bucket,omitempty"`
S3Region string `json:"s3Region,omitempty"`
S3KeyPrefix string `json:"s3KeyPrefix,omitempty"`
Expand All @@ -70,6 +80,9 @@ type LogstreamEndpointType string
// LogType describes the type of logging.
type LogType string

// CompressionFormat specifies what kind of compression to use on logs.
type CompressionFormat string

// S3AuthenticationType describes the type of authentication used to stream logs to a LogstreamS3Endpoint.
type S3AuthenticationType string

Expand Down
21 changes: 18 additions & 3 deletions logging_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,27 @@ func TestClient_LogstreamConfiguration(t *testing.T) {
client, server := NewTestHarness(t)
server.ResponseCode = http.StatusOK

expectedLogstream := &LogstreamConfiguration{}
expectedLogstream := &LogstreamConfiguration{
DestinationType: LogstreamCriblEndpoint,
URL: "http://example.com",
User: "my-user",
UploadPeriodMinutes: 5,
CompressionFormat: CompressionFormatZstd,
S3Bucket: "my-bucket",
S3Region: "us-west-2",
S3KeyPrefix: "logs/",
S3AuthenticationType: S3AccessKeyAuthentication,
S3AccessKeyID: "my-access-key-id",
S3RoleARN: "my-role-arn",
S3ExternalID: "my-external-id",
}
server.ResponseBody = expectedLogstream

actualWebhook, err := client.Logging().LogstreamConfiguration(context.Background(), LogTypeConfig)
actualLogstream, err := client.Logging().LogstreamConfiguration(context.Background(), LogTypeConfig)
assert.NoError(t, err)
assert.Equal(t, http.MethodGet, server.Method)
assert.Equal(t, "/api/v2/tailnet/example.com/logging/configuration/stream", server.Path)
assert.Equal(t, expectedLogstream, actualWebhook)
assert.Equal(t, expectedLogstream, actualLogstream)
}

func TestClient_SetLogstreamConfiguration(t *testing.T) {
Expand All @@ -39,6 +52,8 @@ func TestClient_SetLogstreamConfiguration(t *testing.T) {
URL: "http://example.com",
User: "my-user",
Token: "my-token",
UploadPeriodMinutes: 5,
CompressionFormat: CompressionFormatZstd,
S3Bucket: "my-bucket",
S3Region: "us-west-2",
S3KeyPrefix: "logs/",
Expand Down