Skip to content

Commit

Permalink
feat(s3): allow specifying storage class for PutObject
Browse files Browse the repository at this point in the history
  • Loading branch information
syhpoon authored and moshloop committed Feb 12, 2025
1 parent 69d6896 commit 1c3e8ea
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 4 deletions.
3 changes: 2 additions & 1 deletion api/v1/checks.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ type HTTPCheck struct {
Body string `yaml:"body,omitempty" json:"body,omitempty" template:"true"`
// Header fields to be used in the query
Headers []types.EnvVar `yaml:"headers,omitempty" json:"headers,omitempty"`
//Template the request body
// Template the request body
TemplateBody bool `yaml:"templateBody,omitempty" json:"templateBody,omitempty"`
// EnvVars are the environment variables that are accessible to templated body
EnvVars []types.EnvVar `yaml:"env,omitempty" json:"env,omitempty"`
Expand Down Expand Up @@ -187,6 +187,7 @@ type S3Check struct {
Relatable `yaml:",inline" json:",inline"`
connection.S3Connection `yaml:",inline" json:",inline"`
BucketName string `yaml:"bucketName" json:"bucketName,omitempty"`
StorageClass string `yaml:"storageClass" json:"storageClass,omitempty"`
}

func (c S3Check) GetEndpoint() string {
Expand Down
8 changes: 5 additions & 3 deletions checks/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/flanksource/commons/utils"

"github.com/aws/aws-sdk-go-v2/service/s3"
"github.com/aws/aws-sdk-go-v2/service/s3/types"
"github.com/prometheus/client_golang/prometheus"

v1 "github.com/flanksource/canary-checker/api/v1"
Expand Down Expand Up @@ -93,9 +94,10 @@ func (c *S3Checker) Check(ctx *context.Context, check v1.S3Check) pkg.Results {
data := utils.RandomString(16)
updateTimer := NewTimer()
_, err = client.PutObject(ctx, &s3.PutObjectInput{
Bucket: &check.BucketName,
Key: &check.ObjectPath,
Body: bytes.NewReader([]byte(data)),
Bucket: &check.BucketName,
Key: &check.ObjectPath,
Body: bytes.NewReader([]byte(data)),
StorageClass: types.StorageClass(check.StorageClass),
})
if err != nil {
return results.Failf("Failed to put object %s in bucket %s: %v", check.ObjectPath, check.BucketName, err)
Expand Down
2 changes: 2 additions & 0 deletions config/deploy/Canary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7166,6 +7166,8 @@ spec:
skipTLSVerify:
description: Skip TLS verify when connecting to aws
type: boolean
storageClass:
type: string
transformDeleteStrategy:
type: string
usePathStyle:
Expand Down
2 changes: 2 additions & 0 deletions config/deploy/manifests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7165,6 +7165,8 @@ spec:
skipTLSVerify:
description: Skip TLS verify when connecting to aws
type: boolean
storageClass:
type: string
transformDeleteStrategy:
type: string
usePathStyle:
Expand Down
3 changes: 3 additions & 0 deletions config/schemas/canary.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -3740,6 +3740,9 @@
},
"bucketName": {
"type": "string"
},
"storageClass": {
"type": "string"
}
},
"additionalProperties": false,
Expand Down
3 changes: 3 additions & 0 deletions config/schemas/component.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -4187,6 +4187,9 @@
},
"bucketName": {
"type": "string"
},
"storageClass": {
"type": "string"
}
},
"additionalProperties": false,
Expand Down
3 changes: 3 additions & 0 deletions config/schemas/health_s3.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,9 @@
},
"bucketName": {
"type": "string"
},
"storageClass": {
"type": "string"
}
},
"additionalProperties": false,
Expand Down
3 changes: 3 additions & 0 deletions config/schemas/topology.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -4193,6 +4193,9 @@
},
"bucketName": {
"type": "string"
},
"storageClass": {
"type": "string"
}
},
"additionalProperties": false,
Expand Down

0 comments on commit 1c3e8ea

Please sign in to comment.