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


Golang Strings.Values方法代码示例

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


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

示例1: stripIgnored

// stripIgnored removes the ignored DBs from the mongo dump files.
// This involves deleting DB-specific directories.
//
// NOTE(fwereade): the only directories we actually delete are "admin"
// and "backups"; and those only if they're in the `ignored` set. I have
// no idea why the code was structured this way; but I am, as requested
// as usual by management, *not* fixing anything about backup beyond the
// bug du jour.
//
// Basically, the ignored set is a filthy lie, and all the work we do to
// generate it is pure obfuscation.
func stripIgnored(ignored set.Strings, dumpDir string) error {
	for _, dbName := range ignored.Values() {
		switch dbName {
		case storageDBName, "admin":
			dirname := filepath.Join(dumpDir, dbName)
			if err := os.RemoveAll(dirname); err != nil {
				return errors.Trace(err)
			}
		}
	}

	return nil
}
开发者ID:bac,项目名称:juju,代码行数:24,代码来源:db.go

示例2: AssertValues

// Helper methods for the tests.
func AssertValues(c *gc.C, s set.Strings, expected ...string) {
	values := s.Values()
	// Expect an empty slice, not a nil slice for values.
	if expected == nil {
		expected = []string{}
	}
	sort.Strings(expected)
	sort.Strings(values)
	c.Assert(values, gc.DeepEquals, expected)
	c.Assert(s.Size(), gc.Equals, len(expected))
	// Check the sorted values too.
	sorted := s.SortedValues()
	c.Assert(sorted, gc.DeepEquals, expected)
}
开发者ID:kat-co,项目名称:utils,代码行数:15,代码来源:strings_test.go

示例3: prepareToSetDevicesAddresses

func (m *Machine) prepareToSetDevicesAddresses(devicesAddresses []LinkLayerDeviceAddress, existingProviderIDs set.Strings) ([]ipAddressDoc, error) {
	var pendingDocs []ipAddressDoc
	allProviderIDs := set.NewStrings(existingProviderIDs.Values()...)

	for _, args := range devicesAddresses {
		newDoc, err := m.prepareOneSetDevicesAddresses(&args, allProviderIDs)
		if err != nil {
			return nil, errors.Trace(err)
		}
		pendingDocs = append(pendingDocs, *newDoc)
		if args.ProviderID != "" {
			allProviderIDs.Add(string(args.ProviderID))
		}
	}
	return pendingDocs, nil
}
开发者ID:makyo,项目名称:juju,代码行数:16,代码来源:machine_linklayerdevices.go

示例4: stripIgnored

// stripIgnored removes the ignored DBs from the mongo dump files.
// This involves deleting DB-specific directories.
func stripIgnored(ignored set.Strings, dumpDir string) error {
	for _, dbName := range ignored.Values() {
		if dbName != "backups" {
			// We allow all ignored databases except "backups" to be
			// included in the archive file.  Restore will be
			// responsible for deleting those databases after
			// restoring them.
			continue
		}
		dirname := filepath.Join(dumpDir, dbName)
		if err := os.RemoveAll(dirname); err != nil {
			return errors.Trace(err)
		}
	}

	return nil
}
开发者ID:imoapps,项目名称:juju,代码行数:19,代码来源:db.go

示例5: loop

func (w *actionWatcher) loop() error {
	var (
		changes set.Strings
		in      <-chan watcher.Change = w.source
		out     chan<- []string       = w.sink
	)

	w.st.watcher.WatchCollectionWithFilter(w.st.actions.Name, w.source, w.filterFn)
	defer w.st.watcher.UnwatchCollection(w.st.actions.Name, w.source)

	initial, err := w.initial()
	if err != nil {
		return err
	}
	changes = initial

	for {
		select {
		case <-w.tomb.Dying():
			return tomb.ErrDying
		case <-w.st.watcher.Dead():
			return stateWatcherDeadError(w.st.watcher.Err())
		case ch := <-in:
			updates, ok := collect(ch, in, w.tomb.Dying())
			if !ok {
				return tomb.ErrDying
			}
			if err := w.merge(changes, initial, updates); err != nil {
				return err
			}
			if !changes.IsEmpty() {
				out = w.sink
			} else {
				out = nil
			}
		case out <- changes.Values():
			changes = set.NewStrings()
			out = nil
		}
	}
}
开发者ID:klyachin,项目名称:juju,代码行数:41,代码来源:watcher.go

示例6: upgradeCertificateDNSNames

// upgradeCertificateDNSNames ensure that the controller certificate
// recorded in the agent config and also mongo server.pem contains the
// DNSNames entries required by Juju.
func upgradeCertificateDNSNames(config agent.ConfigSetter) error {
	si, ok := config.StateServingInfo()
	if !ok || si.CAPrivateKey == "" {
		// No certificate information exists yet, nothing to do.
		return nil
	}

	// Validate the current certificate and private key pair, and then
	// extract the current DNS names from the certificate. If the
	// certificate validation fails, or it does not contain the DNS
	// names we require, we will generate a new one.
	var dnsNames set.Strings
	serverCert, _, err := cert.ParseCertAndKey(si.Cert, si.PrivateKey)
	if err != nil {
		// The certificate is invalid, so create a new one.
		logger.Infof("parsing certificate/key failed, will generate a new one: %v", err)
		dnsNames = set.NewStrings()
	} else {
		dnsNames = set.NewStrings(serverCert.DNSNames...)
	}

	update := false
	requiredDNSNames := []string{"local", "juju-apiserver", "juju-mongodb"}
	for _, dnsName := range requiredDNSNames {
		if dnsNames.Contains(dnsName) {
			continue
		}
		dnsNames.Add(dnsName)
		update = true
	}
	if !update {
		return nil
	}

	// Write a new certificate to the mongo pem and agent config files.
	si.Cert, si.PrivateKey, err = cert.NewDefaultServer(config.CACert(), si.CAPrivateKey, dnsNames.Values())
	if err != nil {
		return err
	}
	if err := mongo.UpdateSSLKey(config.DataDir(), si.Cert, si.PrivateKey); err != nil {
		return err
	}
	config.SetStateServingInfo(si)
	return nil
}
开发者ID:bac,项目名称:juju,代码行数:48,代码来源:machine.go


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