forked from buildpacks/pack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
yank_buildpack.go
56 lines (47 loc) · 1.2 KB
/
yank_buildpack.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
package pack
import (
"net/url"
"runtime"
"github.com/buildpacks/pack/internal/registry"
)
// YankBuildpackOptions is a configuration struct that controls the Yanking a buildpack
// from the Buildpack Registry.
type YankBuildpackOptions struct {
ID string
Version string
Type string
URL string
Yank bool
}
// YankBuildpack marks a buildpack on the Buildpack Registry as 'yanked'. This forbids future
// builds from using it.
func (c *Client) YankBuildpack(opts YankBuildpackOptions) error {
namespace, name, err := registry.ParseNamespaceName(opts.ID)
if err != nil {
return err
}
issueURL, err := registry.GetIssueURL(opts.URL)
if err != nil {
return err
}
buildpack := registry.Buildpack{
Namespace: namespace,
Name: name,
Version: opts.Version,
Yanked: opts.Yank,
}
issue, err := registry.CreateGithubIssue(buildpack)
if err != nil {
return err
}
params := url.Values{}
params.Add("title", issue.Title)
params.Add("body", issue.Body)
issueURL.RawQuery = params.Encode()
c.logger.Debugf("Open URL in browser: %s", issueURL)
cmd, err := registry.CreateBrowserCmd(issueURL.String(), runtime.GOOS)
if err != nil {
return err
}
return cmd.Start()
}