Skip to content

Commit

Permalink
move the shouldEncodeFileName field from the common log export rule f…
Browse files Browse the repository at this point in the history
…ield to a type-specific field
  • Loading branch information
sharkpc138 committed Dec 30, 2024
1 parent ed89699 commit d212075
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 24 deletions.
14 changes: 10 additions & 4 deletions deploy/templates/operator/manifests/crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ spec:
description: Root directory to store logs within external
storage
type: string
shouldEncodeFileName:
description: Provide an option to convert '+' to '%2B' to
address issues in certain web environments where '+' is
misinterpreted
type: boolean
timeLayoutOfSubDirectory:
description: An option(default `2006-01`) that sets the
name of the sub-directory following `{Root path}` to a
Expand Down Expand Up @@ -214,6 +219,11 @@ spec:
secretKey:
description: S3 bucket secret key
type: string
shouldEncodeFileName:
description: Provide an option to convert '+' to '%2B' to
address issues in certain web environments where '+' is
misinterpreted
type: boolean
tags:
additionalProperties:
type: string
Expand All @@ -225,10 +235,6 @@ spec:
time-based layout
type: string
type: object
shouldEncodeFileName:
description: Provide an option to convert '+' to '%2B' to address
issues in certain web environments where '+' is misinterpreted
type: boolean
type: object
type: array
logMetricRules:
Expand Down
12 changes: 8 additions & 4 deletions pkg/docs/operator/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,10 @@ const docTemplate = `{
"description": "Root directory to store logs within external storage",
"type": "string"
},
"shouldEncodeFileName": {
"description": "Provide an option to convert '+' to '%2B' to address issues in certain web environments where '+' is misinterpreted",
"type": "boolean"
},
"timeLayoutOfSubDirectory": {
"description": "An option(default ` + "`" + `2006-01` + "`" + `) that sets the name of the sub-directory following ` + "`" + `{Root path}` + "`" + ` to a time-based layout",
"type": "string",
Expand Down Expand Up @@ -379,10 +383,6 @@ const docTemplate = `{
"$ref": "#/definitions/v1.S3Bucket"
}
]
},
"shouldEncodeFileName": {
"description": "Provide an option to convert '+' to '%2B' to address issues in certain web environments where '+' is misinterpreted",
"type": "boolean"
}
}
},
Expand Down Expand Up @@ -434,6 +434,10 @@ const docTemplate = `{
"description": "S3 bucket secret key",
"type": "string"
},
"shouldEncodeFileName": {
"description": "Provide an option to convert '+' to '%2B' to address issues in certain web environments where '+' is misinterpreted",
"type": "boolean"
},
"tags": {
"description": "Tags for objects to be stored",
"allOf": [
Expand Down
12 changes: 8 additions & 4 deletions pkg/docs/operator/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,10 @@
"description": "Root directory to store logs within external storage",
"type": "string"
},
"shouldEncodeFileName": {
"description": "Provide an option to convert '+' to '%2B' to address issues in certain web environments where '+' is misinterpreted",
"type": "boolean"
},
"timeLayoutOfSubDirectory": {
"description": "An option(default `2006-01`) that sets the name of the sub-directory following `{Root path}` to a time-based layout",
"type": "string",
Expand Down Expand Up @@ -371,10 +375,6 @@
"$ref": "#/definitions/v1.S3Bucket"
}
]
},
"shouldEncodeFileName": {
"description": "Provide an option to convert '+' to '%2B' to address issues in certain web environments where '+' is misinterpreted",
"type": "boolean"
}
}
},
Expand Down Expand Up @@ -426,6 +426,10 @@
"description": "S3 bucket secret key",
"type": "string"
},
"shouldEncodeFileName": {
"description": "Provide an option to convert '+' to '%2B' to address issues in certain web environments where '+' is misinterpreted",
"type": "boolean"
},
"tags": {
"description": "Tags for objects to be stored",
"allOf": [
Expand Down
12 changes: 8 additions & 4 deletions pkg/docs/operator/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ definitions:
rootPath:
description: Root directory to store logs within external storage
type: string
shouldEncodeFileName:
description: Provide an option to convert '+' to '%2B' to address issues in
certain web environments where '+' is misinterpreted
type: boolean
timeLayoutOfSubDirectory:
default: 2006-01
description: An option(default `2006-01`) that sets the name of the sub-directory
Expand Down Expand Up @@ -113,10 +117,6 @@ definitions:
allOf:
- $ref: '#/definitions/v1.S3Bucket'
description: Settings required to export logs to S3 bucket
shouldEncodeFileName:
description: Provide an option to convert '+' to '%2B' to address issues in
certain web environments where '+' is misinterpreted
type: boolean
type: object
v1.LogMetricRule:
properties:
Expand Down Expand Up @@ -151,6 +151,10 @@ definitions:
secretKey:
description: S3 bucket secret key
type: string
shouldEncodeFileName:
description: Provide an option to convert '+' to '%2B' to address issues in
certain web environments where '+' is misinterpreted
type: boolean
tags:
allOf:
- $ref: '#/definitions/v1.Tags'
Expand Down
2 changes: 1 addition & 1 deletion pkg/lobster/sink/exporter/uploader/basic.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func (b BasicUploader) Dir(chunk model.Chunk, date time.Time) string {
func (b BasicUploader) FileName(start, end time.Time) string {
fileName := fmt.Sprintf("%s_%s.log", start.Format(layoutFileName), end.Format(layoutFileName))

if b.Order.LogExportRule.ShouldEncodeFileName {
if b.Order.LogExportRule.BasicBucket.ShouldEncodeFileName {
return strings.ReplaceAll(fileName, "+", "%2B")
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/lobster/sink/exporter/uploader/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func (s S3Uploader) Dir(chunk model.Chunk, date time.Time) string {
func (b S3Uploader) FileName(start, end time.Time) string {
fileName := fmt.Sprintf("%s_%s.log", start.Format(layoutFileName), end.Format(layoutFileName))

if b.Order.LogExportRule.ShouldEncodeFileName {
if b.Order.LogExportRule.S3Bucket.ShouldEncodeFileName {
return strings.ReplaceAll(fileName, "+", "%2B")
}

Expand Down
2 changes: 2 additions & 0 deletions pkg/operator/api/v1/basicBucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ type BasicBucket struct {
RootPath string `json:"rootPath,omitempty"`
// An option(default `2006-01`) that sets the name of the sub-directory following `{Root path}` to a time-based layout
TimeLayoutOfSubDirectory string `json:"timeLayoutOfSubDirectory,omitempty" default:"2006-01"`
// Provide an option to convert '+' to '%2B' to address issues in certain web environments where '+' is misinterpreted
ShouldEncodeFileName bool `json:"shouldEncodeFileName,omitempty"`
}

func (b BasicBucket) Validate() error {
Expand Down
2 changes: 0 additions & 2 deletions pkg/operator/api/v1/logExportRule.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ type LogExportRule struct {
Filter Filter `json:"filter,omitempty"`
// Interval to export logs
Interval metav1.Duration `json:"interval,omitempty" swaggertype:"string" example:"time duration(e.g. 1m)"`
// Provide an option to convert '+' to '%2B' to address issues in certain web environments where '+' is misinterpreted
ShouldEncodeFileName bool `json:"shouldEncodeFileName,omitempty"`
}

func (r LogExportRule) Validate() error {
Expand Down
2 changes: 2 additions & 0 deletions pkg/operator/api/v1/s3Bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ type S3Bucket struct {
SecretKey string `json:"secretKey,omitempty"`
// Tags for objects to be stored
Tags Tags `json:"tags,omitempty"`
// Provide an option to convert '+' to '%2B' to address issues in certain web environments where '+' is misinterpreted
ShouldEncodeFileName bool `json:"shouldEncodeFileName,omitempty"`
}

func (s S3Bucket) Validate() error {
Expand Down
12 changes: 8 additions & 4 deletions web/static/docs/operator/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,10 @@
"description": "Root directory to store logs within external storage",
"type": "string"
},
"shouldEncodeFileName": {
"description": "Provide an option to convert '+' to '%2B' to address issues in certain web environments where '+' is misinterpreted",
"type": "boolean"
},
"timeLayoutOfSubDirectory": {
"description": "An option(default `2006-01`) that sets the name of the sub-directory following `{Root path}` to a time-based layout",
"type": "string",
Expand Down Expand Up @@ -371,10 +375,6 @@
"$ref": "#/definitions/v1.S3Bucket"
}
]
},
"shouldEncodeFileName": {
"description": "Provide an option to convert '+' to '%2B' to address issues in certain web environments where '+' is misinterpreted",
"type": "boolean"
}
}
},
Expand Down Expand Up @@ -426,6 +426,10 @@
"description": "S3 bucket secret key",
"type": "string"
},
"shouldEncodeFileName": {
"description": "Provide an option to convert '+' to '%2B' to address issues in certain web environments where '+' is misinterpreted",
"type": "boolean"
},
"tags": {
"description": "Tags for objects to be stored",
"allOf": [
Expand Down

0 comments on commit d212075

Please sign in to comment.