in cft/pkg/util.go [112:162]
func upload(root, path string, force bool) (*s3Path, error) {
if !filepath.IsAbs(path) {
path = filepath.Join(root, path)
if abs, err := filepath.Abs(path); err == nil {
path = abs
}
}
artifactName := path
if force {
artifactName = "zip:" + artifactName
}
if result, ok := uploads[artifactName]; ok {
config.Debugf("Using existing upload for: %s\n", path)
return result, nil
}
info, err := os.Stat(path)
if err != nil {
return nil, err
}
if info.IsDir() || force {
// Zip it!
zipped, err := zipPath(path)
if err != nil {
return nil, err
}
config.Debugf("Zipped %s as %s\n", path, zipped)
path = zipped
}
config.Debugf("Uploading: %s\n", path)
content, err := ioutil.ReadFile(path)
if err != nil {
return nil, err
}
bucket := s3.RainBucket(false)
key, err := s3.Upload(bucket, content)
uploads[artifactName] = &s3Path{
bucket: bucket,
key: key,
region: aws.Config().Region,
}
return uploads[artifactName], err
}