Skip to content

Commit

Permalink
Add support for creating world-readable managedFiles
Browse files Browse the repository at this point in the history
  • Loading branch information
Ole Markus With committed Feb 9, 2021
1 parent 3673b6e commit d632cc1
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions upup/pkg/fi/fitasks/managedfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ type ManagedFile struct {
Base *string
Location *string
Contents fi.Resource
Public *bool
}

func (e *ManagedFile) Find(c *fi.Context) (*ManagedFile, error) {
Expand Down Expand Up @@ -102,9 +103,23 @@ func (_ *ManagedFile) Render(c *fi.Context, a, e, changes *ManagedFile) error {
}
p = p.Join(location)

acl, err := acls.GetACL(p, c.Cluster)
if err != nil {
return err
var acl vfs.ACL
if fi.BoolValue(e.Public) {
switch p.(type) {
case *vfs.S3Path:
acl = vfs.S3Acl{
RequestACL: fi.String("public-read"),
}
default:
return fmt.Errorf("the %q path does not support public ACL", p.Path())
}

} else {

acl, err = acls.GetACL(p, c.Cluster)
if err != nil {
return err
}
}

err = p.WriteFile(bytes.NewReader(data), acl)
Expand Down

0 comments on commit d632cc1

Please sign in to comment.