当前位置: 首页>>代码示例>>Golang>>正文


Golang Number.String方法代码示例

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


在下文中一共展示了Number.String方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: 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


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