當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Charm.Meta方法代碼示例

本文整理匯總了Golang中launchpad/net/juju-core/charm.Charm.Meta方法的典型用法代碼示例。如果您正苦於以下問題:Golang Charm.Meta方法的具體用法?Golang Charm.Meta怎麽用?Golang Charm.Meta使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在launchpad/net/juju-core/charm.Charm的用法示例。


在下文中一共展示了Charm.Meta方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: addCharm

func addCharm(c *C, st *State, series string, ch charm.Charm) *Charm {
	ident := fmt.Sprintf("%s-%s-%d", series, ch.Meta().Name, ch.Revision())
	curl := charm.MustParseURL("local:" + series + "/" + ident)
	bundleURL, err := url.Parse("http://bundles.testing.invalid/" + ident)
	c.Assert(err, IsNil)
	sch, err := st.AddCharm(ch, curl, bundleURL, ident+"-sha256")
	c.Assert(err, IsNil)
	return sch
}
開發者ID:hivetech,項目名稱:judo.legacy,代碼行數:9,代碼來源:export_test.go

示例2: checkDummy

func checkDummy(c *C, f charm.Charm, path string) {
	c.Assert(f.Revision(), Equals, 1)
	c.Assert(f.Meta().Name, Equals, "dummy")
	c.Assert(f.Config().Options["title"].Default, Equals, "My Title")
	switch f := f.(type) {
	case *charm.Bundle:
		c.Assert(f.Path, Equals, path)
	case *charm.Dir:
		c.Assert(f.Path, Equals, path)
	}
}
開發者ID:johnvilsack,項目名稱:golang-stuff,代碼行數:11,代碼來源:charm_test.go

示例3: AddCharm

// AddCharm adds the ch charm with curl to the state.  bundleUrl must be
// set to a URL where the bundle for ch may be downloaded from.
// On success the newly added charm state is returned.
func (st *State) AddCharm(ch charm.Charm, curl *charm.URL, bundleURL *url.URL, bundleSha256 string) (stch *Charm, err error) {
	cdoc := &charmDoc{
		URL:          curl,
		Meta:         ch.Meta(),
		Config:       ch.Config(),
		BundleURL:    bundleURL,
		BundleSha256: bundleSha256,
	}
	err = st.charms.Insert(cdoc)
	if err != nil {
		return nil, fmt.Errorf("cannot add charm %q: %v", curl, err)
	}
	return newCharm(st, cdoc)
}
開發者ID:hivetech,項目名稱:judo.legacy,代碼行數:17,代碼來源:state.go

示例4: ImplementedBy

// ImplementedBy returns whether the endpoint is implemented by the supplied charm.
func (ep Endpoint) ImplementedBy(ch charm.Charm) bool {
	if ep.IsImplicit() {
		return true
	}
	var m map[string]charm.Relation
	switch ep.Role {
	case charm.RoleProvider:
		m = ch.Meta().Provides
	case charm.RoleRequirer:
		m = ch.Meta().Requires
	case charm.RolePeer:
		m = ch.Meta().Peers
	default:
		panic(fmt.Errorf("unknown relation role %q", ep.Role))
	}
	rel, found := m[ep.Name]
	if !found {
		return false
	}
	if rel.Interface == ep.Interface {
		switch ep.Scope {
		case charm.ScopeGlobal:
			return rel.Scope != charm.ScopeContainer
		case charm.ScopeContainer:
			return true
		default:
			panic(fmt.Errorf("unknown relation scope %q", ep.Scope))
		}
	}
	return false
}
開發者ID:johnvilsack,項目名稱:golang-stuff,代碼行數:32,代碼來源:endpoint.go


注:本文中的launchpad/net/juju-core/charm.Charm.Meta方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。