Skip to content

Commit ce22d6b

Browse files
committed
Adding CacheControl setting for S3 uploads
1 parent 9daf886 commit ce22d6b

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

main.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,11 @@ func main() {
8686
Usage: "use path style for bucket paths",
8787
EnvVar: "PLUGIN_PATH_STYLE",
8888
},
89+
cli.StringFlag{
90+
Name: "cache-control",
91+
Usage: "set cache-control header for uploaded objects",
92+
EnvVar: "PLUGIN_CACHE_CONTROL",
93+
},
8994
cli.BoolTFlag{
9095
Name: "yaml-verified",
9196
Usage: "Ensure the yaml was signed",
@@ -119,6 +124,7 @@ func run(c *cli.Context) error {
119124
StripPrefix: c.String("strip-prefix"),
120125
Exclude: c.StringSlice("exclude"),
121126
Encryption: c.String("encryption"),
127+
CacheControl: c.String("cache-control"),
122128
PathStyle: c.Bool("path-style"),
123129
DryRun: c.Bool("dry-run"),
124130
YamlVerified: c.BoolT("yaml-verified"),

plugin.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ type Plugin struct {
4848
// bucket-owner-full-control
4949
Access string
5050

51+
// Sets the Cache-Control header on each uploaded object
52+
CacheControl string
53+
5154
// Copies the files from the specified directory.
5255
// Regexp matching will apply to match multiple
5356
// files
@@ -171,6 +174,10 @@ func (p *Plugin) Exec() error {
171174
putObjectInput.ServerSideEncryption = &(p.Encryption)
172175
}
173176

177+
if p.CacheControl != "" {
178+
putObjectInput.CacheControl = &(p.CacheControl)
179+
}
180+
174181
_, err = client.PutObject(putObjectInput)
175182

176183
if err != nil {

0 commit comments

Comments
 (0)