// deactivatePlugin deactivates the top plugin.
352709
func (w *mlWriter) deactivatePlugin() {
	w.stack = w.stack[:len(w.stack)-1]
}
1056663
func (pm PluginManager) Plugin(name string) interface{} {
	if p, exists := pm.pluginsByName[name]; exists {
		return p.instance.Interface()
	} else {
		return nil
	}
}
725161
func NewPlugin(opts ...Option) *Plugin {
	p := &Plugin{}

	p.PluginName = "grpcsync"
	p.GRPC = &grpc.DefaultPlugin

	for _, o := range opts {
		o(p)
	}

	return p
}
741831
func RegisterPlugin(key string, strategy ACLStrategy) {
	strategiesMutex.Lock()
	defer strategiesMutex.Unlock()

	if strategies == nil {
		strategies = make(map[string]ACLStrategy)
	}

	strategies[key] = strategy
}
454771
func (m *ServeMux) Plugin(plugin interface{}) {
	p, ok := plugin.(*pluginContainer)
	if !ok {
		p = &pluginContainer{base: plugin}
	}
	p.check()
	m.plugins = append(m.plugins, p)
}
1027298
func (s *userServiceImpl) DeactivateUser(ctx context.Context, username string) (*repository.Identity, error) {
	identities, err := s.Repositories().Identities().Query(
		repository.IdentityWithUser(),
		repository.IdentityFilterByUsername(username),
		repository.IdentityFilterByProviderType(repository.DefaultIDP))
	if err != nil {
		return nil, err
	}
	if len(identities) == 0 {
		return nil, errors.NewNotFoundErrorWithKey("user identity", "username", username)
	}
	identity := &identities[0]

	// call WIT and Tenant to deactivate the user,
	// using `auth` SA token here, not the request context's token
	err = s.Services().WITService().DeleteUser(ctx, username)
	if err != nil {
		// just log the error but don't suspend the deactivation
		log.Error(ctx, map[string]interface{}{"identity_id": identity.ID, "error": err}, "error occurred during user deactivation on WIT Service")
	}
	// call Che
	// call WIT and Tenant to deactivate the user there as well,
	// using `auth` SA token here, not the request context's token
	err = s.Services().CheService().DeleteUser(ctx, *identity)
	if err != nil {
		// do not proceed with tenant removal if something wrong happened during Che cleanup
		return nil, errs.Wrapf(err, "error occurred during deactivation of user '%s' on Che Service", identity.ID)
	}
	err = s.Services().TenantService().Delete(ctx, identity.ID)
	if err != nil {
		return nil, errs.Wrapf(err, "error occurred during deleting of user '%s' on Tenant Service", identity.ID)
	}

	// Now it's safe to clean up Auth DB
	if err := s.ExecuteInTransaction(func() error {
		// unlink external accounts (while we still have the user.Cluster info)
		err = s.Services().TokenService().DeleteExternalToken(ctx, identity.ID, "", provider.GitHubProviderAlias)
		if err != nil {
			return err
		}
		err = s.Services().TokenService().DeleteExternalToken(ctx, identity.ID, "", provider.OpenShiftProviderAlias)
		if err != nil {
			return err
		}

		// mark the account as inactive
		identity.User.Active = false
		// obfuscate the data
		obfuscatated := uuid.NewV4().String()
		identity.Username = obfuscatated
		identity.ProfileURL = &obfuscatated
		identity.User.Email = obfuscatated
		identity.User.FullName = obfuscatated
		identity.User.ImageURL = obfuscatated
		identity.User.URL = obfuscatated
		identity.User.Company = obfuscatated
		identity.User.Bio = obfuscatated
		identity.User.Cluster = obfuscatated
		identity.User.FeatureLevel = obfuscatated
		// empty data
		identity.User.ContextInformation = account.ContextInformation{}
		err = s.Repositories().Identities().Save(ctx, identity)
		if err != nil {
			return err
		}
		err = s.Repositories().Users().Save(ctx, &identity.User)
		if err != nil {
			return err
		}
		// revoke all user's tokens
		err = s.Services().TokenService().SetStatusForAllIdentityTokens(ctx, identity.ID, token.TOKEN_STATUS_REVOKED)
		if err != nil {
			return err
		}
		// soft-delete user account
		if err := s.Repositories().Identities().Delete(ctx, identity.ID); err != nil {
			return err
		}
		return s.Repositories().Users().Delete(ctx, identity.User.ID)
	}); err != nil {
		return nil, err
	}

	return identity, err
}
1012771
func (c *Client) ConfigurePlugin(opts ConfigurePluginOptions) error {
	path := "/plugins/" + opts.Name + "/set"
	resp, err := c.do("POST", path, doOptions{
		data:    opts.Envs,
		context: opts.Context,
	})
	defer resp.Body.Close()
	if err != nil {
		if e, ok := err.(*Error); ok && e.Status == http.StatusNotFound {
			return &NoSuchPlugin{ID: opts.Name}
		}
		return err
	}
	return nil
}
1020693
func (daemon *Daemon) DeactivateContainerServiceBinding(containerName string) error {
	container, err := daemon.GetContainer(containerName)
	if err != nil {
		return err
	}
	sb := daemon.getNetworkSandbox(container)
	if sb == nil {
		// If the network sandbox is not found, then there is nothing to deactivate
		logrus.Debugf("Could not find network sandbox for container %s on service binding deactivation request", containerName)
		return nil
	}
	return sb.DisableService()
}
166287
func (ssa *SQLStorageAuthority) DeactivateAuthorization2(ctx context.Context, req *sapb.AuthorizationID2) (*corepb.Empty, error) {
	_, err := ssa.dbMap.Exec(
		`UPDATE authz2 SET status = :deactivated WHERE id = :id and status IN (:valid,:pending)`,
		map[string]interface{}{
			"deactivated": statusUint(core.StatusDeactivated),
			"id":          *req.Id,
			"valid":       statusUint(core.StatusValid),
			"pending":     statusUint(core.StatusPending),
		},
	)
	if err != nil {
		return nil, err
	}
	return &corepb.Empty{}, nil
}
376151
func (m *MTTrie) DeleteByPlugin(cp core.CatalogedPlugin) {
	for _, mt := range m.gatherMetricTypes() {
		mtPluginKey := fmt.Sprintf("%s"+core.Separator+"%s"+core.Separator+"%d", mt.Plugin.TypeName(), mt.Plugin.Name(), mt.Plugin.Version())
		cpKey := fmt.Sprintf("%s"+core.Separator+"%s"+core.Separator+"%d", cp.TypeName(), cp.Name(), cp.Version())
		if mtPluginKey == cpKey {
			// remove this metric
			m.RemoveMetric(mt)
		}
	}
}
1026039
func WithPlugin(name string, conf interface{}) DaemonOpt {
	return func(r *remote) error {
		r.pluginConfs.Plugins[name] = conf
		return nil
	}
}
440639
func (n *nessusImpl) AllPlugins() (chan PluginDetails, error) {
	plugChan := make(chan PluginDetails, 20)

	families, err := n.PluginFamilies()
	if err != nil {
		return nil, err
	}
	idChan := make(chan int64, 20)
	var wgf sync.WaitGroup
	var wgp sync.WaitGroup
	// Launch a goroutine per family to get all the plugins of those families.
	for _, family := range families {
		wgf.Add(1)
		go func(famID int64) {
			defer wgf.Done()
			famDetails, err := n.FamilyDetails(famID)
			if err != nil {
				return
			}
			for _, plugin := range famDetails.Plugins {
				wgp.Add(1)
				idChan <- plugin.ID
			}
		}(family.ID)
	}
	// Launch our workers getting individual plugin details.
	for i := 0; i < 10; i++ {
		go func() {
			for id := range idChan {
				plugin, err := n.PluginDetails(id)
				if err != nil {
					wgp.Done()
					continue
				}
				plugChan <- *plugin
				wgp.Done()
			}
		}()
	}

	go func() {
		wgf.Wait()
		// Once we finished adding all the plugin IDs, we can close the channel.
		close(idChan)
		// Once all the plugins have been returned, we can close the plugin channel
		// to let the receiver know.
		wgp.Wait()
		close(plugChan)
	}()

	return plugChan, nil
}
12809
func (c Config) PluginsEnabled() bool {
	return c.Bundle != nil || c.DecisionLogs != nil || c.Status != nil || len(c.Plugins) > 0
}
537505
func (ps *Plugins) InitPlugin(name string, config io.Reader, pluginInitializer PluginInitializer) (Interface, error) {
	if name == "" {
		klog.Info("No admission plugin specified.")
		return nil, nil
	}

	plugin, found, err := ps.getPlugin(name, config)
	if err != nil {
		return nil, fmt.Errorf("couldn't init admission plugin %q: %v", name, err)
	}
	if !found {
		return nil, fmt.Errorf("unknown admission plugin: %s", name)
	}

	pluginInitializer.Initialize(plugin)
	// ensure that plugins have been properly initialized
	if err := ValidateInitialization(plugin); err != nil {
		return nil, fmt.Errorf("failed to initialize admission plugin %q: %v", name, err)
	}

	return plugin, nil
}
633191
func (s *State) Deactivate() {
	if s.active < 1 {
		return
	}
	atomic.StoreInt64(&s.active, 0)

	s.do.Lock()
	if s.deactivator != nil {
		s.deactivator()
	}
	s.do.Unlock()
}
286215
func (c *Client) DeletePluginConfig(pluginType, name, version string, key string) *DeletePluginConfigResult {
	r := &DeletePluginConfigResult{}
	b, err := json.Marshal([]string{key})
	if err != nil {
		r.Err = err
		return r
	}
	resp, err := c.do("DELETE", fmt.Sprintf("/plugins/%s/%s/%s/config", pluginType, url.QueryEscape(name), version), ContentTypeJSON, b)
	if err != nil {
		r.Err = err
		return r
	}

	switch resp.Meta.Type {
	case rbody.DeletePluginConfigItemType:
		// Success
		config := resp.Body.(*rbody.DeletePluginConfigItem)
		r = &DeletePluginConfigResult{config, nil}
	case rbody.ErrorType:
		r.Err = resp.Body.(*rbody.Error)
	default:
		r.Err = ErrAPIResponseMetaType
	}
	return r
}
301966
func (c *Sys) DeregisterPlugin(i *DeregisterPluginInput) error {
	path := catalogPathByType(i.Type, i.Name)
	req := c.c.NewRequest(http.MethodDelete, path)

	ctx, cancelFunc := context.WithCancel(context.Background())
	defer cancelFunc()
	resp, err := c.c.RawRequestWithContext(ctx, req)
	if err == nil {
		defer resp.Body.Close()
	}
	return err
}