本文整理汇总了Golang中github.com/blang/semver.Make函数的典型用法代码示例。如果您正苦于以下问题:Golang Make函数的具体用法?Golang Make怎么用?Golang Make使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Make函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: GetUpdatePackage
// GetUpdatePackage returns an update package for the instance/application
// provided. The instance details and the application it's running will be
// registered in CoreRoller (or updated if it's already registered).
func (api *API) GetUpdatePackage(instanceID, instanceIP, instanceVersion, appID, groupID string) (*Package, error) {
instance, err := api.RegisterInstance(instanceID, instanceIP, instanceVersion, appID, groupID)
if err != nil {
return nil, ErrRegisterInstanceFailed
}
if instance.Application.Status.Valid {
switch int(instance.Application.Status.Int64) {
case InstanceStatusUpdateGranted, InstanceStatusDownloading, InstanceStatusDownloaded, InstanceStatusInstalled:
return nil, ErrUpdateInProgressOnInstance
}
}
group, err := api.GetGroup(groupID)
if err != nil {
return nil, err
}
if group.Channel == nil || group.Channel.Package == nil {
_ = api.newGroupActivityEntry(activityPackageNotFound, activityWarning, "0.0.0", appID, groupID)
return nil, ErrNoPackageFound
}
for _, blacklistedChannelID := range group.Channel.Package.ChannelsBlacklist {
if blacklistedChannelID == group.Channel.ID {
return nil, ErrNoUpdatePackageAvailable
}
}
instanceSemver, _ := semver.Make(instanceVersion)
packageSemver, _ := semver.Make(group.Channel.Package.Version)
if !instanceSemver.LT(packageSemver) {
return nil, ErrNoUpdatePackageAvailable
}
updatesStats, err := api.getGroupUpdatesStats(group)
if err != nil {
return nil, ErrGetUpdatesStatsFailed
}
if err := api.enforceRolloutPolicy(instance, group, updatesStats); err != nil {
return nil, err
}
if err := api.grantUpdate(instance.ID, appID, group.Channel.Package.Version); err != nil {
return nil, ErrGrantingUpdate
}
if updatesStats.UpdatesToCurrentVersionGranted == 0 {
_ = api.newGroupActivityEntry(activityRolloutStarted, activityInfo, group.Channel.Package.Version, appID, group.ID)
}
if !group.RolloutInProgress {
_ = api.setGroupRolloutInProgress(groupID, true)
}
_ = api.updateInstanceStatus(instance.ID, appID, InstanceStatusUpdateGranted)
return group.Channel.Package, nil
}
示例2: isUpgradeAvailable
func isUpgradeAvailable() (bool, string) {
gh := buildGithubClient()
release, response, err := gh.Repositories.GetLatestRelease("getcarina", "dvm")
if err != nil {
warnWhenRateLimitExceeded(err, response)
writeWarning("Unable to query the latest dvm release from GitHub:")
writeWarning("%s", err)
return false, ""
}
if response.StatusCode != 200 {
writeWarning("Unable to query the latest dvm release from GitHub (Status %s):", response.StatusCode)
return false, ""
}
currentVersion, err := semver.Make(dvmVersion)
if err != nil {
writeWarning("Unable to parse the current dvm version as a semantic version!")
writeWarning("%s", err)
return false, ""
}
latestVersion, err := semver.Make(*release.TagName)
if err != nil {
writeWarning("Unable to parse the latest dvm version as a semantic version!")
writeWarning("%s", err)
return false, ""
}
return latestVersion.Compare(currentVersion) > 0, *release.TagName
}
示例3: Less
func (a BugListByMilestone) Less(i, j int) bool {
iMS := a[i].Milestone()
jMS := a[j].Milestone()
// If there's a "v" at the start, strip it out
// before doing any comparisons of semantic
// versions
if len(iMS) > 1 && iMS[0] == "v"[0] {
iMS = iMS[1:]
}
if len(jMS) > 1 && jMS[0] == "v"[0] {
jMS = jMS[1:]
}
// First try semantic versioning comparison
iVer, iVerErr := semver.Make(iMS)
jVer, jVerErr := semver.Make(jMS)
if iVerErr == nil && jVerErr == nil {
return iVer.LT(jVer)
}
// Next try floating point comparison as an
// approximation of real number comparison..
iFloat, iVerErr := strconv.ParseFloat(iMS, 32)
jFloat, jVerErr := strconv.ParseFloat(jMS, 32)
if iVerErr == nil && jVerErr == nil {
return iFloat < jFloat
}
// Finally, just use a normal string collation
return iMS < jMS
}
示例4: latestTag
func latestTag(client *github.Client, org, name string) string {
opt := &github.ListOptions{PerPage: 100}
latest, err := semver.Make("0.0.1")
if err != nil {
panic(err)
}
for {
newTags, resp, err := client.Repositories.ListTags(org, name, opt)
if err != nil {
panic(err)
}
for _, tag := range newTags {
version, err := semver.Make(*tag.Name)
if err != nil {
continue
}
if version.Compare(latest) > 0 {
latest = version
}
}
if resp.NextPage == 0 {
break
}
opt.Page = resp.NextPage
}
return latest.String()
}
示例5: greater
func greater(s1, s2 string) bool {
v1, err1 := semver.Make(s1)
v2, err2 := semver.Make(s2)
if err1 != nil || err2 != nil {
return s1 > s2
}
return v1.Compare(v2) > 0
}
示例6: compareVersion
// @return result.Result<VersionStatus, error>
func compareVersion(toolVersion, repoVersion string) result.Result {
errorMsg := fmt.Sprintf(toolInvalidError, toolVersion, repoVersion)
invalidErr := result.NewFailure(errors.New(errorMsg))
vt := result.NewResult(semver.Make(toolVersion)).RecoverWith(invalidErr)
vr := result.NewResult(semver.Make(repoVersion)).RecoverWith(invalidErr)
return result.Combine(func(values ...interface{}) result.Result {
vt, vr := values[0].(semver.Version), values[1].(semver.Version)
return comparisonStatus(vt.Compare(vr))
}, vt, vr)
}
示例7: getLatestVersion
func (m *Manifest) getLatestVersion() string {
latestVersion, _ := semver.Make(NoVersion)
for _, version := range m.Versions {
if currentVersion, err := semver.Make(version.Version); err != nil {
continue
} else if latestVersion.LT(currentVersion) {
latestVersion = currentVersion
}
}
return latestVersion.String()
}
示例8: updateSelf
func updateSelf() error {
up := update.New()
if err := up.CanUpdate(); err != nil {
logger.Warn("msg", "Can't update this binary!", "error", err)
return err
}
up, err := up.VerifySignatureWithPEM([]byte(publicKey))
if err != nil {
logger.Error("msg", "Failed to parse public key!", "error", err)
return err
}
// check for the update
r, err := (&check.Params{
AppId: "ap_XZ-6toIU_0Bf0BJFDVvDpV9IVD",
AppVersion: version,
Channel: "latest",
}).CheckForUpdate(updateURI, up)
if err != nil {
if err == check.NoUpdateAvailable {
logger.Info("msg", "No update available.")
return nil
}
logger.Error("msg", "Checking for update", "error", err)
return err
}
v1, err := semver.Make(version)
if err != nil {
logger.Error("msg", "Bad version", "current", version, "error", err)
return err
}
v2, err := semver.Make(r.Version)
if err != nil {
logger.Error("msg", "Bad version", "new", r.Version, "error", err)
return err
}
if !v2.GTE(v1) {
logger.Warn("msg", "Version mismatch", "current", v1, "new", v2)
return nil
}
// apply the update
if err, _ = r.Update(); err != nil {
logger.Error("msg", "Update failed", "error", err)
return err
}
logger.Info("msg", "Update successful, exiting.")
os.Exit(0)
return nil
}
示例9: IsMinCliVersion
func (cmd *CliRpcCmd) IsMinCliVersion(version string, retVal *bool) error {
actualVersion, err := semver.Make(cf.Version)
if err != nil {
return err
}
requiredVersion, err := semver.Make(version)
if err != nil {
return err
}
*retVal = actualVersion.GTE(requiredVersion)
return nil
}
示例10: IsMountainLion
func IsMountainLion() bool {
osver, err := semver.Make(OSRelease())
if err != nil {
return false
}
return runtime.GOOS == "darwin" && osver.GTE(mountainLionVer)
}
示例11: Requirements
func (cmd *UnbindRouteService) Requirements(requirementsFactory requirements.Factory, fc flags.FlagContext) []requirements.Requirement {
if len(fc.Args()) != 2 {
cmd.ui.Failed(T("Incorrect Usage. Requires DOMAIN and SERVICE_INSTANCE as arguments\n\n") + commandregistry.Commands.CommandUsage("unbind-route-service"))
}
serviceName := fc.Args()[1]
cmd.serviceInstanceReq = requirementsFactory.NewServiceInstanceRequirement(serviceName)
domainName := fc.Args()[0]
cmd.domainReq = requirementsFactory.NewDomainRequirement(domainName)
minAPIVersion, err := semver.Make("2.51.0")
if err != nil {
panic(err.Error())
}
minAPIVersionRequirement := requirementsFactory.NewMinAPIVersionRequirement(
"unbind-route-service",
minAPIVersion,
)
reqs := []requirements.Requirement{
minAPIVersionRequirement,
requirementsFactory.NewLoginRequirement(),
cmd.domainReq,
cmd.serviceInstanceReq,
}
return reqs
}
示例12: IsWin8
func IsWin8() bool {
osver, err := semver.Make(OSRelease())
if err != nil {
return false
}
return runtime.GOOS == "windows" && osver.GTE(win8ver)
}
示例13: getNextVersion
func (m *Manifest) getNextVersion() string {
latestVersion, _ := semver.Make(m.getLatestVersion())
latestVersion.Minor++
latestVersion.Patch = 0
return latestVersion.String()
}
示例14: getLatestVersionFromURL
func getLatestVersionFromURL(url string) (semver.Version, error) {
r, err := GetAllVersionsFromURL(url)
if err != nil {
return semver.Version{}, err
}
return semver.Make(strings.TrimPrefix(r[0].Name, version.VersionPrefix))
}
示例15: Execute
func (r MaxAPIVersionRequirement) Execute() bool {
if r.config.ApiVersion() == "" {
r.ui.Failed(T("Unable to determine CC API Version. Please log in again."))
}
apiVersion, err := semver.Make(r.config.ApiVersion())
if err != nil {
r.ui.Failed(T("Unable to parse CC API Version '{{.APIVersion}}'", map[string]interface{}{
"APIVersion": r.config.ApiVersion(),
}))
return false
}
if apiVersion.GT(r.maximumVersion) {
r.ui.Failed(T(`{{.Feature}} only works up to CF API version {{.MaximumVersion}}. Your target is {{.ApiVersion}}.`,
map[string]interface{}{
"ApiVersion": r.config.ApiVersion(),
"Feature": r.feature,
"MaximumVersion": r.maximumVersion.String(),
}))
return false
}
return true
}