forked from a2call/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
status.go
45 lines (41 loc) · 1.12 KB
/
status.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
package targets
import (
"github.com/Sirupsen/logrus"
"github.com/daticahealth/cli/commands/environments"
"github.com/daticahealth/cli/lib/images"
"github.com/daticahealth/cli/models"
"github.com/docker/notary/client/changelist"
)
func cmdTargetsStatus(envID, imageName string, user *models.User, ie environments.IEnvironments, ii images.IImages) error {
env, err := ie.Retrieve(envID)
if err != nil {
return err
}
repositoryName, tag, err := ii.GetGloballyUniqueNamespace(imageName, env, true)
if err != nil {
return err
}
repo := ii.GetNotaryRepository(env.Pod, repositoryName, user)
changelist, err := repo.GetChangelist()
if err != nil {
return err
}
changes := filterChanges(changelist.List(), tag)
if len(changes) > 0 {
ii.PrintChangelist(changes)
} else {
logrus.Printf("No unpublished changes for %s\n", repositoryName)
}
return nil
}
func filterChanges(changes []changelist.Change, tag string) (filteredList []changelist.Change) {
if tag == "" {
return changes
}
for _, change := range changes {
if change.Path() == tag {
filteredList = append(filteredList, change)
}
}
return filteredList
}