-
Notifications
You must be signed in to change notification settings - Fork 90
/
peek.go
62 lines (51 loc) · 1.91 KB
/
peek.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
57
58
59
60
61
62
package pull
import (
"os"
"time"
"github.com/pkg/errors"
reportingtypes "github.com/replicatedhq/kots/pkg/api/reporting/types"
"github.com/replicatedhq/kots/pkg/logger"
"github.com/replicatedhq/kots/pkg/upstream"
upstreamtypes "github.com/replicatedhq/kots/pkg/upstream/types"
kotsv1beta1 "github.com/replicatedhq/kotskinds/apis/kots/v1beta1"
)
type GetUpdatesOptions struct {
HelmRepoURI string
Namespace string
License *kotsv1beta1.License
LastUpdateCheckAt *time.Time
CurrentCursor string
CurrentChannelID string
CurrentChannelName string
ChannelChanged bool
ReportingInfo *reportingtypes.ReportingInfo
Silent bool
}
// GetUpdates will retrieve all later versions of the application specified in upstreamURI
// using the options specified in getUpdatesOptions. It returns a list of versions.
func GetUpdates(upstreamURI string, getUpdatesOptions GetUpdatesOptions) (*upstreamtypes.UpdateCheckResult, error) {
log := logger.NewCLILogger(os.Stdout)
if getUpdatesOptions.Silent {
log.Silence()
}
log.Initialize()
fetchOptions := upstreamtypes.FetchOptions{}
fetchOptions.HelmRepoURI = getUpdatesOptions.HelmRepoURI
fetchOptions.LastUpdateCheckAt = getUpdatesOptions.LastUpdateCheckAt
fetchOptions.CurrentCursor = getUpdatesOptions.CurrentCursor
fetchOptions.CurrentChannelID = getUpdatesOptions.CurrentChannelID
fetchOptions.CurrentChannelName = getUpdatesOptions.CurrentChannelName
fetchOptions.ChannelChanged = getUpdatesOptions.ChannelChanged
fetchOptions.ReportingInfo = getUpdatesOptions.ReportingInfo
if getUpdatesOptions.License != nil {
fetchOptions.License = getUpdatesOptions.License
}
log.ActionWithSpinner("Listing releases")
v, err := upstream.GetUpdatesUpstream(upstreamURI, &fetchOptions)
if err != nil {
log.FinishSpinnerWithError()
return nil, errors.Wrap(err, "failed to peek upstream")
}
log.FinishSpinner()
return v, nil
}