Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Renamed _b2v4 to b2v4, b2 points to b2v4 #1029

Merged
merged 1 commit into from
May 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,43 +122,43 @@ that command.

Thanks to [ApiVer methodology](#apiver-cli-versions-b2-vs-b2v3-b2v4-etc),
you should be perfectly fine using `b2:latest` version even in long-term support scripts,
but make sure to explicitly use `b2v3` command from the docker image as shown below.
but make sure to explicitly use `b2v4` command from the docker image as shown below.

#### Authorization

User can either authorize on each command (`bucket list` is just a example here)

```bash
B2_APPLICATION_KEY=<key> B2_APPLICATION_KEY_ID=<key-id> docker run --rm -e B2_APPLICATION_KEY -e B2_APPLICATION_KEY_ID backblazeit/b2:latest b2v3 bucket list
B2_APPLICATION_KEY=<key> B2_APPLICATION_KEY_ID=<key-id> docker run --rm -e B2_APPLICATION_KEY -e B2_APPLICATION_KEY_ID backblazeit/b2:latest b2v4 bucket list
```

or authorize once and keep the credentials persisted:

```bash
docker run --rm -it -v b2:/root backblazeit/b2:latest b2v3 account authorize
docker run --rm -v b2:/root backblazeit/b2:latest b2v3 bucket list # remember to include `-v` - authorization details are there
docker run --rm -it -v b2:/root backblazeit/b2:latest b2v4 account authorize
docker run --rm -v b2:/root backblazeit/b2:latest b2v4 bucket list # remember to include `-v` - authorization details are there
```

#### Downloading and uploading

When uploading a single file, data can be passed to the container via a pipe:

```bash
cat source_file.txt | docker run -i --rm -v b2:/root backblazeit/b2:latest b2v3 upload-unbound-stream bucket_name - target_file_name
cat source_file.txt | docker run -i --rm -v b2:/root backblazeit/b2:latest b2v4 upload-unbound-stream bucket_name - target_file_name
```

or by mounting local files in the docker container:

```bash
docker run --rm -v b2:/root -v /home/user/path/to/data:/data backblazeit/b2:latest b2v3 file upload bucket_name /data/source_file.txt target_file_name
docker run --rm -v b2:/root -v /home/user/path/to/data:/data backblazeit/b2:latest b2v4 file upload bucket_name /data/source_file.txt target_file_name
```

## ApiVer CLI versions (`b2` vs `b2v3`, `b2v4`, etc.)

Summary:

* in terminal, for best UX, use the latest apiver interface provided by `b2` command
* for long-term support, i.e. in scripts, use `b2v3` command
* for long-term support, i.e. in scripts, use `b2v4` command

Explanation:

Expand All @@ -170,13 +170,13 @@ It provides all the bells and whistles, latest features, and the best performanc
While it's a great version to work with directly, but when writing a reliable, long-running script,
you want to ensure that your script won't break when we release a new version of the `b2` command.

In that case instead of using the `b2` command, you should use a version-bound interface e.g.: `b2v3`.
In that case instead of using the `b2` command, you should use a version-bound interface e.g.: `b2v4`.
This command will always provide the same ApiVer 3 interface, regardless of the semantic version of the `b2` command.
Even if the `b2` command goes into the ApiVer `4`, `6` or even `10` with some major changes,
`b2v3` will still provide the same interface, same commands, and same parameters, with all the security and bug fixes.
`b2v4` will still provide the same interface, same commands, and same parameters, with all the security and bug fixes.
Over time, it might get slower as we may need to emulate some older behaviors, but we'll ensure that it won't break.

You may find the next interface under `_b2v4`, but please note, as suggested by `_` prefix,
You may find the next interface under `_b2v5`, but please note, as suggested by `_` prefix,
it is not yet stable and is not yet covered by guarantees listed above.

## Contrib
Expand Down
2 changes: 1 addition & 1 deletion b2/_internal/b2v3/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
######################################################################

# ruff: noqa: F405
from b2._internal._b2v4.registry import * # noqa
from b2._internal.b2v4.registry import * # noqa
from b2._internal._cli.b2api import _get_b2api_for_profile
from b2._internal.arg_parser import enable_camel_case_arguments
from .rm import Rm
Expand Down
2 changes: 1 addition & 1 deletion b2/_internal/b2v3/rm.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
######################################################################
from __future__ import annotations

from b2._internal._b2v4.registry import B2URIBucketNFolderNameArgMixin, BaseRm
from b2._internal.b2v4.registry import B2URIBucketNFolderNameArgMixin, BaseRm


# NOTE: We need to keep v3 Rm in separate file, because we need to import it in
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
######################################################################
#
# File: b2/_internal/_b2v4/__init__.py
# File: b2/_internal/b2v4/__init__.py
#
# Copyright 2023 Backblaze Inc. All Rights Reserved.
#
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
######################################################################
#
# File: b2/_internal/_b2v4/__main__.py
# File: b2/_internal/b2v4/__main__.py
#
# Copyright 2023 Backblaze Inc. All Rights Reserved.
#
# License https://www.backblaze.com/using_b2_code.html
#
######################################################################

from b2._internal._b2v4.registry import main
from b2._internal.b2v4.registry import main

main()
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
######################################################################
#
# File: b2/_internal/_b2v4/registry.py
# File: b2/_internal/b2v4/registry.py
#
# Copyright 2023 Backblaze Inc. All Rights Reserved.
#
Expand Down
1 change: 1 addition & 0 deletions changelog.d/+apiver-v4.changed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CLI `b2` executable now points to the latest stable ApiVer version, `b2v4`, previously it pointed to `b2v3`.
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ full = [
Homepage = "https://github.com/Backblaze/B2_Command_Line_Tool"

[project.scripts]
b2 = "b2._internal.b2v3.__main__:main"
b2 = "b2._internal.b2v4.__main__:main"
b2v3 = "b2._internal.b2v3.__main__:main"
_b2v4 = "b2._internal._b2v4.__main__:main"
b2v4 = "b2._internal.b2v4.__main__:main"

[build-system]
requires = ["pdm-backend"]
Expand Down
2 changes: 1 addition & 1 deletion test/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def cli_version(request) -> str:
"""
Get CLI version name, i.e. b2v3, _b2v4, etc.
"""
# The default stable version could be provided directly as e.g.: b2v3, but also indirectly as b2.
# The default stable version could be provided directly as e.g.: b2v4, but also indirectly as b2.
# In case there is no direct version, we return the default binary name instead.
raw_cli_version = get_raw_cli_int_version(request.config)
if raw_cli_version is None:
Expand Down
2 changes: 1 addition & 1 deletion test/unit/test_console_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@
from b2sdk.v2.exception import Conflict # Any error for testing fast-fail of the rm command.
from more_itertools import one

from b2._internal._b2v4.registry import Rm as v4Rm
from b2._internal._cli.const import (
B2_APPLICATION_KEY_ENV_VAR,
B2_APPLICATION_KEY_ID_ENV_VAR,
B2_ENVIRONMENT_ENV_VAR,
)
from b2._internal.b2v3.rm import Rm as v3Rm
from b2._internal.b2v4.registry import Rm as v4Rm
from b2._internal.version import VERSION

from .test_base import TestBase
Expand Down
Loading