func (c *Client) Deploy(args DeployArgs) error {
	if len(args.AttachStorage) > 0 {
		if args.NumUnits != 1 {
			return errors.New("cannot attach existing storage when more than one unit is requested")
		}
		if c.BestAPIVersion() < 5 {
			return errors.New("this juju controller does not support AttachStorage")
		}
	}
	attachStorage := make([]string, len(args.AttachStorage))
	for i, id := range args.AttachStorage {
		if !names.IsValidStorage(id) {
			return errors.NotValidf("storage ID %q", id)
		}
		attachStorage[i] = names.NewStorageTag(id).String()
	}
	origin := args.CharmOrigin.ParamsCharmOrigin()
	deployArgs := params.ApplicationsDeploy{
		Applications: []params.ApplicationDeploy{{
			ApplicationName:  args.ApplicationName,
			Series:           args.Series,
			CharmURL:         args.CharmID.URL.String(),
			CharmOrigin:      &origin,
			Channel:          origin.Risk,
			NumUnits:         args.NumUnits,
			ConfigYAML:       args.ConfigYAML,
			Config:           args.Config,
			Constraints:      args.Cons,
			Placement:        args.Placement,
			Storage:          args.Storage,
			Devices:          args.Devices,
			AttachStorage:    attachStorage,
			EndpointBindings: args.EndpointBindings,
			Resources:        args.Resources,
			Force:            args.Force,
		}},
	}
	var results params.ErrorResults
	var err error
	err = c.facade.FacadeCall("Deploy", deployArgs, &results)
	if err != nil {
		return errors.Trace(err)
	}
	err = results.OneError()
	if err == nil {
		return nil
	}
	if pErr, ok := errors.Cause(err).(*params.Error); ok {
		switch pErr.Code {
		case params.CodeAlreadyExists:
			// Remove the "already exists" in the error message to prevent
			// stuttering.
			msg := strings.Replace(err.Error(), " already exists", "", -1)
			return errors.AlreadyExistsf(msg)
		}
	}
	return errors.Trace(err)
}
// Deploy obtains the charm, either locally or from the charm store, and deploys
// it. Placement directives, if provided, specify the machine on which the charm
// is deployed.
Deploy obtains the charm, either locally or from the charm store, and deploys
it. Placement directives, if provided, specify the machine on which the charm
is deployed.
// Deploy obtains the charm either locally or from the charm store and deploys // it . Placement directives if provided specify the machine on which the charm // is deployed .
func (c *Client) Deploy(args DeployArgs) error {
	if len(args.AttachStorage) > 0 {
		if args.NumUnits != 1 {
			return errors.New("cannot attach existing storage when more than one unit is requested")
		}
		if c.BestAPIVersion() < 5 {
			return errors.New("this juju controller does not support AttachStorage")
		}
	}
	attachStorage := make([]string, len(args.AttachStorage))
	for i, id := range args.AttachStorage {
		if !names.IsValidStorage(id) {
			return errors.NotValidf("storage ID %q", id)
		}
		attachStorage[i] = names.NewStorageTag(id).String()
	}
	origin := args.CharmOrigin.ParamsCharmOrigin()
	deployArgs := params.ApplicationsDeploy{
		Applications: []params.ApplicationDeploy{{
			ApplicationName:  args.ApplicationName,
			Series:           args.Series,
			CharmURL:         args.CharmID.URL.String(),
			CharmOrigin:      &origin,
			Channel:          origin.Risk,
			NumUnits:         args.NumUnits,
			ConfigYAML:       args.ConfigYAML,
			Config:           args.Config,
			Constraints:      args.Cons,
			Placement:        args.Placement,
			Storage:          args.Storage,
			Devices:          args.Devices,
			AttachStorage:    attachStorage,
			EndpointBindings: args.EndpointBindings,
			Resources:        args.Resources,
			Force:            args.Force,
		}},
	}
	var results params.ErrorResults
	var err error
	err = c.facade.FacadeCall("Deploy", deployArgs, &results)
	if err != nil {
		return errors.Trace(err)
	}
	err = results.OneError()
	if err == nil {
		return nil
	}
	if pErr, ok := errors.Cause(err).(*params.Error); ok {
		switch pErr.Code {
		case params.CodeAlreadyExists:
			msg := strings.Replace(err.Error(), " already exists", "", -1)
			return errors.AlreadyExistsf(msg)
		}
	}
	return errors.Trace(err)
}
func ( c * Client ) Deploy ( args DeployArgs ) error { if len ( args . AttachStorage ) > 0 { if args . NumUnits != 1 { return errors . New ( " " ) } if c . BestAPIVersion ( ) < 5 { return errors . New ( " " ) } } attachStorage := make ( [ ] string , len ( args . AttachStorage ) ) for i , id := range args . AttachStorage { if ! names . IsValidStorage ( id ) { return errors . NotValidf ( " " , id ) } attachStorage [ i ] = names . NewStorageTag ( id ) . String ( ) } origin := args . CharmOrigin . ParamsCharmOrigin ( ) deployArgs := params . ApplicationsDeploy { Applications : [ ] params . ApplicationDeploy { { ApplicationName : args . ApplicationName , Series : args . Series , CharmURL : args . CharmID . URL . String ( ) , CharmOrigin : & origin , Channel : origin . Risk , NumUnits : args . NumUnits , ConfigYAML : args . ConfigYAML , Config : args . Config , Constraints : args . Cons , Placement : args . Placement , Storage : args . Storage , Devices : args . Devices , AttachStorage : attachStorage , EndpointBindings : args . EndpointBindings , Resources : args . Resources , Force : args . Force , } } , } var results params . ErrorResults var err error err = c . facade . FacadeCall ( " " , deployArgs , & results ) if err != nil { return errors . Trace ( err ) } err = results . OneError ( ) if err == nil { return nil } if pErr , ok := errors . Cause ( err ) . ( * params . Error ) ; ok { switch pErr . Code { case params . CodeAlreadyExists : msg := strings . Replace ( err . Error ( ) , " " , " " , - 1 ) return errors . AlreadyExistsf ( msg ) } } return errors . Trace ( err ) }
Deploy obtains the charm, either locally or from the charm store, and deploys
it.
Deploy obtains the charm either locally or from the charm store and deploys it .
// Remove the "already exists" in the error message to prevent // stuttering.