本文整理汇总了Golang中github.com/juju/juju/state/api.Client类的典型用法代码示例。如果您正苦于以下问题:Golang Client类的具体用法?Golang Client怎么用?Golang Client使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Client类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: addCharmViaAPI
// addCharmViaAPI calls the appropriate client API calls to add the
// given charm URL to state. Also displays the charm URL of the added
// charm on stdout.
func addCharmViaAPI(client *api.Client, ctx *cmd.Context, curl *charm.URL, repo charm.Repository) (*charm.URL, error) {
if curl.Revision < 0 {
latest, err := charm.Latest(repo, curl)
if err != nil {
return nil, err
}
curl = curl.WithRevision(latest)
}
switch curl.Schema {
case "local":
ch, err := repo.Get(curl)
if err != nil {
return nil, err
}
stateCurl, err := client.AddLocalCharm(curl, ch)
if err != nil {
return nil, err
}
curl = stateCurl
case "cs":
err := client.AddCharm(curl)
if err != nil {
return nil, err
}
default:
return nil, fmt.Errorf("unsupported charm URL schema: %q", curl.Schema)
}
ctx.Infof("Added charm %q to the environment.", curl)
return curl, nil
}
开发者ID:rogpeppe,项目名称:juju,代码行数:33,代码来源:deploy.go
示例2: getCharmInfo
func getCharmInfo(client *api.Client, charmName string, localRepoPath string, defaultSeries string) (*api.CharmInfo, error) {
curl, err := resolveCharmURL(client, charmName, defaultSeries)
if err != nil {
return nil, err
}
repo, err := charm.InferRepository(curl.Reference, localRepoPath)
if err != nil {
return nil, err
}
// repo = config.SpecializeCharmRepo(repo, defaultSeries)
curl, err = addCharmViaAPI(client, curl, repo)
if err != nil {
return nil, err
}
charmInfo, err := client.CharmInfo(curl.String())
if err != nil {
log.Info("Error getting charm info for: %v", curl.String(), err)
return nil, err
}
return charmInfo, nil
}
开发者ID:jxaas,项目名称:jxaas,代码行数:25,代码来源:charm.go
示例3: resolveCharmURL
// resolveCharmURL returns a resolved charm URL, given a charm location string.
// If the series is not resolved, the environment default-series is used, or if
// not set, the series is resolved with the state server.
func resolveCharmURL(client *api.Client, url string, defaultSeries string) (*charm.URL, error) {
ref, series, err := charm.ParseReference(url)
if err != nil {
return nil, err
}
// If series is not set, use configured default series
if series == "" {
series = defaultSeries
}
// Otherwise, look up the best supported series for this charm
if series == "" {
return client.ResolveCharm(ref)
}
return &charm.URL{Reference: ref, Series: series}, nil
}
开发者ID:jxaas,项目名称:jxaas,代码行数:18,代码来源:charm.go
示例4: recordMachineInState
func recordMachineInState(
client *api.Client, machineParams params.AddMachineParams) (machineId string, err error) {
// Note: we explicitly use AddMachines1dot18 rather than AddMachines to preserve
// backwards compatibility; we do not require any of the new features of AddMachines
// here.
results, err := client.AddMachines1dot18([]params.AddMachineParams{machineParams})
if err != nil {
return "", err
}
// Currently, only one machine is added, but in future there may be several added in one call.
machineInfo := results[0]
if machineInfo.Error != nil {
return "", machineInfo.Error
}
return machineInfo.Machine, nil
}
开发者ID:rogpeppe,项目名称:juju,代码行数:16,代码来源:provisioner.go
示例5: initVersions
// initVersions collects state relevant to an upgrade decision. The returned
// agent and client versions, and the list of currently available tools, will
// always be accurate; the chosen version, and the flag indicating development
// mode, may remain blank until uploadTools or validate is called.
func (c *UpgradeJujuCommand) initVersions(client *api.Client, cfg *config.Config) (*upgradeContext, error) {
agent, ok := cfg.AgentVersion()
if !ok {
// Can't happen. In theory.
return nil, fmt.Errorf("incomplete environment configuration")
}
if c.Version == agent {
return nil, errUpToDate
}
clientVersion := version.Current.Number
findResult, err := client.FindTools(clientVersion.Major, -1, "", "")
var availableTools coretools.List
if params.IsCodeNotImplemented(err) {
availableTools, err = findTools1dot17(cfg)
} else {
availableTools = findResult.List
}
if err != nil {
return nil, err
}
err = findResult.Error
if findResult.Error != nil {
if !params.IsCodeNotFound(err) {
return nil, err
}
if !c.UploadTools {
// No tools found and we shouldn't upload any, so if we are not asking for a
// major upgrade, pretend there is no more recent version available.
if c.Version == version.Zero && agent.Major == clientVersion.Major {
return nil, errUpToDate
}
return nil, err
}
}
return &upgradeContext{
agent: agent,
client: clientVersion,
chosen: c.Version,
tools: availableTools,
apiClient: client,
config: cfg,
}, nil
}
开发者ID:jiasir,项目名称:juju,代码行数:47,代码来源:upgradejuju.go
示例6: resolveCharmURL
// resolveCharmURL returns a resolved charm URL, given a charm location string.
// If the series is not resolved, the environment default-series is used, or if
// not set, the series is resolved with the state server.
func resolveCharmURL(url string, client *api.Client, conf *config.Config) (*charm.URL, error) {
ref, series, err := charm.ParseReference(url)
if err != nil {
return nil, err
}
// If series is not set, use configured default series
if series == "" {
if defaultSeries, ok := conf.DefaultSeries(); ok {
series = defaultSeries
}
}
// Otherwise, look up the best supported series for this charm
if series == "" {
if ref.Schema == "local" {
possibleUrl := &charm.URL{Reference: ref, Series: "precise"}
logger.Errorf(`The series is not specified in the environment (default-series) or with the charm. Did you mean:
%s`, possibleUrl.String())
return nil, fmt.Errorf("cannot resolve series for charm: %q", ref)
}
return client.ResolveCharm(ref)
}
return &charm.URL{Reference: ref, Series: series}, nil
}
开发者ID:rogpeppe,项目名称:juju,代码行数:26,代码来源:common.go
示例7: assertEnvironmentName
func assertEnvironmentName(c *gc.C, client *api.Client, expectName string) {
envInfo, err := client.EnvironmentInfo()
c.Assert(err, gc.IsNil)
c.Assert(envInfo.Name, gc.Equals, expectName)
}
开发者ID:klyachin,项目名称:juju,代码行数:5,代码来源:api_test.go
注:本文中的github.com/juju/juju/state/api.Client类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论