forked from linuxkit/linuxkit
/
index.go
46 lines (38 loc) · 1.17 KB
/
index.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
package pkglib
import (
"fmt"
"github.com/linuxkit/linuxkit/src/cmd/linuxkit/registry"
"github.com/linuxkit/linuxkit/src/cmd/linuxkit/util"
)
// Index create an index for the package tag based on all arch-specific tags in the registry.
func (p Pkg) Index(bos ...BuildOpt) error {
var bo buildOpts
for _, fn := range bos {
if err := fn(&bo); err != nil {
return err
}
}
name := p.FullTag()
// Even though we may have pushed the index, we want to be sure that we have an index that includes every architecture on the registry,
// not just those that were in our local cache. So we use manifest-tool library to build a broad index
// push based on tag
fmt.Printf("Pushing index based on all arch-specific images in registry %s\n", name)
_, _, err := registry.PushManifest(name)
if err != nil {
return err
}
// push based on release
if bo.release != "" {
relTag, err := p.ReleaseTag(bo.release)
if err != nil {
return err
}
fullRelTag := util.ReferenceExpand(relTag)
fmt.Printf("Pushing index based on all arch-specific images in registry %s\n", fullRelTag)
_, _, err = registry.PushManifest(fullRelTag)
if err != nil {
return err
}
}
return nil
}