forked from docker-archive/docker-bb
/
static.go
57 lines (48 loc) · 1.53 KB
/
static.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package main
import (
"path"
"strings"
log "github.com/Sirupsen/logrus"
"github.com/crowdmob/goamz/s3"
)
const (
index string = `<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Docker Master Binaries</title>
<link rel="stylesheet" href="/static/style.css" />
</head>
<body>
<h1>Docker Master Binaries</h1>
<div class="wrapper">
<p>These binaries are built and updated with each commit to the master branch of Docker. Want to use that cool new feature that was just merged? Download your system's binary and check out the master docs at <a href="http://docs.master.dockerproject.com" target="_blank">docs.master.dockerproject.com</a>.</p>
<table>
<thead>
<tr>
<th><img src="/static/folder.png" alt="[ICO]"/></th>
<th>Name</th>
<th>Size</th>
<th>Uploaded Date</th>
</tr>
</thead>
<tbody>
{{ . }}
</tbody>
</table>
</div>
</body>
</html>`
)
func createIndexFile(bucket *s3.Bucket, bucketpath, html string) error {
p := path.Join(bucketpath, "index.html")
contents := strings.Replace(index, "{{ . }}", html, -1)
// push the file to s3
log.Debugf("Pushing %s to s3", p)
if err := bucket.Put(p, []byte(contents), "text/html", "public-read", s3.Options{CacheControl: "no-cache"}); err != nil {
return err
}
log.Infof("Sucessfully pushed %s to s3", p)
return nil
}