• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Golang version.Number类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/juju/version.Number的典型用法代码示例。如果您正苦于以下问题:Golang Number类的具体用法?Golang Number怎么用?Golang Number使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Number类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: bundleTools

// bundleTools bundles all the current juju tools in gzipped tar
// format to the given writer.
// If forceVersion is not nil, a FORCE-VERSION file is included in
// the tools bundle so it will lie about its current version number.
func bundleTools(build bool, w io.Writer, forceVersion *version.Number) (tvers version.Binary, sha256Hash string, err error) {
	dir, err := ioutil.TempDir("", "juju-tools")
	if err != nil {
		return version.Binary{}, "", err
	}
	defer os.RemoveAll(dir)
	if err := packageLocalTools(dir, build); err != nil {
		return version.Binary{}, "", err
	}

	// Extract the version number that the jujud binary was built with.
	// This is used to check compatibility with the version of the client
	// being used to bootstrap.
	tvers, err = getVersionFromJujud(dir)
	if err != nil {
		return version.Binary{}, "", errors.Trace(err)
	}

	if forceVersion != nil {
		logger.Debugf("forcing version to %s", forceVersion)
		if err := ioutil.WriteFile(filepath.Join(dir, "FORCE-VERSION"), []byte(forceVersion.String()), 0666); err != nil {
			return version.Binary{}, "", err
		}
	}

	sha256hash, err := archiveAndSHA256(w, dir)
	if err != nil {
		return version.Binary{}, "", err
	}
	return tvers, sha256hash, err
}
开发者ID:bac,项目名称:juju,代码行数:35,代码来源:build.go


示例2: NewDbLogger

// NewDbLogger returns a DbLogger instance which is used to write logs
// to the database.
func NewDbLogger(st ModelSessioner, entity names.Tag, ver version.Number) *DbLogger {
	_, logsColl := initLogsSession(st)
	return &DbLogger{
		logsColl:  logsColl,
		modelUUID: st.ModelUUID(),
		entity:    entity.String(),
		version:   ver.String(),
	}
}
开发者ID:bac,项目名称:juju,代码行数:11,代码来源:logs.go


示例3: TestUpgradeOperationsOrdered

