// ApplyTabletAction applies the provided action to the tablet.
193418
func (ar *ActionRepository) ApplyTabletAction(ctx context.Context, actionName string, tabletAlias *topodatapb.TabletAlias, r *http.Request) *ActionResult {
	result := &ActionResult{
		Name:       actionName,
		Parameters: topoproto.TabletAliasString(tabletAlias),
	}

	action, ok := ar.tabletActions[actionName]
	if !ok {
		result.error("Unknown tablet action")
		return result
	}

	// check the role
	if action.role != "" {
		if err := acl.CheckAccessHTTP(r, action.role); err != nil {
			result.error("Access denied")
			return result
		}
	}

	// run the action
	ctx, cancel := context.WithTimeout(ctx, *actionTimeout)
	wr := wrangler.New(logutil.NewConsoleLogger(), ar.ts, tmclient.NewTabletManagerClient())
	output, err := action.method(ctx, wr, tabletAlias, r)
	cancel()
	if err != nil {
		result.error(err.Error())
		return result
	}
	result.Output = output
	return result
}
765589
func ApplyManifest(ctx Context, manifest *Manifest) error {
	for _, resource := range manifest.Resources {
		if err := ctx.Apply(resource); err != nil {
			return err
		}
	}

	return nil
}
445438
func (s *UpdateTableInput) SetTableInput(v *TableInput) *UpdateTableInput {
	s.TableInput = v
	return s
}
981256
func (s *DescribeTableOutput) SetTable(v *TableDescription) *DescribeTableOutput {
	s.Table = v
	return s
}
968041
func (format *ExtractJSON) ApplyFormatter(msg *core.Message) error {
	content := format.GetAppliedContent(msg)

	value, err := format.extractJSON(content)
	if err != nil {
		return err
	}

	format.SetAppliedContent(msg, value)
	return nil
}
1206999
func (s *Table) SetTableType(v string) *Table {
	s.TableType = &v
	return s
}
603783
func (actx *ApplyContext) ApplyPatch(patchReader savior.SeekSource) error {
	// XXX: this patch API does not support cancellation, so we just use a background
	// context
	ctx := context.Background()

	actx.actualOutputPath = actx.OutputPath
	if actx.OutputPool == nil {
		if actx.DryRun {
			if actx.actualOutputPath != "" {
				return fmt.Errorf("cannot specify both OutputPath and DryRun")
			}
		} else if actx.InPlace {
			// applying in-place is a bit tricky: we can't overwrite files in the
			// target directory (old) while we're reading the patch otherwise
			// we might be copying new bytes instead of old bytes into later files
			// so, we rebuild 'touched' files in a staging area
			stagePath := actx.StagePath
			if stagePath == "" {
				stagePath = actx.actualOutputPath + "-stage"
				actx.Consumer.Infof("No staging path specified, using: %s", stagePath)
			}
			err := os.MkdirAll(stagePath, os.FileMode(0755))
			if err != nil {
				return errors.WithStack(err)
			}

			defer os.RemoveAll(stagePath)
			actx.OutputPath = stagePath
		} else {
			os.MkdirAll(actx.OutputPath, os.FileMode(0755))
		}
	} else {
		if actx.actualOutputPath != "" {
			return fmt.Errorf("cannot specify both OutputPath and OutputPool")
		}
	}

	rawPatchWire := wire.NewReadContext(patchReader)
	err := rawPatchWire.ExpectMagic(PatchMagic)
	if err != nil {
		return errors.WithStack(err)
	}

	header := &PatchHeader{}
	err = rawPatchWire.ReadMessage(header)
	if err != nil {
		return errors.WithStack(err)
	}

	patchWire, err := DecompressWire(rawPatchWire, header.Compression)
	if err != nil {
		return errors.WithStack(err)
	}

	targetContainer := &tlc.Container{}
	err = patchWire.ReadMessage(targetContainer)
	if err != nil {
		return errors.WithStack(err)
	}
	actx.TargetContainer = targetContainer

	sourceContainer := &tlc.Container{}
	err = patchWire.ReadMessage(sourceContainer)
	if err != nil {
		return errors.WithStack(err)
	}
	actx.SourceContainer = sourceContainer

	if actx.VetApply != nil {
		err = actx.VetApply(actx)
		if err != nil {
			return errors.WithStack(err)
		}
	}

	var ghosts []Ghost

	// when not working with a custom output pool
	if actx.OutputPool == nil {
		if actx.DryRun {
			actx.OutputPool = nullpool.New(actx.SourceContainer)
		} else if actx.InPlace {
			// when working in-place, we have to keep track of which files were deleted
			// from one version to the other, so that we too may delete them in the end.
			ghosts = detectGhosts(actx.SourceContainer, actx.TargetContainer)
		} else {
			// when rebuilding in a fresh directory, there's no need to worry about
			// deleted files, because they won't even exist in the first place.
			err = sourceContainer.Prepare(actx.OutputPath)
			if err != nil {
				return errors.WithStack(err)
			}
		}
	}

	err = actx.patchAll(ctx, patchWire, actx.Signature)
	if err != nil {
		return errors.WithStack(err)
	}

	if actx.DryRun {
		// muffin to do
	} else if actx.InPlace {
		err = actx.ensureDirsAndSymlinks(actx.actualOutputPath)
		if err != nil {
			return errors.WithStack(err)
		}

		actx.Stats.StageSize, err = actx.mergeFolders(actx.actualOutputPath, actx.OutputPath)
		if err != nil {
			return errors.WithStack(err)
		}

		err = actx.deleteGhosts(actx.actualOutputPath, ghosts)
		if err != nil {
			return errors.WithStack(err)
		}
		actx.OutputPath = actx.actualOutputPath
	}

	return nil
}
10523
func ApplyRouteTable(r transport.RouteTable, m Router) transport.RouteTable {
	if m == nil {
		return r
	}
	return routeTableWithMiddleware{r: r, m: m}
}
575912
func (o *AttachDetachControllerOptions) ApplyTo(cfg *attachdetachconfig.AttachDetachControllerConfiguration) error {
	if o == nil {
		return nil
	}

	cfg.DisableAttachDetachReconcilerSync = o.DisableAttachDetachReconcilerSync
	cfg.ReconcilerSyncLoopPeriod = o.ReconcilerSyncLoopPeriod

	return nil
}
225907
func (o *HPAControllerOptions) ApplyTo(cfg *poautosclerconfig.HPAControllerConfiguration) error {
	if o == nil {
		return nil
	}

	cfg.HorizontalPodAutoscalerSyncPeriod = o.HorizontalPodAutoscalerSyncPeriod
	cfg.HorizontalPodAutoscalerDownscaleStabilizationWindow = o.HorizontalPodAutoscalerDownscaleStabilizationWindow
	cfg.HorizontalPodAutoscalerTolerance = o.HorizontalPodAutoscalerTolerance
	cfg.HorizontalPodAutoscalerUseRESTClients = o.HorizontalPodAutoscalerUseRESTClients
	cfg.HorizontalPodAutoscalerCPUInitializationPeriod = o.HorizontalPodAutoscalerCPUInitializationPeriod
	cfg.HorizontalPodAutoscalerInitialReadinessDelay = o.HorizontalPodAutoscalerInitialReadinessDelay

	return nil
}
707968
func (w *Waiter) ApplyOptions(opts ...WaiterOption) {
	for _, fn := range opts {
		fn(w)
	}
}
898823
func appliesTo(user user.Info, bindingSubjects []rbacv1.Subject, namespace string) (int, bool) {
	for i, bindingSubject := range bindingSubjects {
		if appliesToUser(user, bindingSubject, namespace) {
			return i, true
		}
	}
	return 0, false
}
616553
func (o *NodeLifecycleControllerOptions) ApplyTo(cfg *nodelifecycleconfig.NodeLifecycleControllerConfiguration) error {
	if o == nil {
		return nil
	}

	cfg.EnableTaintManager = o.EnableTaintManager
	cfg.NodeStartupGracePeriod = o.NodeStartupGracePeriod
	cfg.NodeMonitorGracePeriod = o.NodeMonitorGracePeriod
	cfg.PodEvictionTimeout = o.PodEvictionTimeout
	cfg.NodeEvictionRate = o.NodeEvictionRate
	cfg.SecondaryNodeEvictionRate = o.SecondaryNodeEvictionRate
	cfg.LargeClusterSizeThreshold = o.LargeClusterSizeThreshold
	cfg.UnhealthyZoneThreshold = o.UnhealthyZoneThreshold

	return nil
}
993237
func MouseAction(typ input.MouseType, x, y int64, opts ...MouseOption) Action {
	me := input.DispatchMouseEvent(typ, float64(x), float64(y))

	// apply opts
	for _, o := range opts {
		me = o(me)
	}

	return me
}
1098858
func (_class PoolClass) ApplyEdition(sessionID SessionRef, self PoolRef, edition string) (_err error) {
	_method := "pool.apply_edition"
	_sessionIDArg, _err := convertSessionRefToXen(fmt.Sprintf("%s(%s)", _method, "session_id"), sessionID)
	if _err != nil {
		return
	}
	_selfArg, _err := convertPoolRefToXen(fmt.Sprintf("%s(%s)", _method, "self"), self)
	if _err != nil {
		return
	}
	_editionArg, _err := convertStringToXen(fmt.Sprintf("%s(%s)", _method, "edition"), edition)
	if _err != nil {
		return
	}
	_, _err =  _class.client.APICall(_method, _sessionIDArg, _selfArg, _editionArg)
	return
}
1166200
func (format *Aggregate) ApplyFormatter(msg *core.Message) error {
	for _, modulator := range format.modulators {
		modulateResult := modulator.Modulate(msg)
		if modulateResult != core.ModulateResultContinue {
			errMsg := "child modulator discarded or trigger fallback routing. " +
				"Please try to use only contend based formatter and filter as child modulators"
			return fmt.Errorf(errMsg)
		}
	}
	return nil
}
744284
func (o *GenericControllerManagerConfigurationOptions) ApplyTo(cfg *kubectrlmgrconfig.GenericControllerManagerConfiguration) error {
	if o == nil {
		return nil
	}

	if err := o.Debugging.ApplyTo(&cfg.Debugging); err != nil {
		return err
	}

	cfg.Port = o.Port
	cfg.Address = o.Address
	cfg.MinResyncPeriod = o.MinResyncPeriod
	cfg.ClientConnection = o.ClientConnection
	cfg.ControllerStartInterval = o.ControllerStartInterval
	cfg.LeaderElection = o.LeaderElection
	cfg.Controllers = o.Controllers

	return nil
}