// Upgrade pulls a plugin, check if the correct privileges are provided and install the plugin.
542081
func (pm *Manager) Upgrade(ctx context.Context, ref reference.Named, name string, metaHeader http.Header, authConfig *types.AuthConfig, privileges types.PluginPrivileges, outStream io.Writer) error {
	return errNotSupported
}
597271
func NeedsUpgrade(bdb *bolt.DB) (bool, error) {
	needsUpgrade := true
	err := bdb.View(func(tx *bolt.Tx) error {
		b := tx.Bucket(metaBucketName)
		if b == nil {
			// No meta bucket; upgrade
			return nil
		}

		v := b.Get(metaVersionKey)
		if len(v) == 0 {
			// No version; upgrade
			return nil
		}

		if !bytes.Equal(v, metaVersion) {
			// Version exists but does not match. Abort.
			return fmt.Errorf("incompatible state version. expected %q but found %q",
				metaVersion, v)
		}

		// Version matches! Assume migrated!
		needsUpgrade = false
		return nil
	})

	return needsUpgrade, err
}
242377
func Upgrade(version string) error {
	term.HideCursor()
	defer term.ShowCursor()

	p := &update.Manager{
		Command: "apex",
		Store: &github.Store{
			Owner:   "apex",
			Repo:    "apex",
			Version: version,
		},
	}

	// fetch releases
	releases, err := p.LatestReleases()
	if err != nil {
		return errors.Wrap(err, "fetching latest release")
	}

	// no updates
	if len(releases) == 0 {
		util.LogPad("No updates available, you're good :)")
		return nil
	}

	// latest
	r := releases[0]

	// find the tarball for this system
	a := r.FindTarball(runtime.GOOS, runtime.GOARCH)
	if a == nil {
		return errors.Errorf("failed to find a binary for %s %s", runtime.GOOS, runtime.GOARCH)
	}

	// download tarball to a tmp dir
	tarball, err := a.DownloadProxy(progressreader.New)
	if err != nil {
		return errors.Wrap(err, "downloading tarball")
	}

	// install it
	if err := p.Install(tarball); err != nil {
		return errors.Wrap(err, "installing")
	}

	term.ClearAll()
	util.LogPad("Updated %s to %s", version, r.Version)

	return nil
}
708114
func upgrade(mgr Manager) error {
	// We'll start by fetching the service's current and latest version.
	ns := mgr.Namespace()
	currentVersion, err := mgr.CurrentVersion(ns)
	if err != nil {
		return err
	}
	versions := mgr.Versions()
	latestVersion := GetLatestVersion(versions)

	switch {
	// If the current version is greater than the latest, then the service
	// is attempting to revert to a previous version that's possibly
	// backwards-incompatible. To prevent this, we'll return an error
	// indicating so.
	case currentVersion > latestVersion:
		return ErrReversion

	// If the current version is behind the latest version, we'll need to
	// apply all of the newer versions in order to catch up to the latest.
	case currentVersion < latestVersion:
		versions := VersionsToApply(currentVersion, versions)
		mgrName := mgr.Name()
		ns := mgr.Namespace()

		for _, version := range versions {
			log.Infof("Applying %v migration #%d", mgrName,
				version.Number)

			// We'll only run a migration if there is one available
			// for this version.
			if version.Migration != nil {
				err := version.Migration(ns)
				if err != nil {
					log.Errorf("Unable to apply %v "+
						"migration #%d: %v", mgrName,
						version.Number, err)
					return err
				}
			}
		}

		// With all of the versions applied, we can now reflect the
		// latest version upon the service.
		if err := mgr.SetVersion(ns, latestVersion); err != nil {
			return err
		}

	// If the current version matches the latest one, there's no upgrade
	// needed and we can safely exit.
	case currentVersion == latestVersion:
	}

	return nil
}
1218677
func (c *ServerContext) Update(token []byte) (authCompleted bool, outputToken []byte, err error) {
	otoken := make([]byte, PackageInfo.MaxToken)
	authDone, n, err2 := updateContext(c.sctxt, otoken, token, nil)
	if err2 != nil {
		return false, nil, err2
	}
	if n == 0 && !authDone {
		return false, nil, errors.New("negotiate token should not be empty")
	}
	otoken = otoken[:n]
	return authDone, otoken, nil
}
161031
func (s *sentFolderDownloadState) update(pullers []*sharedPullerState) []protocol.FileDownloadProgressUpdate {
	var name string
	var updates []protocol.FileDownloadProgressUpdate
	seen := make(map[string]struct{}, len(pullers))

	for _, puller := range pullers {
		name = puller.file.Name

		seen[name] = struct{}{}

		pullerBlockIndexes := puller.Available()
		pullerVersion := puller.file.Version
		pullerBlockIndexesUpdated := puller.AvailableUpdated()
		pullerCreated := puller.created

		localFile, ok := s.files[name]

		// New file we haven't seen before
		if !ok {
			// Only send an update if the file actually has some blocks.
			if len(pullerBlockIndexes) > 0 {
				s.files[name] = &sentFolderFileDownloadState{
					blockIndexes: pullerBlockIndexes,
					updated:      pullerBlockIndexesUpdated,
					version:      pullerVersion,
					created:      pullerCreated,
				}

				updates = append(updates, protocol.FileDownloadProgressUpdate{
					Name:         name,
					Version:      pullerVersion,
					UpdateType:   protocol.UpdateTypeAppend,
					BlockIndexes: pullerBlockIndexes,
				})
			}
			continue
		}

		// Existing file we've already sent an update for.
		if pullerBlockIndexesUpdated.Equal(localFile.updated) && pullerVersion.Equal(localFile.version) {
			// The file state hasn't changed, go to next.
			continue
		}

		if !pullerVersion.Equal(localFile.version) || !pullerCreated.Equal(localFile.created) {
			// The version has changed or the puller was reconstrcuted due to failure.
			// Clean up whatever we had for the old file, and advertise the new file.
			updates = append(updates, protocol.FileDownloadProgressUpdate{
				Name:       name,
				Version:    localFile.version,
				UpdateType: protocol.UpdateTypeForget,
			})
			updates = append(updates, protocol.FileDownloadProgressUpdate{
				Name:         name,
				Version:      pullerVersion,
				UpdateType:   protocol.UpdateTypeAppend,
				BlockIndexes: pullerBlockIndexes,
			})
			localFile.blockIndexes = pullerBlockIndexes
			localFile.updated = pullerBlockIndexesUpdated
			localFile.version = pullerVersion
			localFile.created = pullerCreated
			continue
		}

		// Relies on the fact that sharedPullerState.Available() should always
		// append.
		newBlocks := pullerBlockIndexes[len(localFile.blockIndexes):]

		localFile.blockIndexes = append(localFile.blockIndexes, newBlocks...)
		localFile.updated = pullerBlockIndexesUpdated

		// If there are new blocks, send the update.
		if len(newBlocks) > 0 {
			updates = append(updates, protocol.FileDownloadProgressUpdate{
				Name:         name,
				Version:      localFile.version,
				UpdateType:   protocol.UpdateTypeAppend,
				BlockIndexes: newBlocks,
			})
		}
	}

	// For each file that we are tracking, see if there still is a puller for it
	// if not, the file completed or errored out.
	for name, info := range s.files {
		_, ok := seen[name]
		if !ok {
			updates = append(updates, protocol.FileDownloadProgressUpdate{
				Name:       name,
				Version:    info.version,
				UpdateType: protocol.UpdateTypeForget,
			})
			delete(s.files, name)
		}
	}

	return updates
}
589609
func Upgrade(w http.ResponseWriter, r *http.Request, responseHeader http.Header) (Websocket, error) {
	wsConn, err := upgrader.Upgrade(w, r, responseHeader)
	if err != nil {
		return nil, err
	}
	return Ping(wsConn), nil
}
286835
func (i *VCSInstaller) Update() error {
	debug("updating %s", i.Repo.Remote())
	if i.Repo.IsDirty() {
		return errors.New("plugin repo was modified")
	}
	if err := i.Repo.Update(); err != nil {
		return err
	}
	if !isPlugin(i.Repo.LocalPath()) {
		return ErrMissingMetadata
	}
	return nil
}
126503
func (j *Jenkins) InstallPlugin(name string, version string) error {
	xml := fmt.Sprintf(`<jenkins><install plugin="%s@%s" /></jenkins>`, name, version)
	resp, err := j.Requester.PostXML("/pluginManager/installNecessaryPlugins", xml, j.Raw, map[string]string{})

	if resp.StatusCode != 200 {
		return fmt.Errorf("Invalid status code returned: %d", resp.StatusCode)
	}
	return err
}
1075197
func UpgradeRelease(req *rudderAPI.UpgradeReleaseRequest) (*rudderAPI.UpgradeReleaseResponse, error) {
	conn, err := grpc.Dial(grpcAddr, grpc.WithInsecure())
	if err != nil {
		return nil, err
	}
	defer conn.Close()
	client := rudderAPI.NewReleaseModuleServiceClient(conn)
	return client.UpgradeRelease(context.Background(), req)
}
490618
func (c *FakeLeases) Update(lease *v1beta1.Lease) (result *v1beta1.Lease, err error) {
	obj, err := c.Fake.
		Invokes(testing.NewUpdateAction(leasesResource, c.ns, lease), &v1beta1.Lease{})

	if obj == nil {
		return nil, err
	}
	return obj.(*v1beta1.Lease), err
}
1190689
func (c *FakeRoles) Update(role *authorization.Role) (result *authorization.Role, err error) {
	obj, err := c.Fake.
		Invokes(testing.NewUpdateAction(rolesResource, c.ns, role), &authorization.Role{})

	if obj == nil {
		return nil, err
	}
	return obj.(*authorization.Role), err
}
18762
func (c *FakeRoleBindings) Update(roleBinding *authorization.RoleBinding) (result *authorization.RoleBinding, err error) {
	obj, err := c.Fake.
		Invokes(testing.NewUpdateAction(rolebindingsResource, c.ns, roleBinding), &authorization.RoleBinding{})

	if obj == nil {
		return nil, err
	}
	return obj.(*authorization.RoleBinding), err
}
70455
func (c *Conn) Upgrade(upgrader ConnUpgrader) error {
	// Block reads and writes during the upgrading process
	w := c.createWaiter()
	defer w.Close()

	upgraded, err := upgrader(c.Conn)
	if err != nil {
		return err
	}

	c.Conn = upgraded
	c.init()
	return nil
}
350108
func (u *upgrader) PerformUpgrade() error {
	if err := u.populateAgents(); err != nil {
		return errors.Trace(err)
	}

	if err := u.ensureSystemdFiles(); err != nil {
		return errors.Trace(err)
	}

	return errors.Trace(u.ensureAgentBinaries())
}
1326431
func UpgradeHandlerFunc(eventHandler EventHandler) http.HandlerFunc {
	upgrader := websocket.Upgrader{
		HandshakeTimeout: HandshakeTimeout,
		ReadBufferSize:   ReadBufferSize,
		WriteBufferSize:  WriteBufferSize,
		Subprotocols:     []string{"birect"},
		Error:            ErrorFn,
		CheckOrigin:      CheckOrigin,
	}
	return func(w http.ResponseWriter, r *http.Request) {
		if version := r.Header.Get("Sec-Websocket-Version"); version != "13" {
			http.Error(w, "Sec-Websocket-Version must be 13", 400)
			return
		}
		wsConn, err := upgrader.Upgrade(w, r, nil)
		if err != nil {
			_checkAndGenerateEvent(eventHandler, Error, nil, nil, err)
		} else if wsConn.Subprotocol() != "birect" {
			_checkAndGenerateEvent(eventHandler, Error, nil, nil, errs.New(nil, "Unable to negotiate birect subprotocol"))
		} else {
			newConn(r, wsConn, eventHandler)
		}
	}
}
727547
func (c *FakeOAuthAuthorizeTokens) Update(oAuthAuthorizeToken *oauth.OAuthAuthorizeToken) (result *oauth.OAuthAuthorizeToken, err error) {
	obj, err := c.Fake.
		Invokes(testing.NewRootUpdateAction(oauthauthorizetokensResource, oAuthAuthorizeToken), &oauth.OAuthAuthorizeToken{})
	if obj == nil {
		return nil, err
	}
	return obj.(*oauth.OAuthAuthorizeToken), err
}