本文整理汇总了Golang中github.com/juju/juju/version.Number类的典型用法代码示例。如果您正苦于以下问题:Golang Number类的具体用法?Golang Number怎么用?Golang Number使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Number类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestMongoRestoreArgsForOldVersion
func (s *mongoRestoreSuite) TestMongoRestoreArgsForOldVersion(c *gc.C) {
versionNumber := version.Number{}
versionNumber.Major = 0
versionNumber.Minor = 0
_, err := backups.MongoRestoreArgsForVersion(versionNumber, "/some/fake/path")
c.Assert(err, gc.ErrorMatches, "this backup file is incompatible with the current version of juju")
}
开发者ID:imoapps,项目名称:juju,代码行数:7,代码来源:db_restore_test.go
示例2: 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:kapilt,项目名称:juju,代码行数:10,代码来源:upgrade_test.go
示例3: 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:exekias,项目名称:juju,代码行数:14,代码来源:upgrade.go
示例4: 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:kapilt,项目名称:juju,代码行数:15,代码来源:list.go
示例5: UpdateLatestToolsVersion
// UpdateLatestToolsVersion looks up for the latest available version of
// juju tools and updates environementDoc with it.
func (e *Environment) 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: environmentsC,
Id: e.doc.UUID,
Update: bson.D{{"$set", bson.D{{"available-tools", v}}}},
}}
err := e.st.runTransaction(ops)
if err != nil {
return errors.Trace(err)
}
return e.Refresh()
}
开发者ID:snailwalker,项目名称:juju,代码行数:17,代码来源:environ.go
示例6: TestMongoRestoreArgsForVersion121
func (s *mongoRestoreSuite) TestMongoRestoreArgsForVersion121(c *gc.C) {
dir := filepath.Join(agent.DefaultPaths.DataDir, "db")
versionNumber := version.Number{}
versionNumber.Major = 1
versionNumber.Minor = 21
args, err := backups.MongoRestoreArgsForVersion(versionNumber, "/some/fake/path")
c.Assert(err, jc.ErrorIsNil)
c.Assert(args, gc.HasLen, 5)
c.Assert(args[0:5], jc.DeepEquals, []string{
"--drop",
"--journal",
"--dbpath",
dir,
"/some/fake/path",
})
}
开发者ID:imoapps,项目名称:juju,代码行数:16,代码来源:db_restore_test.go
示例7: PreferredStream
// PreferredStream returns the tools stream used to search for tools, based
// on the required version, whether devel mode is required, and any user specified stream.
func PreferredStream(vers *version.Number, forceDevel bool, stream string) string {
// If the use has already nominated a specific stream, we'll use that.
if stream != "" && stream != ReleasedStream {
return stream
}
// If we're not upgrading from a known version, we use the
// currently running version.
if vers == nil {
vers = &version.Current.Number
}
// Devel versions are alpha or beta etc as defined by the version tag.
// The user can also force the use of devel streams via config.
if forceDevel || vers.IsDev() {
return DevelStream
}
return ReleasedStream
}
开发者ID:ktsakalozos,项目名称:juju,代码行数:19,代码来源:tools.go
示例8: TestMongoRestoreArgsForVersion
func (s *mongoRestoreSuite) TestMongoRestoreArgsForVersion(c *gc.C) {
dir := filepath.Join(agent.DefaultDataDir, "db")
versionNumber := version.Number{}
versionNumber.Major = 1
versionNumber.Minor = 21
args, err := backups.MongoRestoreArgsForVersion(versionNumber, "/some/fake/path")
c.Assert(err, jc.ErrorIsNil)
c.Assert(args, gc.HasLen, 5)
c.Assert(args[0:5], jc.DeepEquals, []string{
"--drop",
"--journal",
"--dbpath",
dir,
"/some/fake/path",
})
versionNumber.Major = 1
versionNumber.Minor = 22
args, err = backups.MongoRestoreArgsForVersion(versionNumber, "/some/fake/path")
c.Assert(err, jc.ErrorIsNil)
c.Assert(args, gc.HasLen, 6)
c.Assert(args[0:6], jc.DeepEquals, []string{
"--drop",
"--journal",
"--oplogReplay",
"--dbpath",
dir,
"/some/fake/path",
})
versionNumber.Major = 0
versionNumber.Minor = 0
_, err = backups.MongoRestoreArgsForVersion(versionNumber, "/some/fake/path")
c.Assert(err, gc.ErrorMatches, "this backup file is incompatible with the current version of juju")
}
开发者ID:Pankov404,项目名称:juju,代码行数:35,代码来源:db_restore_test.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:kapilt,项目名称: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:imoapps,项目名称:juju,代码行数:23,代码来源:operations.go
示例11: 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:imoapps,项目名称:juju,代码行数:41,代码来源:build.go
示例12: SetBootstrapTools
// SetBootstrapTools returns the newest tools from the given tools list,
// and updates the agent-version configuration attribute.
func SetBootstrapTools(environ environs.Environ, possibleTools coretools.List) (coretools.List, error) {
if len(possibleTools) == 0 {
return nil, fmt.Errorf("no bootstrap tools available")
}
var newVersion version.Number
newVersion, toolsList := possibleTools.Newest()
logger.Infof("newest version: %s", newVersion)
cfg := environ.Config()
if agentVersion, _ := cfg.AgentVersion(); agentVersion != newVersion {
cfg, err := cfg.Apply(map[string]interface{}{
"agent-version": newVersion.String(),
})
if err == nil {
err = environ.SetConfig(cfg)
}
if err != nil {
return nil, fmt.Errorf("failed to update environment configuration: %v", err)
}
}
bootstrapVersion := newVersion
// We should only ever bootstrap the exact same version as the client,
// or we risk bootstrap incompatibility. We still set agent-version to
// the newest version, so the agent will immediately upgrade itself.
if !isCompatibleVersion(newVersion, version.Current.Number) {
compatibleVersion, compatibleTools := findCompatibleTools(possibleTools, version.Current.Number)
if len(compatibleTools) == 0 {
logger.Warningf(
"failed to find %s tools, will attempt to use %s",
version.Current.Number, newVersion,
)
} else {
bootstrapVersion, toolsList = compatibleVersion, compatibleTools
}
}
logger.Infof("picked bootstrap tools version: %s", bootstrapVersion)
return toolsList, nil
}
开发者ID:klyachin,项目名称:juju,代码行数:39,代码来源:bootstrap.go
示例13: SetEnvironAgentVersion
// SetEnvironAgentVersion changes the agent version for the
// environment to the given version, only if the environment is in a
// stable state (all agents are running the current version).
func (st *State) SetEnvironAgentVersion(newVersion version.Number) error {
for i := 0; i < 5; i++ {
settings, err := readSettings(st, environGlobalKey)
if err != nil {
return err
}
agentVersion, ok := settings.Get("agent-version")
if !ok {
return fmt.Errorf("no agent version set in the environment")
}
currentVersion, ok := agentVersion.(string)
if !ok {
return fmt.Errorf("invalid agent version format: expected string, got %v", agentVersion)
}
if newVersion.String() == currentVersion {
// Nothing to do.
return nil
}
if err := st.checkCanUpgrade(currentVersion, newVersion.String()); err != nil {
return err
}
ops := []txn.Op{{
C: st.settings.Name,
Id: environGlobalKey,
Assert: bson.D{{"txn-revno", settings.txnRevno}},
Update: bson.D{{"$set", bson.D{{"agent-version", newVersion.String()}}}},
}}
if err := st.runTransaction(ops); err == nil {
return nil
} else if err != txn.ErrAborted {
return fmt.Errorf("cannot set agent-version: %v", err)
}
}
return ErrExcessiveContention
}
开发者ID:rogpeppe,项目名称:juju,代码行数:40,代码来源:state.go
示例14: SetEnvironAgentVersion
// SetEnvironAgentVersion changes the agent version for the
// environment to the given version, only if the environment is in a
// stable state (all agents are running the current version).
func (st *State) SetEnvironAgentVersion(newVersion version.Number) (err error) {
buildTxn := func(attempt int) ([]txn.Op, error) {
settings, err := readSettings(st, environGlobalKey)
if err != nil {
return nil, err
}
agentVersion, ok := settings.Get("agent-version")
if !ok {
return nil, fmt.Errorf("no agent version set in the environment")
}
currentVersion, ok := agentVersion.(string)
if !ok {
return nil, fmt.Errorf("invalid agent version format: expected string, got %v", agentVersion)
}
if newVersion.String() == currentVersion {
// Nothing to do.
return nil, jujutxn.ErrNoOperations
}
if err := st.checkCanUpgrade(currentVersion, newVersion.String()); err != nil {
return nil, err
}
ops := []txn.Op{{
C: st.settings.Name,
Id: environGlobalKey,
Assert: bson.D{{"txn-revno", settings.txnRevno}},
Update: bson.D{{"$set", bson.D{{"agent-version", newVersion.String()}}}},
}}
return ops, nil
}
if err = st.run(buildTxn); err == jujutxn.ErrExcessiveContention {
err = errors.Annotate(err, "cannot set agent version")
}
return err
}
开发者ID:klyachin,项目名称:juju,代码行数:39,代码来源:state.go
示例15: isPreHAVersion
func isPreHAVersion(v version.Number) bool {
return v.Compare(version.MustParse("1.19.0")) < 0
}
开发者ID:zhouqt,项目名称:juju,代码行数:3,代码来源:machine.go
示例16: isCompatibleVersion
func isCompatibleVersion(v1, v2 version.Number) bool {
v1.Build = 0
v2.Build = 0
return v1.Compare(v2) == 0
}
开发者ID:klyachin,项目名称:juju,代码行数:5,代码来源:bootstrap.go
示例17: SetAgentVersion
// SetAgentVersion sets the current agent version in the state's
// environment configuration.
// This is similar to state.SetEnvironAgentVersion but it doesn't require that
// the environment have all agents at the same version already.
func SetAgentVersion(st *state.State, vers version.Number) error {
return st.UpdateEnvironConfig(map[string]interface{}{"agent-version": vers.String()}, nil, nil)
}
开发者ID:imoapps,项目名称:juju,代码行数:7,代码来源:agent.go
注:本文中的github.com/juju/juju/version.Number类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论