本文整理汇总了Golang中github.com/wallyworld/core/errors.NotFoundf函数的典型用法代码示例。如果您正苦于以下问题:Golang NotFoundf函数的具体用法?Golang NotFoundf怎么用?Golang NotFoundf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NotFoundf函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: getMirrorReference
// getMirrorReference returns the reference to the metadata file containing mirrors for the specified content and cloud.
func (mirrorRefs *MirrorRefs) getMirrorReference(datatype, contentId string, cloud CloudSpec) (*MirrorReference, error) {
candidates := mirrorRefs.extractMirrorRefs(contentId)
if len(candidates) == 0 {
return nil, errors.NotFoundf("mirror data for %q", contentId)
}
// Restrict by cloud spec and datatype.
hasRightCloud := func(mirrorRef *MirrorReference) bool {
return mirrorRef.hasCloud(cloud) && mirrorRef.DataType == datatype
}
matchingCandidates := candidates.filter(hasRightCloud)
if len(matchingCandidates) == 0 {
// No cloud specific mirrors found so look for a non cloud specific mirror.
for _, candidate := range candidates {
if len(candidate.Clouds) == 0 {
logger.Debugf("using default candidate for content id %q are %v", contentId, candidate)
return &candidate, nil
}
}
return nil, errors.NotFoundf("index file with cloud %v", cloud)
}
logger.Debugf("candidate matches for content id %q are %v", contentId, candidates)
// Pick arbitrary match.
return &matchingCandidates[0], nil
}
开发者ID:jameinel,项目名称:core,代码行数:27,代码来源:simplestreams.go
示例2: removeSettings
// removeSettings removes the Settings for key.
func removeSettings(st *State, key string) error {
err := st.settings.RemoveId(key)
if err == mgo.ErrNotFound {
return errors.NotFoundf("settings")
}
return nil
}
开发者ID:jameinel,项目名称:core,代码行数:8,代码来源:settings.go
示例3: refresh
func (e *Environment) refresh(query *mgo.Query) error {
err := query.One(&e.doc)
if err == mgo.ErrNotFound {
return errors.NotFoundf("environment")
}
return err
}
开发者ID:jameinel,项目名称:core,代码行数:7,代码来源:environ.go
示例4: AgentTools
// AgentTools returns the tools that the agent is currently running.
// It returns an error that satisfies errors.IsNotFound if the tools
// have not yet been set.
func (m *Machine) AgentTools() (*tools.Tools, error) {
if m.doc.Tools == nil {
return nil, errors.NotFoundf("agent tools for machine %v", m)
}
tools := *m.doc.Tools
return &tools, nil
}
开发者ID:jameinel,项目名称:core,代码行数:10,代码来源:machine.go
示例5: AgentTools
// AgentTools returns the tools that the agent is currently running.
// It an error that satisfies errors.IsNotFound if the tools have not
// yet been set.
func (u *Unit) AgentTools() (*tools.Tools, error) {
if u.doc.Tools == nil {
return nil, errors.NotFoundf("agent tools for unit %q", u)
}
tools := *u.doc.Tools
return &tools, nil
}
开发者ID:jameinel,项目名称:core,代码行数:10,代码来源:unit.go
示例6: runAllowRetriesTest
func (s *BootstrapSuite) runAllowRetriesTest(c *gc.C, test bootstrapRetryTest) {
toolsVersions := envtesting.VAll
if test.version != "" {
useVersion := strings.Replace(test.version, "%LTS%", config.LatestLtsSeries(), 1)
testVersion := version.MustParseBinary(useVersion)
s.PatchValue(&version.Current, testVersion)
if test.addVersionToSource {
toolsVersions = append([]version.Binary{}, toolsVersions...)
toolsVersions = append(toolsVersions, testVersion)
}
}
_, fake := makeEmptyFakeHome(c)
defer fake.Restore()
sourceDir := createToolsSource(c, toolsVersions)
s.PatchValue(&envtools.DefaultBaseURL, sourceDir)
var findToolsRetryValues []bool
mockFindTools := func(cloudInst environs.ConfigGetter, majorVersion, minorVersion int,
filter coretools.Filter, allowRetry bool) (list coretools.List, err error) {
findToolsRetryValues = append(findToolsRetryValues, allowRetry)
return nil, errors.NotFoundf("tools")
}
restore := envtools.TestingPatchBootstrapFindTools(mockFindTools)
defer restore()
_, errc := runCommand(nullContext(c), new(BootstrapCommand), test.args...)
err := <-errc
c.Check(findToolsRetryValues, gc.DeepEquals, test.expectedAllowRetry)
stripped := strings.Replace(err.Error(), "\n", "", -1)
c.Check(stripped, gc.Matches, test.err)
}
开发者ID:jameinel,项目名称:core,代码行数:32,代码来源:bootstrap_test.go
示例7: settingsDecRefOps
// settingsDecRefOps returns a list of operations that decrement the
// ref count of the service settings identified by serviceName and
// curl. If the ref count is set to zero, the appropriate setting and
// ref count documents will both be deleted.
func settingsDecRefOps(st *State, serviceName string, curl *charm.URL) ([]txn.Op, error) {
key := serviceSettingsKey(serviceName, curl)
var doc settingsRefsDoc
if err := st.settingsrefs.FindId(key).One(&doc); err == mgo.ErrNotFound {
return nil, errors.NotFoundf("service %q settings for charm %q", serviceName, curl)
} else if err != nil {
return nil, err
}
if doc.RefCount == 1 {
return []txn.Op{{
C: st.settingsrefs.Name,
Id: key,
Assert: bson.D{{"refcount", 1}},
Remove: true,
}, {
C: st.settings.Name,
Id: key,
Remove: true,
}}, nil
}
return []txn.Op{{
C: st.settingsrefs.Name,
Id: key,
Assert: bson.D{{"refcount", bson.D{{"$gt", 1}}}},
Update: bson.D{{"$inc", bson.D{{"refcount", -1}}}},
}}, nil
}
开发者ID:jameinel,项目名称:core,代码行数:31,代码来源:service.go
示例8: getUser
// getUser fetches information about the user with the
// given name into the provided userDoc.
func (st *State) getUser(name string, udoc *userDoc) error {
err := st.users.Find(bson.D{{"_id", name}}).One(udoc)
if err == mgo.ErrNotFound {
err = errors.NotFoundf("user %q", name)
}
return err
}
开发者ID:jameinel,项目名称:core,代码行数:9,代码来源:user.go
示例9: readConstraints
func readConstraints(st *State, id string) (constraints.Value, error) {
doc := constraintsDoc{}
if err := st.constraints.FindId(id).One(&doc); err == mgo.ErrNotFound {
return constraints.Value{}, errors.NotFoundf("constraints")
} else if err != nil {
return constraints.Value{}, err
}
return doc.value(), nil
}
开发者ID:jameinel,项目名称:core,代码行数:9,代码来源:constraints.go
示例10: ReadInfo
// ReadInfo implements Storage.ReadInfo.
func (m *memStore) ReadInfo(envName string) (EnvironInfo, error) {
m.mu.Lock()
defer m.mu.Unlock()
info := m.envs[envName]
if info != nil {
return info.clone(), nil
}
return nil, errors.NotFoundf("environment %q", envName)
}
开发者ID:jameinel,项目名称:core,代码行数:10,代码来源:mem.go
示例11: Machine
func (st *fakeState) Machine(id string) (stateMachine, error) {
if err := errorFor("State.Machine", id); err != nil {
return nil, err
}
if m := st.machine(id); m != nil {
return m, nil
}
return nil, errors.NotFoundf("machine %s", id)
}
开发者ID:jameinel,项目名称:core,代码行数:9,代码来源:mock_test.go
示例12: Refresh
// Refresh refreshes the contents of the relation from the underlying
// state. It returns an error that satisfies errors.IsNotFound if the
// relation has been removed.
func (r *Relation) Refresh() error {
doc := relationDoc{}
err := r.st.relations.FindId(r.doc.Key).One(&doc)
if err == mgo.ErrNotFound {
return errors.NotFoundf("relation %v", r)
}
if err != nil {
return fmt.Errorf("cannot refresh relation %v: %v", r, err)
}
if r.doc.Id != doc.Id {
// The relation has been destroyed and recreated. This is *not* the
// same relation; if we pretend it is, we run the risk of violating
// the lifecycle-only-advances guarantee.
return errors.NotFoundf("relation %v", r)
}
r.doc = doc
return nil
}
开发者ID:jameinel,项目名称:core,代码行数:21,代码来源:relation.go
示例13: TestUpdateEnvironConfigFailsOnConfigValidateError
func (s *ConfigValidatorSuite) TestUpdateEnvironConfigFailsOnConfigValidateError(c *gc.C) {
var configValidatorErr error
s.policy.getConfigValidator = func(string) (state.ConfigValidator, error) {
configValidatorErr = errors.NotFoundf("")
return &s.configValidator, configValidatorErr
}
err := s.updateEnvironConfig(c)
c.Assert(err, gc.ErrorMatches, " not found")
}
开发者ID:jameinel,项目名称:core,代码行数:10,代码来源:configvalidator_test.go
示例14: Refresh
// Refresh refreshes the contents of the Unit from the underlying
// state. It an error that satisfies errors.IsNotFound if the unit has
// been removed.
func (u *Unit) Refresh() error {
err := u.st.units.FindId(u.doc.Name).One(&u.doc)
if err == mgo.ErrNotFound {
return errors.NotFoundf("unit %q", u)
}
if err != nil {
return fmt.Errorf("cannot refresh unit %q: %v", u, err)
}
return nil
}
开发者ID:jameinel,项目名称:core,代码行数:13,代码来源:unit.go
示例15: constraints
// constraints is a helper function to return a unit's deployment constraints.
func (u *Unit) constraints() (*constraints.Value, error) {
cons, err := readConstraints(u.st, u.globalKey())
if errors.IsNotFound(err) {
// Lack of constraints indicates lack of unit.
return nil, errors.NotFoundf("unit")
} else if err != nil {
return nil, err
}
return &cons, nil
}
开发者ID:jameinel,项目名称:core,代码行数:11,代码来源:unit.go
示例16: FindEntity
func (st *fakeState) FindEntity(tag string) (state.Entity, error) {
entity, ok := st.entities[tag]
if !ok {
return nil, errors.NotFoundf("entity %q", tag)
}
if err := entity.error(); err != nil {
return nil, err
}
return entity, nil
}
开发者ID:jameinel,项目名称:core,代码行数:10,代码来源:password_test.go
示例17: Refresh
// Refresh refreshes the contents of the Service from the underlying
// state. It returns an error that satisfies errors.IsNotFound if the
// service has been removed.
func (s *Service) Refresh() error {
err := s.st.services.FindId(s.doc.Name).One(&s.doc)
if err == mgo.ErrNotFound {
return errors.NotFoundf("service %q", s)
}
if err != nil {
return fmt.Errorf("cannot refresh service %q: %v", s, err)
}
return nil
}
开发者ID:jameinel,项目名称:core,代码行数:13,代码来源:service.go
示例18: TestPartialErrResponse
func (s *aggregateSuite) TestPartialErrResponse(c *gc.C) {
testGetter := new(testInstanceGetter)
testGetter.err = environs.ErrPartialInstances
testGetter.results = []instance.Instance{nil}
aggregator := newAggregator(testGetter)
_, err := aggregator.instanceInfo("foo")
c.Assert(err, gc.DeepEquals, errors.NotFoundf("instance foo"))
}
开发者ID:jameinel,项目名称:core,代码行数:10,代码来源:aggregate_test.go
示例19: Network
// Network returns the network with the given name.
func (st *State) Network(name string) (*Network, error) {
doc := &networkDoc{}
err := st.networks.FindId(name).One(doc)
if err == mgo.ErrNotFound {
return nil, errors.NotFoundf("network %q", name)
}
if err != nil {
return nil, fmt.Errorf("cannot get network %q: %v", name, err)
}
return newNetwork(st, doc), nil
}
开发者ID:jameinel,项目名称:core,代码行数:12,代码来源:state.go
示例20: Get
// Get is specified in the StorageReader interface.
func (storage *azureStorage) Get(name string) (io.ReadCloser, error) {
context, err := storage.getStorageContext()
if err != nil {
return nil, err
}
reader, err := context.GetBlob(storage.getContainer(), name)
if gwacl.IsNotFoundError(err) {
return nil, errors.NotFoundf("file %q not found", name)
}
return reader, err
}
开发者ID:jameinel,项目名称:core,代码行数:12,代码来源:storage.go
注:本文中的github.com/wallyworld/core/errors.NotFoundf函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论