// AppDestroy destroys an app.
331902
func AppDestroy(appID, confirm string) error {
	gitSession := false

	c, err := client.New()

	if err != nil {
		return err
	}

	if appID == "" {
		appID, err = git.DetectAppName(c.ControllerURL.Host)

		if err != nil {
			return err
		}

		gitSession = true
	}

	if confirm == "" {
		fmt.Printf(` !    WARNING: Potentially Destructive Action
 !    This command will destroy the application: %s
 !    To proceed, type "%s" or re-run this command with --confirm=%s

> `, appID, appID, appID)

		fmt.Scanln(&confirm)
	}

	if confirm != appID {
		return fmt.Errorf("App %s does not match confirm %s, aborting.", appID, confirm)
	}

	startTime := time.Now()
	fmt.Printf("Destroying %s...\n", appID)

	if err = apps.Delete(c, appID); err != nil {
		return err
	}

	fmt.Printf("done in %ds\n", int(time.Since(startTime).Seconds()))

	if gitSession {
		return git.DeleteRemote(appID)
	}

	return nil
}
619878
func (s *Service) AddOnDelete(ctx context.Context, appIdentity string, addOnIdentity string) (*AddOn, error) {
	var addOn AddOn
	return &addOn, s.Delete(ctx, &addOn, fmt.Sprintf("/apps/%v/addons/%v", appIdentity, addOnIdentity))
}
891838
func (a *Application) Destroy() (err error) {
	defer func() {
		logger.Tracef("Application(%s).Destroy() => %v", a.doc.Name, err)
		if err == nil {
			// This is a white lie; the document might actually be removed.
			a.doc.Life = Dying
		}
	}()
	return a.st.ApplyOperation(a.DestroyOperation())
}
957308
func (m *Model) removeApplication(ch RemoveApplication) error {
	defer m.doLocked()()

	app, ok := m.applications[ch.Name]
	if ok {
		if err := app.evict(); err != nil {
			return errors.Trace(err)
		}
		delete(m.applications, ch.Name)
	}
	return nil
}
466646
func (e *Empire) Destroy(ctx context.Context, opts DestroyOpts) error {
	if err := opts.Validate(e); err != nil {
		return err
	}

	tx := e.db.Begin()

	if err := e.apps.Destroy(ctx, tx, opts.App); err != nil {
		tx.Rollback()
		return err
	}

	if err := tx.Commit().Error; err != nil {
		return err
	}

	return e.PublishEvent(opts.Event())
}
47358
func (s *Service) AppTransferDelete(ctx context.Context, appTransferIdentity string) (*AppTransfer, error) {
	var appTransfer AppTransfer
	return &appTransfer, s.Delete(ctx, &appTransfer, fmt.Sprintf("/account/app-transfers/%v", appTransferIdentity))
}
804929
func destroyStorage(env environs.Environ, ctx context.ProviderCallContext) error {
	logger.Infof("destroying storage")
	storageProviderTypes, err := env.StorageProviderTypes()
	if err != nil {
		return errors.Trace(err)
	}
	for _, storageProviderType := range storageProviderTypes {
		storageProvider, err := env.StorageProvider(storageProviderType)
		if err != nil {
			return errors.Trace(err)
		}
		if !storageProvider.Dynamic() {
			continue
		}
		if storageProvider.Scope() != storage.ScopeEnviron {
			continue
		}
		storageConfig, err := storage.NewConfig(
			string(storageProviderType),
			storageProviderType,
			map[string]interface{}{},
		)
		if err != nil {
			return errors.Trace(err)
		}
		if storageProvider.Supports(storage.StorageKindBlock) {
			volumeSource, err := storageProvider.VolumeSource(storageConfig)
			if err != nil {
				return errors.Annotate(err, "getting volume source")
			}
			if err := destroyVolumes(volumeSource, ctx); err != nil {
				return errors.Trace(err)
			}
		}
	}
	return nil
}
1000745
func (c *Client) DeleteRoute(appID string, routeID string) error {
	return c.Delete(fmt.Sprintf("/apps/%s/routes/%s", appID, routeID), nil)
}
118007
func (r *AppPackageService) Delete(appId string, version string) *AppPackageDeleteCall {
	c := &AppPackageDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}
	c.appId = appId
	c.version = version
	return c
}
1066525
func (app *Application) Quit() {
	ev := &eventAppQuit{}
	ev.SetEventNow()
	if scr := app.screen; scr != nil {
		go func() { scr.PostEventWait(ev) }()
	}
}
1205439
func (st *State) cleanupApplicationsForDyingModel(cleanupArgs []bson.Raw) (err error) {
	var args DestroyModelParams
	switch n := len(cleanupArgs); n {
	case 0:
		// Old cleanups have no args, so follow the old behaviour.
	case 1:
		if err := cleanupArgs[0].Unmarshal(&args); err != nil {
			return errors.Annotate(err, "unmarshalling cleanup 'destroy model' args")
		}
	default:
		return errors.Errorf("expected 0-1 arguments, got %d", n)
	}
	if err := st.removeRemoteApplicationsForDyingModel(args); err != nil {
		return err
	}
	return st.removeApplicationsForDyingModel(args)
}
527238
func Delete(c *client.Client, appID string, username string) error {
	return doDelete(c, fmt.Sprintf("/v1/apps/%s/perms/%s", appID, username))
}
1197212
func (opts *IngestExternalFileOptions) Destroy() {
	C.rocksdb_ingestexternalfileoptions_destroy(opts.c)
	opts.c = nil
}
972152
func (manager *Manager) SessionDestroy(w http.ResponseWriter, r *http.Request) {
	if manager.config.EnableSidInHttpHeader {
		r.Header.Del(manager.config.SessionNameInHttpHeader)
		w.Header().Del(manager.config.SessionNameInHttpHeader)
	}

	cookie, err := r.Cookie(manager.config.CookieName)
	if err != nil || cookie.Value == "" {
		return
	}

	sid, _ := url.QueryUnescape(cookie.Value)
	manager.provider.SessionDestroy(sid)
	if manager.config.EnableSetCookie {
		expiration := time.Now()
		cookie = &http.Cookie{Name: manager.config.CookieName,
			Path:     "/",
			HttpOnly: true,
			Expires:  expiration,
			MaxAge:   -1}

		http.SetCookie(w, cookie)
	}
}
252007
func Destroy(
	controllerName string,
	env ControllerDestroyer,
	ctx context.ProviderCallContext,
	store jujuclient.ControllerStore,
) error {
	details, err := store.ControllerByName(controllerName)
	if errors.IsNotFound(err) {
		// No controller details, nothing to do.
		return nil
	} else if err != nil {
		return errors.Trace(err)
	}
	if err := env.DestroyController(ctx, details.ControllerUUID); err != nil {
		return errors.Trace(err)
	}
	err = store.RemoveController(controllerName)
	if err != nil && !errors.IsNotFound(err) {
		return errors.Trace(err)
	}
	return nil
}
42472
func (a *adapter) Destroy(app string) error {
	// Check first if the map of file pointers even contains the file pointer we want so we can avoid
	// waiting for / obtaining a lock unnecessarily
	f, ok := a.files[app]
	if ok {
		// Ensure no other goroutine is trying to modify the file pointer map while we're trying to
		// clean up
		a.mutex.Lock()
		defer a.mutex.Unlock()
		exists, err := fileExists(f.Name())
		if err != nil {
			return err
		}
		if exists {
			if err := os.Remove(f.Name()); err != nil {
				return err
			}
		}
		delete(a.files, app)
	}
	return nil
}
70366
func (c *Cache) Delete(appname, path string) {
	if ele, hit := c.cache[appname+path]; hit {
		c.removeElement(ele)
	}
}