func()

in pkg/platform/api/platform.go [83:106]


func (p apiPlatform) Prepare(target platform.Update) error {
	updateStatus, err := p.apiClient.GetUpdateStatus()
	if err != nil {
		return err
	}
	if updateStatus.UpdateState != stateAvailable && updateStatus.UpdateState != stateStaged {
		return errors.Errorf("unexpected update state: %s, expecting state to be 'Available' or 'Staged'. update action performed out of band?", updateStatus.UpdateState)
	}

	// Download the update and apply it to the inactive partition
	err = p.apiClient.PrepareUpdate()
	if err != nil {
		return err
	}

	commandResult, err := p.apiClient.GetMostRecentCommand()
	if err != nil {
		return err
	}
	if commandResult.CmdType != commandPrepare || commandResult.CmdStatus != statusSuccess {
		return errors.New("failed to prepare update or update action performed out of band")
	}
	return nil
}