// Destination returns the deployment destination for an environment in app spec data
3421
func Destination(data []byte, environment string) (*v1alpha1.ApplicationDestination, error) {
	var appSpec struct {
		Environments map[string]struct {
			Destination v1alpha1.ApplicationDestination
		}
	}
	err := yaml.Unmarshal(data, &appSpec)
	if err != nil {
		return nil, fmt.Errorf("could not unmarshal ksonnet spec app.yaml: %v", err)
	}

	envSpec, ok := appSpec.Environments[environment]
	if !ok {
		return nil, fmt.Errorf("environment '%s' does not exist in ksonnet app", environment)
	}

	return &envSpec.Destination, nil
}
243939
func (s *Storage) Deployed(name string) (*rspb.Release, error) {
	ls, err := s.DeployedAll(name)
	if err != nil {
		if strings.Contains(err.Error(), "not found") {
			return nil, fmt.Errorf("%q %s", name, NoReleasesErr)
		}
		return nil, err
	}

	if len(ls) == 0 {
		return nil, fmt.Errorf("%q %s", name, NoReleasesErr)
	}

	return ls[0], err
}
27341
func (bi *BinaryInfo) Location(entry reader.Entry, attr dwarf.Attr, pc uint64, regs op.DwarfRegisters) (int64, []op.Piece, string, error) {
	instr, descr, err := bi.locationExpr(entry, attr, pc)
	if err != nil {
		return 0, nil, "", err
	}
	addr, pieces, err := op.ExecuteStackProgram(regs, instr)
	return addr, pieces, descr, err
}
244131
func destinations(svc *Service) ([]*Destination, error) {
	msg, err := netlink.NewMessage(C.IPVS_CMD_GET_DEST, family, netlink.MFDump)
	if err != nil {
		return nil, err
	}
	defer msg.Free()

	ic := &ipvsCommand{Service: newIPVSService(svc)}
	if err := msg.Marshal(ic); err != nil {
		return nil, err
	}

	var dsts []*Destination
	cb := func(msg *netlink.Message, arg interface{}) error {
		ic := &ipvsCommand{}
		if err := msg.Unmarshal(ic); err != nil {
			return fmt.Errorf("failed to unmarshal service: %v", err)
		}
		if ic.Destination == nil {
			return errors.New("no destination in unmarshalled message")
		}
		dsts = append(dsts, ic.Destination.toDestination())
		return nil
	}
	if err := msg.SendCallback(cb, nil); err != nil {
		return nil, err
	}
	return dsts, nil
}
1178067
func (p *RPCClientV7) Export(ctx context.Context) ([]byte, error) {
	var resp ExportResponse
	err := p.client.Call("RPCServer.Export", struct{}{}, &resp)
	if err != nil {
		if _, ok := err.(rpc.ServerError); !ok && err != nil {
			return resp.Result, remote.FatalError{err}
		}
		return resp.Result, err
	}
	err = resp.ApplicationError
	return resp.Result, err
}
3725
func (c *Client) Export() (migration.SerializedModel, error) {
	var empty migration.SerializedModel
	var serialized params.SerializedModel
	err := c.caller.FacadeCall("Export", nil, &serialized)
	if err != nil {
		return empty, errors.Trace(err)
	}

	// Convert tools info to output map.
	tools := make(map[version.Binary]string)
	for _, toolsInfo := range serialized.Tools {
		v, err := version.ParseBinary(toolsInfo.Version)
		if err != nil {
			return migration.SerializedModel{}, errors.Annotate(err, "error parsing agent binary version")
		}
		tools[v] = toolsInfo.URI
	}

	resources, err := convertResources(serialized.Resources)
	if err != nil {
		return empty, errors.Trace(err)
	}

	return migration.SerializedModel{
		Bytes:     serialized.Bytes,
		Charms:    serialized.Charms,
		Tools:     tools,
		Resources: resources,
	}, nil
}
721844
func (g *G) Go() Location {
	pc := g.GoPC
	if fn := g.variable.bi.PCToFunc(pc); fn != nil {
		// Backup to CALL instruction.
		// Mimics runtime/traceback.go:677.
		if g.GoPC > fn.Entry {
			pc--
		}
	}
	f, l, fn := g.variable.bi.PCToLine(pc)
	return Location{PC: g.GoPC, File: f, Line: l, Fn: fn}
}
718922
func Convert_v1_DeploymentCause_To_apps_DeploymentCause(in *v1.DeploymentCause, out *apps.DeploymentCause, s conversion.Scope) error {
	return autoConvert_v1_DeploymentCause_To_apps_DeploymentCause(in, out, s)
}
1282694
func (c *Client) Migrate(host string, port uint, key string, destination string, timeout int64) (string, error) {
	var ret string

	err := c.command(
		&ret,
		[]byte("MIGRATE"),
		[]byte(host),
		to.Bytes(port),
		[]byte(key),
		[]byte(destination),
		to.Bytes(timeout),
	)

	return ret, err
}
491858
func (s *RecreateDeploymentStrategy) Deploy(from *corev1.ReplicationController, to *corev1.ReplicationController, desiredReplicas int) error {
	return s.DeployWithAcceptor(from, to, desiredReplicas, nil)
}
435494
func (i *Handle) GetDestinations(s *Service) ([]*Destination, error) {
	return i.doGetDestinationsCmd(s, nil)
}
240076
func Move(ctx context.Context, src, dst string) (err error) {
	// Check context
	if err = ctx.Err(); err != nil {
		return
	}

	// Copy
	if err = Copy(ctx, src, dst); err != nil {
		return
	}

	// Check context
	if err = ctx.Err(); err != nil {
		return
	}

	// Delete
	err = os.Remove(src)
	return
}
1204463
func (d *driver) Move(ctx context.Context, sourcePath string, destPath string) error {
	srcBlobRef := d.client.GetContainerReference(d.container).GetBlobReference(sourcePath)
	sourceBlobURL := srcBlobRef.GetURL()
	destBlobRef := d.client.GetContainerReference(d.container).GetBlobReference(destPath)
	err := destBlobRef.Copy(sourceBlobURL, nil)
	if err != nil {
		if is404(err) {
			return storagedriver.PathNotFoundError{Path: sourcePath}
		}
		return err
	}

	return srcBlobRef.Delete(nil)
}
388751
func (u Unit) Destination(root string) string {
	return path.Join(u.prefix(root), u.Name)
}
446052
func (d *destination) down() {
	d.active = false
	log.Infof("%v: %v backend %v down", d.service.vserver, d.service, d)

	ncc := d.service.vserver.ncc
	if err := ncc.Dial(); err != nil {
		log.Fatalf("%v: failed to connect to NCC: %v", d.service.vserver, err)
	}
	defer ncc.Close()
	if err := ncc.IPVSDeleteDestination(d.service.ipvsSvc, d.ipvsDst); err != nil {
		log.Fatalf("%v: failed to delete destination %v: %v", d.service.vserver, d, err)
	}
}
972151
func (p DestinationPublisher) Publish(d Descriptor) error {
	if d.TargetPath == "" {
		return errors.New("Publish: must provide a TargetPath")
	}

	src := d.Src

	transformers := p.createTransformerChain(d)

	if len(transformers) != 0 {
		b := bp.GetBuffer()
		defer bp.PutBuffer(b)

		if err := transformers.Apply(b, d.Src); err != nil {
			return err
		}

		// This is now what we write to disk.
		src = b
	}

	f, err := helpers.OpenFileForWriting(p.fs, d.TargetPath)
	if err != nil {
		return err
	}
	defer f.Close()

	_, err = io.Copy(f, src)
	if err == nil && d.StatCounter != nil {
		atomic.AddUint64(d.StatCounter, uint64(1))
	}
	return err
}
692297
func (d *destination) update(dest *destination) {
	if d.destinationKey != dest.destinationKey {
		log.Fatalf("%v: can't update destination %v using %v: destinationKey mismatch: %v != %v",
			d.service.vserver, d, dest, d.destinationKey, dest.destinationKey)
	}
	log.Infof("%v: %v updating destination %v", d.service.vserver, d.service, d)

	updateIPVS := d.active && !d.ipvsEqual(dest)

	dest.active = d.active
	dest.healthy = d.healthy
	dest.stats = d.stats
	*d = *dest

	if !d.healthy {
		return
	}

	if !d.backend.Enabled {
		log.Infof("%v: %v disabling destination %v", d.service.vserver, d.service, d)
		d.healthy = false
		d.service.updateState()
		return
	}

	if !updateIPVS {
		return
	}

	log.Infof("%v: %v updating IPVS destination %v", d.service.vserver, d.service, d)
	ncc := d.service.vserver.ncc
	if err := ncc.Dial(); err != nil {
		log.Fatalf("%v: failed to connect to NCC: %v", d.service.vserver, err)
	}
	defer ncc.Close()

	if err := ncc.IPVSUpdateDestination(d.service.ipvsSvc, d.ipvsDst); err != nil {
		log.Fatalf("%v: failed to update destination %v: %v", d.service.vserver, d, err)
	}
}