-
Notifications
You must be signed in to change notification settings - Fork 49
/
auto_version_cmd.go
35 lines (31 loc) 路 1.03 KB
/
auto_version_cmd.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
package app
import (
"net/http"
"github.com/cashapp/hermit/errors"
"github.com/cashapp/hermit/github"
"github.com/cashapp/hermit/manifest/autoversion"
"github.com/cashapp/hermit/manifest/digest"
"github.com/cashapp/hermit/state"
"github.com/cashapp/hermit/ui"
)
type autoVersionCmd struct {
UpdateDigests bool `help:"Update digests when auto-versioning."`
Manifest []string `arg:"" type:"existingfile" required:"" help:"Manifests to upgrade." predictor:"hclfile"`
}
func (a *autoVersionCmd) Run(l *ui.UI, hclient *http.Client, state *state.State, client *github.Client) error {
for _, path := range a.Manifest {
l.Debugf("Auto-versioning %s", path)
version, err := autoversion.AutoVersion(hclient, client, path)
if err != nil {
l.Warnf("could not auto-version %q: %s", path, err)
continue
}
if version != "" && a.UpdateDigests {
l.Infof("Auto-versioned %s to %s", path, version)
if err := digest.UpdateDigests(l, hclient, state, path); err != nil {
return errors.WithStack(err)
}
}
}
return nil
}