// addRelabelUnit creates and enables a runtime systemd unit to run restorecon
// if there are files that need to be relabeled.
345607
func (s *stage) addRelabelUnit(config types.Config) error {
	if s.toRelabel == nil || len(s.toRelabel) == 0 {
		return nil
	}
	contents := `[Unit]
Description=Relabel files created by Ignition
DefaultDependencies=no
After=local-fs.target
Before=sysinit.target systemd-sysctl.service
ConditionSecurity=selinux
ConditionPathExists=/etc/selinux/ignition.relabel
OnFailure=emergency.target
OnFailureJobMode=replace-irreversibly

[Service]
Type=oneshot
ExecStart=` + distro.RestoreconCmd() + ` -0vRif /etc/selinux/ignition.relabel
ExecStart=/usr/bin/rm /etc/selinux/ignition.relabel
RemainAfterExit=yes`

	// create the unit file itself
	unit := types.Unit{
		Name:     "ignition-relabel.service",
		Contents: &contents,
	}

	if err := s.writeSystemdUnit(unit, true); err != nil {
		return err
	}

	if err := s.EnableRuntimeUnit(unit, "sysinit.target"); err != nil {
		return err
	}

	// and now create the list of files to relabel
	etcRelabelPath, err := s.JoinPath("etc/selinux/ignition.relabel")
	if err != nil {
		return err
	}
	f, err := os.Create(etcRelabelPath)
	if err != nil {
		return err
	}
	defer f.Close()

	// yes, apparently the final \0 is needed
	_, err = f.WriteString(strings.Join(s.toRelabel, "\000") + "\000")
	return err
}
297632
func addInitContainers(pod *apiv1.Pod, tmpl *wfv1.Template) error {
	if len(tmpl.InitContainers) == 0 {
		return nil
	}
	mainCtr := findMainContainer(pod)
	if mainCtr == nil {
		panic("Unable to locate main container")
	}
	for _, ctr := range tmpl.InitContainers {
		log.Debugf("Adding init container %s", ctr.Name)
		if ctr.MirrorVolumeMounts != nil && *ctr.MirrorVolumeMounts {
			mirrorVolumeMounts(mainCtr, &ctr.Container)
		}
		pod.Spec.InitContainers = append(pod.Spec.InitContainers, ctr.Container)
	}
	return nil
}
418205
func (bh *GCSBackupHandle) AddFile(ctx context.Context, filename string, filesize int64) (io.WriteCloser, error) {
	if bh.readOnly {
		return nil, fmt.Errorf("AddFile cannot be called on read-only backup")
	}
	object := objName(bh.dir, bh.name, filename)
	return bh.client.Bucket(*bucket).Object(object).NewWriter(ctx), nil
}
441378
func (cli *Client) BackupctlGet(appname string) (*pb.BackupctlReply, error) {
	req := &pb.BackupctlRequest{Appname: appname}
	ctx, cancel := context.WithTimeout(context.Background(), cli.timeout)
	defer cancel()
	rpl, err := cli.backupctlClient.Get(ctx, req)
	return rpl, err
}
1008867
func (r Network_Storage_Backup_Evault) AllowAccessFromVirtualGuest(virtualGuestObjectTemplate *datatypes.Virtual_Guest) (resp bool, err error) {
	params := []interface{}{
		virtualGuestObjectTemplate,
	}
	err = r.Session.DoRequest("SoftLayer_Network_Storage_Backup_Evault", "allowAccessFromVirtualGuest", params, &r.Options, &resp)
	return
}
720779
func (s *ReloadTablesInput) SetReloadOption(v string) *ReloadTablesInput {
	s.ReloadOption = &v
	return s
}
226721
func (c *Client) AddResourceApp(providerID, resourceID, appID string) (*ct.Resource, error) {
	var resource *ct.Resource
	return resource, c.Put(fmt.Sprintf("/providers/%s/resources/%s/apps/%s", providerID, resourceID, appID), nil, &resource)
}
1114643
func (p *NetPlugin) Reinit(cfg Config) {
	var err error

	p.Lock()
	defer p.Unlock()
	if p.NetworkDriver != nil {
		logrus.Infof("Reinit de-initializing NetworkDriver")
		p.NetworkDriver.Deinit()
		p.NetworkDriver = nil
	}

	cfg.Instance.StateDriver, _ = utils.GetStateDriver()
	p.NetworkDriver, err = utils.NewNetworkDriver(cfg.Drivers.Network, &cfg.Instance)
	logrus.Infof("Reinit Initializing NetworkDriver")

	if err != nil {
		logrus.Errorf("Reinit De-initializing due to error: %v", err)
		p.NetworkDriver.Deinit()
	}
}
1185013
func (b *RWSetBuilder) AddToReadSet(ns string, key string, version *version.Height) {
	nsPubRwBuilder := b.getOrCreateNsPubRwBuilder(ns)
	nsPubRwBuilder.readMap[key] = NewKVRead(key, version)
}
185395
func (s *Scheme) AddGeneratedConversionFuncs(conversionFuncs ...interface{}) error {
	for _, f := range conversionFuncs {
		if err := s.converter.RegisterGeneratedConversionFunc(f); err != nil {
			return err
		}
	}
	return nil
}
1241425
func (g *Generator) AddLinuxResourcesDevice(allow bool, devType string, major, minor *int64, access string) {
	g.initConfigLinuxResources()

	device := rspec.LinuxDeviceCgroup{
		Allow:  allow,
		Type:   devType,
		Access: access,
		Major:  major,
		Minor:  minor,
	}
	g.Config.Linux.Resources.Devices = append(g.Config.Linux.Resources.Devices, device)
}
317152
func (a *Agent) addServiceLocked(service *structs.NodeService, chkTypes []*structs.CheckType, persist bool, token string, source configSource) error {
	if err := a.validateService(service, chkTypes); err != nil {
		return err
	}

	if a.config.EnableCentralServiceConfig {
		return a.serviceManager.AddService(service, chkTypes, persist, token, source)
	}

	return a.addServiceInternal(service, chkTypes, persist, token, source)
}
619934
func FixInjectionsWithRelativePath(workdir string, injections api.VolumeList) api.VolumeList {
	if len(injections) == 0 {
		return injections
	}
	newList := api.VolumeList{}
	for _, injection := range injections {
		changed := false
		if filepath.Clean(filepath.FromSlash(injection.Destination)) == "." {
			injection.Destination = filepath.ToSlash(workdir)
			changed = true
		}
		if filepath.ToSlash(injection.Destination)[0] != '/' {
			injection.Destination = filepath.ToSlash(filepath.Join(workdir, injection.Destination))
			changed = true
		}
		if changed {
			glog.V(5).Infof("Using %q as a destination for injecting %q", injection.Destination, injection.Source)
		}
		newList = append(newList, injection)
	}
	return newList
}
872263
func (s *RelationalDatabase) SetBackupRetentionEnabled(v bool) *RelationalDatabase {
	s.BackupRetentionEnabled = &v
	return s
}
1221090
func (c *Client) AddToUnit(storages []params.StorageAddParams) ([]params.AddStorageResult, error) {
	out := params.AddStorageResults{}
	in := params.StoragesAddParams{Storages: storages}
	err := c.facade.FacadeCall("AddToUnit", in, &out)
	if err != nil {
		return nil, errors.Trace(err)
	}
	return out.Results, nil
}
255326
func (a *Agent) addServiceInternal(service *structs.NodeService, chkTypes []*structs.CheckType, persist bool, token string, source configSource) error {
	// Pause the service syncs during modification
	a.PauseSync()
	defer a.ResumeSync()

	// Take a snapshot of the current state of checks (if any), and
	// restore them before resuming anti-entropy.
	snap := a.snapshotCheckState()
	defer a.restoreCheckState(snap)

	var checks []*structs.HealthCheck

	// Create an associated health check
	for i, chkType := range chkTypes {
		checkID := string(chkType.CheckID)
		if checkID == "" {
			checkID = fmt.Sprintf("service:%s", service.ID)
			if len(chkTypes) > 1 {
				checkID += fmt.Sprintf(":%d", i+1)
			}
		}
		name := chkType.Name
		if name == "" {
			name = fmt.Sprintf("Service '%s' check", service.Service)
		}
		check := &structs.HealthCheck{
			Node:        a.config.NodeName,
			CheckID:     types.CheckID(checkID),
			Name:        name,
			Status:      api.HealthCritical,
			Notes:       chkType.Notes,
			ServiceID:   service.ID,
			ServiceName: service.Service,
			ServiceTags: service.Tags,
		}
		if chkType.Status != "" {
			check.Status = chkType.Status
		}

		checks = append(checks, check)
	}

	// cleanup, store the ids of services and checks that weren't previously
	// registered so we clean them up if somthing fails halfway through the
	// process.
	var cleanupServices []string
	var cleanupChecks []types.CheckID

	if s := a.State.Service(service.ID); s == nil {
		cleanupServices = append(cleanupServices, service.ID)
	}

	for _, check := range checks {
		if c := a.State.Check(check.CheckID); c == nil {
			cleanupChecks = append(cleanupChecks, check.CheckID)
		}
	}

	err := a.State.AddServiceWithChecks(service, checks, token)
	if err != nil {
		a.cleanupRegistration(cleanupServices, cleanupChecks)
		return err
	}

	for i := range checks {
		if err := a.addCheck(checks[i], chkTypes[i], service, persist, token, source); err != nil {
			a.cleanupRegistration(cleanupServices, cleanupChecks)
			return err
		}

		if persist && a.config.DataDir != "" {
			if err := a.persistCheck(checks[i], chkTypes[i]); err != nil {
				a.cleanupRegistration(cleanupServices, cleanupChecks)
				return err

			}
		}
	}

	// Persist the service to a file
	if persist && a.config.DataDir != "" {
		if err := a.persistService(service); err != nil {
			a.cleanupRegistration(cleanupServices, cleanupChecks)
			return err
		}
	}

	return nil
}
282028
func (c *Client) Restore(ctx context.Context, id string, checkpoint Image, opts ...RestoreOpts) (Container, error) {
	store := c.ContentStore()
	index, err := decodeIndex(ctx, store, checkpoint.Target())
	if err != nil {
		return nil, err
	}

	ctx, done, err := c.WithLease(ctx)
	if err != nil {
		return nil, err
	}
	defer done(ctx)

	copts := []NewContainerOpts{}
	for _, o := range opts {
		copts = append(copts, o(ctx, id, c, checkpoint, index))
	}

	ctr, err := c.NewContainer(ctx, id, copts...)
	if err != nil {
		return nil, err
	}

	return ctr, nil
}