func (s *upgradeSuite) TestUpgradeOperationsOrdered(c *gc.C) {
	var previous version.Number
	for i, utv := range (*upgrades.UpgradeOperations)() {
		vers := utv.TargetVersion()
		if i > 0 {
			c.Check(previous.Compare(vers), gc.Equals, -1)
		}
		previous = vers
	}
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:10,代码来源:upgrade_test.go


示例4: checkUpgradeInfoSanity

func checkUpgradeInfoSanity(st *State, machineId string, previousVersion, targetVersion version.Number) (bson.D, error) {
	if previousVersion.Compare(targetVersion) != -1 {
		return nil, errors.Errorf("cannot sanely upgrade from %s to %s", previousVersion, targetVersion)
	}
	controllerInfo, err := st.ControllerInfo()
	if err != nil {
		return nil, errors.Annotate(err, "cannot read controllers")
	}
	validIds := set.NewStrings(controllerInfo.MachineIds...)
	if !validIds.Contains(machineId) {
		return nil, errors.Errorf("machine %q is not a controller", machineId)
	}
	return assertExpectedVersions(previousVersion, targetVersion), nil
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:14,代码来源:upgrade.go


示例5: Newest

// Newest returns the greatest version in src, and the tools with that version.
func (src List) Newest() (version.Number, List) {
	var result List
	var best version.Number
	for _, tools := range src {
		if best.Compare(tools.Version.Number) < 0 {
			// Found new best number; reset result list.
			best = tools.Version.Number
			result = append(result[:0], tools)
		} else if tools.Version.Number == best {
			result = append(result, tools)
		}
	}
	return best, result
}
开发者ID:bac,项目名称:juju,代码行数:15,代码来源:list.go


示例6: UpdateLatestToolsVersion

// UpdateLatestToolsVersion looks up for the latest available version of
// juju tools and updates environementDoc with it.
func (m *Model) UpdateLatestToolsVersion(ver version.Number) error {
	v := ver.String()
	// TODO(perrito666): I need to assert here that there isn't a newer
	// version in place.
	ops := []txn.Op{{
		C:      modelsC,
		Id:     m.doc.UUID,
		Update: bson.D{{"$set", bson.D{{"available-tools", v}}}},
	}}
	err := m.st.runTransaction(ops)
	if err != nil {
		return errors.Trace(err)
	}
	return m.Refresh()
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:17,代码来源:model.go


示例7: setBootstrapToolsVersion

// setBootstrapToolsVersion updates the agent-version configuration attribute.
func setBootstrapToolsVersion(environ environs.Environ, toolsVersion version.Number) error {
	cfg := environ.Config()
	if agentVersion, _ := cfg.AgentVersion(); agentVersion != toolsVersion {
		cfg, err := cfg.Apply(map[string]interface{}{
			"agent-version": toolsVersion.String(),
		})
		if err == nil {
			err = environ.SetConfig(cfg)
		}
		if err != nil {
			return errors.Errorf("failed to update model configuration: %v", err)
		}
	}
	return nil
}
开发者ID:bac,项目名称:juju,代码行数:16,代码来源:bootstrap.go


示例8: GUISetVersion

// GUISetVersion sets the Juju GUI version that the controller must serve.
func (st *State) GUISetVersion(vers version.Number) error {
	// Check that the provided version is actually present in the GUI storage.
	storage, err := st.GUIStorage()
	if err != nil {
		return errors.Annotate(err, "cannot open GUI storage")
	}
	defer storage.Close()
	if _, err = storage.Metadata(vers.String()); err != nil {
		return errors.Annotatef(err, "cannot find %q GUI version in the storage", vers)
	}

	// Set the current version.
	settings, closer := st.getCollection(guisettingsC)
	defer closer()
	if _, err = settings.Writeable().Upsert(nil, bson.D{{"current-version", vers}}); err != nil {
		return errors.Annotate(err, "cannot set current GUI version")
	}
	return nil
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:20,代码来源:gui.go


示例9: uploadVersion

// uploadVersion returns a copy of the supplied version with a build number
// higher than any of the supplied tools that share its major, minor and patch.
func uploadVersion(vers version.Number, existing coretools.List) version.Number {
	vers.Build++
	for _, t := range existing {
		if t.Version.Major != vers.Major || t.Version.Minor != vers.Minor || t.Version.Patch != vers.Patch {
			continue
		}
		if t.Version.Build >= vers.Build {
			vers.Build = t.Version.Build + 1
		}
	}
	return vers
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:14,代码来源:upgradejuju.go


示例10: newOpsIterator

func newOpsIterator(from, to version.Number, ops []Operation) *opsIterator {
	// If from is not known, it is 1.16.
	if from == version.Zero {
		from = version.MustParse("1.16.0")
	}

	// Clear the version tag of the target release to ensure that all
	// upgrade steps for the release are run for alpha and beta
	// releases.
	// ...but only do this if the agent version has actually changed,
	// lest we trigger upgrade mode unnecessarily for non-final
	// versions.
	if from.Compare(to) != 0 {
		to.Tag = ""
	}

	return &opsIterator{
		from:    from,
		to:      to,
		allOps:  ops,
		current: -1,
	}
}
开发者ID:kat-co,项目名称:juju,代码行数:23,代码来源:operations.go


示例11: UploadGUIArchive

// UploadGUIArchive uploads a GUI archive to the controller over HTTPS, and
// reports about whether the upload updated the current GUI served by Juju.
func (c *Client) UploadGUIArchive(r io.ReadSeeker, hash string, size int64, vers version.Number) (current bool, err error) {
	// Prepare the request.
	v := url.Values{}
	v.Set("version", vers.String())
	v.Set("hash", hash)
	req, err := http.NewRequest("POST", guiArchivePath+"?"+v.Encode(), nil)
	if err != nil {
		return false, errors.Annotate(err, "cannot create upload request")
	}
	req.Header.Set("Content-Type", "application/x-tar-bzip2")
	req.ContentLength = size

	// Retrieve a client and send the request.
	httpClient, err := c.facade.RawAPICaller().HTTPClient()
	if err != nil {
		return false, errors.Annotate(err, "cannot retrieve HTTP client")
	}
	var resp params.GUIArchiveVersion
	if err = httpClient.Do(req, r, &resp); err != nil {
		return false, errors.Annotate(err, "cannot upload the GUI archive")
	}
	return resp.Current, nil
}
开发者ID:bac,项目名称:juju,代码行数:25,代码来源:gui.go


示例12: bundleTools

// BundleTools bundles all the current juju tools in gzipped tar
// format to the given writer.
// If forceVersion is not nil, a FORCE-VERSION file is included in
// the tools bundle so it will lie about its current version number.
func bundleTools(w io.Writer, forceVersion *version.Number) (tvers version.Binary, sha256Hash string, err error) {
	dir, err := ioutil.TempDir("", "juju-tools")
	if err != nil {
		return version.Binary{}, "", err
	}
	defer os.RemoveAll(dir)

	if err := copyExistingJujud(dir); err != nil {
		logger.Debugf("copy existing failed: %v", err)
		if err := buildJujud(dir); err != nil {
			return version.Binary{}, "", err
		}
	}

	if forceVersion != nil {
		logger.Debugf("forcing version to %s", forceVersion)
		if err := ioutil.WriteFile(filepath.Join(dir, "FORCE-VERSION"), []byte(forceVersion.String()), 0666); err != nil {
			return version.Binary{}, "", err
		}
	}
	cmd := exec.Command(filepath.Join(dir, names.Jujud), "version")
	out, err := cmd.CombinedOutput()
	if err != nil {
		return version.Binary{}, "", fmt.Errorf("cannot get version from %q: %v; %s", cmd.Args[0], err, out)
	}
	tvs := strings.TrimSpace(string(out))
	tvers, err = version.ParseBinary(tvs)
	if err != nil {
		return version.Binary{}, "", fmt.Errorf("invalid version %q printed by jujud", tvs)
	}

	sha256hash, err := archiveAndSHA256(w, dir)
	if err != nil {
		return version.Binary{}, "", err
	}
	return tvers, sha256hash, err
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:41,代码来源:build.go


示例13: SetBootstrapEndpointAddress

// SetBootstrapEndpointAddress writes the API endpoint address of the
// bootstrap server, plus the agent version, into the connection information.
// This should only be run once directly after Bootstrap. It assumes that
// there is just one instance in the environment - the bootstrap instance.
func SetBootstrapEndpointAddress(
	store jujuclient.ControllerStore,
	controllerName string, agentVersion version.Number,
	apiPort int, environ environs.Environ,
) error {
	instances, err := allInstances(environ)
	if err != nil {
		return errors.Trace(err)
	}
	length := len(instances)
	if length == 0 {
		return errors.Errorf("found no instances, expected at least one")
	}
	if length > 1 {
		return errors.Errorf("expected one instance, got %d", length)
	}
	bootstrapInstance := instances[0]

	// Don't use c.ConnectionEndpoint as it attempts to contact the state
	// server if no addresses are found in connection info.
	netAddrs, err := bootstrapInstance.Addresses()
	if err != nil {
		return errors.Annotate(err, "failed to get bootstrap instance addresses")
	}
	apiHostPorts := network.AddressesWithPort(netAddrs, apiPort)
	// At bootstrap we have 2 models, the controller model and the default.
	two := 2
	params := juju.UpdateControllerParams{
		AgentVersion:           agentVersion.String(),
		AddrConnectedTo:        apiHostPorts,
		MachineCount:           &length,
		ControllerMachineCount: &length,
		ModelCount:             &two,
	}
	return juju.UpdateControllerDetailsFromLogin(store, controllerName, params)
}
开发者ID:bac,项目名称:juju,代码行数:40,代码来源:controller.go


示例14: IsDev

// IsDev returns whether the version represents a development version. A
// version with a tag or a nonzero build component is considered to be a
// development version.  Versions older than or equal to 1.19.3 (the switch
// over time) check for odd minor versions.
func IsDev(v semversion.Number) bool {
	if v.Compare(switchOverVersion) <= 0 {
		return isOdd(v.Minor) || v.Build > 0
	}
	return v.Tag != "" || v.Build > 0
}
开发者ID:xushiwei,项目名称:juju,代码行数:10,代码来源:version.go



注:本文中的github.com/juju/version.Number类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang draw2d.GraphicContext类代码示例发布时间:2022-05-23
下一篇:
Golang version.Binary类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap