Merge pull request #13165 from justinsb/irsa_terraform

tests: ensure that we use ACLs with memfs
This commit is contained in:
Kubernetes Prow Robot 2022-02-03 19:30:00 -08:00 committed by GitHub
commit 0985005bc8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 0 deletions

View File

@ -87,6 +87,18 @@ func (e *ManagedFile) Find(c *fi.Context) (*ManagedFile, error) {
}
}
if memfsfile, ok := filePath.(*vfs.MemFSPath); ok {
public, err := memfsfile.IsPublic()
if err != nil {
return nil, err
}
actual.Public = &public
if e.Public == nil {
e.Public = fi.Bool(false)
}
}
// Avoid spurious changes
actual.Lifecycle = e.Lifecycle

View File

@ -30,6 +30,7 @@ import (
type MemFSPath struct {
context *MemFSContext
location string
acl ACL
mutex sync.Mutex
contents []byte
@ -109,6 +110,7 @@ func (p *MemFSPath) WriteFile(r io.ReadSeeker, acl ACL) error {
return fmt.Errorf("error reading data: %v", err)
}
p.contents = data
p.acl = acl
return nil
}
@ -193,6 +195,21 @@ func (p *MemFSPath) Location() string {
return p.location
}
func (p *MemFSPath) IsPublic() (bool, error) {
if p.acl == nil {
return false, nil
}
s3Acl, ok := p.acl.(*S3Acl)
if !ok {
return false, fmt.Errorf("expected acl to be S3Acl, was %T", p.acl)
}
isPublic := false
if s3Acl.RequestACL != nil {
isPublic = *s3Acl.RequestACL == "public-read"
}
return isPublic, nil
}
// Terraform support for integration tests.
func (p *MemFSPath) TerraformProvider() (*TerraformProvider, error) {