// WithBundle creates the bundle for the container
14794
func WithBundle(bundleDir string, ociSpec *specs.Spec) containerd.NewContainerOpts {
	return func(ctx context.Context, client *containerd.Client, c *containers.Container) error {
		if c.Labels == nil {
			c.Labels = make(map[string]string)
		}
		uid, gid := getSpecUser(ociSpec)
		if uid == 0 && gid == 0 {
			c.Labels[DockerContainerBundlePath] = bundleDir
			return idtools.MkdirAllAndChownNew(bundleDir, 0755, idtools.Identity{UID: 0, GID: 0})
		}

		p := string(filepath.Separator)
		components := strings.Split(bundleDir, string(filepath.Separator))
		for _, d := range components[1:] {
			p = filepath.Join(p, d)
			fi, err := os.Stat(p)
			if err != nil && !os.IsNotExist(err) {
				return err
			}
			if os.IsNotExist(err) || fi.Mode()&1 == 0 {
				p = fmt.Sprintf("%s.%d.%d", p, uid, gid)
				if err := idtools.MkdirAndChown(p, 0700, idtools.Identity{UID: uid, GID: gid}); err != nil && !os.IsExist(err) {
					return err
				}
			}
		}
		if c.Labels == nil {
			c.Labels = make(map[string]string)
		}
		c.Labels[DockerContainerBundlePath] = p
		return nil
	}
}
399754
func (api *API) ReplayBundle(tailTxHash Hash, depth uint64, mwm uint64, reference ...Hash) (bundle.Bundle, error) {
	if err := Validate(ValidateTransactionHashes(tailTxHash)); err != nil {
		return nil, err
	}
	bndl, err := api.GetBundle(tailTxHash)
	if err != nil {
		return nil, err
	}
	trytes := transaction.MustFinalTransactionTrytes(bndl)
	return api.SendTrytes(trytes, depth, mwm, reference...)
}
575218
func deployBundle(
	bundleDir string,
	data *charm.BundleData,
	bundleURL *charm.URL,
	bundleOverlayFile []string,
	channel csparams.Channel,
	apiRoot DeployAPI,
	ctx *cmd.Context,
	bundleStorage map[string]map[string]storage.Constraints,
	bundleDevices map[string]map[string]devices.Constraints,
	dryRun bool,
	useExistingMachines bool,
	bundleMachines map[string]string,
) (map[*charm.URL]*macaroon.Macaroon, error) {

	if err := composeBundle(data, ctx, bundleDir, bundleOverlayFile); err != nil {
		return nil, errors.Trace(err)
	}
	if err := verifyBundle(data, bundleDir); err != nil {
		return nil, errors.Trace(err)
	}

	// TODO: move bundle parsing and checking into the handler.
	h := makeBundleHandler(dryRun, bundleDir, channel, apiRoot, ctx, data, bundleURL, bundleStorage, bundleDevices)
	if err := h.makeModel(useExistingMachines, bundleMachines); err != nil {
		return nil, errors.Trace(err)
	}
	if err := h.resolveCharmsAndEndpoints(); err != nil {
		return nil, errors.Trace(err)
	}
	if err := h.getChanges(); err != nil {
		return nil, errors.Trace(err)
	}
	if err := h.handleChanges(); err != nil {
		return nil, errors.Trace(err)
	}
	return h.macaroons, nil

}
508042
func WithCredentialsBundle(b credentials.Bundle) DialOption {
	return newFuncDialOption(func(o *dialOptions) {
		o.copts.CredsBundle = b
	})
}
110126
func (b Builder) With(options ...Option) Builder {
	for i := range options {
		if options[i] != nil {
			options[i](&b)
		}
	}
	return b
}
1162908
func (c ChannelAwareFakeClient) UploadBundleWithRevision(id *charm.URL, bundle charm.Bundle, promulgatedRevision int) error {
	return c.charmstore.UploadBundleWithRevision(id, bundle, promulgatedRevision)
}
103418
func (s *CreateApplicationVersionInput) SetSourceBundle(v *S3Location) *CreateApplicationVersionInput {
	s.SourceBundle = v
	return s
}
178789
func (gv GroupVersion) WithResource(resource string) GroupVersionResource {
	return GroupVersionResource{Group: gv.Group, Version: gv.Version, Resource: resource}
}
958392
func (s *CreatePlatformVersionInput) SetPlatformDefinitionBundle(v *S3Location) *CreatePlatformVersionInput {
	s.PlatformDefinitionBundle = v
	return s
}
672004
func (r Repository) UploadBundleWithRevision(id *charm.URL, bundleData charm.Bundle, promulgatedRevision int) error {
	_, err := r.UploadBundle(id, bundleData)
	if err != nil {
		return errors.Trace(err)
	}
	r.revisions[r.channel][*id] = promulgatedRevision
	return nil
}
130986
func (ovsif *ovsExec) bundle(flows []string) error {
	if len(flows) == 0 {
		return nil
	}

	_, err := ovsif.execWithStdin(OVS_OFCTL, flows, "bundle", ovsif.bridge, "-")
	return err
}
965188
func NewPreKeyBundle(registrationID, deviceID, preKeyID uint32, preKey *ECPublicKey,
	signedPreKeyID int32, signedPreKey *ECPublicKey, signature []byte,
	identityKey *IdentityKey) (*PreKeyBundle, error) {
	pkb := &PreKeyBundle{
		RegistrationID:     registrationID,
		DeviceID:           deviceID,
		PreKeyID:           preKeyID,
		PreKeyPublic:       preKey,
		SignedPreKeyID:     signedPreKeyID,
		SignedPreKeyPublic: signedPreKey,
		IdentityKey:        identityKey,
	}
	copy(pkb.SignedPreKeySignature[:], signature)
	return pkb, nil
}
1065834
func (b *Bundle) Get(name string) (*template.Template, error) {
	if b.err != nil {
		return nil, b.err
	}
	if templ := b.templates[name]; templ != nil {
		return templ, nil
	}
	return nil, fmt.Errorf("template: no such template %q in the bundle", name)
}
679024
func (c *Client) Bundle(certResp *CertificateResponse) (bundledPEM []byte, err error) {
	if !certResp.IsAvailable() {
		return nil, errors.New("Cannot bundle without certificate")
	}

	if certResp.Issuer == "" {
		return nil, errors.New("Could not bundle certificates. Issuer not found")
	}

	resp, err := c.client.Get(certResp.Issuer)
	if err != nil {
		return nil, fmt.Errorf("Error requesting issuer certificate: %s", err)
	}
	defer resp.Body.Close()

	issuerDER, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		return nil, fmt.Errorf("Error reading issuer certificate: %s", err)
	}

	certPEM := pem.EncodeToMemory(&pem.Block{Type: "CERTIFICATE", Bytes: certResp.Certificate.Raw})
	issuerPEM := pem.EncodeToMemory(&pem.Block{Type: "CERTIFICATE", Bytes: issuerDER})

	return append(certPEM, issuerPEM...), nil
}
1284454
func (c *FakeBundles) Update(bundle *smithv1.Bundle) (result *smithv1.Bundle, err error) {
	obj, err := c.Fake.
		Invokes(testing.NewUpdateAction(bundlesResource, c.ns, bundle), &smithv1.Bundle{})

	if obj == nil {
		return nil, err
	}
	return obj.(*smithv1.Bundle), err
}
628601
func (h *AuthHandler) SetBundler(caBundleFile, intBundleFile string) (err error) {
	h.bundler, err = bundler.NewBundler(caBundleFile, intBundleFile)
	return err
}
699709
func (s *APNSChannelRequest) SetBundleId(v string) *APNSChannelRequest {
	s.BundleId = &v
	return s
}