forked from buildpacks/pack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pack.go
32 lines (24 loc) · 901 Bytes
/
pack.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
package pack
import (
"context"
"github.com/buildpacks/pack/config"
"github.com/pkg/errors"
"github.com/buildpacks/pack/internal/buildpackage"
"github.com/buildpacks/pack/internal/dist"
"github.com/buildpacks/pack/internal/style"
)
var (
// Version is the version of `pack`. It is injected at compile time.
Version = "0.0.0"
)
func extractPackagedBuildpacks(ctx context.Context, pkgImageRef string, fetcher ImageFetcher, publish bool, pullPolicy config.PullPolicy) (mainBP dist.Buildpack, depBPs []dist.Buildpack, err error) {
pkgImage, err := fetcher.Fetch(ctx, pkgImageRef, !publish, pullPolicy)
if err != nil {
return nil, nil, errors.Wrapf(err, "fetching image")
}
mainBP, depBPs, err = buildpackage.ExtractBuildpacks(pkgImage)
if err != nil {
return nil, nil, errors.Wrapf(err, "extracting buildpacks from %s", style.Symbol(pkgImageRef))
}
return mainBP, depBPs, nil
}